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" |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 | 290 |
291 state_ = kWaitingForKey; | 291 state_ = kWaitingForKey; |
292 return; | 292 return; |
293 } | 293 } |
294 | 294 |
295 if (status == Decryptor::kNeedMoreData) { | 295 if (status == Decryptor::kNeedMoreData) { |
296 DVLOG(2) << "DeliverFrame() - kNeedMoreData"; | 296 DVLOG(2) << "DeliverFrame() - kNeedMoreData"; |
297 if (scoped_pending_buffer_to_decode->end_of_stream()) { | 297 if (scoped_pending_buffer_to_decode->end_of_stream()) { |
298 state_ = kDecodeFinished; | 298 state_ = kDecodeFinished; |
299 output_cb_.Run(AudioBuffer::CreateEOSBuffer()); | 299 output_cb_.Run(AudioBuffer::CreateEOSBuffer()); |
300 base::ResetAndReturn(&decode_cb_).Run(kOk); | 300 } else { |
301 return; | 301 state_ = kIdle; |
302 } | 302 } |
303 | |
304 state_ = kIdle; | |
305 base::ResetAndReturn(&decode_cb_).Run(kOk); | 303 base::ResetAndReturn(&decode_cb_).Run(kOk); |
306 return; | 304 return; |
307 } | 305 } |
308 | 306 |
309 DCHECK_EQ(status, Decryptor::kSuccess); | 307 DCHECK_EQ(status, Decryptor::kSuccess); |
310 DCHECK(!frames.empty()); | 308 DCHECK(!frames.empty()); |
311 ProcessDecodedFrames(frames); | 309 ProcessDecodedFrames(frames); |
312 | 310 |
| 311 if (scoped_pending_buffer_to_decode->end_of_stream()) { |
| 312 // Set |pending_buffer_to_decode_| back as we need to keep flushing the |
| 313 // decryptor until kNeedMoreData is returned. |
| 314 pending_buffer_to_decode_ = scoped_pending_buffer_to_decode; |
| 315 DecodePendingBuffer(); |
| 316 return; |
| 317 } |
| 318 |
313 state_ = kIdle; | 319 state_ = kIdle; |
314 base::ResetAndReturn(&decode_cb_).Run(kOk); | 320 base::ResetAndReturn(&decode_cb_).Run(kOk); |
315 } | 321 } |
316 | 322 |
317 void DecryptingAudioDecoder::OnKeyAdded() { | 323 void DecryptingAudioDecoder::OnKeyAdded() { |
318 DCHECK(task_runner_->BelongsToCurrentThread()); | 324 DCHECK(task_runner_->BelongsToCurrentThread()); |
319 | 325 |
320 if (state_ == kPendingDecode) { | 326 if (state_ == kPendingDecode) { |
321 key_added_while_decode_pending_ = true; | 327 key_added_while_decode_pending_ = true; |
322 return; | 328 return; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 } | 361 } |
356 | 362 |
357 frame->set_timestamp(current_time); | 363 frame->set_timestamp(current_time); |
358 timestamp_helper_->AddFrames(frame->frame_count()); | 364 timestamp_helper_->AddFrames(frame->frame_count()); |
359 | 365 |
360 output_cb_.Run(frame); | 366 output_cb_.Run(frame); |
361 } | 367 } |
362 } | 368 } |
363 | 369 |
364 } // namespace media | 370 } // namespace media |
OLD | NEW |