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

winmm: Ignore broken nBlockAlign and AvgBytes within PCMWAVEFORMAT.

parent bcc65899
...@@ -843,6 +843,19 @@ static LRESULT WINMM_OpenDevice(WINMM_Device *device, WINMM_MMDevice *mmdevice, ...@@ -843,6 +843,19 @@ static LRESULT WINMM_OpenDevice(WINMM_Device *device, WINMM_MMDevice *mmdevice,
passed_fmt = &fmt; passed_fmt = &fmt;
memcpy(passed_fmt, info->format, sizeof(PCMWAVEFORMAT)); memcpy(passed_fmt, info->format, sizeof(PCMWAVEFORMAT));
passed_fmt->cbSize = 0; passed_fmt->cbSize = 0;
if(fmt.wBitsPerSample % 8 != 0){
WARN("Fixing bad wBitsPerSample (%u)\n", fmt.wBitsPerSample);
fmt.wBitsPerSample = (fmt.wBitsPerSample + 7) & ~7;
}
/* winmm ignores broken blockalign and avgbytes */
if(fmt.nBlockAlign != fmt.nChannels * fmt.wBitsPerSample/8){
WARN("Fixing bad nBlockAlign (%u)\n", fmt.nBlockAlign);
fmt.nBlockAlign = fmt.nChannels * fmt.wBitsPerSample/8;
}
if (fmt.nAvgBytesPerSec != fmt.nSamplesPerSec * fmt.nBlockAlign) {
WARN("Fixing bad nAvgBytesPerSec (%u)\n", fmt.nAvgBytesPerSec);
fmt.nAvgBytesPerSec = fmt.nSamplesPerSec * fmt.nBlockAlign;
}
}else }else
passed_fmt = info->format; passed_fmt = info->format;
...@@ -909,8 +922,8 @@ static LRESULT WINMM_OpenDevice(WINMM_Device *device, WINMM_MMDevice *mmdevice, ...@@ -909,8 +922,8 @@ static LRESULT WINMM_OpenDevice(WINMM_Device *device, WINMM_MMDevice *mmdevice,
goto error; goto error;
} }
device->bytes_per_frame = info->format->nBlockAlign; device->bytes_per_frame = passed_fmt->nBlockAlign;
device->samples_per_sec = info->format->nSamplesPerSec; device->samples_per_sec = passed_fmt->nSamplesPerSec;
device->played_frames = 0; device->played_frames = 0;
device->last_clock_pos = 0; device->last_clock_pos = 0;
......
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