Skip to content
Snippets Groups Projects
Commit 4f26d8ee authored by Philippe Gorley's avatar Philippe Gorley
Browse files

audio: make receiver observable

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

Change-Id: I77d3d4286301c75ebeabeeab6e6d882656020fba
parent 10126454
Branches
No related tags found
No related merge requests found
...@@ -93,20 +93,18 @@ void ...@@ -93,20 +93,18 @@ void
AudioReceiveThread::process() AudioReceiveThread::process()
{ {
AudioFormat mainBuffFormat = Manager::instance().getRingBufferPool().getInternalAudioFormat(); AudioFormat mainBuffFormat = Manager::instance().getRingBufferPool().getInternalAudioFormat();
AudioFrame decodedFrame; auto decodedFrame = std::make_shared<AudioFrame>();
switch (audioDecoder_->decode(*decodedFrame)) {
switch (audioDecoder_->decode(decodedFrame)) {
case MediaDecoder::Status::FrameFinished: case MediaDecoder::Status::FrameFinished:
{ {
auto rec = recorder_.lock(); auto rec = recorder_.lock();
if (rec && rec->isRecording()) 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); mainBuffFormat);
notify(decodedFrame);
return; return;
case MediaDecoder::Status::DecodeError: case MediaDecoder::Status::DecodeError:
RING_WARN("decoding failure, trying to reset decoder..."); RING_WARN("decoding failure, trying to reset decoder...");
if (not setup()) { if (not setup()) {
...@@ -117,12 +115,10 @@ AudioReceiveThread::process() ...@@ -117,12 +115,10 @@ AudioReceiveThread::process()
loop_.stop(); loop_.stop();
} }
break; break;
case MediaDecoder::Status::ReadError: case MediaDecoder::Status::ReadError:
RING_ERR("fatal error, read failed"); RING_ERR("fatal error, read failed");
loop_.stop(); loop_.stop();
break; break;
case MediaDecoder::Status::Success: case MediaDecoder::Status::Success:
case MediaDecoder::Status::EOFError: case MediaDecoder::Status::EOFError:
default: default:
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "media_buffer.h" #include "media_buffer.h"
#include "media_device.h" #include "media_device.h"
#include "noncopyable.h" #include "noncopyable.h"
#include "observer.h"
#include "socket_pair.h" #include "socket_pair.h"
#include "threadloop.h" #include "threadloop.h"
...@@ -35,7 +36,7 @@ class MediaIOHandle; ...@@ -35,7 +36,7 @@ class MediaIOHandle;
class MediaRecorder; class MediaRecorder;
class RingBuffer; class RingBuffer;
class AudioReceiveThread class AudioReceiveThread : Observable<std::shared_ptr<AudioFrame>>
{ {
public: public:
AudioReceiveThread(const std::string &id, AudioReceiveThread(const std::string &id,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment