MCPcopy Create free account
hub / github.com/clangen/musikcube / RefillFifoQueue

Method RefillFifoQueue

src/plugins/ffmpegdecoder/FfmpegDecoder.cpp:574–614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

572}
573
574bool FfmpegDecoder::RefillFifoQueue() {
575 bool sentAtLeastOnePacket = false;
576 bool readFailed = false;
577 int fifoSize = av_audio_fifo_size(this->outputFifo);
578 while (!readFailed && fifoSize < this->preferredFrameSize) {
579 AVPacket packet;
580 memset(&packet, 0, sizeof(AVPacket));
581 packet.pts = AV_NOPTS_VALUE;
582 packet.dts = AV_NOPTS_VALUE;
583 packet.pos = -1;
584 int error = av_read_frame(this->formatContext, &packet);
585
586 if (error >= 0) {
587 /* note that sometimes decoders seem to return packets that are
588 invalid. this can be observed when playing wav files that have
589 album art metadata, but may happen in other cases. if we detect
590 an invalid packet, simply discard it and get the next one. to make
591 things worse, some decoders (e.g. APE) always return packets in this
592 state. we're missing something, somewhere during codec init probably,
593 but after hours of messing around I can't figure it out. if you
594 are reading this comment and have any ideas, please let me know. */
595 if (packet.pos == -1 &&
596 packet.duration <= 1 &&
597 !this->disableInvalidPacketDetection)
598 {
599 logError("invalid packet detected, discarding.");
600 }
601 else {
602 sentAtLeastOnePacket = this->ReadSendAndReceivePacket(&packet);
603 }
604 }
605 else {
606 logAvError("av_read_frame", error);
607 readFailed = true;
608 }
609
610 av_packet_unref(&packet);
611 fifoSize = av_audio_fifo_size(this->outputFifo);
612 }
613 return sentAtLeastOnePacket;
614}
615
616bool FfmpegDecoder::ReadFromFifoAndWriteToBuffer(IBuffer* buffer) {
617 int error = 0;

Callers 1

GetBufferMethod · 0.95

Calls 3

logErrorFunction · 0.70
logAvErrorFunction · 0.70

Tested by

no test coverage detected