winecoreaudio: Move midi_out_[gs]et_volume to the unixlib.
Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Andrew Eikum <aeikum@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
501cbc1944
commit
5df38b4708
|
@ -7,7 +7,6 @@ EXTRALIBS = $(COREAUDIO_LIBS)
|
|||
EXTRADLLFLAGS = -mcygwin
|
||||
|
||||
C_SRCS = \
|
||||
audiounit.c \
|
||||
coreaudio.c \
|
||||
coremidi.c \
|
||||
midi.c \
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
* Wine Driver for CoreAudio / AudioUnit
|
||||
*
|
||||
* Copyright 2005, 2006 Emmanuel Maillard
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define ULONG CoreFoundation_ULONG
|
||||
#define HRESULT CoreFoundation_HRESULT
|
||||
#include <mach/mach_time.h>
|
||||
#include <AudioUnit/AudioUnit.h>
|
||||
#include <AudioToolbox/AudioToolbox.h>
|
||||
#undef ULONG
|
||||
#undef HRESULT
|
||||
#undef STDMETHODCALLTYPE
|
||||
#undef SUCCEEDED
|
||||
#undef FAILED
|
||||
#undef IS_ERROR
|
||||
#undef HRESULT_FACILITY
|
||||
#undef MAKE_HRESULT
|
||||
#undef S_OK
|
||||
#undef S_FALSE
|
||||
#undef E_UNEXPECTED
|
||||
#undef E_NOTIMPL
|
||||
#undef E_OUTOFMEMORY
|
||||
#undef E_INVALIDARG
|
||||
#undef E_NOINTERFACE
|
||||
#undef E_POINTER
|
||||
#undef E_HANDLE
|
||||
#undef E_ABORT
|
||||
#undef E_FAIL
|
||||
#undef E_ACCESSDENIED
|
||||
#include "coreaudio.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(wave);
|
||||
|
||||
int AudioUnit_SetVolume(AudioUnit au, float left, float right)
|
||||
{
|
||||
OSStatus err = noErr;
|
||||
static int once;
|
||||
|
||||
if (!once++) FIXME("independent left/right volume not implemented (%f, %f)\n", left, right);
|
||||
|
||||
err = AudioUnitSetParameter(au, kHALOutputParam_Volume, kAudioUnitParameterFlag_Output, 0, left, 0);
|
||||
|
||||
if (err != noErr)
|
||||
{
|
||||
ERR("AudioUnitSetParameter return an error %s\n", wine_dbgstr_fourcc(err));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int AudioUnit_GetVolume(AudioUnit au, float *left, float *right)
|
||||
{
|
||||
OSStatus err = noErr;
|
||||
static int once;
|
||||
|
||||
if (!once++) FIXME("independent left/right volume not implemented\n");
|
||||
|
||||
err = AudioUnitGetParameter(au, kHALOutputParam_Volume, kAudioUnitParameterFlag_Output, 0, left);
|
||||
if (err != noErr)
|
||||
{
|
||||
ERR("AudioUnitGetParameter return an error %s\n", wine_dbgstr_fourcc(err));
|
||||
return 0;
|
||||
}
|
||||
*right = *left;
|
||||
return 1;
|
||||
}
|
|
@ -620,6 +620,60 @@ static DWORD midi_out_get_num_devs(void)
|
|||
return num_dests;
|
||||
}
|
||||
|
||||
static DWORD midi_out_get_volume(WORD dev_id, DWORD *volume)
|
||||
{
|
||||
TRACE("%d\n", dev_id);
|
||||
|
||||
if (dev_id >= num_dests)
|
||||
{
|
||||
WARN("bad device ID : %d\n", dev_id);
|
||||
return MMSYSERR_BADDEVICEID;
|
||||
}
|
||||
if (!volume)
|
||||
{
|
||||
WARN("Invalid Parameter\n");
|
||||
return MMSYSERR_INVALPARAM;
|
||||
}
|
||||
|
||||
if (dests[dev_id].caps.wTechnology == MOD_SYNTH)
|
||||
{
|
||||
static int once;
|
||||
float left;
|
||||
|
||||
if (!once++) FIXME("independent left/right volume not implemented\n");
|
||||
AudioUnitGetParameter(dests[dev_id].synth, kHALOutputParam_Volume, kAudioUnitParameterFlag_Output, 0, &left);
|
||||
*volume = (WORD)(left * 0xffff) + ((WORD)(left * 0xffff) << 16);
|
||||
return MMSYSERR_NOERROR;
|
||||
}
|
||||
|
||||
return MMSYSERR_NOTSUPPORTED;
|
||||
}
|
||||
|
||||
static DWORD midi_out_set_volume(WORD dev_id, DWORD volume)
|
||||
{
|
||||
TRACE("dev_id = %d vol = %08x\n", dev_id, volume);
|
||||
|
||||
if (dev_id >= num_dests)
|
||||
{
|
||||
WARN("bad device ID : %d\n", dev_id);
|
||||
return MMSYSERR_BADDEVICEID;
|
||||
}
|
||||
if (dests[dev_id].caps.wTechnology == MOD_SYNTH)
|
||||
{
|
||||
float left, right;
|
||||
static int once;
|
||||
|
||||
if (!once++) FIXME("independent left/right volume not implemented\n");
|
||||
left = LOWORD(volume) / 65535.0f;
|
||||
right = HIWORD(volume) / 65535.0f;
|
||||
|
||||
AudioUnitSetParameter(dests[dev_id].synth, kHALOutputParam_Volume, kAudioUnitParameterFlag_Output, 0, left, 0);
|
||||
return MMSYSERR_NOERROR;
|
||||
}
|
||||
|
||||
return MMSYSERR_NOTSUPPORTED;
|
||||
}
|
||||
|
||||
NTSTATUS midi_out_message(void *args)
|
||||
{
|
||||
struct midi_out_message_params *params = args;
|
||||
|
@ -658,6 +712,12 @@ NTSTATUS midi_out_message(void *args)
|
|||
case MODM_GETNUMDEVS:
|
||||
*params->err = midi_out_get_num_devs();
|
||||
break;
|
||||
case MODM_GETVOLUME:
|
||||
*params->err = midi_out_get_volume(params->dev_id, (DWORD *)params->param_1);
|
||||
break;
|
||||
case MODM_SETVOLUME:
|
||||
*params->err = midi_out_set_volume(params->dev_id, params->param_1);
|
||||
break;
|
||||
default:
|
||||
TRACE("Unsupported message\n");
|
||||
*params->err = MMSYSERR_NOTSUPPORTED;
|
||||
|
|
|
@ -61,10 +61,6 @@ typedef void *AUGraph;
|
|||
|
||||
extern OSStatus MusicDeviceMIDIEvent(AudioUnit au, UInt32 inStatus, UInt32 inData1, UInt32 inData2, UInt32 inOffsetSampleFrame);
|
||||
extern OSStatus MusicDeviceSysEx(AudioUnit au, const UInt8 *inData, UInt32 inLength);
|
||||
|
||||
/* audiounit.c */
|
||||
extern int AudioUnit_SetVolume(AudioUnit au, float left, float right);
|
||||
extern int AudioUnit_GetVolume(AudioUnit au, float *left, float *right);
|
||||
#endif
|
||||
|
||||
/* midi.c */
|
||||
|
|
|
@ -155,56 +155,6 @@ static void MIDI_NotifyClient(UINT wDevID, WORD wMsg, DWORD_PTR dwParam1, DWORD_
|
|||
DriverCallback(dwCallBack, uFlags, hDev, wMsg, dwInstance, dwParam1, dwParam2);
|
||||
}
|
||||
|
||||
static DWORD MIDIOut_GetVolume(WORD wDevID, DWORD *lpdwVolume)
|
||||
{
|
||||
TRACE("%d\n", wDevID);
|
||||
|
||||
if (wDevID >= MIDIOut_NumDevs) {
|
||||
WARN("bad device ID : %d\n", wDevID);
|
||||
return MMSYSERR_BADDEVICEID;
|
||||
}
|
||||
if (lpdwVolume == NULL) {
|
||||
WARN("Invalid Parameter\n");
|
||||
return MMSYSERR_INVALPARAM;
|
||||
}
|
||||
|
||||
if (destinations[wDevID].caps.wTechnology == MOD_SYNTH)
|
||||
{
|
||||
float left;
|
||||
float right;
|
||||
AudioUnit_GetVolume(destinations[wDevID].synth, &left, &right);
|
||||
|
||||
*lpdwVolume = (WORD) (left * 0xFFFF) + ((WORD) (right * 0xFFFF) << 16);
|
||||
|
||||
return MMSYSERR_NOERROR;
|
||||
}
|
||||
|
||||
return MMSYSERR_NOTSUPPORTED;
|
||||
}
|
||||
|
||||
static DWORD MIDIOut_SetVolume(WORD wDevID, DWORD dwVolume)
|
||||
{
|
||||
TRACE("%d\n", wDevID);
|
||||
|
||||
if (wDevID >= MIDIOut_NumDevs) {
|
||||
WARN("bad device ID : %d\n", wDevID);
|
||||
return MMSYSERR_BADDEVICEID;
|
||||
}
|
||||
if (destinations[wDevID].caps.wTechnology == MOD_SYNTH)
|
||||
{
|
||||
float left;
|
||||
float right;
|
||||
|
||||
left = LOWORD(dwVolume) / 65535.0f;
|
||||
right = HIWORD(dwVolume) / 65535.0f;
|
||||
AudioUnit_SetVolume(destinations[wDevID].synth, left, right);
|
||||
|
||||
return MMSYSERR_NOERROR;
|
||||
}
|
||||
|
||||
return MMSYSERR_NOTSUPPORTED;
|
||||
}
|
||||
|
||||
static DWORD MIDIOut_Reset(WORD wDevID)
|
||||
{
|
||||
unsigned chn;
|
||||
|
@ -583,10 +533,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);
|
||||
|
||||
switch (wMsg) {
|
||||
case MODM_GETVOLUME:
|
||||
return MIDIOut_GetVolume(wDevID, (DWORD*)dwParam1);
|
||||
case MODM_SETVOLUME:
|
||||
return MIDIOut_SetVolume(wDevID, dwParam1);
|
||||
case MODM_RESET:
|
||||
return MIDIOut_Reset(wDevID);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue