OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/audio/audio_output_controller.h" | 5 #include "media/audio/audio_output_controller.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 | 8 |
9 // The following parameters limit the request buffer and packet size from the | 9 // The following parameters limit the request buffer and packet size from the |
10 // renderer to avoid renderer from requesting too much memory. | 10 // renderer to avoid renderer from requesting too much memory. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 scoped_refptr<AudioOutputController> AudioOutputController::Create( | 51 scoped_refptr<AudioOutputController> AudioOutputController::Create( |
52 EventHandler* event_handler, | 52 EventHandler* event_handler, |
53 AudioParameters params, | 53 AudioParameters params, |
54 uint32 hardware_buffer_size, | 54 uint32 hardware_buffer_size, |
55 uint32 buffer_capacity) { | 55 uint32 buffer_capacity) { |
56 | 56 |
57 if (!CheckParameters(params, hardware_buffer_size)) | 57 if (!CheckParameters(params, hardware_buffer_size)) |
58 return NULL; | 58 return NULL; |
59 | 59 |
60 // Starts the audio controller thread. | 60 // Starts the audio controller thread. |
61 scoped_refptr<AudioOutputController> controller = new AudioOutputController( | 61 scoped_refptr<AudioOutputController> controller(new AudioOutputController( |
62 event_handler, buffer_capacity, NULL); | 62 event_handler, buffer_capacity, NULL)); |
63 | 63 |
64 controller->message_loop_ = | 64 controller->message_loop_ = |
65 AudioManager::GetAudioManager()->GetMessageLoop(); | 65 AudioManager::GetAudioManager()->GetMessageLoop(); |
66 controller->message_loop_->PostTask( | 66 controller->message_loop_->PostTask( |
67 FROM_HERE, | 67 FROM_HERE, |
68 NewRunnableMethod(controller.get(), &AudioOutputController::DoCreate, | 68 NewRunnableMethod(controller.get(), &AudioOutputController::DoCreate, |
69 params, hardware_buffer_size)); | 69 params, hardware_buffer_size)); |
70 return controller; | 70 return controller; |
71 } | 71 } |
72 | 72 |
73 // static | 73 // static |
74 scoped_refptr<AudioOutputController> AudioOutputController::CreateLowLatency( | 74 scoped_refptr<AudioOutputController> AudioOutputController::CreateLowLatency( |
75 EventHandler* event_handler, | 75 EventHandler* event_handler, |
76 AudioParameters params, | 76 AudioParameters params, |
77 uint32 hardware_buffer_size, | 77 uint32 hardware_buffer_size, |
78 SyncReader* sync_reader) { | 78 SyncReader* sync_reader) { |
79 | 79 |
80 DCHECK(sync_reader); | 80 DCHECK(sync_reader); |
81 | 81 |
82 if (!CheckParameters(params, hardware_buffer_size)) | 82 if (!CheckParameters(params, hardware_buffer_size)) |
83 return NULL; | 83 return NULL; |
84 | 84 |
85 // Starts the audio controller thread. | 85 // Starts the audio controller thread. |
86 scoped_refptr<AudioOutputController> controller = new AudioOutputController( | 86 scoped_refptr<AudioOutputController> controller(new AudioOutputController( |
87 event_handler, 0, sync_reader); | 87 event_handler, 0, sync_reader)); |
88 | 88 |
89 controller->message_loop_ = | 89 controller->message_loop_ = |
90 AudioManager::GetAudioManager()->GetMessageLoop(); | 90 AudioManager::GetAudioManager()->GetMessageLoop(); |
91 controller->message_loop_->PostTask( | 91 controller->message_loop_->PostTask( |
92 FROM_HERE, | 92 FROM_HERE, |
93 NewRunnableMethod(controller.get(), &AudioOutputController::DoCreate, | 93 NewRunnableMethod(controller.get(), &AudioOutputController::DoCreate, |
94 params, hardware_buffer_size)); | 94 params, hardware_buffer_size)); |
95 return controller; | 95 return controller; |
96 } | 96 } |
97 | 97 |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 buffers_state.pending_bytes += buffer_.forward_bytes(); | 329 buffers_state.pending_bytes += buffer_.forward_bytes(); |
330 | 330 |
331 // If we need more data then call the event handler to ask for more data. | 331 // If we need more data then call the event handler to ask for more data. |
332 // It is okay that we don't lock in this block because the parameters are | 332 // It is okay that we don't lock in this block because the parameters are |
333 // correct and in the worst case we are just asking more data than needed. | 333 // correct and in the worst case we are just asking more data than needed. |
334 AutoUnlock auto_unlock(lock_); | 334 AutoUnlock auto_unlock(lock_); |
335 handler_->OnMoreData(this, buffers_state); | 335 handler_->OnMoreData(this, buffers_state); |
336 } | 336 } |
337 | 337 |
338 } // namespace media | 338 } // namespace media |
OLD | NEW |