From: Rémi Bernon rbernon@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winegstreamer/gst_private.h | 5 ++++- dlls/winegstreamer/main.c | 9 +++++++-- dlls/winegstreamer/unixlib.h | 2 -- dlls/winegstreamer/wg_sample.c | 18 ++++-------------- dlls/winegstreamer/wg_transform.c | 12 +----------- 5 files changed, 16 insertions(+), 30 deletions(-)
diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index 6657cb792f9..5f7a34780fc 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -69,6 +69,8 @@ struct wg_sample_queue; HRESULT wg_sample_queue_create(struct wg_sample_queue **out); void wg_sample_queue_destroy(struct wg_sample_queue *queue); void wg_sample_queue_flush(struct wg_sample_queue *queue, bool all); +void wg_sample_queue_begin_append(struct wg_sample_queue *queue, struct wg_sample *wg_sample); +void wg_sample_queue_end_append(struct wg_sample_queue *queue, struct wg_sample *wg_sample);
struct wg_parser *wg_parser_create(enum wg_parser_type type, bool unlimited_buffering); void wg_parser_destroy(struct wg_parser *parser); @@ -102,7 +104,8 @@ void wg_parser_stream_seek(struct wg_parser_stream *stream, double rate, struct wg_transform *wg_transform_create(const struct wg_format *input_format, const struct wg_format *output_format); void wg_transform_destroy(struct wg_transform *transform); -HRESULT wg_transform_push_data(struct wg_transform *transform, struct wg_sample *sample); +HRESULT wg_transform_push_data(struct wg_transform *transform, struct wg_sample *sample, + struct wg_sample_queue *queue); HRESULT wg_transform_read_data(struct wg_transform *transform, struct wg_sample *sample, struct wg_format *format);
diff --git a/dlls/winegstreamer/main.c b/dlls/winegstreamer/main.c index 5075b3118cd..c9d1ec0cc20 100644 --- a/dlls/winegstreamer/main.c +++ b/dlls/winegstreamer/main.c @@ -312,7 +312,8 @@ void wg_transform_destroy(struct wg_transform *transform) __wine_unix_call(unix_handle, unix_wg_transform_destroy, transform); }
-HRESULT wg_transform_push_data(struct wg_transform *transform, struct wg_sample *sample) +HRESULT wg_transform_push_data(struct wg_transform *transform, struct wg_sample *sample, + struct wg_sample_queue *queue) { struct wg_transform_push_data_params params = { @@ -323,7 +324,11 @@ HRESULT wg_transform_push_data(struct wg_transform *transform, struct wg_sample
TRACE("transform %p, sample %p.\n", transform, sample);
- if ((status = __wine_unix_call(unix_handle, unix_wg_transform_push_data, ¶ms))) + wg_sample_queue_begin_append(queue, sample); + status = __wine_unix_call(unix_handle, unix_wg_transform_push_data, ¶ms); + wg_sample_queue_end_append(queue, sample); + + if (status) return HRESULT_FROM_NT(status);
return params.result; diff --git a/dlls/winegstreamer/unixlib.h b/dlls/winegstreamer/unixlib.h index ed56fb47908..860a8ab2a52 100644 --- a/dlls/winegstreamer/unixlib.h +++ b/dlls/winegstreamer/unixlib.h @@ -121,8 +121,6 @@ enum wg_sample_flag WG_SAMPLE_FLAG_HAS_PTS = 2, WG_SAMPLE_FLAG_HAS_DURATION = 4, WG_SAMPLE_FLAG_SYNC_POINT = 8, - - WG_SAMPLE_FLAG_HAS_REFCOUNT = 0x10000, /* sample is queued on the client side and may be wrapped */ };
struct wg_sample diff --git a/dlls/winegstreamer/wg_sample.c b/dlls/winegstreamer/wg_sample.c index 646d8511821..bc802008805 100644 --- a/dlls/winegstreamer/wg_sample.c +++ b/dlls/winegstreamer/wg_sample.c @@ -149,20 +149,19 @@ void wg_sample_release(struct wg_sample *wg_sample) free(sample); }
-static void wg_sample_queue_begin_append(struct wg_sample_queue *queue, struct wg_sample *wg_sample) +void wg_sample_queue_begin_append(struct wg_sample_queue *queue, struct wg_sample *wg_sample) { struct sample *sample = CONTAINING_RECORD(wg_sample, struct sample, wg_sample);
/* make sure a concurrent wg_sample_queue_flush call won't release the sample until we're done */ InterlockedIncrement(&wg_sample->refcount); - sample->wg_sample.flags |= WG_SAMPLE_FLAG_HAS_REFCOUNT;
EnterCriticalSection(&queue->cs); list_add_tail(&queue->samples, &sample->entry); LeaveCriticalSection(&queue->cs); }
-static void wg_sample_queue_end_append(struct wg_sample_queue *queue, struct wg_sample *wg_sample) +void wg_sample_queue_end_append(struct wg_sample_queue *queue, struct wg_sample *wg_sample) { /* release temporary ref taken in wg_sample_queue_begin_append */ InterlockedDecrement(&wg_sample->refcount); @@ -221,7 +220,6 @@ HRESULT wg_transform_push_mf(struct wg_transform *transform, struct wg_sample *w struct sample *sample = CONTAINING_RECORD(wg_sample, struct sample, wg_sample); LONGLONG time, duration; UINT32 value; - HRESULT hr;
if (sample->type != WG_SAMPLE_TYPE_MF) return E_INVALIDARG; @@ -239,11 +237,7 @@ HRESULT wg_transform_push_mf(struct wg_transform *transform, struct wg_sample *w if (SUCCEEDED(IMFSample_GetUINT32(sample->u.mf.sample, &MFSampleExtension_CleanPoint, &value)) && value) sample->wg_sample.flags |= WG_SAMPLE_FLAG_SYNC_POINT;
- wg_sample_queue_begin_append(queue, wg_sample); - hr = wg_transform_push_data(transform, wg_sample); - wg_sample_queue_end_append(queue, wg_sample); - - return hr; + return wg_transform_push_data(transform, wg_sample, queue); }
HRESULT wg_transform_push_qz(struct wg_transform *transform, struct wg_sample *wg_sample, @@ -271,11 +265,7 @@ HRESULT wg_transform_push_qz(struct wg_transform *transform, struct wg_sample *w if (IMediaSample_IsSyncPoint(sample->u.qz.sample) == S_OK) wg_sample->flags |= WG_SAMPLE_FLAG_SYNC_POINT;
- wg_sample_queue_begin_append(queue, wg_sample); - hr = wg_transform_push_data(transform, wg_sample); - wg_sample_queue_end_append(queue, wg_sample); - - return hr; + return wg_transform_push_data(transform, wg_sample, queue); }
HRESULT wg_transform_read_mf(struct wg_transform *transform, struct wg_sample *wg_sample, diff --git a/dlls/winegstreamer/wg_transform.c b/dlls/winegstreamer/wg_transform.c index d40f508250c..b5517f24515 100644 --- a/dlls/winegstreamer/wg_transform.c +++ b/dlls/winegstreamer/wg_transform.c @@ -542,17 +542,7 @@ NTSTATUS wg_transform_push_data(void *args) return STATUS_SUCCESS; }
- if (!(sample->flags & WG_SAMPLE_FLAG_HAS_REFCOUNT)) - { - if (!(buffer = gst_buffer_new_and_alloc(sample->size))) - { - GST_ERROR("Failed to allocate input buffer"); - return STATUS_NO_MEMORY; - } - gst_buffer_fill(buffer, 0, sample->data, sample->size); - GST_INFO("Copied %u bytes from sample %p to buffer %p", sample->size, sample, buffer); - } - else 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, sample->data, sample->max_size, 0, sample->size, sample, wg_sample_free_notify))) { GST_ERROR("Failed to allocate input buffer");