MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ setup_resampler()

bool MayaFlux::IO::AudioEncodeContext::setup_resampler ( )
private

Definition at line 173 of file AudioEncodeContext.cpp.

174{
175 AVChannelLayout layout {};
176 av_channel_layout_default(&layout, static_cast<int>(m_channels));
177
178 int ret = swr_alloc_set_opts2(
180 &layout, codec_context->sample_fmt, codec_context->sample_rate,
181 &layout, AV_SAMPLE_FMT_DBL, static_cast<int>(m_sample_rate),
182 0, nullptr);
183
184 av_channel_layout_uninit(&layout);
185
186 if (ret < 0 || !swr_context) {
187 m_last_error = "swr_alloc_set_opts2 failed";
188 return false;
189 }
190
191 if (swr_init(swr_context) < 0) {
192 m_last_error = "swr_init failed";
193 swr_free(&swr_context);
194 swr_context = nullptr;
195 return false;
196 }
197
198 return true;
199}
AVCodecContext * codec_context
Owned; freed in destructor.
SwrContext * swr_context
Owned; freed in destructor.

References codec_context, m_channels, m_last_error, m_sample_rate, and swr_context.

Referenced by open().

+ Here is the caller graph for this function: