diff --git a/src/audio/alsalayer.cpp b/src/audio/alsalayer.cpp index 5409c855963e18002f45ebb8ab787a98afef0f83..f805d1be67510c7126127af99de1eb2c78d70337 100644 --- a/src/audio/alsalayer.cpp +++ b/src/audio/alsalayer.cpp @@ -55,14 +55,26 @@ AlsaLayer::closeLayer() { _debugAlsa("Close ALSA streams\n"); - if (_audioThread) + /* Stop the audio thread first */ + try { + if (_audioThread) + { + _debug("Try to stop audio thread\n"); + delete _audioThread; _audioThread=NULL; + } + } + catch( ... ) { - _debug("Try to stop audio thread\n"); - delete _audioThread; _audioThread=NULL; + _debugException("! Audio Thread Exception\n"); + throw; } + /* Then close the audio devices */ closeCaptureStream(); closePlaybackStream(); + + _CaptureHandle = 0; + _PlaybackHandle = 0; } bool @@ -373,8 +385,12 @@ AlsaLayer::open_device(std::string pcm_p, std::string pcm_c, int flag) } /* Start the secondary audio thread for callbacks */ - _audioThread->start(); - + try{ + _audioThread->start(); + } + catch (...) { + _debugException("Fail to start audio thread\n"); + } return true; } diff --git a/src/audio/audiortp.cpp b/src/audio/audiortp.cpp index ed25feec437a4373e2dc787453a348e3e9bb510a..62eb098abe788887528a15cb853a991524a0d9fd 100644 --- a/src/audio/audiortp.cpp +++ b/src/audio/audiortp.cpp @@ -89,8 +89,8 @@ AudioRtp::closeRtpSession () { _debugException("! ARTP Exception: when stopping audiortp\n"); throw; } - //AudioLayer* audiolayer = Manager::instance().getAudioDriver(); - //audiolayer->stopStream(); + AudioLayer* audiolayer = Manager::instance().getAudioDriver(); + audiolayer->stopStream(); } ////////////////////////////////////////////////////////////////////////////////