Credit Andrew - fix vorbis audio which was scratchy and ensure aging plugin does...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / adeviceprefs.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #include "adeviceprefs.h"
23 #include "audioalsa.h"
24 #include "audiodevice.inc"
25 #include "audiopulse.h"
26 #include "bcsignals.h"
27 #include "bitspopup.h"
28 #include "edl.h"
29 #include "language.h"
30 #include "mwindow.h"
31 #include "playbackconfig.h"
32 #include "preferences.h"
33 #include "preferencesthread.h"
34 #include "recordconfig.h"
35 #include "theme.h"
36 #include <string.h>
37
38 //#define DEVICE_H 50
39
40 ADevicePrefs::ADevicePrefs(int x, int y, PreferencesWindow *pwindow, PreferencesDialog *dialog,
41         AudioOutConfig *out_config, AudioInConfig *in_config, int mode)
42 {
43         reset();
44         this->pwindow = pwindow;
45         this->dialog = dialog;
46         this->driver = -1;
47         this->mode = mode;
48         this->out_config = out_config;
49         this->in_config = in_config;
50         this->x = x;
51         this->y = y;
52 }
53
54 ADevicePrefs::~ADevicePrefs()
55 {
56         delete_objects();
57         if(menu) delete menu;
58 }
59
60 void ADevicePrefs::reset()
61 {
62         menu = 0;
63         follow_audio_config = 0;
64         firewire_path = 0;
65         firewire_syt = 0;
66         channel_title = 0;
67         firewire_port = 0;
68         firewire_channel = 0;
69         syt_title = 0;
70         path_title = 0;
71
72         alsa_drivers = 0;
73         path_title = 0;
74         bits_title = 0;
75         alsa_device = 0;
76         alsa_workaround = 0;
77
78         alsa_bits = 0;
79         oss_bits = 0;
80         dvb_bits = 0;
81         v4l2_bits = 0;
82
83         for(int i = 0; i < MAXDEVICES; i++)
84                 oss_path[i] = 0;
85
86         dvb_adapter_title = 0;
87         dvb_adapter_path = 0;
88         dvb_device_title = 0;
89         dvb_adapter_device = 0;
90
91         cine_bits = 0;
92         cine_path = 0;
93         server_title = 0;
94         port_title = 0;
95         port = 0;
96 }
97
98 int ADevicePrefs::initialize(int creation)
99 {
100         int *driver = 0;
101         delete_objects();
102
103         switch(mode) {
104         case MODEPLAY:
105                 driver = &out_config->driver;
106                 break;
107         case MODERECORD:
108                 driver = &in_config->driver;
109                 break;
110         case MODEDUPLEX:
111                 driver = &out_config->driver;
112                 break;
113         }
114         this->driver = *driver;
115
116         if(!menu) {
117                 dialog->add_subwindow(menu = new ADriverMenu(x,
118                         y + yS(10), this, (mode == MODERECORD), driver));
119                 menu->create_objects();
120                 menu->context_help_set_keyword("Audio Out section");
121         }
122
123         switch(*driver) {
124         case AUDIO_OSS:
125         case AUDIO_OSS_ENVY24:
126                 create_oss_objs();
127                 break;
128         case AUDIO_ALSA:
129                 create_alsa_objs();
130                 break;
131         case AUDIO_PULSE:
132                 create_pulse_objs();
133                 break;
134         case AUDIO_ESOUND:
135                 create_esound_objs();
136                 break;
137         case AUDIO_1394:
138         case AUDIO_DV1394:
139         case AUDIO_IEC61883:
140                 create_firewire_objs();
141                 break;
142         case AUDIO_DVB:
143                 create_dvb_objs();
144                 break;
145         case AUDIO_V4L2MPEG:
146                 create_v4l2mpeg_objs();
147                 break;
148         }
149
150         return 0;
151 }
152
153 int ADevicePrefs::get_h(int recording)
154 {
155         int margin = pwindow->mwindow->theme->widget_border;
156         int result = BC_Title::calculate_h(dialog, "X", MEDIUMFONT) + margin +
157                 BC_TextBox::calculate_h(dialog, MEDIUMFONT, 1, 1);
158         if( !recording ) {
159                 result += BC_CheckBox::calculate_h(dialog) + margin;
160         }
161
162         return result;
163 }
164
165 int ADevicePrefs::delete_objects()
166 {
167         switch(driver) {
168         case AUDIO_OSS:
169         case AUDIO_OSS_ENVY24:
170                 delete_oss_objs();
171                 break;
172         case AUDIO_ALSA:
173                 delete_alsa_objs();
174                 break;
175         case AUDIO_PULSE:
176                 delete_pulse_objs();
177                 break;
178         case AUDIO_ESOUND:
179                 delete_esound_objs();
180                 break;
181         case AUDIO_1394:
182         case AUDIO_DV1394:
183         case AUDIO_IEC61883:
184                 delete_firewire_objs();
185                 break;
186         case AUDIO_DVB:
187                 delete_dvb_objs();
188                 break;
189         case AUDIO_V4L2MPEG:
190                 delete_v4l2mpeg_objs();
191                 break;
192         }
193
194         delete cine_bits;
195         delete cine_path;
196
197         reset();
198         driver = -1;
199         return 0;
200 }
201
202 int ADevicePrefs::delete_oss_objs()
203 {
204         delete path_title;
205         delete bits_title;
206         delete oss_bits;
207
208         for(int i = 0; i < MAXDEVICES; i++)
209                 delete oss_path[i];
210         return 0;
211 }
212
213 int ADevicePrefs::delete_esound_objs()
214 {
215         delete server_title;
216         delete server;
217         delete port_title;
218         delete port;
219         return 0;
220 }
221
222 int ADevicePrefs::delete_firewire_objs()
223 {
224         delete port_title;
225         delete channel_title;
226         delete firewire_port;
227         delete firewire_channel;
228         if(firewire_path)
229         {
230                 delete path_title;
231                 delete firewire_path;
232         }
233         firewire_path = 0;
234         if(firewire_syt)
235         {
236                 delete firewire_syt;
237                 delete syt_title;
238         }
239         firewire_syt = 0;
240         return 0;
241 }
242
243 int ADevicePrefs::delete_alsa_objs()
244 {
245 #ifdef HAVE_ALSA
246         if(alsa_drivers) alsa_drivers->remove_all_objects();
247         delete alsa_drivers;
248         delete path_title;
249         delete bits_title;
250         delete alsa_device;
251         delete alsa_bits;
252         delete alsa_workaround;
253 #endif
254         return 0;
255 }
256
257 int ADevicePrefs::delete_pulse_objs()
258 {
259 #ifdef HAVE_PULSE
260         delete server_title;
261         delete server;
262 #endif
263         return 0;
264 }
265
266 int ADevicePrefs::delete_dvb_objs()
267 {
268         delete dvb_adapter_title;
269         delete dvb_adapter_path;
270         delete dvb_device_title;
271         delete dvb_adapter_device;
272         delete dvb_bits;
273         delete follow_audio_config;
274         return 0;
275 }
276
277 int ADevicePrefs::delete_v4l2mpeg_objs()
278 {
279         delete follow_audio_config;
280         delete v4l2_bits;
281         return 0;
282 }
283
284 int ADevicePrefs::create_oss_objs()
285 {
286         char *output_char = 0;
287         int *output_int = 0;
288         int margin = pwindow->mwindow->theme->widget_border;
289         int y1 = y;
290         BC_Resources *resources = BC_WindowBase::get_resources();
291
292         for(int i = 0; i < MAXDEVICES; i++) {
293                 int x1 = x + menu->get_w() + xS(5);
294 #if 0
295                 switch(mode) {
296                 case MODEPLAY:
297                         output_int = &out_config->oss_enable[i];
298                         break;
299                 case MODERECORD:
300                         output_int = &in_config->oss_enable[i];
301                         break;
302                 case MODEDUPLEX:
303                         output_int = &out_config->oss_enable[i];
304                         break;
305                 }
306                 dialog->add_subwindow(oss_enable[i] = new OSSEnable(x1, y1 + yS(20), output_int));
307                 x1 += oss_enable[i]->get_w() + margin;
308 #endif
309                 switch(mode) {
310                 case MODEPLAY:
311                         output_char = out_config->oss_out_device[i];
312                         break;
313                 case MODERECORD:
314                         output_char = in_config->oss_in_device[i];
315                         break;
316                 case MODEDUPLEX:
317                         output_char = out_config->oss_out_device[i];
318                         break;
319                 }
320
321                 if(i == 0) {
322                         path_title = new BC_Title(x1, y, _("Device path:"),
323                                 MEDIUMFONT, resources->text_default);
324                         dialog->add_subwindow(path_title);
325                         path_title->context_help_set_keyword("Audio Out section");
326                 }
327
328                 oss_path[i] = new ADeviceTextBox(
329                         x1, y1 + path_title->get_h() + margin, output_char);
330                 dialog->add_subwindow(oss_path[i]);
331                 oss_path[i]->context_help_set_keyword("Audio Out section");
332                 x1 += oss_path[i]->get_w() + margin;
333                 if(i == 0) {
334                         switch(mode) {
335                         case MODEPLAY:
336                                 output_int = &out_config->oss_out_bits;
337                                 break;
338                         case MODERECORD:
339                                 output_int = &in_config->oss_in_bits;
340                                 break;
341                         case MODEDUPLEX:
342                                 output_int = &out_config->oss_out_bits;
343                                 break;
344                         }
345                         bits_title = new BC_Title(x1, y, _("Bits:"),
346                                         MEDIUMFONT, resources->text_default);
347                         dialog->add_subwindow(bits_title);
348                         bits_title->context_help_set_keyword("Audio Out section");
349                         oss_bits = new BitsPopup(dialog,
350                                 x1, y1 + bits_title->get_h() + margin, 
351                                 output_int, 0, 0, 0, 0, 1);
352                         oss_bits->create_objects();
353                 }
354
355                 x1 += oss_bits->get_w() + margin;
356 //              y1 += DEVICE_H;
357                 break;
358         }
359
360         return 0;
361 }
362
363 int ADevicePrefs::create_alsa_objs()
364 {
365 #ifdef HAVE_ALSA
366         char *output_char = 0;
367         int *output_int = 0;
368         int margin = pwindow->mwindow->theme->widget_border;
369         BC_Resources *resources = BC_WindowBase::get_resources();
370
371         int x1 = x + menu->get_w() + margin;
372         int y1 = y;
373
374         ArrayList<char*> *alsa_titles = new ArrayList<char*>;
375         alsa_titles->set_array_delete();
376         AudioALSA::list_devices(alsa_titles, 0, mode);
377         AudioALSA::add_pulse_devices(mode, alsa_titles, 0);
378
379         alsa_drivers = new ArrayList<BC_ListBoxItem*>;
380         for(int i = 0; i < alsa_titles->total; i++)
381                 alsa_drivers->append(new BC_ListBoxItem(alsa_titles->values[i]));
382         alsa_titles->remove_all_objects();
383         delete alsa_titles;
384
385         switch(mode) {
386         case MODEPLAY:
387                 output_char = out_config->alsa_out_device;
388                 break;
389         case MODERECORD:
390                 output_char = in_config->alsa_in_device;
391                 break;
392         case MODEDUPLEX:
393                 output_char = out_config->alsa_out_device;
394                 break;
395         }
396         path_title = new BC_Title(x1, y, _("Device:"),
397                         MEDIUMFONT, resources->text_default);
398         dialog->add_subwindow(path_title);
399         path_title->context_help_set_keyword("Audio Out section");
400         y1 += path_title->get_h() + margin;
401         alsa_device = new ALSADevice(dialog,
402                 x1, y1, output_char, alsa_drivers);
403         alsa_device->create_objects();
404         int x2 = x1;
405
406         x1 += alsa_device->get_w() + xS(5);
407         switch(mode) {
408         case MODEPLAY:
409                 output_int = &out_config->alsa_out_bits;
410                 break;
411         case MODERECORD:
412                 output_int = &in_config->alsa_in_bits;
413                 break;
414         case MODEDUPLEX:
415                 output_int = &out_config->alsa_out_bits;
416                 break;
417         }
418         bits_title = new BC_Title(x1, y, _("Bits:"),
419                         MEDIUMFONT, resources->text_default);
420         dialog->add_subwindow(bits_title);
421         bits_title->context_help_set_keyword("Audio Out section");
422         y1 = y + bits_title->get_h() + margin;
423         alsa_bits = new BitsPopup(dialog,
424                         x1, y1, output_int, 0, 0, 0, 0, 1);
425         alsa_bits->create_objects();
426
427         y1 += alsa_bits->get_h();
428         x1 = x2;
429
430         if(mode == MODEPLAY) {
431                 alsa_workaround = new BC_CheckBox(x1, y1,
432                                 &out_config->interrupt_workaround,
433                                 _("Stop playback locks up."));
434                 dialog->add_subwindow(alsa_workaround);
435                 alsa_workaround->context_help_set_keyword("Audio Out section");
436         }
437 #endif
438         return 0;
439 }
440
441 int ADevicePrefs::create_esound_objs()
442 {
443         int x1 = x + menu->get_w() + xS(5);
444         char *output_char = 0;
445         int *output_int = 0;
446         BC_Resources *resources = BC_WindowBase::get_resources();
447
448         switch(mode) {
449         case MODEPLAY:
450                 output_char = out_config->esound_out_server;
451                 break;
452         case MODERECORD:
453                 output_char = in_config->esound_in_server;
454                 break;
455         case MODEDUPLEX:
456                 output_char = out_config->esound_out_server;
457                 break;
458         }
459         server_title = new BC_Title(x1, y, _("Server:"),
460                         MEDIUMFONT, resources->text_default);
461         dialog->add_subwindow(server_title);
462         server_title->context_help_set_keyword("Audio Out section");
463         server = new ADeviceTextBox(x1, y + yS(20), output_char);
464         dialog->add_subwindow(server);
465         server->context_help_set_keyword("Audio Out section");
466
467         switch(mode) {
468         case MODEPLAY:
469                 output_int = &out_config->esound_out_port;
470                 break;
471         case MODERECORD:
472                 output_int = &in_config->esound_in_port;
473                 break;
474         case MODEDUPLEX:
475                 output_int = &out_config->esound_out_port;
476                 break;
477         }
478         x1 += server->get_w() + xS(5);
479         port_title = new BC_Title(x1, y, _("Port:"),
480                         MEDIUMFONT, resources->text_default);
481         dialog->add_subwindow(port_title);
482         port_title->context_help_set_keyword("Audio Out section");
483         port = new ADeviceIntBox(x1, y + yS(20), output_int);
484         dialog->add_subwindow(port);
485         port->context_help_set_keyword("Audio Out section");
486         return 0;
487 }
488
489 int ADevicePrefs::create_firewire_objs()
490 {
491         int xs5 = xS(5);
492         int ys20 = yS(20);
493         int x1 = x + menu->get_w() + xs5;
494         int *output_int = 0;
495         char *output_char = 0;
496         BC_Resources *resources = BC_WindowBase::get_resources();
497
498 // Firewire path
499         switch(mode) {
500         case MODEPLAY:
501                 if(driver == AUDIO_DV1394)
502                         output_char = out_config->dv1394_path;
503                 else
504                 if(driver == AUDIO_1394)
505                         output_char = out_config->firewire_path;
506                 break;
507         case MODERECORD:
508                 if(driver == AUDIO_DV1394 || driver == AUDIO_1394)
509                         output_char = in_config->firewire_path;
510                 break;
511         }
512
513         if(output_char) {
514                 dialog->add_subwindow(path_title = new BC_Title(x1, y, _("Device Path:"), MEDIUMFONT, resources->text_default));
515                 path_title->context_help_set_keyword("Audio Out section");
516                 dialog->add_subwindow(firewire_path = new ADeviceTextBox(x1, y + ys20, output_char));
517                 firewire_path->context_help_set_keyword("Audio Out section");
518                 x1 += firewire_path->get_w() + xs5;
519         }
520
521 // Firewire port
522         switch(mode) {
523         case MODEPLAY:
524                 if(driver == AUDIO_DV1394)
525                         output_int = &out_config->dv1394_port;
526                 else
527                         output_int = &out_config->firewire_port;
528                 break;
529         case MODERECORD:
530                 output_int = &in_config->firewire_port;
531                 break;
532         case MODEDUPLEX:
533 //              output_int = &out_config->afirewire_out_port;
534                 break;
535         }
536         port_title = new BC_Title(x1, y, _("Port:"),
537                         MEDIUMFONT, resources->text_default);
538         dialog->add_subwindow(port_title);
539         port_title->context_help_set_keyword("Audio Out section");
540         firewire_port = new ADeviceIntBox(x1, y + ys20, output_int);
541         dialog->add_subwindow(firewire_port);
542         firewire_port->context_help_set_keyword("Audio Out section");
543
544         x1 += firewire_port->get_w() + xs5;
545
546 // Firewire channel
547         switch(mode) {
548         case MODEPLAY:
549                 if(driver == AUDIO_DV1394)
550                         output_int = &out_config->dv1394_channel;
551                 else
552                         output_int = &out_config->firewire_channel;
553                 break;
554         case MODERECORD:
555                 output_int = &in_config->firewire_channel;
556                 break;
557         }
558         channel_title = new BC_Title(x1, y, _("Channel:"),
559                         MEDIUMFONT, resources->text_default);
560         dialog->add_subwindow(channel_title);
561         channel_title->context_help_set_keyword("Audio Out section");
562         firewire_channel = new ADeviceIntBox(x1, y + ys20, output_int);
563         dialog->add_subwindow(firewire_channel);
564         firewire_channel->context_help_set_keyword("Audio Out section");
565         x1 += firewire_channel->get_w() + xs5;
566
567 // Syt offset
568         switch(mode) {
569         case MODEPLAY:
570                 if(driver == AUDIO_DV1394)
571                         output_int = &out_config->dv1394_syt;
572                 else
573                 if(driver == AUDIO_1394)
574                         output_int = &out_config->firewire_syt;
575                 else
576                         output_int = 0;
577                 break;
578         case MODERECORD:
579                 output_int = 0;
580                 break;
581         }
582
583         if(output_int) {
584                 syt_title = new BC_Title(x1, y, _("Syt Offset:"),
585                                 MEDIUMFONT, resources->text_default);
586                 dialog->add_subwindow(syt_title);
587                 syt_title->context_help_set_keyword("Audio Out section");
588                 firewire_syt = new ADeviceIntBox(x1, y + ys20, output_int);
589                 dialog->add_subwindow(firewire_syt);
590                 firewire_syt->context_help_set_keyword("Audio Out section");
591                 x1 += firewire_syt->get_w() + xs5;
592         }
593
594         return 0;
595 }
596
597
598
599 int ADevicePrefs::create_dvb_objs()
600 {
601         int x1 = x + menu->get_w() + xS(30);
602         int y1 = y + yS(10);
603         char *output_char = in_config->dvb_in_adapter;
604         int y2 = y1 - BC_Title::calculate_h(dialog, _("DVB Adapter:"), MEDIUMFONT) - yS(5);
605         BC_Resources *resources = BC_WindowBase::get_resources();
606         dvb_adapter_title = new BC_Title(x1, y2, _("DVB Adapter:"),
607                         MEDIUMFONT, resources->text_default);
608         dialog->add_subwindow(dvb_adapter_title);
609         dvb_adapter_title->context_help_set_keyword("Audio Out section");
610         dvb_adapter_path = new ADeviceTextBox(x1, y1, output_char);
611         dialog->add_subwindow(dvb_adapter_path);
612         dvb_adapter_path->context_help_set_keyword("Audio Out section");
613         int x2 = x1 + dvb_adapter_path->get_w() + xS(5);
614         dvb_device_title = new BC_Title(x2, y2, _("dev:"),
615                         MEDIUMFONT, resources->text_default);
616         dialog->add_subwindow(dvb_device_title);
617         dvb_device_title->context_help_set_keyword("Audio Out section");
618         int *output_int = &in_config->dvb_in_device;
619         dvb_adapter_device = new ADeviceTumbleBox(this, x2, y1, output_int, 0, 9, xS(20));
620         dvb_adapter_device->create_objects();
621         x2 += dvb_device_title->get_w() + xS(30);
622         bits_title = new BC_Title(x2, y2, _("Bits:"),
623                         MEDIUMFONT, resources->text_default);
624         dialog->add_subwindow(bits_title);
625         bits_title->context_help_set_keyword("Audio Out section");
626         output_int = &in_config->dvb_in_bits;
627         dvb_bits = new BitsPopup(dialog, x2, y1, output_int, 0, 0, 0, 0, 1);
628         dvb_bits->create_objects();
629         x1 += xS(100);  y1 += dvb_adapter_path->get_h() + yS(5);
630         output_int =  &in_config->follow_audio;
631         follow_audio_config = new BC_CheckBox(x1, y1, output_int, _("Follow audio config"));
632         dialog->add_subwindow(follow_audio_config);
633         follow_audio_config->context_help_set_keyword("Audio Out section");
634         return 0;
635 }
636
637 int ADevicePrefs::create_v4l2mpeg_objs()
638 {
639         int x1 = x + menu->get_w() + xS(30);
640         int y1 = y + yS(10);
641         int y2 = y1 - BC_Title::calculate_h(dialog, _("Bits:"), MEDIUMFONT) - yS(5);
642         BC_Resources *resources = BC_WindowBase::get_resources();
643         bits_title = new BC_Title(x1, y2, _("Bits:"),
644                         MEDIUMFONT, resources->text_default);
645         dialog->add_subwindow(bits_title);
646         bits_title->context_help_set_keyword("Audio Out section");
647         int *output_int = &in_config->v4l2_in_bits;
648         v4l2_bits = new BitsPopup(dialog, x1, y1, output_int, 0, 0, 0, 0, 1);
649         v4l2_bits->create_objects();
650         x1 += v4l2_bits->get_w() + xS(10);
651         follow_audio_config = new BC_CheckBox(x1, y1,
652                         &in_config->follow_audio, _("Follow audio config"));
653         dialog->add_subwindow(follow_audio_config);
654         follow_audio_config->context_help_set_keyword("Audio Out section");
655         return 0;
656 }
657
658
659 int ADevicePrefs::create_pulse_objs()
660 {
661 #ifdef HAVE_PULSE
662         char *output_char = 0;
663         switch(mode) {
664         case MODEPLAY:
665                 output_char = out_config->pulse_out_server;
666                 break;
667         case MODERECORD:
668                 output_char = in_config->pulse_in_server;
669                 break;
670         }
671         int x1 = x, y1 = y;
672         x1 += menu->get_w() + xS(5);
673         dialog->add_subwindow(server_title = new BC_Title(x1, y1,
674                 _("Server (blank for default):")));
675         server_title->context_help_set_keyword("Audio Out section");
676         y1 += server_title->get_h() + yS(5);
677         dialog->add_subwindow(server = new ADeviceTextBox(x1, y1, output_char));
678         server->context_help_set_keyword("Audio Out section");
679 #endif
680         return 0;
681 }
682
683
684 ADriverMenu::ADriverMenu(int x, int y, ADevicePrefs *device_prefs,
685         int do_input, int *output)
686  : BC_PopupMenu(x, y, xS(125), adriver_to_string(*output), 1)
687 {
688         this->output = output;
689         this->do_input = do_input;
690         this->device_prefs = device_prefs;
691 }
692
693 ADriverMenu::~ADriverMenu()
694 {
695 }
696
697 void ADriverMenu::create_objects()
698 {
699 #ifdef HAVE_ALSA
700         add_item(new ADriverItem(this, AUDIO_ALSA_TITLE, AUDIO_ALSA));
701 #endif
702
703 #ifdef HAVE_OSS
704         add_item(new ADriverItem(this, AUDIO_OSS_TITLE, AUDIO_OSS));
705         add_item(new ADriverItem(this, AUDIO_OSS_ENVY24_TITLE, AUDIO_OSS_ENVY24));
706 #endif
707
708 #ifdef HAVE_ESOUND
709         if(!do_input) add_item(new ADriverItem(this, AUDIO_ESOUND_TITLE, AUDIO_ESOUND));
710 #endif
711
712 #ifdef HAVE_FIREWIRE
713         if(!do_input) add_item(new ADriverItem(this, AUDIO_1394_TITLE, AUDIO_1394));
714         add_item(new ADriverItem(this, AUDIO_DV1394_TITLE, AUDIO_DV1394));
715         add_item(new ADriverItem(this, AUDIO_IEC61883_TITLE, AUDIO_IEC61883));
716 #endif
717
718 #ifdef HAVE_DVB
719         if(do_input) add_item(new ADriverItem(this, AUDIO_DVB_TITLE, AUDIO_DVB));
720 #endif
721
722 #ifdef HAVE_VIDEO4LINUX2
723         if(do_input) add_item(new ADriverItem(this, AUDIO_V4L2MPEG_TITLE, AUDIO_V4L2MPEG));
724 #endif
725 #ifdef HAVE_PULSE
726         add_item(new ADriverItem(this, AUDIO_PULSE_TITLE, AUDIO_PULSE));
727 #endif
728 }
729
730 char* ADriverMenu::adriver_to_string(int driver)
731 {
732         switch(driver) {
733         case AUDIO_OSS:
734                 sprintf(string, AUDIO_OSS_TITLE);
735                 break;
736         case AUDIO_OSS_ENVY24:
737                 sprintf(string, AUDIO_OSS_ENVY24_TITLE);
738                 break;
739         case AUDIO_ESOUND:
740                 sprintf(string, AUDIO_ESOUND_TITLE);
741                 break;
742         case AUDIO_PULSE:
743                 sprintf(string, AUDIO_PULSE_TITLE);
744                 break;
745         case AUDIO_NAS:
746                 sprintf(string, AUDIO_NAS_TITLE);
747                 break;
748         case AUDIO_ALSA:
749                 sprintf(string, AUDIO_ALSA_TITLE);
750                 break;
751 #ifdef HAVE_FIREWIRE
752         case AUDIO_1394:
753                 sprintf(string, AUDIO_1394_TITLE);
754                 break;
755         case AUDIO_DV1394:
756                 sprintf(string, AUDIO_DV1394_TITLE);
757                 break;
758         case AUDIO_IEC61883:
759                 sprintf(string, AUDIO_IEC61883_TITLE);
760                 break;
761 #endif
762         case AUDIO_DVB:
763                 sprintf(string, AUDIO_DVB_TITLE);
764                 break;
765         case AUDIO_V4L2MPEG:
766                 sprintf(string, AUDIO_V4L2MPEG_TITLE);
767                 break;
768         }
769         return string;
770 }
771
772 ADriverItem::ADriverItem(ADriverMenu *popup, const char *text, int driver)
773  : BC_MenuItem(text)
774 {
775         this->popup = popup;
776         this->driver = driver;
777 }
778
779 ADriverItem::~ADriverItem()
780 {
781 }
782
783 int ADriverItem::handle_event()
784 {
785         popup->set_text(get_text());
786         *(popup->output) = driver;
787         popup->device_prefs->initialize(0);
788         popup->device_prefs->pwindow->show_dialog();
789         return 1;
790 }
791
792
793
794
795 OSSEnable::OSSEnable(int x, int y, int *output)
796  : BC_CheckBox(x, y, *output)
797 {
798         this->output = output;
799 }
800 int OSSEnable::handle_event()
801 {
802         *output = get_value();
803         return 1;
804 }
805
806
807
808
809 ADeviceTextBox::ADeviceTextBox(int x, int y, char *output)
810  : BC_TextBox(x, y, xS(150), 1, output)
811 {
812         this->output = output;
813 }
814
815 int ADeviceTextBox::handle_event()
816 {
817         strcpy(output, get_text());
818         return 1;
819 }
820
821 ADeviceIntBox::ADeviceIntBox(int x, int y, int *output)
822  : BC_TextBox(x, y, xS(80), 1, *output)
823 {
824         this->output = output;
825 }
826
827 int ADeviceIntBox::handle_event()
828 {
829         *output = atol(get_text());
830         return 1;
831 }
832
833
834
835 ADeviceTumbleBox::ADeviceTumbleBox(ADevicePrefs *prefs,
836         int x, int y, int *output, int min, int max, int text_w)
837  : BC_TumbleTextBox(prefs->dialog, *output, min, max, x, y, text_w)
838 {
839         this->output = output;
840 }
841
842 int ADeviceTumbleBox::handle_event()
843 {
844         *output = atol(get_text());
845         return 1;
846 }
847
848
849
850 ALSADevice::ALSADevice(PreferencesDialog *dialog,
851         int x,
852         int y,
853         char *output,
854         ArrayList<BC_ListBoxItem*> *devices)
855  : BC_PopupTextBox(dialog, devices, output, x, y, xS(200), yS(200))
856 {
857         this->output = output;
858 }
859
860 ALSADevice::~ALSADevice()
861 {
862 }
863
864 int ALSADevice::handle_event()
865 {
866         strcpy(output, get_text());
867         return 1;
868 }
869