Commit bb356e61 authored by Alexandre Savard's avatar Alexandre Savard

[#1962] Use ALSA plugin dsnoop in order to share capture device

parent f5802f03
......@@ -94,7 +94,7 @@ void preferences_dialog_fill_codec_list (account_t **a) {
* Fill store with output audio plugins
*/
void
preferences_dialog_fill_output_audio_plugin_list()
preferences_dialog_fill_audio_plugin_list()
{
GtkTreeIter iter;
gchar** list;
......@@ -103,7 +103,7 @@ preferences_dialog_fill_output_audio_plugin_list()
gtk_list_store_clear(pluginlist);
// Call dbus to retreive list
list = dbus_get_output_audio_plugin_list();
list = dbus_get_audio_plugin_list();
// For each API name included in list
int c = 0;
......@@ -787,7 +787,7 @@ GtkWidget* alsa_box()
gtk_widget_show( item );
// Set choices of audio managers
pluginlist = gtk_list_store_new(1, G_TYPE_STRING);
preferences_dialog_fill_output_audio_plugin_list();
preferences_dialog_fill_audio_plugin_list();
plugin = gtk_combo_box_new_with_model(GTK_TREE_MODEL(pluginlist));
select_active_output_audio_plugin();
gtk_label_set_mnemonic_widget(GTK_LABEL(item), plugin);
......
......@@ -466,17 +466,7 @@
<!-- Audio devices methods -->
<method name="getInputAudioPluginList" tp:name-for-bindings="getInputAudioPluginList">
<tp:docstring>
</tp:docstring>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="VectorString"/>
<arg type="as" name="list" direction="out">
<tp:docstring>
</tp:docstring>
</arg>
</method>
<method name="getOutputAudioPluginList" tp:name-for-bindings="getOutputAudioPluginList">
<method name="getAudioPluginList" tp:name-for-bindings="getAudioPluginList">
<tp:docstring>
</tp:docstring>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="VectorString"/>
......
......@@ -1297,44 +1297,27 @@ dbus_set_active_codec_list(const gchar** list, const gchar *accountID)
}
}
/**
* Get a list of input supported audio plugins
*/
gchar**
dbus_get_input_audio_plugin_list()
{
gchar** array;
GError* error = NULL;
org_sflphone_SFLphone_ConfigurationManager_get_input_audio_plugin_list(
configurationManagerProxy, &array, &error);
if (error)
{
ERROR("Failed to call get_input_audio_plugin_list() on ConfigurationManager: %s", error->message);
g_error_free(error);
}
return array;
}
/**
* Get a list of output supported audio plugins
*/
gchar**
dbus_get_output_audio_plugin_list()
dbus_get_audio_plugin_list()
{
gchar** array;
GError* error = NULL;
if (!org_sflphone_SFLphone_ConfigurationManager_get_output_audio_plugin_list(
if (!org_sflphone_SFLphone_ConfigurationManager_get_audio_plugin_list(
configurationManagerProxy, &array, &error))
{
if (error->domain == DBUS_GERROR && error->code
== DBUS_GERROR_REMOTE_EXCEPTION)
{
ERROR ("Caught remote method (get_output_audio_plugin_list) exception %s: %s", dbus_g_error_get_name(error), error->message);
ERROR ("Caught remote method (get_output_plugin_list) exception %s: %s", dbus_g_error_get_name(error), error->message);
}
else
{
ERROR("Error while calling get_out_audio_plugin_list: %s", error->message);
ERROR("Error while calling get_out_plugin_list: %s", error->message);
}
g_error_free(error);
return NULL;
......
......@@ -241,17 +241,11 @@ void dbus_set_active_codec_list (const gchar** list, const gchar*);
*/
gchar* dbus_get_current_codec_name(const callable_obj_t * c);
/**
* ConfigurationManager - Get the list of available input audio plugins
* @return gchar** The list of plugins
*/
gchar** dbus_get_input_audio_plugin_list();
/**
* ConfigurationManager - Get the list of available output audio plugins
* @return gchar** The list of plugins
*/
gchar** dbus_get_output_audio_plugin_list();
gchar** dbus_get_audio_plugin_list();
/**
* ConfigurationManager - Select an input audio plugin
......
......@@ -139,10 +139,20 @@ AlsaLayer::startStream (void)
if(is_playback_running() && is_capture_running() )
return;
std::string pcmp = buildDeviceTopo (_audioPlugin, _indexOut, 0);
std::string pcmr = buildDeviceTopo (_audioPlugin, _indexRing, 0);
std::string pcmc = buildDeviceTopo("default", _indexIn, 0);
std::string pcmp;
std::string pcmr;
std::string pcmc;
if(_audioPlugin == PCM_DMIX_DSNOOP) {
pcmp = buildDeviceTopo (PCM_DMIX, _indexOut, 0);
pcmr = buildDeviceTopo (PCM_DMIX, _indexRing, 0);
pcmc = buildDeviceTopo(PCM_DSNOOP, _indexIn, 0);
}
else {
pcmp = buildDeviceTopo (_audioPlugin, _indexOut, 0);
pcmr = buildDeviceTopo (_audioPlugin, _indexRing, 0);
pcmc = buildDeviceTopo(_audioPlugin, _indexIn, 0);
}
_debug("pcmp: %s, index %d", pcmp.c_str(), _indexOut);
_debug("pcmr: %s, index %d", pcmr.c_str(), _indexRing);
......@@ -647,14 +657,14 @@ AlsaLayer::read (void* buffer, int toCopy)
case -ESTRPIPE:
case -EIO:
_debugAlsa (" XRUN capture ignored (%s)", snd_strerror (samples));
_debugAlsa ("Audio: XRUN capture ignored (%s)", snd_strerror (samples));
handle_xrun_capture();
//samples = snd_pcm_readi( _CaptureHandle, buffer, frames);
//if (samples<0) samples=0;
break;
case EPERM:
_debugAlsa (" Capture EPERM (%s)", snd_strerror (samples));
_debugAlsa ("Audio: Capture EPERM (%s)", snd_strerror (samples));
prepareCaptureStream ();
startCaptureStream ();
break;
......@@ -719,10 +729,10 @@ AlsaLayer::handle_xrun_playback (snd_pcm_t *handle)
std::string
AlsaLayer::buildDeviceTopo (std::string plugin, int card, int subdevice)
{
std::string pcm = plugin;
std::stringstream ss,ss1;
std::string pcm = plugin;
if (pcm == "default" || pcm == "pulse")
if (pcm == PCM_DEFAULT)
return pcm;
ss << card;
......@@ -864,6 +874,8 @@ void AlsaLayer::audioCallback (void)
// toGet = framesPerBufferAlsa;
// maxBytes = toGet * sizeof (SFLDataFormat);
if(!_PlaybackHandle)
return;
int playbackAvailSmpl = snd_pcm_avail_update(_PlaybackHandle);
int playbackAvailBytes = playbackAvailSmpl*sizeof(SFLDataFormat);
......
......@@ -466,17 +466,7 @@
<!-- Audio devices methods -->
<method name="getInputAudioPluginList" tp:name-for-bindings="getInputAudioPluginList">
<tp:docstring>
</tp:docstring>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="VectorString"/>
<arg type="as" name="list" direction="out">
<tp:docstring>
</tp:docstring>
</arg>
</method>
<method name="getOutputAudioPluginList" tp:name-for-bindings="getOutputAudioPluginList">
<method name="getAudioPluginList" tp:name-for-bindings="getAudioPluginList">
<tp:docstring>
</tp:docstring>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="VectorString"/>
......
......@@ -505,28 +505,13 @@ void ConfigurationManager::setActiveCodecList(
}
// Audio devices related methods
std::vector<std::string> ConfigurationManager::getInputAudioPluginList() {
_debug("ConfigurationManager: Active codec list received");
std::vector<std::string> v;
v.push_back("default");
v.push_back("surround40");
v.push_back("plug:hw");
return v;
}
std::vector<std::string> ConfigurationManager::getOutputAudioPluginList() {
std::vector<std::string> ConfigurationManager::getAudioPluginList() {
std::vector<std::string> v;
v.push_back(PCM_DEFAULT);
v.push_back(PCM_DMIX);
// v.push_back(PCM_DMIX);
v.push_back(PCM_DMIX_DSNOOP);
return v;
}
......
......@@ -64,8 +64,7 @@ public:
std::vector< std::string > getActiveCodecList (const std::string& accountID);
void setActiveCodecList (const std::vector< std::string >& list, const std::string& accountID);
std::vector< std::string > getInputAudioPluginList();
std::vector< std::string > getOutputAudioPluginList();
std::vector< std::string > getAudioPluginList();
void setInputAudioPlugin(const std::string& audioPlugin);
void setOutputAudioPlugin(const std::string& audioPlugin);
std::vector< std::string > getAudioOutputDeviceList();
......
......@@ -54,7 +54,7 @@ void AudioThread::run (void)
{
while (!testCancel()) {
_alsa->audioCallback();
Thread::sleep (3);
Thread::sleep (20);
}
}
......@@ -86,6 +86,8 @@ static const SOUND_FORMAT INT32 = 0x8;
#define PCM_PLUGHW "plughw" /** Alsa plugin */
#define PCM_DEFAULT "default" /** Default ALSA plugin */
#define PCM_DMIX "plug:dmix" /** Alsa plugin for software mixing */
#define PCM_DSNOOP "plug:dsnoop" /** Alsa plugin for microphone sharing */
#define PCM_DMIX_DSNOOP "dmix/dsnoop" /** Audio profile using Alsa dmix/dsnoop */
#define SFL_CODEC_VALID_PREFIX "libcodec_" /** Valid prefix for codecs shared library */
#define SFL_CODEC_VALID_EXTEN ".so" /** Valid extension for codecs shared library */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment