OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_H_ | 5 #ifndef MEDIA_MIDI_MIDI_MANAGER_H_ |
6 #define MEDIA_MIDI_MIDI_MANAGER_H_ | 6 #define MEDIA_MIDI_MIDI_MANAGER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 // This happens as a result of the client having previously called | 66 // This happens as a result of the client having previously called |
67 // MidiManager::DispatchSendMidiData(). | 67 // MidiManager::DispatchSendMidiData(). |
68 virtual void AccumulateMidiBytesSent(size_t n) = 0; | 68 virtual void AccumulateMidiBytesSent(size_t n) = 0; |
69 | 69 |
70 // Detach() is called when MidiManager is going to shutdown immediately. | 70 // Detach() is called when MidiManager is going to shutdown immediately. |
71 // Client should not touch MidiManager instance after Detach() is called. | 71 // Client should not touch MidiManager instance after Detach() is called. |
72 virtual void Detach() = 0; | 72 virtual void Detach() = 0; |
73 }; | 73 }; |
74 | 74 |
75 // Manages access to all MIDI hardware. | 75 // Manages access to all MIDI hardware. |
| 76 // *** Note ***: If dynamic instantiation feature is enabled, all MidiManager |
| 77 // methods will be called on Chrome_IOThread. See comments on Shutdown() too. |
76 class MIDI_EXPORT MidiManager { | 78 class MIDI_EXPORT MidiManager { |
77 public: | 79 public: |
78 static const size_t kMaxPendingClientCount = 128; | 80 static const size_t kMaxPendingClientCount = 128; |
79 | 81 |
80 MidiManager(); | 82 MidiManager(); |
81 virtual ~MidiManager(); | 83 virtual ~MidiManager(); |
82 | 84 |
83 // The constructor and the destructor will be called on the CrBrowserMain | 85 // The constructor and the destructor will be called on the CrBrowserMain |
84 // thread. | 86 // thread. |
85 static MidiManager* Create(); | 87 static MidiManager* Create(); |
86 | 88 |
87 // Called on the CrBrowserMain thread to notify the Chrome_IOThread will stop | 89 // Called on the CrBrowserMain thread to notify the Chrome_IOThread will stop |
88 // and the instance will be destructed on the CrBrowserMain thread soon. | 90 // and the instance will be destructed on the CrBrowserMain thread soon. |
| 91 // *** Note ***: If dynamic instantiation feature is enabled, MidiService call |
| 92 // this on Chrome_IOThread and ShutdownOnSessionThread() will be called |
| 93 // synchronously so that MidiService can destruct MidiManager synchronously. |
89 void Shutdown(); | 94 void Shutdown(); |
90 | 95 |
91 // A client calls StartSession() to receive and send MIDI data. | 96 // A client calls StartSession() to receive and send MIDI data. |
92 // If the session is ready to start, the MIDI system is lazily initialized | 97 // If the session is ready to start, the MIDI system is lazily initialized |
93 // and the client is registered to receive MIDI data. | 98 // and the client is registered to receive MIDI data. |
94 // CompleteStartSession() is called with mojom::Result::OK if the session is | 99 // CompleteStartSession() is called with mojom::Result::OK if the session is |
95 // started. Otherwise CompleteStartSession() is called with a proper | 100 // started. Otherwise CompleteStartSession() is called with a proper |
96 // mojom::Result code. | 101 // mojom::Result code. |
97 // StartSession() and EndSession() can be called on the Chrome_IOThread. | 102 // StartSession() and EndSession() can be called on the Chrome_IOThread. |
98 // CompleteStartSession() will be invoked on the same Chrome_IOThread. | 103 // CompleteStartSession() will be invoked on the same Chrome_IOThread. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 // |session_thread_runner_|, |initialization_state_|, |finalize_|, |result_|, | 220 // |session_thread_runner_|, |initialization_state_|, |finalize_|, |result_|, |
216 // |input_ports_| and |output_ports_|. | 221 // |input_ports_| and |output_ports_|. |
217 base::Lock lock_; | 222 base::Lock lock_; |
218 | 223 |
219 DISALLOW_COPY_AND_ASSIGN(MidiManager); | 224 DISALLOW_COPY_AND_ASSIGN(MidiManager); |
220 }; | 225 }; |
221 | 226 |
222 } // namespace midi | 227 } // namespace midi |
223 | 228 |
224 #endif // MEDIA_MIDI_MIDI_MANAGER_H_ | 229 #endif // MEDIA_MIDI_MIDI_MANAGER_H_ |
OLD | NEW |