| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MEDIA_MIDI_MIDI_SERVICE_H_ |
| 6 #define MEDIA_MIDI_MIDI_SERVICE_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 #include <memory> |
| 11 #include <vector> |
| 12 |
| 13 #include "base/macros.h" |
| 14 #include "base/synchronization/lock.h" |
| 15 #include "media/midi/midi_export.h" |
| 16 #include "media/midi/midi_manager.h" |
| 17 |
| 18 namespace midi { |
| 19 |
| 20 // Manages MidiManager backends. This class expects to be constructed and |
| 21 // destructed on the browser main thread, but methods can be called on both |
| 22 // the main thread and the I/O thread. |
| 23 class MIDI_EXPORT MidiService final { |
| 24 public: |
| 25 // |MidiManager| can be explicitly specified in the constructor for testing. |
| 26 explicit MidiService(std::unique_ptr<MidiManager> manager = nullptr); |
| 27 ~MidiService(); |
| 28 |
| 29 // Called on the browser main thread to notify the I/O thread will stop and |
| 30 // the instance will be destructed on the main thread soon. |
| 31 void Shutdown(); |
| 32 |
| 33 // A client calls StartSession() to receive and send MIDI data. |
| 34 void StartSession(MidiManagerClient* client); |
| 35 |
| 36 // A client calls EndSession() to stop receiving MIDI data. |
| 37 void EndSession(MidiManagerClient* client); |
| 38 |
| 39 // A client calls DispatchSendMidiData() to send MIDI data. |
| 40 virtual void DispatchSendMidiData(MidiManagerClient* client, |
| 41 uint32_t port_index, |
| 42 const std::vector<uint8_t>& data, |
| 43 double timestamp); |
| 44 |
| 45 std::unique_ptr<MidiManager> manager_; |
| 46 base::Lock lock_; |
| 47 |
| 48 DISALLOW_COPY_AND_ASSIGN(MidiService); |
| 49 }; |
| 50 |
| 51 } // namespace midi |
| 52 |
| 53 #endif // MEDIA_MIDI_MIDI_SERVICE_H_ |
| OLD | NEW |