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

◆ setup_resampler()

bool MayaFlux::IO::AudioStreamContext::setup_resampler ( bool  planar_output,
uint32_t  target_rate 
)
private

Definition at line 108 of file AudioStreamContext.cpp.

109{
110 if (!codec_context)
111 return false;
112
113 AVChannelLayout out_layout;
114 av_channel_layout_copy(&out_layout, &codec_context->ch_layout);
115
116 uint32_t out_rate = target_rate > 0 ? target_rate : sample_rate;
117 AVSampleFormat out_fmt = planar_output ? AV_SAMPLE_FMT_DBLP : AV_SAMPLE_FMT_DBL;
118
119 int ret = swr_alloc_set_opts2(
121 &out_layout, out_fmt, static_cast<int>(out_rate),
122 &codec_context->ch_layout, codec_context->sample_fmt, codec_context->sample_rate,
123 0, nullptr);
124
125 av_channel_layout_uninit(&out_layout);
126
127 if (ret < 0 || !swr_context) {
128 m_last_error = "swr_alloc_set_opts2 failed";
129 return false;
130 }
131
132 if (swr_init(swr_context) < 0) {
133 m_last_error = "swr_init failed";
134 swr_free(&swr_context);
135 swr_context = nullptr;
136 return false;
137 }
138
139 return true;
140}
SwrContext * swr_context
Owned; freed in destructor.
AVCodecContext * codec_context
Owned; freed in destructor.

References codec_context, m_last_error, sample_rate, and swr_context.

Referenced by open().

+ Here is the caller graph for this function: