| 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/shared_memory.h" | 11 #include "base/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/base/media_export.h" | 14 #include "media/base/media_export.h" |
| 15 #include "media/audio/audio_parameters.h" | 15 #include "media/audio/audio_parameters.h" |
| 16 #include "media/audio/shared_memory_util.h" |
| 16 | 17 |
| 17 class MessageLoop; | 18 class MessageLoop; |
| 18 | 19 |
| 19 namespace media { | 20 namespace media { |
| 20 class AudioBus; | 21 class AudioBus; |
| 21 | 22 |
| 22 // Data transfer between browser and render process uses a combination | 23 // Data transfer between browser and render process uses a combination |
| 23 // of sync sockets and shared memory. To read from the socket and render | 24 // of sync sockets and shared memory. To read from the socket and render |
| 24 // data, we use a worker thread, a.k.a. the AudioDeviceThread, which reads | 25 // data, we use a worker thread, a.k.a. the AudioDeviceThread, which reads |
| 25 // data from the browser via the socket and fills the shared memory from the | 26 // data from the browser via the socket and fills the shared memory from the |
| (...skipping 27 matching lines...) Expand all Loading... |
| 53 protected: | 54 protected: |
| 54 // Protected so that derived classes can access directly. | 55 // Protected so that derived classes can access directly. |
| 55 // The variables are 'const' since values are calculated/set in the | 56 // The variables are 'const' since values are calculated/set in the |
| 56 // constructor and must never change. | 57 // constructor and must never change. |
| 57 const AudioParameters audio_parameters_; | 58 const AudioParameters audio_parameters_; |
| 58 const int samples_per_ms_; | 59 const int samples_per_ms_; |
| 59 const int bytes_per_ms_; | 60 const int bytes_per_ms_; |
| 60 | 61 |
| 61 // Audio buffers that are allocated in InitializeOnAudioThread() based on | 62 // Audio buffers that are allocated in InitializeOnAudioThread() based on |
| 62 // info from audio_parameters_. | 63 // info from audio_parameters_. |
| 63 scoped_ptr<AudioBus> audio_bus_; | |
| 64 base::SharedMemory shared_memory_; | 64 base::SharedMemory shared_memory_; |
| 65 const int memory_length_; | 65 const int memory_length_; |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 DISALLOW_COPY_AND_ASSIGN(Callback); | 68 DISALLOW_COPY_AND_ASSIGN(Callback); |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 AudioDeviceThread(); | 71 AudioDeviceThread(); |
| 72 ~AudioDeviceThread(); | 72 ~AudioDeviceThread(); |
| 73 | 73 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 102 | 102 |
| 103 base::Lock thread_lock_; | 103 base::Lock thread_lock_; |
| 104 scoped_refptr<AudioDeviceThread::Thread> thread_; | 104 scoped_refptr<AudioDeviceThread::Thread> thread_; |
| 105 | 105 |
| 106 DISALLOW_COPY_AND_ASSIGN(AudioDeviceThread); | 106 DISALLOW_COPY_AND_ASSIGN(AudioDeviceThread); |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 } // namespace media. | 109 } // namespace media. |
| 110 | 110 |
| 111 #endif // MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_ | 111 #endif // MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_ |
| OLD | NEW |