winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
October 2023
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
1 participants
702 discussions
Start a n
N
ew thread
Rémi Bernon : dmsynth: Correctly lookup instrument from the default drum bank.
by Alexandre Julliard
18 Oct '23
18 Oct '23
Module: wine Branch: master Commit: 1728f82a2af115bb72aab8ce676ceb6fa491cc95 URL:
https://gitlab.winehq.org/wine/wine/-/commit/1728f82a2af115bb72aab8ce676ceb…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Mon Oct 16 19:07:07 2023 +0200 dmsynth: Correctly lookup instrument from the default drum bank. --- dlls/dmsynth/synth.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dlls/dmsynth/synth.c b/dlls/dmsynth/synth.c index 941fc465d17..5fcc1e9d075 100644 --- a/dlls/dmsynth/synth.c +++ b/dlls/dmsynth/synth.c @@ -1570,7 +1570,10 @@ static fluid_preset_t *synth_sfont_get_preset(fluid_sfont_t *fluid_sfont, int ba EnterCriticalSection(&synth->cs); LIST_FOR_EACH_ENTRY(instrument, &synth->instruments, struct instrument, entry) - if (instrument->patch == patch) break; + { + if (bank == 128 && instrument->patch == (0x80000000 | patch)) break; + else if (instrument->patch == ((bank << 8) | patch)) break; + } if (&instrument->entry == &synth->instruments) {
1
0
0
0
Rémi Bernon : dmsynth: Implement sink rendering to DirectSound buffer.
by Alexandre Julliard
18 Oct '23
18 Oct '23
Module: wine Branch: master Commit: 7274902a3bd79824a43dfa8d11bbfd8c2cead0e4 URL:
https://gitlab.winehq.org/wine/wine/-/commit/7274902a3bd79824a43dfa8d11bbfd…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Thu Oct 12 11:59:36 2023 +0200 dmsynth: Implement sink rendering to DirectSound buffer. --- dlls/dmsynth/synthsink.c | 148 ++++++++++++++++++++++++++++++++++++++++++- dlls/dmsynth/tests/dmsynth.c | 2 +- 2 files changed, 147 insertions(+), 3 deletions(-) diff --git a/dlls/dmsynth/synthsink.c b/dlls/dmsynth/synthsink.c index fb7ea5fd283..d0a89358652 100644 --- a/dlls/dmsynth/synthsink.c +++ b/dlls/dmsynth/synthsink.c @@ -25,7 +25,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dmsynth); -#define BUFFER_SUBDIVISIONS 8 +#define BUFFER_SUBDIVISIONS 100 struct synth_sink { @@ -74,6 +74,128 @@ static void synth_sink_get_format(struct synth_sink *This, WAVEFORMATEX *format) } } +static HRESULT synth_sink_write_data(struct synth_sink *sink, IDirectSoundBuffer *buffer, + DSBCAPS *caps, WAVEFORMATEX *format, const void *data, DWORD size) +{ + DWORD write_end, size1, size2, current_pos; + void *data1, *data2; + HRESULT hr; + + TRACE("sink %p, data %p, size %#lx\n", sink, data, size); + + current_pos = sink->written % caps->dwBufferBytes; + + if (sink->written) + { + DWORD play_pos, write_pos; + + if (FAILED(hr = IDirectSoundBuffer_GetCurrentPosition(buffer, &play_pos, &write_pos))) return hr; + + if (current_pos - play_pos <= write_pos - play_pos) + { + ERR("Underrun detected, sink %p, play pos %#lx, write pos %#lx, current pos %#lx!\n", + buffer, play_pos, write_pos, current_pos); + current_pos = write_pos; + } + + write_end = (current_pos + size) % caps->dwBufferBytes; + if (write_end - current_pos >= play_pos - current_pos) return S_FALSE; + } + + if (FAILED(hr = IDirectSoundBuffer_Lock(buffer, current_pos, size, + &data1, &size1, &data2, &size2, 0))) + { + ERR("IDirectSoundBuffer_Lock failed, hr %#lx\n", hr); + return hr; + } + + if (!data) + { + memset(data1, format->wBitsPerSample == 8 ? 128 : 0, size1); + memset(data2, format->wBitsPerSample == 8 ? 128 : 0, size2); + } + else + { + memcpy(data1, data, size1); + data = (char *)data + size1; + memcpy(data2, data, size2); + } + + if (FAILED(hr = IDirectSoundBuffer_Unlock(buffer, data1, size1, data2, size2))) + { + ERR("IDirectSoundBuffer_Unlock failed, hr %#lx\n", hr); + return hr; + } + + sink->written += size; + TRACE("Written size %#lx, total %#lx\n", size, sink->written); + return S_OK; +} + +static HRESULT synth_sink_wait_play_end(struct synth_sink *sink, IDirectSoundBuffer *buffer, + DSBCAPS *caps, WAVEFORMATEX *format, HANDLE buffer_event) +{ + DWORD current_pos, start_pos, play_pos, written, played = 0; + HRESULT hr; + + if (FAILED(hr = IDirectSoundBuffer_GetCurrentPosition(buffer, &start_pos, NULL))) + { + ERR("IDirectSoundBuffer_GetCurrentPosition failed, hr %#lx\n", hr); + return hr; + } + + current_pos = sink->written % caps->dwBufferBytes; + written = current_pos - start_pos + (current_pos < start_pos ? caps->dwBufferBytes : 0); + if (FAILED(hr = synth_sink_write_data(sink, buffer, caps, format, NULL, caps->dwBufferBytes / 2))) return hr; + + for (;;) + { + DWORD ret; + + if (FAILED(hr = IDirectSoundBuffer_GetCurrentPosition(buffer, &play_pos, NULL))) + { + ERR("IDirectSoundBuffer_GetCurrentPosition failed, hr %#lx\n", hr); + return hr; + } + + played += play_pos - start_pos + (play_pos < start_pos ? caps->dwBufferBytes : 0); + if (played >= written) break; + + TRACE("Waiting for EOS, start_pos %#lx, play_pos %#lx, written %#lx, played %#lx\n", + start_pos, play_pos, written, played); + if ((ret = WaitForMultipleObjects(1, &buffer_event, FALSE, INFINITE))) + { + ERR("WaitForMultipleObjects returned %#lx\n", ret); + break; + } + + start_pos = play_pos; + } + + return S_OK; +} + +static HRESULT synth_sink_render_data(struct synth_sink *sink, IDirectMusicSynth *synth, + IDirectSoundBuffer *buffer, WAVEFORMATEX *format, short *samples, DWORD samples_size) +{ + REFERENCE_TIME sample_time; + HRESULT hr; + + if (FAILED(hr = IDirectMusicSynth_Render(synth, samples, samples_size / format->nBlockAlign, + sink->written / format->nBlockAlign))) + ERR("Failed to render synthesizer samples, hr %#lx\n", hr); + + if (FAILED(hr = IDirectMusicSynthSink_SampleToRefTime(&sink->IDirectMusicSynthSink_iface, + (sink->written + samples_size) / format->nBlockAlign, &sample_time))) + ERR("Failed to convert sample position to time, hr %#lx\n", hr); + + EnterCriticalSection(&sink->cs); + sink->latency_time = sample_time; + LeaveCriticalSection(&sink->cs); + + return hr; +} + struct render_thread_params { struct synth_sink *sink; @@ -90,7 +212,10 @@ static DWORD CALLBACK synth_sink_render_thread(void *args) IDirectMusicSynth *synth = params->synth; struct synth_sink *sink = params->sink; IDirectSoundNotify *notify; + WAVEFORMATEX format; HANDLE buffer_event; + DWORD samples_size; + short *samples; HRESULT hr; TRACE("Starting thread, args %p\n", args); @@ -103,6 +228,8 @@ static DWORD CALLBACK synth_sink_render_thread(void *args) ERR("Failed to create buffer event, error %lu\n", GetLastError()); else if (FAILED(hr = IDirectSoundBuffer_GetCaps(buffer, &caps))) ERR("Failed to query sound buffer caps, hr %#lx.\n", hr); + else if (FAILED(hr = IDirectSoundBuffer_GetFormat(buffer, &format, sizeof(format), NULL))) + ERR("Failed to query sound buffer format, hr %#lx.\n", hr); else if (FAILED(hr = IDirectSoundBuffer_QueryInterface(buffer, &IID_IDirectSoundNotify, (void **)¬ify))) ERR("Failed to query IDirectSoundNotify iface, hr %#lx.\n", hr); @@ -124,15 +251,28 @@ static DWORD CALLBACK synth_sink_render_thread(void *args) IDirectSoundNotify_Release(notify); } + samples_size = caps.dwBufferBytes / BUFFER_SUBDIVISIONS; + if (!(samples = malloc(samples_size))) + { + ERR("Failed to allocate memory for samples\n"); + goto done; + } + + if (FAILED(hr = synth_sink_render_data(sink, synth, buffer, &format, samples, samples_size))) + ERR("Failed to render initial buffer data, hr %#lx.\n", hr); if (FAILED(hr = IDirectSoundBuffer_Play(buffer, 0, 0, DSBPLAY_LOOPING))) ERR("Failed to start sound buffer, hr %#lx.\n", hr); SetEvent(params->started_event); - while (hr == S_OK) + while (SUCCEEDED(hr) && SUCCEEDED(hr = synth_sink_write_data(sink, buffer, + &caps, &format, samples, samples_size))) { HANDLE handles[] = {sink->stop_event, buffer_event}; DWORD ret; + if (hr == S_OK) /* if successfully written, render more data */ + hr = synth_sink_render_data(sink, synth, buffer, &format, samples, samples_size); + if (!(ret = WaitForMultipleObjects(ARRAY_SIZE(handles), handles, FALSE, INFINITE)) || ret >= ARRAY_SIZE(handles)) { @@ -148,6 +288,10 @@ static DWORD CALLBACK synth_sink_render_thread(void *args) return hr; } + synth_sink_wait_play_end(sink, buffer, &caps, &format, buffer_event); + free(samples); + +done: IDirectSoundBuffer_Release(buffer); IDirectMusicSynth_Release(synth); CloseHandle(buffer_event); diff --git a/dlls/dmsynth/tests/dmsynth.c b/dlls/dmsynth/tests/dmsynth.c index 6529bdeac34..ad09a651094 100644 --- a/dlls/dmsynth/tests/dmsynth.c +++ b/dlls/dmsynth/tests/dmsynth.c @@ -1317,7 +1317,7 @@ static void test_IDirectMusicSynthSink(void) tmp_time = time; hr = IReferenceClock_GetTime(latency_clock, &tmp_time); ok(hr == S_OK, "got %#lx\n", hr); - todo_wine ok(tmp_time > time, "got %I64d\n", tmp_time - time); + ok(tmp_time > time, "got %I64d\n", tmp_time - time); ok(tmp_time - time <= 2000000, "got %I64d\n", tmp_time - time); /* setting the clock while active is fine */
1
0
0
0
Rémi Bernon : dmsynth: Create a render thread on sink activation.
by Alexandre Julliard
18 Oct '23
18 Oct '23
Module: wine Branch: master Commit: 0d56c54d8b5d754ab71576232b04df39b5e46414 URL:
https://gitlab.winehq.org/wine/wine/-/commit/0d56c54d8b5d754ab71576232b04df…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Tue Sep 5 13:43:07 2023 +0200 dmsynth: Create a render thread on sink activation. --- dlls/dmsynth/synthsink.c | 153 ++++++++++++++++++++++++++++++++++++++++++- dlls/dmsynth/tests/dmsynth.c | 4 +- 2 files changed, 154 insertions(+), 3 deletions(-) diff --git a/dlls/dmsynth/synthsink.c b/dlls/dmsynth/synthsink.c index 28cee0c3a28..fb7ea5fd283 100644 --- a/dlls/dmsynth/synthsink.c +++ b/dlls/dmsynth/synthsink.c @@ -25,6 +25,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(dmsynth); +#define BUFFER_SUBDIVISIONS 8 + struct synth_sink { IDirectMusicSynthSink IDirectMusicSynthSink_iface; @@ -35,10 +37,17 @@ struct synth_sink IReferenceClock *master_clock; IDirectMusicSynth *synth; /* No reference hold! */ IDirectSound *dsound; + IDirectSoundBuffer *dsound_buffer; BOOL active; REFERENCE_TIME activate_time; + + CRITICAL_SECTION cs; REFERENCE_TIME latency_time; + + DWORD written; /* number of bytes written out */ + HANDLE stop_event; + HANDLE render_thread; }; static inline struct synth_sink *impl_from_IDirectMusicSynthSink(IDirectMusicSynthSink *iface) @@ -65,8 +74,93 @@ static void synth_sink_get_format(struct synth_sink *This, WAVEFORMATEX *format) } } +struct render_thread_params +{ + struct synth_sink *sink; + IDirectMusicSynth *synth; + IDirectSoundBuffer *buffer; + HANDLE started_event; +}; + +static DWORD CALLBACK synth_sink_render_thread(void *args) +{ + struct render_thread_params *params = args; + DSBCAPS caps = {.dwSize = sizeof(DSBCAPS)}; + IDirectSoundBuffer *buffer = params->buffer; + IDirectMusicSynth *synth = params->synth; + struct synth_sink *sink = params->sink; + IDirectSoundNotify *notify; + HANDLE buffer_event; + HRESULT hr; + + TRACE("Starting thread, args %p\n", args); + SetThreadDescription(GetCurrentThread(), L"wine_dmsynth_sink"); + + if (FAILED(hr = IDirectSoundBuffer_Stop(buffer))) + ERR("Failed to stop sound buffer, hr %#lx.\n", hr); + + if (!(buffer_event = CreateEventW(NULL, FALSE, FALSE, NULL))) + ERR("Failed to create buffer event, error %lu\n", GetLastError()); + else if (FAILED(hr = IDirectSoundBuffer_GetCaps(buffer, &caps))) + ERR("Failed to query sound buffer caps, hr %#lx.\n", hr); + else if (FAILED(hr = IDirectSoundBuffer_QueryInterface(buffer, &IID_IDirectSoundNotify, + (void **)¬ify))) + ERR("Failed to query IDirectSoundNotify iface, hr %#lx.\n", hr); + else + { + DSBPOSITIONNOTIFY positions[BUFFER_SUBDIVISIONS] = {{.dwOffset = 0, .hEventNotify = buffer_event}}; + int i; + + for (i = 1; i < ARRAY_SIZE(positions); ++i) + { + positions[i] = positions[i - 1]; + positions[i].dwOffset += caps.dwBufferBytes / ARRAY_SIZE(positions); + } + + if (FAILED(hr = IDirectSoundNotify_SetNotificationPositions(notify, + ARRAY_SIZE(positions), positions))) + ERR("Failed to set notification positions, hr %#lx\n", hr); + + IDirectSoundNotify_Release(notify); + } + + if (FAILED(hr = IDirectSoundBuffer_Play(buffer, 0, 0, DSBPLAY_LOOPING))) + ERR("Failed to start sound buffer, hr %#lx.\n", hr); + SetEvent(params->started_event); + + while (hr == S_OK) + { + HANDLE handles[] = {sink->stop_event, buffer_event}; + DWORD ret; + + if (!(ret = WaitForMultipleObjects(ARRAY_SIZE(handles), handles, FALSE, INFINITE)) + || ret >= ARRAY_SIZE(handles)) + { + ERR("WaitForMultipleObjects returned %lu\n", ret); + hr = HRESULT_FROM_WIN32(ret); + break; + } + } + + if (FAILED(hr)) + { + ERR("Thread unexpected termination, hr %#lx\n", hr); + return hr; + } + + IDirectSoundBuffer_Release(buffer); + IDirectMusicSynth_Release(synth); + CloseHandle(buffer_event); + + return 0; +} + static HRESULT synth_sink_activate(struct synth_sink *This) { + IDirectMusicSynthSink *iface = &This->IDirectMusicSynthSink_iface; + DSBUFFERDESC desc = {.dwSize = sizeof(DSBUFFERDESC)}; + struct render_thread_params params; + WAVEFORMATEX format; HRESULT hr; if (!This->synth) return DMUS_E_SYNTHNOTCONFIGURED; @@ -77,13 +171,54 @@ static HRESULT synth_sink_activate(struct synth_sink *This) if (FAILED(hr = IReferenceClock_GetTime(This->master_clock, &This->activate_time))) return hr; This->latency_time = This->activate_time; + if ((params.buffer = This->dsound_buffer)) + IDirectMusicBuffer_AddRef(params.buffer); + else + { + synth_sink_get_format(This, &format); + desc.lpwfxFormat = (WAVEFORMATEX *)&format; + desc.dwBufferBytes = format.nAvgBytesPerSec; + if (FAILED(hr = IDirectMusicSynthSink_GetDesiredBufferSize(iface, &desc.dwBufferBytes))) + ERR("Failed to get desired buffer size, hr %#lx\n", hr); + + desc.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; + if (FAILED(hr = IDirectSound8_CreateSoundBuffer(This->dsound, &desc, ¶ms.buffer, NULL))) + { + ERR("Failed to create sound buffer, hr %#lx.\n", hr); + return hr; + } + } + + params.sink = This; + params.synth = This->synth; + IDirectMusicSynth_AddRef(This->synth); + + if (!(params.started_event = CreateEventW(NULL, FALSE, FALSE, NULL)) + || !(This->render_thread = CreateThread(NULL, 0, synth_sink_render_thread, ¶ms, 0, NULL))) + { + ERR("Failed to create render thread, error %lu\n", GetLastError()); + hr = HRESULT_FROM_WIN32(GetLastError()); + IDirectSoundBuffer_Release(params.buffer); + IDirectMusicSynth_Release(params.synth); + CloseHandle(params.started_event); + return hr; + } + + WaitForSingleObject(params.started_event, INFINITE); + CloseHandle(params.started_event); This->active = TRUE; return S_OK; } static HRESULT synth_sink_deactivate(struct synth_sink *This) { + if (!This->active) return S_OK; + + SetEvent(This->stop_event); + WaitForSingleObject(This->render_thread, INFINITE); + This->render_thread = NULL; This->active = FALSE; + return S_OK; } @@ -133,8 +268,15 @@ static ULONG WINAPI synth_sink_Release(IDirectMusicSynthSink *iface) TRACE("(%p): new ref = %lu\n", This, ref); if (!ref) { + if (This->active) + IDirectMusicSynthSink_Activate(iface, FALSE); if (This->master_clock) IReferenceClock_Release(This->master_clock); + + This->cs.DebugInfo->Spare[0] = 0; + DeleteCriticalSection(&This->cs); + CloseHandle(This->stop_event); + free(This); } @@ -238,15 +380,17 @@ static HRESULT WINAPI synth_sink_SetDirectSound(IDirectMusicSynthSink *iface, TRACE("(%p)->(%p, %p)\n", This, dsound, dsound_buffer); - if (dsound_buffer) FIXME("Ignoring IDirectSoundBuffer parameter.\n"); if (This->active) return DMUS_E_SYNTHACTIVE; if (This->dsound) IDirectSound_Release(This->dsound); This->dsound = NULL; + if (This->dsound_buffer) IDirectSoundBuffer_Release(This->dsound_buffer); + This->dsound_buffer = NULL; if (!dsound) return S_OK; if (!This->synth) return DMUS_E_SYNTHNOTCONFIGURED; if ((This->dsound = dsound)) IDirectSound_AddRef(This->dsound); + if ((This->dsound_buffer = dsound_buffer)) IDirectSoundBuffer_AddRef(This->dsound_buffer); return S_OK; } @@ -413,7 +557,10 @@ static HRESULT WINAPI latency_clock_GetTime(IReferenceClock *iface, REFERENCE_TI if (!time) return E_INVALIDARG; if (!This->active) return E_FAIL; + + EnterCriticalSection(&This->cs); *time = This->latency_time; + LeaveCriticalSection(&This->cs); return S_OK; } @@ -462,6 +609,10 @@ HRESULT synth_sink_create(IUnknown **ret_iface) obj->IReferenceClock_iface.lpVtbl = &latency_clock_vtbl; obj->ref = 1; + obj->stop_event = CreateEventW(NULL, FALSE, FALSE, NULL); + InitializeCriticalSection(&obj->cs); + obj->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": cs"); + TRACE("Created DirectMusicSynthSink %p\n", obj); *ret_iface = (IUnknown *)&obj->IDirectMusicSynthSink_iface; return S_OK; diff --git a/dlls/dmsynth/tests/dmsynth.c b/dlls/dmsynth/tests/dmsynth.c index 25ecff97048..6529bdeac34 100644 --- a/dlls/dmsynth/tests/dmsynth.c +++ b/dlls/dmsynth/tests/dmsynth.c @@ -1294,7 +1294,7 @@ static void test_IDirectMusicSynthSink(void) hr = IDirectMusicSynthSink_Activate(sink, TRUE); ok(hr == DMUS_E_SYNTHACTIVE, "got %#lx\n", hr); ref = get_refcount(synth); - ok(ref == 1, "got %#lx\n", ref); + todo_wine ok(ref == 1, "got %#lx\n", ref); hr = IDirectMusicSynthSink_GetDesiredBufferSize(sink, &size); ok(hr == S_OK, "got %#lx\n", hr); @@ -1328,7 +1328,7 @@ static void test_IDirectMusicSynthSink(void) hr = IDirectMusicSynthSink_Init(sink, NULL); ok(hr == S_OK, "got %#lx\n", hr); ref = get_refcount(synth); - ok(ref == 1, "got %#lx\n", ref); + todo_wine ok(ref == 1, "got %#lx\n", ref); hr = IDirectMusicSynthSink_Activate(sink, TRUE); ok(hr == DMUS_E_SYNTHNOTCONFIGURED, "got %#lx\n", hr);
1
0
0
0
Connor McAdams : uiautomationcore: Implement IUIAutomationElement::get_CachedBoundingRectangle.
by Alexandre Julliard
18 Oct '23
18 Oct '23
Module: wine Branch: master Commit: 27aed609c6ea0c2c06e5e66d957695bd5480641d URL:
https://gitlab.winehq.org/wine/wine/-/commit/27aed609c6ea0c2c06e5e66d957695…
Author: Connor McAdams <cmcadams(a)codeweavers.com> Date: Thu Sep 21 11:31:49 2023 -0400 uiautomationcore: Implement IUIAutomationElement::get_CachedBoundingRectangle. Signed-off-by: Connor McAdams <cmcadams(a)codeweavers.com> --- dlls/uiautomationcore/tests/uiautomation.c | 19 +++++----- dlls/uiautomationcore/uia_com_client.c | 58 +++++++++++++++++++++--------- 2 files changed, 51 insertions(+), 26 deletions(-) diff --git a/dlls/uiautomationcore/tests/uiautomation.c b/dlls/uiautomationcore/tests/uiautomation.c index 2f2a5e1329c..b527e5bf98d 100644 --- a/dlls/uiautomationcore/tests/uiautomation.c +++ b/dlls/uiautomationcore/tests/uiautomation.c @@ -13675,11 +13675,11 @@ static void test_Element_cache_methods(IUIAutomation *uia_iface) /* Cached UIA_BoundingRectanglePropertyId helper. */ hr = IUIAutomationElement_get_CachedBoundingRectangle(element, NULL); - todo_wine ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); rect.left = rect.top = rect.bottom = rect.right = 1; hr = IUIAutomationElement_get_CachedBoundingRectangle(element, &rect); - todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); ok(rect.left == 1, "Unexpected rect left %ld\n", rect.left); ok(rect.top == 1, "Unexpected rect top %ld\n", rect.top); ok(rect.right == 1, "Unexpected rect right %ld\n", rect.right); @@ -13687,17 +13687,16 @@ static void test_Element_cache_methods(IUIAutomation *uia_iface) rect.left = rect.top = rect.bottom = rect.right = 1; hr = IUIAutomationElement_get_CachedBoundingRectangle(element2, &rect); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine ok(!rect.left, "Unexpected rect left %ld\n", rect.left); - todo_wine ok(!rect.top, "Unexpected rect top %ld\n", rect.top); - todo_wine ok(!rect.right, "Unexpected rect right %ld\n", rect.right); - todo_wine ok(!rect.bottom, "Unexpected rect bottom %ld\n", rect.bottom); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!rect.left, "Unexpected rect left %ld\n", rect.left); + ok(!rect.top, "Unexpected rect top %ld\n", rect.top); + ok(!rect.right, "Unexpected rect right %ld\n", rect.right); + ok(!rect.bottom, "Unexpected rect bottom %ld\n", rect.bottom); memset(&rect, 0, sizeof(rect)); hr = IUIAutomationElement_get_CachedBoundingRectangle(element3, &rect); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - if (SUCCEEDED(hr)) - check_uia_rect_rect_val(&rect, &Provider.bounds_rect); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + check_uia_rect_rect_val(&rect, &Provider.bounds_rect); IUIAutomationElement_Release(element3); IUIAutomationElement_Release(element2); diff --git a/dlls/uiautomationcore/uia_com_client.c b/dlls/uiautomationcore/uia_com_client.c index d383abe0d9b..5c0d0cd0b9e 100644 --- a/dlls/uiautomationcore/uia_com_client.c +++ b/dlls/uiautomationcore/uia_com_client.c @@ -2312,6 +2312,32 @@ static HRESULT WINAPI uia_element_get_CurrentItemStatus(IUIAutomationElement9 *i return E_NOTIMPL; } +static void uia_variant_rect_to_rect(VARIANT *v, RECT *ret_val) +{ + double *vals; + HRESULT hr; + + memset(ret_val, 0, sizeof(*ret_val)); + if (V_VT(v) != (VT_R8 | VT_ARRAY)) + return; + + hr = SafeArrayAccessData(V_ARRAY(v), (void **)&vals); + if (FAILED(hr)) + { + WARN("SafeArrayAccessData failed with hr %#lx\n", hr); + return; + } + + ret_val->left = vals[0]; + ret_val->top = vals[1]; + ret_val->right = ret_val->left + vals[2]; + ret_val->bottom = ret_val->top + vals[3]; + + hr = SafeArrayUnaccessData(V_ARRAY(v)); + if (FAILED(hr)) + WARN("SafeArrayUnaccessData failed with hr %#lx\n", hr); +} + static HRESULT WINAPI uia_element_get_CurrentBoundingRectangle(IUIAutomationElement9 *iface, RECT *ret_val) { struct uia_element *element = impl_from_IUIAutomationElement9(iface); @@ -2320,22 +2346,9 @@ static HRESULT WINAPI uia_element_get_CurrentBoundingRectangle(IUIAutomationElem TRACE("%p, %p\n", element, ret_val); - memset(ret_val, 0, sizeof(*ret_val)); VariantInit(&v); hr = UiaGetPropertyValue(element->node, UIA_BoundingRectanglePropertyId, &v); - if (SUCCEEDED(hr) && V_VT(&v) == (VT_R8 | VT_ARRAY)) - { - double vals[4]; - LONG idx; - - for (idx = 0; idx < ARRAY_SIZE(vals); idx++) - SafeArrayGetElement(V_ARRAY(&v), &idx, &vals[idx]); - - ret_val->left = vals[0]; - ret_val->top = vals[1]; - ret_val->right = ret_val->left + vals[2]; - ret_val->bottom = ret_val->top + vals[3]; - } + uia_variant_rect_to_rect(&v, ret_val); VariantClear(&v); return hr; @@ -2588,8 +2601,21 @@ static HRESULT WINAPI uia_element_get_CachedItemStatus(IUIAutomationElement9 *if static HRESULT WINAPI uia_element_get_CachedBoundingRectangle(IUIAutomationElement9 *iface, RECT *ret_val) { - FIXME("%p: stub\n", iface); - return E_NOTIMPL; + struct uia_element *element = impl_from_IUIAutomationElement9(iface); + const int prop_id = UIA_BoundingRectanglePropertyId; + struct uia_cache_property *cache_prop = NULL; + + TRACE("%p, %p\n", iface, ret_val); + + if (!ret_val) + return E_POINTER; + + if (!(cache_prop = bsearch(&prop_id, element->cached_props, element->cached_props_count, sizeof(*cache_prop), + uia_cached_property_id_compare))) + return E_INVALIDARG; + + uia_variant_rect_to_rect(&cache_prop->prop_val, ret_val); + return S_OK; } static HRESULT WINAPI uia_element_get_CachedLabeledBy(IUIAutomationElement9 *iface, IUIAutomationElement **ret_val)
1
0
0
0
Connor McAdams : uiautomationcore: Implement IUIAutomationElement::get_CachedName.
by Alexandre Julliard
18 Oct '23
18 Oct '23
Module: wine Branch: master Commit: f9f59d109fef46489abaf4f084133e7774ad28b6 URL:
https://gitlab.winehq.org/wine/wine/-/commit/f9f59d109fef46489abaf4f084133e…
Author: Connor McAdams <cmcadams(a)codeweavers.com> Date: Thu Sep 21 10:56:55 2023 -0400 uiautomationcore: Implement IUIAutomationElement::get_CachedName. Signed-off-by: Connor McAdams <cmcadams(a)codeweavers.com> --- dlls/uiautomationcore/tests/uiautomation.c | 14 ++++++-------- dlls/uiautomationcore/uia_com_client.c | 21 +++++++++++++++++++-- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/dlls/uiautomationcore/tests/uiautomation.c b/dlls/uiautomationcore/tests/uiautomation.c index 6eb1f204dbb..2f2a5e1329c 100644 --- a/dlls/uiautomationcore/tests/uiautomation.c +++ b/dlls/uiautomationcore/tests/uiautomation.c @@ -13635,25 +13635,23 @@ static void test_Element_cache_methods(IUIAutomation *uia_iface) /* Cached UIA_NamePropertyId helper. */ hr = IUIAutomationElement_get_CachedName(element, NULL); - todo_wine ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); tmp_bstr = (void *)0xdeadbeef; hr = IUIAutomationElement_get_CachedName(element, &tmp_bstr); - todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); ok(tmp_bstr == (void *)0xdeadbeef, "Unexpected BSTR ptr %p\n", tmp_bstr); tmp_bstr = NULL; hr = IUIAutomationElement_get_CachedName(element2, &tmp_bstr); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - if (SUCCEEDED(hr)) - ok(!lstrcmpW(tmp_bstr, L""), "Unexpected BSTR %s\n", wine_dbgstr_w(tmp_bstr)); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!lstrcmpW(tmp_bstr, L""), "Unexpected BSTR %s\n", wine_dbgstr_w(tmp_bstr)); SysFreeString(tmp_bstr); tmp_bstr = NULL; hr = IUIAutomationElement_get_CachedName(element3, &tmp_bstr); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - if (SUCCEEDED(hr)) - ok(!lstrcmpW(tmp_bstr, uia_bstr_prop_str), "Unexpected BSTR %s\n", wine_dbgstr_w(tmp_bstr)); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!lstrcmpW(tmp_bstr, uia_bstr_prop_str), "Unexpected BSTR %s\n", wine_dbgstr_w(tmp_bstr)); SysFreeString(tmp_bstr); /* Cached UIA_ControlTypePropertyId. */ diff --git a/dlls/uiautomationcore/uia_com_client.c b/dlls/uiautomationcore/uia_com_client.c index d517b680bdd..d383abe0d9b 100644 --- a/dlls/uiautomationcore/uia_com_client.c +++ b/dlls/uiautomationcore/uia_com_client.c @@ -2424,8 +2424,25 @@ static HRESULT WINAPI uia_element_get_CachedLocalizedControlType(IUIAutomationEl static HRESULT WINAPI uia_element_get_CachedName(IUIAutomationElement9 *iface, BSTR *ret_val) { - FIXME("%p: stub\n", iface); - return E_NOTIMPL; + struct uia_element *element = impl_from_IUIAutomationElement9(iface); + struct uia_cache_property *cache_prop = NULL; + const int prop_id = UIA_NamePropertyId; + + TRACE("%p, %p\n", iface, ret_val); + + if (!ret_val) + return E_POINTER; + + if (!(cache_prop = bsearch(&prop_id, element->cached_props, element->cached_props_count, sizeof(*cache_prop), + uia_cached_property_id_compare))) + return E_INVALIDARG; + + if ((V_VT(&cache_prop->prop_val) == VT_BSTR) && V_BSTR(&cache_prop->prop_val)) + *ret_val = SysAllocString(V_BSTR(&cache_prop->prop_val)); + else + *ret_val = SysAllocString(L""); + + return S_OK; } static HRESULT WINAPI uia_element_get_CachedAcceleratorKey(IUIAutomationElement9 *iface, BSTR *ret_val)
1
0
0
0
Connor McAdams : uiautomationcore: Implement IUIAutomationElement::get_CachedIsKeyboardFocusable.
by Alexandre Julliard
18 Oct '23
18 Oct '23
Module: wine Branch: master Commit: e9e009b723e2fe7d1d38733d8909b53bb5b4d43f URL:
https://gitlab.winehq.org/wine/wine/-/commit/e9e009b723e2fe7d1d38733d8909b5…
Author: Connor McAdams <cmcadams(a)codeweavers.com> Date: Thu Sep 21 10:50:35 2023 -0400 uiautomationcore: Implement IUIAutomationElement::get_CachedIsKeyboardFocusable. Signed-off-by: Connor McAdams <cmcadams(a)codeweavers.com> --- dlls/uiautomationcore/tests/uiautomation.c | 12 ++++++------ dlls/uiautomationcore/uia_com_client.c | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/dlls/uiautomationcore/tests/uiautomation.c b/dlls/uiautomationcore/tests/uiautomation.c index b3f4d2517f5..6eb1f204dbb 100644 --- a/dlls/uiautomationcore/tests/uiautomation.c +++ b/dlls/uiautomationcore/tests/uiautomation.c @@ -13616,22 +13616,22 @@ static void test_Element_cache_methods(IUIAutomation *uia_iface) /* Cached UIA_IsKeyboardFocusablePropertyId helper. */ hr = IUIAutomationElement_get_CachedIsKeyboardFocusable(element, NULL); - todo_wine ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); tmp_bool = 0xdeadbeef; hr = IUIAutomationElement_get_CachedIsKeyboardFocusable(element, &tmp_bool); - todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); ok(tmp_bool == 0xdeadbeef, "Unexpected tmp_bool %d\n", tmp_bool); tmp_bool = 0xdeadbeef; hr = IUIAutomationElement_get_CachedIsKeyboardFocusable(element2, &tmp_bool); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine ok(!tmp_bool, "tmp_bool != FALSE\n"); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!tmp_bool, "tmp_bool != FALSE\n"); tmp_bool = FALSE; hr = IUIAutomationElement_get_CachedIsKeyboardFocusable(element3, &tmp_bool); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine ok(!!tmp_bool, "tmp_bool == FALSE\n"); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!!tmp_bool, "tmp_bool == FALSE\n"); /* Cached UIA_NamePropertyId helper. */ hr = IUIAutomationElement_get_CachedName(element, NULL); diff --git a/dlls/uiautomationcore/uia_com_client.c b/dlls/uiautomationcore/uia_com_client.c index d949b3c0a92..d517b680bdd 100644 --- a/dlls/uiautomationcore/uia_com_client.c +++ b/dlls/uiautomationcore/uia_com_client.c @@ -2461,8 +2461,21 @@ static HRESULT WINAPI uia_element_get_CachedHasKeyboardFocus(IUIAutomationElemen static HRESULT WINAPI uia_element_get_CachedIsKeyboardFocusable(IUIAutomationElement9 *iface, BOOL *ret_val) { - FIXME("%p: stub\n", iface); - return E_NOTIMPL; + struct uia_element *element = impl_from_IUIAutomationElement9(iface); + const int prop_id = UIA_IsKeyboardFocusablePropertyId; + struct uia_cache_property *cache_prop = NULL; + + TRACE("%p, %p\n", iface, ret_val); + + if (!ret_val) + return E_POINTER; + + if (!(cache_prop = bsearch(&prop_id, element->cached_props, element->cached_props_count, sizeof(*cache_prop), + uia_cached_property_id_compare))) + return E_INVALIDARG; + + *ret_val = ((V_VT(&cache_prop->prop_val) == VT_BOOL) && (V_BOOL(&cache_prop->prop_val) == VARIANT_TRUE)); + return S_OK; } static HRESULT WINAPI uia_element_get_CachedIsEnabled(IUIAutomationElement9 *iface, BOOL *ret_val)
1
0
0
0
Connor McAdams : uiautomationcore: Implement IUIAutomationElement::get_CachedHasKeyboardFocus.
by Alexandre Julliard
18 Oct '23
18 Oct '23
Module: wine Branch: master Commit: 118b74f82f08cf887977d05d297ee3280ad97b47 URL:
https://gitlab.winehq.org/wine/wine/-/commit/118b74f82f08cf887977d05d297ee3…
Author: Connor McAdams <cmcadams(a)codeweavers.com> Date: Thu Sep 21 10:40:12 2023 -0400 uiautomationcore: Implement IUIAutomationElement::get_CachedHasKeyboardFocus. Signed-off-by: Connor McAdams <cmcadams(a)codeweavers.com> --- dlls/uiautomationcore/tests/uiautomation.c | 12 ++++++------ dlls/uiautomationcore/uia_com_client.c | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/dlls/uiautomationcore/tests/uiautomation.c b/dlls/uiautomationcore/tests/uiautomation.c index 4a5bca74b6a..b3f4d2517f5 100644 --- a/dlls/uiautomationcore/tests/uiautomation.c +++ b/dlls/uiautomationcore/tests/uiautomation.c @@ -13597,22 +13597,22 @@ static void test_Element_cache_methods(IUIAutomation *uia_iface) /* Cached UIA_HasKeyboardFocusPropertyId helper. */ hr = IUIAutomationElement_get_CachedHasKeyboardFocus(element, NULL); - todo_wine ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); tmp_bool = 0xdeadbeef; hr = IUIAutomationElement_get_CachedHasKeyboardFocus(element, &tmp_bool); - todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); ok(tmp_bool == 0xdeadbeef, "Unexpected tmp_bool %d\n", tmp_bool); tmp_bool = 0xdeadbeef; hr = IUIAutomationElement_get_CachedHasKeyboardFocus(element2, &tmp_bool); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine ok(!tmp_bool, "tmp_bool != FALSE\n"); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!tmp_bool, "tmp_bool != FALSE\n"); tmp_bool = FALSE; hr = IUIAutomationElement_get_CachedHasKeyboardFocus(element3, &tmp_bool); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine ok(!!tmp_bool, "tmp_bool == FALSE\n"); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!!tmp_bool, "tmp_bool == FALSE\n"); /* Cached UIA_IsKeyboardFocusablePropertyId helper. */ hr = IUIAutomationElement_get_CachedIsKeyboardFocusable(element, NULL); diff --git a/dlls/uiautomationcore/uia_com_client.c b/dlls/uiautomationcore/uia_com_client.c index e47c64c479b..d949b3c0a92 100644 --- a/dlls/uiautomationcore/uia_com_client.c +++ b/dlls/uiautomationcore/uia_com_client.c @@ -2442,8 +2442,21 @@ static HRESULT WINAPI uia_element_get_CachedAccessKey(IUIAutomationElement9 *ifa static HRESULT WINAPI uia_element_get_CachedHasKeyboardFocus(IUIAutomationElement9 *iface, BOOL *ret_val) { - FIXME("%p: stub\n", iface); - return E_NOTIMPL; + struct uia_element *element = impl_from_IUIAutomationElement9(iface); + const int prop_id = UIA_HasKeyboardFocusPropertyId; + struct uia_cache_property *cache_prop = NULL; + + TRACE("%p, %p\n", iface, ret_val); + + if (!ret_val) + return E_POINTER; + + if (!(cache_prop = bsearch(&prop_id, element->cached_props, element->cached_props_count, sizeof(*cache_prop), + uia_cached_property_id_compare))) + return E_INVALIDARG; + + *ret_val = ((V_VT(&cache_prop->prop_val) == VT_BOOL) && (V_BOOL(&cache_prop->prop_val) == VARIANT_TRUE)); + return S_OK; } static HRESULT WINAPI uia_element_get_CachedIsKeyboardFocusable(IUIAutomationElement9 *iface, BOOL *ret_val)
1
0
0
0
Connor McAdams : uiautomationcore: Implement IUIAutomationElement::get_CachedControlType.
by Alexandre Julliard
18 Oct '23
18 Oct '23
Module: wine Branch: master Commit: 15f098c34e183d0e6e71187ef47972ceba79eb47 URL:
https://gitlab.winehq.org/wine/wine/-/commit/15f098c34e183d0e6e71187ef47972…
Author: Connor McAdams <cmcadams(a)codeweavers.com> Date: Thu Sep 21 06:53:16 2023 -0400 uiautomationcore: Implement IUIAutomationElement::get_CachedControlType. Signed-off-by: Connor McAdams <cmcadams(a)codeweavers.com> --- dlls/uiautomationcore/tests/uiautomation.c | 12 ++++----- dlls/uiautomationcore/uia_com_client.c | 43 +++++++++++++++++++++--------- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/dlls/uiautomationcore/tests/uiautomation.c b/dlls/uiautomationcore/tests/uiautomation.c index 1fd734bff65..4a5bca74b6a 100644 --- a/dlls/uiautomationcore/tests/uiautomation.c +++ b/dlls/uiautomationcore/tests/uiautomation.c @@ -13658,22 +13658,22 @@ static void test_Element_cache_methods(IUIAutomation *uia_iface) /* Cached UIA_ControlTypePropertyId. */ hr = IUIAutomationElement_get_CachedControlType(element, NULL); - todo_wine ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); tmp_int = 0xdeadbeef; hr = IUIAutomationElement_get_CachedControlType(element, &tmp_int); - todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); ok(tmp_int == 0xdeadbeef, "Unexpected control type %#x\n", tmp_int); tmp_int = 0; hr = IUIAutomationElement_get_CachedControlType(element2, &tmp_int); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine ok(tmp_int == UIA_CustomControlTypeId, "Unexpected control type %#x\n", tmp_int); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(tmp_int == UIA_CustomControlTypeId, "Unexpected control type %#x\n", tmp_int); tmp_int = 0; hr = IUIAutomationElement_get_CachedControlType(element3, &tmp_int); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine ok(tmp_int == UIA_HyperlinkControlTypeId, "Unexpected control type %#x\n", tmp_int); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(tmp_int == UIA_HyperlinkControlTypeId, "Unexpected control type %#x\n", tmp_int); /* Cached UIA_BoundingRectanglePropertyId helper. */ hr = IUIAutomationElement_get_CachedBoundingRectangle(element, NULL); diff --git a/dlls/uiautomationcore/uia_com_client.c b/dlls/uiautomationcore/uia_com_client.c index d138d4ed919..e47c64c479b 100644 --- a/dlls/uiautomationcore/uia_com_client.c +++ b/dlls/uiautomationcore/uia_com_client.c @@ -2143,27 +2143,33 @@ static HRESULT WINAPI uia_element_get_CurrentProcessId(IUIAutomationElement9 *if return E_NOTIMPL; } +static void uia_elem_get_control_type(VARIANT *v, CONTROLTYPEID *ret_val) +{ + const struct uia_control_type_info *info = NULL; + + *ret_val = UIA_CustomControlTypeId; + if (V_VT(v) != VT_I4) + return; + + if ((info = uia_control_type_info_from_id(V_I4(v)))) + *ret_val = info->control_type_id; + else + WARN("Provider returned invalid control type ID %ld\n", V_I4(v)); +} + static HRESULT WINAPI uia_element_get_CurrentControlType(IUIAutomationElement9 *iface, CONTROLTYPEID *ret_val) { struct uia_element *element = impl_from_IUIAutomationElement9(iface); - const struct uia_control_type_info *control_type_info = NULL; HRESULT hr; VARIANT v; TRACE("%p, %p\n", iface, ret_val); VariantInit(&v); - *ret_val = UIA_CustomControlTypeId; hr = UiaGetPropertyValue(element->node, UIA_ControlTypePropertyId, &v); - if (SUCCEEDED(hr) && V_VT(&v) == VT_I4) - { - if ((control_type_info = uia_control_type_info_from_id(V_I4(&v)))) - *ret_val = control_type_info->control_type_id; - else - WARN("Provider returned invalid control type ID %ld\n", V_I4(&v)); - } - + uia_elem_get_control_type(&v, ret_val); VariantClear(&v); + return hr; } @@ -2393,8 +2399,21 @@ static HRESULT WINAPI uia_element_get_CachedProcessId(IUIAutomationElement9 *ifa static HRESULT WINAPI uia_element_get_CachedControlType(IUIAutomationElement9 *iface, CONTROLTYPEID *ret_val) { - FIXME("%p: stub\n", iface); - return E_NOTIMPL; + struct uia_element *element = impl_from_IUIAutomationElement9(iface); + const int prop_id = UIA_ControlTypePropertyId; + struct uia_cache_property *cache_prop = NULL; + + TRACE("%p, %p\n", iface, ret_val); + + if (!ret_val) + return E_POINTER; + + if (!(cache_prop = bsearch(&prop_id, element->cached_props, element->cached_props_count, sizeof(*cache_prop), + uia_cached_property_id_compare))) + return E_INVALIDARG; + + uia_elem_get_control_type(&cache_prop->prop_val, ret_val); + return S_OK; } static HRESULT WINAPI uia_element_get_CachedLocalizedControlType(IUIAutomationElement9 *iface, BSTR *ret_val)
1
0
0
0
Connor McAdams : uiautomationcore/tests: Add tests for cached value helper functions in the COM API.
by Alexandre Julliard
18 Oct '23
18 Oct '23
Module: wine Branch: master Commit: 6d0047ad66280f83458e4123d654f61ef7e77a25 URL:
https://gitlab.winehq.org/wine/wine/-/commit/6d0047ad66280f83458e4123d654f6…
Author: Connor McAdams <cmcadams(a)codeweavers.com> Date: Wed Sep 20 13:07:20 2023 -0400 uiautomationcore/tests: Add tests for cached value helper functions in the COM API. Signed-off-by: Connor McAdams <cmcadams(a)codeweavers.com> --- dlls/uiautomationcore/tests/uiautomation.c | 177 ++++++++++++++++++++++++++++- 1 file changed, 176 insertions(+), 1 deletion(-) diff --git a/dlls/uiautomationcore/tests/uiautomation.c b/dlls/uiautomationcore/tests/uiautomation.c index f34f020b814..1fd734bff65 100644 --- a/dlls/uiautomationcore/tests/uiautomation.c +++ b/dlls/uiautomationcore/tests/uiautomation.c @@ -13310,13 +13310,19 @@ static const struct prov_method_sequence get_cached_prop_val_seq3[] = { static void test_Element_cache_methods(IUIAutomation *uia_iface) { + static const int cache_test_props[] = { UIA_IsKeyboardFocusablePropertyId, UIA_NamePropertyId, UIA_ControlTypePropertyId, + UIA_BoundingRectanglePropertyId, UIA_HasKeyboardFocusPropertyId, }; HWND hwnd = create_test_hwnd("test_Element_cache_methods class"); IUIAutomationElement *element, *element2, *element3; + struct Provider_prop_override prop_override; IUIAutomationCacheRequest *cache_req; IUIAutomationElementArray *elem_arr; - int tmp_rt_id[2], i, len; + int tmp_rt_id[2], i, len, tmp_int; IUnknown *unk_ns; + BSTR tmp_bstr; + BOOL tmp_bool; HRESULT hr; + RECT rect; VARIANT v; element = create_test_element_from_hwnd(uia_iface, hwnd, TRUE); @@ -13534,6 +13540,175 @@ static void test_Element_cache_methods(IUIAutomation *uia_iface) ok(Provider.ref == 1, "Unexpected refcnt %ld\n", Provider.ref); IUnknown_Release(unk_ns); + /* + * Windows 7 will call get_FragmentRoot in an endless loop until the fragment root returns an HWND. + * It's the only version with this behavior. + */ + if (!UiaLookupId(AutomationIdentifierType_Property, &OptimizeForVisualContent_Property_GUID)) + { + win_skip("Skipping cached UIA_BoundingRectanglePropertyId tests for Win7\n"); + goto exit; + } + + /* + * Cached property value helper function tests. + */ + element = create_test_element_from_hwnd(uia_iface, hwnd, TRUE); + method_sequences_enabled = FALSE; + + /* + * element has no cached values, element2 has cached values but they're + * all the equivalent of VT_EMPTY, element3 has valid cached values. + */ + cache_req = NULL; + hr = IUIAutomation_CreateCacheRequest(uia_iface, &cache_req); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!!cache_req, "cache_req == NULL\n"); + + for (i = 0; i < ARRAY_SIZE(cache_test_props); i++) + { + hr = IUIAutomationCacheRequest_AddProperty(cache_req, cache_test_props[i]); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + } + + /* element2, invalid values for all cached properties. */ + element2 = NULL; + Provider.ret_invalid_prop_type = TRUE; + set_uia_rect(&Provider.bounds_rect, 0, 0, 0, 0); + hr = IUIAutomationElement_BuildUpdatedCache(element, cache_req, &element2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!!element2, "element2 == NULL\n"); + Provider.ret_invalid_prop_type = FALSE; + + /* element3, valid values for all cached properties. */ + V_VT(&v) = VT_I4; + V_I4(&v) = UIA_HyperlinkControlTypeId; + set_property_override(&prop_override, UIA_ControlTypePropertyId, &v); + set_provider_prop_override(&Provider, &prop_override, 1); + set_uia_rect(&Provider.bounds_rect, 0, 0, 50, 50); + + element3 = NULL; + hr = IUIAutomationElement_BuildUpdatedCache(element, cache_req, &element3); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!!element3, "element3 == NULL\n"); + set_provider_prop_override(&Provider, NULL, 0); + + IUIAutomationCacheRequest_Release(cache_req); + + /* Cached UIA_HasKeyboardFocusPropertyId helper. */ + hr = IUIAutomationElement_get_CachedHasKeyboardFocus(element, NULL); + todo_wine ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + + tmp_bool = 0xdeadbeef; + hr = IUIAutomationElement_get_CachedHasKeyboardFocus(element, &tmp_bool); + todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + ok(tmp_bool == 0xdeadbeef, "Unexpected tmp_bool %d\n", tmp_bool); + + tmp_bool = 0xdeadbeef; + hr = IUIAutomationElement_get_CachedHasKeyboardFocus(element2, &tmp_bool); + todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine ok(!tmp_bool, "tmp_bool != FALSE\n"); + + tmp_bool = FALSE; + hr = IUIAutomationElement_get_CachedHasKeyboardFocus(element3, &tmp_bool); + todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine ok(!!tmp_bool, "tmp_bool == FALSE\n"); + + /* Cached UIA_IsKeyboardFocusablePropertyId helper. */ + hr = IUIAutomationElement_get_CachedIsKeyboardFocusable(element, NULL); + todo_wine ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + + tmp_bool = 0xdeadbeef; + hr = IUIAutomationElement_get_CachedIsKeyboardFocusable(element, &tmp_bool); + todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + ok(tmp_bool == 0xdeadbeef, "Unexpected tmp_bool %d\n", tmp_bool); + + tmp_bool = 0xdeadbeef; + hr = IUIAutomationElement_get_CachedIsKeyboardFocusable(element2, &tmp_bool); + todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine ok(!tmp_bool, "tmp_bool != FALSE\n"); + + tmp_bool = FALSE; + hr = IUIAutomationElement_get_CachedIsKeyboardFocusable(element3, &tmp_bool); + todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine ok(!!tmp_bool, "tmp_bool == FALSE\n"); + + /* Cached UIA_NamePropertyId helper. */ + hr = IUIAutomationElement_get_CachedName(element, NULL); + todo_wine ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + + tmp_bstr = (void *)0xdeadbeef; + hr = IUIAutomationElement_get_CachedName(element, &tmp_bstr); + todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + ok(tmp_bstr == (void *)0xdeadbeef, "Unexpected BSTR ptr %p\n", tmp_bstr); + + tmp_bstr = NULL; + hr = IUIAutomationElement_get_CachedName(element2, &tmp_bstr); + todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + ok(!lstrcmpW(tmp_bstr, L""), "Unexpected BSTR %s\n", wine_dbgstr_w(tmp_bstr)); + SysFreeString(tmp_bstr); + + tmp_bstr = NULL; + hr = IUIAutomationElement_get_CachedName(element3, &tmp_bstr); + todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + ok(!lstrcmpW(tmp_bstr, uia_bstr_prop_str), "Unexpected BSTR %s\n", wine_dbgstr_w(tmp_bstr)); + SysFreeString(tmp_bstr); + + /* Cached UIA_ControlTypePropertyId. */ + hr = IUIAutomationElement_get_CachedControlType(element, NULL); + todo_wine ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + + tmp_int = 0xdeadbeef; + hr = IUIAutomationElement_get_CachedControlType(element, &tmp_int); + todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + ok(tmp_int == 0xdeadbeef, "Unexpected control type %#x\n", tmp_int); + + tmp_int = 0; + hr = IUIAutomationElement_get_CachedControlType(element2, &tmp_int); + todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine ok(tmp_int == UIA_CustomControlTypeId, "Unexpected control type %#x\n", tmp_int); + + tmp_int = 0; + hr = IUIAutomationElement_get_CachedControlType(element3, &tmp_int); + todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine ok(tmp_int == UIA_HyperlinkControlTypeId, "Unexpected control type %#x\n", tmp_int); + + /* Cached UIA_BoundingRectanglePropertyId helper. */ + hr = IUIAutomationElement_get_CachedBoundingRectangle(element, NULL); + todo_wine ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + + rect.left = rect.top = rect.bottom = rect.right = 1; + hr = IUIAutomationElement_get_CachedBoundingRectangle(element, &rect); + todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + ok(rect.left == 1, "Unexpected rect left %ld\n", rect.left); + ok(rect.top == 1, "Unexpected rect top %ld\n", rect.top); + ok(rect.right == 1, "Unexpected rect right %ld\n", rect.right); + ok(rect.bottom == 1, "Unexpected rect bottom %ld\n", rect.bottom); + + rect.left = rect.top = rect.bottom = rect.right = 1; + hr = IUIAutomationElement_get_CachedBoundingRectangle(element2, &rect); + todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine ok(!rect.left, "Unexpected rect left %ld\n", rect.left); + todo_wine ok(!rect.top, "Unexpected rect top %ld\n", rect.top); + todo_wine ok(!rect.right, "Unexpected rect right %ld\n", rect.right); + todo_wine ok(!rect.bottom, "Unexpected rect bottom %ld\n", rect.bottom); + + memset(&rect, 0, sizeof(rect)); + hr = IUIAutomationElement_get_CachedBoundingRectangle(element3, &rect); + todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + check_uia_rect_rect_val(&rect, &Provider.bounds_rect); + + IUIAutomationElement_Release(element3); + IUIAutomationElement_Release(element2); + IUIAutomationElement_Release(element); + + set_uia_rect(&Provider.bounds_rect, 0, 0, 0, 0); + method_sequences_enabled = TRUE; + +exit: DestroyWindow(hwnd); UnregisterClassA("test_Element_cache_methods class", NULL); }
1
0
0
0
Brendan Shanks : configure: Only build Wayland if linux/input.h is present.
by Alexandre Julliard
18 Oct '23
18 Oct '23
Module: wine Branch: master Commit: 83e80e9b600d220a5362949e64342aa9b9906c6e URL:
https://gitlab.winehq.org/wine/wine/-/commit/83e80e9b600d220a5362949e64342a…
Author: Brendan Shanks <bshanks(a)codeweavers.com> Date: Tue Oct 17 11:18:29 2023 -0700 configure: Only build Wayland if linux/input.h is present. --- configure | 2 +- configure.ac | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index d496a28f982..9fd92bbf6f6 100755 --- a/configure +++ b/configure @@ -15710,7 +15710,7 @@ fi CPPFLAGS=$ac_save_CPPFLAGS fi -if test -z "$WAYLAND_CLIENT_LIBS" -o -z "$WAYLAND_SCANNER" +if test -z "$WAYLAND_CLIENT_LIBS" -o -z "$WAYLAND_SCANNER" -o "$ac_cv_header_linux_input_h" = "no" then : case "x$with_wayland" in x) as_fn_append wine_notices "|Wayland ${notice_platform}development files not found, the Wayland driver won't be supported." ;; diff --git a/configure.ac b/configure.ac index 599d18eee43..6aa46659293 100644 --- a/configure.ac +++ b/configure.ac @@ -1373,7 +1373,7 @@ then [`test -n "$PKG_CONFIG" && $PKG_CONFIG --variable=wayland_scanner wayland-scanner 2>/dev/null`])], [WAYLAND_CLIENT_LIBS=""],[$WAYLAND_CLIENT_LIBS])])]) fi -WINE_NOTICE_WITH(wayland, [test -z "$WAYLAND_CLIENT_LIBS" -o -z "$WAYLAND_SCANNER"], +WINE_NOTICE_WITH(wayland, [test -z "$WAYLAND_CLIENT_LIBS" -o -z "$WAYLAND_SCANNER" -o "$ac_cv_header_linux_input_h" = "no"], [Wayland ${notice_platform}development files not found, the Wayland driver won't be supported.], [enable_winewayland_drv])
1
0
0
0
← Newer
1
...
21
22
23
24
25
26
27
...
71
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Results per page:
10
25
50
100
200