| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chromecast/media/cma/decoder/cast_audio_decoder.h" | 5 #include "chromecast/media/cma/decoder/cast_audio_decoder.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 } | 78 } |
| 79 | 79 |
| 80 // CastAudioDecoder implementation: | 80 // CastAudioDecoder implementation: |
| 81 bool Decode(const scoped_refptr<media::DecoderBufferBase>& data, | 81 bool Decode(const scoped_refptr<media::DecoderBufferBase>& data, |
| 82 const DecodeCallback& decode_callback) override { | 82 const DecodeCallback& decode_callback) override { |
| 83 DCHECK(!decode_callback.is_null()); | 83 DCHECK(!decode_callback.is_null()); |
| 84 DCHECK(task_runner_->BelongsToCurrentThread()); | 84 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 85 | 85 |
| 86 if (data->decrypt_context() != nullptr) { | 86 if (data->decrypt_context() != nullptr) { |
| 87 LOG(ERROR) << "Audio decoder doesn't support encrypted stream"; | 87 LOG(ERROR) << "Audio decoder doesn't support encrypted stream"; |
| 88 decode_callback.Run(kDecodeError, data); | 88 // Post the task to ensure that |decode_callback| is not called from |
| 89 // within a call to Decode(). |
| 90 task_runner_->PostTask(FROM_HERE, |
| 91 base::Bind(decode_callback, kDecodeError, data)); |
| 89 } else if (!initialized_ || decode_pending_) { | 92 } else if (!initialized_ || decode_pending_) { |
| 90 decode_queue_.push(std::make_pair(data, decode_callback)); | 93 decode_queue_.push(std::make_pair(data, decode_callback)); |
| 91 } else { | 94 } else { |
| 92 DecodeNow(data, decode_callback); | 95 DecodeNow(data, decode_callback); |
| 93 } | 96 } |
| 94 return true; | 97 return true; |
| 95 } | 98 } |
| 96 | 99 |
| 97 private: | 100 private: |
| 98 typedef std::pair<scoped_refptr<media::DecoderBufferBase>, DecodeCallback> | 101 typedef std::pair<scoped_refptr<media::DecoderBufferBase>, DecodeCallback> |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 return 2; | 274 return 2; |
| 272 case CastAudioDecoder::OutputFormat::kOutputPlanarFloat: | 275 case CastAudioDecoder::OutputFormat::kOutputPlanarFloat: |
| 273 return 4; | 276 return 4; |
| 274 } | 277 } |
| 275 NOTREACHED(); | 278 NOTREACHED(); |
| 276 return 1; | 279 return 1; |
| 277 } | 280 } |
| 278 | 281 |
| 279 } // namespace media | 282 } // namespace media |
| 280 } // namespace chromecast | 283 } // namespace chromecast |
| OLD | NEW |