Commit 7149cbbb authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

audio: start capture or playback stream.

Change-Id: If67bb0d338daca8d96a0398d0f9f0cbecb3293c9
parent ecc47105
......@@ -214,7 +214,7 @@ bool AlsaLayer::openDevice(snd_pcm_t **pcm, const std::string &dev, snd_pcm_stre
}
void
AlsaLayer::startStream()
AlsaLayer::startStream(AudioStreamType stream)
{
{
std::lock_guard<std::mutex> lock(mutex_);
......
......@@ -67,7 +67,7 @@ class AlsaLayer : public AudioLayer {
* The playback starts accordingly to its threshold
* ALSA Library API
*/
virtual void startStream();
virtual void startStream(AudioStreamType stream = AudioStreamType::DEFAULT);
/**
* Stop the playback and capture streams.
......
......@@ -60,6 +60,12 @@ enum class DeviceType {
RINGTONE /** To open the ringtone device only */
};
enum class AudioStreamType {
PLAYBACK, /** To start playback stream only */
CAPTURE, /** To start capture stream only */
DEFAULT /** To start both playback and capture streams */
};
class AudioLayer {
private:
......@@ -91,7 +97,7 @@ public:
* The playback starts accordingly to its threshold
* ALSA Library API
*/
virtual void startStream() = 0;
virtual void startStream(AudioStreamType stream = AudioStreamType::DEFAULT) = 0;
/**
* Stop the playback and capture streams.
......
......@@ -87,7 +87,7 @@ CoreLayer::getAudioDeviceName(int index, DeviceType type) const
}
void
CoreLayer::initAudioLayerIO()
CoreLayer::initAudioLayerIO(AudioStreamType stream)
{
JAMI_DBG("iOS CoreLayer - initializing audio session");
......@@ -135,8 +135,14 @@ CoreLayer::initAudioLayerIO()
break;
}
setupOutputBus();
setupInputBus();
bool setUpOutput = stream == AudioStreamType::DEFAULT || stream == AudioStreamType::PLAYBACK;
bool setUpInput = stream == AudioStreamType::DEFAULT || stream == AudioStreamType::CAPTURE;
if (setUpOutput) {
setupOutputBus();
}
if (setUpInput) {
setupInputBus();
}
bindCallbacks();
}
......@@ -308,7 +314,7 @@ CoreLayer::bindCallbacks() {
}
void
CoreLayer::startStream()
CoreLayer::startStream(AudioStreamType stream)
{
JAMI_DBG("iOS CoreLayer - Start Stream");
......@@ -321,7 +327,7 @@ CoreLayer::startStream()
dcblocker_.reset();
initAudioLayerIO();
initAudioLayerIO(stream);
// Run
auto inputRes = AudioUnitInitialize(ioUnit_);
......
......@@ -83,7 +83,7 @@ class CoreLayer : public AudioLayer {
/**
* Configure the AudioUnit
*/
void initAudioLayerIO();
void initAudioLayerIO(AudioStreamType stream);
void setupOutputBus();
void setupInputBus();
void bindCallbacks();
......@@ -96,7 +96,7 @@ class CoreLayer : public AudioLayer {
* CoreAudio Library API
*/
virtual void startStream();
virtual void startStream(AudioStreamType stream = AudioStreamType::DEFAULT);
void destroyAudioLayer();
......
......@@ -230,7 +230,7 @@ CoreLayer::initAudioLayerIO()
}
void
CoreLayer::startStream()
CoreLayer::startStream(AudioStreamType stream)
{
JAMI_DBG("START STREAM");
......
......@@ -97,7 +97,7 @@ class CoreLayer : public AudioLayer {
* CoreAudio Library API
*/
virtual void startStream();
virtual void startStream(AudioStreamType stream = AudioStreamType::DEFAULT);
void destroyAudioLayer();
......
......@@ -347,7 +347,7 @@ JackLayer::process_playback(jack_nframes_t frames, void *arg)
* Start the capture and playback.
*/
void
JackLayer::startStream()
JackLayer::startStream(AudioStreamType stream)
{
{
std::lock_guard<std::mutex> lock(mutex_);
......
......@@ -75,7 +75,7 @@ private:
/**
* Start the capture and playback.
*/
void startStream();
void startStream(AudioStreamType stream = AudioStreamType::DEFAULT);
/**
* Stop playback and capture.
......
......@@ -68,7 +68,7 @@ OpenSLLayer::init()
}
void
OpenSLLayer::startStream()
OpenSLLayer::startStream(AudioStreamType stream)
{
std::lock_guard<std::mutex> lock(mutex_);
if (status_ != Status::Idle)
......
......@@ -67,7 +67,7 @@ class OpenSLLayer : public AudioLayer {
* Start the capture stream and prepare the playback stream.
* The playback starts accordingly to its threshold
*/
virtual void startStream();
virtual void startStream(AudioStreamType stream = AudioStreamType::DEFAULT);
/**
* Stop the playback and capture streams.
......
......@@ -155,7 +155,7 @@ PortAudioLayer::getIndexRingtone() const
}
void
PortAudioLayer::startStream()
PortAudioLayer::startStream(AudioStreamType stream)
{
{
std::lock_guard<std::mutex> lock(mutex_);
......
......@@ -47,7 +47,7 @@ public:
* Start the capture stream and prepare the playback stream.
* The playback starts accordingly to its threshold
*/
void startStream() override;
void startStream(AudioStreamType stream = AudioStreamType::DEFAULT) override;
/**
* Stop the playback and capture streams.
......
......@@ -373,7 +373,7 @@ void PulseLayer::disconnectAudioStream()
record_.reset();
}
void PulseLayer::startStream()
void PulseLayer::startStream(AudioStreamType stream)
{
std::unique_lock<std::mutex> lk(readyMtx_);
readyCv_.wait(lk, [this] {
......
......@@ -130,7 +130,7 @@ class PulseLayer : public AudioLayer {
std::string getAudioDeviceName(int index, DeviceType type) const;
virtual void startStream();
virtual void startStream(AudioStreamType stream = AudioStreamType::DEFAULT);
virtual void stopStream();
private:
......
Markdown is supported
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