Chromium Code Reviews| 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_MANAGER_WINRT_H_ | |
| 6 #define MEDIA_MIDI_MIDI_MANAGER_WINRT_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "base/threading/thread.h" | |
| 11 #include "base/threading/thread_checker.h" | |
| 12 #include "media/midi/midi_manager.h" | |
| 13 #include "media/midi/midi_scheduler.h" | |
| 14 | |
| 15 namespace media { | |
| 16 namespace midi { | |
| 17 | |
| 18 class MIDI_EXPORT MidiManagerWinrt final : public MidiManager { | |
| 19 public: | |
| 20 MidiManagerWinrt(); | |
| 21 ~MidiManagerWinrt() override; | |
| 22 | |
| 23 // MidiManager overrides: | |
| 24 void StartInitialization() final; | |
| 25 void Finalize() final; | |
| 26 void DispatchSendMidiData(MidiManagerClient* client, | |
| 27 uint32_t port_index, | |
| 28 const std::vector<uint8_t>& data, | |
| 29 double timestamp) final; | |
| 30 | |
| 31 // Callback from MidiPortManager::OnEnumerationComplete on the COM thread. | |
| 32 // Sets |is_initialized_| and calls CompleteInitialization() when both | |
|
Shao-Chuan Lee
2016/08/23 04:33:29
|is_initialized_| is already removed, fix comments
| |
| 33 // MidiPortManagers are ready. | |
| 34 void OnPortManagerReady(); | |
| 35 | |
| 36 private: | |
| 37 // Callbacks on the COM thread. | |
| 38 void InitializeOnComThread(); | |
| 39 void FinalizeOnComThread(); | |
| 40 void SendOnComThread(uint32_t port_index, const std::vector<uint8_t>& data); | |
| 41 | |
| 42 // Subclasses that access protected members of MidiManager. | |
| 43 class MidiInPortManager; | |
| 44 class MidiOutPortManager; | |
| 45 | |
| 46 // COM-initialized thread for calling WinRT methods. | |
| 47 base::Thread com_thread_; | |
| 48 | |
| 49 // Should be instantiated on COM thread. | |
| 50 std::unique_ptr<base::ThreadChecker> com_thread_checker_; | |
| 51 | |
| 52 // All operations to MidiPortManager should be done on COM thread. | |
| 53 std::unique_ptr<MidiInPortManager> port_manager_in_; | |
| 54 std::unique_ptr<MidiOutPortManager> port_manager_out_; | |
| 55 | |
| 56 // |scheduler_| is constructed/destructed on COM thread and used by | |
| 57 // DispatchSendMidiData on Chrome_IOThread, a lock is required. | |
| 58 base::Lock scheduler_lock_; | |
| 59 std::unique_ptr<MidiScheduler> scheduler_; // GUARDED_BY(scheduler_lock_) | |
| 60 | |
| 61 // Incremented when a MidiPortManager is ready. | |
| 62 uint8_t port_manager_ready_count_ = 0; | |
| 63 | |
| 64 DISALLOW_COPY_AND_ASSIGN(MidiManagerWinrt); | |
| 65 }; | |
| 66 | |
| 67 } // namespace midi | |
| 68 } // namespace media | |
| 69 | |
| 70 #endif // MEDIA_MIDI_MIDI_MANAGER_WINRT_H_ | |
| OLD | NEW |