| Index: media/filters/audio_file_reader.cc
|
| diff --git a/media/filters/audio_file_reader.cc b/media/filters/audio_file_reader.cc
|
| index 58dee72e5d91a8c34af83d6b024f42fe2348749e..80f8ce60a624e66d0016224d1e0b6cd88476f8d5 100644
|
| --- a/media/filters/audio_file_reader.cc
|
| +++ b/media/filters/audio_file_reader.cc
|
| @@ -126,14 +126,7 @@ int AudioFileReader::Read(AudioBus* audio_bus) {
|
| bool continue_decoding = true;
|
|
|
| while (current_frame < audio_bus->frames() && continue_decoding &&
|
| - av_read_frame(glue_->format_context(), &packet) >= 0 &&
|
| - av_dup_packet(&packet) >= 0) {
|
| - // Skip packets from other streams.
|
| - if (packet.stream_index != stream_index_) {
|
| - av_free_packet(&packet);
|
| - continue;
|
| - }
|
| -
|
| + ReadPacket(&packet)) {
|
| // Make a shallow copy of packet so we can slide packet.data as frames are
|
| // decoded from the packet; otherwise av_free_packet() will corrupt memory.
|
| AVPacket packet_temp = packet;
|
| @@ -245,4 +238,21 @@ int AudioFileReader::GetNumberOfFrames() const {
|
| return static_cast<int>(ceil(GetDuration().InSecondsF() * sample_rate()));
|
| }
|
|
|
| +bool AudioFileReader::ReadPacketForTesting(AVPacket* output_packet) {
|
| + return ReadPacket(output_packet);
|
| +}
|
| +
|
| +bool AudioFileReader::ReadPacket(AVPacket* output_packet) {
|
| + while (av_read_frame(glue_->format_context(), output_packet) >= 0 &&
|
| + av_dup_packet(output_packet) >= 0) {
|
| + // Skip packets from other streams.
|
| + if (output_packet->stream_index != stream_index_) {
|
| + av_free_packet(output_packet);
|
| + continue;
|
| + }
|
| + return true;
|
| + }
|
| + return false;
|
| +}
|
| +
|
| } // namespace media
|
|
|