[PATCH v2 2/3] winegstreamer: Allocate source media buffers in the PE components.
Zebediah Figura
zfigura at codeweavers.com
Mon Sep 13 12:30:53 CDT 2021
On 9/10/21 12:04 PM, Derek Lesho wrote:
> @@ -539,18 +544,34 @@ static DWORD CALLBACK read_thread(void *arg)
> ULONG ret_size;
> uint32_t size;
> HRESULT hr;
> - void *data;
>
> - if (!unix_funcs->wg_parser_get_read_request(source->wg_parser, &data, &offset, &size))
> + if (!unix_funcs->wg_parser_get_next_read_offset(source->wg_parser, &offset, &size))
> continue;
>
> + if (offset >= file_size)
> + size = 0;
> + else if (offset + size >= file_size)
> + size = file_size - offset;
> +
> + if (size > buffer_size)
> + {
> + buffer_size = size;
> + free(data);
> + data = malloc(size);
> + }
Any reason not to use realloc() here?
> +
> + ret_size = 0;
> +
> if (SUCCEEDED(hr = IMFByteStream_SetCurrentPosition(byte_stream, offset)))
> hr = IMFByteStream_Read(byte_stream, data, size, &ret_size);
> - if (SUCCEEDED(hr) && ret_size != size)
> + if (FAILED(hr))
> + ERR("Failed to read source stream bytes %p+%u. hr=%#x\n", data, size, hr);
> + else if (ret_size != size)
> ERR("Unexpected short read: requested %u bytes, got %u.\n", size, ret_size);
> - unix_funcs->wg_parser_complete_read_request(source->wg_parser, SUCCEEDED(hr));
> + unix_funcs->wg_parser_push_data(source->wg_parser, SUCCEEDED(hr) ? data : NULL, ret_size);
> }
>
> + free(data);
> TRACE("Media source is shutting down; exiting.\n");
> return 0;
> }
...
> @@ -1224,10 +1224,10 @@ static GstFlowReturn src_getrange_cb(GstPad *pad, GstObject *parent,
>
> GST_LOG("Request returned %d.", ret);
>
> - if (!ret && new_buffer)
> + if ((!ret || !size) && new_buffer)
> gst_buffer_unref(new_buffer);
>
> - return ret ? GST_FLOW_OK : GST_FLOW_ERROR;
> + return ret ? size ? GST_FLOW_OK : GST_FLOW_EOS : GST_FLOW_ERROR;
Please don't do this; it's hard to read.
> }
>
> static gboolean src_query_cb(GstPad *pad, GstObject *parent, GstQuery *query)
More information about the wine-devel
mailing list