Commit ae7f0730 authored by Rafaël Carré's avatar Rafaël Carré
Browse files

audiolayer : cleanup

parent 4b391c15
......@@ -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
......
......@@ -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.
......
......@@ -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.
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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! ");
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment