Commit 8dffc9b6 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #6692: audiolayer cleanup

parent e3dbfbcc
This diff is collapsed.
......@@ -42,9 +42,6 @@
class RingBuffer;
class ManagerImpl;
/** Associate a sound card index to its string description */
typedef std::pair<int , std::string> HwIDPair;
/**
* @file AlsaLayer.h
* @brief Main sound class. Manages the data transfers between the application and the hardware.
......@@ -79,7 +76,7 @@ class AlsaLayer : public AudioLayer
* SFL_PCM_BOTH
* @param plugin The alsa plugin ( dmix , default , front , surround , ...)
*/
void 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, const std::string &plugin);
/**
* Start the capture stream and prepare the playback stream.
......@@ -152,7 +149,7 @@ class AlsaLayer : public AudioLayer
* @return std::string The name of the audio plugin
*/
std::string getAudioPlugin (void) const {
return _audioPlugin;
return audioPlugin_;
}
void audioCallback (void);
......@@ -174,6 +171,9 @@ class AlsaLayer : public AudioLayer
virtual void setNoiseSuppressState (bool state);
private:
/** Associate a sound card index to its string description */
typedef std::pair<int , std::string> HwIDPair;
// Copy Constructor
AlsaLayer (const AlsaLayer& rh);
......@@ -181,57 +181,6 @@ class AlsaLayer : public AudioLayer
// Assignment Operator
AlsaLayer& operator= (const AlsaLayer& rh);
bool is_playback_prepared (void) {
return _is_prepared_playback;
}
bool is_capture_prepared (void) {
return _is_prepared_capture;
}
void prepare_playback (void) {
_is_prepared_playback = true;
}
void prepare_capture (void) {
_is_prepared_capture = true;
}
bool is_capture_running (void) {
return _is_running_capture;
}
bool is_playback_running (void) {
return _is_running_playback;
}
void start_playback (void) {
_is_running_playback = true;
}
void stop_playback (void) {
_is_running_playback = false;
_is_prepared_playback = false;
}
void start_capture (void) {
_is_running_capture = true;
}
void stop_capture (void) {
_is_running_capture = false;
_is_prepared_capture = false;
}
void close_playback (void) {
_is_open_playback = false;
}
void close_capture (void) {
_is_open_capture = false;
}
void open_playback (void) {
_is_open_playback = true;
}
void open_capture (void) {
_is_open_capture = true;
}
bool is_capture_open (void) {
return _is_open_capture;
}
bool is_playback_open (void) {
return _is_open_playback;
}
/**
* Drop the pending frames and close the capture device
* ALSA Library API
......@@ -292,54 +241,49 @@ class AlsaLayer : public AudioLayer
*/
void handle_xrun_playback (snd_pcm_t *handle);
void adjustVolume (SFLDataFormat* buffer , int samples, int volumePercentage);
/**
* Handles to manipulate playback stream
* ALSA Library API
*/
snd_pcm_t* _PlaybackHandle;
snd_pcm_t* playbackHandle_;
/**
* Handles to manipulate ringtone stream
*
*/
snd_pcm_t *_RingtoneHandle;
snd_pcm_t *ringtoneHandle_;
/**
* Handles to manipulate capture stream
* ALSA Library API
*/
snd_pcm_t* _CaptureHandle;
snd_pcm_t* captureHandle_;
/**
* Alsa parameter - Size of a period in the hardware ring buffer
*/
snd_pcm_uframes_t _periodSize;
snd_pcm_uframes_t periodSize_;
/**
* name of the alsa audio plugin used
*/
std::string _audioPlugin;
std::string audioPlugin_;
/** Vector to manage all soundcard index - description association of the system */
std::vector<HwIDPair> IDSoundCards_;
bool _is_prepared_playback;
bool _is_prepared_capture;
bool _is_running_playback;
bool _is_running_capture;
bool _is_open_playback;
bool _is_open_capture;
bool _trigger_request;
bool is_playback_prepared_;
bool is_capture_prepared_;
bool is_playback_running_;
bool is_capture_running_;
bool is_playback_open_;
bool is_capture_open_;
bool trigger_request_;
AudioThread* _audioThread;
AudioThread* audioThread_;
/** Sample rate converter object */
SamplerateConverter* _converter;
// ofstream *captureFile;
SamplerateConverter* converter_;
};
#endif // _ALSA_LAYER_H_
......@@ -117,7 +117,7 @@ class AudioLayer
* SFL_PCM_BOTH
* @param plugin The alsa plugin ( dmix , default , front , surround , ...)
*/
virtual void 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 , const std::string &plugin) = 0;
/**
* Start the capture stream and prepare the playback stream.
......
......@@ -32,30 +32,18 @@
#include "pulselayer.h"
#include "managerimpl.h"
// #include <fstream>
int framesPerBuffer = 2048;
static void playback_callback (pa_stream* s, size_t bytes, void* userdata)
static void playback_callback (pa_stream* s, size_t bytes, void* userdata)
{
assert (s && bytes);
assert (bytes > 0);
static_cast<PulseLayer*> (userdata)->processPlaybackData();
}
static void capture_callback (pa_stream* s, size_t bytes, void* userdata)
{
assert (s && bytes);
assert (bytes > 0);
static_cast<PulseLayer*> (userdata)->processCaptureData();
}
static void ringtone_callback (pa_stream* s, size_t bytes, void* userdata)
......@@ -390,7 +378,7 @@ void PulseLayer::context_state_callback (pa_context* c, void* user_data)
}
}
void 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, const std::string &plugin UNUSED)
{
_debug ("Audio: Open device sampling rate %d, frame size %d", _audioSampleRate, _frameSize);
......
......@@ -77,7 +77,7 @@ class PulseLayer : public AudioLayer
* SFL_PCM_BOTH
* @param plugin The alsa plugin ( dmix , default , front , surround , ...)
*/
void 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, const std::string &plugin) ;
DeviceList* getSinkList (void) {
return &_sinkList;
......
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