pub struct MidiSender { /* private fields */ }Expand description
One render thread’s end of the output queue.
Held in that thread’s
RenderState, taken from
MidiOutput::take_sender. Not Clone: one sender is one
writer, and that is what the queue behind it relies on.
Implementations§
Source§impl MidiSender
impl MidiSender
Sourcepub fn send(
&mut self,
context: &impl CallbackContext,
message: MidiMessage,
) -> Result<(), Error>
pub fn send( &mut self, context: &impl CallbackContext, message: MidiMessage, ) -> Result<(), Error>
Queues message and asks for the queue to be emptied.
Real-time safe, and the whole of what render does: one store
into a ring, one index update, and a schedule — the same one
AuxiliaryTask::schedule documents. Bela’s pipe is written on
the task’s thread, not here.
Not the same call as MidiOutput::send, which shares its
name and little else: that one writes to Bela’s pipe itself and
waits for the drain, and belongs in setup or cleanup. This
one is the one a render callback may make.
The context is the callback this is being sent from, as
AuxiliaryTask::schedule requires.
§When it leaves
With the next drain, which the schedule here asks for. A
request that arrives while the drain is running is dropped
rather than queued — that is
AuxiliaryTask::schedule’s
documented behaviour — so the drain looks again before it
finishes, and only stops when the queues are empty.
What is left is the few instructions between that last look and
the callback returning. A message queued there waits for the
next send to schedule a drain. A program that sends
continuously never notices; one that sends a note off and then
nothing can, which is the case to know about.
§Errors
Error::MidiQueueFull when this thread has already queued
MidiOutput::capacity messages that have not been drained.
The message is not queued, and nothing later is affected: the
next drain empties what is there and the next send succeeds.
It says the program outran the budget it declared, and nothing
about the device — see MidiOutput.