| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/filters/opus_audio_decoder.h" | 5 #include "media/filters/opus_audio_decoder.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 void OpusAudioDecoder::DecodeBuffer( | 189 void OpusAudioDecoder::DecodeBuffer( |
| 190 const scoped_refptr<DecoderBuffer>& input, | 190 const scoped_refptr<DecoderBuffer>& input, |
| 191 const DecodeCB& decode_cb) { | 191 const DecodeCB& decode_cb) { |
| 192 DCHECK(task_runner_->BelongsToCurrentThread()); | 192 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 193 DCHECK(!decode_cb.is_null()); | 193 DCHECK(!decode_cb.is_null()); |
| 194 DCHECK(input.get()); | 194 DCHECK(input.get()); |
| 195 | 195 |
| 196 // Libopus does not buffer output. Decoding is complete when an end of stream | 196 // Libopus does not buffer output. Decoding is complete when an end of stream |
| 197 // input buffer is received. | 197 // input buffer is received. |
| 198 if (input->end_of_stream()) { | 198 if (input->end_of_stream()) { |
| 199 decode_cb.Run(kOk); | 199 decode_cb.Run(DecodeStatus::OK); |
| 200 return; | 200 return; |
| 201 } | 201 } |
| 202 | 202 |
| 203 // Make sure we are notified if http://crbug.com/49709 returns. Issue also | 203 // Make sure we are notified if http://crbug.com/49709 returns. Issue also |
| 204 // occurs with some damaged files. | 204 // occurs with some damaged files. |
| 205 if (input->timestamp() == kNoTimestamp()) { | 205 if (input->timestamp() == kNoTimestamp()) { |
| 206 DLOG(ERROR) << "Received a buffer without timestamps!"; | 206 DLOG(ERROR) << "Received a buffer without timestamps!"; |
| 207 decode_cb.Run(kDecodeError); | 207 decode_cb.Run(DecodeStatus::DECODE_ERROR); |
| 208 return; | 208 return; |
| 209 } | 209 } |
| 210 | 210 |
| 211 scoped_refptr<AudioBuffer> output_buffer; | 211 scoped_refptr<AudioBuffer> output_buffer; |
| 212 | 212 |
| 213 if (!Decode(input, &output_buffer)) { | 213 if (!Decode(input, &output_buffer)) { |
| 214 decode_cb.Run(kDecodeError); | 214 decode_cb.Run(DecodeStatus::DECODE_ERROR); |
| 215 return; | 215 return; |
| 216 } | 216 } |
| 217 | 217 |
| 218 if (output_buffer.get()) { | 218 if (output_buffer.get()) { |
| 219 output_cb_.Run(output_buffer); | 219 output_cb_.Run(output_buffer); |
| 220 } | 220 } |
| 221 | 221 |
| 222 decode_cb.Run(kOk); | 222 decode_cb.Run(DecodeStatus::OK); |
| 223 } | 223 } |
| 224 | 224 |
| 225 bool OpusAudioDecoder::ConfigureDecoder() { | 225 bool OpusAudioDecoder::ConfigureDecoder() { |
| 226 if (config_.codec() != kCodecOpus) { | 226 if (config_.codec() != kCodecOpus) { |
| 227 DVLOG(1) << "Codec must be kCodecOpus."; | 227 DVLOG(1) << "Codec must be kCodecOpus."; |
| 228 return false; | 228 return false; |
| 229 } | 229 } |
| 230 | 230 |
| 231 const int channel_count = | 231 const int channel_count = |
| 232 ChannelLayoutToChannelCount(config_.channel_layout()); | 232 ChannelLayoutToChannelCount(config_.channel_layout()); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 output_buffer->get()->TrimEnd(trim_frames); | 359 output_buffer->get()->TrimEnd(trim_frames); |
| 360 | 360 |
| 361 // Handles discards and timestamping. Discard the buffer if more data needed. | 361 // Handles discards and timestamping. Discard the buffer if more data needed. |
| 362 if (!discard_helper_->ProcessBuffers(input, *output_buffer)) | 362 if (!discard_helper_->ProcessBuffers(input, *output_buffer)) |
| 363 *output_buffer = nullptr; | 363 *output_buffer = nullptr; |
| 364 | 364 |
| 365 return true; | 365 return true; |
| 366 } | 366 } |
| 367 | 367 |
| 368 } // namespace media | 368 } // namespace media |
| OLD | NEW |