| 614 | } |
| 615 | |
| 616 | bool FfmpegDecoder::ReadFromFifoAndWriteToBuffer(IBuffer* buffer) { |
| 617 | int error = 0; |
| 618 | int fifoSize = av_audio_fifo_size(this->outputFifo); |
| 619 | |
| 620 | if (this->eof && fifoSize == 0) { |
| 621 | return false; |
| 622 | } |
| 623 | |
| 624 | if ( |
| 625 | fifoSize >= this->preferredFrameSize || |
| 626 | (this->eof && fifoSize > 0) |
| 627 | ) { |
| 628 | const int expectedFrameSize = FFMIN(fifoSize, this->preferredFrameSize); |
| 629 | buffer->SetSamples(expectedFrameSize * this->channels); |
| 630 | void* outData = (void*)buffer->BufferPointer(); |
| 631 | int actualFrameSize = av_audio_fifo_read(this->outputFifo, &outData, expectedFrameSize); |
| 632 | |
| 633 | if (actualFrameSize > expectedFrameSize) { |
| 634 | logError("av_audio_fifo_read read the incorrect number of samples"); |
| 635 | return false; |
| 636 | } |
| 637 | else if (actualFrameSize != expectedFrameSize) { |
| 638 | buffer->SetSamples(actualFrameSize * this->channels); |
| 639 | } |
| 640 | } |
| 641 | |
| 642 | return true; |
| 643 | } |
| 644 | |
| 645 | void FfmpegDecoder::FlushAndFinalizeDecoder() { |
| 646 | /* reading from a packet with a null `data` pointer is a "flush" operation, |
no test coverage detected