Commit 5bda5172 authored by Emmanuel Milou's avatar Emmanuel Milou

Add alsa plugin choice in GTK + asynchronous call

Still no ringtones!!!!
parent a2a04360
......@@ -617,22 +617,22 @@ static
inline
#endif
gboolean
org_sflphone_SFLphone_ConfigurationManager_get_audio_manager_list (DBusGProxy *proxy, char *** OUT_list, GError **error)
org_sflphone_SFLphone_ConfigurationManager_get_input_audio_plugin_list (DBusGProxy *proxy, char *** OUT_list, GError **error)
{
return dbus_g_proxy_call (proxy, "getAudioManagerList", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_list, G_TYPE_INVALID);
return dbus_g_proxy_call (proxy, "getInputAudioPluginList", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_list, G_TYPE_INVALID);
}
typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_audio_manager_list_reply) (DBusGProxy *proxy, char * *OUT_list, GError *error, gpointer userdata);
typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_input_audio_plugin_list_reply) (DBusGProxy *proxy, char * *OUT_list, GError *error, gpointer userdata);
static void
org_sflphone_SFLphone_ConfigurationManager_get_audio_manager_list_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
org_sflphone_SFLphone_ConfigurationManager_get_input_audio_plugin_list_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
{
DBusGAsyncData *data = (DBusGAsyncData*) user_data;
GError *error = NULL;
char ** OUT_list;
dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRV, &OUT_list, G_TYPE_INVALID);
(*(org_sflphone_SFLphone_ConfigurationManager_get_audio_manager_list_reply)data->cb) (proxy, OUT_list, error, data->userdata);
(*(org_sflphone_SFLphone_ConfigurationManager_get_input_audio_plugin_list_reply)data->cb) (proxy, OUT_list, error, data->userdata);
return;
}
......@@ -641,35 +641,110 @@ static
inline
#endif
DBusGProxyCall*
org_sflphone_SFLphone_ConfigurationManager_get_audio_manager_list_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_audio_manager_list_reply callback, gpointer userdata)
org_sflphone_SFLphone_ConfigurationManager_get_input_audio_plugin_list_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_input_audio_plugin_list_reply callback, gpointer userdata)
{
DBusGAsyncData *stuff;
stuff = g_new (DBusGAsyncData, 1);
stuff->cb = G_CALLBACK (callback);
stuff->userdata = userdata;
return dbus_g_proxy_begin_call (proxy, "getAudioManagerList", org_sflphone_SFLphone_ConfigurationManager_get_audio_manager_list_async_callback, stuff, g_free, G_TYPE_INVALID);
return dbus_g_proxy_begin_call (proxy, "getInputAudioPluginList", org_sflphone_SFLphone_ConfigurationManager_get_input_audio_plugin_list_async_callback, stuff, g_free, G_TYPE_INVALID);
}
static
#ifdef G_HAVE_INLINE
inline
#endif
gboolean
org_sflphone_SFLphone_ConfigurationManager_set_audio_manager (DBusGProxy *proxy, const char * IN_audioManager, GError **error)
org_sflphone_SFLphone_ConfigurationManager_get_output_audio_plugin_list (DBusGProxy *proxy, char *** OUT_list, GError **error)
{
return dbus_g_proxy_call (proxy, "setAudioManager", error, G_TYPE_STRING, IN_audioManager, G_TYPE_INVALID, G_TYPE_INVALID);
return dbus_g_proxy_call (proxy, "getOutputAudioPluginList", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_list, G_TYPE_INVALID);
}
typedef void (*org_sflphone_SFLphone_ConfigurationManager_set_audio_manager_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_output_audio_plugin_list_reply) (DBusGProxy *proxy, char * *OUT_list, GError *error, gpointer userdata);
static void
org_sflphone_SFLphone_ConfigurationManager_set_audio_manager_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
org_sflphone_SFLphone_ConfigurationManager_get_output_audio_plugin_list_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
{
DBusGAsyncData *data = (DBusGAsyncData*) user_data;
GError *error = NULL;
char ** OUT_list;
dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRV, &OUT_list, G_TYPE_INVALID);
(*(org_sflphone_SFLphone_ConfigurationManager_get_output_audio_plugin_list_reply)data->cb) (proxy, OUT_list, error, data->userdata);
return;
}
static
#ifdef G_HAVE_INLINE
inline
#endif
DBusGProxyCall*
org_sflphone_SFLphone_ConfigurationManager_get_output_audio_plugin_list_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_output_audio_plugin_list_reply callback, gpointer userdata)
{
DBusGAsyncData *stuff;
stuff = g_new (DBusGAsyncData, 1);
stuff->cb = G_CALLBACK (callback);
stuff->userdata = userdata;
return dbus_g_proxy_begin_call (proxy, "getOutputAudioPluginList", org_sflphone_SFLphone_ConfigurationManager_get_output_audio_plugin_list_async_callback, stuff, g_free, G_TYPE_INVALID);
}
static
#ifdef G_HAVE_INLINE
inline
#endif
gboolean
org_sflphone_SFLphone_ConfigurationManager_set_input_audio_plugin (DBusGProxy *proxy, const char * IN_audioPlugin, GError **error)
{
return dbus_g_proxy_call (proxy, "setInputAudioPlugin", error, G_TYPE_STRING, IN_audioPlugin, G_TYPE_INVALID, G_TYPE_INVALID);
}
typedef void (*org_sflphone_SFLphone_ConfigurationManager_set_input_audio_plugin_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
static void
org_sflphone_SFLphone_ConfigurationManager_set_input_audio_plugin_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
{
DBusGAsyncData *data = (DBusGAsyncData*) user_data;
GError *error = NULL;
dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
(*(org_sflphone_SFLphone_ConfigurationManager_set_input_audio_plugin_reply)data->cb) (proxy, error, data->userdata);
return;
}
static
#ifdef G_HAVE_INLINE
inline
#endif
DBusGProxyCall*
org_sflphone_SFLphone_ConfigurationManager_set_input_audio_plugin_async (DBusGProxy *proxy, const char * IN_audioPlugin, org_sflphone_SFLphone_ConfigurationManager_set_input_audio_plugin_reply callback, gpointer userdata)
{
DBusGAsyncData *stuff;
stuff = g_new (DBusGAsyncData, 1);
stuff->cb = G_CALLBACK (callback);
stuff->userdata = userdata;
return dbus_g_proxy_begin_call (proxy, "setInputAudioPlugin", org_sflphone_SFLphone_ConfigurationManager_set_input_audio_plugin_async_callback, stuff, g_free, G_TYPE_STRING, IN_audioPlugin, G_TYPE_INVALID);
}
static
#ifdef G_HAVE_INLINE
inline
#endif
gboolean
org_sflphone_SFLphone_ConfigurationManager_set_output_audio_plugin (DBusGProxy *proxy, const char * IN_audioPlugin, GError **error)
{
return dbus_g_proxy_call (proxy, "setOutputAudioPlugin", error, G_TYPE_STRING, IN_audioPlugin, G_TYPE_INVALID, G_TYPE_INVALID);
}
typedef void (*org_sflphone_SFLphone_ConfigurationManager_set_output_audio_plugin_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
static void
org_sflphone_SFLphone_ConfigurationManager_set_output_audio_plugin_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
{
DBusGAsyncData *data = (DBusGAsyncData*) user_data;
GError *error = NULL;
dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
(*(org_sflphone_SFLphone_ConfigurationManager_set_audio_manager_reply)data->cb) (proxy, error, data->userdata);
(*(org_sflphone_SFLphone_ConfigurationManager_set_output_audio_plugin_reply)data->cb) (proxy, error, data->userdata);
return;
}
......@@ -678,14 +753,14 @@ static
inline
#endif
DBusGProxyCall*
org_sflphone_SFLphone_ConfigurationManager_set_audio_manager_async (DBusGProxy *proxy, const char * IN_audioManager, org_sflphone_SFLphone_ConfigurationManager_set_audio_manager_reply callback, gpointer userdata)
org_sflphone_SFLphone_ConfigurationManager_set_output_audio_plugin_async (DBusGProxy *proxy, const char * IN_audioPlugin, org_sflphone_SFLphone_ConfigurationManager_set_output_audio_plugin_reply callback, gpointer userdata)
{
DBusGAsyncData *stuff;
stuff = g_new (DBusGAsyncData, 1);
stuff->cb = G_CALLBACK (callback);
stuff->userdata = userdata;
return dbus_g_proxy_begin_call (proxy, "setAudioManager", org_sflphone_SFLphone_ConfigurationManager_set_audio_manager_async_callback, stuff, g_free, G_TYPE_STRING, IN_audioManager, G_TYPE_INVALID);
return dbus_g_proxy_begin_call (proxy, "setOutputAudioPlugin", org_sflphone_SFLphone_ConfigurationManager_set_output_audio_plugin_async_callback, stuff, g_free, G_TYPE_STRING, IN_audioPlugin, G_TYPE_INVALID);
}
static
#ifdef G_HAVE_INLINE
......
......@@ -39,7 +39,8 @@ gboolean dialogOpen = FALSE;
GtkListStore *accountStore;
GtkWidget *codecTreeView; // View used instead of store to get access to selection
// instead of keeping selected codec as a variable
GtkListStore *audioManagerStore;
GtkListStore *inputAudioPluginStore;
GtkListStore *outputAudioPluginStore;
GtkListStore *outputAudioDeviceManagerStore;
GtkListStore *inputAudioDeviceManagerStore;
......@@ -137,30 +138,54 @@ config_window_fill_codec_list()
}
/**
* Fill store with audio managers
* Fill store with input audio plugins
*/
void
config_window_fill_audio_manager_list()
config_window_fill_input_audio_plugin_list()
{
GtkTreeIter iter;
gchar** list;
gchar* managerName;
gtk_list_store_clear(audioManagerStore);
gtk_list_store_clear(inputAudioPluginStore);
// Call dbus to retreive list
list = dbus_get_audio_manager_list();
list = dbus_get_input_audio_plugin_list();
// For each API name included in list
int c = 0;
for(managerName = list[c]; managerName != NULL; managerName = list[c])
{
c++;
gtk_list_store_append(audioManagerStore, &iter);
gtk_list_store_set(audioManagerStore, &iter, 0 , managerName, -1);
gtk_list_store_append(inputAudioPluginStore, &iter);
gtk_list_store_set(inputAudioPluginStore, &iter, 0 , managerName, -1);
}
}
/**
* Fill store with output audio plugins
*/
void
config_window_fill_output_audio_plugin_list()
{
GtkTreeIter iter;
gchar** list;
gchar* managerName;
gtk_list_store_clear(outputAudioPluginStore);
// Call dbus to retreive list
list = dbus_get_output_audio_plugin_list();
// For each API name included in list
int c = 0;
for(managerName = list[c]; managerName != NULL; managerName = list[c])
{
c++;
gtk_list_store_append(outputAudioPluginStore, &iter);
gtk_list_store_set(outputAudioPluginStore, &iter, 0 , managerName, -1);
}
}
/**
* Fill output audio device store
*/
......@@ -281,15 +306,37 @@ select_active_input_audio_device()
}
/**
* Select the audio manager by calling the server
* Not yet used because audio manager is by default ALSA
* Select the input audio plugin by calling the server
*/
static void
select_audio_manager(GtkWidget* widget, gpointer data)
select_input_audio_plugin(GtkWidget* widget, gpointer data)
{
//dbus_set_audio_manager("");
}
/**
* Select the output audio plugin by calling the server
*/
static void
select_output_audio_plugin(GtkComboBox* widget, gpointer data)
{
GtkTreeModel* model;
GtkTreeIter iter;
int comboBoxIndex;
gchar* pluginName;
comboBoxIndex = gtk_combo_box_get_active(widget);
if(comboBoxIndex >= 0)
{
model = gtk_combo_box_get_model(widget);
gtk_combo_box_get_active_iter(widget, &iter);
gtk_tree_model_get(model, &iter, 0, &pluginName, -1);
dbus_set_output_audio_plugin(pluginName);
}
//dbus_set_output_audio_manager("");
}
/**
* Set the audio output device on the server with its index
*/
......@@ -873,6 +920,7 @@ create_audio_tab ()
gtk_misc_set_alignment(GTK_MISC(deviceLabel), 0, 0.5);
gtk_label_set_justify(GTK_LABEL(deviceLabel), GTK_JUSTIFY_LEFT);
gtk_box_pack_start(GTK_BOX(ret), deviceLabel, FALSE, FALSE, 0);
// Main device widget
deviceBox = gtk_hbox_new(FALSE, 10);
......@@ -887,17 +935,38 @@ create_audio_tab ()
// Device : Audio manager
// Create title label
titleLabel = gtk_label_new("Audio manager:");
gtk_misc_set_alignment(GTK_MISC(titleLabel), 0, 0.5);
/*
titleLabel = gtk_label_new("Alsa plug-IN:");
gtk_misc_set_alignment(GTK_MISC(titleLabel), 0, 0.5);
gtk_table_attach(GTK_TABLE(deviceTable), titleLabel, 0, 1, 0, 1, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
gtk_widget_show(titleLabel);
// Set choices of audio managers
inputAudioPluginStore = gtk_list_store_new(1, G_TYPE_STRING);
config_window_fill_input_audio_plugin_list();
comboBox = gtk_combo_box_new_with_model(GTK_TREE_MODEL(inputAudioPluginStore));
gtk_combo_box_set_active(GTK_COMBO_BOX(comboBox), 0);
gtk_label_set_mnemonic_widget(GTK_LABEL(titleLabel), comboBox);
g_signal_connect(G_OBJECT(comboBox), "changed", G_CALLBACK(select_input_audio_plugin), comboBox);
// Set rendering
renderer = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(comboBox), renderer, TRUE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(comboBox), renderer, "text", 0, NULL);
gtk_table_attach(GTK_TABLE(deviceTable), comboBox, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
gtk_widget_show(comboBox);
*/
// Create title label
titleLabel = gtk_label_new("Alsa plug-OUT:");
gtk_misc_set_alignment(GTK_MISC(titleLabel), 0, 0.5);
gtk_table_attach(GTK_TABLE(deviceTable), titleLabel, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
gtk_widget_show(titleLabel);
// Set choices of audio managers
audioManagerStore = gtk_list_store_new(1, G_TYPE_STRING);
config_window_fill_audio_manager_list();
comboBox = gtk_combo_box_new_with_model(GTK_TREE_MODEL(audioManagerStore));
outputAudioPluginStore = gtk_list_store_new(1, G_TYPE_STRING);
config_window_fill_output_audio_plugin_list();
comboBox = gtk_combo_box_new_with_model(GTK_TREE_MODEL(outputAudioPluginStore));
gtk_combo_box_set_active(GTK_COMBO_BOX(comboBox), 0);
gtk_label_set_mnemonic_widget(GTK_LABEL(titleLabel), comboBox);
g_signal_connect(G_OBJECT(comboBox), "changed", G_CALLBACK(select_audio_manager), comboBox);
g_signal_connect(G_OBJECT(comboBox), "changed", G_CALLBACK(select_output_audio_plugin), comboBox);
// Set rendering
renderer = gtk_cell_renderer_text_new();
......@@ -951,7 +1020,7 @@ create_audio_tab ()
// Create detect button
refreshButton = gtk_button_new_with_label("Detect all");
gtk_button_set_image(GTK_BUTTON(refreshButton), gtk_image_new_from_stock(GTK_STOCK_REFRESH, GTK_ICON_SIZE_BUTTON));
gtk_table_attach(GTK_TABLE(deviceTable), refreshButton, 3, 4, 0, 3, GTK_EXPAND, GTK_EXPAND, 0, 0);
gtk_table_attach(GTK_TABLE(deviceTable), refreshButton, 3, 4, 3, 4, GTK_EXPAND, GTK_EXPAND, 0, 0);
// Set event on selection
g_signal_connect(G_OBJECT(refreshButton), "clicked", G_CALLBACK(detect_all_audio_settings), NULL);
......
......@@ -28,7 +28,8 @@
*/
void config_window_fill_account_list();
void config_window_fill_codec_list();
void config_window_fill_audio_manager_list();
void config_window_fill_input_audio_plugin_list();
void config_window_fill_output_audio_plugin_list();
void config_window_fill_output_audio_device_list();
void select_active_output_audio_device();
void config_window_fill_input_audio_device_list();
......
......@@ -772,50 +772,95 @@ dbus_set_active_codec_list(const gchar** list)
}
/**
* Get a list of all supported audio managers
* Get a list of input supported audio plugins
*/
gchar**
dbus_get_audio_manager_list()
dbus_get_input_audio_plugin_list()
{
g_print("Before get audio manager list");
g_print("Before get input audio plugin list");
gchar** array;
GError* error = NULL;
org_sflphone_SFLphone_ConfigurationManager_get_audio_manager_list(
org_sflphone_SFLphone_ConfigurationManager_get_input_audio_plugin_list(
configurationManagerProxy,
&array,
&error);
g_print("After");
if(error)
{
g_printerr("Failed to call get_audio_manager_list() on ConfigurationManager: %s\n", error->message);
g_printerr("Failed to call get_input_audio_plugin_list() on ConfigurationManager: %s\n", error->message);
g_error_free(error);
}
else
g_print("DBus called get_audio_manager_list() on ConfigurationManager\n");
g_print("DBus called get_input_audio_plugin_list() on ConfigurationManager\n");
return array;
}
/**
* Sets the audio manager from its name
* Still not used because ALSA is used by default
* Get a list of output supported audio plugins
*/
gchar**
dbus_get_output_audio_plugin_list()
{
g_print("Before get output audio plugin list");
gchar** array;
GError* error = NULL;
org_sflphone_SFLphone_ConfigurationManager_get_output_audio_plugin_list(
configurationManagerProxy,
&array,
&error);
g_print("After");
if(error)
{
g_printerr("Failed to call get_output_audio_plugin_list() on ConfigurationManager: %s\n", error->message);
g_error_free(error);
}
else
g_print("DBus called get_output_audio_plugin_list() on ConfigurationManager\n");
return array;
}
/**
* Sets the input audio plugin from its name
*/
void
dbus_set_input_audio_plugin(gchar* audioPlugin)
{
g_print("Before set input audio plugin");
GError* error = NULL;
org_sflphone_SFLphone_ConfigurationManager_set_input_audio_plugin(
configurationManagerProxy,
audioPlugin,
&error);
g_print("After");
if(error)
{
g_printerr("Failed to call set_input_audio_plugin() on ConfigurationManager: %s\n", error->message);
g_error_free(error);
}
else
g_print("DBus called set_input_audio_plugin() on ConfigurationManager\n");
}
/**
* Sets the output audio plugin from its name
*/
void
dbus_set_audio_manager(gchar* audioManager)
dbus_set_output_audio_plugin(gchar* audioPlugin)
{
g_print("Before set audio manager");
g_print("Before set output audio plugin");
GError* error = NULL;
org_sflphone_SFLphone_ConfigurationManager_set_audio_manager(
org_sflphone_SFLphone_ConfigurationManager_set_output_audio_plugin(
configurationManagerProxy,
audioManager,
audioPlugin,
&error);
g_print("After");
if(error)
{
g_printerr("Failed to call set_audio_manager() on ConfigurationManager: %s\n", error->message);
g_printerr("Failed to call set_output_audio_plugin() on ConfigurationManager: %s\n", error->message);
g_error_free(error);
}
else
g_print("DBus called set_audio_manager() on ConfigurationManager\n");
g_print("DBus called set_output_audio_plugin() on ConfigurationManager\n");
}
/**
......
......@@ -61,8 +61,10 @@ gchar** dbus_get_active_codec_list( void );
void dbus_set_active_codec_list( const gchar** list );
// Audio devices related methods
gchar** dbus_get_audio_manager_list();
void dbus_set_audio_manager(gchar* audioManager);
gchar** dbus_get_input_audio_plugin_list();
gchar** dbus_get_output_audio_plugin_list();
void dbus_set_input_audio_plugin(gchar* audioPlugin);
void dbus_set_output_audio_plugin(gchar* audioPlugin);
gchar** dbus_get_audio_output_device_list();
void dbus_set_audio_output_device(const int index);
gchar** dbus_get_audio_input_device_list();
......
......@@ -41,7 +41,9 @@
, _manager(manager)
, _playback_handle( NULL )
, _capture_handle( NULL )
, device_closed( true )
, deviceClosed( true )
, _mainBuffer( SIZEBUF )
, _urgentBuffer( SIZEBUF )
{
_inChannel = 1; // don't put in stereo
......@@ -53,7 +55,7 @@
// Destructor
AudioLayer::~AudioLayer (void)
{
device_closed = true;
deviceClosed = true;
if(_capture_handle){
snd_pcm_drop( _capture_handle );
snd_pcm_close( _capture_handle );
......@@ -68,12 +70,12 @@ AudioLayer::~AudioLayer (void)
bool
AudioLayer::openDevice (int indexIn, int indexOut, int sampleRate, int frameSize, int flag)
AudioLayer::openDevice (int indexIn, int indexOut, int sampleRate, int frameSize, int stream , std::string plugin)
{
if(device_closed == false)
if(deviceClosed == false)
{
if( flag == SFL_PCM_CAPTURE)
if( stream == SFL_PCM_CAPTURE ){
if(_capture_handle)
{
_debugAlsa(" Close the current capture device\n");
......@@ -81,30 +83,35 @@ AudioLayer::openDevice (int indexIn, int indexOut, int sampleRate, int frameSize
snd_pcm_close( _capture_handle );
_capture_handle = 0;
}
else if( flag == SFL_PCM_PLAYBACK)
if(_playback_handle){
_debugAlsa(" Close the current playback device\n");
snd_pcm_drop( _playback_handle );
snd_pcm_close( _playback_handle );
_playback_handle = 0;
}
}
else if( stream == SFL_PCM_PLAYBACK){
if(_playback_handle){
_debugAlsa(" Close the current playback device\n");
snd_pcm_drop( _playback_handle );
snd_pcm_close( _playback_handle );
_playback_handle = 0;
}
}
}
_indexIn = indexIn;
_indexOut = indexOut;
_sampleRate = sampleRate;
_frameSize = frameSize;
_audioPlugin = plugin;
_debug(" Setting audiolayer: device in=%2d, out=%2d\n", _indexIn, _indexOut);
_debug(" : nb channel in=%2d, out=%2d\n", _inChannel, _outChannel);
_debug(" : sample rate=%5d, format=%s\n", _sampleRate, SFLPortaudioFormatString);
_debug(" : sample rate=%5d, format=%s\n", _sampleRate, SFLDataFormatString);
_debug(" : frame per buffer=%d\n", FRAME_PER_BUFFER);
ost::MutexLock guard( _mutex );
std::string pcmp = buildDeviceTopo(PCM_DMIX, indexOut , 0);
std::string pcmc = buildDeviceTopo(PCM_SURROUND40, indexIn , 0);
return open_device( pcmp , pcmc , flag);
//std::string plugin = PCM_DEFAULT;
//std::string plugout = PCM_DEFAULT;
std::string pcmp = buildDeviceTopo( plugin , indexOut , 0);
std::string pcmc = buildDeviceTopo(PCM_SURROUND40 , indexIn , 0);
return open_device( pcmp , pcmc , stream);
}
int
......@@ -114,14 +121,54 @@ AudioLayer::getDeviceCount()
return 1;
}
void AudioLayer::AlsaCallBack( snd_async_handler_t* pcm_callback )
{
( ( AudioLayer *)snd_async_handler_get_callback_private( pcm_callback )) -> updateBuffers();
}
void
AudioLayer::fillHWBuffer( void)
{
unsigned char* data;
int pcmreturn, l1, l2;
short s1, s2;
int frames;
int periodSize = 1024 * 2;
data = (unsigned char*)malloc(periodSize);
frames = periodSize >> 2;
for(l1 = 0; l1 < 100; l1++) {
for(l2 = 0; l2 < frames; l2++) {
s1 = 0;
s2 = 0;
data[4*l2] = (unsigned char)s1;
data[4*l2+1] = s1 >> 8;
data[4*l2+2] = (unsigned char)s2;
data[4*l2+3] = s2 >> 8;
}
/* Write num_frames frames from buffer data to the PCM device pointed to by pcm_handle */
/* writei for interleaved */
/* writen for non-interleaved */
while ((pcmreturn = snd_pcm_writei(_playback_handle, data, frames)) < 0) {
snd_pcm_prepare(_playback_handle);
fprintf(stderr, "<<<<<<<<<<<<<<< Buffer Underrun >>>>>>>>>>>>>>>\n");
}
}
}
void
AudioLayer::startStream(void)
{
_debug(" Start stream\n");
int err;
ost::MutexLock guard( _mutex );
snd_pcm_prepare( _capture_handle );
snd_pcm_start( _capture_handle ) ;
//snd_pcm_start( _playback_handle ) ;
snd_pcm_prepare( _playback_handle );
//if( err = snd_pcm_start( _playback_handle) < 0 ) _debugAlsa(" Cannot start (%s)\n", snd_strerror(err));
}
</