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

Function faad_decoder_init

src/decoder/plugins/FaadDecoderPlugin.cxx:235–257  ·  view source on GitHub ↗

* Wrapper for NeAACDecInit() which works around some API * inconsistencies in libfaad. * * Throws #std::runtime_error on error. */

Source from the content-addressed store, hash-verified

233 * Throws #std::runtime_error on error.
234 */
235static void
236faad_decoder_init(NeAACDecHandle decoder, DecoderBuffer &buffer,
237 AudioFormat &audio_format)
238{
239 auto data = FromBytesStrict<const uint8_t>(buffer.Read());
240 if (data.empty())
241 throw std::runtime_error("Empty file");
242
243 uint8_t channels;
244 unsigned long sample_rate;
245 long nbytes = NeAACDecInit(decoder,
246 /* deconst hack, libfaad requires this */
247 const_cast<unsigned char *>(data.data()),
248 data.size(),
249 &sample_rate, &channels);
250 if (nbytes < 0)
251 throw std::runtime_error("Not an AAC stream");
252
253 buffer.Consume(nbytes);
254
255 audio_format = CheckAudioFormat(sample_rate, SampleFormat::S16,
256 channels);
257}
258
259/**
260 * Wrapper for NeAACDecDecode() which works around some API

Callers 2

faad_get_file_timeFunction · 0.85
faad_stream_decodeFunction · 0.85

Calls 4

emptyMethod · 0.80
CheckAudioFormatFunction · 0.70
ReadMethod · 0.45
ConsumeMethod · 0.45

Tested by

no test coverage detected