Skip to content
Snippets Groups Projects
Commit ae7f0730 authored by Rafaël Carré's avatar Rafaël Carré
Browse files

audiolayer : cleanup

parent 4b391c15
Branches
Tags
No related merge requests found
...@@ -68,10 +68,7 @@ AlsaLayer::~AlsaLayer (void) ...@@ -68,10 +68,7 @@ AlsaLayer::~AlsaLayer (void)
_debug ("Audio: Destroy of ALSA layer"); _debug ("Audio: Destroy of ALSA layer");
closeLayer(); closeLayer();
if (_converter) {
delete _converter; delete _converter;
_converter = NULL;
}
} }
bool bool
...@@ -103,7 +100,7 @@ AlsaLayer::closeLayer() ...@@ -103,7 +100,7 @@ AlsaLayer::closeLayer()
return true; return true;
} }
bool void
AlsaLayer::openDevice (int indexIn, int indexOut, int indexRing, int sampleRate, int frameSize, int stream , std::string plugin) AlsaLayer::openDevice (int indexIn, int indexOut, int indexRing, int sampleRate, int frameSize, int stream , std::string plugin)
{ {
/* Close the devices before open it */ /* Close the devices before open it */
...@@ -136,8 +133,6 @@ AlsaLayer::openDevice (int indexIn, int indexOut, int indexRing, int sampleRate, ...@@ -136,8 +133,6 @@ AlsaLayer::openDevice (int indexIn, int indexOut, int indexRing, int sampleRate,
AudioLayer::_dcblocker = new DcBlocker(); AudioLayer::_dcblocker = new DcBlocker();
AudioLayer::_audiofilter = new AudioProcessing (static_cast<Algorithm *> (_dcblocker)); AudioLayer::_audiofilter = new AudioProcessing (static_cast<Algorithm *> (_dcblocker));
return true;
} }
void void
...@@ -801,14 +796,13 @@ AlsaLayer::soundCardIndexExist (int card , int stream) ...@@ -801,14 +796,13 @@ AlsaLayer::soundCardIndexExist (int card , int stream)
ss << card ; ss << card ;
name.append (ss.str()); name.append (ss.str());
if (snd_ctl_open (&handle, name.c_str(), 0) == 0) { 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_pcm_info (handle , pcminfo) < 0) return false;
else
return true;
} else
return false; 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 int
......
...@@ -79,7 +79,7 @@ class AlsaLayer : public AudioLayer ...@@ -79,7 +79,7 @@ class AlsaLayer : public AudioLayer
* SFL_PCM_BOTH * SFL_PCM_BOTH
* @param plugin The alsa plugin ( dmix , default , front , surround , ...) * @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. * Start the capture stream and prepare the playback stream.
......
...@@ -93,7 +93,8 @@ class AudioLayer ...@@ -93,7 +93,8 @@ class AudioLayer
*/ */
virtual ~AudioLayer (void) { virtual ~AudioLayer (void) {
delete _time; delete _time;
_time = NULL; delete _dcblocker;
delete _audiofilter;
} }
virtual bool closeLayer (void) = 0; virtual bool closeLayer (void) = 0;
...@@ -111,7 +112,7 @@ class AudioLayer ...@@ -111,7 +112,7 @@ class AudioLayer
* SFL_PCM_BOTH * SFL_PCM_BOTH
* @param plugin The alsa plugin ( dmix , default , front , surround , ...) * @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. * Start the capture stream and prepare the playback stream.
......
...@@ -252,16 +252,7 @@ PulseLayer::~PulseLayer (void) ...@@ -252,16 +252,7 @@ PulseLayer::~PulseLayer (void)
{ {
closeLayer (); closeLayer ();
if (_converter) {
delete _converter; delete _converter;
_converter = NULL;
}
delete AudioLayer::_dcblocker;
AudioLayer::_dcblocker = NULL;
delete AudioLayer::_audiofilter;
AudioLayer::_audiofilter = NULL;
} }
void void
...@@ -402,7 +393,7 @@ void PulseLayer::context_state_callback (pa_context* c, void* user_data) ...@@ -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); _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 ...@@ -417,8 +408,6 @@ bool PulseLayer::openDevice (int indexIn UNUSED, int indexOut UNUSED, int indexR
// Instantiate the algorithm // Instantiate the algorithm
AudioLayer::_dcblocker = new DcBlocker(); AudioLayer::_dcblocker = new DcBlocker();
AudioLayer::_audiofilter = new AudioProcessing (static_cast<Algorithm *> (_dcblocker)); AudioLayer::_audiofilter = new AudioProcessing (static_cast<Algorithm *> (_dcblocker));
return true;
} }
......
...@@ -77,7 +77,7 @@ class PulseLayer : public AudioLayer ...@@ -77,7 +77,7 @@ class PulseLayer : public AudioLayer
* SFL_PCM_BOTH * SFL_PCM_BOTH
* @param plugin The alsa plugin ( dmix , default , front , surround , ...) * @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) { DeviceList* getSinkList (void) {
return &_sinkList; return &_sinkList;
......
...@@ -119,7 +119,7 @@ void AudioLayerTest::testPulseConnect() ...@@ -119,7 +119,7 @@ void AudioLayerTest::testPulseConnect()
_pulselayer->setErrorMessage (-1); _pulselayer->setErrorMessage (-1);
try { 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 (...) { } catch (...) {
_debug ("Exception occured wile opening device! "); _debug ("Exception occured wile opening device! ");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment