| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/mojo/clients/mojo_audio_decoder.h" | 5 #include "media/mojo/clients/mojo_audio_decoder.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 const InitCB& init_cb, | 41 const InitCB& init_cb, |
| 42 const OutputCB& output_cb) { | 42 const OutputCB& output_cb) { |
| 43 DVLOG(1) << __func__; | 43 DVLOG(1) << __func__; |
| 44 DCHECK(task_runner_->BelongsToCurrentThread()); | 44 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 45 | 45 |
| 46 if (!remote_decoder_.is_bound()) | 46 if (!remote_decoder_.is_bound()) |
| 47 BindRemoteDecoder(); | 47 BindRemoteDecoder(); |
| 48 | 48 |
| 49 // This could happen during reinitialization. | 49 // This could happen during reinitialization. |
| 50 if (remote_decoder_.encountered_error()) { | 50 if (remote_decoder_.encountered_error()) { |
| 51 DVLOG(1) << __func__ << ": Connection error happened."; |
| 51 task_runner_->PostTask(FROM_HERE, base::Bind(init_cb, false)); | 52 task_runner_->PostTask(FROM_HERE, base::Bind(init_cb, false)); |
| 52 return; | 53 return; |
| 53 } | 54 } |
| 54 | 55 |
| 55 // Fail immediately if the stream is encrypted but |cdm_context| is invalid. | 56 // Fail immediately if the stream is encrypted but |cdm_context| is invalid. |
| 56 int cdm_id = (config.is_encrypted() && cdm_context) | 57 int cdm_id = (config.is_encrypted() && cdm_context) |
| 57 ? cdm_context->GetCdmId() | 58 ? cdm_context->GetCdmId() |
| 58 : CdmContext::kInvalidCdmId; | 59 : CdmContext::kInvalidCdmId; |
| 59 | 60 |
| 60 if (config.is_encrypted() && CdmContext::kInvalidCdmId == cdm_id) { | 61 if (config.is_encrypted() && CdmContext::kInvalidCdmId == cdm_id) { |
| 62 DVLOG(1) << __func__ << ": Invalid CdmContext."; |
| 61 task_runner_->PostTask(FROM_HERE, base::Bind(init_cb, false)); | 63 task_runner_->PostTask(FROM_HERE, base::Bind(init_cb, false)); |
| 62 return; | 64 return; |
| 63 } | 65 } |
| 64 | 66 |
| 65 init_cb_ = init_cb; | 67 init_cb_ = init_cb; |
| 66 output_cb_ = output_cb; | 68 output_cb_ = output_cb; |
| 67 | 69 |
| 68 // Using base::Unretained(this) is safe because |this| owns |remote_decoder_|, | 70 // Using base::Unretained(this) is safe because |this| owns |remote_decoder_|, |
| 69 // and the callback won't be dispatched if |remote_decoder_| is destroyed. | 71 // and the callback won't be dispatched if |remote_decoder_| is destroyed. |
| 70 remote_decoder_->Initialize( | 72 remote_decoder_->Initialize( |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 DCHECK(task_runner_->BelongsToCurrentThread()); | 200 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 199 | 201 |
| 200 // For pending decodes OnDecodeStatus() should arrive before OnResetDone(). | 202 // For pending decodes OnDecodeStatus() should arrive before OnResetDone(). |
| 201 DCHECK(decode_cb_.is_null()); | 203 DCHECK(decode_cb_.is_null()); |
| 202 | 204 |
| 203 DCHECK(!reset_cb_.is_null()); | 205 DCHECK(!reset_cb_.is_null()); |
| 204 base::ResetAndReturn(&reset_cb_).Run(); | 206 base::ResetAndReturn(&reset_cb_).Run(); |
| 205 } | 207 } |
| 206 | 208 |
| 207 } // namespace media | 209 } // namespace media |
| OLD | NEW |