diff --git a/autogen.sh b/autogen.sh index 060b7d28caecc796d33338ec6d96568c6187cef8..06b6a97c95e0c7f4db9c8bd21a358a14784e9187 100755 --- a/autogen.sh +++ b/autogen.sh @@ -6,5 +6,4 @@ libtoolize --force autoheader autoconf -f automake -a - -echo "\nDone! Now you can ./configure. \n" +./configure $@ diff --git a/sflphone-gtk/autogen.sh b/sflphone-gtk/autogen.sh index 826d47d8edba52766a7a63430c6a517ad78a7b49..115f4372542d9a656c19679513bf20b076c206cf 100755 --- a/sflphone-gtk/autogen.sh +++ b/sflphone-gtk/autogen.sh @@ -6,6 +6,6 @@ libtoolize --force autoheader autoconf -f automake -a +./configure $@ -echo "\nDone! Now you can ./configure." diff --git a/sflphone-gtk/src/errors.c b/sflphone-gtk/src/errors.c index 00db523d7842547f407df60ea04bba191bf3d96f..9f9842720b9d5d443c9fde7148790e4d867ea675 100644 --- a/sflphone-gtk/src/errors.c +++ b/sflphone-gtk/src/errors.c @@ -30,6 +30,9 @@ sflphone_throw_exception( int err ) case ALSA_CAPTURE_DEVICE: markup = g_markup_printf_escaped(_("<b>ALSA notification</b>\n\nError while opening capture device")); break; + case PULSEAUDIO_NOT_RUNNING: + markup = g_markup_printf_escaped(_("<b>Pulseaudio notification</b>\n\nPulseaudio is not running")); + break; } main_window_error_message( markup ); free( markup ); diff --git a/sflphone-gtk/src/sflphone_const.h b/sflphone-gtk/src/sflphone_const.h index 134f462cab85e263c4d63806cae8b356bf6dc049..34faa3f59d9cdbdffbd0d59ed40cff3ee93217dd 100644 --- a/sflphone-gtk/src/sflphone_const.h +++ b/sflphone-gtk/src/sflphone_const.h @@ -66,6 +66,10 @@ #define ALSA_CAPTURE_DEVICE 0x0001 /** Error while opening playback device */ #define ALSA_PLAYBACK_DEVICE 0x0010 +/** Error pulseaudio */ +#define PULSEAUDIO_NOT_RUNNING 0x0100 + + /** Tone to play when no voice mails */ #define TONE_WITHOUT_MESSAGE 0 diff --git a/src/global.h b/src/global.h index 69ac066acc7cab7cb24911d7d022ab3edabd4b10..e95d776764d08d4d0935d08bed9890873ae13a27 100644 --- a/src/global.h +++ b/src/global.h @@ -126,6 +126,7 @@ typedef short int16; #define ALSA_CAPTURE_DEVICE 0x0001 /** Error while opening capture device */ #define ALSA_PLAYBACK_DEVICE 0x0010 /** Error while opening playback device */ #define NETWORK_UNREACHABLE 0x0011 /** Network unreachable */ +#define PULSEAUDIO_NOT_RUNNING 0x0100 /** Pulseaudio is not running */ #define ALSA 0 #define PULSEAUDIO 1 diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index 341e55f33b24a9872aed6a3386c6a07cd58c2b39..51d8342d80b9420de3435c53a01b7e1e46501606 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -1522,11 +1522,27 @@ ManagerImpl::setPulseAppVolumeControl( void ) (getConfigInt( PREFERENCES , CONFIG_PA_VOLUME_CTRL ) == 1)? setConfig( PREFERENCES , CONFIG_PA_VOLUME_CTRL , NO_STR) : setConfig( PREFERENCES , CONFIG_PA_VOLUME_CTRL , YES_STR) ; } -void -ManagerImpl::setAudioManager( const int32_t& api ) +void ManagerImpl::setAudioManager( const int32_t& api ) { - setConfig( PREFERENCES , CONFIG_AUDIO , api) ; - switchAudioManager(); + int manager; + + manager = api; + if( manager == PULSEAUDIO ) + { + if(app_is_running("pulseaudio") != 0) + { + // The pulseaudio daemon is not running + manager = ALSA; + notifyErrClient(PULSEAUDIO_NOT_RUNNING); + } + } + + if(manager == api) + { + // it means that we can change the audio manager + setConfig( PREFERENCES , CONFIG_AUDIO , api) ; + switchAudioManager(); + } } int32_t @@ -1571,6 +1587,14 @@ ManagerImpl::getCurrentAudioOutputPlugin( void ) return _audiodriver -> getAudioPlugin(); } +int ManagerImpl::app_is_running( std::string process ) +{ + std::ostringstream cmd; + + cmd << "ps -C " << process; + return system(cmd.str().c_str()); +} + /** * Initialization: Main Thread @@ -1583,12 +1607,23 @@ ManagerImpl::initAudioDriver(void) _debugInit("AudioLayer Creation"); - if( getConfigInt( PREFERENCES , CONFIG_AUDIO ) == ALSA ) - _audiodriver = new AlsaLayer( this ); - else if( getConfigInt( PREFERENCES , CONFIG_AUDIO ) == PULSEAUDIO ) - _audiodriver = new PulseLayer( this ); - else - _debug("Error - Audio API unknown\n"); + if( getConfigInt( PREFERENCES , CONFIG_AUDIO ) == ALSA ) + { + _audiodriver = new AlsaLayer( this ); + } + else if( getConfigInt( PREFERENCES , CONFIG_AUDIO ) == PULSEAUDIO ) + { + if( app_is_running("pulseaudio") == 0 ) + { + _audiodriver = new PulseLayer( this ); + } else + { + _audiodriver = new AlsaLayer( this ); + setConfig( PREFERENCES, CONFIG_AUDIO, ALSA); + } + } + else + _debug("Error - Audio API unknown\n"); if (_audiodriver == 0) { _debug("Init audio driver error\n"); @@ -1632,6 +1667,7 @@ ManagerImpl::selectAudioDriver (void) setConfig( AUDIO , ALSA_CARD_ID_OUT , ALSA_DFT_CARD_ID ); } + if(CHECK_INTERFACE( layer , ALSA )) { delete _audiodriver; diff --git a/src/managerimpl.h b/src/managerimpl.h index b97edb59d6de79e94137ccbc14f1658584427a95..6f5dac3fb737feaa5f6f0e6d14ecd6ff8fc458ff 100644 --- a/src/managerimpl.h +++ b/src/managerimpl.h @@ -829,6 +829,14 @@ class ManagerImpl { private: + /** + * Check if a process is running with the system command + * + * @return 0 on success + * 1 otherelse + */ + int app_is_running(std::string process); + /** * Create .PROGNAME directory in home user and create * configuration tree from the settings file if this file exists.