winmm: Fix looping handling.

This commit is contained in:
Andrew Eikum 2011-08-01 13:11:59 -05:00 committed by Alexandre Julliard
parent 729afa6adc
commit 5512c2482f

View file

@ -1263,7 +1263,7 @@ static WAVEHDR *WOD_MarkDoneHeaders(WINMM_Device *device)
HRESULT hr; HRESULT hr;
WAVEHDR *queue, *first = device->first; WAVEHDR *queue, *first = device->first;
UINT64 clock_freq, clock_pos, clock_frames; UINT64 clock_freq, clock_pos, clock_frames;
UINT32 nloops, queue_frames; UINT32 nloops, queue_frames = 0;
hr = IAudioClock_GetFrequency(device->clock, &clock_freq); hr = IAudioClock_GetFrequency(device->clock, &clock_freq);
if(FAILED(hr)){ if(FAILED(hr)){
@ -1282,19 +1282,21 @@ static WAVEHDR *WOD_MarkDoneHeaders(WINMM_Device *device)
first = queue = device->first; first = queue = device->first;
nloops = device->loop_counter; nloops = device->loop_counter;
while(queue && while(queue &&
(queue_frames = WINMM_HeaderLenFrames(device, queue)) <= (queue_frames += WINMM_HeaderLenFrames(device, queue)) <=
clock_frames - device->last_clock_pos){ clock_frames - device->last_clock_pos){
WAVEHDR *next = queue->lpNext;
if(!nloops){ if(!nloops){
device->first->dwFlags &= ~WHDR_INQUEUE; device->first->dwFlags &= ~WHDR_INQUEUE;
device->first->dwFlags |= WHDR_DONE; device->first->dwFlags |= WHDR_DONE;
device->last_clock_pos += queue_frames; device->last_clock_pos += queue_frames;
queue = device->first = next; queue_frames = 0;
queue = device->first = queue->lpNext;
}else{ }else{
if(queue->dwFlags & WHDR_BEGINLOOP) if(queue->dwFlags & WHDR_BEGINLOOP){
queue = next; if(queue->dwFlags & WHDR_ENDLOOP)
--nloops;
if(queue->dwFlags & WHDR_ENDLOOP){ else
queue = queue->lpNext;
}else if(queue->dwFlags & WHDR_ENDLOOP){
queue = device->loop_start; queue = device->loop_start;
--nloops; --nloops;
} }
@ -2476,8 +2478,13 @@ UINT WINAPI waveOutWrite(HWAVEOUT hWaveOut, WAVEHDR *header, UINT uSize)
device->last = header; device->last = header;
if(!device->playing) if(!device->playing)
device->playing = header; device->playing = header;
}else }else{
device->playing = device->first = device->last = header; device->playing = device->first = device->last = header;
if(header->dwFlags & WHDR_BEGINLOOP){
device->loop_counter = header->dwLoops;
device->loop_start = header;
}
}
header->lpNext = NULL; header->lpNext = NULL;
header->dwFlags &= ~WHDR_DONE; header->dwFlags &= ~WHDR_DONE;