| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 147 |
| 148 void DecryptingAudioDecoder::Stop(const base::Closure& closure) { | 148 void DecryptingAudioDecoder::Stop(const base::Closure& closure) { |
| 149 DVLOG(2) << "Stop() - state: " << state_; | 149 DVLOG(2) << "Stop() - state: " << state_; |
| 150 DCHECK(task_runner_->BelongsToCurrentThread()); | 150 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 151 | 151 |
| 152 // Invalidate all weak pointers so that pending callbacks won't be fired into | 152 // Invalidate all weak pointers so that pending callbacks won't be fired into |
| 153 // this object. | 153 // this object. |
| 154 weak_factory_.InvalidateWeakPtrs(); | 154 weak_factory_.InvalidateWeakPtrs(); |
| 155 | 155 |
| 156 if (decryptor_) { | 156 if (decryptor_) { |
| 157 decryptor_->RegisterNewKeyCB(Decryptor::kAudio, Decryptor::NewKeyCB()); | |
| 158 decryptor_->DeinitializeDecoder(Decryptor::kAudio); | 157 decryptor_->DeinitializeDecoder(Decryptor::kAudio); |
| 159 decryptor_ = NULL; | 158 decryptor_ = NULL; |
| 160 } | 159 } |
| 161 if (!set_decryptor_ready_cb_.is_null()) | 160 if (!set_decryptor_ready_cb_.is_null()) |
| 162 base::ResetAndReturn(&set_decryptor_ready_cb_).Run(DecryptorReadyCB()); | 161 base::ResetAndReturn(&set_decryptor_ready_cb_).Run(DecryptorReadyCB()); |
| 163 pending_buffer_to_decode_ = NULL; | 162 pending_buffer_to_decode_ = NULL; |
| 164 if (!init_cb_.is_null()) | 163 if (!init_cb_.is_null()) |
| 165 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); | 164 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); |
| 166 if (!read_cb_.is_null()) | 165 if (!read_cb_.is_null()) |
| 167 base::ResetAndReturn(&read_cb_).Run(kAborted, NULL); | 166 base::ResetAndReturn(&read_cb_).Run(kAborted, NULL); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 if (!success) { | 240 if (!success) { |
| 242 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); | 241 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); |
| 243 state_ = kStopped; | 242 state_ = kStopped; |
| 244 return; | 243 return; |
| 245 } | 244 } |
| 246 | 245 |
| 247 // Success! | 246 // Success! |
| 248 UpdateDecoderConfig(); | 247 UpdateDecoderConfig(); |
| 249 | 248 |
| 250 decryptor_->RegisterNewKeyCB( | 249 decryptor_->RegisterNewKeyCB( |
| 251 Decryptor::kAudio, BindToCurrentLoop(base::Bind( | 250 Decryptor::kAudio, |
| 252 &DecryptingAudioDecoder::OnKeyAdded, weak_this_))); | 251 BindToCurrentLoop( |
| 252 base::Bind(&DecryptingAudioDecoder::OnKeyAdded, weak_this_))); |
| 253 | 253 |
| 254 state_ = kIdle; | 254 state_ = kIdle; |
| 255 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); | 255 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); |
| 256 } | 256 } |
| 257 | 257 |
| 258 void DecryptingAudioDecoder::FinishConfigChange(bool success) { | 258 void DecryptingAudioDecoder::FinishConfigChange(bool success) { |
| 259 DVLOG(2) << "FinishConfigChange()"; | 259 DVLOG(2) << "FinishConfigChange()"; |
| 260 DCHECK(task_runner_->BelongsToCurrentThread()); | 260 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 261 DCHECK_EQ(state_, kPendingConfigChange) << state_; | 261 DCHECK_EQ(state_, kPendingConfigChange) << state_; |
| 262 DCHECK(!read_cb_.is_null()); | 262 DCHECK(!read_cb_.is_null()); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 } | 495 } |
| 496 | 496 |
| 497 frame->set_timestamp(current_time); | 497 frame->set_timestamp(current_time); |
| 498 frame->set_duration( | 498 frame->set_duration( |
| 499 timestamp_helper_->GetFrameDuration(frame->frame_count())); | 499 timestamp_helper_->GetFrameDuration(frame->frame_count())); |
| 500 timestamp_helper_->AddFrames(frame->frame_count()); | 500 timestamp_helper_->AddFrames(frame->frame_count()); |
| 501 } | 501 } |
| 502 } | 502 } |
| 503 | 503 |
| 504 } // namespace media | 504 } // namespace media |
| OLD | NEW |