[PATCH v2 07/11] winestreamer: Add stub bytestream handler and source.

Nikolay Sivov nsivov at codeweavers.com
Thu Feb 13 04:55:37 CST 2020


On 2/11/20 1:32 AM, Derek Lesho wrote:
> --- a/dlls/winegstreamer/Makefile.in
> +++ b/dlls/winegstreamer/Makefile.in
> @@ -10,6 +10,7 @@ C_SRCS = \
>   	gst_cbs.c \
>   	gstdemux.c \
>   	main.c \
> +	media_source.c \
>   	mediatype.c \
>   	mfplat.c \
>   	pin.c \
Can we have everything in single mfplat.c?

> +static ULONG WINAPI media_source_Release(IMFMediaSource *iface)
> +{
> +    struct media_source *This = impl_from_IMFMediaSource(iface);
> +    ULONG ref = InterlockedDecrement(&This->ref);
> +
> +    TRACE("(%p) ref=%u\n", This, ref);
> +
> +    if (!ref)
> +    {
> +        if (This->state != SOURCE_SHUTDOWN)
> +            ERR("Application has freed media source without calling ::Shutdown\n");
> +        heap_free(This);
> +    }
> +
> +    return ref;
> +}
I don't think it's necessarily an error. You should shutdown and release 
event queue here by the way.

> +static HRESULT WINAPI media_source_GetEvent(IMFMediaSource *iface, DWORD flags, IMFMediaEvent **event)
> +{
> +    struct media_source *This = impl_from_IMFMediaSource(iface);
> +
> +    TRACE("(%p)->(%#x, %p)\n", This, flags, event);
> +
> +    if (This->state == SOURCE_SHUTDOWN)
> +        return MF_E_SHUTDOWN;
> +
> +    return IMFMediaEventQueue_GetEvent(This->event_queue, flags, event);
> +}
> +
> +static HRESULT WINAPI media_source_BeginGetEvent(IMFMediaSource *iface, IMFAsyncCallback *callback, IUnknown *state)
> +{
> +    struct media_source *This = impl_from_IMFMediaSource(iface);
> +
> +    TRACE("(%p)->(%p, %p)\n", This, callback, state);
> +
> +    if (This->state == SOURCE_SHUTDOWN)
> +        return MF_E_SHUTDOWN;
> +
> +    return IMFMediaEventQueue_BeginGetEvent(This->event_queue, callback, state);
> +}
State checks here are unnecessary, on source Shutdown() event queue 
should be shut down too, to unblock potential waiting threads.

P.S. please use names and traces formats similar to current code in 
other media foundation module - This -> source, etc.


> +static HRESULT WINAPI media_source_Shutdown(IMFMediaSource *iface)
> +{
> +    struct media_source *This = impl_from_IMFMediaSource(iface);
> +
> +    TRACE("(%p)\n", This);
> +
> +    This->state = SOURCE_SHUTDOWN;
> +    return media_source_teardown(This);
> +}
I think this and everything testing/setting state should be protected 
for multiple threads access.




More information about the wine-devel mailing list