Credit Andrew - fix vorbis audio which was scratchy and ensure aging plugin does...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / adeviceprefs.C
index d93cef30551aa45cb63b1eafa19323d4bc6075a7..92f6c364dce500fc4247dc8518dc9fa93a58c376 100644 (file)
@@ -2,6 +2,7 @@
 /*
  * CINELERRA
  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
+ * Copyright (C) 2003-2016 Cinelerra CV contributors
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -22,6 +23,7 @@
 #include "adeviceprefs.h"
 #include "audioalsa.h"
 #include "audiodevice.inc"
+#include "audiopulse.h"
 #include "bcsignals.h"
 #include "bitspopup.h"
 #include "edl.h"
@@ -62,6 +64,9 @@ void ADevicePrefs::reset()
        follow_audio_config = 0;
        firewire_path = 0;
        firewire_syt = 0;
+       channel_title = 0;
+       firewire_port = 0;
+       firewire_channel = 0;
        syt_title = 0;
        path_title = 0;
 
@@ -86,6 +91,9 @@ void ADevicePrefs::reset()
 
        cine_bits = 0;
        cine_path = 0;
+       server_title = 0;
+       port_title = 0;
+       port = 0;
 }
 
 int ADevicePrefs::initialize(int creation)
@@ -108,11 +116,9 @@ int ADevicePrefs::initialize(int creation)
 
        if(!menu) {
                dialog->add_subwindow(menu = new ADriverMenu(x,
-                       y + 10,
-                       this,
-                       (mode == MODERECORD),
-                       driver));
+                       y + yS(10), this, (mode == MODERECORD), driver));
                menu->create_objects();
+               menu->context_help_set_keyword("Audio Out section");
        }
 
        switch(*driver) {
@@ -123,6 +129,9 @@ int ADevicePrefs::initialize(int creation)
        case AUDIO_ALSA:
                create_alsa_objs();
                break;
+       case AUDIO_PULSE:
+               create_pulse_objs();
+               break;
        case AUDIO_ESOUND:
                create_esound_objs();
                break;
@@ -164,8 +173,11 @@ int ADevicePrefs::delete_objects()
        case AUDIO_ALSA:
                delete_alsa_objs();
                break;
+       case AUDIO_PULSE:
+               delete_pulse_objs();
+               break;
        case AUDIO_ESOUND:
-                       delete_esound_objs();
+               delete_esound_objs();
                break;
        case AUDIO_1394:
        case AUDIO_DV1394:
@@ -202,9 +214,9 @@ int ADevicePrefs::delete_oss_objs()
 int ADevicePrefs::delete_esound_objs()
 {
        delete server_title;
+       delete server;
        delete port_title;
-       delete esound_server;
-       delete esound_port;
+       delete port;
        return 0;
 }
 
@@ -243,6 +255,15 @@ int ADevicePrefs::delete_alsa_objs()
        return 0;
 }
 
+int ADevicePrefs::delete_pulse_objs()
+{
+#ifdef HAVE_PULSE
+       delete server_title;
+       delete server;
+#endif
+       return 0;
+}
+
 int ADevicePrefs::delete_dvb_objs()
 {
        delete dvb_adapter_title;
@@ -270,7 +291,7 @@ int ADevicePrefs::create_oss_objs()
        BC_Resources *resources = BC_WindowBase::get_resources();
 
        for(int i = 0; i < MAXDEVICES; i++) {
-               int x1 = x + menu->get_w() + 5;
+               int x1 = x + menu->get_w() + xS(5);
 #if 0
                switch(mode) {
                case MODEPLAY:
@@ -283,7 +304,7 @@ int ADevicePrefs::create_oss_objs()
                        output_int = &out_config->oss_enable[i];
                        break;
                }
-               dialog->add_subwindow(oss_enable[i] = new OSSEnable(x1, y1 + 20, output_int));
+               dialog->add_subwindow(oss_enable[i] = new OSSEnable(x1, y1 + yS(20), output_int));
                x1 += oss_enable[i]->get_w() + margin;
 #endif
                switch(mode) {
@@ -302,11 +323,13 @@ int ADevicePrefs::create_oss_objs()
                        path_title = new BC_Title(x1, y, _("Device path:"),
                                MEDIUMFONT, resources->text_default);
                        dialog->add_subwindow(path_title);
+                       path_title->context_help_set_keyword("Audio Out section");
                }
 
                oss_path[i] = new ADeviceTextBox(
                        x1, y1 + path_title->get_h() + margin, output_char);
                dialog->add_subwindow(oss_path[i]);
+               oss_path[i]->context_help_set_keyword("Audio Out section");
                x1 += oss_path[i]->get_w() + margin;
                if(i == 0) {
                        switch(mode) {
@@ -323,6 +346,7 @@ int ADevicePrefs::create_oss_objs()
                        bits_title = new BC_Title(x1, y, _("Bits:"),
                                        MEDIUMFONT, resources->text_default);
                        dialog->add_subwindow(bits_title);
+                       bits_title->context_help_set_keyword("Audio Out section");
                        oss_bits = new BitsPopup(dialog,
                                x1, y1 + bits_title->get_h() + margin, 
                                output_int, 0, 0, 0, 0, 1);
@@ -351,6 +375,7 @@ int ADevicePrefs::create_alsa_objs()
        ArrayList<char*> *alsa_titles = new ArrayList<char*>;
        alsa_titles->set_array_delete();
        AudioALSA::list_devices(alsa_titles, 0, mode);
+       AudioALSA::add_pulse_devices(mode, alsa_titles, 0);
 
        alsa_drivers = new ArrayList<BC_ListBoxItem*>;
        for(int i = 0; i < alsa_titles->total; i++)
@@ -372,13 +397,14 @@ int ADevicePrefs::create_alsa_objs()
        path_title = new BC_Title(x1, y, _("Device:"),
                        MEDIUMFONT, resources->text_default);
        dialog->add_subwindow(path_title);
+       path_title->context_help_set_keyword("Audio Out section");
        y1 += path_title->get_h() + margin;
        alsa_device = new ALSADevice(dialog,
                x1, y1, output_char, alsa_drivers);
        alsa_device->create_objects();
        int x2 = x1;
 
-       x1 += alsa_device->get_w() + 5;
+       x1 += alsa_device->get_w() + xS(5);
        switch(mode) {
        case MODEPLAY:
                output_int = &out_config->alsa_out_bits;
@@ -393,6 +419,7 @@ int ADevicePrefs::create_alsa_objs()
        bits_title = new BC_Title(x1, y, _("Bits:"),
                        MEDIUMFONT, resources->text_default);
        dialog->add_subwindow(bits_title);
+       bits_title->context_help_set_keyword("Audio Out section");
        y1 = y + bits_title->get_h() + margin;
        alsa_bits = new BitsPopup(dialog,
                        x1, y1, output_int, 0, 0, 0, 0, 1);
@@ -406,16 +433,15 @@ int ADevicePrefs::create_alsa_objs()
                                &out_config->interrupt_workaround,
                                _("Stop playback locks up."));
                dialog->add_subwindow(alsa_workaround);
+               alsa_workaround->context_help_set_keyword("Audio Out section");
        }
-
 #endif
-
        return 0;
 }
 
 int ADevicePrefs::create_esound_objs()
 {
-       int x1 = x + menu->get_w() + 5;
+       int x1 = x + menu->get_w() + xS(5);
        char *output_char = 0;
        int *output_int = 0;
        BC_Resources *resources = BC_WindowBase::get_resources();
@@ -434,8 +460,10 @@ int ADevicePrefs::create_esound_objs()
        server_title = new BC_Title(x1, y, _("Server:"),
                        MEDIUMFONT, resources->text_default);
        dialog->add_subwindow(server_title);
-       esound_server = new ADeviceTextBox(x1, y + 20, output_char);
-       dialog->add_subwindow(esound_server);
+       server_title->context_help_set_keyword("Audio Out section");
+       server = new ADeviceTextBox(x1, y + yS(20), output_char);
+       dialog->add_subwindow(server);
+       server->context_help_set_keyword("Audio Out section");
 
        switch(mode) {
        case MODEPLAY:
@@ -448,18 +476,22 @@ int ADevicePrefs::create_esound_objs()
                output_int = &out_config->esound_out_port;
                break;
        }
-       x1 += esound_server->get_w() + 5;
+       x1 += server->get_w() + xS(5);
        port_title = new BC_Title(x1, y, _("Port:"),
                        MEDIUMFONT, resources->text_default);
        dialog->add_subwindow(port_title);
-       esound_port = new ADeviceIntBox(x1, y + 20, output_int);
-       dialog->add_subwindow(esound_port);
+       port_title->context_help_set_keyword("Audio Out section");
+       port = new ADeviceIntBox(x1, y + yS(20), output_int);
+       dialog->add_subwindow(port);
+       port->context_help_set_keyword("Audio Out section");
        return 0;
 }
 
 int ADevicePrefs::create_firewire_objs()
 {
-       int x1 = x + menu->get_w() + 5;
+       int xs5 = xS(5);
+       int ys20 = yS(20);
+       int x1 = x + menu->get_w() + xs5;
        int *output_int = 0;
        char *output_char = 0;
        BC_Resources *resources = BC_WindowBase::get_resources();
@@ -481,8 +513,10 @@ int ADevicePrefs::create_firewire_objs()
 
        if(output_char) {
                dialog->add_subwindow(path_title = new BC_Title(x1, y, _("Device Path:"), MEDIUMFONT, resources->text_default));
-               dialog->add_subwindow(firewire_path = new ADeviceTextBox(x1, y + 20, output_char));
-               x1 += firewire_path->get_w() + 5;
+               path_title->context_help_set_keyword("Audio Out section");
+               dialog->add_subwindow(firewire_path = new ADeviceTextBox(x1, y + ys20, output_char));
+               firewire_path->context_help_set_keyword("Audio Out section");
+               x1 += firewire_path->get_w() + xs5;
        }
 
 // Firewire port
@@ -503,10 +537,12 @@ int ADevicePrefs::create_firewire_objs()
        port_title = new BC_Title(x1, y, _("Port:"),
                        MEDIUMFONT, resources->text_default);
        dialog->add_subwindow(port_title);
-       firewire_port = new ADeviceIntBox(x1, y + 20, output_int);
+       port_title->context_help_set_keyword("Audio Out section");
+       firewire_port = new ADeviceIntBox(x1, y + ys20, output_int);
        dialog->add_subwindow(firewire_port);
+       firewire_port->context_help_set_keyword("Audio Out section");
 
-       x1 += firewire_port->get_w() + 5;
+       x1 += firewire_port->get_w() + xs5;
 
 // Firewire channel
        switch(mode) {
@@ -523,9 +559,11 @@ int ADevicePrefs::create_firewire_objs()
        channel_title = new BC_Title(x1, y, _("Channel:"),
                        MEDIUMFONT, resources->text_default);
        dialog->add_subwindow(channel_title);
-       firewire_channel = new ADeviceIntBox(x1, y + 20, output_int);
+       channel_title->context_help_set_keyword("Audio Out section");
+       firewire_channel = new ADeviceIntBox(x1, y + ys20, output_int);
        dialog->add_subwindow(firewire_channel);
-       x1 += firewire_channel->get_w() + 5;
+       firewire_channel->context_help_set_keyword("Audio Out section");
+       x1 += firewire_channel->get_w() + xs5;
 
 // Syt offset
        switch(mode) {
@@ -547,9 +585,11 @@ int ADevicePrefs::create_firewire_objs()
                syt_title = new BC_Title(x1, y, _("Syt Offset:"),
                                MEDIUMFONT, resources->text_default);
                dialog->add_subwindow(syt_title);
-               firewire_syt = new ADeviceIntBox(x1, y + 20, output_int);
+               syt_title->context_help_set_keyword("Audio Out section");
+               firewire_syt = new ADeviceIntBox(x1, y + ys20, output_int);
                dialog->add_subwindow(firewire_syt);
-               x1 += firewire_syt->get_w() + 5;
+               firewire_syt->context_help_set_keyword("Audio Out section");
+               x1 += firewire_syt->get_w() + xs5;
        }
 
        return 0;
@@ -559,60 +599,92 @@ int ADevicePrefs::create_firewire_objs()
 
 int ADevicePrefs::create_dvb_objs()
 {
-       int x1 = x + menu->get_w() + 30;
-       int y1 = y + 10;
+       int x1 = x + menu->get_w() + xS(30);
+       int y1 = y + yS(10);
        char *output_char = in_config->dvb_in_adapter;
-       int y2 = y1 - BC_Title::calculate_h(dialog, _("DVB Adapter:"), MEDIUMFONT) - 5;
+       int y2 = y1 - BC_Title::calculate_h(dialog, _("DVB Adapter:"), MEDIUMFONT) - yS(5);
        BC_Resources *resources = BC_WindowBase::get_resources();
        dvb_adapter_title = new BC_Title(x1, y2, _("DVB Adapter:"),
                        MEDIUMFONT, resources->text_default);
        dialog->add_subwindow(dvb_adapter_title);
+       dvb_adapter_title->context_help_set_keyword("Audio Out section");
        dvb_adapter_path = new ADeviceTextBox(x1, y1, output_char);
        dialog->add_subwindow(dvb_adapter_path);
-       int x2 = x1 + dvb_adapter_path->get_w() + 5;
+       dvb_adapter_path->context_help_set_keyword("Audio Out section");
+       int x2 = x1 + dvb_adapter_path->get_w() + xS(5);
        dvb_device_title = new BC_Title(x2, y2, _("dev:"),
                        MEDIUMFONT, resources->text_default);
        dialog->add_subwindow(dvb_device_title);
+       dvb_device_title->context_help_set_keyword("Audio Out section");
        int *output_int = &in_config->dvb_in_device;
-       dvb_adapter_device = new ADeviceTumbleBox(this, x2, y1, output_int, 0, 9, 20);
+       dvb_adapter_device = new ADeviceTumbleBox(this, x2, y1, output_int, 0, 9, xS(20));
        dvb_adapter_device->create_objects();
-       x2 += dvb_device_title->get_w() + 30;
+       x2 += dvb_device_title->get_w() + xS(30);
        bits_title = new BC_Title(x2, y2, _("Bits:"),
                        MEDIUMFONT, resources->text_default);
        dialog->add_subwindow(bits_title);
+       bits_title->context_help_set_keyword("Audio Out section");
        output_int = &in_config->dvb_in_bits;
        dvb_bits = new BitsPopup(dialog, x2, y1, output_int, 0, 0, 0, 0, 1);
        dvb_bits->create_objects();
-       x1 += 100;  y1 += dvb_adapter_path->get_h() + 5;
+       x1 += xS(100);  y1 += dvb_adapter_path->get_h() + yS(5);
        output_int =  &in_config->follow_audio;
        follow_audio_config = new BC_CheckBox(x1, y1, output_int, _("Follow audio config"));
        dialog->add_subwindow(follow_audio_config);
+       follow_audio_config->context_help_set_keyword("Audio Out section");
        return 0;
 }
 
 int ADevicePrefs::create_v4l2mpeg_objs()
 {
-       int x1 = x + menu->get_w() + 30;
-       int y1 = y + 10;
-       int y2 = y1 - BC_Title::calculate_h(dialog, _("Bits:"), MEDIUMFONT) - 5;
+       int x1 = x + menu->get_w() + xS(30);
+       int y1 = y + yS(10);
+       int y2 = y1 - BC_Title::calculate_h(dialog, _("Bits:"), MEDIUMFONT) - yS(5);
        BC_Resources *resources = BC_WindowBase::get_resources();
        bits_title = new BC_Title(x1, y2, _("Bits:"),
                        MEDIUMFONT, resources->text_default);
        dialog->add_subwindow(bits_title);
+       bits_title->context_help_set_keyword("Audio Out section");
        int *output_int = &in_config->v4l2_in_bits;
        v4l2_bits = new BitsPopup(dialog, x1, y1, output_int, 0, 0, 0, 0, 1);
        v4l2_bits->create_objects();
-       x1 += v4l2_bits->get_w() + 10;
+       x1 += v4l2_bits->get_w() + xS(10);
        follow_audio_config = new BC_CheckBox(x1, y1,
                        &in_config->follow_audio, _("Follow audio config"));
        dialog->add_subwindow(follow_audio_config);
+       follow_audio_config->context_help_set_keyword("Audio Out section");
+       return 0;
+}
+
+
+int ADevicePrefs::create_pulse_objs()
+{
+#ifdef HAVE_PULSE
+       char *output_char = 0;
+       switch(mode) {
+       case MODEPLAY:
+               output_char = out_config->pulse_out_server;
+               break;
+       case MODERECORD:
+               output_char = in_config->pulse_in_server;
+               break;
+       }
+       int x1 = x, y1 = y;
+       x1 += menu->get_w() + xS(5);
+       dialog->add_subwindow(server_title = new BC_Title(x1, y1,
+               _("Server (blank for default):")));
+       server_title->context_help_set_keyword("Audio Out section");
+       y1 += server_title->get_h() + yS(5);
+       dialog->add_subwindow(server = new ADeviceTextBox(x1, y1, output_char));
+       server->context_help_set_keyword("Audio Out section");
+#endif
        return 0;
 }
 
 
 ADriverMenu::ADriverMenu(int x, int y, ADevicePrefs *device_prefs,
        int do_input, int *output)
- : BC_PopupMenu(x, y, 125, adriver_to_string(*output), 1)
+ : BC_PopupMenu(x, y, xS(125), adriver_to_string(*output), 1)
 {
        this->output = output;
        this->do_input = do_input;
@@ -651,6 +723,9 @@ void ADriverMenu::create_objects()
 #ifdef HAVE_VIDEO4LINUX2
        if(do_input) add_item(new ADriverItem(this, AUDIO_V4L2MPEG_TITLE, AUDIO_V4L2MPEG));
 #endif
+#ifdef HAVE_PULSE
+       add_item(new ADriverItem(this, AUDIO_PULSE_TITLE, AUDIO_PULSE));
+#endif
 }
 
 char* ADriverMenu::adriver_to_string(int driver)
@@ -665,6 +740,9 @@ char* ADriverMenu::adriver_to_string(int driver)
        case AUDIO_ESOUND:
                sprintf(string, AUDIO_ESOUND_TITLE);
                break;
+       case AUDIO_PULSE:
+               sprintf(string, AUDIO_PULSE_TITLE);
+               break;
        case AUDIO_NAS:
                sprintf(string, AUDIO_NAS_TITLE);
                break;
@@ -730,7 +808,7 @@ int OSSEnable::handle_event()
 
 
 ADeviceTextBox::ADeviceTextBox(int x, int y, char *output)
- : BC_TextBox(x, y, 150, 1, output)
+ : BC_TextBox(x, y, xS(150), 1, output)
 {
        this->output = output;
 }
@@ -742,7 +820,7 @@ int ADeviceTextBox::handle_event()
 }
 
 ADeviceIntBox::ADeviceIntBox(int x, int y, int *output)
- : BC_TextBox(x, y, 80, 1, *output)
+ : BC_TextBox(x, y, xS(80), 1, *output)
 {
        this->output = output;
 }
@@ -775,7 +853,7 @@ ALSADevice::ALSADevice(PreferencesDialog *dialog,
        int y,
        char *output,
        ArrayList<BC_ListBoxItem*> *devices)
- : BC_PopupTextBox(dialog, devices, output, x, y, 200, 200)
+ : BC_PopupTextBox(dialog, devices, output, x, y, xS(200), yS(200))
 {
        this->output = output;
 }