OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_MIDI_DYNAMICALLY_INITIALIZED_MIDI_MANAGER_WIN_H_ | 5 #ifndef MEDIA_MIDI_MIDI_MANAGER_WIN_H_ |
6 #define MEDIA_MIDI_DYNAMICALLY_INITIALIZED_MIDI_MANAGER_WIN_H_ | 6 #define MEDIA_MIDI_MIDI_MANAGER_WIN_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/system_monitor/system_monitor.h" | 14 #include "base/system_monitor/system_monitor.h" |
15 #include "media/midi/midi_manager.h" | 15 #include "media/midi/midi_manager.h" |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class SingleThreadTaskRunner; | 18 class SingleThreadTaskRunner; |
19 class TimeDelta; | 19 class TimeDelta; |
20 } // namespace base | 20 } // namespace base |
21 | 21 |
22 namespace midi { | 22 namespace midi { |
23 | 23 |
24 // New backend for legacy Windows that support dynamic instantiation. | 24 // New backend for legacy Windows that support dynamic instantiation. |
25 class DynamicallyInitializedMidiManagerWin final | 25 class MidiManagerWin final |
26 : public MidiManager, | 26 : public MidiManager, |
27 public base::SystemMonitor::DevicesChangedObserver { | 27 public base::SystemMonitor::DevicesChangedObserver { |
28 public: | 28 public: |
29 class PortManager; | 29 class PortManager; |
30 | 30 |
31 explicit DynamicallyInitializedMidiManagerWin(MidiService* service); | 31 explicit MidiManagerWin(MidiService* service); |
32 ~DynamicallyInitializedMidiManagerWin() override; | 32 ~MidiManagerWin() override; |
33 | 33 |
34 // Returns PortManager that implements interfaces to help implementation. | 34 // Returns PortManager that implements interfaces to help implementation. |
35 // This hides Windows specific structures, i.e. HMIDIIN in the header. | 35 // This hides Windows specific structures, i.e. HMIDIIN in the header. |
36 PortManager* port_manager() { return port_manager_.get(); } | 36 PortManager* port_manager() { return port_manager_.get(); } |
37 | 37 |
38 // MidiManager overrides: | 38 // MidiManager overrides: |
39 void StartInitialization() override; | 39 void StartInitialization() override; |
40 void Finalize() override; | 40 void Finalize() override; |
41 void DispatchSendMidiData(MidiManagerClient* client, | 41 void DispatchSendMidiData(MidiManagerClient* client, |
42 uint32_t port_index, | 42 uint32_t port_index, |
(...skipping 24 matching lines...) Expand all Loading... |
67 | 67 |
68 // Initializes instance asynchronously on TaskRunner. | 68 // Initializes instance asynchronously on TaskRunner. |
69 void InitializeOnTaskRunner(); | 69 void InitializeOnTaskRunner(); |
70 | 70 |
71 // Updates device lists on TaskRunner. | 71 // Updates device lists on TaskRunner. |
72 // Returns true if device lists were changed. | 72 // Returns true if device lists were changed. |
73 void UpdateDeviceListOnTaskRunner(); | 73 void UpdateDeviceListOnTaskRunner(); |
74 | 74 |
75 // Reflect active port list to a device list. | 75 // Reflect active port list to a device list. |
76 template <typename T> | 76 template <typename T> |
77 void ReflectActiveDeviceList(DynamicallyInitializedMidiManagerWin* manager, | 77 void ReflectActiveDeviceList(MidiManagerWin* manager, |
78 std::vector<T>* known_ports, | 78 std::vector<T>* known_ports, |
79 std::vector<T>* active_ports); | 79 std::vector<T>* active_ports); |
80 | 80 |
81 // Sends MIDI data on TaskRunner. | 81 // Sends MIDI data on TaskRunner. |
82 void SendOnTaskRunner(MidiManagerClient* client, | 82 void SendOnTaskRunner(MidiManagerClient* client, |
83 uint32_t port_index, | 83 uint32_t port_index, |
84 const std::vector<uint8_t>& data); | 84 const std::vector<uint8_t>& data); |
85 | 85 |
86 // Holds an unique instance ID. | 86 // Holds an unique instance ID. |
87 const int instance_id_; | 87 const int instance_id_; |
88 | 88 |
89 // Keeps a TaskRunner for the I/O thread. | 89 // Keeps a TaskRunner for the I/O thread. |
90 scoped_refptr<base::SingleThreadTaskRunner> thread_runner_; | 90 scoped_refptr<base::SingleThreadTaskRunner> thread_runner_; |
91 | 91 |
92 // Manages platform dependent implementation for port managegent. Should be | 92 // Manages platform dependent implementation for port managegent. Should be |
93 // accessed with the task lock. | 93 // accessed with the task lock. |
94 std::unique_ptr<PortManager> port_manager_; | 94 std::unique_ptr<PortManager> port_manager_; |
95 | 95 |
96 DISALLOW_COPY_AND_ASSIGN(DynamicallyInitializedMidiManagerWin); | 96 DISALLOW_COPY_AND_ASSIGN(MidiManagerWin); |
97 }; | 97 }; |
98 | 98 |
99 } // namespace midi | 99 } // namespace midi |
100 | 100 |
101 #endif // MEDIA_MIDI_DYNAMICALLY_INITIALIZED_MIDI_MANAGER_WIN_H_ | 101 #endif // MEDIA_MIDI_MIDI_MANAGER_WIN_H_ |
OLD | NEW |