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

decoder: don't set channels and sample rate in dictionary


This is redundant, the information can already be found in the AVStream
object and is set by avcodec_parameters_to_context. Let FFmpeg take care
of these details.

Change-Id: I199de87a852caeef34047e4f906ccd21dcb696c4
Reviewed-by: default avatarSebastien Blin <sebastien.blin@savoirfairelinux.com>
parent a843a5b6
Branches
No related tags found
No related merge requests found
...@@ -304,7 +304,7 @@ AudioReceiveThread::setup() ...@@ -304,7 +304,7 @@ AudioReceiveThread::setup()
// Now replace our custom AVIOContext with one that will read packets // Now replace our custom AVIOContext with one that will read packets
audioDecoder_->setIOContext(demuxContext_.get()); audioDecoder_->setIOContext(demuxContext_.get());
EXIT_IF_FAIL(not audioDecoder_->setupFromAudioData(format_), EXIT_IF_FAIL(not audioDecoder_->setupFromAudioData(),
"decoder IO startup failed"); "decoder IO startup failed");
ringbuffer_ = Manager::instance().getRingBufferPool().getRingBuffer(id_); ringbuffer_ = Manager::instance().getRingBufferPool().getRingBuffer(id_);
...@@ -347,7 +347,7 @@ AudioReceiveThread::process() ...@@ -347,7 +347,7 @@ AudioReceiveThread::process()
loop_.stop(); loop_.stop();
break; break;
} }
if (not audioDecoder_->setupFromAudioData(format_)) { if (not audioDecoder_->setupFromAudioData()) {
RING_ERR("fatal error, a-decoder setup failed"); RING_ERR("fatal error, a-decoder setup failed");
loop_.stop(); loop_.stop();
break; break;
......
...@@ -144,11 +144,8 @@ void MediaDecoder::setInterruptCallback(int (*cb)(void*), void *opaque) ...@@ -144,11 +144,8 @@ void MediaDecoder::setInterruptCallback(int (*cb)(void*), void *opaque)
void MediaDecoder::setIOContext(MediaIOHandle *ioctx) void MediaDecoder::setIOContext(MediaIOHandle *ioctx)
{ inputCtx_->pb = ioctx->getContext(); } { inputCtx_->pb = ioctx->getContext(); }
int MediaDecoder::setupFromAudioData(const AudioFormat format) int MediaDecoder::setupFromAudioData()
{ {
// Use AVDictionary to send extra arguments to setupStream, since video setup doesn't need them
av_dict_set_int(&options_, "nb_channels", format.nb_channels, 0);
av_dict_set_int(&options_, "sample_rate", format.sample_rate, 0);
return setupStream(AVMEDIA_TYPE_AUDIO); return setupStream(AVMEDIA_TYPE_AUDIO);
} }
...@@ -197,10 +194,6 @@ MediaDecoder::setupStream(AVMediaType mediaType) ...@@ -197,10 +194,6 @@ MediaDecoder::setupStream(AVMediaType mediaType)
decoderCtx_->framerate = avStream_->avg_frame_rate; decoderCtx_->framerate = avStream_->avg_frame_rate;
decoderCtx_->thread_count = std::max(1u, std::min(8u, std::thread::hardware_concurrency()/2)); decoderCtx_->thread_count = std::max(1u, std::min(8u, std::thread::hardware_concurrency()/2));
if (mediaType == AVMEDIA_TYPE_AUDIO) {
decoderCtx_->channels = std::stoi(av_dict_get(options_, "nb_channels", nullptr, 0)->value);
decoderCtx_->sample_rate = std::stoi(av_dict_get(options_, "sample_rate", nullptr, 0)->value);
}
if (emulateRate_) if (emulateRate_)
RING_DBG() << "Using framerate emulation"; RING_DBG() << "Using framerate emulation";
......
...@@ -84,7 +84,7 @@ class MediaDecoder { ...@@ -84,7 +84,7 @@ class MediaDecoder {
Status flush(VideoFrame&); Status flush(VideoFrame&);
#endif // RING_VIDEO #endif // RING_VIDEO
int setupFromAudioData(const AudioFormat format); int setupFromAudioData();
Status decode(const AudioFrame&); Status decode(const AudioFrame&);
void writeToRingBuffer(const AudioFrame&, RingBuffer&, const AudioFormat); void writeToRingBuffer(const AudioFrame&, RingBuffer&, const AudioFormat);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment