From 58bd405778b19097679a23394817d53485c7bc0d Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Wed, 13 Jul 2011 14:20:28 -0500 Subject: [PATCH] winmm: Support WAVE_MAPPED flag in waveOut*. --- dlls/winmm/waveform.c | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/dlls/winmm/waveform.c b/dlls/winmm/waveform.c index 254bf21e731..57c6add096d 100644 --- a/dlls/winmm/waveform.c +++ b/dlls/winmm/waveform.c @@ -615,6 +615,11 @@ static UINT WAVE_Open(HANDLE* lphndl, UINT uDeviceID, UINT uType, return dwRet; } +static inline BOOL WINMM_IsMapper(UINT device) +{ + return (device == WAVE_MAPPER || device == (UINT16)WAVE_MAPPER); +} + static MMRESULT WINMM_TryDeviceMapping(WINMM_OpenInfo *info, WORD channels, DWORD freq, DWORD bits_per_samp, BOOL is_out) { @@ -644,15 +649,24 @@ static MMRESULT WINMM_TryDeviceMapping(WINMM_OpenInfo *info, WORD channels, /* ACM can convert from src->dst, so try to find a device * that supports dst */ - for(i = 0; i < g_outmmdevices_count; ++i){ + if(WINMM_IsMapper(info->req_device)){ + for(i = 0; i < g_outmmdevices_count; ++i){ + WINMM_OpenInfo l_info = *info; + l_info.req_device = i; + l_info.format = ⌖ + mr = WOD_Open(&l_info); + if(mr == MMSYSERR_NOERROR){ + info->handle = l_info.handle; + break; + } + } + }else{ WINMM_OpenInfo l_info = *info; - l_info.req_device = i; + l_info.flags &= ~WAVE_MAPPED; l_info.format = ⌖ mr = WOD_Open(&l_info); - if(mr == MMSYSERR_NOERROR){ + if(mr == MMSYSERR_NOERROR) info->handle = l_info.handle; - break; - } } if(mr != MMSYSERR_NOERROR) return WAVERR_BADFORMAT; @@ -684,8 +698,17 @@ static MMRESULT WINMM_MapDevice(WINMM_OpenInfo *info, BOOL is_out) /* try to find a direct match */ if(is_out){ WINMM_OpenInfo l_info = *info; - for(i = 0; i < g_outmmdevices_count; ++i){ - l_info.req_device = i; + if(WINMM_IsMapper(info->req_device)){ + for(i = 0; i < g_outmmdevices_count; ++i){ + l_info.req_device = i; + mr = WOD_Open(&l_info); + if(mr == MMSYSERR_NOERROR){ + info->handle = l_info.handle; + return mr; + } + } + }else{ + l_info.flags &= ~WAVE_MAPPED; mr = WOD_Open(&l_info); if(mr == MMSYSERR_NOERROR){ info->handle = l_info.handle; @@ -940,11 +963,6 @@ error: return ret; } -static inline BOOL WINMM_IsMapper(UINT device) -{ - return (device == WAVE_MAPPER || device == (UINT16)WAVE_MAPPER); -} - static LRESULT WOD_Open(WINMM_OpenInfo *info) { WINMM_MMDevice *mmdevice; @@ -955,7 +973,7 @@ static LRESULT WOD_Open(WINMM_OpenInfo *info) TRACE("(%u, %p, %08x)\n", info->req_device, info, info->flags); - if(WINMM_IsMapper(info->req_device)) + if(WINMM_IsMapper(info->req_device) || (info->flags & WAVE_MAPPED)) return WINMM_MapDevice(info, TRUE); if(info->req_device >= g_outmmdevices_count) -- 2.11.4.GIT