Commit f18b84c6 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #6692: cleanup/refactoring in audiolayers

parent 8e4e63eb
......@@ -108,7 +108,7 @@ AlsaLayer::~AlsaLayer (void)
delete converter_;
}
bool
void
AlsaLayer::closeLayer()
{
_debugAlsa ("Audio: Close ALSA streams");
......@@ -132,8 +132,6 @@ AlsaLayer::closeLayer()
captureHandle_ = NULL;
playbackHandle_ = NULL;
ringtoneHandle_ = NULL;
return true;
}
void
......@@ -258,14 +256,6 @@ AlsaLayer::stopStream (void)
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)
{
// if a stream already opened
......
......@@ -59,8 +59,6 @@ class AlsaLayer : public AudioLayer
*/
~AlsaLayer (void);
bool closeLayer (void);
/**
* Check if no devices are opened, otherwise close them.
* Then open the specified devices by calling the private functions open_device
......@@ -90,12 +88,6 @@ class AlsaLayer : public AudioLayer
*/
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
* @param buffer The buffer for data
......@@ -152,8 +144,6 @@ class AlsaLayer : public AudioLayer
void audioCallback (void);
bool isCaptureActive (void);
/**
* Get the noise suppressor state
* @return true if noise suppressor activated
......@@ -169,6 +159,8 @@ class AlsaLayer : public AudioLayer
virtual void setNoiseSuppressState (bool state);
private:
void closeLayer (void);
/** Associate a sound card index to its string description */
typedef std::pair<int , std::string> HwIDPair;
......
......@@ -72,8 +72,6 @@ class AudioLayer
*/
virtual ~AudioLayer (void);
virtual bool closeLayer (void) = 0;
/**
* Check if no devices are opened, otherwise close them.
* Then open the specified devices by calling the private functions open_device
......@@ -117,9 +115,6 @@ class AudioLayer
void flushUrgent (void);
virtual bool isCaptureActive (void) = 0;
/**
* Write accessor to the error state
* @param error The error code
......
This diff is collapsed.
......@@ -33,15 +33,9 @@
#define _PULSE_LAYER_H
#include "audio/audiolayer.h"
#include "audio/samplerateconverter.h"
#include "audio/dcblocker.h"
#include "audiostream.h"
#include <pulse/pulseaudio.h>
#include <pulse/stream.h>
#include <stdlib.h>
#include <list>
#include <string>
......@@ -51,6 +45,9 @@
class RingBuffer;
class ManagerImpl;
class AudioStream;
class DcBlocker;
class SamplerateConverter;
typedef std::list<std::string> DeviceList;
......@@ -59,11 +56,6 @@ class PulseLayer : public AudioLayer
public:
PulseLayer (ManagerImpl* manager);
~PulseLayer (void);
void openLayer (void);
bool closeLayer (void);
/**
* Check if no devices are opened, otherwise close them.
* Then open the specified devices by calling the private functions open_device
......@@ -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) ;
DeviceList* getSinkList (void) {
return &_sinkList;
return &sinkList_;
}
DeviceList* getSourceList (void) {
return &_sourceList;
return &sourceList_;
}
void updateSinkList (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 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 stream_suspended_callback ( pa_stream* s, void* userdata );
bool isCaptureActive (void) {
return true;
}
/**
* Reduce volume of every audio applications connected to the same sink
......@@ -141,38 +119,38 @@ class PulseLayer : public AudioLayer
* Accessor
* @return AudioStream* The pointer on the playback AudioStream object
*/
AudioStream* getPlaybackStream() {
return playback;
AudioStream* getPlaybackStream() const {
return playback_;
}
/**
* Accessor
* @return AudioStream* The pointer on the record AudioStream object
*/
AudioStream* getRecordStream() {
return record;
AudioStream* getRecordStream() const {
return record_;
}
/**
* Accessor
* @return AudioStream* The pointer on the ringtone AudioStream object
*/
AudioStream* getRingtoneStream() {
return ringtone;
AudioStream* getRingtoneStream() const {
return ringtone_;
}
int getSpkrVolume (void) {
return spkrVolume;
int getSpkrVolume (void) const {
return spkrVolume_;
}
void setSpkrVolume (int value) {
spkrVolume = value;
spkrVolume_ = value;
}
int getMicVolume (void) {
return micVolume;
int getMicVolume (void) const {
return micVolume_;
}
void setMicVolume (int value) {
micVolume = value;
micVolume_ = value;
}
/**
......@@ -233,7 +211,7 @@ class PulseLayer : public AudioLayer
* Create the audio streams into the given 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
......@@ -248,46 +226,47 @@ class PulseLayer : public AudioLayer
/**
* Close the connection with the local pulseaudio server
*/
bool disconnectAudioStream (void);
void disconnectAudioStream (void);
/**
* Get some information about the pulseaudio server
*/
void serverinfo (void);
void openLayer (void);
void closeLayer (void);
/** PulseAudio context and asynchronous loop */
pa_context* context;
pa_threaded_mainloop* m;
pa_context* context_;
pa_threaded_mainloop* mainloop_;
/**
* A stream object to handle the pulseaudio playback stream
*/
AudioStream* playback;
AudioStream* playback_;
/**
* A stream object to handle the pulseaudio capture stream
*/
AudioStream* record;
AudioStream* record_;
/**
* A special stream object to handle specific playback stream for ringtone
*/
AudioStream* ringtone;
AudioStream* ringtone_;
/** Sample rate converter object */
SamplerateConverter * _converter;
int spkrVolume;
int micVolume;
SamplerateConverter * converter_;
DeviceList _sinkList;
int spkrVolume_;
int micVolume_;
DeviceList _sourceList;
int byteCounter;
DeviceList sinkList_;
DeviceList sourceList_;
public:
friend class AudioLayerTest;
};
......
......@@ -471,14 +471,14 @@ class AudioPreference : public Serializable
std::string getDevicePlayback (void) const {
return _devicePlayback;
}
void setDevicePlayback (std::string p) {
void setDevicePlayback (const std::string &p) {
_devicePlayback = p;
}
std::string getDeviceRecord (void) const {
return _deviceRecord;
}
void setDeviceRecord (std::string r) {
void setDeviceRecord (const std::string &r) {
_deviceRecord = r;
}
......
......@@ -32,6 +32,7 @@
#include <sstream>
#include "audiolayertest.h"
#include "audio/pulseaudio/audiostream.h"
#include <unistd.h>
......
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