From 0c9e8e655bc121d06f1b55f2f2423d916b67c514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Mon, 24 Jul 2023 14:39:14 +0200 Subject: [PATCH] winegstreamer: Use a fixed size type for wg_sample data pointer. --- dlls/winegstreamer/unix_private.h | 5 +++++ dlls/winegstreamer/unixlib.h | 2 +- dlls/winegstreamer/wg_allocator.c | 6 +++--- dlls/winegstreamer/wg_sample.c | 6 +++--- dlls/winegstreamer/wg_transform.c | 8 ++++---- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/dlls/winegstreamer/unix_private.h b/dlls/winegstreamer/unix_private.h index 527822cf15b..db6bf3ebb2e 100644 --- a/dlls/winegstreamer/unix_private.h +++ b/dlls/winegstreamer/unix_private.h @@ -59,6 +59,11 @@ extern NTSTATUS wg_transform_flush(void *args) DECLSPEC_HIDDEN; /* wg_allocator.c */ +static inline BYTE *wg_sample_data(struct wg_sample *sample) +{ + return (BYTE *)(UINT_PTR)sample->data; +} + /* wg_allocator_release_sample can be used to release any sample that was requested. */ typedef struct wg_sample *(*wg_allocator_request_sample_cb)(gsize size, void *context); extern GstAllocator *wg_allocator_create(void) DECLSPEC_HIDDEN; diff --git a/dlls/winegstreamer/unixlib.h b/dlls/winegstreamer/unixlib.h index 39391b44735..66c363b5b6e 100644 --- a/dlls/winegstreamer/unixlib.h +++ b/dlls/winegstreamer/unixlib.h @@ -182,7 +182,7 @@ struct wg_sample UINT32 flags; UINT32 max_size; UINT32 size; - BYTE *data; + UINT64 data; /* pointer to user memory */ }; struct wg_parser_buffer diff --git a/dlls/winegstreamer/wg_allocator.c b/dlls/winegstreamer/wg_allocator.c index 629546b237c..5cc2a6fcf12 100644 --- a/dlls/winegstreamer/wg_allocator.c +++ b/dlls/winegstreamer/wg_allocator.c @@ -96,7 +96,7 @@ static void release_memory_sample(WgAllocator *allocator, WgMemory *memory, bool if (memory->written && !discard_data) { GST_WARNING("Copying %#zx bytes from sample %p, back to memory %p", memory->written, sample, memory); - memcpy(get_unix_memory_data(memory), memory->sample->data, memory->written); + memcpy(get_unix_memory_data(memory), wg_sample_data(memory->sample), memory->written); } memory->sample = NULL; @@ -120,7 +120,7 @@ static gpointer wg_allocator_map(GstMemory *gst_memory, GstMapInfo *info, gsize else { InterlockedIncrement(&memory->sample->refcount); - info->data = memory->sample->data; + info->data = wg_sample_data(memory->sample); } if (info->flags & GST_MAP_WRITE) memory->written = max(memory->written, maxsize); @@ -143,7 +143,7 @@ static void wg_allocator_unmap(GstMemory *gst_memory, GstMapInfo *info) pthread_mutex_lock(&allocator->mutex); - if (memory->sample && info->data == memory->sample->data) + if (memory->sample && info->data == wg_sample_data(memory->sample)) { InterlockedDecrement(&memory->sample->refcount); pthread_cond_signal(&allocator->release_cond); diff --git a/dlls/winegstreamer/wg_sample.c b/dlls/winegstreamer/wg_sample.c index 4f786e4febc..4b02252174b 100644 --- a/dlls/winegstreamer/wg_sample.c +++ b/dlls/winegstreamer/wg_sample.c @@ -104,7 +104,7 @@ HRESULT wg_sample_create_mf(IMFSample *mf_sample, struct wg_sample **out) goto fail; IMFSample_AddRef((sample->u.mf.sample = mf_sample)); - sample->wg_sample.data = buffer; + sample->wg_sample.data = (UINT_PTR)buffer; sample->wg_sample.size = current_length; sample->wg_sample.max_size = max_length; sample->ops = &mf_sample_ops; @@ -159,7 +159,7 @@ HRESULT wg_sample_create_quartz(IMediaSample *media_sample, struct wg_sample **o return E_OUTOFMEMORY; IMediaSample_AddRef((sample->u.quartz.sample = media_sample)); - sample->wg_sample.data = buffer; + sample->wg_sample.data = (UINT_PTR)buffer; sample->wg_sample.size = current_length; sample->wg_sample.max_size = max_length; sample->ops = &quartz_sample_ops; @@ -207,7 +207,7 @@ HRESULT wg_sample_create_dmo(IMediaBuffer *media_buffer, struct wg_sample **out) goto fail; IMediaBuffer_AddRef((sample->u.dmo.buffer = media_buffer)); - sample->wg_sample.data = buffer; + sample->wg_sample.data = (UINT_PTR)buffer; sample->wg_sample.size = length; sample->wg_sample.max_size = max_length; sample->ops = &dmo_sample_ops; diff --git a/dlls/winegstreamer/wg_transform.c b/dlls/winegstreamer/wg_transform.c index fc05d8159fb..775fed7a46c 100644 --- a/dlls/winegstreamer/wg_transform.c +++ b/dlls/winegstreamer/wg_transform.c @@ -577,7 +577,7 @@ NTSTATUS wg_transform_push_data(void *args) return STATUS_SUCCESS; } - if (!(buffer = gst_buffer_new_wrapped_full(GST_MEMORY_FLAG_READONLY, sample->data, sample->max_size, + if (!(buffer = gst_buffer_new_wrapped_full(GST_MEMORY_FLAG_READONLY, wg_sample_data(sample), sample->max_size, 0, sample->size, sample, wg_sample_free_notify))) { GST_ERROR("Failed to allocate input buffer"); @@ -627,7 +627,7 @@ static NTSTATUS copy_video_buffer(GstBuffer *buffer, GstCaps *caps, gsize plane_ return STATUS_BUFFER_TOO_SMALL; } - if (!(dst_buffer = gst_buffer_new_wrapped_full(0, sample->data, sample->max_size, + if (!(dst_buffer = gst_buffer_new_wrapped_full(0, wg_sample_data(sample), sample->max_size, 0, sample->max_size, 0, NULL))) { GST_ERROR("Failed to wrap wg_sample into GstBuffer"); @@ -673,7 +673,7 @@ static NTSTATUS copy_buffer(GstBuffer *buffer, GstCaps *caps, struct wg_sample * sample->size = sample->max_size; } - memcpy(sample->data, info.data, sample->size); + memcpy(wg_sample_data(sample), info.data, sample->size); gst_buffer_unmap(buffer, &info); if (sample->flags & WG_SAMPLE_FLAG_INCOMPLETE) @@ -697,7 +697,7 @@ static NTSTATUS read_transform_output_data(GstBuffer *buffer, GstCaps *caps, gsi sample->size = 0; return STATUS_UNSUCCESSFUL; } - needs_copy = info.data != sample->data; + needs_copy = info.data != wg_sample_data(sample); total_size = sample->size = info.size; gst_buffer_unmap(buffer, &info);