| 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 = AudioBus::CalculateMemorySize(params); | 541 uint32 shared_memory_size = sizeof(media::AudioOutputBufferParameters) + |
| 542 AudioBus::CalculateMemorySize(params); |
| 542 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory()); | 543 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory()); |
| 543 if (!shared_memory->CreateAndMapAnonymous(shared_memory_size)) { | 544 if (!shared_memory->CreateAndMapAnonymous(shared_memory_size)) { |
| 544 SendErrorMessage(stream_id); | 545 SendErrorMessage(stream_id); |
| 545 return; | 546 return; |
| 546 } | 547 } |
| 547 | 548 |
| 548 scoped_ptr<AudioSyncReader> reader( | 549 scoped_ptr<AudioSyncReader> reader( |
| 549 new AudioSyncReader(shared_memory.get(), params)); | 550 new AudioSyncReader(shared_memory.get(), params)); |
| 550 if (!reader->Init()) { | 551 if (!reader->Init()) { |
| 551 SendErrorMessage(stream_id); | 552 SendErrorMessage(stream_id); |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 callback.Run(false, device_info); | 809 callback.Run(false, device_info); |
| 809 } | 810 } |
| 810 | 811 |
| 811 bool AudioRendererHost::IsAuthorizationStarted(int stream_id) { | 812 bool AudioRendererHost::IsAuthorizationStarted(int stream_id) { |
| 812 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 813 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 813 const auto& i = authorizations_.find(stream_id); | 814 const auto& i = authorizations_.find(stream_id); |
| 814 return i != authorizations_.end(); | 815 return i != authorizations_.end(); |
| 815 } | 816 } |
| 816 | 817 |
| 817 } // namespace content | 818 } // namespace content |
| OLD | NEW |