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