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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 24 matching lines...) Expand all Loading... | |
35 int total_segments); | 35 int total_segments); |
36 | 36 |
37 // One time initialization for the callback object on the audio thread. | 37 // One time initialization for the callback object on the audio thread. |
38 void InitializeOnAudioThread(); | 38 void InitializeOnAudioThread(); |
39 | 39 |
40 // Derived implementations must call shared_memory_.Map appropriately | 40 // Derived implementations must call shared_memory_.Map appropriately |
41 // before Process can be called. | 41 // before Process can be called. |
42 virtual void MapSharedMemory() = 0; | 42 virtual void MapSharedMemory() = 0; |
43 | 43 |
44 // Called whenever we receive notifications about pending input data. | 44 // Called whenever we receive notifications about pending input data. |
45 virtual void Process(uint32_t pending_data) = 0; | 45 virtual void Process(int64_t pending_data, |
chcunningham
2016/10/21 18:19:47
Can you use a TimeDelta in this signature (and cal
Mikhail
2016/10/24 19:50:24
The reason for the current naming is that AudioInp
| |
46 base::TimeTicks data_timestamp) = 0; | |
46 | 47 |
47 protected: | 48 protected: |
48 virtual ~Callback(); | 49 virtual ~Callback(); |
49 | 50 |
50 // Protected so that derived classes can access directly. | 51 // Protected so that derived classes can access directly. |
51 // The variables are 'const' since values are calculated/set in the | 52 // The variables are 'const' since values are calculated/set in the |
52 // constructor and must never change. | 53 // constructor and must never change. |
53 const AudioParameters audio_parameters_; | 54 const AudioParameters audio_parameters_; |
54 | 55 |
55 base::SharedMemory shared_memory_; | 56 base::SharedMemory shared_memory_; |
(...skipping 12 matching lines...) Expand all Loading... | |
68 | 69 |
69 // Creates and automatically starts the audio thread. | 70 // Creates and automatically starts the audio thread. |
70 AudioDeviceThread(Callback* callback, | 71 AudioDeviceThread(Callback* callback, |
71 base::SyncSocket::Handle socket, | 72 base::SyncSocket::Handle socket, |
72 const char* thread_name); | 73 const char* thread_name); |
73 | 74 |
74 // This tells the audio thread to stop and clean up the data; this is a | 75 // This tells the audio thread to stop and clean up the data; this is a |
75 // synchronous process and the thread will stop before the method returns. | 76 // synchronous process and the thread will stop before the method returns. |
76 ~AudioDeviceThread() override; | 77 ~AudioDeviceThread() override; |
77 | 78 |
79 // Represents a data packet to be received via the socket. | |
80 struct Packet { | |
81 int64_t pending_data; | |
chcunningham
2016/10/21 18:19:47
Can you name these like you do browser side?
del
Mikhail
2016/10/24 19:50:24
Same motivation as in the comment above.
| |
82 int64_t data_timestamp_us; | |
83 }; | |
84 | |
78 private: | 85 private: |
79 void ThreadMain() final; | 86 void ThreadMain() final; |
80 | 87 |
81 Callback* const callback_; | 88 Callback* const callback_; |
82 const char* thread_name_; | 89 const char* thread_name_; |
83 base::CancelableSyncSocket socket_; | 90 base::CancelableSyncSocket socket_; |
84 base::PlatformThreadHandle thread_handle_; | 91 base::PlatformThreadHandle thread_handle_; |
85 | 92 |
86 DISALLOW_COPY_AND_ASSIGN(AudioDeviceThread); | 93 DISALLOW_COPY_AND_ASSIGN(AudioDeviceThread); |
87 }; | 94 }; |
88 | 95 |
89 } // namespace media. | 96 } // namespace media. |
90 | 97 |
91 #endif // MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_ | 98 #endif // MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_ |
OLD | NEW |