Chromium Code Reviews| 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 "content/browser/renderer_host/media/audio_renderer_host.h" | 5 #include "content/browser/renderer_host/media/audio_renderer_host.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 488 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 488 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 489 DVLOG(1) << "AudioRendererHost@" << this << "::OnCreateStream" | 489 DVLOG(1) << "AudioRendererHost@" << this << "::OnCreateStream" |
| 490 << "(stream_id=" << stream_id << ")"; | 490 << "(stream_id=" << stream_id << ")"; |
| 491 | 491 |
| 492 // Determine whether to use the device_unique_id from an authorization, or an | 492 // Determine whether to use the device_unique_id from an authorization, or an |
| 493 // empty string (i.e., when no previous authorization was requested, assume | 493 // empty string (i.e., when no previous authorization was requested, assume |
| 494 // default device). | 494 // default device). |
| 495 std::string device_unique_id; | 495 std::string device_unique_id; |
| 496 const auto& auth_data = authorizations_.find(stream_id); | 496 const auto& auth_data = authorizations_.find(stream_id); |
| 497 if (auth_data != authorizations_.end()) { | 497 if (auth_data != authorizations_.end()) { |
| 498 CHECK(auth_data->second.first); | 498 if (!auth_data->second.first) { |
| 499 // The authorization for this stream is still pending, so it's an error | |
| 500 // to create it now. | |
| 501 SendErrorMessage(stream_id); | |
|
Guido Urdaneta
2016/10/04 09:57:11
Since this should happen only with a bad renderer,
| |
| 502 return; | |
| 503 } | |
| 499 device_unique_id.swap(auth_data->second.second); | 504 device_unique_id.swap(auth_data->second.second); |
| 500 authorizations_.erase(auth_data); | 505 authorizations_.erase(auth_data); |
| 501 } | 506 } |
| 502 | 507 |
| 503 // Fail early if either of two sanity-checks fail: | 508 // Fail early if either of two sanity-checks fail: |
| 504 // 1. There should not yet exist an AudioEntry for the given |stream_id| | 509 // 1. There should not yet exist an AudioEntry for the given |stream_id| |
| 505 // since the renderer may not create two streams with the same ID. | 510 // since the renderer may not create two streams with the same ID. |
| 506 // 2. An out-of-range render frame ID was provided. Renderers must *always* | 511 // 2. An out-of-range render frame ID was provided. Renderers must *always* |
| 507 // specify a valid render frame ID for each audio output they create, as | 512 // specify a valid render frame ID for each audio output they create, as |
| 508 // several browser-level features depend on this (e.g., OOM manager, UI | 513 // several browser-level features depend on this (e.g., OOM manager, UI |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 850 std::string() /* matched_device_id */)); | 855 std::string() /* matched_device_id */)); |
| 851 } | 856 } |
| 852 | 857 |
| 853 bool AudioRendererHost::IsAuthorizationStarted(int stream_id) { | 858 bool AudioRendererHost::IsAuthorizationStarted(int stream_id) { |
| 854 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 859 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 855 const auto& i = authorizations_.find(stream_id); | 860 const auto& i = authorizations_.find(stream_id); |
| 856 return i != authorizations_.end(); | 861 return i != authorizations_.end(); |
| 857 } | 862 } |
| 858 | 863 |
| 859 } // namespace content | 864 } // namespace content |
| OLD | NEW |