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(int64_t pending_data, | 45 virtual void Process(uint32_t pending_data) = 0; |
46 base::TimeTicks data_timestamp) = 0; | |
47 | 46 |
48 protected: | 47 protected: |
49 virtual ~Callback(); | 48 virtual ~Callback(); |
50 | 49 |
51 // Protected so that derived classes can access directly. | 50 // Protected so that derived classes can access directly. |
52 // The variables are 'const' since values are calculated/set in the | 51 // The variables are 'const' since values are calculated/set in the |
53 // constructor and must never change. | 52 // constructor and must never change. |
54 const AudioParameters audio_parameters_; | 53 const AudioParameters audio_parameters_; |
55 | 54 |
56 base::SharedMemory shared_memory_; | 55 base::SharedMemory shared_memory_; |
(...skipping 12 matching lines...) Expand all Loading... |
69 | 68 |
70 // Creates and automatically starts the audio thread. | 69 // Creates and automatically starts the audio thread. |
71 AudioDeviceThread(Callback* callback, | 70 AudioDeviceThread(Callback* callback, |
72 base::SyncSocket::Handle socket, | 71 base::SyncSocket::Handle socket, |
73 const char* thread_name); | 72 const char* thread_name); |
74 | 73 |
75 // This tells the audio thread to stop and clean up the data; this is a | 74 // This tells the audio thread to stop and clean up the data; this is a |
76 // synchronous process and the thread will stop before the method returns. | 75 // synchronous process and the thread will stop before the method returns. |
77 ~AudioDeviceThread() override; | 76 ~AudioDeviceThread() override; |
78 | 77 |
79 // Represents a data packet to be received via the socket. | |
80 struct Packet { | |
81 int64_t pending_data; | |
82 int64_t data_timestamp_us; | |
83 }; | |
84 | |
85 private: | 78 private: |
86 void ThreadMain() final; | 79 void ThreadMain() final; |
87 | 80 |
88 Callback* const callback_; | 81 Callback* const callback_; |
89 const char* thread_name_; | 82 const char* thread_name_; |
90 base::CancelableSyncSocket socket_; | 83 base::CancelableSyncSocket socket_; |
91 base::PlatformThreadHandle thread_handle_; | 84 base::PlatformThreadHandle thread_handle_; |
92 | 85 |
93 DISALLOW_COPY_AND_ASSIGN(AudioDeviceThread); | 86 DISALLOW_COPY_AND_ASSIGN(AudioDeviceThread); |
94 }; | 87 }; |
95 | 88 |
96 } // namespace media. | 89 } // namespace media. |
97 | 90 |
98 #endif // MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_ | 91 #endif // MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_ |
OLD | NEW |