Evilly merge tag 'wine-1.5.11' into dsoal
[wine/multimedia.git] / dlls / dsound / dsp / 0023_dsound:_Add_dumb_heuristic_to_find_buggy_applications__try_3.patch
blobdaf50d22589d96895ac957f5ff5f955fcd3ac5e8
1 commit f974bd20533dd3b8adca5bfdb3c1677f2e6b2960
2 Author: Maarten Lankhorst <m.b.lankhorst@gmail.com>
3 Date: Tue Apr 12 00:59:48 2011 +0200
5 dsound: Add dumb heuristic to find buggy applications, try 3
7 ---
8 Make monkey island really work
10 diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c
11 index efa1778..0dad7c3 100644
12 --- a/dlls/dsound/buffer.c
13 +++ b/dlls/dsound/buffer.c
14 @@ -74,6 +74,7 @@ struct DS8Data
15 ALuint numsegs;
16 ALuint segsize;
17 ALuint lastsegsize;
18 + ALuint buggy_app_detection;
21 static void trigger_notifies(DS8Buffer *buf, DWORD lastpos, DWORD curpos, BOOL stopping)
22 @@ -181,6 +182,28 @@ static void CALLBACK DS8Buffer_timer(UINT timerID, UINT msg, DWORD_PTR dwUser,
24 IAudioClient_GetCurrentPadding(prim->dev, &pad);
25 pad = 2048 - pad;
26 + if(pad && !prim->ExtAL.BufferDataStatic && prim->ExtAL.BufferSubData)
27 + {
28 + for (i = 0; i < prim->nbuffers; ++i)
29 + {
30 + DS8Buffer *buf = prim->buffers[i];
31 + ALint state;
32 + DWORD pos1, pos2, ofs;
33 + void *ptr1, *ptr2;
34 + if (!buf->buffer->buggy_app_detection)
35 + continue;
36 + palGetSourcei(buf->source, AL_SOURCE_STATE, &state);
37 + if (state != AL_PLAYING)
38 + continue;
39 + EnterCriticalSection(buf->crst);
40 + WARN("Unlock never was called succesfully, doing this manually now\n");
41 + IDirectSoundBuffer8_GetCurrentPosition(&buf->IDirectSoundBuffer8_iface, &ofs, NULL);
42 + IDirectSoundBuffer8_Lock(&buf->IDirectSoundBuffer8_iface, ofs, pad * buf->buffer->format->nBlockAlign, &ptr1, &pos1, &ptr2, &pos2, 0);
43 + IDirectSoundBuffer8_Unlock(&buf->IDirectSoundBuffer8_iface, ptr1, pos1, ptr2, pos2);
44 + buf->buffer->buggy_app_detection = 1;
45 + LeaveCriticalSection(buf->crst);
46 + }
47 + }
48 if (pad)
50 IAudioRenderClient_GetBuffer(prim->render_dev, pad, &data);
51 @@ -1351,6 +1374,8 @@ static HRESULT WINAPI DS8Buffer_Play(IDirectSoundBuffer8 *iface, DWORD res1, DWO
53 palGetSourcei(This->source, AL_SOURCE_TYPE, &type);
54 palSourcei(This->source, AL_LOOPING, (flags&DSBPLAY_LOOPING) ? AL_TRUE : AL_FALSE);
55 + if (flags & DSBPLAY_LOOPING)
56 + This->buffer->buggy_app_detection = 1;
58 getALError();
60 @@ -1632,10 +1657,12 @@ static HRESULT WINAPI DS8Buffer_Unlock(IDirectSoundBuffer8 *iface, void *ptr1, D
61 getALError();
65 + This->buffer->buggy_app_detection = 0;
66 out:
67 - if (hr != S_OK)
68 + if (hr != S_OK) {
69 WARN("Invalid parameters (0x%lx,%u) (%p,%u,%p,%u)\n", boundary, bufsize, ptr1, len1, ptr2, len2);
70 + buf->buggy_app_detection = buf->buf_size;
71 + }
72 popALContext();
73 LeaveCriticalSection(This->crst);
74 return hr;