OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_MIDI_MANAGER_USB_H_ | 5 #ifndef MEDIA_MIDI_MIDI_MANAGER_USB_H_ |
6 #define MEDIA_MIDI_MIDI_MANAGER_USB_H_ | 6 #define MEDIA_MIDI_MIDI_MANAGER_USB_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 base::TimeTicks time) override; | 57 base::TimeTicks time) override; |
58 void OnDeviceAttached(std::unique_ptr<UsbMidiDevice> device) override; | 58 void OnDeviceAttached(std::unique_ptr<UsbMidiDevice> device) override; |
59 void OnDeviceDetached(size_t index) override; | 59 void OnDeviceDetached(size_t index) override; |
60 | 60 |
61 // UsbMidiInputStream::Delegate implementation. | 61 // UsbMidiInputStream::Delegate implementation. |
62 void OnReceivedData(size_t jack_index, | 62 void OnReceivedData(size_t jack_index, |
63 const uint8_t* data, | 63 const uint8_t* data, |
64 size_t size, | 64 size_t size, |
65 base::TimeTicks time) override; | 65 base::TimeTicks time) override; |
66 | 66 |
67 const ScopedVector<UsbMidiOutputStream>& output_streams() const { | 67 const std::vector<std::unique_ptr<UsbMidiOutputStream>>& output_streams() |
| 68 const { |
68 return output_streams_; | 69 return output_streams_; |
69 } | 70 } |
70 const UsbMidiInputStream* input_stream() const { return input_stream_.get(); } | 71 const UsbMidiInputStream* input_stream() const { return input_stream_.get(); } |
71 | 72 |
72 // Initializes this object. | 73 // Initializes this object. |
73 // When the initialization finishes, |callback| will be called with the | 74 // When the initialization finishes, |callback| will be called with the |
74 // result. | 75 // result. |
75 // When this factory is destroyed during the operation, the operation | 76 // When this factory is destroyed during the operation, the operation |
76 // will be canceled silently (i.e. |callback| will not be called). | 77 // will be canceled silently (i.e. |callback| will not be called). |
77 // The function is public just for unit tests. Do not call this function | 78 // The function is public just for unit tests. Do not call this function |
78 // outside code for testing. | 79 // outside code for testing. |
79 void Initialize(base::Callback<void(mojom::Result result)> callback); | 80 void Initialize(base::Callback<void(mojom::Result result)> callback); |
80 | 81 |
81 private: | 82 private: |
82 void OnEnumerateDevicesDone(bool result, UsbMidiDevice::Devices* devices); | 83 void OnEnumerateDevicesDone(bool result, UsbMidiDevice::Devices* devices); |
83 bool AddPorts(UsbMidiDevice* device, int device_id); | 84 bool AddPorts(UsbMidiDevice* device, int device_id); |
84 | 85 |
85 std::unique_ptr<UsbMidiDevice::Factory> device_factory_; | 86 std::unique_ptr<UsbMidiDevice::Factory> device_factory_; |
86 ScopedVector<UsbMidiDevice> devices_; | 87 std::vector<std::unique_ptr<UsbMidiDevice>> devices_; |
87 ScopedVector<UsbMidiOutputStream> output_streams_; | 88 std::vector<std::unique_ptr<UsbMidiOutputStream>> output_streams_; |
88 std::unique_ptr<UsbMidiInputStream> input_stream_; | 89 std::unique_ptr<UsbMidiInputStream> input_stream_; |
89 | 90 |
90 base::Callback<void(mojom::Result result)> initialize_callback_; | 91 base::Callback<void(mojom::Result result)> initialize_callback_; |
91 | 92 |
92 // A map from <endpoint_number, cable_number> to the index of input jacks. | 93 // A map from <endpoint_number, cable_number> to the index of input jacks. |
93 base::hash_map<std::pair<int, int>, size_t> input_jack_dictionary_; | 94 base::hash_map<std::pair<int, int>, size_t> input_jack_dictionary_; |
94 | 95 |
95 // Lock to ensure the MidiScheduler is being destructed only once in | 96 // Lock to ensure the MidiScheduler is being destructed only once in |
96 // Finalize() on Chrome_IOThread. | 97 // Finalize() on Chrome_IOThread. |
97 base::Lock scheduler_lock_; | 98 base::Lock scheduler_lock_; |
98 std::unique_ptr<MidiScheduler> scheduler_; | 99 std::unique_ptr<MidiScheduler> scheduler_; |
99 | 100 |
100 DISALLOW_COPY_AND_ASSIGN(MidiManagerUsb); | 101 DISALLOW_COPY_AND_ASSIGN(MidiManagerUsb); |
101 }; | 102 }; |
102 | 103 |
103 } // namespace midi | 104 } // namespace midi |
104 | 105 |
105 #endif // MEDIA_MIDI_MIDI_MANAGER_USB_H_ | 106 #endif // MEDIA_MIDI_MIDI_MANAGER_USB_H_ |
OLD | NEW |