| 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 #ifndef MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_ |
| 6 #define MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_ | 6 #define MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/shared_memory.h" | 11 #include "base/memory/shared_memory.h" |
| 12 #include "base/sync_socket.h" | 12 #include "base/sync_socket.h" |
| 13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 14 #include "media/audio/audio_parameters.h" | 14 #include "media/audio/audio_parameters.h" |
| 15 #include "media/audio/shared_memory_util.h" | |
| 16 #include "media/base/media_export.h" | 15 #include "media/base/media_export.h" |
| 17 | 16 |
| 18 namespace base { | 17 namespace base { |
| 19 class MessageLoop; | 18 class MessageLoop; |
| 20 } | 19 } |
| 21 | 20 |
| 22 namespace media { | 21 namespace media { |
| 23 class AudioBus; | 22 class AudioBus; |
| 24 | 23 |
| 25 // Data transfer between browser and render process uses a combination | 24 // Data transfer between browser and render process uses a combination |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 const int total_segments_; | 66 const int total_segments_; |
| 68 int segment_length_; | 67 int segment_length_; |
| 69 | 68 |
| 70 private: | 69 private: |
| 71 DISALLOW_COPY_AND_ASSIGN(Callback); | 70 DISALLOW_COPY_AND_ASSIGN(Callback); |
| 72 }; | 71 }; |
| 73 | 72 |
| 74 AudioDeviceThread(); | 73 AudioDeviceThread(); |
| 75 ~AudioDeviceThread(); | 74 ~AudioDeviceThread(); |
| 76 | 75 |
| 77 // Starts the audio thread. The thread must not already be running. | 76 // Starts the audio thread. The thread must not already be running. If |
| 77 // |sychronized_buffers| is set, the browser expects to be notified via the |
| 78 // |socket| every time AudioDeviceThread::Process() completes. |
| 78 void Start(AudioDeviceThread::Callback* callback, | 79 void Start(AudioDeviceThread::Callback* callback, |
| 79 base::SyncSocket::Handle socket, | 80 base::SyncSocket::Handle socket, |
| 80 const char* thread_name); | 81 const char* thread_name, |
| 82 bool synchronized_buffers); |
| 81 | 83 |
| 82 // This tells the audio thread to stop and clean up the data. | 84 // This tells the audio thread to stop and clean up the data. |
| 83 // The method can stop the thread synchronously or asynchronously. | 85 // The method can stop the thread synchronously or asynchronously. |
| 84 // In the latter case, the thread will still be running after Stop() | 86 // In the latter case, the thread will still be running after Stop() |
| 85 // returns, but the callback pointer is cleared so no further callbacks will | 87 // returns, but the callback pointer is cleared so no further callbacks will |
| 86 // be made (IOW after Stop() returns, it is safe to delete the callback). | 88 // be made (IOW after Stop() returns, it is safe to delete the callback). |
| 87 // The |loop_for_join| parameter is required for asynchronous operation | 89 // The |loop_for_join| parameter is required for asynchronous operation |
| 88 // in order to join the worker thread and close the thread handle later via a | 90 // in order to join the worker thread and close the thread handle later via a |
| 89 // posted task. | 91 // posted task. |
| 90 // If set to NULL, function will wait for the thread to exit before returning. | 92 // If set to NULL, function will wait for the thread to exit before returning. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 105 | 107 |
| 106 base::Lock thread_lock_; | 108 base::Lock thread_lock_; |
| 107 scoped_refptr<AudioDeviceThread::Thread> thread_; | 109 scoped_refptr<AudioDeviceThread::Thread> thread_; |
| 108 | 110 |
| 109 DISALLOW_COPY_AND_ASSIGN(AudioDeviceThread); | 111 DISALLOW_COPY_AND_ASSIGN(AudioDeviceThread); |
| 110 }; | 112 }; |
| 111 | 113 |
| 112 } // namespace media. | 114 } // namespace media. |
| 113 | 115 |
| 114 #endif // MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_ | 116 #endif // MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_ |
| OLD | NEW |