| 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 <vector> | |
| 9 | |
| 10 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 11 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/shared_memory.h" | 11 #include "base/shared_memory.h" |
| 13 #include "base/sync_socket.h" | 12 #include "base/sync_socket.h" |
| 14 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 15 #include "media/base/media_export.h" | 14 #include "media/base/media_export.h" |
| 16 #include "media/audio/audio_parameters.h" | 15 #include "media/audio/audio_parameters.h" |
| 17 | 16 |
| 18 class MessageLoop; | 17 class MessageLoop; |
| 19 | 18 |
| 20 namespace media { | 19 namespace media { |
| 20 class AudioBus; |
| 21 | 21 |
| 22 // Data transfer between browser and render process uses a combination | 22 // Data transfer between browser and render process uses a combination |
| 23 // of sync sockets and shared memory. To read from the socket and render | 23 // 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 | 24 // 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 | 25 // data from the browser via the socket and fills the shared memory from the |
| 26 // audio thread via the AudioDeviceThread::Callback interface/class. | 26 // audio thread via the AudioDeviceThread::Callback interface/class. |
| 27 // For more details see the documentation in audio_device.h. | 27 // For more details see the documentation in audio_device.h. |
| 28 // | 28 // |
| 29 // TODO(tommi): Multiple audio input/output device instances should be able to | 29 // TODO(tommi): Multiple audio input/output device instances should be able to |
| 30 // share the same thread instead of spinning one per instance. | 30 // share the same thread instead of spinning one per instance. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 53 protected: | 53 protected: |
| 54 // Protected so that derived classes can access directly. | 54 // Protected so that derived classes can access directly. |
| 55 // The variables are 'const' since values are calculated/set in the | 55 // The variables are 'const' since values are calculated/set in the |
| 56 // constructor and must never change. | 56 // constructor and must never change. |
| 57 const AudioParameters audio_parameters_; | 57 const AudioParameters audio_parameters_; |
| 58 const int samples_per_ms_; | 58 const int samples_per_ms_; |
| 59 const int bytes_per_ms_; | 59 const int bytes_per_ms_; |
| 60 | 60 |
| 61 // Audio buffers that are allocated in InitializeOnAudioThread() based on | 61 // Audio buffers that are allocated in InitializeOnAudioThread() based on |
| 62 // info from audio_parameters_. | 62 // info from audio_parameters_. |
| 63 std::vector<float*> audio_data_; | 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 |