Skip to content
Snippets Groups Projects
Commit 350f858f authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#1314] Add some return values to audio init functions

parent 780b74d2
No related branches found
No related tags found
No related merge requests found
...@@ -50,7 +50,7 @@ AlsaLayer::~AlsaLayer (void) ...@@ -50,7 +50,7 @@ AlsaLayer::~AlsaLayer (void)
closeLayer(); closeLayer();
} }
void bool
AlsaLayer::closeLayer() AlsaLayer::closeLayer()
{ {
_debugAlsa("Close ALSA streams\n"); _debugAlsa("Close ALSA streams\n");
...@@ -73,6 +73,8 @@ AlsaLayer::closeLayer() ...@@ -73,6 +73,8 @@ AlsaLayer::closeLayer()
_CaptureHandle = 0; _CaptureHandle = 0;
_PlaybackHandle = 0; _PlaybackHandle = 0;
return true;
} }
bool bool
......
...@@ -48,7 +48,7 @@ class AlsaLayer : public AudioLayer { ...@@ -48,7 +48,7 @@ class AlsaLayer : public AudioLayer {
*/ */
~AlsaLayer(void); ~AlsaLayer(void);
void closeLayer( void ); bool closeLayer( void );
/** /**
* Check if no devices are opened, otherwise close them. * Check if no devices are opened, otherwise close them.
......
...@@ -76,7 +76,7 @@ class AudioLayer { ...@@ -76,7 +76,7 @@ class AudioLayer {
*/ */
virtual ~AudioLayer(void) {} virtual ~AudioLayer(void) {}
virtual void closeLayer( void ) = 0; virtual bool closeLayer( void ) = 0;
/** /**
* Check if no devices are opened, otherwise close them. * Check if no devices are opened, otherwise close them.
......
...@@ -52,7 +52,7 @@ PulseLayer::~PulseLayer (void) ...@@ -52,7 +52,7 @@ PulseLayer::~PulseLayer (void)
pa_context_unref( context ); pa_context_unref( context );
} }
void bool
PulseLayer::closeLayer( void ) PulseLayer::closeLayer( void )
{ {
_debug("PulseLayer::closeLayer :: Destroy pulselayer\n"); _debug("PulseLayer::closeLayer :: Destroy pulselayer\n");
...@@ -66,6 +66,10 @@ PulseLayer::closeLayer( void ) ...@@ -66,6 +66,10 @@ PulseLayer::closeLayer( void )
//TODO Remove this ugly hack //TODO Remove this ugly hack
sleep(2); sleep(2);
return true;
} }
void void
...@@ -123,7 +127,7 @@ void PulseLayer::context_state_callback( pa_context* c, void* user_data ) ...@@ -123,7 +127,7 @@ void PulseLayer::context_state_callback( pa_context* c, void* user_data )
} }
} }
void PulseLayer::disconnectPulseAudioServer( void ) bool PulseLayer::disconnectPulseAudioServer( void )
{ {
_debug(" PulseLayer::disconnectPulseAudioServer( void ) \n"); _debug(" PulseLayer::disconnectPulseAudioServer( void ) \n");
if( playback ) if( playback )
...@@ -131,6 +135,11 @@ void PulseLayer::disconnectPulseAudioServer( void ) ...@@ -131,6 +135,11 @@ void PulseLayer::disconnectPulseAudioServer( void )
if( record ) if( record )
delete record; record=NULL; delete record; record=NULL;
if (!playback && !record)
return true;
else
return false;
} }
......
...@@ -37,7 +37,7 @@ class PulseLayer : public AudioLayer { ...@@ -37,7 +37,7 @@ class PulseLayer : public AudioLayer {
PulseLayer(ManagerImpl* manager); PulseLayer(ManagerImpl* manager);
~PulseLayer(void); ~PulseLayer(void);
void closeLayer( void ); bool closeLayer( void );
/** /**
* Check if no devices are opened, otherwise close them. * Check if no devices are opened, otherwise close them.
...@@ -168,7 +168,7 @@ class PulseLayer : public AudioLayer { ...@@ -168,7 +168,7 @@ class PulseLayer : public AudioLayer {
/** /**
* Close the connection with the local pulseaudio server * Close the connection with the local pulseaudio server
*/ */
void disconnectPulseAudioServer( void ); bool disconnectPulseAudioServer( void );
/** /**
* Get some information about the pulseaudio server * Get some information about the pulseaudio server
......
...@@ -1843,7 +1843,7 @@ int ManagerImpl::app_is_running( std::string process ) ...@@ -1843,7 +1843,7 @@ int ManagerImpl::app_is_running( std::string process )
/** /**
* Initialization: Main Thread * Initialization: Main Thread
*/ */
void bool
ManagerImpl::initAudioDriver(void) ManagerImpl::initAudioDriver(void)
{ {
...@@ -1871,13 +1871,17 @@ ManagerImpl::initAudioDriver(void) ...@@ -1871,13 +1871,17 @@ ManagerImpl::initAudioDriver(void)
if (_audiodriver == 0) { if (_audiodriver == 0) {
_debug("Init audio driver error\n"); _debug("Init audio driver error\n");
return false;
} else { } else {
error = getAudioDriver()->getErrorMessage(); error = getAudioDriver()->getErrorMessage();
if (error == -1) { if (error == -1) {
_debug("Init audio driver: %i\n", error); _debug("Init audio driver: %i\n", error);
return false;
} }
} }
return true;manager
} }
/** /**
...@@ -1974,7 +1978,7 @@ void ManagerImpl::switchAudioManager (void) ...@@ -1974,7 +1978,7 @@ void ManagerImpl::switchAudioManager (void)
// need to stop audio streams if there is currently no call // need to stop audio streams if there is currently no call
if( (type != PULSEAUDIO) && (!hasCurrentCall())) { if( (type != PULSEAUDIO) && (!hasCurrentCall())) {
_debug("There is currently a call!!\n"); // _debug("There is currently a call!!\n");
_audiodriver->stopStream(); _audiodriver->stopStream();
} }
......
...@@ -880,6 +880,11 @@ class ManagerImpl { ...@@ -880,6 +880,11 @@ class ManagerImpl {
*/ */
AccountMap getSipAccountMap( void ); AccountMap getSipAccountMap( void );
/*
* Initialize audiodriver
*/
bool initAudioDriver(void);
private: private:
/** /**
...@@ -905,10 +910,6 @@ class ManagerImpl { ...@@ -905,10 +910,6 @@ class ManagerImpl {
*/ */
void initAudioCodec(void); void initAudioCodec(void);
/*
* Initialize audiodriver
*/
void initAudioDriver(void);
/* /*
* Initialize zeroconf module and scanning * Initialize zeroconf module and scanning
......
include ../globals.mak include ../globals.mak
bin_PROGRAMS = numbercleanerTester pluginmanagerTester hookmanagerTester bin_PROGRAMS = numbercleanerTester pluginmanagerTester hookmanagerTester audiolayerTester
OBJECT_FILES= \ OBJECT_FILES= \
../src/sflphoned-managerimpl.o \ ../src/sflphoned-managerimpl.o \
...@@ -78,3 +78,21 @@ hookmanagerTester_LDADD = \ ...@@ -78,3 +78,21 @@ hookmanagerTester_LDADD = \
-luuid \ -luuid \
$(OBJECT_FILES) $(OBJECT_FILES)
audiolayerTester_SOURCES = \
audiolayerTest.h \
audiolayerTest.cpp \
TestMain.cpp
audiolayerTester_LDADD = \
../src/libsflphone.la \
$(SFLPHONE_LIBS) $(ZEROCONFLIB) $(LIB_DNSSD) \
@ALSA_LIBS@ \
@PULSEAUDIO_LIBS@ \
@CPPUNIT_LIBS@ \
@CCEXT2_LIBS@ \
@CCGNU2_LIBS@ \
@CCRTP_LIBS@ \
@SAMPLERATE_LIBS@ \
$(PJSIP_LIBS) \
-luuid \
$(OBJECT_FILES)
\ No newline at end of file
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software-
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
......
x/* /*
* Copyright (C) 2009 Savoir-Faire Linux inc. * Copyright (C) 2009 Savoir-Faire Linux inc.
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment