blob: 8cb562dd7164f805c616e4e2c4de2cb6f8df1c27 [file] [log] [blame]
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include "base/strings/string16.h"
#include "media/midi/midi_manager.h"
namespace midi {
class MidiService;
class MIDI_EXPORT MidiManagerWinrt final : public MidiManager {
class MidiInPortManager;
class MidiOutPortManager;
explicit MidiManagerWinrt(MidiService* service);
~MidiManagerWinrt() override;
// MidiManager overrides:
void StartInitialization() final;
void Finalize() final;
void DispatchSendMidiData(MidiManagerClient* client,
uint32_t port_index,
const std::vector<uint8_t>& data,
double timestamp) final;
// Subclasses that access private/protected members of MidiManager.
template <typename InterfaceType,
typename RuntimeType,
typename StaticsInterfaceType,
base::char16 const* runtime_class_id>
class MidiPortManager;
// Callbacks on kComTaskRunner.
void InitializeOnComRunner();
void SendOnComRunner(uint32_t port_index, const std::vector<uint8_t>& data);
// Callback from MidiPortManager::OnEnumerationComplete on kComTaskRunner.
// Calls CompleteInitialization() when both MidiPortManagers are ready.
void OnPortManagerReady();
// Lock to ensure all smart pointers initialized in InitializeOnComRunner()
// and destroyed in FinalizeOnComRunner() will not be accidentally destructed
// twice in the destructor.
base::Lock lazy_init_member_lock_;
// All operations to Midi{In|Out}PortManager should be done on kComTaskRunner.
port_manager_in_; // GUARDED_BY(lazy_init_member_lock_)
port_manager_out_; // GUARDED_BY(lazy_init_member_lock_)
// Incremented when a MidiPortManager is ready.
uint8_t port_manager_ready_count_ = 0;
} // namespace midi