Commit e3e0bfca authored by Jörg Höhle's avatar Jörg Höhle Committed by Alexandre Julliard

winmm: Avoid generic MMSYSERR_ERROR during initialisation.

parent 6086c7be
......@@ -379,6 +379,29 @@ static inline void WINMM_NotifyClient(WINMM_CBInfo *info, WORD msg, DWORD_PTR pa
msg, info->user, param1, param2);
}
static MMRESULT hr2mmr(HRESULT hr)
{
switch(hr){
case S_OK:
case AUDCLNT_E_NOT_STOPPED:
return MMSYSERR_NOERROR;
case AUDCLNT_E_UNSUPPORTED_FORMAT:
return WAVERR_BADFORMAT;
case AUDCLNT_E_DEVICE_IN_USE:
return MMSYSERR_ALLOCATED;
case AUDCLNT_E_ENDPOINT_CREATE_FAILED:
return MMSYSERR_NOTENABLED;
case E_OUTOFMEMORY:
return MMSYSERR_NOMEM;
case E_POINTER:
case E_INVALIDARG:
return MMSYSERR_INVALPARAM;
case AUDCLNT_E_DEVICE_INVALIDATED: /* DSERR_BUFFERLOST */
default:
return FAILED(hr) ? MMSYSERR_ERROR : MMSYSERR_NOERROR;
}
}
static HRESULT WINMM_GetFriendlyName(IMMDevice *device, WCHAR *out,
UINT outlen)
{
......@@ -898,7 +921,7 @@ static LRESULT WINMM_OpenDevice(WINMM_Device *device, WINMM_MMDevice *mmdevice,
WINMM_OpenInfo *info)
{
WAVEFORMATEX *closer_fmt = NULL, fmt, *passed_fmt;
LRESULT ret = MMSYSERR_ERROR;
LRESULT ret = MMSYSERR_NOMEM;
HRESULT hr;
hr = IMMDeviceEnumerator_GetDevice(g_devenum, mmdevice->dev_id,
......@@ -907,13 +930,18 @@ static LRESULT WINMM_OpenDevice(WINMM_Device *device, WINMM_MMDevice *mmdevice,
WARN("Device %s (%s) unavailable: %08x\n",
wine_dbgstr_w(mmdevice->dev_id),
wine_dbgstr_w(mmdevice->out_caps.szPname), hr);
ret = MMSYSERR_NODRIVER;
goto error;
}
/* this is where winexyz.drv opens the audio device */
hr = IMMDevice_Activate(device->device, &IID_IAudioClient,
CLSCTX_INPROC_SERVER, NULL, (void**)&device->client);
if(FAILED(hr)){
WARN("Activate failed: %08x\n", hr);
ret = hr2mmr(hr);
if(ret == MMSYSERR_ERROR)
ret = MMSYSERR_NOTENABLED;
goto error;
}
......@@ -945,6 +973,7 @@ static LRESULT WINMM_OpenDevice(WINMM_Device *device, WINMM_MMDevice *mmdevice,
CoTaskMemFree(closer_fmt);
if(FAILED(hr) && hr != AUDCLNT_E_UNSUPPORTED_FORMAT){
WARN("IsFormatSupported failed: %08x\n", hr);
ret = hr2mmr(hr);
goto error;
}
if(hr == S_FALSE || hr == AUDCLNT_E_UNSUPPORTED_FORMAT){
......@@ -962,6 +991,7 @@ static LRESULT WINMM_OpenDevice(WINMM_Device *device, WINMM_MMDevice *mmdevice,
10 * 100000, 50000, passed_fmt, &device->parent->session);
if(FAILED(hr)){
WARN("Initialize failed: %08x\n", hr);
ret = hr2mmr(hr);
goto error;
}
......@@ -1038,7 +1068,7 @@ static LRESULT WOD_Open(WINMM_OpenInfo *info)
{
WINMM_MMDevice *mmdevice;
WINMM_Device *device = NULL;
LRESULT ret = MMSYSERR_ERROR;
LRESULT ret;
HRESULT hr;
TRACE("(%u, %p, %08x)\n", info->req_device, info, info->flags);
......@@ -1111,7 +1141,7 @@ static LRESULT WID_Open(WINMM_OpenInfo *info)
{
WINMM_MMDevice *mmdevice;
WINMM_Device *device = NULL;
LRESULT ret = MMSYSERR_ERROR;
LRESULT ret;
HRESULT hr;
TRACE("(%u, %p, %08x)\n", info->req_device, info, info->flags);
......@@ -2378,7 +2408,7 @@ UINT WINAPI waveOutGetDevCapsW(UINT_PTR uDeviceID, LPWAVEOUTCAPSW lpCaps,
hr = WINMM_InitMMDevices();
if(FAILED(hr))
return MMSYSERR_ERROR;
return MMSYSERR_NODRIVER;
if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
......@@ -2474,7 +2504,7 @@ MMRESULT WINAPI waveOutOpen(LPHWAVEOUT lphWaveOut, UINT uDeviceID,
dwCallback, dwInstance, dwFlags);
if(!WINMM_StartDevicesThread())
return MMSYSERR_ERROR;
return MMSYSERR_NODRIVER;
if(!lphWaveOut && !(dwFlags & WAVE_FORMAT_QUERY))
return MMSYSERR_INVALPARAM;
......@@ -2939,7 +2969,7 @@ static UINT get_device_interface(UINT msg, BOOL is_out, UINT index, WCHAR *out,
WINMM_QueryInterfaceInfo info;
if(!WINMM_StartDevicesThread())
return MMSYSERR_ERROR;
return MMSYSERR_NODRIVER;
info.is_out = is_out;
info.index = index;
......@@ -3021,7 +3051,7 @@ UINT WINAPI waveInGetDevCapsW(UINT_PTR uDeviceID, LPWAVEINCAPSW lpCaps, UINT uSi
hr = WINMM_InitMMDevices();
if(FAILED(hr))
return MMSYSERR_ERROR;
return MMSYSERR_NODRIVER;
if(!lpCaps)
return MMSYSERR_INVALPARAM;
......@@ -3096,7 +3126,7 @@ MMRESULT WINAPI waveInOpen(HWAVEIN* lphWaveIn, UINT uDeviceID,
dwCallback, dwInstance, dwFlags);
if(!WINMM_StartDevicesThread())
return MMSYSERR_ERROR;
return MMSYSERR_NODRIVER;
if(!lphWaveIn && !(dwFlags & WAVE_FORMAT_QUERY))
return MMSYSERR_INVALPARAM;
......@@ -3445,7 +3475,7 @@ UINT WINAPI mixerGetDevCapsW(UINT_PTR uDeviceID, LPMIXERCAPSW lpCaps, UINT uSize
hr = WINMM_InitMMDevices();
if(FAILED(hr))
return MMSYSERR_ERROR;
return MMSYSERR_NODRIVER;
if(!lpCaps)
return MMSYSERR_INVALPARAM;
......@@ -3490,7 +3520,7 @@ UINT WINAPI mixerOpen(LPHMIXER lphMix, UINT uDeviceID, DWORD_PTR dwCallback,
hr = WINMM_InitMMDevices();
if(FAILED(hr))
return MMSYSERR_ERROR;
return MMSYSERR_NODRIVER;
if(!lphMix)
return MMSYSERR_INVALPARAM;
......@@ -3539,7 +3569,7 @@ UINT WINAPI mixerGetID(HMIXEROBJ hmix, LPUINT lpid, DWORD fdwID)
hr = WINMM_InitMMDevices();
if(FAILED(hr))
return MMSYSERR_ERROR;
return MMSYSERR_NODRIVER;
if(!lpid)
return MMSYSERR_INVALPARAM;
......@@ -3567,7 +3597,7 @@ UINT WINAPI mixerGetControlDetailsW(HMIXEROBJ hmix, LPMIXERCONTROLDETAILS lpmcdW
hr = WINMM_InitMMDevices();
if(FAILED(hr))
return MMSYSERR_ERROR;
return MMSYSERR_NODRIVER;
if(!lpmcdW)
return MMSYSERR_INVALPARAM;
......@@ -3754,7 +3784,7 @@ UINT WINAPI mixerGetLineControlsW(HMIXEROBJ hmix, LPMIXERLINECONTROLSW lpmlcW,
hr = WINMM_InitMMDevices();
if(FAILED(hr))
return MMSYSERR_ERROR;
return MMSYSERR_NODRIVER;
if(fdwControls & ~(MIXER_GETLINECONTROLSF_ALL |
MIXER_GETLINECONTROLSF_ONEBYID |
......@@ -3972,7 +4002,7 @@ UINT WINAPI mixerGetLineInfoW(HMIXEROBJ hmix, LPMIXERLINEW lpmliW, DWORD fdwInfo
hr = WINMM_InitMMDevices();
if(FAILED(hr))
return MMSYSERR_ERROR;
return MMSYSERR_NODRIVER;
if(!lpmliW || lpmliW->cbStruct < sizeof(MIXERLINEW))
return MMSYSERR_INVALPARAM;
......@@ -4098,7 +4128,7 @@ UINT WINAPI mixerSetControlDetails(HMIXEROBJ hmix, LPMIXERCONTROLDETAILS lpmcd,
TRACE("(%p, %p, %x)\n", hmix, lpmcd, fdwDetails);
if(!WINMM_StartDevicesThread())
return MMSYSERR_ERROR;
return MMSYSERR_NODRIVER;
if((fdwDetails & MIXER_SETCONTROLDETAILSF_QUERYMASK) ==
MIXER_SETCONTROLDETAILSF_CUSTOM)
......
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