[ekiga/ds-gsettings3] Devices: Removed desired_device and simplified code.
- From: Damien Sandras <dsandras src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga/ds-gsettings3] Devices: Removed desired_device and simplified code.
- Date: Wed, 27 Nov 2013 18:59:57 +0000 (UTC)
commit 1a07efefd1203f03840bfe6d4cc500d61700d26d
Author: Damien Sandras <dsandras beip be>
Date: Sat Nov 23 18:06:44 2013 +0100
Devices: Removed desired_device and simplified code.
The desired_device code was correct. However, it was complex and
probably useless.
With the simplification, if the user configured the headset as default
device, and the headset is not present, it will fallback to another
device. If the user plugs the headset, the user will get a popup asking
to use it or not. The desired behavior is still good.
This allowed moving the device selection from the prefs window to the
engine.
lib/engine/audioinput/audioinput-core.cpp | 21 ++----------
lib/engine/audioinput/audioinput-core.h | 3 +-
lib/engine/audiooutput/audiooutput-core.cpp | 16 ++-------
lib/engine/audiooutput/audiooutput-core.h | 2 +-
lib/engine/gui/gtk-frontend/preferences-window.cpp | 35 +++++++-------------
lib/engine/videoinput/videoinput-core.cpp | 18 ++--------
lib/engine/videoinput/videoinput-core.h | 3 +-
7 files changed, 24 insertions(+), 74 deletions(-)
---
diff --git a/lib/engine/audioinput/audioinput-core.cpp b/lib/engine/audioinput/audioinput-core.cpp
index 989654c..692f2bc 100644
--- a/lib/engine/audioinput/audioinput-core.cpp
+++ b/lib/engine/audioinput/audioinput-core.cpp
@@ -201,8 +201,6 @@ AudioInputCore::set_device (const std::string& device_string)
internal_set_device (device);
- desired_device = device;
-
PTRACE(4, "AudioInputCore\tSet device to " << device.source << "/" << device.name);
}
@@ -218,18 +216,10 @@ void AudioInputCore::add_device (const std::string & source, const std::string &
iter++) {
if ((*iter)->has_device (source, device_name, device)) {
- if ( desired_device == device) {
- internal_set_device(desired_device);
- boost::shared_ptr<Ekiga::Notification> notif (new Ekiga::Notification (Ekiga::Notification::Info,
_("New device detected"), device.GetString ()));
- notification_core->push_notification (notif);
- }
- else {
-
- boost::shared_ptr<Ekiga::Notification> notif (new Ekiga::Notification (Ekiga::Notification::Info,
_("New device detected"), device.GetString (), _("Use it"), boost::bind (&AudioInputCore::on_set_device,
(AudioInputCore*) this, device)));
- notification_core->push_notification (notif);
- }
+ device_added(device);
- device_added(device, desired_device == device);
+ boost::shared_ptr<Ekiga::Notification> notif (new Ekiga::Notification (Ekiga::Notification::Info,
_("New device detected"), device.GetString (), _("Use it"), boost::bind (&AudioInputCore::on_set_device,
(AudioInputCore*) this, device)));
+ notification_core->push_notification (notif);
}
}
}
@@ -301,7 +291,6 @@ void AudioInputCore::stop_preview ()
}
internal_close();
- internal_set_manager(desired_device);
preview_config.active = false;
}
@@ -327,8 +316,6 @@ void AudioInputCore::start_stream (unsigned channels, unsigned samplerate, unsig
PTRACE(4, "AudioInputCore\tStarting stream " << channels << "x" << samplerate << "/" << bits_per_sample);
- internal_set_manager(desired_device); /* make sure it is set */
-
if (preview_config.active || stream_config.active) {
PTRACE(1, "AudioInputCore\tTrying to start stream in wrong state");
}
@@ -356,8 +343,6 @@ void AudioInputCore::stop_stream ()
}
internal_close();
- internal_set_manager(desired_device);
-
stream_config.active = false;
average_level = 0;
}
diff --git a/lib/engine/audioinput/audioinput-core.h b/lib/engine/audioinput/audioinput-core.h
index 0679f73..489eadf 100644
--- a/lib/engine/audioinput/audioinput-core.h
+++ b/lib/engine/audioinput/audioinput-core.h
@@ -262,7 +262,7 @@ namespace Ekiga
* a manager claimed support for this device.
* @param device the audio input device that was added.
*/
- boost::signals2::signal<void(AudioInputDevice, bool)> device_added;
+ boost::signals2::signal<void(AudioInputDevice)> device_added;
/** This signal is emitted when an audio input device has been removed from the system.
* This signal will be emitted if remove_device was called with a device name and
@@ -307,7 +307,6 @@ namespace Ekiga
DeviceConfig stream_config;
AudioInputManager* current_manager;
- AudioInputDevice desired_device;
AudioInputDevice current_device;
unsigned current_volume;
unsigned desired_volume;
diff --git a/lib/engine/audiooutput/audiooutput-core.cpp b/lib/engine/audiooutput/audiooutput-core.cpp
index a097345..c61958e 100644
--- a/lib/engine/audiooutput/audiooutput-core.cpp
+++ b/lib/engine/audiooutput/audiooutput-core.cpp
@@ -334,7 +334,6 @@ void AudioOutputCore::set_device(AudioOutputPS ps, const AudioOutputDevice & dev
yield = true;
core_mutex[primary].Wait();
internal_set_primary_device (device);
- desired_primary_device = device;
core_mutex[primary].Signal();
break;
@@ -367,18 +366,11 @@ void AudioOutputCore::add_device (const std::string & sink, const std::string &
iter++) {
if ((*iter)->has_device (sink, device_name, device)) {
- if ( desired_primary_device == device) {
- internal_set_primary_device(desired_primary_device);
- boost::shared_ptr<Ekiga::Notification> notif (new Ekiga::Notification (Ekiga::Notification::Info,
_("New device detected"), device.GetString ()));
- notification_core->push_notification (notif);
- }
- else {
+ device_added(device);
- boost::shared_ptr<Ekiga::Notification> notif (new Ekiga::Notification (Ekiga::Notification::Info,
_("New device detected"), device.GetString (), _("Use it"), boost::bind (&AudioOutputCore::on_set_device,
(AudioOutputCore*) this, device)));
- notification_core->push_notification (notif);
- }
+ boost::shared_ptr<Ekiga::Notification> notif (new Ekiga::Notification (Ekiga::Notification::Info,
_("New device detected"), device.GetString (), _("Use it"), boost::bind (&AudioOutputCore::on_set_device,
(AudioOutputCore*) this, device)));
- device_added(device, desired_primary_device == device);
+ notification_core->push_notification (notif);
}
}
}
@@ -421,7 +413,6 @@ void AudioOutputCore::start (unsigned channels, unsigned samplerate, unsigned bi
return;
}
- internal_set_manager(primary, desired_primary_device); /* may be left undetermined after the last call
*/
average_level = 0;
internal_open(primary, channels, samplerate, bits_per_sample);
@@ -440,7 +431,6 @@ void AudioOutputCore::stop()
average_level = 0;
internal_close(primary);
- internal_set_manager(primary, desired_primary_device);
current_primary_config.active = false;
}
diff --git a/lib/engine/audiooutput/audiooutput-core.h b/lib/engine/audiooutput/audiooutput-core.h
index 6cdcb46..5487ef1 100644
--- a/lib/engine/audiooutput/audiooutput-core.h
+++ b/lib/engine/audiooutput/audiooutput-core.h
@@ -313,7 +313,7 @@ namespace Ekiga
* a manager claimed support for this device.
* @param device the audio output device that was added.
*/
- boost::signals2::signal<void(AudioOutputDevice, bool)> device_added;
+ boost::signals2::signal<void(AudioOutputDevice)> device_added;
/** This signal is emitted when an audio output device has been removed from the system.
* This signal will be emitted if remove_device was called with a device name and
diff --git a/lib/engine/gui/gtk-frontend/preferences-window.cpp
b/lib/engine/gui/gtk-frontend/preferences-window.cpp
index db1c1cd..b8d32db 100644
--- a/lib/engine/gui/gtk-frontend/preferences-window.cpp
+++ b/lib/engine/gui/gtk-frontend/preferences-window.cpp
@@ -454,8 +454,7 @@ static void gm_pw_string_option_menu_update (GtkWidget *option_menu,
const gchar *default_value);
static void gm_pw_string_option_menu_add (GtkWidget *option_menu,
- const gchar *option,
- gboolean active);
+ const gchar *option);
static void gm_pw_string_option_menu_remove (GtkWidget *option_menu,
const gchar *option);
@@ -1234,7 +1233,6 @@ gm_pw_string_option_menu_new (GtkWidget *grid,
std::string conf_string;
- bool found = false;
int cpt = 0;
label = gtk_label_new (label_txt);
@@ -1252,10 +1250,7 @@ gm_pw_string_option_menu_new (GtkWidget *grid,
conf_string = settings->get_string (key);
while (options [cpt]) {
- if (!conf_string.empty () && !g_strcmp0 (conf_string.c_str (), options [cpt]))
- found = true;
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (option_menu), options [cpt], options [cpt]);
-
cpt++;
}
@@ -1353,14 +1348,12 @@ gm_pw_string_option_menu_update (GtkWidget *option_menu,
void
gm_pw_string_option_menu_add (GtkWidget *option_menu,
- const gchar *option,
- gboolean active)
+ const gchar *option)
{
if (!option)
return;
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (option_menu), option, option);
- std::cout << "FIXME: active not handled" << std::endl << std::flush;
}
@@ -2008,13 +2001,12 @@ sound_event_toggled_cb (G_GNUC_UNUSED GtkCellRendererToggle *cell,
gtk_tree_path_free (path);
}
-void on_videoinput_device_added_cb (const Ekiga::VideoInputDevice & device, bool isDesired, GtkWidget
*prefs_window)
+void on_videoinput_device_added_cb (const Ekiga::VideoInputDevice & device, GtkWidget *prefs_window)
{
GmPreferencesWindow *pw = NULL;
g_return_if_fail (prefs_window != NULL);
pw = gm_pw_get_pw (prefs_window);
- gm_pw_string_option_menu_add (pw->video_device, (device.GetString()).c_str(),
- isDesired ? TRUE : FALSE);
+ gm_pw_string_option_menu_add (pw->video_device, (device.GetString()).c_str());
}
void on_videoinput_device_removed_cb (const Ekiga::VideoInputDevice & device, bool, GtkWidget *prefs_window)
@@ -2025,13 +2017,12 @@ void on_videoinput_device_removed_cb (const Ekiga::VideoInputDevice & device, bo
gm_pw_string_option_menu_remove(pw->video_device, (device.GetString()).c_str());
}
-void on_audioinput_device_added_cb (const Ekiga::AudioInputDevice & device, bool isDesired, GtkWidget
*prefs_window)
+void on_audioinput_device_added_cb (const Ekiga::AudioInputDevice & device, GtkWidget *prefs_window)
{
GmPreferencesWindow *pw = NULL;
g_return_if_fail (prefs_window != NULL);
pw = gm_pw_get_pw (prefs_window);
- gm_pw_string_option_menu_add (pw->audio_recorder, (device.GetString()).c_str(),
- isDesired ? TRUE : FALSE);
+ gm_pw_string_option_menu_add (pw->audio_recorder, (device.GetString()).c_str());
}
@@ -2043,15 +2034,13 @@ void on_audioinput_device_removed_cb (const Ekiga::AudioInputDevice & device, bo
gm_pw_string_option_menu_remove(pw->audio_recorder, (device.GetString()).c_str());
}
-void on_audiooutput_device_added_cb (const Ekiga::AudioOutputDevice & device, bool isDesired, GtkWidget
*prefs_window)
+void on_audiooutput_device_added_cb (const Ekiga::AudioOutputDevice & device, GtkWidget *prefs_window)
{
GmPreferencesWindow *pw = NULL;
g_return_if_fail (prefs_window != NULL);
pw = gm_pw_get_pw (prefs_window);
- gm_pw_string_option_menu_add (pw->audio_player, (device.GetString()).c_str(),
- isDesired ? TRUE : FALSE);
- gm_pw_string_option_menu_add (pw->sound_events_output, (device.GetString()).c_str(),
- isDesired ? TRUE : FALSE);
+ gm_pw_string_option_menu_add (pw->audio_player, (device.GetString()).c_str());
+ gm_pw_string_option_menu_add (pw->sound_events_output, (device.GetString()).c_str());
}
void on_audiooutput_device_removed_cb (const Ekiga::AudioOutputDevice & device, bool, GtkWidget
*prefs_window)
@@ -2211,17 +2200,17 @@ preferences_window_new (Ekiga::ServiceCore& core)
boost::signals2::connection conn;
- conn = pw->videoinput_core->device_added.connect (boost::bind (&on_videoinput_device_added_cb, _1, _2,
window));
+ conn = pw->videoinput_core->device_added.connect (boost::bind (&on_videoinput_device_added_cb, _1,
window));
pw->connections.add (conn);
conn = pw->videoinput_core->device_removed.connect (boost::bind (&on_videoinput_device_removed_cb, _1, _2,
window));
pw->connections.add (conn);
- conn = pw->audioinput_core->device_added.connect (boost::bind (&on_audioinput_device_added_cb, _1, _2,
window));
+ conn = pw->audioinput_core->device_added.connect (boost::bind (&on_audioinput_device_added_cb, _1,
window));
pw->connections.add (conn);
conn = pw->audioinput_core->device_removed.connect (boost::bind (&on_audioinput_device_removed_cb, _1, _2,
window));
pw->connections.add (conn);
- conn = pw->audiooutput_core->device_added.connect (boost::bind (&on_audiooutput_device_added_cb, _1, _2,
window));
+ conn = pw->audiooutput_core->device_added.connect (boost::bind (&on_audiooutput_device_added_cb, _1,
window));
pw->connections.add(conn);
conn = pw->audiooutput_core->device_removed.connect (boost::bind (&on_audiooutput_device_removed_cb, _1,
_2, window));
pw->connections.add (conn);
diff --git a/lib/engine/videoinput/videoinput-core.cpp b/lib/engine/videoinput/videoinput-core.cpp
index 1f0bf5f..3af1c7c 100644
--- a/lib/engine/videoinput/videoinput-core.cpp
+++ b/lib/engine/videoinput/videoinput-core.cpp
@@ -333,7 +333,6 @@ void VideoInputCore::set_device(const VideoInputDevice & _device, int channel, V
g_settings_set_string (settings, "input-device", device.GetString ().c_str ());
internal_set_device (device, channel, format);
- desired_device = _device;
}
void VideoInputCore::add_device (const std::string & source, const std::string & device_name, unsigned
capabilities, HalManager* /*manager*/)
@@ -347,18 +346,10 @@ void VideoInputCore::add_device (const std::string & source, const std::string &
iter++) {
if ((*iter)->has_device (source, device_name, capabilities, device)) {
- if ( desired_device == device ) {
- internal_set_device(device, current_channel, current_format);
- boost::shared_ptr<Ekiga::Notification> notif (new Ekiga::Notification (Ekiga::Notification::Info,
_("New device detected"), device.GetString ()));
- notification_core->push_notification (notif);
- }
- else {
-
- boost::shared_ptr<Ekiga::Notification> notif (new Ekiga::Notification (Ekiga::Notification::Info,
_("New device detected"), device.GetString (), _("Use it"), boost::bind (&VideoInputCore::on_set_device,
(VideoInputCore*) this, device)));
- notification_core->push_notification (notif);
- }
+ device_added (device);
- device_added(device, desired_device == device);
+ boost::shared_ptr<Ekiga::Notification> notif (new Ekiga::Notification (Ekiga::Notification::Info,
_("New device detected"), device.GetString (), _("Use it"), boost::bind (&VideoInputCore::on_set_device,
(VideoInputCore*) this, device)));
+ notification_core->push_notification (notif);
}
}
}
@@ -438,7 +429,6 @@ void VideoInputCore::stop_preview ()
if (preview_config.active && !stream_config.active) {
preview_manager->stop();
internal_close();
- internal_set_manager(desired_device, current_channel, current_format);
}
preview_config.active = false;
@@ -490,7 +480,6 @@ void VideoInputCore::stop_stream ()
if ( preview_config != stream_config )
{
internal_close();
- internal_set_manager(desired_device, current_channel, current_format);
internal_open(preview_config.width, preview_config.height, preview_config.fps);
}
preview_manager->start(preview_config.width, preview_config.height);
@@ -498,7 +487,6 @@ void VideoInputCore::stop_stream ()
if (!preview_config.active && stream_config.active) {
internal_close();
- internal_set_manager(desired_device, current_channel, current_format);
}
stream_config.active = false;
diff --git a/lib/engine/videoinput/videoinput-core.h b/lib/engine/videoinput/videoinput-core.h
index 0d49374..2f6f437 100644
--- a/lib/engine/videoinput/videoinput-core.h
+++ b/lib/engine/videoinput/videoinput-core.h
@@ -286,7 +286,7 @@ namespace Ekiga
* a manager claimed support for this device.
* @param device the video input device that was added.
*/
- boost::signals2::signal<void(VideoInputDevice, bool)> device_added;
+ boost::signals2::signal<void(VideoInputDevice)> device_added;
/** This signal is emitted when a video input has been removed from the system.
* This signal will be emitted if remove_device was called with a device name and
@@ -427,7 +427,6 @@ private:
VideoDeviceConfig stream_config;
VideoInputManager* current_manager;
- VideoInputDevice desired_device;
VideoInputDevice current_device;
VideoInputFormat current_format;
int current_channel;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]