Commit 0c9e8e65 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winegstreamer: Use a fixed size type for wg_sample data pointer.

parent 7c814a3e
......@@ -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;
......
......@@ -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
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment