ScummVM API documentation
WindowsMusicPlugin Class Reference

#include <winmm.h>

Inheritance diagram for WindowsMusicPlugin:
MusicPluginObject PluginObject

Public Types

typedef bool(* MidiWarmUpWaitCallback) (const Common::Functor0< bool > &isComplete)
 

Public Member Functions

const char * getName () const override
 
const char * getId () const override
 
MusicDevices getDevices () const override
 
Common::Error createInstance (MidiDriver **mididriver, MidiDriver::DeviceHandle dev=0) const override
 
bool checkDevice (MidiDriver::DeviceHandle hdl, int checkFlags, bool quiet) const override
 
virtual const char * getId () const =0
 
virtual MusicDevices getDevices () const =0
 
virtual bool checkDevice (MidiDriver::DeviceHandle hdl, int checkFlags, bool quiet) const
 
virtual Common::Error createInstance (MidiDriver **mididriver, MidiDriver::DeviceHandle=0) const =0
 
virtual const char * getName () const =0
 

Static Public Member Functions

static void startMidiWarmUpThread ()
 
static void cleanupMidiWarmUpThread ()
 
static void setMidiWarmUpWaitCallback (MidiWarmUpWaitCallback callback)
 

Detailed Description

Enumerate WinMM devices and create Windows MIDI drivers.

Member Typedef Documentation

◆ MidiWarmUpWaitCallback

typedef bool(* WindowsMusicPlugin::MidiWarmUpWaitCallback) (const Common::Functor0< bool > &isComplete)

Wait for background MIDI warm-up through a modal dialog when the GUI is active. A modal dialog will handle UI events, keeping the process responsive.

Parameters
isCompleteA functor immediately returns whether the warm-up has been finished.
Returns
True if completion was observed. False if the wait was skipped because the GUI was unavailable or inactive, or if the dialog closed before completion (e.g. on quit or return to launcher).
See also
setMidiWarmUpWaitCallback()

Member Function Documentation

◆ getName()

const char * WindowsMusicPlugin::getName ( ) const
overridevirtual

Returns the name of the plugin.

Implements PluginObject.

◆ getId()

const char * WindowsMusicPlugin::getId ( ) const
overridevirtual

Returns a unique string identifier which will be used to save the selected MIDI driver to the config file.

Implements MusicPluginObject.

◆ getDevices()

MusicDevices WindowsMusicPlugin::getDevices ( ) const
overridevirtual

Enumerate available MIDI devices with WinMM.

Implements MusicPluginObject.

◆ createInstance()

Common::Error WindowsMusicPlugin::createInstance ( MidiDriver **  mididriver,
MidiDriver::DeviceHandle  dev = 0 
) const
overridevirtual

Create a driver for the selected device, or the default device when no match exists.

Implements MusicPluginObject.

◆ checkDevice()

bool WindowsMusicPlugin::checkDevice ( MidiDriver::DeviceHandle  hdl,
int  checkFlags,
bool  quiet 
) const
overridevirtual

Checks whether a device can actually be used. Always return trues on Windows MIDI backend.

Reimplemented from MusicPluginObject.

◆ startMidiWarmUpThread()

static void WindowsMusicPlugin::startMidiWarmUpThread ( )
static

Start background WinMM warm-up thread.

Must be called on backend init after SDL audio init. Windows MIDI Services init can block concurrent MME audo init, one of the possible audio backend on Windows.

See also
https://github.com/microsoft/MIDI/issues/1076

◆ cleanupMidiWarmUpThread()

static void WindowsMusicPlugin::cleanupMidiWarmUpThread ( )
static

Clear the warm-up thread result and resources.

Should only be called on platform teardown.

◆ setMidiWarmUpWaitCallback()

static void WindowsMusicPlugin::setMidiWarmUpWaitCallback ( MidiWarmUpWaitCallback  callback)
static

Register the function that displays progress dialog while MIDI warm-up is running. The main purpose of that dialog is to prevent UI thread hang by first WinMM API call.

WinMM APIs may be called while the warm-up thread is still running. In that case, the plugin invokes this callback on the UI thread to spawn the dialog. The dialog polls isComplete while processing UI events.

The Windows backend registers GUI::MidiDeviceScanDialog::waitForCompletion() as a callback.

Parameters
callbackFunction that spawns a progress dialog.
See also
MidiWarmUpWaitCallback

The documentation for this class was generated from the following file: