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
June 2022
----- 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
2 participants
791 discussions
Start a n
N
ew thread
Akihiro Sagawa : msvcrt: Avoid passing an invalid LCID to LCMapStringW.
by Alexandre Julliard
09 Jun '22
09 Jun '22
Module: wine Branch: master Commit: b4f20eec463d5bffe543305eeab4875074080e04 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=b4f20eec463d5bffe543305e…
Author: Akihiro Sagawa <sagawa.aki(a)gmail.com> Date: Wed Jun 8 21:38:02 2022 +0900 msvcrt: Avoid passing an invalid LCID to LCMapStringW. Because it complains as follows on startup in Japanese locale: 002c:err:msvcrt:create_mbcinfo WideCharToMultiByte failed for cp 932, ret=0 (exp 196), error=122 This happens after commit c2a455a20d7b5124bab0086df75178d8c53f27ef. Signed-off-by: Akihiro Sagawa <sagawa.aki(a)gmail.com> Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/msvcrt/mbcs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/msvcrt/mbcs.c b/dlls/msvcrt/mbcs.c index fa25a7092e3..dc9abca1b44 100644 --- a/dlls/msvcrt/mbcs.c +++ b/dlls/msvcrt/mbcs.c @@ -333,8 +333,8 @@ threadmbcinfo* create_mbcinfo(int cp, LCID lcid, threadmbcinfo *old_mbcinfo) } GetStringTypeW(CT_CTYPE1, bufW, charcount, chartypes); - LCMapStringW(lcid, LCMAP_LOWERCASE, bufW, charcount, lowW, charcount); - LCMapStringW(lcid, LCMAP_UPPERCASE, bufW, charcount, upW, charcount); + LCMapStringW(mbcinfo->mblcid, LCMAP_LOWERCASE, bufW, charcount, lowW, charcount); + LCMapStringW(mbcinfo->mblcid, LCMAP_UPPERCASE, bufW, charcount, upW, charcount); charcount = 0; for (i = 0; i < maxchar; i++)
1
0
0
0
Alexandre Julliard : ntdll: Move the user locale initialization to the Unix side.
by Alexandre Julliard
09 Jun '22
09 Jun '22
Module: wine Branch: master Commit: 21a1c3097236e7de6451ce13958a6dc7edf27285 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=21a1c3097236e7de6451ce13…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Thu Jun 9 12:41:29 2022 +0200 ntdll: Move the user locale initialization to the Unix side. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/locale.c | 16 +--------------- dlls/ntdll/unix/env.c | 51 ++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 37 insertions(+), 30 deletions(-) diff --git a/dlls/ntdll/locale.c b/dlls/ntdll/locale.c index b5a11c41516..b4bfdf48f0c 100644 --- a/dlls/ntdll/locale.c +++ b/dlls/ntdll/locale.c @@ -92,10 +92,9 @@ void locale_init(void) { USHORT utf8[2] = { 0, CP_UTF8 }; WCHAR locale[LOCALE_NAME_MAX_LENGTH]; - UNICODE_STRING name, value; LARGE_INTEGER unused; SIZE_T size; - LCID system_lcid, user_lcid = 0; + LCID system_lcid; UINT ansi_cp = 1252, oem_cp = 437; void *ansi_ptr = utf8, *oem_ptr = utf8, *case_ptr; NTSTATUS status; @@ -109,21 +108,8 @@ void locale_init(void) } locale_table = (const NLS_LOCALE_HEADER *)((char *)header + header->locales); - value.Buffer = locale; - value.MaximumLength = sizeof(locale); - RtlInitUnicodeString( &name, L"WINEUSERLOCALE" ); - if (!RtlQueryEnvironmentVariable_U( NULL, &name, &value )) - { - const NLS_LOCALE_LCNAME_INDEX *entry = find_lcname_entry( locale_table, locale ); - if (entry) user_lcid = get_locale_data( locale_table, entry->idx )->idefaultlanguage; - } - if (!user_lcid) user_lcid = system_lcid; - NtSetDefaultUILanguage( user_lcid ); - NtSetDefaultLocale( TRUE, user_lcid ); - if (system_lcid == LOCALE_CUSTOM_UNSPECIFIED) { - system_lcid = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT ); ansi_cp = oem_cp = CP_UTF8; } else diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c index 6f67ed40245..a71df03966f 100644 --- a/dlls/ntdll/unix/env.c +++ b/dlls/ntdll/unix/env.c @@ -113,13 +113,17 @@ static char *get_nls_file_path( ULONG type, ULONG id ) return path; } -static void *read_nls_file( ULONG type, ULONG id ) +static void *read_nls_file( const char *name ) { - char *path = get_nls_file_path( type, id ); + const char *dir = build_dir ? build_dir : data_dir; + char *path; struct stat st; void *data, *ret = NULL; int fd; + if (!(path = malloc( strlen(dir) + strlen(name) + 10 ))) return NULL; + sprintf( path, "%s/nls/%s", dir, name ); + if ((fd = open( path, O_RDONLY )) != -1) { fstat( fd, &st ); @@ -135,7 +139,7 @@ static void *read_nls_file( ULONG type, ULONG id ) } close( fd ); } - else ERR( "failed to load %u/%u\n", type, id ); + else ERR( "failed to load %s\n", path ); free( path ); return ret; } @@ -201,7 +205,7 @@ static struct norm_table *nfc_table; static void init_unix_codepage(void) { - nfc_table = read_nls_file( NLS_SECTION_NORMALIZE, NormalizationC ); + nfc_table = read_nls_file( "normnfc.nls" ); } #elif defined(__ANDROID__) /* Android always uses UTF-8 */ @@ -297,8 +301,11 @@ static void init_unix_codepage(void) { if (charset_names[pos].cp != CP_UTF8) { - void *data = read_nls_file( NLS_SECTION_CODEPAGE, charset_names[pos].cp ); - if (data) init_codepage_table( data, &unix_cp ); + char buffer[16]; + void *data; + + sprintf( buffer, "c_%03u.nls", charset_names[pos].cp ); + if ((data = read_nls_file( buffer ))) init_codepage_table( data, &unix_cp ); } return; } @@ -761,17 +768,14 @@ static BOOL unix_to_win_locale( const char *unix_name, char *win_name ) } -static LCID init_system_lcid( const struct locale_nls_header *header ) +static const NLS_LOCALE_DATA *get_win_locale( const NLS_LOCALE_HEADER *header, const char *win_name ) { WCHAR name[LOCALE_NAME_MAX_LENGTH]; - const NLS_LOCALE_HEADER *locale_table = (const NLS_LOCALE_HEADER *)((char *)header + header->locales); const NLS_LOCALE_LCNAME_INDEX *entry; - ascii_to_unicode( name, system_locale, strlen(system_locale) + 1 ); - if ((entry = find_lcname_entry( locale_table, name ))) - return get_locale_data( locale_table, entry->idx )->idefaultlanguage; - - return MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT ); + ascii_to_unicode( name, win_name, strlen(win_name) + 1 ); + if (!(entry = find_lcname_entry( header, name ))) return NULL; + return get_locale_data( header, entry->idx ); } @@ -780,6 +784,10 @@ static LCID init_system_lcid( const struct locale_nls_header *header ) */ static void init_locale(void) { + struct locale_nls_header *header; + const NLS_LOCALE_HEADER *locale_table; + const NLS_LOCALE_DATA *locale; + setlocale( LC_ALL, "" ); if (!unix_to_win_locale( setlocale( LC_CTYPE, NULL ), system_locale )) system_locale[0] = 0; if (!unix_to_win_locale( setlocale( LC_MESSAGES, NULL ), user_locale )) user_locale[0] = 0; @@ -834,6 +842,20 @@ static void init_locale(void) if (preferred_langs) CFRelease( preferred_langs ); } #endif + + if ((header = read_nls_file( "locale.nls" ))) + { + locale_table = (const NLS_LOCALE_HEADER *)((char *)header + header->locales); + if ((locale = get_win_locale( locale_table, system_locale ))) + system_lcid = locale->idefaultlanguage; + if ((locale = get_win_locale( locale_table, user_locale ))) + user_lcid = locale->idefaultlanguage; + free( header ); + } + if (!system_lcid) system_lcid = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT ); + if (!user_lcid) user_lcid = system_lcid; + user_ui_language = user_lcid; + setlocale( LC_NUMERIC, "C" ); /* FIXME: oleaut32 depends on this */ } @@ -848,7 +870,7 @@ void init_environment( int argc, char *argv[], char *envp[] ) init_unix_codepage(); init_locale(); - if ((case_table = read_nls_file( NLS_SECTION_CASEMAP, 0 ))) + if ((case_table = read_nls_file( "l_intl.nls" ))) { uctable = case_table + 2; lctable = case_table + case_table[1] + 2; @@ -2190,7 +2212,6 @@ NTSTATUS WINAPI NtInitializeNlsFiles( void **ptr, LCID *lcid, LARGE_INTEGER *siz status = map_section( handle, ptr, &mapsize, PAGE_READONLY ); NtClose( handle ); } - if (!status && !system_lcid) system_lcid = init_system_lcid( *ptr ); *lcid = system_lcid; return status; }
1
0
0
0
Alexandre Julliard : ntdll: Share a few more locale functions with the Unix side.
by Alexandre Julliard
09 Jun '22
09 Jun '22
Module: wine Branch: master Commit: c5eb9cb25e2262fc27479bd9143c5751a34775e0 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=c5eb9cb25e2262fc27479bd9…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Thu Jun 9 12:06:47 2022 +0200 ntdll: Share a few more locale functions with the Unix side. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/locale.c | 113 ++++++++------------------------------------ dlls/ntdll/locale_private.h | 78 ++++++++++++++++++++++++++++++ dlls/ntdll/unix/env.c | 41 +++------------- 3 files changed, 105 insertions(+), 127 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=c5eb9cb25e2262fc2747…
1
0
0
0
Paul Gofman : ws2_32/tests: Add tests for terminated thread asyncs completion.
by Alexandre Julliard
09 Jun '22
09 Jun '22
Module: wine Branch: master Commit: ab88f34de6a947b6e1e7d1b4045de1c5b582e433 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=ab88f34de6a947b6e1e7d1b4…
Author: Paul Gofman <pgofman(a)codeweavers.com> Date: Thu May 26 14:48:17 2022 -0500 ws2_32/tests: Add tests for terminated thread asyncs completion. Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com> --- dlls/ws2_32/tests/afd.c | 212 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 212 insertions(+) diff --git a/dlls/ws2_32/tests/afd.c b/dlls/ws2_32/tests/afd.c index 5b64ccd7715..fe3c2ef2ff6 100644 --- a/dlls/ws2_32/tests/afd.c +++ b/dlls/ws2_32/tests/afd.c @@ -2355,6 +2355,217 @@ static void test_getsockname(void) CloseHandle(event); } +struct ioctl_params +{ + HANDLE handle, event; + PIO_APC_ROUTINE apc; + void *apc_context; + IO_STATUS_BLOCK *io; + ULONG code; + void *in_buffer; + ULONG in_size; + void *out_buffer; + ULONG out_size; + NTSTATUS ret; + HANDLE complete_event; + BOOL kill_thread; +}; + +static DWORD WINAPI async_ioctl_thread(void *params) +{ + struct ioctl_params *io = params; + + io->ret = NtDeviceIoControlFile(io->handle, io->event, io->apc, io->apc_context, io->io, + io->code, io->in_buffer, io->in_size, io->out_buffer, io->out_size); + SetEvent(io->complete_event); + if (io->kill_thread) + Sleep(3000); + return io->ret; +} + +static NTSTATUS WINAPI thread_NtDeviceIoControlFile(BOOL kill_thread, HANDLE handle, HANDLE event, + PIO_APC_ROUTINE apc, void *apc_context, IO_STATUS_BLOCK *io, ULONG code, void *in_buffer, ULONG in_size, + void *out_buffer, ULONG out_size) +{ + struct ioctl_params p; + HANDLE thread; + DWORD ret; + + p.handle = handle; + p.event = event; + p.apc = apc; + p.apc_context = apc_context; + p.io = io; + p.code = code; + p.in_buffer = in_buffer; + p.in_size = in_size; + p.out_buffer = out_buffer; + p.out_size = out_size; + p.complete_event = CreateEventW(NULL, FALSE, FALSE, NULL); + p.kill_thread = kill_thread; + + thread = CreateThread(NULL, 0, async_ioctl_thread, &p, 0, NULL); + ok(!!thread, "got NULL.\n"); + ret = WaitForSingleObject(p.complete_event, INFINITE); + ok(ret == WAIT_OBJECT_0, "got ret %#lx.\n", ret); + if (kill_thread) + TerminateThread(thread, -1); + CloseHandle(p.complete_event); + ret = WaitForSingleObject(thread, INFINITE); + ok(ret == WAIT_OBJECT_0, "got ret %#lx.\n", ret); + CloseHandle(thread); + SleepEx(0, TRUE); + return p.ret; +} + +static unsigned int test_async_thread_termination_apc_count; + +static void WINAPI test_async_thread_termination_apc( void *arg, IO_STATUS_BLOCK *iosb, ULONG reserved ) +{ + ++test_async_thread_termination_apc_count; +} + +static void test_async_thread_termination(void) +{ + static const struct + { + BOOL kill_thread; + BOOL event; + PIO_APC_ROUTINE apc; + void *apc_context; + } + tests[] = + { + {FALSE, TRUE, NULL, NULL}, + {TRUE, TRUE, NULL, NULL}, + {FALSE, FALSE, NULL, NULL}, + {TRUE, FALSE, NULL, NULL}, + {FALSE, TRUE, test_async_thread_termination_apc, NULL}, + {TRUE, TRUE, test_async_thread_termination_apc, NULL}, + {FALSE, FALSE, test_async_thread_termination_apc, NULL}, + {TRUE, FALSE, test_async_thread_termination_apc, NULL}, + {FALSE, TRUE, NULL, (void *)0xdeadbeef}, + {TRUE, TRUE, NULL, (void *)0xdeadbeef}, + {FALSE, FALSE, NULL, (void *)0xdeadbeef}, + {TRUE, FALSE, NULL, (void *)0xdeadbeef}, + {FALSE, TRUE, test_async_thread_termination_apc, (void *)0xdeadbeef}, + {TRUE, TRUE, test_async_thread_termination_apc, (void *)0xdeadbeef}, + {FALSE, FALSE, test_async_thread_termination_apc, (void *)0xdeadbeef}, + {TRUE, FALSE, test_async_thread_termination_apc, (void *)0xdeadbeef}, + }; + + const struct sockaddr_in bind_addr = {.sin_family = AF_INET, .sin_addr.s_addr = htonl(INADDR_LOOPBACK)}; + char in_buffer[offsetof(struct afd_poll_params, sockets[3])]; + char out_buffer[offsetof(struct afd_poll_params, sockets[3])]; + struct afd_poll_params *in_params = (struct afd_poll_params *)in_buffer; + struct afd_poll_params *out_params = (struct afd_poll_params *)out_buffer; + LARGE_INTEGER zero = {{0}}; + ULONG_PTR key, value; + IO_STATUS_BLOCK io; + HANDLE event, port; + ULONG params_size; + SOCKET listener; + unsigned int i; + int ret; + + event = CreateEventW(NULL, FALSE, FALSE, NULL); + + listener = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + ret = bind(listener, (const struct sockaddr *)&bind_addr, sizeof(bind_addr)); + ok(!ret, "got error %u\n", WSAGetLastError()); + ret = listen(listener, 1); + ok(!ret, "got error %u\n", WSAGetLastError()); + + in_params->count = 1; + in_params->exclusive = FALSE; + in_params->sockets[0].socket = listener; + in_params->sockets[0].flags = ~0; + in_params->sockets[0].status = 0xdeadbeef; + params_size = offsetof(struct afd_poll_params, sockets[1]); + in_params->timeout = -10 * 1000 * 1000 * 5; + + /* asyncs without completion port are always cancelled on thread exit. */ + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + winetest_push_context("test %u", i); + memset(&io, 0xcc, sizeof(io)); + ResetEvent(event); + ret = thread_NtDeviceIoControlFile(tests[i].kill_thread, (HANDLE)listener, tests[i].event ? event : NULL, + tests[i].apc, tests[i].apc_context, &io, IOCTL_AFD_POLL, in_params, params_size, + out_params, params_size); + ok(ret == STATUS_PENDING, "got %#x\n", ret); + ok(io.Status == STATUS_CANCELLED, "got %#lx\n", io.Status); + if (tests[i].event) + { + ret = WaitForSingleObject(event, 1000); + ok(!ret, "got %#x\n", ret); + } + winetest_pop_context(); + } + + SleepEx(0, TRUE); + ok(!test_async_thread_termination_apc_count, "got APC.\n"); + + port = CreateIoCompletionPort((HANDLE)listener, NULL, 0, 0); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + winetest_push_context("test %u", i); + memset(&io, 0xcc, sizeof(io)); + ResetEvent(event); + ret = thread_NtDeviceIoControlFile(tests[i].kill_thread, (HANDLE)listener, tests[i].event ? event : NULL, + tests[i].apc, tests[i].apc_context, &io, IOCTL_AFD_POLL, in_params, params_size, + out_params, params_size); + if (tests[i].apc) + { + ok(ret == STATUS_INVALID_PARAMETER, "got %#x\n", ret); + winetest_pop_context(); + continue; + } + ok(ret == STATUS_PENDING, "got %#x\n", ret); + if (!tests[i].apc_context || tests[i].event) + { + ok(io.Status == STATUS_CANCELLED, "got %#lx\n", io.Status); + memset(&io, 0xcc, sizeof(io)); + key = 0xcc; + value = 0; + ret = NtRemoveIoCompletion(port, &key, &value, &io, &zero); + if (tests[i].apc_context) + { + ok(!ret, "got %#x\n", ret); + ok(!key, "got key %#Ix\n", key); + ok(value == 0xdeadbeef, "got value %#Ix\n", value); + ok(io.Status == STATUS_CANCELLED, "got %#lx\n", io.Status); + } + else + { + ok(ret == WAIT_TIMEOUT, "got %#x\n", ret); + } + winetest_pop_context(); + continue; + } + + /* async is not cancelled if there is a completion port, completion key and no event. */ + ok(io.Status == 0xcccccccc, "got %#lx\n", io.Status); + memset(&io, 0xcc, sizeof(io)); + key = 0xcc; + value = 0; + ret = NtRemoveIoCompletion(port, &key, &value, &io, &zero); + ok(ret == WAIT_TIMEOUT, "got %#x\n", ret); + CancelIoEx((HANDLE)listener, NULL); + ret = NtRemoveIoCompletion(port, &key, &value, &io, &zero); + ok(!ret, "got %#x\n", ret); + ok(!key, "got key %#Ix\n", key); + ok(value == 0xdeadbeef, "got value %#Ix\n", value); + ok(io.Status == STATUS_CANCELLED, "got %#lx\n", io.Status); + winetest_pop_context(); + } + + CloseHandle(port); + CloseHandle(event); + closesocket(listener); +} + START_TEST(afd) { WSADATA data; @@ -2372,6 +2583,7 @@ START_TEST(afd) test_get_events_reset(); test_bind(); test_getsockname(); + test_async_thread_termination(); WSACleanup(); }
1
0
0
0
Paul Gofman : ntdll: Cancel asyncs when thread is terminated.
by Alexandre Julliard
09 Jun '22
09 Jun '22
Module: wine Branch: master Commit: 7c597313f801c093dce2a16c3770c4f989c5209e URL:
https://source.winehq.org/git/wine.git/?a=commit;h=7c597313f801c093dce2a16c…
Author: Paul Gofman <pgofman(a)codeweavers.com> Date: Thu May 26 13:41:47 2022 -0500 ntdll: Cancel asyncs when thread is terminated. Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com> --- dlls/ntdll/unix/thread.c | 24 +++++++++++++----------- server/async.c | 16 ++++++++++++++++ server/file.h | 1 + server/thread.c | 1 + 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c index 15bb3be34b2..ad47a5fce74 100644 --- a/dlls/ntdll/unix/thread.c +++ b/dlls/ntdll/unix/thread.c @@ -1610,20 +1610,22 @@ NTSTATUS WINAPI NtAlertThread( HANDLE handle ) NTSTATUS WINAPI NtTerminateThread( HANDLE handle, LONG exit_code ) { NTSTATUS ret; - BOOL self = (handle == GetCurrentThread()); + BOOL self; - if (!self || exit_code) + SERVER_START_REQ( terminate_thread ) { - SERVER_START_REQ( terminate_thread ) - { - req->handle = wine_server_obj_handle( handle ); - req->exit_code = exit_code; - ret = wine_server_call( req ); - self = !ret && reply->self; - } - SERVER_END_REQ; + req->handle = wine_server_obj_handle( handle ); + req->exit_code = exit_code; + ret = wine_server_call( req ); + self = !ret && reply->self; + } + SERVER_END_REQ; + + if (self) + { + server_select( NULL, 0, SELECT_INTERRUPTIBLE, 0, NULL, NULL ); + exit_thread( exit_code ); } - if (self) exit_thread( exit_code ); return ret; } diff --git a/server/async.c b/server/async.c index a4fbeab555e..4832d69b7bf 100644 --- a/server/async.c +++ b/server/async.c @@ -593,6 +593,22 @@ void cancel_process_asyncs( struct process *process ) cancel_async( process, NULL, NULL, 0 ); } +void cancel_terminating_thread_asyncs( struct thread *thread ) +{ + struct async *async; + +restart: + LIST_FOR_EACH_ENTRY( async, &thread->process->asyncs, struct async, process_entry ) + { + if (async->thread != thread || async->terminated || async->canceled) continue; + if (async->completion && async->data.apc_context && !async->event) continue; + + async->canceled = 1; + fd_cancel_async( async->fd, async ); + goto restart; + } +} + /* wake up async operations on the queue */ void async_wake_up( struct async_queue *queue, unsigned int status ) { diff --git a/server/file.h b/server/file.h index 9f9d4cd4e1a..0ffe0e2c8dc 100644 --- a/server/file.h +++ b/server/file.h @@ -245,6 +245,7 @@ extern struct iosb *async_get_iosb( struct async *async ); extern struct thread *async_get_thread( struct async *async ); extern struct async *find_pending_async( struct async_queue *queue ); extern void cancel_process_asyncs( struct process *process ); +extern void cancel_terminating_thread_asyncs( struct thread *thread ); static inline void init_async_queue( struct async_queue *queue ) { diff --git a/server/thread.c b/server/thread.c index 467ccd1f0db..f49fbf40b78 100644 --- a/server/thread.c +++ b/server/thread.c @@ -1462,6 +1462,7 @@ DECL_HANDLER(terminate_thread) thread->exit_code = req->exit_code; if (thread != current) kill_thread( thread, 1 ); else reply->self = 1; + cancel_terminating_thread_asyncs( thread ); release_object( thread ); } }
1
0
0
0
Paul Gofman : ws2_32: Check for valid socket in WSAGetOverlappedResult().
by Alexandre Julliard
09 Jun '22
09 Jun '22
Module: wine Branch: master Commit: 5a8ccc15a2bc2b6e599e27356fba4b2a978fe75e URL:
https://source.winehq.org/git/wine.git/?a=commit;h=5a8ccc15a2bc2b6e599e2735…
Author: Paul Gofman <pgofman(a)codeweavers.com> Date: Tue Jun 7 14:06:54 2022 -0500 ws2_32: Check for valid socket in WSAGetOverlappedResult(). Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com> --- dlls/ws2_32/socket.c | 6 ++++++ dlls/ws2_32/tests/sock.c | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 6a93d00730a..964724b36e7 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -3626,6 +3626,12 @@ BOOL WINAPI WSAGetOverlappedResult( SOCKET s, LPWSAOVERLAPPED lpOverlapped, return FALSE; } + if (!socket_list_find( s )) + { + SetLastError( WSAENOTSOCK ); + return FALSE; + } + status = lpOverlapped->Internal; if (status == STATUS_PENDING) { diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 4a4a3a84e51..22e414e02ec 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -11848,6 +11848,7 @@ static void test_WSAGetOverlappedResult(void) NTSTATUS status; unsigned int i; SOCKET s; + HANDLE h; BOOL ret; static const NTSTATUS ranges[][2] = @@ -11862,8 +11863,20 @@ static void test_WSAGetOverlappedResult(void) {0xd0070000, 0xd0080000}, }; + WSASetLastError(0xdeadbeef); + ret = WSAGetOverlappedResult(0xdeadbeef, &overlapped, &size, FALSE, &flags); + ok(!ret, "got %d.\n", ret); + ok(WSAGetLastError() == WSAENOTSOCK, "got %u.\n", WSAGetLastError()); + s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + ret = DuplicateHandle(GetCurrentProcess(), (HANDLE)s, GetCurrentProcess(), &h, 0, FALSE, DUPLICATE_SAME_ACCESS); + ok(ret, "got %d.\n", ret); + ret = WSAGetOverlappedResult((SOCKET)h, &overlapped, &size, FALSE, &flags); + ok(!ret, "got %d.\n", ret); + ok(WSAGetLastError() == WSAENOTSOCK, "got %u.\n", WSAGetLastError()); + CloseHandle(h); + for (i = 0; i < ARRAY_SIZE(ranges); ++i) { for (status = ranges[i][0]; status < ranges[i][1]; ++status)
1
0
0
0
Martin Storsjö : ntdll/tests: Test returning an exception handler on arm/arm64.
by Alexandre Julliard
09 Jun '22
09 Jun '22
Module: wine Branch: master Commit: 94dc5714ac19ab5d3347c55b8698823c5d62625b URL:
https://source.winehq.org/git/wine.git/?a=commit;h=94dc5714ac19ab5d3347c55b…
Author: Martin Storsjö <martin(a)martin.st> Date: Thu Jun 9 11:03:42 2022 +0300 ntdll/tests: Test returning an exception handler on arm/arm64. Signed-off-by: Martin Storsjö <martin(a)martin.st> --- dlls/ntdll/tests/exception.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index 2089f3ed3d8..820e435bc1b 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -5140,7 +5140,6 @@ static void call_virtual_unwind( int testnum, const struct unwind_test *test ) &runtime_func, &context, &data, &frame, &ctx_ptr ); if (test->results[i].handler > 0) { - /* Yet untested */ ok( (char *)handler == (char *)code_mem + 0x200, "%u/%u: wrong handler %p/%p\n", testnum, i, handler, (char *)code_mem + 0x200 ); if (handler) ok( *(DWORD *)data == 0x08070605, @@ -5278,7 +5277,7 @@ static void test_virtual_unwind(void) static const DWORD unwind_info_0_header = (sizeof(function_0)/2) | /* function length */ - (0 << 20) | /* X */ + (1 << 20) | /* X */ (0 << 21) | /* E */ (0 << 22) | /* F */ (1 << 23) | /* epilog */ @@ -5309,6 +5308,10 @@ static void test_virtual_unwind(void) UWOP_ALLOC_SMALL(32), /* add sp, sp, #32 */ UWOP_SAVE_RANGE_4_7_LR(6, 1), /* pop {r4-r6,pc} */ UWOP_END, + + 0, 0, /* align */ + 0x00, 0x02, 0x00, 0x00, /* handler */ + 0x05, 0x06, 0x07, 0x08, /* data */ }; static const struct results results_0[] = @@ -5323,7 +5326,7 @@ static void test_virtual_unwind(void) { 0x12, 0x10, 0, 0x5c, 0x060, TRUE, { {r4,0x50}, {r5,0x54}, {r6,0x58}, {lr,0x5c}, {d8, 0x1c00000018}, {d9, 0x2400000020}, {d10, 0x2c00000028}, {d3, 0x400000000}, {d4, 0xc00000008}, {d5, 0x1400000010}, {-1,-1} }}, { 0x16, 0x10, 0, 0x74, 0x078, TRUE, { {r4,0x68}, {r5,0x6c}, {r6,0x70}, {lr,0x74}, {d8, 0x3400000030}, {d9, 0x3c00000038}, {d10, 0x4400000040}, {d3, 0x1c00000018}, {d4, 0x2400000020}, {d5, 0x2c00000028}, {d17, 0x400000000}, {d18, 0xc00000008}, {d19, 0x1400000010}, {-1,-1} }}, { 0x1a, 0x10, 0, 0x80, 0x084, TRUE, { {r4,0x74}, {r5,0x78}, {r6,0x7c}, {lr,0x80}, {d8, 0x400000003c}, {d9, 0x4800000044}, {d10, 0x500000004c}, {d3, 0x2800000024}, {d4, 0x300000002c}, {d5, 0x3800000034}, {d17, 0x100000000c}, {d18, 0x1800000014}, {d19, 0x200000001c}, {r8,0x00}, {r10,0x04}, {r12,0x08}, {-1,-1} }}, - { 0x1c, 0x10, 0, 0x90, 0x094, TRUE, { {r4,0x84}, {r5,0x88}, {r6,0x8c}, {lr,0x90}, {d8, 0x500000004c}, {d9, 0x5800000054}, {d10, 0x600000005c}, {d3, 0x3800000034}, {d4, 0x400000003c}, {d5, 0x4800000044}, {d17, 0x200000001c}, {d18, 0x2800000024}, {d19, 0x300000002c}, {r8,0x10}, {r10,0x14}, {r12,0x18}, {-1,-1} }}, + { 0x1c, 0x10, 1, 0x90, 0x094, TRUE, { {r4,0x84}, {r5,0x88}, {r6,0x8c}, {lr,0x90}, {d8, 0x500000004c}, {d9, 0x5800000054}, {d10, 0x600000005c}, {d3, 0x3800000034}, {d4, 0x400000003c}, {d5, 0x4800000044}, {d17, 0x200000001c}, {d18, 0x2800000024}, {d19, 0x300000002c}, {r8,0x10}, {r10,0x14}, {r12,0x18}, {-1,-1} }}, { 0x1e, 0x10, 0, 0x3c, 0x040, TRUE, { {r4,0x30}, {r5,0x34}, {r6,0x38}, {lr,0x3c}, {d8, 0x400000000}, {d9, 0xc00000008}, {d10, 0x1400000010}, {-1,-1} }}, { 0x22, 0x10, 0, 0x3c, 0x040, TRUE, { {r4,0x30}, {r5,0x34}, {r6,0x38}, {lr,0x3c}, {-1,-1} }}, { 0x24, 0x10, 0, 0x2c, 0x030, TRUE, { {r4,0x20}, {r5,0x24}, {r6,0x28}, {lr,0x2c}, {-1,-1} }}, @@ -6818,7 +6821,6 @@ static void call_virtual_unwind( int testnum, const struct unwind_test *test ) &runtime_func, &context, &data, &frame, &ctx_ptr ); if (test->results[i].handler > 0) { - /* Yet untested */ ok( (char *)handler == (char *)code_mem + 0x200, "%u/%u: wrong handler %p/%p\n", testnum, i, handler, (char *)code_mem + 0x200 ); if (handler) ok( *(DWORD *)data == 0x08070605, @@ -6934,7 +6936,7 @@ static void test_virtual_unwind(void) static const DWORD unwind_info_0_header = (sizeof(function_0)/4) | /* function length */ - (0 << 20) | /* X */ + (1 << 20) | /* X */ (0 << 21) | /* E */ (1 << 22) | /* epilog */ (2 << 27); /* codes */ @@ -6954,6 +6956,9 @@ static void test_virtual_unwind(void) UWOP_SAVE_REGP(19, 16), /* stp x19, x20, [sp, #16] */ UWOP_ALLOC_SMALL(32), /* sub sp, sp, #32 */ UWOP_END, + + 0x00, 0x02, 0x00, 0x00, /* handler */ + 0x05, 0x06, 0x07, 0x08, /* data */ }; static const struct results results_0[] = @@ -6961,7 +6966,7 @@ static void test_virtual_unwind(void) /* offset fp handler pc frame offset registers */ { 0x00, 0x00, 0, ORIG_LR, 0x000, TRUE, { {-1,-1} }}, { 0x04, 0x00, 0, ORIG_LR, 0x020, TRUE, { {-1,-1} }}, - { 0x08, 0x00, 0, ORIG_LR, 0x020, TRUE, { {x19,0x10}, {x20,0x18}, {-1,-1} }}, + { 0x08, 0x00, 1, ORIG_LR, 0x020, TRUE, { {x19,0x10}, {x20,0x18}, {-1,-1} }}, { 0x0c, 0x00, 0, ORIG_LR, 0x020, TRUE, { {x19,0x10}, {x20,0x18}, {-1,-1} }}, { 0x10, 0x00, 0, ORIG_LR, 0x020, TRUE, { {-1,-1} }}, { 0x14, 0x00, 0, ORIG_LR, 0x000, TRUE, { {-1,-1} }},
1
0
0
0
Martin Storsjö : ntdll/tests: Fix printing of incorrect exception handler data.
by Alexandre Julliard
09 Jun '22
09 Jun '22
Module: wine Branch: master Commit: f1f7e096db99bcb280683767b5b5966ff1a85605 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=f1f7e096db99bcb280683767…
Author: Martin Storsjö <martin(a)martin.st> Date: Thu Jun 9 10:57:22 2022 +0300 ntdll/tests: Fix printing of incorrect exception handler data. *(DWORD *)data is the value being compared; printing the 'data' pointer itself provides little value here. Signed-off-by: Martin Storsjö <martin(a)martin.st> --- dlls/ntdll/tests/exception.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index 3e76b001147..2089f3ed3d8 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -2123,7 +2123,7 @@ static void call_virtual_unwind( int testnum, const struct unwind_test *test ) ok( handler == expected_handler || broken( test->broken_results && handler == broken_handler ), "%u/%u: wrong handler %p/%p\n", testnum, i, handler, expected_handler ); if (handler) - ok( *(DWORD *)data == 0x08070605, "%u/%u: wrong handler data %p\n", testnum, i, data ); + ok( *(DWORD *)data == 0x08070605, "%u/%u: wrong handler data %lx\n", testnum, i, *(DWORD *)data ); else ok( data == (void *)0xdeadbeef, "%u/%u: handler data set to %p\n", testnum, i, data ); @@ -5144,7 +5144,7 @@ static void call_virtual_unwind( int testnum, const struct unwind_test *test ) ok( (char *)handler == (char *)code_mem + 0x200, "%u/%u: wrong handler %p/%p\n", testnum, i, handler, (char *)code_mem + 0x200 ); if (handler) ok( *(DWORD *)data == 0x08070605, - "%u/%u: wrong handler data %p\n", testnum, i, data ); + "%u/%u: wrong handler data %lx\n", testnum, i, *(DWORD *)data ); } else { @@ -6822,7 +6822,7 @@ static void call_virtual_unwind( int testnum, const struct unwind_test *test ) ok( (char *)handler == (char *)code_mem + 0x200, "%u/%u: wrong handler %p/%p\n", testnum, i, handler, (char *)code_mem + 0x200 ); if (handler) ok( *(DWORD *)data == 0x08070605, - "%u/%u: wrong handler data %p\n", testnum, i, data ); + "%u/%u: wrong handler data %lx\n", testnum, i, *(DWORD *)data ); } else {
1
0
0
0
Derek Lesho : mfreadwrite: Update source reader MF_SOURCE_READER_ANY_STREAM behavior based on tests.
by Alexandre Julliard
09 Jun '22
09 Jun '22
Module: wine Branch: master Commit: 474d1824c474fa731885c76481fefddb6899d0df URL:
https://source.winehq.org/git/wine.git/?a=commit;h=474d1824c474fa731885c764…
Author: Derek Lesho <dlesho(a)codeweavers.com> Date: Wed Jun 8 13:15:39 2022 +0200 mfreadwrite: Update source reader MF_SOURCE_READER_ANY_STREAM behavior based on tests. Signed-off-by: Derek Lesho <dlesho(a)codeweavers.com> --- dlls/mfreadwrite/reader.c | 34 +++++++++++++++++++++------------- dlls/mfreadwrite/tests/mfplat.c | 5 ++--- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/dlls/mfreadwrite/reader.c b/dlls/mfreadwrite/reader.c index b1175479dec..76348458fac 100644 --- a/dlls/mfreadwrite/reader.c +++ b/dlls/mfreadwrite/reader.c @@ -92,6 +92,7 @@ struct media_stream unsigned int flags; unsigned int requests; unsigned int responses; + LONGLONG last_sample_ts; struct source_reader *reader; }; @@ -160,7 +161,6 @@ struct source_reader IUnknown *device_manager; unsigned int first_audio_stream_index; unsigned int first_video_stream_index; - unsigned int last_read_index; DWORD stream_count; unsigned int flags; DWORD queue; @@ -459,6 +459,8 @@ static HRESULT source_reader_queue_response(struct source_reader *reader, struct source_reader_response_ready(reader, response); + stream->last_sample_ts = timestamp; + return S_OK; } @@ -1101,10 +1103,11 @@ static BOOL source_reader_get_read_result(struct source_reader *reader, struct m static HRESULT source_reader_get_next_selected_stream(struct source_reader *reader, DWORD *stream_index) { - unsigned int i, first_selected = ~0u, requests = ~0u; + unsigned int i, first_selected = ~0u; BOOL selected, stream_drained; + LONGLONG min_ts = MAXLONGLONG; - for (i = (reader->last_read_index + 1) % reader->stream_count; ; i = (i + 1) % reader->stream_count) + for (i = 0; i < reader->stream_count; ++i) { stream_drained = reader->streams[i].state == STREAM_STATE_EOS && !reader->streams[i].responses; selected = SUCCEEDED(source_reader_get_stream_selection(reader, i, &selected)) && selected; @@ -1114,24 +1117,20 @@ static HRESULT source_reader_get_next_selected_stream(struct source_reader *read if (first_selected == ~0u) first_selected = i; - /* Try to balance pending reads. */ - if (!stream_drained && reader->streams[i].requests < requests) + /* Pick the stream whose last sample had the lowest timestamp. */ + if (!stream_drained && reader->streams[i].last_sample_ts < min_ts) { - requests = reader->streams[i].requests; + min_ts = reader->streams[i].last_sample_ts; *stream_index = i; } } - - if (i == reader->last_read_index) - break; } /* If all selected streams reached EOS, use first selected. */ if (first_selected != ~0u) { - if (requests == ~0u) + if (min_ts == MAXLONGLONG) *stream_index = first_selected; - reader->last_read_index = *stream_index; } return first_selected == ~0u ? MF_E_MEDIA_SOURCE_NO_STREAMS_SELECTED : S_OK; @@ -1499,7 +1498,12 @@ static HRESULT WINAPI src_reader_SetStreamSelection(IMFSourceReader *iface, DWOR } if (selection_changed) - reader->last_read_index = reader->stream_count - 1; + { + for (i = 0; i < reader->stream_count; ++i) + { + reader->streams[i].last_sample_ts = 0; + } + } LeaveCriticalSection(&reader->cs); @@ -1911,6 +1915,11 @@ static HRESULT WINAPI src_reader_SetCurrentPosition(IMFSourceReader *iface, REFG if (SUCCEEDED(hr)) { + for (i = 0; i < reader->stream_count; ++i) + { + reader->streams[i].last_sample_ts = 0; + } + if (reader->async_callback) { if (SUCCEEDED(hr = source_reader_create_async_op(SOURCE_READER_ASYNC_SEEK, &command))) @@ -2357,7 +2366,6 @@ static HRESULT create_source_reader_from_source(IMFMediaSource *source, IMFAttri /* At least one major type has to be set. */ object->first_audio_stream_index = reader_get_first_stream_index(object->descriptor, &MFMediaType_Audio); object->first_video_stream_index = reader_get_first_stream_index(object->descriptor, &MFMediaType_Video); - object->last_read_index = object->stream_count - 1; if (object->first_audio_stream_index == MF_SOURCE_READER_INVALID_STREAM_INDEX && object->first_video_stream_index == MF_SOURCE_READER_INVALID_STREAM_INDEX) diff --git a/dlls/mfreadwrite/tests/mfplat.c b/dlls/mfreadwrite/tests/mfplat.c index 2762e88281a..c36e1a7e04d 100644 --- a/dlls/mfreadwrite/tests/mfplat.c +++ b/dlls/mfreadwrite/tests/mfplat.c @@ -994,7 +994,7 @@ static void test_source_reader_from_media_source(void) /* Once the last read sample of all streams has the same timestamp value, the reader will continue reading from the first stream until its timestamp increases. */ - todo_wine ok(!actual_index, "%d: Unexpected stream index %lu.\n", TEST_SOURCE_NUM_STREAMS + 1, actual_index); + ok(!actual_index, "%d: Unexpected stream index %lu.\n", TEST_SOURCE_NUM_STREAMS + 1, actual_index); IMFSample_Release(sample); @@ -1231,8 +1231,7 @@ static void test_source_reader_from_media_source(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(!stream_flags, "Unexpected stream flags %#lx.\n", stream_flags); ok(!!sample, "Expected sample object.\n"); - todo_wine_if (actual_index != expected_sample_order[i]) - ok (actual_index == expected_sample_order[i], "Got sample %u from unexpected stream %lu, expected %lu.\n", + ok (actual_index == expected_sample_order[i], "Got sample %u from unexpected stream %lu, expected %lu.\n", i, actual_index, expected_sample_order[i]); IMFSample_Release(sample); }
1
0
0
0
Derek Lesho : mfreadwrite/tests: Test timestamp-based MF_SOURCE_READER_ANY_STREAM behavior.
by Alexandre Julliard
09 Jun '22
09 Jun '22
Module: wine Branch: master Commit: 35f9b6f0b166300041fbc3cde09dbef44b855916 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=35f9b6f0b166300041fbc3cd…
Author: Derek Lesho <dlesho(a)codeweavers.com> Date: Wed Jun 8 13:13:16 2022 +0200 mfreadwrite/tests: Test timestamp-based MF_SOURCE_READER_ANY_STREAM behavior. Signed-off-by: Derek Lesho <dlesho(a)codeweavers.com> --- dlls/mfreadwrite/tests/mfplat.c | 71 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/dlls/mfreadwrite/tests/mfplat.c b/dlls/mfreadwrite/tests/mfplat.c index fcf642859d5..2762e88281a 100644 --- a/dlls/mfreadwrite/tests/mfplat.c +++ b/dlls/mfreadwrite/tests/mfplat.c @@ -105,6 +105,7 @@ struct test_media_stream IMFStreamDescriptor *sd; IMFMediaEventQueue *event_queue; BOOL is_new; + LONGLONG sample_duration, sample_time; }; static struct test_media_stream *impl_from_IMFMediaStream(IMFMediaStream *iface) @@ -211,8 +212,25 @@ static HRESULT WINAPI test_media_stream_RequestSample(IMFMediaStream *iface, IUn hr = MFCreateSample(&sample); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = IMFSample_SetSampleTime(sample, 123); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + if (stream->sample_duration) + { + hr = IMFSample_SetSampleDuration(sample, stream->sample_duration); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IMFSample_SetSampleTime(sample, stream->sample_time); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + stream->sample_time += stream->sample_duration; + } + else + { + hr = IMFSample_SetSampleTime(sample, 123); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IMFSample_SetSampleDuration(sample, 1); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + } + if (token) IMFSample_SetUnknown(sample, &MFSampleExtension_Token, token); @@ -888,9 +906,12 @@ skip_read_sample: static void test_source_reader_from_media_source(void) { + static const DWORD expected_sample_order[10] = {0, 0, 1, 1, 0, 0, 0, 0, 1, 0}; + struct async_callback *callback; IMFSourceReader *reader; IMFMediaSource *source; + struct test_source *test_source; IMFMediaType *media_type; HRESULT hr; DWORD actual_index, stream_flags; @@ -964,6 +985,19 @@ static void test_source_reader_from_media_source(void) IMFSample_Release(sample); } + hr = IMFSourceReader_ReadSample(reader, MF_SOURCE_READER_ANY_STREAM, 0, &actual_index, &stream_flags, + ×tamp, &sample); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!stream_flags, "Unexpected stream flags %#lx.\n", stream_flags); + ok(timestamp == 123, "Unexpected timestamp.\n"); + ok(!!sample, "Expected sample object.\n"); + + /* Once the last read sample of all streams has the same timestamp value, the reader will + continue reading from the first stream until its timestamp increases. */ + todo_wine ok(!actual_index, "%d: Unexpected stream index %lu.\n", TEST_SOURCE_NUM_STREAMS + 1, actual_index); + + IMFSample_Release(sample); + IMFSourceReader_Release(reader); IMFMediaSource_Release(source); @@ -1172,6 +1206,39 @@ static void test_source_reader_from_media_source(void) IMFMediaSource_Release(source); fail_request_sample = FALSE; + + /* MF_SOURCE_READER_ANY_STREAM with streams of different sample sizes */ + source = create_test_source(2); + ok(!!source, "Failed to create test source.\n"); + + test_source = impl_from_IMFMediaSource(source); + test_source->streams[0]->sample_duration = 100000; + test_source->streams[1]->sample_duration = 400000; + + hr = MFCreateSourceReaderFromMediaSource(source, NULL, &reader); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IMFSourceReader_SetStreamSelection(reader, 0, TRUE); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IMFSourceReader_SetStreamSelection(reader, 1, TRUE); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + /* The source reader picks the stream whose last sample had the lower timestamp */ + for (i = 0; i < ARRAY_SIZE(expected_sample_order); i++) + { + hr = IMFSourceReader_ReadSample(reader, MF_SOURCE_READER_ANY_STREAM, 0, &actual_index, &stream_flags, ×tamp, &sample); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!stream_flags, "Unexpected stream flags %#lx.\n", stream_flags); + ok(!!sample, "Expected sample object.\n"); + todo_wine_if (actual_index != expected_sample_order[i]) + ok (actual_index == expected_sample_order[i], "Got sample %u from unexpected stream %lu, expected %lu.\n", + i, actual_index, expected_sample_order[i]); + IMFSample_Release(sample); + } + + IMFSourceReader_Release(reader); + IMFMediaSource_Release(source); } static void test_reader_d3d9(void)
1
0
0
0
← Newer
1
...
51
52
53
54
55
56
57
...
80
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
72
73
74
75
76
77
78
79
80
Results per page:
10
25
50
100
200