[ekiga] Implemented fallback possibility if plugin/device does not exist.



commit 5e1efe8f42c43b7e34cf6b853a74886612e7a7a1
Author: Damien Sandras <dsandras seconix com>
Date:   Wed Oct 14 20:38:23 2009 +0200

    Implemented fallback possibility if plugin/device does not exist.
    
    The cores will fallback to the first detected device in that case.

 lib/engine/audioinput/audioinput-gmconf-bridge.cpp |   24 +++++++++---
 .../audiooutput/audiooutput-gmconf-bridge.cpp      |   39 ++++++++++++--------
 lib/engine/videoinput/videoinput-gmconf-bridge.cpp |   28 ++++++++++-----
 3 files changed, 61 insertions(+), 30 deletions(-)
---
diff --git a/lib/engine/audioinput/audioinput-gmconf-bridge.cpp b/lib/engine/audioinput/audioinput-gmconf-bridge.cpp
index fc95e23..e9831bb 100644
--- a/lib/engine/audioinput/audioinput-gmconf-bridge.cpp
+++ b/lib/engine/audioinput/audioinput-gmconf-bridge.cpp
@@ -60,15 +60,27 @@ void AudioInputCoreConfBridge::on_property_changed (std::string key, GmConfEntry
 
   if (key == AUDIO_DEVICES_KEY "input_device") {
 
+    std::vector <AudioInputDevice> devices;
+    bool found = false;
+    const 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;
+        }
+      }
+    }
     PTRACE(4, "AudioInputCoreConfBridge\tUpdating device");
 
     AudioInputDevice device;
