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" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 int total_segments); | 43 int total_segments); |
44 virtual ~Callback(); | 44 virtual ~Callback(); |
45 | 45 |
46 // One time initialization for the callback object on the audio thread. | 46 // One time initialization for the callback object on the audio thread. |
47 void InitializeOnAudioThread(); | 47 void InitializeOnAudioThread(); |
48 | 48 |
49 // Derived implementations must call shared_memory_.Map appropriately | 49 // Derived implementations must call shared_memory_.Map appropriately |
50 // before Process can be called. | 50 // before Process can be called. |
51 virtual void MapSharedMemory() = 0; | 51 virtual void MapSharedMemory() = 0; |
52 | 52 |
53 // Called whenever we receive notifications about pending data. | 53 // Called whenever we receive notifications about pending input data. |
54 virtual void Process(uint32 pending_data) = 0; | 54 virtual void Process(uint32_t pending_data) = 0; |
55 | 55 |
56 protected: | 56 protected: |
57 // Protected so that derived classes can access directly. | 57 // Protected so that derived classes can access directly. |
58 // The variables are 'const' since values are calculated/set in the | 58 // The variables are 'const' since values are calculated/set in the |
59 // constructor and must never change. | 59 // constructor and must never change. |
60 const AudioParameters audio_parameters_; | 60 const AudioParameters audio_parameters_; |
61 const int samples_per_ms_; | 61 const int samples_per_ms_; |
62 const int bytes_per_ms_; | 62 const int bytes_per_ms_; |
63 | 63 |
64 base::SharedMemory shared_memory_; | 64 base::SharedMemory shared_memory_; |
65 const int memory_length_; | 65 const int memory_length_; |
66 const int total_segments_; | 66 const int total_segments_; |
67 int segment_length_; | 67 int segment_length_; |
68 | 68 |
69 private: | 69 private: |
70 DISALLOW_COPY_AND_ASSIGN(Callback); | 70 DISALLOW_COPY_AND_ASSIGN(Callback); |
71 }; | 71 }; |
72 | 72 |
73 AudioDeviceThread(); | 73 AudioDeviceThread(); |
74 ~AudioDeviceThread(); | 74 ~AudioDeviceThread(); |
75 | 75 |
76 // Starts the audio thread. The thread must not already be running. If | 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 | 77 // |sychronized_buffers| is set, the browser expects to be notified via the |
78 // |socket| every time AudioDeviceThread::Process() completes. | 78 // |socket| every time AudioDeviceThread::Process() completes. |input| should |
tommi (sloooow) - chröme
2015/12/08 08:34:51
what does |input| refer to?
Henrik Grunell
2015/12/08 09:30:34
Whether this object is used for input audio or not
tommi (sloooow) - chröme
2015/12/08 10:08:09
It looks like this refers to a variable that can b
Henrik Grunell
2015/12/08 11:12:32
Merge error. removed.
| |
79 // be true for input and false for output. It is used for reading the right | |
80 // amount of data from the socket. | |
81 // TODO(grunell): |input| is ugly, but there are plans to re-use a thread for | |
82 // multiple inputs/outputs (see todo comment above) so we do it this way | |
83 // meanwhile instead of using separate classes. | |
79 void Start(AudioDeviceThread::Callback* callback, | 84 void Start(AudioDeviceThread::Callback* callback, |
80 base::SyncSocket::Handle socket, | 85 base::SyncSocket::Handle socket, |
81 const char* thread_name, | 86 const char* thread_name, |
82 bool synchronized_buffers); | 87 bool synchronized_buffers); |
83 | 88 |
84 // This tells the audio thread to stop and clean up the data. | 89 // This tells the audio thread to stop and clean up the data. |
85 // The method can stop the thread synchronously or asynchronously. | 90 // The method can stop the thread synchronously or asynchronously. |
86 // In the latter case, the thread will still be running after Stop() | 91 // In the latter case, the thread will still be running after Stop() |
87 // returns, but the callback pointer is cleared so no further callbacks will | 92 // returns, but the callback pointer is cleared so no further callbacks will |
88 // be made (IOW after Stop() returns, it is safe to delete the callback). | 93 // be made (IOW after Stop() returns, it is safe to delete the callback). |
(...skipping 18 matching lines...) Expand all Loading... | |
107 | 112 |
108 base::Lock thread_lock_; | 113 base::Lock thread_lock_; |
109 scoped_refptr<AudioDeviceThread::Thread> thread_; | 114 scoped_refptr<AudioDeviceThread::Thread> thread_; |
110 | 115 |
111 DISALLOW_COPY_AND_ASSIGN(AudioDeviceThread); | 116 DISALLOW_COPY_AND_ASSIGN(AudioDeviceThread); |
112 }; | 117 }; |
113 | 118 |
114 } // namespace media. | 119 } // namespace media. |
115 | 120 |
116 #endif // MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_ | 121 #endif // MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_ |
OLD | NEW |