Commit 4f26d8ee authored by Philippe Gorley's avatar Philippe Gorley

audio: make receiver observable

Matches the video receive thread, video input and audio input.

Change-Id: I77d3d4286301c75ebeabeeab6e6d882656020fba
parent 10126454
......@@ -93,20 +93,18 @@ void
AudioReceiveThread::process()
{
AudioFormat mainBuffFormat = Manager::instance().getRingBufferPool().getInternalAudioFormat();
AudioFrame decodedFrame;
switch (audioDecoder_->decode(decodedFrame)) {
auto decodedFrame = std::make_shared<AudioFrame>();
switch (audioDecoder_->decode(*decodedFrame)) {
case MediaDecoder::Status::FrameFinished:
{
auto rec = recorder_.lock();
if (rec && rec->isRecording())
rec->recordData(decodedFrame.pointer(), audioDecoder_->getStream("a:remote"));
rec->recordData(decodedFrame->pointer(), audioDecoder_->getStream("a:remote"));
}
audioDecoder_->writeToRingBuffer(decodedFrame, *ringbuffer_,
audioDecoder_->writeToRingBuffer(*decodedFrame, *ringbuffer_,
mainBuffFormat);
notify(decodedFrame);
return;
case MediaDecoder::Status::DecodeError:
RING_WARN("decoding failure, trying to reset decoder...");
if (not setup()) {
......@@ -117,12 +115,10 @@ AudioReceiveThread::process()
loop_.stop();
}
break;
case MediaDecoder::Status::ReadError:
RING_ERR("fatal error, read failed");
loop_.stop();
break;
case MediaDecoder::Status::Success:
case MediaDecoder::Status::EOFError:
default:
......
......@@ -23,6 +23,7 @@
#include "media_buffer.h"
#include "media_device.h"
#include "noncopyable.h"
#include "observer.h"
#include "socket_pair.h"
#include "threadloop.h"
......@@ -35,7 +36,7 @@ class MediaIOHandle;
class MediaRecorder;
class RingBuffer;
class AudioReceiveThread
class AudioReceiveThread : Observable<std::shared_ptr<AudioFrame>>
{
public:
AudioReceiveThread(const std::string &id,
......
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