-    if (gm_conf_entry_get_string (entry) == NULL) {
-      PTRACE(1, "AudioInputCoreConfBridge\t" << AUDIO_DEVICES_KEY "input_device" << " is NULL");
-    }
-    else {
-      device.SetFromString(gm_conf_entry_get_string (entry));
-    }
+    if (found)
+      device.SetFromString (value);
+    else 
+      device.SetFromString (devices.begin ()->GetString ());
 
     if ( (device.type == "" )   ||
          (device.source == "")  ||
diff --git a/lib/engine/audiooutput/audiooutput-gmconf-bridge.cpp b/lib/engine/audiooutput/audiooutput-gmconf-bridge.cpp
index c6fb876..8128942 100644
--- a/lib/engine/audiooutput/audiooutput-gmconf-bridge.cpp
+++ b/lib/engine/audiooutput/audiooutput-gmconf-bridge.cpp
@@ -77,18 +77,27 @@ void AudioOutputCoreConfBridge::on_property_changed (std::string key, GmConfEntr
 
   if (key == AUDIO_DEVICES_KEY "output_device") {
 
+    std::vector <AudioOutputDevice> devices;
+    bool found = false;
+    const gchar *value = gm_conf_entry_get_string (entry);
+    audiooutput_core.get_devices (devices);
+    if (value != NULL) {
+      for (std::vector<AudioOutputDevice>::iterator it = devices.begin ();
+           it < devices.end ();
+           it++) {
+        if ((*it).GetString () == value) {
+          found = true;
+          break;
+        }
+      }
+    }
     PTRACE(4, "AudioOutputCoreConfBridge\tUpdating device");
 
     AudioOutputDevice device;
-    const gchar *audio_device = NULL;
-    audio_device = gm_conf_entry_get_string (entry);
-
-    if (audio_device == NULL) {
-      PTRACE(1, "AudioOutputCoreConfBridge\t" << AUDIO_DEVICES_KEY "output_device" << " is NULL");
-    }
-    else {
-      device.SetFromString(audio_device);
-    }
+    if (found)
+      device.SetFromString (value);
+    else 
+      device.SetFromString (devices.begin ()->GetString ());
   
     if ( (device.type   == "" )   ||
          (device.source == "")  ||
@@ -124,7 +133,7 @@ void AudioOutputCoreConfBridge::on_property_changed (std::string key, GmConfEntr
       device.source = AUDIO_OUTPUT_FALLBACK_DEVICE_SOURCE;
       device.name   = AUDIO_OUTPUT_FALLBACK_DEVICE_NAME;
     }
-    audioinput_core.set_device (secondary, device);
+    audiooutput_core.set_device (secondary, device);
   }
 
   if ( (key == SOUND_EVENTS_KEY "busy_tone_sound") ||
@@ -141,7 +150,7 @@ void AudioOutputCoreConfBridge::on_property_changed (std::string key, GmConfEntr
     file_name = c_file_name;
     g_free (c_file_name);
     enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_busy_tone_sound");
-    audioinput_core.add_event (name, file_name, primary, enabled);
+    audiooutput_core.add_event (name, file_name, primary, enabled);
   }
 
   if ( (key == SOUND_EVENTS_KEY "incoming_call_sound") ||
@@ -158,7 +167,7 @@ void AudioOutputCoreConfBridge::on_property_changed (std::string key, GmConfEntr
     file_name = c_file_name;
     g_free (c_file_name);
     enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_incoming_call_sound");
-    audioinput_core.add_event (name, file_name, secondary, enabled);
+    audiooutput_core.add_event (name, file_name, secondary, enabled);
   }
 
   if ( (key == SOUND_EVENTS_KEY "new_message_sound") ||
@@ -175,7 +184,7 @@ void AudioOutputCoreConfBridge::on_property_changed (std::string key, GmConfEntr
     file_name = c_file_name;
     g_free (c_file_name);
     enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_new_message_sound");
-    audioinput_core.add_event (name, file_name, secondary, enabled);
+    audiooutput_core.add_event (name, file_name, secondary, enabled);
 
   }
 
@@ -193,7 +202,7 @@ void AudioOutputCoreConfBridge::on_property_changed (std::string key, GmConfEntr
     file_name = c_file_name;
     g_free (c_file_name);
     enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_new_voicemail_sound");
-    audioinput_core.add_event (name, file_name, secondary, enabled);
+    audiooutput_core.add_event (name, file_name, secondary, enabled);
   }
 
   if ( (key == SOUND_EVENTS_KEY "ring_tone_sound") ||
@@ -210,7 +219,7 @@ void AudioOutputCoreConfBridge::on_property_changed (std::string key, GmConfEntr
     file_name = c_file_name;
     g_free (c_file_name);
     enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_ring_tone_sound");
-    audioinput_core.add_event (name, file_name, primary, enabled);
+    audiooutput_core.add_event (name, file_name, primary, enabled);
   }
 }
 
diff --git a/lib/engine/videoinput/videoinput-gmconf-bridge.cpp b/lib/engine/videoinput/videoinput-gmconf-bridge.cpp
index 1d4cbe3..2feb387 100644
--- a/lib/engine/videoinput/videoinput-gmconf-bridge.cpp
+++ b/lib/engine/videoinput/videoinput-gmconf-bridge.cpp
@@ -88,18 +88,28 @@ void VideoInputCoreConfBridge::on_property_changed (std::string key, GmConfEntry
             (key == VIDEO_DEVICES_KEY "channel") ||
             (key == VIDEO_DEVICES_KEY "format") ) {
 
+    std::vector <VideoInputDevice> devices;
+    bool found = false;
+    gchar *value = gm_conf_get_string (VIDEO_DEVICES_KEY "input_device");
+    videoinput_core.get_devices (devices);
+    if (value != NULL) {
+      for (std::vector<VideoInputDevice>::iterator it = devices.begin ();
+           it < devices.end ();
+           it++) {
+        if ((*it).GetString () == value) {
+          found = true;
+          break;
+        }
+      }
+    }
     PTRACE(4, "VidInputCoreConfBridge\tUpdating device");
 
     VideoInputDevice device;
-    gchar *input_device = NULL;
-    input_device = gm_conf_get_string (VIDEO_DEVICES_KEY "input_device");
-    if (input_device == NULL) {
-      PTRACE(1, "VidInputCoreConfBridge\t" << VIDEO_DEVICES_KEY "input_device" << " is NULL");
-    }
-    else {
-      device.SetFromString(input_device);
-      g_free (input_device);
-    }
+    if (found)
+      device.SetFromString (value);
+    else 
+      device.SetFromString (devices.begin ()->GetString ());
+    g_free (value);
 
     if ( (device.type == "" )   ||
          (device.source == "")  ||



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]