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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 const std::string& device_unique_id) { | 531 const std::string& device_unique_id) { |
532 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 532 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
533 | 533 |
534 // media::AudioParameters is validated in the deserializer. | 534 // media::AudioParameters is validated in the deserializer. |
535 if (LookupById(stream_id) != NULL) { | 535 if (LookupById(stream_id) != NULL) { |
536 SendErrorMessage(stream_id); | 536 SendErrorMessage(stream_id); |
537 return; | 537 return; |
538 } | 538 } |
539 | 539 |
540 // Create the shared memory and share with the renderer process. | 540 // Create the shared memory and share with the renderer process. |
541 uint32 shared_memory_size = sizeof(media::AudioOutputBufferParameters) + | 541 uint32 shared_memory_size = AudioBus::CalculateMemorySize(params); |
542 AudioBus::CalculateMemorySize(params); | |
543 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory()); | 542 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory()); |
544 if (!shared_memory->CreateAndMapAnonymous(shared_memory_size)) { | 543 if (!shared_memory->CreateAndMapAnonymous(shared_memory_size)) { |
545 SendErrorMessage(stream_id); | 544 SendErrorMessage(stream_id); |
546 return; | 545 return; |
547 } | 546 } |
548 | 547 |
549 scoped_ptr<AudioSyncReader> reader( | 548 scoped_ptr<AudioSyncReader> reader( |
550 new AudioSyncReader(shared_memory.get(), params)); | 549 new AudioSyncReader(shared_memory.get(), params)); |
551 if (!reader->Init()) { | 550 if (!reader->Init()) { |
552 SendErrorMessage(stream_id); | 551 SendErrorMessage(stream_id); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 callback.Run(false, device_info); | 808 callback.Run(false, device_info); |
810 } | 809 } |
811 | 810 |
812 bool AudioRendererHost::IsAuthorizationStarted(int stream_id) { | 811 bool AudioRendererHost::IsAuthorizationStarted(int stream_id) { |
813 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 812 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
814 const auto& i = authorizations_.find(stream_id); | 813 const auto& i = authorizations_.find(stream_id); |
815 return i != authorizations_.end(); | 814 return i != authorizations_.end(); |
816 } | 815 } |
817 | 816 |
818 } // namespace content | 817 } // namespace content |
OLD | NEW |