Skip to content
Snippets Groups Projects
Commit c6ab12e5 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Add protection when an error occurs while opening the audio device

parent a85fd524
No related branches found
No related tags found
No related merge requests found
...@@ -96,6 +96,8 @@ AudioLayer::openDevice (int indexIn, int indexOut, int sampleRate, int frameSize ...@@ -96,6 +96,8 @@ AudioLayer::openDevice (int indexIn, int indexOut, int sampleRate, int frameSize
void void
AudioLayer::startStream(void) AudioLayer::startStream(void)
{
if( _CaptureHandle && _PlaybackHandle )
{ {
_talk = true ; _talk = true ;
_debugAlsa(" Start stream\n"); _debugAlsa(" Start stream\n");
...@@ -107,9 +109,12 @@ AudioLayer::startStream(void) ...@@ -107,9 +109,12 @@ AudioLayer::startStream(void)
snd_pcm_prepare( _PlaybackHandle ); snd_pcm_prepare( _PlaybackHandle );
if( err = snd_pcm_start( _PlaybackHandle) < 0 ) _debugAlsa(" Cannot start (%s)\n", snd_strerror(err)); if( err = snd_pcm_start( _PlaybackHandle) < 0 ) _debugAlsa(" Cannot start (%s)\n", snd_strerror(err));
} }
}
void void
AudioLayer::stopStream(void) AudioLayer::stopStream(void)
{
if( _CaptureHandle && _PlaybackHandle )
{ {
//ost::MutexLock lock( _mutex ); //ost::MutexLock lock( _mutex );
_debugAlsa(" Stop Stream\n "); _debugAlsa(" Stop Stream\n ");
...@@ -120,6 +125,7 @@ AudioLayer::stopStream(void) ...@@ -120,6 +125,7 @@ AudioLayer::stopStream(void)
snd_pcm_prepare( _PlaybackHandle ); snd_pcm_prepare( _PlaybackHandle );
_urgentBuffer.flush(); _urgentBuffer.flush();
} }
}
void AudioLayer::AlsaCallBack( snd_async_handler_t* pcm_callback ) void AudioLayer::AlsaCallBack( snd_async_handler_t* pcm_callback )
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment