From a92bfb32d2bea7d1bc0cb9d3adac5efa8ca89a0f Mon Sep 17 00:00:00 2001 From: urioxis Date: Mon, 7 Feb 2011 16:56:48 +0000 Subject: [PATCH] AlsaOut tweaks. Must finish handling errors in that... --- src/contrib/alsaout/AlsaOut.cpp | 6 +++--- src/contrib/alsaout/AlsaOutBuffer.cpp | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/contrib/alsaout/AlsaOut.cpp b/src/contrib/alsaout/AlsaOut.cpp index 631910b19..9450ed063 100644 --- a/src/contrib/alsaout/AlsaOut.cpp +++ b/src/contrib/alsaout/AlsaOut.cpp @@ -44,9 +44,9 @@ AlsaOut::AlsaOut() std::cerr << "AlsaOut::AlsaOut() called" << std::endl; #endif int err; - if ((err = snd_pcm_open (&waveHandle, 0, SND_PCM_STREAM_PLAYBACK, 0)) < 0) { - std::cerr << "AlsaOut: cannot open audio device 0" << snd_strerror(err) << std::endl; - exit (1); + if ((err = snd_pcm_open (&waveHandle, "default", SND_PCM_STREAM_PLAYBACK, 0)) < 0) { + std::cerr << "AlsaOut: cannot open audio device 'default' :" << snd_strerror(err) << std::endl; + return; } #ifdef _DEBUG else { diff --git a/src/contrib/alsaout/AlsaOutBuffer.cpp b/src/contrib/alsaout/AlsaOutBuffer.cpp index df83c2605..dd8dbd02b 100644 --- a/src/contrib/alsaout/AlsaOutBuffer.cpp +++ b/src/contrib/alsaout/AlsaOutBuffer.cpp @@ -79,6 +79,10 @@ bool AlsaOutBuffer::AddToOutput(){ }*/ int err; snd_pcm_t* wHandle = waveOut->getWaveHandle(); + if (wHandle == NULL) { + printf("Error. No device handle \n"); + return false; + } frames = snd_pcm_writei(wHandle, (void*)data, bufferLength); if (frames < 0) frames = snd_pcm_recover(wHandle, frames, 0);