1 #include "adeviceprefs.h"
3 #include "audiodevice.inc"
7 #include "playbackconfig.h"
8 #include "preferences.h"
9 #include "preferencesthread.h"
10 #include "recordconfig.h"
15 ADevicePrefs::ADevicePrefs(int x,
17 PreferencesWindow *pwindow,
18 PreferencesDialog *dialog,
19 AudioOutConfig *out_config,
20 AudioInConfig *in_config,
24 this->pwindow = pwindow;
25 this->dialog = dialog;
28 this->out_config = out_config;
29 this->in_config = in_config;
34 ADevicePrefs::~ADevicePrefs()
40 void ADevicePrefs::reset()
59 int ADevicePrefs::initialize(int creation)
67 driver = &out_config->driver;
70 driver = &in_config->driver;
73 driver = &out_config->driver;
76 this->driver = *driver;
80 dialog->add_subwindow(menu = new ADriverMenu(x,
85 menu->create_objects();
91 case AUDIO_OSS_ENVY24:
103 create_firewire_objs();
112 int ADevicePrefs::get_h(int recording)
115 return DEVICE_H + 30;
120 int ADevicePrefs::delete_objects()
125 case AUDIO_OSS_ENVY24:
132 delete_esound_objs();
137 delete_firewire_objs();
149 int ADevicePrefs::delete_oss_objs()
154 for(int i = 0; i < MAXDEVICES; i++)
162 int ADevicePrefs::delete_esound_objs()
166 delete esound_server;
171 int ADevicePrefs::delete_firewire_objs()
174 delete channel_title;
175 delete firewire_port;
176 delete firewire_channel;
180 delete firewire_path;
192 int ADevicePrefs::delete_alsa_objs()
195 alsa_drivers->remove_all_objects();
201 delete alsa_workaround;
207 int ADevicePrefs::create_oss_objs()
212 BC_Resources *resources = BC_WindowBase::get_resources();
214 for(int i = 0; i < MAXDEVICES; i++)
216 int x1 = x + menu->get_w() + 5;
220 // output_int = &out_config->oss_enable[i];
223 // output_int = &in_config->oss_enable[i];
226 // output_int = &out_config->oss_enable[i];
229 // dialog->add_subwindow(oss_enable[i] = new OSSEnable(x1, y1 + 20, output_int));
230 // x1 += oss_enable[i]->get_w() + 5;
234 output_char = out_config->oss_out_device[i];
237 output_char = in_config->oss_in_device[i];
240 output_char = out_config->oss_out_device[i];
243 if(i == 0) dialog->add_subwindow(path_title = new BC_Title(x1,
247 resources->text_default));
248 dialog->add_subwindow(oss_path[i] = new ADeviceTextBox(x1,
252 x1 += oss_path[i]->get_w() + 5;
258 output_int = &out_config->oss_out_bits;
261 output_int = &in_config->oss_in_bits;
264 output_int = &out_config->oss_out_bits;
267 if(i == 0) dialog->add_subwindow(bits_title = new BC_Title(x1, y, _("Bits:"), MEDIUMFONT, resources->text_default));
268 oss_bits = new BitsPopup(dialog,
277 oss_bits->create_objects();
280 x1 += oss_bits->get_w() + 5;
288 int ADevicePrefs::create_alsa_objs()
294 BC_Resources *resources = BC_WindowBase::get_resources();
296 int x1 = x + menu->get_w() + 5;
298 ArrayList<char*> *alsa_titles = new ArrayList<char*>;
299 AudioALSA::list_devices(alsa_titles, 0, mode);
301 alsa_drivers = new ArrayList<BC_ListBoxItem*>;
302 for(int i = 0; i < alsa_titles->total; i++)
303 alsa_drivers->append(new BC_ListBoxItem(alsa_titles->values[i]));
304 alsa_titles->remove_all_objects();
310 output_char = out_config->alsa_out_device;
313 output_char = in_config->alsa_in_device;
316 output_char = out_config->alsa_out_device;
319 dialog->add_subwindow(path_title = new BC_Title(x1, y, _("Device:"), MEDIUMFONT, resources->text_default));
320 alsa_device = new ALSADevice(dialog,
325 alsa_device->create_objects();
328 x1 += alsa_device->get_w() + 5;
332 output_int = &out_config->alsa_out_bits;
335 output_int = &in_config->alsa_in_bits;
338 output_int = &out_config->alsa_out_bits;
341 dialog->add_subwindow(bits_title = new BC_Title(x1, y, _("Bits:"), MEDIUMFONT, resources->text_default));
342 alsa_bits = new BitsPopup(dialog,
351 alsa_bits->create_objects();
353 y1 += alsa_bits->get_h() + 20 + 5;
358 dialog->add_subwindow(alsa_workaround =
361 &out_config->interrupt_workaround,
362 _("Stop playback locks up.")));
371 int ADevicePrefs::create_esound_objs()
373 int x1 = x + menu->get_w() + 5;
376 BC_Resources *resources = BC_WindowBase::get_resources();
381 output_char = out_config->esound_out_server;
384 output_char = in_config->esound_in_server;
387 output_char = out_config->esound_out_server;
390 dialog->add_subwindow(server_title = new BC_Title(x1, y, _("Server:"), MEDIUMFONT, resources->text_default));
391 dialog->add_subwindow(esound_server = new ADeviceTextBox(x1, y + 20, output_char));
396 output_int = &out_config->esound_out_port;
399 output_int = &in_config->esound_in_port;
402 output_int = &out_config->esound_out_port;
405 x1 += esound_server->get_w() + 5;
406 dialog->add_subwindow(port_title = new BC_Title(x1, y, _("Port:"), MEDIUMFONT, resources->text_default));
407 dialog->add_subwindow(esound_port = new ADeviceIntBox(x1, y + 20, output_int));
411 int ADevicePrefs::create_firewire_objs()
413 int x1 = x + menu->get_w() + 5;
415 char *output_char = 0;
416 BC_Resources *resources = BC_WindowBase::get_resources();
422 if(driver == AUDIO_DV1394)
423 output_char = out_config->dv1394_path;
425 if(driver == AUDIO_1394)
426 output_char = out_config->firewire_path;
429 if(driver == AUDIO_DV1394 || driver == AUDIO_1394)
430 output_char = in_config->firewire_path;
436 dialog->add_subwindow(path_title = new BC_Title(x1, y, _("Device Path:"), MEDIUMFONT, resources->text_default));
437 dialog->add_subwindow(firewire_path = new ADeviceTextBox(x1, y + 20, output_char));
438 x1 += firewire_path->get_w() + 5;
445 if(driver == AUDIO_DV1394)
446 output_int = &out_config->dv1394_port;
448 output_int = &out_config->firewire_port;
451 output_int = &in_config->firewire_port;
454 // output_int = &out_config->afirewire_out_port;
457 dialog->add_subwindow(port_title = new BC_Title(x1, y, _("Port:"), MEDIUMFONT, resources->text_default));
458 dialog->add_subwindow(firewire_port = new ADeviceIntBox(x1, y + 20, output_int));
460 x1 += firewire_port->get_w() + 5;
466 if(driver == AUDIO_DV1394)
467 output_int = &out_config->dv1394_channel;
469 output_int = &out_config->firewire_channel;
472 output_int = &in_config->firewire_channel;
475 dialog->add_subwindow(channel_title = new BC_Title(x1, y, _("Channel:"), MEDIUMFONT, resources->text_default));
476 dialog->add_subwindow(firewire_channel = new ADeviceIntBox(x1, y + 20, output_int));
477 x1 += firewire_channel->get_w() + 5;
483 if(driver == AUDIO_DV1394)
484 output_int = &out_config->dv1394_syt;
486 if(driver == AUDIO_1394)
487 output_int = &out_config->firewire_syt;
498 dialog->add_subwindow(syt_title = new BC_Title(x1, y, _("Syt Offset:"), MEDIUMFONT, resources->text_default));
499 dialog->add_subwindow(firewire_syt = new ADeviceIntBox(x1, y + 20, output_int));
500 x1 += firewire_syt->get_w() + 5;
508 int ADevicePrefs::create_cine_objs()
510 BC_Resources *resources = BC_WindowBase::get_resources();
511 int x1 = x + menu->get_w() + 5;
517 ADriverMenu::ADriverMenu(int x,
519 ADevicePrefs *device_prefs,
522 : BC_PopupMenu(x, y, 125, adriver_to_string(*output), 1)
524 this->output = output;
525 this->do_input = do_input;
526 this->device_prefs = device_prefs;
529 ADriverMenu::~ADriverMenu()
533 void ADriverMenu::create_objects()
535 add_item(new ADriverItem(this, AUDIO_OSS_TITLE, AUDIO_OSS));
536 add_item(new ADriverItem(this, AUDIO_OSS_ENVY24_TITLE, AUDIO_OSS_ENVY24));
539 add_item(new ADriverItem(this, AUDIO_ALSA_TITLE, AUDIO_ALSA));
542 if(!do_input) add_item(new ADriverItem(this, AUDIO_ESOUND_TITLE, AUDIO_ESOUND));
543 // add_item(new ADriverItem(this, AUDIO_NAS_TITLE, AUDIO_NAS));
545 if(!do_input) add_item(new ADriverItem(this, AUDIO_1394_TITLE, AUDIO_1394));
546 add_item(new ADriverItem(this, AUDIO_DV1394_TITLE, AUDIO_DV1394));
547 add_item(new ADriverItem(this, AUDIO_IEC61883_TITLE, AUDIO_IEC61883));
549 add_item(new ADriverItem(this, AUDIO_DVB_TITLE, AUDIO_DVB));
552 char* ADriverMenu::adriver_to_string(int driver)
557 sprintf(string, AUDIO_OSS_TITLE);
559 case AUDIO_OSS_ENVY24:
560 sprintf(string, AUDIO_OSS_ENVY24_TITLE);
563 sprintf(string, AUDIO_ESOUND_TITLE);
566 sprintf(string, AUDIO_NAS_TITLE);
569 sprintf(string, AUDIO_ALSA_TITLE);
573 sprintf(string, AUDIO_1394_TITLE);
576 sprintf(string, AUDIO_DV1394_TITLE);
579 sprintf(string, AUDIO_IEC61883_TITLE);
583 sprintf(string, AUDIO_DVB_TITLE);
589 ADriverItem::ADriverItem(ADriverMenu *popup, char *text, int driver)
593 this->driver = driver;
596 ADriverItem::~ADriverItem()
600 int ADriverItem::handle_event()
602 popup->set_text(get_text());
603 *(popup->output) = driver;
604 popup->device_prefs->initialize();
611 OSSEnable::OSSEnable(int x, int y, int *output)
612 : BC_CheckBox(x, y, *output)
614 this->output = output;
616 int OSSEnable::handle_event()
618 *output = get_value();
625 ADeviceTextBox::ADeviceTextBox(int x, int y, char *output)
626 : BC_TextBox(x, y, 150, 1, output)
628 this->output = output;
631 int ADeviceTextBox::handle_event()
633 strcpy(output, get_text());
637 ADeviceIntBox::ADeviceIntBox(int x, int y, int *output)
638 : BC_TextBox(x, y, 80, 1, *output)
640 this->output = output;
643 int ADeviceIntBox::handle_event()
645 *output = atol(get_text());
650 ALSADevice::ALSADevice(PreferencesDialog *dialog,
654 ArrayList<BC_ListBoxItem*> *devices)
655 : BC_PopupTextBox(dialog,
663 this->output = output;
666 ALSADevice::~ALSADevice()
670 int ALSADevice::handle_event()
672 strcpy(output, get_text());