Commit bf502e36 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

winecoreaudio: Move midi_out_close to the unixlib.

parent ec9d2a77
...@@ -49,7 +49,6 @@ ...@@ -49,7 +49,6 @@
#include "wine/debug.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(wave); WINE_DEFAULT_DEBUG_CHANNEL(wave);
WINE_DECLARE_DEBUG_CHANNEL(midi);
int AudioUnit_SetVolume(AudioUnit au, float left, float right) int AudioUnit_SetVolume(AudioUnit au, float left, float right)
{ {
...@@ -85,28 +84,6 @@ int AudioUnit_GetVolume(AudioUnit au, float *left, float *right) ...@@ -85,28 +84,6 @@ int AudioUnit_GetVolume(AudioUnit au, float *left, float *right)
return 1; return 1;
} }
int SynthUnit_Close(AUGraph graph)
{
OSStatus err = noErr;
err = AUGraphStop(graph);
if (err != noErr)
{
ERR_(midi)("AUGraphStop(%p) return %s\n", graph, wine_dbgstr_fourcc(err));
return 0;
}
err = DisposeAUGraph(graph);
if (err != noErr)
{
ERR_(midi)("DisposeAUGraph(%p) return %s\n", graph, wine_dbgstr_fourcc(err));
return 0;
}
return 1;
}
void MIDIOut_Send(MIDIPortRef port, MIDIEndpointRef dest, UInt8 *buffer, unsigned length) void MIDIOut_Send(MIDIPortRef port, MIDIEndpointRef dest, UInt8 *buffer, unsigned length)
{ {
Byte packetBuff[512]; Byte packetBuff[512];
......
...@@ -356,6 +356,27 @@ static BOOL synth_unit_init(AudioUnit synth, AUGraph graph) ...@@ -356,6 +356,27 @@ static BOOL synth_unit_init(AudioUnit synth, AUGraph graph)
return TRUE; return TRUE;
} }
static BOOL synth_unit_close(AUGraph graph)
{
OSStatus sc;
sc = AUGraphStop(graph);
if (sc != noErr)
{
ERR("AUGraphStop(%p) returns %s\n", graph, wine_dbgstr_fourcc(sc));
return FALSE;
}
sc = DisposeAUGraph(graph);
if (sc != noErr)
{
ERR("DisposeAUGraph(%p) returns %s\n", graph, wine_dbgstr_fourcc(sc));
return FALSE;
}
return TRUE;
}
static void set_out_notify(struct notify_context *notify, struct midi_dest *dest, WORD dev_id, WORD msg, static void set_out_notify(struct notify_context *notify, struct midi_dest *dest, WORD dev_id, WORD msg,
DWORD_PTR param_1, DWORD_PTR param_2) DWORD_PTR param_1, DWORD_PTR param_2)
{ {
...@@ -416,6 +437,32 @@ static DWORD midi_out_open(WORD dev_id, MIDIOPENDESC *midi_desc, DWORD flags, st ...@@ -416,6 +437,32 @@ static DWORD midi_out_open(WORD dev_id, MIDIOPENDESC *midi_desc, DWORD flags, st
return MMSYSERR_NOERROR; return MMSYSERR_NOERROR;
} }
static DWORD midi_out_close(WORD dev_id, struct notify_context *notify)
{
struct midi_dest *dest;
TRACE("dev_id = %d\n", dev_id);
if (dev_id >= num_dests)
{
WARN("bad device ID : %d\n", dev_id);
return MMSYSERR_BADDEVICEID;
}
dest = dests + dev_id;
if (dest->caps.wTechnology == MOD_SYNTH)
synth_unit_close(dest->graph);
dest->graph = 0;
dest->synth = 0;
set_out_notify(notify, dest, dev_id, MOM_CLOSE, 0, 0);
dest->midiDesc.hMidi = 0;
return MMSYSERR_NOERROR;
}
NTSTATUS midi_out_message(void *args) NTSTATUS midi_out_message(void *args)
{ {
struct midi_out_message_params *params = args; struct midi_out_message_params *params = args;
...@@ -433,6 +480,9 @@ NTSTATUS midi_out_message(void *args) ...@@ -433,6 +480,9 @@ NTSTATUS midi_out_message(void *args)
case MODM_OPEN: case MODM_OPEN:
*params->err = midi_out_open(params->dev_id, (MIDIOPENDESC *)params->param_1, params->param_2, params->notify); *params->err = midi_out_open(params->dev_id, (MIDIOPENDESC *)params->param_1, params->param_2, params->notify);
break; break;
case MODM_CLOSE:
*params->err = midi_out_close(params->dev_id, params->notify);
break;
default: default:
TRACE("Unsupported message\n"); TRACE("Unsupported message\n");
*params->err = MMSYSERR_NOTSUPPORTED; *params->err = MMSYSERR_NOTSUPPORTED;
......
...@@ -64,8 +64,6 @@ static MIDIPortRef MIDIOutPort = NULL; ...@@ -64,8 +64,6 @@ static MIDIPortRef MIDIOutPort = NULL;
MIDIDestination *destinations; MIDIDestination *destinations;
MIDISource *sources; MIDISource *sources;
extern int SynthUnit_Close(AUGraph graph);
static void notify_client(struct notify_context *notify) static void notify_client(struct notify_context *notify)
{ {
TRACE("dev_id=%d msg=%d param1=%04lX param2=%04lX\n", notify->dev_id, notify->msg, notify->param_1, notify->param_2); TRACE("dev_id=%d msg=%d param1=%04lX param2=%04lX\n", notify->dev_id, notify->msg, notify->param_1, notify->param_2);
...@@ -137,7 +135,6 @@ static void MIDI_NotifyClient(UINT wDevID, WORD wMsg, DWORD_PTR dwParam1, DWORD_ ...@@ -137,7 +135,6 @@ static void MIDI_NotifyClient(UINT wDevID, WORD wMsg, DWORD_PTR dwParam1, DWORD_
TRACE("wDevID=%d wMsg=%d dwParm1=%04lX dwParam2=%04lX\n", wDevID, wMsg, dwParam1, dwParam2); TRACE("wDevID=%d wMsg=%d dwParm1=%04lX dwParam2=%04lX\n", wDevID, wMsg, dwParam1, dwParam2);
switch (wMsg) { switch (wMsg) {
case MOM_CLOSE:
case MOM_DONE: case MOM_DONE:
case MOM_POSITIONCB: case MOM_POSITIONCB:
dwCallBack = destinations[wDevID].midiDesc.dwCallback; dwCallBack = destinations[wDevID].midiDesc.dwCallback;
...@@ -166,29 +163,6 @@ static void MIDI_NotifyClient(UINT wDevID, WORD wMsg, DWORD_PTR dwParam1, DWORD_ ...@@ -166,29 +163,6 @@ static void MIDI_NotifyClient(UINT wDevID, WORD wMsg, DWORD_PTR dwParam1, DWORD_
DriverCallback(dwCallBack, uFlags, hDev, wMsg, dwInstance, dwParam1, dwParam2); DriverCallback(dwCallBack, uFlags, hDev, wMsg, dwInstance, dwParam1, dwParam2);
} }
static DWORD MIDIOut_Close(WORD wDevID)
{
DWORD ret = MMSYSERR_NOERROR;
TRACE("wDevID=%d\n", wDevID);
if (wDevID >= MIDIOut_NumDevs) {
WARN("bad device ID : %d\n", wDevID);
return MMSYSERR_BADDEVICEID;
}
if (destinations[wDevID].caps.wTechnology == MOD_SYNTH)
SynthUnit_Close(destinations[wDevID].graph);
destinations[wDevID].graph = 0;
destinations[wDevID].synth = 0;
MIDI_NotifyClient(wDevID, MOM_CLOSE, 0L, 0L);
destinations[wDevID].midiDesc.hMidi = 0;
return ret;
}
static DWORD MIDIOut_Data(WORD wDevID, DWORD dwParam) static DWORD MIDIOut_Data(WORD wDevID, DWORD dwParam)
{ {
WORD evt = LOBYTE(LOWORD(dwParam)); WORD evt = LOBYTE(LOWORD(dwParam));
...@@ -789,8 +763,6 @@ DWORD WINAPI CoreAudio_modMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser, DWOR ...@@ -789,8 +763,6 @@ DWORD WINAPI CoreAudio_modMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser, DWOR
TRACE("%d %08x %08lx %08lx %08lx\n", wDevID, wMsg, dwUser, dwParam1, dwParam2); TRACE("%d %08x %08lx %08lx %08lx\n", wDevID, wMsg, dwUser, dwParam1, dwParam2);
switch (wMsg) { switch (wMsg) {
case MODM_CLOSE:
return MIDIOut_Close(wDevID);
case MODM_DATA: case MODM_DATA:
return MIDIOut_Data(wDevID, dwParam1); return MIDIOut_Data(wDevID, dwParam1);
case MODM_LONGDATA: case MODM_LONGDATA:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment