Skip to content
Snippets Groups Projects
Commit f18b84c6 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #6692: cleanup/refactoring in audiolayers

parent 8e4e63eb
No related branches found
No related tags found
No related merge requests found
...@@ -108,7 +108,7 @@ AlsaLayer::~AlsaLayer (void) ...@@ -108,7 +108,7 @@ AlsaLayer::~AlsaLayer (void)
delete converter_; delete converter_;
} }
bool void
AlsaLayer::closeLayer() AlsaLayer::closeLayer()
{ {
_debugAlsa ("Audio: Close ALSA streams"); _debugAlsa ("Audio: Close ALSA streams");
...@@ -132,8 +132,6 @@ AlsaLayer::closeLayer() ...@@ -132,8 +132,6 @@ AlsaLayer::closeLayer()
captureHandle_ = NULL; captureHandle_ = NULL;
playbackHandle_ = NULL; playbackHandle_ = NULL;
ringtoneHandle_ = NULL; ringtoneHandle_ = NULL;
return true;
} }
void void
...@@ -258,14 +256,6 @@ AlsaLayer::stopStream (void) ...@@ -258,14 +256,6 @@ AlsaLayer::stopStream (void)
flushMain (); flushMain ();
} }
bool AlsaLayer::isCaptureActive (void)
{
ost::MutexLock guard (_mutex);
return captureHandle_ and snd_pcm_state(captureHandle_) == SND_PCM_STATE_RUNNING;
}
void AlsaLayer::setNoiseSuppressState (bool state) void AlsaLayer::setNoiseSuppressState (bool state)
{ {
// if a stream already opened // if a stream already opened
... ...
......
...@@ -59,8 +59,6 @@ class AlsaLayer : public AudioLayer ...@@ -59,8 +59,6 @@ class AlsaLayer : public AudioLayer
*/ */
~AlsaLayer (void); ~AlsaLayer (void);
bool closeLayer (void);
/** /**
* Check if no devices are opened, otherwise close them. * Check if no devices are opened, otherwise close them.
* Then open the specified devices by calling the private functions open_device * Then open the specified devices by calling the private functions open_device
...@@ -90,12 +88,6 @@ class AlsaLayer : public AudioLayer ...@@ -90,12 +88,6 @@ class AlsaLayer : public AudioLayer
*/ */
void stopStream (void); void stopStream (void);
/**
* Query the capture device for number of bytes available in the hardware ring buffer
* @return int The number of bytes available
*/
int canGetMic();
/** /**
* Get data from the capture device * Get data from the capture device
* @param buffer The buffer for data * @param buffer The buffer for data
...@@ -152,8 +144,6 @@ class AlsaLayer : public AudioLayer ...@@ -152,8 +144,6 @@ class AlsaLayer : public AudioLayer
void audioCallback (void); void audioCallback (void);
bool isCaptureActive (void);
/** /**
* Get the noise suppressor state * Get the noise suppressor state
* @return true if noise suppressor activated * @return true if noise suppressor activated
...@@ -169,6 +159,8 @@ class AlsaLayer : public AudioLayer ...@@ -169,6 +159,8 @@ class AlsaLayer : public AudioLayer
virtual void setNoiseSuppressState (bool state); virtual void setNoiseSuppressState (bool state);
private: private:
void closeLayer (void);
/** Associate a sound card index to its string description */ /** Associate a sound card index to its string description */
typedef std::pair<int , std::string> HwIDPair; typedef std::pair<int , std::string> HwIDPair;
... ...
......
...@@ -72,8 +72,6 @@ class AudioLayer ...@@ -72,8 +72,6 @@ class AudioLayer
*/ */
virtual ~AudioLayer (void); virtual ~AudioLayer (void);
virtual bool closeLayer (void) = 0;
/** /**
* Check if no devices are opened, otherwise close them. * Check if no devices are opened, otherwise close them.
* Then open the specified devices by calling the private functions open_device * Then open the specified devices by calling the private functions open_device
...@@ -117,9 +115,6 @@ class AudioLayer ...@@ -117,9 +115,6 @@ class AudioLayer
void flushUrgent (void); void flushUrgent (void);
virtual bool isCaptureActive (void) = 0;
/** /**
* Write accessor to the error state * Write accessor to the error state
* @param error The error code * @param error The error code
... ...
......
This diff is collapsed.
...@@ -33,15 +33,9 @@ ...@@ -33,15 +33,9 @@
#define _PULSE_LAYER_H #define _PULSE_LAYER_H
#include "audio/audiolayer.h" #include "audio/audiolayer.h"
#include "audio/samplerateconverter.h"
#include "audio/dcblocker.h"
#include "audiostream.h"
#include <pulse/pulseaudio.h> #include <pulse/pulseaudio.h>
#include <pulse/stream.h> #include <pulse/stream.h>
#include <stdlib.h>
#include <list> #include <list>
#include <string> #include <string>
...@@ -51,6 +45,9 @@ ...@@ -51,6 +45,9 @@
class RingBuffer; class RingBuffer;
class ManagerImpl; class ManagerImpl;
class AudioStream;
class DcBlocker;
class SamplerateConverter;
typedef std::list<std::string> DeviceList; typedef std::list<std::string> DeviceList;
...@@ -59,11 +56,6 @@ class PulseLayer : public AudioLayer ...@@ -59,11 +56,6 @@ class PulseLayer : public AudioLayer
public: public:
PulseLayer (ManagerImpl* manager); PulseLayer (ManagerImpl* manager);
~PulseLayer (void); ~PulseLayer (void);
void openLayer (void);
bool closeLayer (void);
/** /**
* Check if no devices are opened, otherwise close them. * Check if no devices are opened, otherwise close them.
* Then open the specified devices by calling the private functions open_device * Then open the specified devices by calling the private functions open_device
...@@ -80,40 +72,26 @@ class PulseLayer : public AudioLayer ...@@ -80,40 +72,26 @@ class PulseLayer : public AudioLayer
void openDevice (int indexIn, int indexOut, int indexRing, int sampleRate, int frameSize , int stream, const std::string &plugin) ; void openDevice (int indexIn, int indexOut, int indexRing, int sampleRate, int frameSize , int stream, const std::string &plugin) ;
DeviceList* getSinkList (void) { DeviceList* getSinkList (void) {
return &_sinkList; return &sinkList_;
} }
DeviceList* getSourceList (void) { DeviceList* getSourceList (void) {
return &_sourceList; return &sourceList_;
} }
void updateSinkList (void); void updateSinkList (void);
void updateSourceList (void); void updateSourceList (void);
bool inSinkList (std::string deviceName); bool inSinkList (const std::string &deviceName) const;
bool inSourceList (std::string deviceName); bool inSourceList (const std::string &deviceName) const;
void startStream (void); void startStream (void);
void stopStream (void); void stopStream (void);
/**
* Query the capture device for number of bytes available in the hardware ring buffer
* @return int The number of bytes available
*/
int canGetMic();
static void overflow (pa_stream* s, void* userdata);
static void underflow (pa_stream* s, void* userdata);
static void stream_state_callback (pa_stream* s, void* user_data);
static void context_state_callback (pa_context* c, void* user_data); static void context_state_callback (pa_context* c, void* user_data);
// static void stream_suspended_callback ( pa_stream* s, void* userdata );
bool isCaptureActive (void) {
return true;
}
/** /**
* Reduce volume of every audio applications connected to the same sink * Reduce volume of every audio applications connected to the same sink
...@@ -141,38 +119,38 @@ class PulseLayer : public AudioLayer ...@@ -141,38 +119,38 @@ class PulseLayer : public AudioLayer
* Accessor * Accessor
* @return AudioStream* The pointer on the playback AudioStream object * @return AudioStream* The pointer on the playback AudioStream object
*/ */
AudioStream* getPlaybackStream() { AudioStream* getPlaybackStream() const {
return playback; return playback_;
} }
/** /**
* Accessor * Accessor
* @return AudioStream* The pointer on the record AudioStream object * @return AudioStream* The pointer on the record AudioStream object
*/ */
AudioStream* getRecordStream() { AudioStream* getRecordStream() const {
return record; return record_;
} }
/** /**
* Accessor * Accessor
* @return AudioStream* The pointer on the ringtone AudioStream object * @return AudioStream* The pointer on the ringtone AudioStream object
*/ */
AudioStream* getRingtoneStream() { AudioStream* getRingtoneStream() const {
return ringtone; return ringtone_;
} }
int getSpkrVolume (void) { int getSpkrVolume (void) const {
return spkrVolume; return spkrVolume_;
} }
void setSpkrVolume (int value) { void setSpkrVolume (int value) {
spkrVolume = value; spkrVolume_ = value;
} }
int getMicVolume (void) { int getMicVolume (void) const {
return micVolume; return micVolume_;
} }
void setMicVolume (int value) { void setMicVolume (int value) {
micVolume = value; micVolume_ = value;
} }
/** /**
...@@ -233,7 +211,7 @@ class PulseLayer : public AudioLayer ...@@ -233,7 +211,7 @@ class PulseLayer : public AudioLayer
* Create the audio streams into the given context * Create the audio streams into the given context
* @param c The pulseaudio context * @param c The pulseaudio context
*/ */
bool createStreams (pa_context* c); void createStreams (pa_context* c);
/** /**
* Drop the pending frames and close the playback device * Drop the pending frames and close the playback device
...@@ -248,46 +226,47 @@ class PulseLayer : public AudioLayer ...@@ -248,46 +226,47 @@ class PulseLayer : public AudioLayer
/** /**
* Close the connection with the local pulseaudio server * Close the connection with the local pulseaudio server
*/ */
bool disconnectAudioStream (void); void disconnectAudioStream (void);
/** /**
* Get some information about the pulseaudio server * Get some information about the pulseaudio server
*/ */
void serverinfo (void); void serverinfo (void);
void openLayer (void);
void closeLayer (void);
/** PulseAudio context and asynchronous loop */ /** PulseAudio context and asynchronous loop */
pa_context* context; pa_context* context_;
pa_threaded_mainloop* m; pa_threaded_mainloop* mainloop_;
/** /**
* A stream object to handle the pulseaudio playback stream * A stream object to handle the pulseaudio playback stream
*/ */
AudioStream* playback; AudioStream* playback_;
/** /**
* A stream object to handle the pulseaudio capture stream * A stream object to handle the pulseaudio capture stream
*/ */
AudioStream* record; AudioStream* record_;
/** /**
* A special stream object to handle specific playback stream for ringtone * A special stream object to handle specific playback stream for ringtone
*/ */
AudioStream* ringtone; AudioStream* ringtone_;
/** Sample rate converter object */ /** Sample rate converter object */
SamplerateConverter * _converter; SamplerateConverter * converter_;
int spkrVolume;
int micVolume;
DeviceList _sinkList; int spkrVolume_;
int micVolume_;
DeviceList _sourceList; DeviceList sinkList_;
DeviceList sourceList_;
int byteCounter;
public: public:
friend class AudioLayerTest; friend class AudioLayerTest;
}; };
... ...
......
...@@ -471,14 +471,14 @@ class AudioPreference : public Serializable ...@@ -471,14 +471,14 @@ class AudioPreference : public Serializable
std::string getDevicePlayback (void) const { std::string getDevicePlayback (void) const {
return _devicePlayback; return _devicePlayback;
} }
void setDevicePlayback (std::string p) { void setDevicePlayback (const std::string &p) {
_devicePlayback = p; _devicePlayback = p;
} }
std::string getDeviceRecord (void) const { std::string getDeviceRecord (void) const {
return _deviceRecord; return _deviceRecord;
} }
void setDeviceRecord (std::string r) { void setDeviceRecord (const std::string &r) {
_deviceRecord = r; _deviceRecord = r;
} }
... ...
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <sstream> #include <sstream>
#include "audiolayertest.h" #include "audiolayertest.h"
#include "audio/pulseaudio/audiostream.h"
#include <unistd.h> #include <unistd.h>
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment