diff --git a/src/media/audio/audio_receive_thread.cpp b/src/media/audio/audio_receive_thread.cpp index 9e8826c759b1b0e2322a7ef69e8f805b7cbc85b5..f320a8b7c9ba1440287a1a050be05b63e9fc110a 100644 --- a/src/media/audio/audio_receive_thread.cpp +++ b/src/media/audio/audio_receive_thread.cpp @@ -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: diff --git a/src/media/audio/audio_receive_thread.h b/src/media/audio/audio_receive_thread.h index 4f6572f8a63d4d70fc718741a99e6cf4783033f5..38a75a6a1d696141b181441dc29390c82fb30089 100644 --- a/src/media/audio/audio_receive_thread.h +++ b/src/media/audio/audio_receive_thread.h @@ -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,