This replaces Wine's 10 copies of the function.
From: Alex Henrie alexhenrie24@gmail.com
--- dlls/evr/evr_private.h | 21 --------------------- dlls/evr/sample.c | 21 --------------------- dlls/mf/mf_private.h | 21 --------------------- dlls/mfplat/mfplat_private.h | 21 --------------------- dlls/mfsrcsnk/wave.c | 21 --------------------- dlls/qasf/asfreader.c | 21 --------------------- dlls/quartz/quartz_private.h | 21 --------------------- dlls/winegstreamer/gst_private.h | 21 --------------------- dlls/wmvcore/wmvcore_private.h | 21 --------------------- include/wine/debug.h | 22 ++++++++++++++++++++++ libs/strmbase/strmbase_private.h | 21 --------------------- 11 files changed, 22 insertions(+), 210 deletions(-)
diff --git a/dlls/evr/evr_private.h b/dlls/evr/evr_private.h index 225e60348b4..c24dd01a745 100644 --- a/dlls/evr/evr_private.h +++ b/dlls/evr/evr_private.h @@ -24,27 +24,6 @@ #include "wine/strmbase.h" #include "wine/debug.h"
-static inline const char *debugstr_time(LONGLONG time) -{ - ULONGLONG abstime = time >= 0 ? time : -time; - unsigned int i = 0, j = 0; - char buffer[23], rev[23]; - - while (abstime || i <= 8) - { - buffer[i++] = '0' + (abstime % 10); - abstime /= 10; - if (i == 7) buffer[i++] = '.'; - } - if (time < 0) buffer[i++] = '-'; - - while (i--) rev[j++] = buffer[i]; - while (rev[j-1] == '0' && rev[j-2] != '.') --j; - rev[j] = 0; - - return wine_dbg_sprintf("%s", rev); -} - static inline const char *debugstr_normalized_rect(const MFVideoNormalizedRect *rect) { if (!rect) return "(null)"; diff --git a/dlls/evr/sample.c b/dlls/evr/sample.c index aa3f120b115..0dc46e1cd55 100644 --- a/dlls/evr/sample.c +++ b/dlls/evr/sample.c @@ -29,27 +29,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(evr);
-static const char *debugstr_time(LONGLONG time) -{ - ULONGLONG abstime = time >= 0 ? time : -time; - unsigned int i = 0, j = 0; - char buffer[23], rev[23]; - - while (abstime || i <= 8) - { - buffer[i++] = '0' + (abstime % 10); - abstime /= 10; - if (i == 7) buffer[i++] = '.'; - } - if (time < 0) buffer[i++] = '-'; - - while (i--) rev[j++] = buffer[i]; - while (rev[j-1] == '0' && rev[j-2] != '.') --j; - rev[j] = 0; - - return wine_dbg_sprintf("%s", rev); -} - struct surface_buffer { IMFMediaBuffer IMFMediaBuffer_iface; diff --git a/dlls/mf/mf_private.h b/dlls/mf/mf_private.h index bbfadaee5d8..c4e2214c993 100644 --- a/dlls/mf/mf_private.h +++ b/dlls/mf/mf_private.h @@ -58,27 +58,6 @@ struct activate_funcs
HRESULT create_activation_object(void *context, const struct activate_funcs *funcs, IMFActivate **ret);
-static inline const char *debugstr_time(LONGLONG time) -{ - ULONGLONG abstime = time >= 0 ? time : -time; - unsigned int i = 0, j = 0; - char buffer[23], rev[23]; - - while (abstime || i <= 8) - { - buffer[i++] = '0' + (abstime % 10); - abstime /= 10; - if (i == 7) buffer[i++] = '.'; - } - if (time < 0) buffer[i++] = '-'; - - while (i--) rev[j++] = buffer[i]; - while (rev[j-1] == '0' && rev[j-2] != '.') --j; - rev[j] = 0; - - return wine_dbg_sprintf("%s", rev); -} - static inline const char *debugstr_propvar(const PROPVARIANT *v) { if (!v) diff --git a/dlls/mfplat/mfplat_private.h b/dlls/mfplat/mfplat_private.h index c9af96d88f9..703e0ce196f 100644 --- a/dlls/mfplat/mfplat_private.h +++ b/dlls/mfplat/mfplat_private.h @@ -183,24 +183,3 @@ static inline const char *mf_debugstr_fourcc(DWORD format)
return wine_dbgstr_an((char *)&format, 4); } - -static inline const char *debugstr_time(LONGLONG time) -{ - ULONGLONG abstime = time >= 0 ? time : -time; - unsigned int i = 0, j = 0; - char buffer[23], rev[23]; - - while (abstime || i <= 8) - { - buffer[i++] = '0' + (abstime % 10); - abstime /= 10; - if (i == 7) buffer[i++] = '.'; - } - if (time < 0) buffer[i++] = '-'; - - while (i--) rev[j++] = buffer[i]; - while (rev[j-1] == '0' && rev[j-2] != '.') --j; - rev[j] = 0; - - return wine_dbg_sprintf("%s", rev); -} diff --git a/dlls/mfsrcsnk/wave.c b/dlls/mfsrcsnk/wave.c index 736bbb5aa3c..cf1252e382c 100644 --- a/dlls/mfsrcsnk/wave.c +++ b/dlls/mfsrcsnk/wave.c @@ -28,27 +28,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
-static inline const char *debugstr_time(LONGLONG time) -{ - ULONGLONG abstime = time >= 0 ? time : -time; - unsigned int i = 0, j = 0; - char buffer[23], rev[23]; - - while (abstime || i <= 8) - { - buffer[i++] = '0' + (abstime % 10); - abstime /= 10; - if (i == 7) buffer[i++] = '.'; - } - if (time < 0) buffer[i++] = '-'; - - while (i--) rev[j++] = buffer[i]; - while (rev[j-1] == '0' && rev[j-2] != '.') --j; - rev[j] = 0; - - return wine_dbg_sprintf("%s", rev); -} - enum wave_sink_flags { SINK_SHUT_DOWN = 0x1, diff --git a/dlls/qasf/asfreader.c b/dlls/qasf/asfreader.c index 4cf077e9dd3..7a832e9a718 100644 --- a/dlls/qasf/asfreader.c +++ b/dlls/qasf/asfreader.c @@ -27,27 +27,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(quartz);
-static inline const char *debugstr_time(REFERENCE_TIME time) -{ - ULONGLONG abstime = time >= 0 ? time : -time; - unsigned int i = 0, j = 0; - char buffer[23], rev[23]; - - while (abstime || i <= 8) - { - buffer[i++] = '0' + (abstime % 10); - abstime /= 10; - if (i == 7) buffer[i++] = '.'; - } - if (time < 0) buffer[i++] = '-'; - - while (i--) rev[j++] = buffer[i]; - while (rev[j-1] == '0' && rev[j-2] != '.') --j; - rev[j] = 0; - - return wine_dbg_sprintf("%s", rev); -} - struct buffer { INSSBuffer INSSBuffer_iface; diff --git a/dlls/quartz/quartz_private.h b/dlls/quartz/quartz_private.h index 849795d9c1b..af31afc1d74 100644 --- a/dlls/quartz/quartz_private.h +++ b/dlls/quartz/quartz_private.h @@ -44,27 +44,6 @@ 0, 0, { (DWORD_PTR)(__FILE__ ": " # cs) }}; \ static CRITICAL_SECTION cs = { &cs##_debug, -1, 0, 0, 0, 0 };
-static inline const char *debugstr_time(REFERENCE_TIME time) -{ - ULONGLONG abstime = time >= 0 ? time : -time; - unsigned int i = 0, j = 0; - char buffer[23], rev[23]; - - while (abstime || i <= 8) - { - buffer[i++] = '0' + (abstime % 10); - abstime /= 10; - if (i == 7) buffer[i++] = '.'; - } - if (time < 0) buffer[i++] = '-'; - - while (i--) rev[j++] = buffer[i]; - while (rev[j-1] == '0' && rev[j-2] != '.') --j; - rev[j] = 0; - - return wine_dbg_sprintf("%s", rev); -} - /* see IAsyncReader::Request on MSDN for the explanation of this */ #define MEDIATIME_FROM_BYTES(x) ((LONGLONG)(x) * 10000000) #define BYTES_FROM_MEDIATIME(time) ((time) / 10000000) diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index 26873edb74b..7d5abfd5937 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -41,27 +41,6 @@
bool array_reserve(void **elements, size_t *capacity, size_t count, size_t size);
-static inline const char *debugstr_time(REFERENCE_TIME time) -{ - ULONGLONG abstime = time >= 0 ? time : -time; - unsigned int i = 0, j = 0; - char buffer[23], rev[23]; - - while (abstime || i <= 8) - { - buffer[i++] = '0' + (abstime % 10); - abstime /= 10; - if (i == 7) buffer[i++] = '.'; - } - if (time < 0) buffer[i++] = '-'; - - while (i--) rev[j++] = buffer[i]; - while (rev[j-1] == '0' && rev[j-2] != '.') --j; - rev[j] = 0; - - return wine_dbg_sprintf("%s", rev); -} - #define MEDIATIME_FROM_BYTES(x) ((LONGLONG)(x) * 10000000)
struct wg_sample_queue; diff --git a/dlls/wmvcore/wmvcore_private.h b/dlls/wmvcore/wmvcore_private.h index a5225d79da9..81ecdf953a2 100644 --- a/dlls/wmvcore/wmvcore_private.h +++ b/dlls/wmvcore/wmvcore_private.h @@ -27,24 +27,3 @@ #include "wine/debug.h"
HRESULT WINAPI winegstreamer_create_wm_sync_reader(IUnknown *outer, void **out); - -static inline const char *debugstr_time(LONGLONG time) -{ - ULONGLONG abstime = time >= 0 ? time : -time; - unsigned int i = 0, j = 0; - char buffer[23], rev[23]; - - while (abstime || i <= 8) - { - buffer[i++] = '0' + (abstime % 10); - abstime /= 10; - if (i == 7) buffer[i++] = '.'; - } - if (time < 0) buffer[i++] = '-'; - - while (i--) rev[j++] = buffer[i]; - while (rev[j-1] == '0' && rev[j-2] != '.') --j; - rev[j] = 0; - - return wine_dbg_sprintf("%s", rev); -} diff --git a/include/wine/debug.h b/include/wine/debug.h index 86e008a1408..7a1f378d936 100644 --- a/include/wine/debug.h +++ b/include/wine/debug.h @@ -334,6 +334,27 @@ static inline const char *wine_dbgstr_fourcc( unsigned int fourcc ) return wine_dbg_sprintf( "0x%08x", fourcc ); }
+static inline const char *wine_dbgstr_time( LONGLONG time ) +{ + ULONGLONG abstime = time >= 0 ? time : -time; + unsigned int i = 0, j = 0; + char buffer[23], rev[23]; + + while (abstime || i <= 8) + { + buffer[i++] = '0' + (abstime % 10); + abstime /= 10; + if (i == 7) buffer[i++] = '.'; + } + if (time < 0) buffer[i++] = '-'; + + while (i--) rev[j++] = buffer[i]; + while (rev[j-1] == '0' && rev[j-2] != '.') --j; + rev[j] = 0; + + return wine_dbg_sprintf( "%s", rev ); +} + static inline const char *wine_dbgstr_point( const POINT *pt ) { if (!pt) return "(null)"; @@ -515,6 +536,7 @@ static inline const char *debugstr_an( const char * s, int n ) { return wine_dbg static inline const char *debugstr_wn( const WCHAR *s, int n ) { return wine_dbgstr_wn( s, n ); } static inline const char *debugstr_guid( const struct _GUID *id ) { return wine_dbgstr_guid(id); } static inline const char *debugstr_fourcc( unsigned int cc ) { return wine_dbgstr_fourcc( cc ); } +static inline const char *debugstr_time( LONGLONG time ) { return wine_dbgstr_time( time ); } static inline const char *debugstr_a( const char *s ) { return wine_dbgstr_an( s, -1 ); } static inline const char *debugstr_w( const WCHAR *s ) { return wine_dbgstr_wn( s, -1 ); }
diff --git a/libs/strmbase/strmbase_private.h b/libs/strmbase/strmbase_private.h index cf702a279c2..374b10e7d51 100644 --- a/libs/strmbase/strmbase_private.h +++ b/libs/strmbase/strmbase_private.h @@ -30,25 +30,4 @@ #include "wine/list.h" #include "wine/strmbase.h"
-static inline const char *debugstr_time(REFERENCE_TIME time) -{ - ULONGLONG abstime = time >= 0 ? time : -time; - unsigned int i = 0, j = 0; - char buffer[23], rev[23]; - - while (abstime || i <= 8) - { - buffer[i++] = '0' + (abstime % 10); - abstime /= 10; - if (i == 7) buffer[i++] = '.'; - } - if (time < 0) buffer[i++] = '-'; - - while (i--) rev[j++] = buffer[i]; - while (rev[j-1] == '0' && rev[j-2] != '.') --j; - rev[j] = 0; - - return wine_dbg_sprintf("%s", rev); -} - #endif /* __WINE_STRMBASE_PRIVATE_H */
This is fine I guess, but the name is too generic. This helper is for one particular notion of time that is used by multimedia components.
On Mon Nov 27 07:07:29 2023 +0000, Nikolay Sivov wrote:
This is fine I guess, but the name is too generic. This helper is for one particular notion of time that is used by multimedia components.
How about `debugstr_mmtime`, where "mm" stands for "multimedia"?
On Mon Nov 27 07:07:29 2023 +0000, Alex Henrie wrote:
How about `debugstr_mmtime`, where "mm" stands for "multimedia"?
At least in DirectShow this is called "reference time".
On Mon Nov 27 19:21:36 2023 +0000, Zebediah Figura wrote:
At least in DirectShow this is called "reference time".
Maybe we can have this helper in strmbase.h, if mediafoundation modules still build after including that. If it's difficult, we can still have it for quartz modules in this header.
On Mon Nov 27 19:27:07 2023 +0000, Nikolay Sivov wrote:
Maybe we can have this helper in strmbase.h, if mediafoundation modules still build after including that. If it's difficult, we can still have it for quartz modules in this header.
Imo winecrt0 would be a good place to put all these debugstr implementations.
Then you could just declare that function as extern, anywhere, and it would resolve the right object.
They don't have to all be in the same source, for instance to split debugstr for different subsystems.
This also makes them usable in tests and avoid very painful recompilation (because touching wine/debug.h) if for some reason the implementation needs to be changed.