blob: 3148cbe5aea9665881139dc819dda2a74b789db2 [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library fuchsia.hardware.midi;
using zx;
/// Describes what type of MIDI device an implementation of Device represents
type Info = struct {
/// Whether or not this device is a MIDI sink
is_sink bool;
/// Whether or not this device is a MIDI source
is_source bool;
};
const READ_SIZE uint32 = 3;
closed protocol Device {
/// Get information about the type of MIDI device
strict GetInfo() -> (struct {
info Info;
});
/// Reads data from the midi device. Only applicable if GetInfo returns
/// is_source.
strict Read() -> (struct {
event vector<uint8>:READ_SIZE;
}) error zx.Status;
/// Writes data to the midi device. Only applicable if GetInfo returns
/// is_sink.
strict Write(struct {
data vector<uint8>:MAX;
}) -> () error zx.Status;
};
closed protocol Controller {
/// Opens a new session on the device.
///
/// At most one session is permitted at one time; the server end will be
/// closed with `ZX_ERR_ALREADY_BOUND` if a session already exists.
strict OpenSession(resource struct {
session server_end:Device;
});
};