MCPcopy Create free account
hub / github.com/MusicPlayerDaemon/MPD / GetAudioFormat

Function GetAudioFormat

src/decoder/plugins/Mpg123DecoderPlugin.cxx:157–180  ·  view source on GitHub ↗

* Convert libmpg123's format to an #AudioFormat instance. * * @param handle a handle which was created before; on error, this * function will not free it * @param audio_format this parameter is filled after successful * return * @return true on success */

Source from the content-addressed store, hash-verified

155 * @return true on success
156 */
157static bool
158GetAudioFormat(mpg123_handle &handle, AudioFormat &audio_format)
159{
160 long rate;
161 int channels, encoding;
162 if (const int error = mpg123_getformat(&handle, &rate, &channels, &encoding);
163 error != MPG123_OK) {
164 FmtWarning(mpg123_domain,
165 "mpg123_getformat() failed: {}",
166 mpg123_plain_strerror(error));
167 return false;
168 }
169
170 if (encoding != MPG123_ENC_SIGNED_16) {
171 /* other formats not yet implemented */
172 FmtWarning(mpg123_domain,
173 "expected MPG123_ENC_SIGNED_16, got {}",
174 encoding);
175 return false;
176 }
177
178 audio_format = CheckAudioFormat(rate, SampleFormat::S16, channels);
179 return true;
180}
181
182#ifdef ENABLE_ID3TAG
183

Callers 2

DecodeFunction · 0.85
ScanFunction · 0.85

Calls 1

CheckAudioFormatFunction · 0.70

Tested by

no test coverage detected