Credit Andrew - fix vorbis audio which was scratchy and ensure aging plugin does...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / adeviceprefs.C
index 60c9126978395ee6eb8e1a438bb577699cca054e..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"
@@ -91,7 +93,7 @@ void ADevicePrefs::reset()
        cine_path = 0;
        server_title = 0;
        port_title = 0;
-       esound_port = 0;
+       port = 0;
 }
 
 int ADevicePrefs::initialize(int creation)
@@ -116,6 +118,7 @@ int ADevicePrefs::initialize(int creation)
                dialog->add_subwindow(menu = new ADriverMenu(x,
                        y + yS(10), this, (mode == MODERECORD), driver));
                menu->create_objects();
+               menu->context_help_set_keyword("Audio Out section");
        }
 
        switch(*driver) {
@@ -126,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;
@@ -167,6 +173,9 @@ int ADevicePrefs::delete_objects()
        case AUDIO_ALSA:
                delete_alsa_objs();
                break;
+       case AUDIO_PULSE:
+               delete_pulse_objs();
+               break;
        case AUDIO_ESOUND:
                delete_esound_objs();
                break;
@@ -205,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;
 }
 
@@ -246,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;
@@ -305,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) {
@@ -326,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);
@@ -354,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++)
@@ -375,6 +397,7 @@ 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);
@@ -396,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);
@@ -409,10 +433,9 @@ 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;
 }
 
@@ -437,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 + yS(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:
@@ -451,12 +476,14 @@ int ADevicePrefs::create_esound_objs()
                output_int = &out_config->esound_out_port;
                break;
        }
-       x1 += esound_server->get_w() + xS(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 + yS(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;
 }
 
@@ -486,7 +513,9 @@ int ADevicePrefs::create_firewire_objs()
 
        if(output_char) {
                dialog->add_subwindow(path_title = new BC_Title(x1, y, _("Device Path:"), MEDIUMFONT, resources->text_default));
+               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;
        }
 
@@ -508,8 +537,10 @@ int ADevicePrefs::create_firewire_objs()
        port_title = new BC_Title(x1, y, _("Port:"),
                        MEDIUMFONT, resources->text_default);
        dialog->add_subwindow(port_title);
+       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() + xs5;
 
@@ -528,8 +559,10 @@ int ADevicePrefs::create_firewire_objs()
        channel_title = new BC_Title(x1, y, _("Channel:"),
                        MEDIUMFONT, resources->text_default);
        dialog->add_subwindow(channel_title);
+       channel_title->context_help_set_keyword("Audio Out section");
        firewire_channel = new ADeviceIntBox(x1, y + ys20, output_int);
        dialog->add_subwindow(firewire_channel);
+       firewire_channel->context_help_set_keyword("Audio Out section");
        x1 += firewire_channel->get_w() + xs5;
 
 // Syt offset
@@ -552,8 +585,10 @@ int ADevicePrefs::create_firewire_objs()
                syt_title = new BC_Title(x1, y, _("Syt Offset:"),
                                MEDIUMFONT, resources->text_default);
                dialog->add_subwindow(syt_title);
+               syt_title->context_help_set_keyword("Audio Out section");
                firewire_syt = new ADeviceIntBox(x1, y + ys20, output_int);
                dialog->add_subwindow(firewire_syt);
+               firewire_syt->context_help_set_keyword("Audio Out section");
                x1 += firewire_syt->get_w() + xs5;
        }
 
@@ -572,12 +607,15 @@ int ADevicePrefs::create_dvb_objs()
        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);
+       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, xS(20));
        dvb_adapter_device->create_objects();
@@ -585,6 +623,7 @@ int ADevicePrefs::create_dvb_objs()
        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();
@@ -592,6 +631,7 @@ int ADevicePrefs::create_dvb_objs()
        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;
 }
 
@@ -604,6 +644,7 @@ int ADevicePrefs::create_v4l2mpeg_objs()
        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();
@@ -611,6 +652,32 @@ int ADevicePrefs::create_v4l2mpeg_objs()
        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;
 }
 
@@ -656,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)
@@ -670,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;