| 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 <memory> |
| 11 |
| 10 #include "base/macros.h" | 12 #include "base/macros.h" |
| 11 #include "base/memory/shared_memory.h" | 13 #include "base/memory/shared_memory.h" |
| 12 #include "base/sync_socket.h" | 14 #include "base/sync_socket.h" |
| 13 #include "base/threading/platform_thread.h" | |
| 14 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 15 #include "media/base/audio_parameters.h" | 16 #include "media/base/audio_parameters.h" |
| 16 #include "media/base/media_export.h" | 17 #include "media/base/media_export.h" |
| 17 | 18 |
| 19 namespace base { |
| 20 class Thread; |
| 21 } |
| 22 |
| 18 namespace media { | 23 namespace media { |
| 19 | 24 |
| 20 // Data transfer between browser and render process uses a combination | 25 // Data transfer between browser and render process uses a combination |
| 21 // of sync sockets and shared memory. To read from the socket and render | 26 // of sync sockets and shared memory. To read from the socket and render |
| 22 // data, we use a worker thread, a.k.a. the AudioDeviceThread, which reads | 27 // data, we use a worker thread, a.k.a. the AudioDeviceThread, which reads |
| 23 // data from the browser via the socket and fills the shared memory from the | 28 // data from the browser via the socket and fills the shared memory from the |
| 24 // audio thread via the AudioDeviceThread::Callback interface/class. | 29 // audio thread via the AudioDeviceThread::Callback interface/class. |
| 25 class MEDIA_EXPORT AudioDeviceThread : public base::PlatformThread::Delegate { | 30 class MEDIA_EXPORT AudioDeviceThread : public base::PlatformThread::Delegate { |
| 26 public: | 31 public: |
| 27 // This is the callback interface/base class that Audio[Output|Input]Device | 32 // This is the callback interface/base class that Audio[Output|Input]Device |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 const char* thread_name); | 77 const char* thread_name); |
| 73 | 78 |
| 74 // This tells the audio thread to stop and clean up the data; this is a | 79 // 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. | 80 // synchronous process and the thread will stop before the method returns. |
| 76 ~AudioDeviceThread() override; | 81 ~AudioDeviceThread() override; |
| 77 | 82 |
| 78 private: | 83 private: |
| 79 void ThreadMain() final; | 84 void ThreadMain() final; |
| 80 | 85 |
| 81 Callback* const callback_; | 86 Callback* const callback_; |
| 82 const char* thread_name_; | |
| 83 base::CancelableSyncSocket socket_; | 87 base::CancelableSyncSocket socket_; |
| 84 base::PlatformThreadHandle thread_handle_; | 88 std::unique_ptr<base::Thread> thread_; |
| 85 | 89 |
| 86 DISALLOW_COPY_AND_ASSIGN(AudioDeviceThread); | 90 DISALLOW_COPY_AND_ASSIGN(AudioDeviceThread); |
| 87 }; | 91 }; |
| 88 | 92 |
| 89 } // namespace media. | 93 } // namespace media. |
| 90 | 94 |
| 91 #endif // MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_ | 95 #endif // MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_ |
| OLD | NEW |