[ekiga/ds-gsettings3] AudioOutputCore: Added device auto-selection algorithm.
- From: Damien Sandras <dsandras src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga/ds-gsettings3] AudioOutputCore: Added device auto-selection algorithm.
- Date: Mon, 2 Dec 2013 19:24:40 +0000 (UTC)
commit 832d76182e0ec01f2ab6f42145841d50c7f1a95c
Author: Damien Sandras <dsandras beip be>
Date: Sat Nov 30 16:11:18 2013 +0100
AudioOutputCore: Added device auto-selection algorithm.
The responsability to choose the best device for the user is
now left to the Core. The Core will select the best default device in
case the choosen setting is invalid.
On Linux, we respectively prefer PulseAudio, then ALSA, then the first
available device if the others are not found.
lib/engine/audiooutput/audiooutput-core.cpp | 47 ++++++++++++++++-----------
lib/engine/audiooutput/audiooutput-core.h | 16 +++++++++
lib/engine/audiooutput/audiooutput-info.h | 11 +++++-
3 files changed, 53 insertions(+), 21 deletions(-)
---
diff --git a/lib/engine/audiooutput/audiooutput-core.cpp b/lib/engine/audiooutput/audiooutput-core.cpp
index c61958e..15f1d41 100644
--- a/lib/engine/audiooutput/audiooutput-core.cpp
+++ b/lib/engine/audiooutput/audiooutput-core.cpp
@@ -141,7 +141,18 @@ void AudioOutputCore::setup_audio_device (AudioOutputPS device_idx)
AudioOutputDevice device;
std::vector <AudioOutputDevice> devices;
+ AudioOutputDevice device_fallback (AUDIO_OUTPUT_FALLBACK_DEVICE_TYPE,
+ AUDIO_OUTPUT_FALLBACK_DEVICE_SOURCE,
+ AUDIO_OUTPUT_FALLBACK_DEVICE_NAME);
+ AudioOutputDevice device_preferred1 (AUDIO_OUTPUT_PREFERRED_DEVICE_TYPE1,
+ AUDIO_OUTPUT_PREFERRED_DEVICE_SOURCE1,
+ AUDIO_OUTPUT_PREFERRED_DEVICE_NAME1);
+ AudioOutputDevice device_preferred2 (AUDIO_OUTPUT_PREFERRED_DEVICE_TYPE2,
+ AUDIO_OUTPUT_PREFERRED_DEVICE_SOURCE2,
+ AUDIO_OUTPUT_PREFERRED_DEVICE_NAME2);
bool found = false;
+ bool found_preferred1 = false;
+ bool found_preferred2 = false;
gchar* audio_device = NULL;
@@ -159,35 +170,32 @@ void AudioOutputCore::setup_audio_device (AudioOutputPS device_idx)
found = true;
break;
}
+ else if ((*it).GetString () == device_preferred1.GetString ()) {
+ found_preferred1 = true;
+ }
+ else if ((*it).GetString () == device_preferred2.GetString ()) {
+ found_preferred2 = true;
+ }
}
}
if (found) {
device.SetFromString (audio_device);
}
- else {
- if (!devices.empty())
- device.SetFromString (devices.begin ()->GetString ());
- else {
- // if there is no audio device / ptlib plugin, use fallback device below
- device.type = "";
- }
- }
-
- if (audio_device == NULL || !g_strcmp0 (audio_device, "")
- || device.type.empty () || device.source.empty () || device.name.empty ()) {
- PTRACE(1, "AudioOutputCore\tTried to set malformed audio device");
- device.type = AUDIO_OUTPUT_FALLBACK_DEVICE_TYPE;
- device.source = AUDIO_OUTPUT_FALLBACK_DEVICE_SOURCE;
- device.name = AUDIO_OUTPUT_FALLBACK_DEVICE_NAME;
- found = false;
- }
+ else if (found_preferred1)
+ device.SetFromString (device_preferred1.GetString ());
+ else if (found_preferred2)
+ device.SetFromString (device_preferred2.GetString ());
+ else if (!devices.empty ())
+ device.SetFromString (devices.begin ()->GetString ());
+ else
+ device.SetFromString (device_fallback.GetString ());
- PTRACE(1, "AudioOutputCore\tSet " << (device_idx == primary ? "primary" : "secondary") << " audio device
to " << device.name);
if (!found)
g_settings_set_string ((device_idx == primary)?audio_device_settings:sound_events_settings,
"output-device", device.GetString ().c_str ());
- set_device (device_idx, device);
+ else
+ set_device (device_idx, device);
if (audio_device_settings_signals[device_idx] == 0 && device_idx == primary)
audio_device_settings_signals[device_idx] =
@@ -198,6 +206,7 @@ void AudioOutputCore::setup_audio_device (AudioOutputPS device_idx)
g_signal_connect (sound_events_settings, "changed::output-device",
G_CALLBACK (audio_device_changed), this);
g_free (audio_device);
+ PTRACE(1, "AudioOutputCore\tSet " << (device_idx == primary ? "primary" : "secondary") << " audio device
to " << device.name);
}
diff --git a/lib/engine/audiooutput/audiooutput-core.h b/lib/engine/audiooutput/audiooutput-core.h
index 5487ef1..df946b3 100644
--- a/lib/engine/audiooutput/audiooutput-core.h
+++ b/lib/engine/audiooutput/audiooutput-core.h
@@ -47,6 +47,22 @@
#include <ptlib.h>
#include <gio/gio.h>
+#ifdef WIN32
+#define AUDIO_OUTPUT_PREFERRED_DEVICE_TYPE1 "FIXME"
+#define AUDIO_OUTPUT_PREFERRED_DEVICE_SOURCE1 "FIXME"
+#define AUDIO_OUTPUT_PREFERRED_DEVICE_NAME1 "FIXME"
+#define AUDIO_OUTPUT_PREFERRED_DEVICE_TYPE2 "FIXME"
+#define AUDIO_OUTPUT_PREFERRED_DEVICE_SOURCE2 "FIXME"
+#define AUDIO_OUTPUT_PREFERRED_DEVICE_NAME2 "FIXME"
+#else
+#define AUDIO_OUTPUT_PREFERRED_DEVICE_TYPE1 "PTLIB"
+#define AUDIO_OUTPUT_PREFERRED_DEVICE_SOURCE1 "Pulse"
+#define AUDIO_OUTPUT_PREFERRED_DEVICE_NAME1 "PulseAudio"
+#define AUDIO_OUTPUT_PREFERRED_DEVICE_TYPE2 "PTLIB"
+#define AUDIO_OUTPUT_PREFERRED_DEVICE_SOURCE2 "ALSA"
+#define AUDIO_OUTPUT_PREFERRED_DEVICE_NAME2 "Default"
+#endif
+
#define AUDIO_OUTPUT_FALLBACK_DEVICE_TYPE "Ekiga"
#define AUDIO_OUTPUT_FALLBACK_DEVICE_SOURCE "Ekiga"
#define AUDIO_OUTPUT_FALLBACK_DEVICE_NAME "SILENT"
diff --git a/lib/engine/audiooutput/audiooutput-info.h b/lib/engine/audiooutput/audiooutput-info.h
index c1be6af..c4b97fd 100644
--- a/lib/engine/audiooutput/audiooutput-info.h
+++ b/lib/engine/audiooutput/audiooutput-info.h
@@ -30,7 +30,7 @@
* begin : written in 2008 by Matthias Schneider
* copyright : (c) 2008 by Matthias Schneider
* description : Declaration of structs and classes used for communication
- * with the AudioInputManagers
+ * with the AudioOutputManagers
*
*/
@@ -41,7 +41,14 @@
namespace Ekiga
{
- class AudioOutputDevice : public Device {};
+ class AudioOutputDevice : public Device
+ {
+public:
+ AudioOutputDevice () : Device () {}
+ AudioOutputDevice (const std::string & t,
+ const std::string & s,
+ const std::string & n) : Device (t, s, n) {};
+ };
typedef struct AudioOutputSettings {
unsigned volume;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]