diff --git a/dlls/winmm/waveform.c b/dlls/winmm/waveform.c
index 42b888e1ac..dffc002c24 100644
--- a/dlls/winmm/waveform.c
+++ b/dlls/winmm/waveform.c
@@ -1243,10 +1243,17 @@ static LRESULT WOD_Open(WINMM_OpenInfo *info)
lock = &g_devthread_lock;
internal_index = MAPPER_INDEX;
}else{
- if(info->req_device >= g_outmmdevices_count)
- return MMSYSERR_BADDEVICEID;
+ if(info->req_device >= g_outmmdevices_count) {
+ WINMM_Device *device = WINMM_GetDeviceFromHWAVE((HWAVE)info->req_device);
+
+ if(device == NULL) return MMSYSERR_BADDEVICEID;
+
+ mmdevice = device->parent;
+ }
+ else {
+ mmdevice = read_map(g_out_map, info->req_device);
+ }
- mmdevice = read_map(g_out_map, info->req_device);
if(!mmdevice->out_caps.szPname[0])
Please add a test for this. Also note req_device is shorter than
HWAVE, on 64-bit.