Commit b701039c authored by Emmanuel Milou's avatar Emmanuel Milou

Add user config for audio devices in GTk GUI

The server sends the list of the sound card it founds on the system to the GTk without
checking it is a capture or a playback device
TODO: improve the list sent ( must add abstraction device plug, default, etc..)
TODO: improve sound quality for capture
parent aaded786
......@@ -169,8 +169,7 @@ config_window_fill_output_audio_device_list()
{
GtkTreeIter iter;
gchar** list;
gchar** details;
gchar* audioDevice;
gchar** audioDevice;
gtk_list_store_clear(outputAudioDeviceManagerStore);
......@@ -179,13 +178,11 @@ config_window_fill_output_audio_device_list()
// For each device name included in list
int c = 0;
for(audioDevice = list[c]; audioDevice != NULL; audioDevice = list[c])
for(audioDevice = list; *list ; list++)
{
c++;
int index = atoi(audioDevice);
details = dbus_get_audio_device_details(index);
gtk_list_store_append(outputAudioDeviceManagerStore, &iter);
gtk_list_store_set(outputAudioDeviceManagerStore, &iter, 0, details[0], 1, index, -1);
gtk_list_store_set(outputAudioDeviceManagerStore, &iter, 0, *list, 1, c, -1);
c++;
}
}
......@@ -231,8 +228,7 @@ config_window_fill_input_audio_device_list()
{
GtkTreeIter iter;
gchar** list;
gchar** details;
gchar* audioDevice;
gchar** audioDevice;
gtk_list_store_clear(inputAudioDeviceManagerStore);
......@@ -241,13 +237,14 @@ config_window_fill_input_audio_device_list()
// For each device name included in list
int c = 0;
for(audioDevice = list[c]; audioDevice != NULL; audioDevice = list[c])
for(audioDevice = list; *list; list++)
{
c++;
int index = atoi(audioDevice);
details = dbus_get_audio_device_details(index);
//int index = atoi(audioDevice);
//details = dbus_get_audio_device_details(index);
gtk_list_store_append(inputAudioDeviceManagerStore, &iter);
gtk_list_store_set(inputAudioDeviceManagerStore, &iter, 0, details[0], 1, index, -1);
gtk_list_store_set(inputAudioDeviceManagerStore, &iter, 0, *list, 1, c, -1);
c++;
}
}
......@@ -348,12 +345,12 @@ static void
detect_all_audio_settings()
{
// Update lists
// config_window_fill_output_audio_device_list();
// config_window_fill_input_audio_device_list();
config_window_fill_output_audio_device_list();
config_window_fill_input_audio_device_list();
// Select active device in combo box
// select_active_output_audio_device();
// select_active_input_audio_device();
select_active_output_audio_device();
select_active_input_audio_device();
}
/**
......@@ -919,7 +916,7 @@ create_audio_tab ()
gtk_widget_show(titleLabel);
// Set choices of output devices
outputAudioDeviceManagerStore = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
// config_window_fill_output_audio_device_list();
config_window_fill_output_audio_device_list();
outputDeviceComboBox = gtk_combo_box_new_with_model(GTK_TREE_MODEL(outputAudioDeviceManagerStore));
// select_active_output_audio_device();
gtk_label_set_mnemonic_widget(GTK_LABEL(titleLabel), outputDeviceComboBox);
......@@ -940,9 +937,9 @@ create_audio_tab ()
gtk_widget_show(titleLabel);
// Set choices of output devices
inputAudioDeviceManagerStore = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
// config_window_fill_input_audio_device_list();
config_window_fill_input_audio_device_list();
inputDeviceComboBox = gtk_combo_box_new_with_model(GTK_TREE_MODEL(inputAudioDeviceManagerStore));
// select_active_input_audio_device();
select_active_input_audio_device();
gtk_label_set_mnemonic_widget(GTK_LABEL(titleLabel), inputDeviceComboBox);
g_signal_connect(G_OBJECT(inputDeviceComboBox), "changed", G_CALLBACK(select_audio_input_device), inputDeviceComboBox);
......
......@@ -22,14 +22,12 @@
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include "audiolayer.h"
#include "../global.h"
#include "../manager.h"
#include "../user_cfg.h"
#define PCM_NAME_DEFAULT "default"
#define PCM_PAUSE 1
#define PCM_RESUME 0
......@@ -38,10 +36,7 @@
#endif
AudioLayer::AudioLayer(ManagerImpl* manager)
: _urgentRingBuffer(SIZEBUF)
, _mainSndRingBuffer(SIZEBUF)
, _micRingBuffer(SIZEBUF)
, _defaultVolume(100)
: _defaultVolume(100)
, _errorMessage("")
, _manager(manager)
, _playback_handle( NULL )
......@@ -53,6 +48,7 @@
_inChannel = 1; // don't put in stereo
_outChannel = 1; // don't put in stereo
_echoTesting = false;
get_alsa_version();
#ifdef SFL_TEST_SINE
leftPhase_ = 0;
......@@ -88,8 +84,24 @@ AudioLayer::~AudioLayer (void)
bool
AudioLayer::openDevice (int indexIn, int indexOut, int sampleRate, int frameSize)
AudioLayer::openDevice (int indexIn, int indexOut, int sampleRate, int frameSize, int flag)
{
if(device_closed = false)
{
_debugAlsa(" CLose the current devices\n");
if(_capture_handle && (flag == 0 || flag == 2)){
snd_pcm_drop( _capture_handle );
snd_pcm_close( _capture_handle );
_capture_handle = 0;
}
if(_playback_handle && ( flag == 0 || flag == 1)){
snd_pcm_drop( _playback_handle );
snd_pcm_close( _playback_handle );
_playback_handle = 0;
}
}
_indexIn = indexIn;
_indexOut = indexOut;
_sampleRate = sampleRate;
......@@ -101,8 +113,10 @@ AudioLayer::openDevice (int indexIn, int indexOut, int sampleRate, int frameSize
_debug(" : frame per buffer=%d\n", FRAME_PER_BUFFER);
ost::MutexLock guard( _mutex );
// TODO: Must be dynamic
return open_device( PCM_NAME_DEFAULT );
std::string pcmp = buildDeviceTopo(PCM_FRONT, indexOut );
std::string pcmc = buildDeviceTopo(PCM_FRONT, indexIn );
return open_device( pcmp , pcmc, flag);
}
int
......@@ -115,13 +129,10 @@ AudioLayer::getDeviceCount()
void
AudioLayer::startStream(void)
{
// STATE PREPARED
_debug(" Start stream\n");
ost::MutexLock guard( _mutex );
_debug(" entry startStream() - c => %d - p => %d\n", snd_pcm_state(_capture_handle), snd_pcm_state( _playback_handle));
snd_pcm_start( _capture_handle ) ;
snd_pcm_start( _playback_handle ) ;
// STATE RUNNING
_debug(" exit startStream() - c => %d - p => %d\n", snd_pcm_state(_capture_handle), snd_pcm_state( _playback_handle));
//snd_pcm_start( _playback_handle ) ;
}
......@@ -129,19 +140,17 @@ AudioLayer::startStream(void)
AudioLayer::stopStream(void)
{
ost::MutexLock guard( _mutex );
_debug(" entry stopStream() - c => %d - p => %d\n", snd_pcm_state(_capture_handle), snd_pcm_state( _playback_handle));
snd_pcm_drop( _capture_handle );
snd_pcm_prepare( _capture_handle );
snd_pcm_drop( _playback_handle );
snd_pcm_prepare( _playback_handle );
_debug(" exit stopStream() - c => %d - p => %d\n", snd_pcm_state(_capture_handle), snd_pcm_state( _playback_handle));
//snd_pcm_drop( _playback_handle );
//snd_pcm_prepare( _playback_handle );
}
void
AudioLayer::sleep(int msec)
{
//snd_pcm_wait(_playback_handle, msec);
snd_pcm_wait(_playback_handle, msec);
}
bool
......@@ -156,17 +165,25 @@ AudioLayer::isStreamActive (void)
int
AudioLayer::putMain(void* buffer, int toCopy)
AudioLayer::playSamples(void* buffer, int toCopy)
{
ost::MutexLock guard( _mutex );
if ( _playback_handle )
if ( _playback_handle ){
write(buffer, toCopy);
}
return 0;
}
void
AudioLayer::flushMain()
int
AudioLayer::playRingTone( void* buffer, int toCopy)
{
_debug(" %d\n", toCopy);
ost::MutexLock guard( _mutex );
if( _playback_handle )
snd_pcm_start( _playback_handle );
write(buffer, toCopy);
return 0;
}
int
......@@ -174,7 +191,7 @@ AudioLayer::putUrgent(void* buffer, int toCopy)
{
ost::MutexLock guard( _mutex );
if ( _playback_handle )
//write(buffer, toCopy);
write(buffer, toCopy);
return 0;
}
......@@ -204,10 +221,6 @@ AudioLayer::getMic(void *buffer, int toCopy)
return 0;
}
void
AudioLayer::flushMic()
{
}
bool
AudioLayer::isStreamStopped (void)
......@@ -247,70 +260,75 @@ AudioLayer::isCaptureActive(void) {
bool
AudioLayer::open_device(std::string pcm_name)
AudioLayer::open_device(std::string pcm_p, std::string pcm_c, int flag)
{
int err;
snd_pcm_hw_params_t *hwparams = NULL;
unsigned int rate_in = _sampleRate;
unsigned int rate_out = _sampleRate;
int direction = 0;
snd_pcm_uframes_t period_size_in = 1024;
snd_pcm_uframes_t buffer_size_in = 2048;
snd_pcm_uframes_t period_size_out = 2048;
snd_pcm_uframes_t buffer_size_out = 4096;
int dir = 0;
unsigned int period_count_in = 2;
snd_pcm_uframes_t period_size_in = 2048; //rate_in * _frameSize / 1000 ;
snd_pcm_uframes_t buffer_size_in = 4096;
unsigned int period_count_out = 2;
snd_pcm_uframes_t period_size_out = 2048 ;
snd_pcm_uframes_t buffer_size_out = 4096 ;
snd_pcm_sw_params_t *swparams = NULL;
_debug(" Opening capture device %s\n", pcm_name.c_str());
if(err = snd_pcm_open(&_capture_handle, pcm_name.c_str(), SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK) < 0){
_debug(" Error while opening capture device %s (%s)\n", pcm_name.c_str(), snd_strerror(err));
return false;
}
if( err = snd_pcm_hw_params_malloc( &hwparams ) < 0 ) {
_debug(" Cannot allocate hardware parameter structure (%s)\n", snd_strerror(err));
return false;
}
if( err = snd_pcm_hw_params_any(_capture_handle, hwparams) < 0) _debug(" Cannot initialize hardware parameter structure (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params_set_access( _capture_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED) < 0) _debug(" Cannot set access type (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params_set_format( _capture_handle, hwparams, SND_PCM_FORMAT_S16_LE) < 0) _debug(" Cannot set sample format (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params_set_rate_near( _capture_handle, hwparams, &rate_in, &direction) < 0) _debug(" Cannot set sample rate (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params_set_channels( _capture_handle, hwparams, 1) < 0) _debug(" Cannot set channel count (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params_set_period_size_near( _capture_handle, hwparams, &period_size_out , &direction) < 0) _debug(" Cannot set period size (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params_set_buffer_size_near( _capture_handle, hwparams, &buffer_size_out ) < 0) _debug(" Cannot set buffer size (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params( _capture_handle, hwparams ) < 0) _debug(" Cannot set hw parameters (%s)\n", snd_strerror(err));
snd_pcm_hw_params_free( hwparams );
_debug(" Opening playback device %s\n", pcm_name.c_str());
if(err = snd_pcm_open(&_playback_handle, pcm_name.c_str(), SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK) < 0){
_debug(" Error while opening playback device %s (%s)\n", pcm_name.c_str(), snd_strerror(err));
return false;
if(flag == 0 || flag == 2)
{
_debug(" Opening capture device %s\n", pcm_c.c_str());
if(err = snd_pcm_open(&_capture_handle, pcm_c.c_str() , SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK) < 0){
_debug(" Error while opening capture device %s (%s)\n", pcm_c.c_str(), snd_strerror(err));
return false;
}
if( err = snd_pcm_hw_params_malloc( &hwparams ) < 0 ) {
_debug(" Cannot allocate hardware parameter structure (%s)\n", snd_strerror(err));
return false;
}
if( err = snd_pcm_hw_params_any(_capture_handle, hwparams) < 0) _debug(" Cannot initialize hardware parameter structure (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params_set_access( _capture_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED) < 0) _debug(" Cannot set access type (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params_set_format( _capture_handle, hwparams, SND_PCM_FORMAT_S16_LE) < 0) _debug(" Cannot set sample format (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params_set_rate_near( _capture_handle, hwparams, &rate_in, &dir) < 0) _debug(" Cannot set sample rate (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params_set_channels( _capture_handle, hwparams, 1) < 0) _debug(" Cannot set channel count (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params_set_period_size_near( _capture_handle, hwparams, &period_size_out , &dir) < 0) _debug(" Cannot set period size (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params_set_buffer_size_near( _capture_handle, hwparams, &buffer_size_out ) < 0) _debug(" Cannot set buffer size (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params( _capture_handle, hwparams ) < 0) _debug(" Cannot set hw parameters (%s)\n", snd_strerror(err));
snd_pcm_hw_params_free( hwparams );
device_closed = false;
}
if( err = snd_pcm_hw_params_malloc( &hwparams ) < 0 ) {
_debug(" Cannot allocate hardware parameter structure (%s)\n", snd_strerror(err));
return false;
if(flag == 0 || flag == 1)
{
_debug(" Opening playback device %s\n", pcm_p.c_str());
if(err = snd_pcm_open(&_playback_handle, pcm_p.c_str(), SND_PCM_STREAM_PLAYBACK, 0) < 0){
_debug(" Error while opening playback device %s (%s)\n", pcm_p.c_str(), snd_strerror(err));
return false;
}
if( err = snd_pcm_hw_params_malloc( &hwparams ) < 0 ) {
_debug(" Cannot allocate hardware parameter structure (%s)\n", snd_strerror(err));
return false;
}
if( err = snd_pcm_hw_params_any( _playback_handle, hwparams) < 0) _debug(" Cannot initialize hardware parameter structure (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params_set_access( _playback_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED) < 0) _debug(" Cannot set access type (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params_set_format( _playback_handle, hwparams, SND_PCM_FORMAT_S16_LE) < 0) _debug(" Cannot set sample format (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params_set_rate_near( _playback_handle, hwparams, &rate_out, &dir) < 0) _debug(" Cannot set sample rate (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params_set_channels( _playback_handle, hwparams, 1) < 0) _debug(" Cannot set channel count (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params_set_period_size_near( _playback_handle, hwparams, &period_size_out , &dir) < 0) _debug(" Cannot set period size (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params_set_buffer_size_near( _playback_handle, hwparams, &buffer_size_out ) < 0) _debug(" Cannot set buffer size (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params( _playback_handle, hwparams ) < 0) _debug(" Cannot set hw parameters (%s)\n", snd_strerror(err));
snd_pcm_hw_params_free( hwparams );
snd_pcm_uframes_t val = 1024 ;
snd_pcm_sw_params_alloca( &swparams );
snd_pcm_sw_params_current( _playback_handle, swparams );
if( err = snd_pcm_sw_params_set_start_threshold( _playback_handle, swparams, val ) < 0 ) _debug(" Cannot set start threshold (%s)\n", snd_strerror(err));
if( err = snd_pcm_sw_params_set_stop_threshold( _playback_handle, swparams, val*4 ) < 0 ) _debug(" Cannot get stop threshold (%s)\n", snd_strerror(err));
if( err = snd_pcm_sw_params( _playback_handle, swparams ) < 0 ) _debug(" Cannot set sw parameters (%s)\n", snd_strerror(err));
device_closed = false;
}
if( err = snd_pcm_hw_params_any( _playback_handle, hwparams) < 0) _debug(" Cannot initialize hardware parameter structure (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params_set_access( _playback_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED) < 0) _debug(" Cannot set access type (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params_set_format( _playback_handle, hwparams, SND_PCM_FORMAT_S16_LE) < 0) _debug(" Cannot set sample format (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params_set_rate_near( _playback_handle, hwparams, &rate_out, &direction) < 0) _debug(" Cannot set sample rate (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params_set_channels( _playback_handle, hwparams, 1) < 0) _debug(" Cannot set channel count (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params_set_period_size_near( _playback_handle, hwparams, &period_size_out , &direction) < 0) _debug(" Cannot set period size (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params_set_buffer_size_near( _playback_handle, hwparams, &buffer_size_out ) < 0) _debug(" Cannot set buffer size (%s)\n", snd_strerror(err));
if( err = snd_pcm_hw_params( _playback_handle, hwparams ) < 0) _debug(" Cannot set hw parameters (%s)\n", snd_strerror(err));
snd_pcm_hw_params_free( hwparams );
snd_pcm_uframes_t val;
snd_pcm_sw_params_alloca( &swparams );
snd_pcm_sw_params_current( _playback_handle, swparams );
if( err = snd_pcm_sw_params_get_start_threshold( swparams, &val ) < 0 ) _debug(" Cannot get start threshold (%s)\n", snd_strerror(err));
if( err = snd_pcm_sw_params_get_stop_threshold( swparams, &val ) < 0 ) _debug(" Cannot get stop threshold (%s)\n", snd_strerror(err));
if( err = snd_pcm_sw_params_get_boundary( swparams, &val ) < 0 ) _debug(" Cannot get boundary (%s)\n", snd_strerror(err));
if( err = snd_pcm_sw_params_set_silence_threshold( _playback_handle, swparams, 0 ) < 0 ) _debug(" Cannot set silence threshold (%s)\n", snd_strerror(err));
if( err = snd_pcm_sw_params_set_silence_size( _playback_handle, swparams, 0 ) < 0 ) _debug(" Cannot set silence size (%s)\n", snd_strerror(err));
if( err = snd_pcm_sw_params( _playback_handle, swparams ) < 0 ) _debug(" Cannot set sw parameters (%s)\n", snd_strerror(err));
device_closed = false;
return true;
}
......@@ -356,7 +374,6 @@ AudioLayer::read( void* target_buffer, int toCopy)
{
if(device_closed || _capture_handle == NULL)
return 0;
int bytes;
snd_pcm_uframes_t frames = snd_pcm_bytes_to_frames( _capture_handle, toCopy);
if( bytes = snd_pcm_readi( _capture_handle, target_buffer, frames) < 0 ) {
......@@ -404,3 +421,76 @@ AudioLayer::handle_xrun_state( void )
else
_debug(" Get status failed\n");
}
void
AudioLayer::get_devices_info( void ){
snd_pcm_info_t *info;
snd_pcm_info_alloca( &info );
//int card = snd_pcm_info_get_card( info );
_debug("device %d - subdevice %d - card %d\n", snd_pcm_info_get_device(info), snd_pcm_info_get_subdevice( info ), snd_pcm_info_get_card( info ));
}
std::string
AudioLayer::get_alsa_version( void )
{
std::stringstream out;
std::string version;
std::ifstream file( "/proc/asound/version" );
out << file.rdbuf();
version = out.str();
//version << std::cout << system("cat /proc/asound/version");
_debugAlsa("%s\n", version.c_str());
return version;
}
std::vector<std::string>
AudioLayer::get_sound_cards( void )
{
std::stringstream out;
std::string sound_cards;
std::ifstream file( "/proc/asound/cards" );
out << file.rdbuf();
sound_cards = out.str();
//_debugAlsa("%s\n", sound_cards.c_str());
return parse_sound_cards(sound_cards);
}
std::vector< std::string >
AudioLayer::parse_sound_cards( std::string& list)
{
std::vector<std::string> lines;
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
boost::char_separator<char> ret("\n");
tokenizer tokens( list , ret );
for(tokenizer::iterator tok_iter = tokens.begin() ; tok_iter != tokens.end() ; ++tok_iter)
{
lines.push_back(*tok_iter);
}
// We keep only the fisrt line of each device description --> the interesting one
int size = lines.size();
// 2 lines of description per sound card
int nb_cards = size / 2 ;
for(size = 0 ; size < nb_cards ; size++)
{
// for each card, we keep the first one
lines.erase(lines.begin() + 2*size + 1);
}
lines.resize(nb_cards);
return lines;
}
std::string
AudioLayer::buildDeviceTopo( std::string prefixe, int suffixe)
{
if( prefixe == PCM_DEFAULT)
return prefixe;
std::string pcm = prefixe;
std::ostringstream ss;
ss << suffixe;
pcm.append(":");
pcm.append(ss.str());
return pcm;
}
......@@ -24,17 +24,19 @@
#define _AUDIO_LAYER_H
#include <cc++/thread.h> // for ost::Mutex
#include <boost/tokenizer.hpp>
#include "../global.h"
#include "ringbuffer.h"
#include "audiodevice.h"
#include <vector>
#include <alsa/asoundlib.h>
#include <iostream>
#include <fstream>
#include <istream>
#include <sstream>
#define FRAME_PER_BUFFER 160
class RingBuffer;
class ManagerImpl;
class AudioLayer {
......@@ -47,8 +49,9 @@ class AudioLayer {
* @param indexOut
* @param sampleRate
* @param frameSize
* @param flag - 0 --> open playback and capture ; 1 --> open playback only ; 2 --> open capture only
*/
bool openDevice(int, int, int, int);
bool openDevice(int, int, int, int, int);
void startStream(void);
void stopStream(void);
void sleep(int);
......@@ -58,16 +61,15 @@ class AudioLayer {
bool isStreamStopped(void);
void closeStream();
void flushMain();
int putMain(void* buffer, int toCopy);
int playSamples(void* buffer, int toCopy);
int playRingTone( void* buffer, int toCopy);
int putUrgent(void* buffer, int toCopy);
int canGetMic();
int getMic(void *, int);
void flushMic();
std::vector<std::string> get_sound_cards( void );
std::string buildDeviceTopo( std::string prefixe, int suffixe);
int audioCallback (const void *, void *, unsigned long);
//int miniAudioCallback (const void *, void *, unsigned long,
//const PaStreamCallbackTimeInfo*, PaStreamCallbackFlags);
void setErrorMessage(const std::string& error) { _errorMessage = error; }
std::string getErrorMessage() { return _errorMessage; }
......@@ -101,15 +103,15 @@ class AudioLayer {
void toggleEchoTesting();
private:
bool open_device( std::string );
bool open_device( std::string , std::string , int);
int write( void* , int );
int read( void*, int );
bool is_playback_active( void );
bool is_capture_active( void );
void handle_xrun_state( void );
RingBuffer _urgentRingBuffer;
RingBuffer _mainSndRingBuffer;
RingBuffer _micRingBuffer;
void get_devices_info( void );
std::string get_alsa_version( void );
std::vector<std::string> parse_sound_cards( std::string& );
ManagerImpl* _manager; // augment coupling, reduce indirect access
// a audiolayer can't live without manager
......
......@@ -428,7 +428,7 @@ try {
#endif
audiolayer->putMain(toAudioLayer, nbSample * sizeof(SFLDataFormat));
audiolayer->playSamples(toAudioLayer, nbSample * sizeof(SFLDataFormat));
// Notify (with a beep) an incoming call when there is already a call
countTime += time->getSecond();
if (Manager::instance().incomingCallWaiting() > 0) {
......
......@@ -48,7 +48,8 @@ typedef short int16;
#define _debugMid(...) fprintf(stderr, __VA_ARGS__)
#define _debugEnd(...) fprintf(stderr, __VA_ARGS__)
#define _debugException(...) fprintf(stderr, "[sfl-excep] " __VA_ARGS__ "\n")
#define _debugInit(...) fprintf(stderr, "[sfl-init.] " __VA_ARGS__ "\n")
#define _debugInit(...) fprintf(stderr, "[sfl-init] " __VA_ARGS__ "\n")
#define _debugAlsa(...) fprintf(stderr, "[alsa-debug] " __VA_ARGS__ )
#else
#define _debug(...)
#define _debugStart(...)
......@@ -56,6 +57,7 @@ typedef short int16;
#define _debugEnd(...)
#define _debugException(...)
#define _debugInit(...)
#define _debugAlsa(...)
#endif
#define SFLPHONED_VERSION "0.7.2"
......@@ -72,14 +74,7 @@ typedef short int16;
#define CHANNELS 2
#define SIZEBUF 1024*1024
// Codecs payloads, as defined in RFC3551
// http://www.iana.org/assignments/rtp-parameters
// http://www.gnu.org/software/ccrtp/doc/refman/html/formats_8h.html#a0
/*#define PAYLOAD_CODEC_ULAW 0 // PCMU 8000
#define PAYLOAD_CODEC_ALAW 8 // PCMA 8000
#define PAYLOAD_CODEC_GSM 3 // GSM 8000
// http://www.ietf.org/rfc/rfc3952.txt
#define PAYLOAD_CODEC_ILBC 97*/
#define PCM_FRONT "plug:front"
#define PCM_DEFAULT "default"
#endif // __GLOBAL_H__
......@@ -305,7 +305,7 @@ IAXVoIPLink::sendAudioFromMic(void)
// Audio codec still not determined.
if (audiolayer) {
// To keep latency low..
audiolayer->flushMic();
//audiolayer->flushMic();
}
return;
}
......@@ -548,7 +548,7 @@ IAXVoIPLink::answer(const CallID& id)
// Start audio
audiolayer->startStream();
audiolayer->flushMic();
//audiolayer->flushMic();
return true;
}
......@@ -749,7 +749,7 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call)
}
Manager::instance().peerAnsweredCall(id);
audiolayer->flushMic();
//audiolayer->flushMic();
audiolayer->startStream();
// start audio here?