| 306 | } |
| 307 | |
| 308 | static void |
| 309 | faad_stream_decode(DecoderClient &client, InputStream &is, |
| 310 | DecoderBuffer &buffer, NeAACDecHandle decoder) |
| 311 | { |
| 312 | const auto total_time = faad_song_duration(buffer, is); |
| 313 | |
| 314 | if (adts_find_frame(buffer) == 0) |
| 315 | return; |
| 316 | |
| 317 | /* initialize it */ |
| 318 | |
| 319 | AudioFormat audio_format; |
| 320 | faad_decoder_init(decoder, buffer, audio_format); |
| 321 | |
| 322 | /* initialize the MPD core */ |
| 323 | |
| 324 | client.Ready(audio_format, false, total_time); |
| 325 | |
| 326 | /* the decoder loop */ |
| 327 | |
| 328 | DecoderCommand cmd; |
| 329 | unsigned bit_rate = 0; |
| 330 | do { |
| 331 | /* find the next frame */ |
| 332 | |
| 333 | const size_t frame_size = adts_find_frame(buffer); |
| 334 | if (frame_size == 0) |
| 335 | /* end of file */ |
| 336 | break; |
| 337 | |
| 338 | /* decode it */ |
| 339 | |
| 340 | NeAACDecFrameInfo frame_info; |
| 341 | const auto decoded = (const int16_t *) |
| 342 | faad_decoder_decode(decoder, buffer, &frame_info); |
| 343 | |
| 344 | if (frame_info.error > 0) { |
| 345 | FmtWarning(faad_decoder_domain, |
| 346 | "error decoding AAC stream: {}", |
| 347 | NeAACDecGetErrorMessage(frame_info.error)); |
| 348 | break; |
| 349 | } |
| 350 | |
| 351 | if (frame_info.channels != audio_format.channels) { |
| 352 | FmtNotice(faad_decoder_domain, |
| 353 | "channel count changed from {} to {}", |
| 354 | audio_format.channels, frame_info.channels); |
| 355 | break; |
| 356 | } |
| 357 | |
| 358 | if (frame_info.samplerate != audio_format.sample_rate) { |
| 359 | FmtNotice(faad_decoder_domain, |
| 360 | "sample rate changed from {} to {}", |
| 361 | audio_format.sample_rate, |
| 362 | frame_info.samplerate); |
| 363 | break; |
| 364 | } |
| 365 |
nothing calls this directly
no test coverage detected