diff --git a/src/media/audio/audio_receive_thread.cpp b/src/media/audio/audio_receive_thread.cpp index 7fd31bb2c7abba68fa3319a54937427a451fd551..69a2d5e492e1a5da16154f1cc0d86c1a46c3036d 100644 --- a/src/media/audio/audio_receive_thread.cpp +++ b/src/media/audio/audio_receive_thread.cpp @@ -92,14 +92,11 @@ AudioReceiveThread::setup() void AudioReceiveThread::process() { - AudioFormat mainBuffFormat = Manager::instance().getRingBufferPool().getInternalAudioFormat(); - auto decodedFrame = std::make_unique<AudioFrame>(); - auto sharedFrame = std::make_shared<AudioFrame>(); + auto decodedFrame = std::make_shared<AudioFrame>(); switch (audioDecoder_->decode(*decodedFrame)) { case MediaDecoder::Status::FrameFinished: - sharedFrame->copyFrom(*decodedFrame); - audioDecoder_->writeToRingBuffer(std::move(decodedFrame), *ringbuffer_, mainBuffFormat); - notify(std::static_pointer_cast<MediaFrame>(sharedFrame)); + notify(std::static_pointer_cast<MediaFrame>(decodedFrame)); + ringbuffer_->put(std::move(decodedFrame)); return; case MediaDecoder::Status::DecodeError: RING_WARN("decoding failure, trying to reset decoder..."); diff --git a/src/media/media_decoder.cpp b/src/media/media_decoder.cpp index ccdaf2ddf1053171d27867e4d9a409895bb0b30b..75c3a51d05c08b2e5ecd8f743545553201f7adf4 100644 --- a/src/media/media_decoder.cpp +++ b/src/media/media_decoder.cpp @@ -466,21 +466,6 @@ MediaDecoder::getTimeBase() const int MediaDecoder::getPixelFormat() const { return decoderCtx_->pix_fmt; } -void -MediaDecoder::writeToRingBuffer(std::unique_ptr<AudioFrame>&& decodedFrame, - RingBuffer& rb, const AudioFormat outFormat) -{ - AudioFormat format (decoderCtx_->sample_rate, decoderCtx_->channels, decoderCtx_->sample_fmt); - if (format != outFormat) { - if (not resampler_) { - RING_DBG("Creating audio resampler"); - resampler_.reset(new Resampler); - } - decodedFrame = resampler_->resample(std::move(decodedFrame), outFormat); - } - rb.put(std::move(decodedFrame)); -} - int MediaDecoder::correctPixFmt(int input_pix_fmt) { diff --git a/src/media/media_decoder.h b/src/media/media_decoder.h index 5781777275e6d495bf39c4912c117da73d7ecf05..3350873057e3ba10c8213e08b7cfbe0f44dc91dd 100644 --- a/src/media/media_decoder.h +++ b/src/media/media_decoder.h @@ -90,7 +90,6 @@ class MediaDecoder { int setupFromAudioData(); Status decode(AudioFrame&); - void writeToRingBuffer(std::unique_ptr<AudioFrame>&& decodedFrame, RingBuffer&, const AudioFormat); int getWidth() const; int getHeight() const; @@ -115,7 +114,6 @@ class MediaDecoder { AVCodecContext *decoderCtx_ = nullptr; AVFormatContext *inputCtx_ = nullptr; AVStream *avStream_ = nullptr; - std::unique_ptr<Resampler> resampler_; int streamIndex_ = -1; bool emulateRate_ = false; int64_t startTime_; @@ -123,10 +121,6 @@ class MediaDecoder { DeviceParams inputParams_; - AudioBuffer decBuff_; - AudioBuffer resamplingBuff_; - - void extract(const std::map<std::string, std::string>& map, const std::string& key); int correctPixFmt(int input_pix_fmt); int setupStream(AVMediaType mediaType); int selectStream(AVMediaType type);