[ekiga] Made the audio input gmconf bridge dumber
- From: Julien Puydt <jpuydt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga] Made the audio input gmconf bridge dumber
- Date: Mon, 27 Sep 2010 09:54:50 +0000 (UTC)
commit 4e34a0c68cd1b590c5b98611410e31f9380fa694
Author: Julien Puydt <jpuydt gnome org>
Date: Sun Sep 26 21:13:31 2010 +0200
Made the audio input gmconf bridge dumber
The audio input core is supposed to think about devices -- the gmconf
bridge doesn't.
It's mostly a code migration : I only added a test for empty "devices",
so we don't get a crash if the case happens.
lib/engine/audioinput/audioinput-core.cpp | 33 ++++++++++++++++++++
lib/engine/audioinput/audioinput-core.h | 8 +++++
lib/engine/audioinput/audioinput-gmconf-bridge.cpp | 29 +-----------------
3 files changed, 42 insertions(+), 28 deletions(-)
---
diff --git a/lib/engine/audioinput/audioinput-core.cpp b/lib/engine/audioinput/audioinput-core.cpp
index 8e03d94..7f1e4ca 100644
--- a/lib/engine/audioinput/audioinput-core.cpp
+++ b/lib/engine/audioinput/audioinput-core.cpp
@@ -146,6 +146,39 @@ void AudioInputCore::set_device(const AudioInputDevice & device)
desired_device = device;
}
+void
+AudioInputCore::set_device (const std::string& device_string)
+{
+ std::vector<AudioInputDevice> devices;
+ AudioInputDevice device;
+ bool found = false;
+
+ get_devices (devices);
+ for (std::vector<AudioInputDevice>::iterator it = devices.begin ();
+ it < devices.end ();
+ it++)
+ if ((*it).GetString () == device_string) {
+ found = true;
+ break;
+ }
+
+ if (found)
+ device.SetFromString (device_string);
+ else if (!devices.empty ())
+ device.SetFromString (devices.begin ()->GetString ());
+
+ if (device.type == ""
+ || device.source == ""
+ || device.name == "") {
+ PTRACE(1, "AudioInputCore\tTried to set malformed device");
+ device.type = AUDIO_INPUT_FALLBACK_DEVICE_TYPE;
+ device.source = AUDIO_INPUT_FALLBACK_DEVICE_SOURCE;
+ device.name = AUDIO_INPUT_FALLBACK_DEVICE_NAME;
+ }
+
+ set_device (device);
+ PTRACE(4, "AudioInputCore\tSet device to " << device.source << "/" << device.name);
+}
void AudioInputCore::add_device (const std::string & source, const std::string & device_name, HalManager* /*manager*/)
{
diff --git a/lib/engine/audioinput/audioinput-core.h b/lib/engine/audioinput/audioinput-core.h
index fe49741..226c056 100644
--- a/lib/engine/audioinput/audioinput-core.h
+++ b/lib/engine/audioinput/audioinput-core.h
@@ -155,6 +155,14 @@ namespace Ekiga
*/
void set_device(const AudioInputDevice & device);
+ /** Set a specific device
+ * This functions sets the current audio input device.
+ * It can also be used while in a stream or in preview mode,
+ * in such a case the old device gets closed and the new device is opened.
+ * @param device_string the new device to be used, as a string
+ */
+ void set_device (const std::string& device_string);
+
/** Inform the core of an added audioinout device
* This function is called by the HalCore when an audio device is added.
* It determines responsible managers for that specific device and informs the
diff --git a/lib/engine/audioinput/audioinput-gmconf-bridge.cpp b/lib/engine/audioinput/audioinput-gmconf-bridge.cpp
index 1659f11..123190e 100644
--- a/lib/engine/audioinput/audioinput-gmconf-bridge.cpp
+++ b/lib/engine/audioinput/audioinput-gmconf-bridge.cpp
@@ -60,37 +60,10 @@ void AudioInputCoreConfBridge::on_property_changed (std::string key, GmConfEntry
if (key == AUDIO_DEVICES_KEY "input_device") {
- std::vector <AudioInputDevice> devices;
- bool found = false;
gchar* value = gm_conf_entry_get_string (entry);
- audioinput_core.get_devices (devices);
if (value != NULL)
- for (std::vector<AudioInputDevice>::iterator it = devices.begin ();
- it < devices.end ();
- it++)
- if ((*it).GetString () == value) {
- found = true;
- break;
- }
-
- AudioInputDevice device;
- if (found)
- device.SetFromString (value);
- else
- device.SetFromString (devices.begin ()->GetString ());
+ audioinput_core.set_device (value);
g_free (value);
-
- if ( (device.type == "" ) ||
- (device.source == "") ||
- (device.name == "" ) ) {
- PTRACE(1, "AudioInputCore\tTried to set malformed device");
- device.type = AUDIO_INPUT_FALLBACK_DEVICE_TYPE;
- device.source = AUDIO_INPUT_FALLBACK_DEVICE_SOURCE;
- device.name = AUDIO_INPUT_FALLBACK_DEVICE_NAME;
- }
-
- audioinput_core.set_device (device);
- PTRACE(4, "AudioInputCoreConfBridge\tSet device to " << device.source << "/" << device.name);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]