1 #include "adeviceprefs.h"
3 #include "audiodevice.inc"
6 #include "playbackconfig.h"
7 #include "preferences.h"
8 #include "preferencesthread.h"
9 #include "recordconfig.h"
13 #define _(String) gettext(String)
14 #define gettext_noop(String) String
15 #define N_(String) gettext_noop (String)
19 ADevicePrefs::ADevicePrefs(int x,
21 PreferencesWindow *pwindow,
22 PreferencesDialog *dialog,
23 AudioOutConfig *out_config,
24 AudioInConfig *in_config,
27 this->pwindow = pwindow;
28 this->dialog = dialog;
31 this->out_config = out_config;
32 this->in_config = in_config;
36 firewire_channels = 0;
39 firewire_use_dv1394 = 0;
45 ADevicePrefs::~ADevicePrefs()
53 int ADevicePrefs::initialize()
61 driver = &out_config->driver;
64 driver = &in_config->driver;
67 driver = &out_config->driver;
70 this->driver = *driver;
74 dialog->add_subwindow(menu = new ADriverMenu(x,
79 menu->create_objects();
85 case AUDIO_OSS_ENVY24:
95 create_firewire_objs();
101 int ADevicePrefs::get_h()
103 return DEVICE_H + 25;
104 return MAXDEVICES * DEVICE_H + 25;
107 int ADevicePrefs::delete_objects()
112 case AUDIO_OSS_ENVY24:
119 delete_esound_objs();
122 delete_firewire_objs();
129 int ADevicePrefs::delete_oss_objs()
133 delete channels_title;
135 for(int i = 0; i < MAXDEVICES; i++)
137 // delete oss_enable[i];
139 delete oss_channels[i];
145 int ADevicePrefs::delete_esound_objs()
149 delete esound_server;
154 int ADevicePrefs::delete_firewire_objs()
157 delete channel_title;
158 delete firewire_port;
159 delete firewire_channel;
163 delete firewire_path;
172 if(firewire_channels)
174 delete firewire_channels;
175 delete channels_title;
177 firewire_channels = 0;
178 if(firewire_use_dv1394)
180 delete firewire_use_dv1394;
182 firewire_use_dv1394 = 0;
186 int ADevicePrefs::delete_alsa_objs()
189 alsa_drivers->remove_all_objects();
193 delete channels_title;
196 delete alsa_channels;
202 int ADevicePrefs::create_oss_objs()
208 for(int i = 0; i < MAXDEVICES; i++)
210 int x1 = x + menu->get_w() + 5;
214 // output_int = &out_config->oss_enable[i];
217 // output_int = &in_config->oss_enable[i];
220 // output_int = &out_config->oss_enable[i];
223 // dialog->add_subwindow(oss_enable[i] = new OSSEnable(x1, y1 + 20, output_int));
224 // x1 += oss_enable[i]->get_w() + 5;
228 output_char = out_config->oss_out_device[i];
231 output_char = in_config->oss_in_device[i];
234 output_char = out_config->oss_out_device[i];
237 if(i == 0) dialog->add_subwindow(path_title = new BC_Title(x1,
242 dialog->add_subwindow(oss_path[i] = new ADeviceTextBox(x1,
246 x1 += oss_path[i]->get_w() + 5;
252 output_int = &out_config->oss_out_bits;
255 output_int = &in_config->oss_in_bits;
258 output_int = &out_config->oss_out_bits;
261 if(i == 0) dialog->add_subwindow(bits_title = new BC_Title(x1, y, _("Bits:"), MEDIUMFONT, BLACK));
262 oss_bits = new BitsPopup(dialog,
271 oss_bits->create_objects();
274 x1 += oss_bits->get_w() + 5;
278 output_int = &out_config->oss_out_channels[i];
281 output_int = &in_config->oss_in_channels[i];
284 output_int = &out_config->oss_out_channels[i];
287 if(i == 0) dialog->add_subwindow(channels_title = new BC_Title(x1, y1, _("Channels:"), MEDIUMFONT, BLACK));
288 dialog->add_subwindow(oss_channels[i] = new ADeviceIntBox(x1, y1 + 20, output_int));
296 int ADevicePrefs::create_alsa_objs()
303 int x1 = x + menu->get_w() + 5;
305 ArrayList<char*> *alsa_titles = new ArrayList<char*>;
306 AudioALSA::list_devices(alsa_titles);
308 alsa_drivers = new ArrayList<BC_ListBoxItem*>;
309 for(int i = 0; i < alsa_titles->total; i++)
310 alsa_drivers->append(new BC_ListBoxItem(alsa_titles->values[i]));
311 alsa_titles->remove_all_objects();
317 output_char = out_config->alsa_out_device;
320 output_char = in_config->alsa_in_device;
323 output_char = out_config->alsa_out_device;
326 dialog->add_subwindow(path_title = new BC_Title(x1, y, _("Device:"), MEDIUMFONT, BLACK));
327 alsa_device = new ALSADevice(dialog,
332 alsa_device->create_objects();
334 x1 += alsa_device->get_w() + 5;
338 output_int = &out_config->alsa_out_bits;
341 output_int = &in_config->alsa_in_bits;
344 output_int = &out_config->alsa_out_bits;
347 dialog->add_subwindow(bits_title = new BC_Title(x1, y, _("Bits:"), MEDIUMFONT, BLACK));
348 alsa_bits = new BitsPopup(dialog,
357 alsa_bits->create_objects();
359 x1 += alsa_bits->get_w() + 5;
363 output_int = &out_config->alsa_out_channels;
366 output_int = &in_config->alsa_in_channels;
369 output_int = &out_config->alsa_out_channels;
372 dialog->add_subwindow(channels_title = new BC_Title(x1, y, _("Channels:"), MEDIUMFONT, BLACK));
373 dialog->add_subwindow(alsa_channels = new ADeviceIntBox(x1, y1 + 20, output_int));
380 int ADevicePrefs::create_esound_objs()
382 int x1 = x + menu->get_w() + 5;
389 output_char = out_config->esound_out_server;
392 output_char = in_config->esound_in_server;
395 output_char = out_config->esound_out_server;
398 dialog->add_subwindow(server_title = new BC_Title(x1, y, _("Server:"), MEDIUMFONT, BLACK));
399 dialog->add_subwindow(esound_server = new ADeviceTextBox(x1, y + 20, output_char));
404 output_int = &out_config->esound_out_port;
407 output_int = &in_config->esound_in_port;
410 output_int = &out_config->esound_out_port;
413 x1 += esound_server->get_w() + 5;
414 dialog->add_subwindow(port_title = new BC_Title(x1, y, _("Port:"), MEDIUMFONT, BLACK));
415 dialog->add_subwindow(esound_port = new ADeviceIntBox(x1, y + 20, output_int));
419 int ADevicePrefs::create_firewire_objs()
421 int x1 = x + menu->get_w() + 5;
429 output_char = out_config->firewire_path;
431 // Our version of raw1394 doesn't support changing the path
439 dialog->add_subwindow(path_title = new BC_Title(x1, y, _("Device Path:"), MEDIUMFONT, BLACK));
440 dialog->add_subwindow(firewire_path = new ADeviceTextBox(x1, y + 20, output_char));
441 x1 += firewire_path->get_w() + 5;
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, BLACK));
458 dialog->add_subwindow(firewire_port = new ADeviceIntBox(x1, y + 20, output_int));
460 x1 += firewire_port->get_w() + 5;
466 output_int = &out_config->firewire_channel;
469 output_int = &in_config->firewire_channel;
472 dialog->add_subwindow(channel_title = new BC_Title(x1, y, _("Channel:"), MEDIUMFONT, BLACK));
473 dialog->add_subwindow(firewire_channel = new ADeviceIntBox(x1, y + 20, output_int));
474 x1 += firewire_channel->get_w() + 5;
480 output_int = &out_config->firewire_channels;
489 dialog->add_subwindow(channels_title = new BC_Title(x1, y, _("Channels:"), MEDIUMFONT, BLACK));
490 dialog->add_subwindow(firewire_channels = new ADeviceIntBox(x1, y + 20, output_int));
491 x1 += firewire_channels->get_w() + 5;
498 output_int = &out_config->firewire_syt;
507 dialog->add_subwindow(syt_title = new BC_Title(x1, y, _("Syt Offset:"), MEDIUMFONT, BLACK));
508 dialog->add_subwindow(firewire_syt = new ADeviceIntBox(x1, y + 20, output_int));
509 x1 += firewire_syt->get_w() + 5;
512 x1 = x + menu->get_w() + 5;
517 output_int = &out_config->firewire_use_dv1394;
526 dialog->add_subwindow(firewire_use_dv1394 =
527 new BC_CheckBox(x1, y + 45, output_int, _("Use DV1394")));
533 ADriverMenu::ADriverMenu(int x,
535 ADevicePrefs *device_prefs,
538 : BC_PopupMenu(x, y, 125, adriver_to_string(*output), 1)
540 this->output = output;
541 this->do_input = do_input;
542 this->device_prefs = device_prefs;
545 ADriverMenu::~ADriverMenu()
549 void ADriverMenu::create_objects()
551 add_item(new ADriverItem(this, AUDIO_OSS_TITLE, AUDIO_OSS));
552 add_item(new ADriverItem(this, AUDIO_OSS_ENVY24_TITLE, AUDIO_OSS_ENVY24));
555 add_item(new ADriverItem(this, AUDIO_ALSA_TITLE, AUDIO_ALSA));
558 if(!do_input) add_item(new ADriverItem(this, AUDIO_ESOUND_TITLE, AUDIO_ESOUND));
559 // add_item(new ADriverItem(this, AUDIO_NAS_TITLE, AUDIO_NAS));
561 add_item(new ADriverItem(this, AUDIO_1394_TITLE, AUDIO_1394));
564 char* ADriverMenu::adriver_to_string(int driver)
569 sprintf(string, AUDIO_OSS_TITLE);
571 case AUDIO_OSS_ENVY24:
572 sprintf(string, AUDIO_OSS_ENVY24_TITLE);
575 sprintf(string, AUDIO_ESOUND_TITLE);
578 sprintf(string, AUDIO_NAS_TITLE);
581 sprintf(string, AUDIO_ALSA_TITLE);
584 sprintf(string, AUDIO_1394_TITLE);
590 ADriverItem::ADriverItem(ADriverMenu *popup, char *text, int driver)
594 this->driver = driver;
597 ADriverItem::~ADriverItem()
601 int ADriverItem::handle_event()
603 popup->set_text(get_text());
604 *(popup->output) = driver;
605 popup->device_prefs->initialize();
612 OSSEnable::OSSEnable(int x, int y, int *output)
613 : BC_CheckBox(x, y, *output)
615 this->output = output;
617 int OSSEnable::handle_event()
619 *output = get_value();
626 ADeviceTextBox::ADeviceTextBox(int x, int y, char *output)
627 : BC_TextBox(x, y, 150, 1, output)
629 this->output = output;
632 int ADeviceTextBox::handle_event()
634 strcpy(output, get_text());
638 ADeviceIntBox::ADeviceIntBox(int x, int y, int *output)
639 : BC_TextBox(x, y, 80, 1, *output)
641 this->output = output;
644 int ADeviceIntBox::handle_event()
646 *output = atol(get_text());
650 ADeviceCheckBox::ADeviceCheckBox(int x, int y, int *output, char *text)
651 : BC_CheckBox(x, y, *output, text)
653 this->output = output;
655 int ADeviceCheckBox::handle_event()
657 *output = get_value();
662 ALSADevice::ALSADevice(PreferencesDialog *dialog,
666 ArrayList<BC_ListBoxItem*> *devices)
667 : BC_PopupTextBox(dialog,
675 this->output = output;
678 ALSADevice::~ALSADevice()
682 int ALSADevice::handle_event()
684 strcpy(output, get_text());