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

Method DecodeNextFrame

src/decoder/plugins/MadDecoderPlugin.cxx:348–390  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

346}
347
348MadDecoderAction
349MadDecoder::DecodeNextFrame(bool skip, Tag *tag) noexcept
350{
351 if ((stream.buffer == nullptr || stream.error == MAD_ERROR_BUFLEN) &&
352 !FillBuffer())
353 return MadDecoderAction::BREAK;
354
355 if (mad_header_decode(&frame.header, &stream)) {
356 if (stream.error == MAD_ERROR_BUFLEN)
357 return MadDecoderAction::CONT;
358
359 if (stream.error == MAD_ERROR_LOSTSYNC && stream.this_frame) {
360 signed long tagsize = id3_tag_query(stream.this_frame,
361 stream.bufend -
362 stream.this_frame);
363
364 if (tagsize > 0) {
365 ParseId3((size_t)tagsize, tag);
366 return MadDecoderAction::CONT;
367 }
368 }
369
370 return RecoverFrameError(stream);
371 }
372
373 enum mad_layer new_layer = frame.header.layer;
374 if (layer == (mad_layer)0) {
375 if (new_layer != MAD_LAYER_II && new_layer != MAD_LAYER_III) {
376 /* Only layer 2 and 3 have been tested to work */
377 return MadDecoderAction::SKIP;
378 }
379
380 layer = new_layer;
381 } else if (new_layer != layer) {
382 /* Don't decode frames with a different layer than the first */
383 return MadDecoderAction::SKIP;
384 }
385
386 if (!skip && mad_frame_decode(&frame, &stream))
387 return RecoverFrameError(stream);
388
389 return MadDecoderAction::OK;
390}
391
392/* xing stuff stolen from alsaplayer, and heavily modified by jat */
393static constexpr unsigned XI_MAGIC = (('X' << 8) | 'i');

Callers

nothing calls this directly

Calls 4

FillBufferFunction · 0.85
id3_tag_queryFunction · 0.85
ParseId3Function · 0.85
RecoverFrameErrorFunction · 0.85

Tested by

no test coverage detected