diff --git a/sflphone-common/src/audio/alsa/alsalayer.cpp b/sflphone-common/src/audio/alsa/alsalayer.cpp index 55dcf4f424736e4a1e323cf4a4516bae37a8a6b8..c13d56450e42fe44aebe23dc3eea51688d58e0ec 100644 --- a/sflphone-common/src/audio/alsa/alsalayer.cpp +++ b/sflphone-common/src/audio/alsa/alsalayer.cpp @@ -68,10 +68,7 @@ AlsaLayer::~AlsaLayer (void) _debug ("Audio: Destroy of ALSA layer"); closeLayer(); - if (_converter) { - delete _converter; - _converter = NULL; - } + delete _converter; } bool @@ -103,7 +100,7 @@ AlsaLayer::closeLayer() return true; } -bool +void AlsaLayer::openDevice (int indexIn, int indexOut, int indexRing, int sampleRate, int frameSize, int stream , std::string plugin) { /* Close the devices before open it */ @@ -136,8 +133,6 @@ AlsaLayer::openDevice (int indexIn, int indexOut, int indexRing, int sampleRate, AudioLayer::_dcblocker = new DcBlocker(); AudioLayer::_audiofilter = new AudioProcessing (static_cast<Algorithm *> (_dcblocker)); - - return true; } void @@ -801,14 +796,13 @@ AlsaLayer::soundCardIndexExist (int card , int stream) ss << card ; name.append (ss.str()); - if (snd_ctl_open (&handle, name.c_str(), 0) == 0) { - snd_pcm_info_set_stream (pcminfo , (stream == SFL_PCM_PLAYBACK) ? SND_PCM_STREAM_PLAYBACK : SND_PCM_STREAM_CAPTURE); + if (snd_ctl_open (&handle, name.c_str(), 0) != 0) + return false; - if (snd_ctl_pcm_info (handle , pcminfo) < 0) return false; - else - return true; - } else - return false; + snd_pcm_info_set_stream (pcminfo , (stream == SFL_PCM_PLAYBACK) ? SND_PCM_STREAM_PLAYBACK : SND_PCM_STREAM_CAPTURE); + bool ret = snd_ctl_pcm_info (handle , pcminfo) >= 0; + snd_ctl_close(handle); + return ret; } int diff --git a/sflphone-common/src/audio/alsa/alsalayer.h b/sflphone-common/src/audio/alsa/alsalayer.h index 2845d36e6b05987878281c9df43cd7fc2551056a..c317700327a35d44b9c63a8a9c81157cf7e5d1f4 100644 --- a/sflphone-common/src/audio/alsa/alsalayer.h +++ b/sflphone-common/src/audio/alsa/alsalayer.h @@ -79,7 +79,7 @@ class AlsaLayer : public AudioLayer * SFL_PCM_BOTH * @param plugin The alsa plugin ( dmix , default , front , surround , ...) */ - bool openDevice (int indexIn, int indexOut, int indexRing, int sampleRate, int frameSize, int stream, std::string plugin); + void openDevice (int indexIn, int indexOut, int indexRing, int sampleRate, int frameSize, int stream, std::string plugin); /** * Start the capture stream and prepare the playback stream. diff --git a/sflphone-common/src/audio/audiolayer.h b/sflphone-common/src/audio/audiolayer.h index f2108f319c757f5c41b414160664872bf05d8781..77e72610565cd7eac72b36cd69eb730c70aaf702 100644 --- a/sflphone-common/src/audio/audiolayer.h +++ b/sflphone-common/src/audio/audiolayer.h @@ -93,7 +93,8 @@ class AudioLayer */ virtual ~AudioLayer (void) { delete _time; - _time = NULL; + delete _dcblocker; + delete _audiofilter; } virtual bool closeLayer (void) = 0; @@ -111,7 +112,7 @@ class AudioLayer * SFL_PCM_BOTH * @param plugin The alsa plugin ( dmix , default , front , surround , ...) */ - virtual bool openDevice (int indexIn, int indexOut, int indexRing, int sampleRate, int frameSize, int stream , std::string plugin) = 0; + virtual void openDevice (int indexIn, int indexOut, int indexRing, int sampleRate, int frameSize, int stream , std::string plugin) = 0; /** * Start the capture stream and prepare the playback stream. diff --git a/sflphone-common/src/audio/pulseaudio/pulselayer.cpp b/sflphone-common/src/audio/pulseaudio/pulselayer.cpp index dcdf68fbc5ebbcce957929ca7f7b88b816ecdef7..08c2e6db9803242da2530bb7a8e27071ee485bfc 100644 --- a/sflphone-common/src/audio/pulseaudio/pulselayer.cpp +++ b/sflphone-common/src/audio/pulseaudio/pulselayer.cpp @@ -252,16 +252,7 @@ PulseLayer::~PulseLayer (void) { closeLayer (); - if (_converter) { - delete _converter; - _converter = NULL; - } - - delete AudioLayer::_dcblocker; - AudioLayer::_dcblocker = NULL; - - delete AudioLayer::_audiofilter; - AudioLayer::_audiofilter = NULL; + delete _converter; } void @@ -402,7 +393,7 @@ void PulseLayer::context_state_callback (pa_context* c, void* user_data) } } -bool PulseLayer::openDevice (int indexIn UNUSED, int indexOut UNUSED, int indexRing UNUSED, int sampleRate, int frameSize , int stream UNUSED, std::string plugin UNUSED) +void PulseLayer::openDevice (int indexIn UNUSED, int indexOut UNUSED, int indexRing UNUSED, int sampleRate, int frameSize , int stream UNUSED, std::string plugin UNUSED) { _debug ("Audio: Open device sampling rate %d, frame size %d", _audioSampleRate, _frameSize); @@ -417,8 +408,6 @@ bool PulseLayer::openDevice (int indexIn UNUSED, int indexOut UNUSED, int indexR // Instantiate the algorithm AudioLayer::_dcblocker = new DcBlocker(); AudioLayer::_audiofilter = new AudioProcessing (static_cast<Algorithm *> (_dcblocker)); - - return true; } diff --git a/sflphone-common/src/audio/pulseaudio/pulselayer.h b/sflphone-common/src/audio/pulseaudio/pulselayer.h index 7d4500731b085d802c75ac58f1afb27d3bb80514..7b89c1f12d5400fc538023719121adb7f00483d0 100644 --- a/sflphone-common/src/audio/pulseaudio/pulselayer.h +++ b/sflphone-common/src/audio/pulseaudio/pulselayer.h @@ -77,7 +77,7 @@ class PulseLayer : public AudioLayer * SFL_PCM_BOTH * @param plugin The alsa plugin ( dmix , default , front , surround , ...) */ - bool openDevice (int indexIn, int indexOut, int indexRing, int sampleRate, int frameSize , int stream, std::string plugin) ; + void openDevice (int indexIn, int indexOut, int indexRing, int sampleRate, int frameSize , int stream, std::string plugin) ; DeviceList* getSinkList (void) { return &_sinkList; diff --git a/sflphone-common/test/audiolayertest.cpp b/sflphone-common/test/audiolayertest.cpp index 0298f042cb841711782eab0f5436ba450a6ecb74..2984f0fe6ed7da926684ec271496b32074534abd 100644 --- a/sflphone-common/test/audiolayertest.cpp +++ b/sflphone-common/test/audiolayertest.cpp @@ -119,7 +119,7 @@ void AudioLayerTest::testPulseConnect() _pulselayer->setErrorMessage (-1); try { - CPPUNIT_ASSERT (_pulselayer->openDevice (numCardIn, numCardOut, numCardRing, sampleRate, frameSize, SFL_PCM_BOTH, alsaPlugin) == true); + _pulselayer->openDevice (numCardIn, numCardOut, numCardRing, sampleRate, frameSize, SFL_PCM_BOTH, alsaPlugin); } catch (...) { _debug ("Exception occured wile opening device! "); }