ekiga r6194 - in trunk: . lib/engine/audioinput/skel lib/engine/audiooutput/skel lib/engine/hal/dbus
- From: mschneid svn gnome org
- To: svn-commits-list gnome org
- Subject: ekiga r6194 - in trunk: . lib/engine/audioinput/skel lib/engine/audiooutput/skel lib/engine/hal/dbus
- Date: Mon, 14 Apr 2008 19:37:27 +0100 (BST)
Author: mschneid
Date: Mon Apr 14 19:37:27 2008
New Revision: 6194
URL: http://svn.gnome.org/viewvc/ekiga?rev=6194&view=rev
Log:
Allow audio devices to be removed during a call. We fall back to
NULL in that case. Added a small hack to allow hotplugging of Logitech
devices that are badly reported by hal.
Modified:
trunk/ChangeLog
trunk/lib/engine/audioinput/skel/audioinput-core.cpp
trunk/lib/engine/audioinput/skel/audioinput-core.h
trunk/lib/engine/audiooutput/skel/audiooutput-core.cpp
trunk/lib/engine/audiooutput/skel/audiooutput-core.h
trunk/lib/engine/hal/dbus/hal-manager-dbus.cpp
Modified: trunk/lib/engine/audioinput/skel/audioinput-core.cpp
==============================================================================
--- trunk/lib/engine/audioinput/skel/audioinput-core.cpp (original)
+++ trunk/lib/engine/audioinput/skel/audioinput-core.cpp Mon Apr 14 19:37:27 2008
@@ -206,34 +206,8 @@
void AudioInputCore::set_audioinput_device(const AudioInputDevice & audioinput_device)
{
PWaitAndSignal m(var_mutex);
- PTRACE(0, "AudioInputCore\tSetting device: " << audioinput_device.type << "/" << audioinput_device.source << "/" << audioinput_device.device);
- if (preview_config.active)
- preview_manager.stop();
-
- if (preview_config.active || stream_config.active)
- internal_close();
-
- internal_set_device (audioinput_device);
-
- if (preview_config.active) {
- internal_open(preview_config.channels, preview_config.samplerate, preview_config.bits_per_sample);
-
- if ((preview_config.buffer_size > 0) && (preview_config.num_buffers > 0 ) ) {
- if (current_manager)
- current_manager->set_buffer_size (preview_config.buffer_size, preview_config.num_buffers);
- }
-// preview_manager.start();
- }
-
- if (stream_config.active) {
- internal_open(stream_config.channels, stream_config.samplerate, stream_config.bits_per_sample);
-
- if ((stream_config.buffer_size > 0) && (stream_config.num_buffers > 0 ) ) {
- if (current_manager)
- current_manager->set_buffer_size (stream_config.buffer_size, stream_config.num_buffers);
- }
- }
+ internal_set_audioinput_device(audioinput_device);
desired_device = audioinput_device;
}
@@ -394,6 +368,39 @@
audioinputdevice_closed.emit (*manager, audioinput_device);
}
+void AudioInputCore::internal_set_audioinput_device(const AudioInputDevice & audioinput_device)
+{
+ PTRACE(0, "AudioInputCore\tSetting device: " << audioinput_device.type << "/" << audioinput_device.source << "/" << audioinput_device.device);
+
+ if (preview_config.active)
+ preview_manager.stop();
+
+ if (preview_config.active || stream_config.active)
+ internal_close();
+
+ internal_set_device (audioinput_device);
+
+ if (preview_config.active) {
+ internal_open(preview_config.channels, preview_config.samplerate, preview_config.bits_per_sample);
+
+ if ((preview_config.buffer_size > 0) && (preview_config.num_buffers > 0 ) ) {
+ if (current_manager)
+ current_manager->set_buffer_size (preview_config.buffer_size, preview_config.num_buffers);
+ }
+// preview_manager.start();
+ }
+
+ if (stream_config.active) {
+ internal_open(stream_config.channels, stream_config.samplerate, stream_config.bits_per_sample);
+
+ if ((stream_config.buffer_size > 0) && (stream_config.num_buffers > 0 ) ) {
+ if (current_manager)
+ current_manager->set_buffer_size (stream_config.buffer_size, stream_config.num_buffers);
+ }
+ }
+}
+
+
void AudioInputCore::internal_open (unsigned channels, unsigned samplerate, unsigned bits_per_sample)
{
PTRACE(0, "AudioInputCore\tOpening device with " << channels << "-" << samplerate << "/" << bits_per_sample );
@@ -467,7 +474,9 @@
void AudioInputCore::add_device (std::string & source, std::string & device, HalManager* /*manager*/)
{
- PTRACE(0, "AudioInputCore\tAdding Device");
+ PTRACE(0, "AudioInputCore\tAdding Device " << device);
+ PWaitAndSignal m(var_mutex);
+
AudioInputDevice audioinput_device;
for (std::set<AudioInputManager *>::iterator iter = managers.begin ();
iter != managers.end ();
@@ -477,7 +486,7 @@
if ( ( desired_device.type == audioinput_device.type ) &&
( desired_device.source == audioinput_device.source ) &&
( desired_device.device == audioinput_device.device ) ) {
- set_audioinput_device(desired_device);
+ internal_set_audioinput_device(desired_device);
}
runtime.run_in_main (sigc::bind (audioinputdevice_added.make_slot (), audioinput_device));
@@ -487,12 +496,25 @@
void AudioInputCore::remove_device (std::string & source, std::string & device, HalManager* /*manager*/)
{
- PTRACE(0, "AudioInputCore\tRemoving Device");
+ PTRACE(0, "AudioInputCore\tRemoving Device " << device);
+ PWaitAndSignal m(var_mutex);
+
AudioInputDevice audioinput_device;
for (std::set<AudioInputManager *>::iterator iter = managers.begin ();
iter != managers.end ();
iter++) {
if ((*iter)->has_device (source, device, audioinput_device)) {
+ if ( ( current_device.type == audioinput_device.type ) &&
+ ( current_device.source == audioinput_device.source ) &&
+ ( current_device.device == audioinput_device.device ) ) {
+
+ AudioInputDevice new_audioinput_device;
+ new_audioinput_device.type = AUDIO_INPUT_FALLBACK_DEVICE_TYPE;
+ new_audioinput_device.source = AUDIO_INPUT_FALLBACK_DEVICE_SOURCE;
+ new_audioinput_device.device = AUDIO_INPUT_FALLBACK_DEVICE_DEVICE;
+ internal_set_audioinput_device( new_audioinput_device);
+ }
+
runtime.run_in_main (sigc::bind (audioinputdevice_removed.make_slot (), audioinput_device));
}
}
Modified: trunk/lib/engine/audioinput/skel/audioinput-core.h
==============================================================================
--- trunk/lib/engine/audioinput/skel/audioinput-core.h (original)
+++ trunk/lib/engine/audioinput/skel/audioinput-core.h Mon Apr 14 19:37:27 2008
@@ -193,6 +193,7 @@
AudioInputManager *manager);
void on_audioinputdevice_closed (AudioInputDevice audioinput_device, AudioInputManager *manager);
+ void internal_set_audioinput_device(const AudioInputDevice & audioinput_device);
void internal_open (unsigned channels, unsigned samplerate, unsigned bits_per_sample);
void internal_close();
void internal_set_device (const AudioInputDevice & audioinput_device);
Modified: trunk/lib/engine/audiooutput/skel/audiooutput-core.cpp
==============================================================================
--- trunk/lib/engine/audiooutput/skel/audiooutput-core.cpp (original)
+++ trunk/lib/engine/audiooutput/skel/audiooutput-core.cpp Mon Apr 14 19:37:27 2008
@@ -162,31 +162,8 @@
switch (primarySecondary) {
case primary:
var_mutex[primary].Wait();
- if (current_primary_config.active)
- internal_close(primary);
-
- if ( (audiooutput_device.type == current_device[secondary].type) &&
- (audiooutput_device.source == current_device[secondary].source) &&
- (audiooutput_device.device == current_device[secondary].device) )
- {
- current_manager[secondary] = NULL;
- current_device[secondary].type = "";
- current_device[secondary].source = "";
- current_device[secondary].device = "";
- }
-
- internal_set_device(primary, audiooutput_device);
-
- if (current_primary_config.active)
- internal_open(primary, current_primary_config.channels, current_primary_config.samplerate, current_primary_config.bits_per_sample);
-
- if ((current_primary_config.buffer_size > 0) && (current_primary_config.num_buffers > 0 ) ) {
- if (current_manager[primary])
- current_manager[primary]->set_buffer_size (primary, current_primary_config.buffer_size, current_primary_config.num_buffers);
- }
-
+ internal_set_prim_audiooutput_device (audiooutput_device);
desired_primary_device = audiooutput_device;
-
var_mutex[primary].Signal();
break;
@@ -314,7 +291,31 @@
}
}
+void AudioOutputCore::internal_set_prim_audiooutput_device(const AudioOutputDevice & audiooutput_device)
+{
+ if (current_primary_config.active)
+ internal_close(primary);
+
+ if ( (audiooutput_device.type == current_device[secondary].type) &&
+ (audiooutput_device.source == current_device[secondary].source) &&
+ (audiooutput_device.device == current_device[secondary].device) )
+ {
+ current_manager[secondary] = NULL;
+ current_device[secondary].type = "";
+ current_device[secondary].source = "";
+ current_device[secondary].device = "";
+ }
+ internal_set_device(primary, audiooutput_device);
+
+ if (current_primary_config.active)
+ internal_open(primary, current_primary_config.channels, current_primary_config.samplerate, current_primary_config.bits_per_sample);
+
+ if ((current_primary_config.buffer_size > 0) && (current_primary_config.num_buffers > 0 ) ) {
+ if (current_manager[primary])
+ current_manager[primary]->set_buffer_size (primary, current_primary_config.buffer_size, current_primary_config.num_buffers);
+ }
+}
void AudioOutputCore::internal_set_device (AudioOutputPrimarySecondary primarySecondary, const AudioOutputDevice & audiooutput_device)
{
current_manager[primarySecondary] = NULL;
@@ -453,7 +454,9 @@
void AudioOutputCore::add_device (std::string & sink, std::string & device, HalManager* /*manager*/)
{
- PTRACE(0, "AudioOutputCore\tAdding Device");
+ PTRACE(0, "AudioOutputCore\tAdding Device " << device);
+ PWaitAndSignal m_pri(var_mutex[primary]);
+
AudioOutputDevice audiooutput_device;
for (std::set<AudioOutputManager *>::iterator iter = managers.begin ();
iter != managers.end ();
@@ -463,7 +466,7 @@
if ( ( desired_primary_device.type == audiooutput_device.type ) &&
( desired_primary_device.source == audiooutput_device.source ) &&
( desired_primary_device.device == audiooutput_device.device ) ) {
- set_audiooutput_device(primary, desired_primary_device);
+ internal_set_prim_audiooutput_device(desired_primary_device);
}
runtime.run_in_main (sigc::bind (audiooutputdevice_added.make_slot (), audiooutput_device));
@@ -473,12 +476,25 @@
void AudioOutputCore::remove_device (std::string & sink, std::string & device, HalManager* /*manager*/)
{
- PTRACE(0, "AudioOutputCore\tRemoving Device");
+ PTRACE(0, "AudioOutputCore\tRemoving Device " << device);
+ PWaitAndSignal m_pri(var_mutex[primary]);
+
AudioOutputDevice audiooutput_device;
for (std::set<AudioOutputManager *>::iterator iter = managers.begin ();
iter != managers.end ();
iter++) {
if ((*iter)->has_device (sink, device, audiooutput_device)) {
+ if ( (audiooutput_device.type == current_device[primary].type) &&
+ (audiooutput_device.source == current_device[primary].source) &&
+ (audiooutput_device.device == current_device[primary].device) ) {
+
+ AudioOutputDevice new_audiooutput_device;
+ new_audiooutput_device.type = AUDIO_OUTPUT_FALLBACK_DEVICE_TYPE;
+ new_audiooutput_device.source = AUDIO_OUTPUT_FALLBACK_DEVICE_SOURCE;
+ new_audiooutput_device.device = AUDIO_OUTPUT_FALLBACK_DEVICE_DEVICE;
+ internal_set_prim_audiooutput_device(new_audiooutput_device);
+ }
+
runtime.run_in_main (sigc::bind (audiooutputdevice_removed.make_slot (), audiooutput_device));
}
}
Modified: trunk/lib/engine/audiooutput/skel/audiooutput-core.h
==============================================================================
--- trunk/lib/engine/audiooutput/skel/audiooutput-core.h (original)
+++ trunk/lib/engine/audiooutput/skel/audiooutput-core.h Mon Apr 14 19:37:27 2008
@@ -180,6 +180,7 @@
AudioOutputManager *manager);
void on_audiooutputdevice_closed (AudioOutputPrimarySecondary primarySecondary, AudioOutputDevice audiooutput_device, AudioOutputManager *manager);
+ void internal_set_prim_audiooutput_device(const AudioOutputDevice & audiooutput_device);
void internal_set_device (AudioOutputPrimarySecondary primarySecondary, const AudioOutputDevice & audiooutput_device);
bool internal_open (AudioOutputPrimarySecondary primarySecondary, unsigned channels, unsigned samplerate, unsigned bits_per_sample);
void internal_close(AudioOutputPrimarySecondary primarySecondary);
Modified: trunk/lib/engine/hal/dbus/hal-manager-dbus.cpp
==============================================================================
--- trunk/lib/engine/hal/dbus/hal-manager-dbus.cpp (original)
+++ trunk/lib/engine/hal/dbus/hal-manager-dbus.cpp Mon Apr 14 19:37:27 2008
@@ -346,6 +346,13 @@
}
g_object_unref(device_proxy);
+
+ // FIXME: Hack to support badly named Logitech devices
+ // Maybe this should be fixed in hald?
+ if (hal_device.name.substr(0, 17) == "Logitech Logitech") {
+ hal_device.name = hal_device.name.substr(9);
+ }
+
return ret;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]