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 CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_THREAD_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_THREAD_H_ |
6 #define CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_THREAD_H_ | 6 #define CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_THREAD_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 // | 28 // |
29 // TODO(tommi): Multiple Audio[Input]Device instances should be able to share | 29 // TODO(tommi): Multiple Audio[Input]Device instances should be able to share |
30 // the same thread instead of spinning one per instance. | 30 // the same thread instead of spinning one per instance. |
31 class CONTENT_EXPORT AudioDeviceThread { | 31 class CONTENT_EXPORT AudioDeviceThread { |
32 public: | 32 public: |
33 // This is the callback interface/base class that Audio[Input]Device | 33 // This is the callback interface/base class that Audio[Input]Device |
34 // implements to render input/output data. The callback happens on the | 34 // implements to render input/output data. The callback happens on the |
35 // AudioDevice thread. | 35 // AudioDevice thread. |
36 class Callback { | 36 class Callback { |
37 public: | 37 public: |
38 Callback(const AudioParameters& audio_parameters, | 38 Callback(const media::AudioParameters& audio_parameters, |
39 base::SharedMemoryHandle memory, | 39 base::SharedMemoryHandle memory, |
40 int memory_length); | 40 int memory_length); |
41 virtual ~Callback(); | 41 virtual ~Callback(); |
42 | 42 |
43 // One time initialization for the callback object on the audio thread. | 43 // One time initialization for the callback object on the audio thread. |
44 void InitializeOnAudioThread(); | 44 void InitializeOnAudioThread(); |
45 | 45 |
46 // Derived implementations must call shared_memory_.Map appropriately | 46 // Derived implementations must call shared_memory_.Map appropriately |
47 // before Process can be called. | 47 // before Process can be called. |
48 virtual void MapSharedMemory() = 0; | 48 virtual void MapSharedMemory() = 0; |
49 | 49 |
50 // Called whenever we receive notifications about pending data. | 50 // Called whenever we receive notifications about pending data. |
51 virtual void Process(int pending_data) = 0; | 51 virtual void Process(int pending_data) = 0; |
52 | 52 |
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 media::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 std::vector<float*> audio_data_; |
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: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // reliable initialization. | 100 // reliable initialization. |
101 class Thread; | 101 class Thread; |
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 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_THREAD_H_ | 109 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_THREAD_H_ |
OLD | NEW |