OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/decrypting_audio_decoder.h" | 5 #include "media/filters/decrypting_audio_decoder.h" |
6 | 6 |
7 #include <cstdlib> | 7 #include <cstdlib> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/message_loop/message_loop_proxy.h" | 13 #include "base/single_thread_task_runner.h" |
14 #include "media/base/audio_buffer.h" | 14 #include "media/base/audio_buffer.h" |
15 #include "media/base/audio_decoder_config.h" | 15 #include "media/base/audio_decoder_config.h" |
16 #include "media/base/audio_timestamp_helper.h" | 16 #include "media/base/audio_timestamp_helper.h" |
17 #include "media/base/bind_to_loop.h" | 17 #include "media/base/bind_to_loop.h" |
18 #include "media/base/buffers.h" | 18 #include "media/base/buffers.h" |
19 #include "media/base/decoder_buffer.h" | 19 #include "media/base/decoder_buffer.h" |
20 #include "media/base/decryptor.h" | 20 #include "media/base/decryptor.h" |
21 #include "media/base/demuxer_stream.h" | 21 #include "media/base/demuxer_stream.h" |
22 #include "media/base/pipeline.h" | 22 #include "media/base/pipeline.h" |
23 | 23 |
24 namespace media { | 24 namespace media { |
25 | 25 |
26 const int DecryptingAudioDecoder::kSupportedBitsPerChannel = 16; | 26 const int DecryptingAudioDecoder::kSupportedBitsPerChannel = 16; |
27 | 27 |
28 static inline bool IsOutOfSync(const base::TimeDelta& timestamp_1, | 28 static inline bool IsOutOfSync(const base::TimeDelta& timestamp_1, |
29 const base::TimeDelta& timestamp_2) { | 29 const base::TimeDelta& timestamp_2) { |
30 // Out of sync of 100ms would be pretty noticeable and we should keep any | 30 // Out of sync of 100ms would be pretty noticeable and we should keep any |
31 // drift below that. | 31 // drift below that. |
32 const int64 kOutOfSyncThresholdInMilliseconds = 100; | 32 const int64 kOutOfSyncThresholdInMilliseconds = 100; |
33 return std::abs(timestamp_1.InMilliseconds() - timestamp_2.InMilliseconds()) > | 33 return std::abs(timestamp_1.InMilliseconds() - timestamp_2.InMilliseconds()) > |
34 kOutOfSyncThresholdInMilliseconds; | 34 kOutOfSyncThresholdInMilliseconds; |
35 } | 35 } |
36 | 36 |
37 DecryptingAudioDecoder::DecryptingAudioDecoder( | 37 DecryptingAudioDecoder::DecryptingAudioDecoder( |
38 const scoped_refptr<base::MessageLoopProxy>& message_loop, | 38 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
39 const SetDecryptorReadyCB& set_decryptor_ready_cb) | 39 const SetDecryptorReadyCB& set_decryptor_ready_cb) |
40 : message_loop_(message_loop), | 40 : task_runner_(task_runner), |
41 weak_factory_(this), | 41 weak_factory_(this), |
42 state_(kUninitialized), | 42 state_(kUninitialized), |
43 demuxer_stream_(NULL), | 43 demuxer_stream_(NULL), |
44 set_decryptor_ready_cb_(set_decryptor_ready_cb), | 44 set_decryptor_ready_cb_(set_decryptor_ready_cb), |
45 decryptor_(NULL), | 45 decryptor_(NULL), |
46 key_added_while_decode_pending_(false), | 46 key_added_while_decode_pending_(false), |
47 bits_per_channel_(0), | 47 bits_per_channel_(0), |
48 channel_layout_(CHANNEL_LAYOUT_NONE), | 48 channel_layout_(CHANNEL_LAYOUT_NONE), |
49 samples_per_second_(0) { | 49 samples_per_second_(0) { |
50 } | 50 } |
51 | 51 |
52 void DecryptingAudioDecoder::Initialize( | 52 void DecryptingAudioDecoder::Initialize( |
53 DemuxerStream* stream, | 53 DemuxerStream* stream, |
54 const PipelineStatusCB& status_cb, | 54 const PipelineStatusCB& status_cb, |
55 const StatisticsCB& statistics_cb) { | 55 const StatisticsCB& statistics_cb) { |
56 DVLOG(2) << "Initialize()"; | 56 DVLOG(2) << "Initialize()"; |
57 DCHECK(message_loop_->BelongsToCurrentThread()); | 57 DCHECK(task_runner_->BelongsToCurrentThread()); |
58 DCHECK_EQ(state_, kUninitialized) << state_; | 58 DCHECK_EQ(state_, kUninitialized) << state_; |
59 DCHECK(stream); | 59 DCHECK(stream); |
60 | 60 |
61 weak_this_ = weak_factory_.GetWeakPtr(); | 61 weak_this_ = weak_factory_.GetWeakPtr(); |
62 init_cb_ = BindToCurrentLoop(status_cb); | 62 init_cb_ = BindToCurrentLoop(status_cb); |
63 | 63 |
64 const AudioDecoderConfig& config = stream->audio_decoder_config(); | 64 const AudioDecoderConfig& config = stream->audio_decoder_config(); |
65 if (!config.IsValidConfig()) { | 65 if (!config.IsValidConfig()) { |
66 DLOG(ERROR) << "Invalid audio stream config."; | 66 DLOG(ERROR) << "Invalid audio stream config."; |
67 base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_DECODE); | 67 base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_DECODE); |
(...skipping 10 matching lines...) Expand all Loading... |
78 demuxer_stream_ = stream; | 78 demuxer_stream_ = stream; |
79 statistics_cb_ = statistics_cb; | 79 statistics_cb_ = statistics_cb; |
80 | 80 |
81 state_ = kDecryptorRequested; | 81 state_ = kDecryptorRequested; |
82 set_decryptor_ready_cb_.Run(BindToCurrentLoop( | 82 set_decryptor_ready_cb_.Run(BindToCurrentLoop( |
83 base::Bind(&DecryptingAudioDecoder::SetDecryptor, weak_this_))); | 83 base::Bind(&DecryptingAudioDecoder::SetDecryptor, weak_this_))); |
84 } | 84 } |
85 | 85 |
86 void DecryptingAudioDecoder::Read(const ReadCB& read_cb) { | 86 void DecryptingAudioDecoder::Read(const ReadCB& read_cb) { |
87 DVLOG(3) << "Read()"; | 87 DVLOG(3) << "Read()"; |
88 DCHECK(message_loop_->BelongsToCurrentThread()); | 88 DCHECK(task_runner_->BelongsToCurrentThread()); |
89 DCHECK(state_ == kIdle || state_ == kDecodeFinished) << state_; | 89 DCHECK(state_ == kIdle || state_ == kDecodeFinished) << state_; |
90 DCHECK(!read_cb.is_null()); | 90 DCHECK(!read_cb.is_null()); |
91 CHECK(read_cb_.is_null()) << "Overlapping decodes are not supported."; | 91 CHECK(read_cb_.is_null()) << "Overlapping decodes are not supported."; |
92 | 92 |
93 read_cb_ = BindToCurrentLoop(read_cb); | 93 read_cb_ = BindToCurrentLoop(read_cb); |
94 | 94 |
95 // Return empty (end-of-stream) frames if decoding has finished. | 95 // Return empty (end-of-stream) frames if decoding has finished. |
96 if (state_ == kDecodeFinished) { | 96 if (state_ == kDecodeFinished) { |
97 base::ResetAndReturn(&read_cb_).Run(kOk, AudioBuffer::CreateEOSBuffer()); | 97 base::ResetAndReturn(&read_cb_).Run(kOk, AudioBuffer::CreateEOSBuffer()); |
98 return; | 98 return; |
99 } | 99 } |
100 | 100 |
101 if (!queued_audio_frames_.empty()) { | 101 if (!queued_audio_frames_.empty()) { |
102 base::ResetAndReturn(&read_cb_).Run(kOk, queued_audio_frames_.front()); | 102 base::ResetAndReturn(&read_cb_).Run(kOk, queued_audio_frames_.front()); |
103 queued_audio_frames_.pop_front(); | 103 queued_audio_frames_.pop_front(); |
104 return; | 104 return; |
105 } | 105 } |
106 | 106 |
107 state_ = kPendingDemuxerRead; | 107 state_ = kPendingDemuxerRead; |
108 ReadFromDemuxerStream(); | 108 ReadFromDemuxerStream(); |
109 } | 109 } |
110 | 110 |
111 void DecryptingAudioDecoder::Reset(const base::Closure& closure) { | 111 void DecryptingAudioDecoder::Reset(const base::Closure& closure) { |
112 DVLOG(2) << "Reset() - state: " << state_; | 112 DVLOG(2) << "Reset() - state: " << state_; |
113 DCHECK(message_loop_->BelongsToCurrentThread()); | 113 DCHECK(task_runner_->BelongsToCurrentThread()); |
114 DCHECK(state_ == kIdle || | 114 DCHECK(state_ == kIdle || |
115 state_ == kPendingConfigChange || | 115 state_ == kPendingConfigChange || |
116 state_ == kPendingDemuxerRead || | 116 state_ == kPendingDemuxerRead || |
117 state_ == kPendingDecode || | 117 state_ == kPendingDecode || |
118 state_ == kWaitingForKey || | 118 state_ == kWaitingForKey || |
119 state_ == kDecodeFinished) << state_; | 119 state_ == kDecodeFinished) << state_; |
120 DCHECK(init_cb_.is_null()); // No Reset() during pending initialization. | 120 DCHECK(init_cb_.is_null()); // No Reset() during pending initialization. |
121 DCHECK(reset_cb_.is_null()); | 121 DCHECK(reset_cb_.is_null()); |
122 | 122 |
123 reset_cb_ = closure; | 123 reset_cb_ = closure; |
(...skipping 15 matching lines...) Expand all Loading... |
139 DCHECK(!read_cb_.is_null()); | 139 DCHECK(!read_cb_.is_null()); |
140 pending_buffer_to_decode_ = NULL; | 140 pending_buffer_to_decode_ = NULL; |
141 base::ResetAndReturn(&read_cb_).Run(kAborted, NULL); | 141 base::ResetAndReturn(&read_cb_).Run(kAborted, NULL); |
142 } | 142 } |
143 | 143 |
144 DCHECK(read_cb_.is_null()); | 144 DCHECK(read_cb_.is_null()); |
145 DoReset(); | 145 DoReset(); |
146 } | 146 } |
147 | 147 |
148 int DecryptingAudioDecoder::bits_per_channel() { | 148 int DecryptingAudioDecoder::bits_per_channel() { |
149 DCHECK(message_loop_->BelongsToCurrentThread()); | 149 DCHECK(task_runner_->BelongsToCurrentThread()); |
150 return bits_per_channel_; | 150 return bits_per_channel_; |
151 } | 151 } |
152 | 152 |
153 ChannelLayout DecryptingAudioDecoder::channel_layout() { | 153 ChannelLayout DecryptingAudioDecoder::channel_layout() { |
154 DCHECK(message_loop_->BelongsToCurrentThread()); | 154 DCHECK(task_runner_->BelongsToCurrentThread()); |
155 return channel_layout_; | 155 return channel_layout_; |
156 } | 156 } |
157 | 157 |
158 int DecryptingAudioDecoder::samples_per_second() { | 158 int DecryptingAudioDecoder::samples_per_second() { |
159 DCHECK(message_loop_->BelongsToCurrentThread()); | 159 DCHECK(task_runner_->BelongsToCurrentThread()); |
160 return samples_per_second_; | 160 return samples_per_second_; |
161 } | 161 } |
162 | 162 |
163 DecryptingAudioDecoder::~DecryptingAudioDecoder() { | 163 DecryptingAudioDecoder::~DecryptingAudioDecoder() { |
164 } | 164 } |
165 | 165 |
166 void DecryptingAudioDecoder::SetDecryptor(Decryptor* decryptor) { | 166 void DecryptingAudioDecoder::SetDecryptor(Decryptor* decryptor) { |
167 DVLOG(2) << "SetDecryptor()"; | 167 DVLOG(2) << "SetDecryptor()"; |
168 DCHECK(message_loop_->BelongsToCurrentThread()); | 168 DCHECK(task_runner_->BelongsToCurrentThread()); |
169 DCHECK_EQ(state_, kDecryptorRequested) << state_; | 169 DCHECK_EQ(state_, kDecryptorRequested) << state_; |
170 DCHECK(!init_cb_.is_null()); | 170 DCHECK(!init_cb_.is_null()); |
171 DCHECK(!set_decryptor_ready_cb_.is_null()); | 171 DCHECK(!set_decryptor_ready_cb_.is_null()); |
172 | 172 |
173 set_decryptor_ready_cb_.Reset(); | 173 set_decryptor_ready_cb_.Reset(); |
174 | 174 |
175 if (!decryptor) { | 175 if (!decryptor) { |
176 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); | 176 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); |
177 // TODO(xhwang): Add kError state. See http://crbug.com/251503 | 177 // TODO(xhwang): Add kError state. See http://crbug.com/251503 |
178 state_ = kDecodeFinished; | 178 state_ = kDecodeFinished; |
(...skipping 18 matching lines...) Expand all Loading... |
197 | 197 |
198 state_ = kPendingDecoderInit; | 198 state_ = kPendingDecoderInit; |
199 decryptor_->InitializeAudioDecoder( | 199 decryptor_->InitializeAudioDecoder( |
200 config, | 200 config, |
201 BindToCurrentLoop(base::Bind( | 201 BindToCurrentLoop(base::Bind( |
202 &DecryptingAudioDecoder::FinishInitialization, weak_this_))); | 202 &DecryptingAudioDecoder::FinishInitialization, weak_this_))); |
203 } | 203 } |
204 | 204 |
205 void DecryptingAudioDecoder::FinishInitialization(bool success) { | 205 void DecryptingAudioDecoder::FinishInitialization(bool success) { |
206 DVLOG(2) << "FinishInitialization()"; | 206 DVLOG(2) << "FinishInitialization()"; |
207 DCHECK(message_loop_->BelongsToCurrentThread()); | 207 DCHECK(task_runner_->BelongsToCurrentThread()); |
208 DCHECK_EQ(state_, kPendingDecoderInit) << state_; | 208 DCHECK_EQ(state_, kPendingDecoderInit) << state_; |
209 DCHECK(!init_cb_.is_null()); | 209 DCHECK(!init_cb_.is_null()); |
210 DCHECK(reset_cb_.is_null()); // No Reset() before initialization finished. | 210 DCHECK(reset_cb_.is_null()); // No Reset() before initialization finished. |
211 DCHECK(read_cb_.is_null()); // No Read() before initialization finished. | 211 DCHECK(read_cb_.is_null()); // No Read() before initialization finished. |
212 | 212 |
213 if (!success) { | 213 if (!success) { |
214 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); | 214 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); |
215 state_ = kDecodeFinished; | 215 state_ = kDecodeFinished; |
216 return; | 216 return; |
217 } | 217 } |
218 | 218 |
219 // Success! | 219 // Success! |
220 UpdateDecoderConfig(); | 220 UpdateDecoderConfig(); |
221 | 221 |
222 decryptor_->RegisterNewKeyCB( | 222 decryptor_->RegisterNewKeyCB( |
223 Decryptor::kAudio, BindToCurrentLoop(base::Bind( | 223 Decryptor::kAudio, BindToCurrentLoop(base::Bind( |
224 &DecryptingAudioDecoder::OnKeyAdded, weak_this_))); | 224 &DecryptingAudioDecoder::OnKeyAdded, weak_this_))); |
225 | 225 |
226 state_ = kIdle; | 226 state_ = kIdle; |
227 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); | 227 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); |
228 } | 228 } |
229 | 229 |
230 void DecryptingAudioDecoder::FinishConfigChange(bool success) { | 230 void DecryptingAudioDecoder::FinishConfigChange(bool success) { |
231 DVLOG(2) << "FinishConfigChange()"; | 231 DVLOG(2) << "FinishConfigChange()"; |
232 DCHECK(message_loop_->BelongsToCurrentThread()); | 232 DCHECK(task_runner_->BelongsToCurrentThread()); |
233 DCHECK_EQ(state_, kPendingConfigChange) << state_; | 233 DCHECK_EQ(state_, kPendingConfigChange) << state_; |
234 DCHECK(!read_cb_.is_null()); | 234 DCHECK(!read_cb_.is_null()); |
235 | 235 |
236 if (!success) { | 236 if (!success) { |
237 base::ResetAndReturn(&read_cb_).Run(kDecodeError, NULL); | 237 base::ResetAndReturn(&read_cb_).Run(kDecodeError, NULL); |
238 state_ = kDecodeFinished; | 238 state_ = kDecodeFinished; |
239 if (!reset_cb_.is_null()) | 239 if (!reset_cb_.is_null()) |
240 base::ResetAndReturn(&reset_cb_).Run(); | 240 base::ResetAndReturn(&reset_cb_).Run(); |
241 return; | 241 return; |
242 } | 242 } |
(...skipping 16 matching lines...) Expand all Loading... |
259 DCHECK(!read_cb_.is_null()); | 259 DCHECK(!read_cb_.is_null()); |
260 | 260 |
261 demuxer_stream_->Read( | 261 demuxer_stream_->Read( |
262 base::Bind(&DecryptingAudioDecoder::DecryptAndDecodeBuffer, weak_this_)); | 262 base::Bind(&DecryptingAudioDecoder::DecryptAndDecodeBuffer, weak_this_)); |
263 } | 263 } |
264 | 264 |
265 void DecryptingAudioDecoder::DecryptAndDecodeBuffer( | 265 void DecryptingAudioDecoder::DecryptAndDecodeBuffer( |
266 DemuxerStream::Status status, | 266 DemuxerStream::Status status, |
267 const scoped_refptr<DecoderBuffer>& buffer) { | 267 const scoped_refptr<DecoderBuffer>& buffer) { |
268 DVLOG(3) << "DecryptAndDecodeBuffer()"; | 268 DVLOG(3) << "DecryptAndDecodeBuffer()"; |
269 DCHECK(message_loop_->BelongsToCurrentThread()); | 269 DCHECK(task_runner_->BelongsToCurrentThread()); |
270 DCHECK_EQ(state_, kPendingDemuxerRead) << state_; | 270 DCHECK_EQ(state_, kPendingDemuxerRead) << state_; |
271 DCHECK(!read_cb_.is_null()); | 271 DCHECK(!read_cb_.is_null()); |
272 DCHECK_EQ(buffer.get() != NULL, status == DemuxerStream::kOk) << status; | 272 DCHECK_EQ(buffer.get() != NULL, status == DemuxerStream::kOk) << status; |
273 | 273 |
274 if (status == DemuxerStream::kConfigChanged) { | 274 if (status == DemuxerStream::kConfigChanged) { |
275 DVLOG(2) << "DecryptAndDecodeBuffer() - kConfigChanged"; | 275 DVLOG(2) << "DecryptAndDecodeBuffer() - kConfigChanged"; |
276 | 276 |
277 const AudioDecoderConfig& input_config = | 277 const AudioDecoderConfig& input_config = |
278 demuxer_stream_->audio_decoder_config(); | 278 demuxer_stream_->audio_decoder_config(); |
279 AudioDecoderConfig config; | 279 AudioDecoderConfig config; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 !buffer->end_of_stream()) { | 317 !buffer->end_of_stream()) { |
318 timestamp_helper_->SetBaseTimestamp(buffer->timestamp()); | 318 timestamp_helper_->SetBaseTimestamp(buffer->timestamp()); |
319 } | 319 } |
320 | 320 |
321 pending_buffer_to_decode_ = buffer; | 321 pending_buffer_to_decode_ = buffer; |
322 state_ = kPendingDecode; | 322 state_ = kPendingDecode; |
323 DecodePendingBuffer(); | 323 DecodePendingBuffer(); |
324 } | 324 } |
325 | 325 |
326 void DecryptingAudioDecoder::DecodePendingBuffer() { | 326 void DecryptingAudioDecoder::DecodePendingBuffer() { |
327 DCHECK(message_loop_->BelongsToCurrentThread()); | 327 DCHECK(task_runner_->BelongsToCurrentThread()); |
328 DCHECK_EQ(state_, kPendingDecode) << state_; | 328 DCHECK_EQ(state_, kPendingDecode) << state_; |
329 | 329 |
330 int buffer_size = 0; | 330 int buffer_size = 0; |
331 if (!pending_buffer_to_decode_->end_of_stream()) { | 331 if (!pending_buffer_to_decode_->end_of_stream()) { |
332 buffer_size = pending_buffer_to_decode_->data_size(); | 332 buffer_size = pending_buffer_to_decode_->data_size(); |
333 } | 333 } |
334 | 334 |
335 decryptor_->DecryptAndDecodeAudio( | 335 decryptor_->DecryptAndDecodeAudio( |
336 pending_buffer_to_decode_, | 336 pending_buffer_to_decode_, |
337 BindToCurrentLoop(base::Bind( | 337 BindToCurrentLoop(base::Bind( |
338 &DecryptingAudioDecoder::DeliverFrame, weak_this_, buffer_size))); | 338 &DecryptingAudioDecoder::DeliverFrame, weak_this_, buffer_size))); |
339 } | 339 } |
340 | 340 |
341 void DecryptingAudioDecoder::DeliverFrame( | 341 void DecryptingAudioDecoder::DeliverFrame( |
342 int buffer_size, | 342 int buffer_size, |
343 Decryptor::Status status, | 343 Decryptor::Status status, |
344 const Decryptor::AudioBuffers& frames) { | 344 const Decryptor::AudioBuffers& frames) { |
345 DVLOG(3) << "DeliverFrame() - status: " << status; | 345 DVLOG(3) << "DeliverFrame() - status: " << status; |
346 DCHECK(message_loop_->BelongsToCurrentThread()); | 346 DCHECK(task_runner_->BelongsToCurrentThread()); |
347 DCHECK_EQ(state_, kPendingDecode) << state_; | 347 DCHECK_EQ(state_, kPendingDecode) << state_; |
348 DCHECK(!read_cb_.is_null()); | 348 DCHECK(!read_cb_.is_null()); |
349 DCHECK(pending_buffer_to_decode_.get()); | 349 DCHECK(pending_buffer_to_decode_.get()); |
350 DCHECK(queued_audio_frames_.empty()); | 350 DCHECK(queued_audio_frames_.empty()); |
351 | 351 |
352 bool need_to_try_again_if_nokey_is_returned = key_added_while_decode_pending_; | 352 bool need_to_try_again_if_nokey_is_returned = key_added_while_decode_pending_; |
353 key_added_while_decode_pending_ = false; | 353 key_added_while_decode_pending_ = false; |
354 | 354 |
355 scoped_refptr<DecoderBuffer> scoped_pending_buffer_to_decode = | 355 scoped_refptr<DecoderBuffer> scoped_pending_buffer_to_decode = |
356 pending_buffer_to_decode_; | 356 pending_buffer_to_decode_; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 DCHECK_EQ(status, Decryptor::kSuccess); | 410 DCHECK_EQ(status, Decryptor::kSuccess); |
411 DCHECK(!frames.empty()); | 411 DCHECK(!frames.empty()); |
412 EnqueueFrames(frames); | 412 EnqueueFrames(frames); |
413 | 413 |
414 state_ = kIdle; | 414 state_ = kIdle; |
415 base::ResetAndReturn(&read_cb_).Run(kOk, queued_audio_frames_.front()); | 415 base::ResetAndReturn(&read_cb_).Run(kOk, queued_audio_frames_.front()); |
416 queued_audio_frames_.pop_front(); | 416 queued_audio_frames_.pop_front(); |
417 } | 417 } |
418 | 418 |
419 void DecryptingAudioDecoder::OnKeyAdded() { | 419 void DecryptingAudioDecoder::OnKeyAdded() { |
420 DCHECK(message_loop_->BelongsToCurrentThread()); | 420 DCHECK(task_runner_->BelongsToCurrentThread()); |
421 | 421 |
422 if (state_ == kPendingDecode) { | 422 if (state_ == kPendingDecode) { |
423 key_added_while_decode_pending_ = true; | 423 key_added_while_decode_pending_ = true; |
424 return; | 424 return; |
425 } | 425 } |
426 | 426 |
427 if (state_ == kWaitingForKey) { | 427 if (state_ == kWaitingForKey) { |
428 state_ = kPendingDecode; | 428 state_ = kPendingDecode; |
429 DecodePendingBuffer(); | 429 DecodePendingBuffer(); |
430 } | 430 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 } | 467 } |
468 | 468 |
469 frame->set_timestamp(current_time); | 469 frame->set_timestamp(current_time); |
470 frame->set_duration( | 470 frame->set_duration( |
471 timestamp_helper_->GetFrameDuration(frame->frame_count())); | 471 timestamp_helper_->GetFrameDuration(frame->frame_count())); |
472 timestamp_helper_->AddFrames(frame->frame_count()); | 472 timestamp_helper_->AddFrames(frame->frame_count()); |
473 } | 473 } |
474 } | 474 } |
475 | 475 |
476 } // namespace media | 476 } // namespace media |
OLD | NEW |