[PATCH v2 04/13] qedit: Store the filename for retrieval instead of querying the filter.

Zebediah Figura zfigura at codeweavers.com
Thu Apr 16 11:58:35 CDT 2020


On 4/16/20 10:24 AM, Gabriel Ivăncescu wrote:
> Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
> ---
> 
> This will be needed after put_Filter is implemented so that it passes the
> tests properly.
> 
>  dlls/qedit/mediadet.c | 32 ++++++++++++++++----------------
>  1 file changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/dlls/qedit/mediadet.c b/dlls/qedit/mediadet.c
> index 0a06d52..5152eea 100644
> --- a/dlls/qedit/mediadet.c
> +++ b/dlls/qedit/mediadet.c
> @@ -28,6 +28,7 @@
>  #include "ole2.h"
>  
>  #include "qedit_private.h"
> +#include "wine/heap.h"
>  #include "wine/debug.h"
>  
>  WINE_DEFAULT_DEBUG_CHANNEL(qedit);
> @@ -40,6 +41,7 @@ typedef struct MediaDetImpl {
>      IGraphBuilder *graph;
>      IBaseFilter *source;
>      IBaseFilter *splitter;
> +    WCHAR *filename;
>      LONG num_streams;
>      LONG cur_stream;
>      IPin *cur_pin;
> @@ -65,6 +67,8 @@ static void MD_cleanup(MediaDetImpl *This)
>      This->splitter = NULL;
>      if (This->graph) IGraphBuilder_Release(This->graph);
>      This->graph = NULL;
> +    if (This->filename) heap_free(This->filename);
> +    This->filename = NULL;
>      This->num_streams = -1;
>      This->cur_stream = 0;
>  }
> @@ -341,9 +345,6 @@ static HRESULT WINAPI MediaDet_get_StreamLength(IMediaDet* iface, double *pVal)
>  static HRESULT WINAPI MediaDet_get_Filename(IMediaDet* iface, BSTR *pVal)
>  {
>      MediaDetImpl *This = impl_from_IMediaDet(iface);
> -    IFileSourceFilter *file;
> -    LPOLESTR name;
> -    HRESULT hr;
>  
>      TRACE("(%p)\n", This);
>  
> @@ -353,21 +354,10 @@ static HRESULT WINAPI MediaDet_get_Filename(IMediaDet* iface, BSTR *pVal)
>      *pVal = NULL;
>      /* MSDN says it should return E_FAIL if no file is open, but tests
>         show otherwise.  */
> -    if (!This->source)
> +    if (!This->filename)
>          return S_OK;
>  
> -    hr = IBaseFilter_QueryInterface(This->source, &IID_IFileSourceFilter,
> -                                    (void **) &file);
> -    if (FAILED(hr))
> -        return hr;
> -
> -    hr = IFileSourceFilter_GetCurFile(file, &name, NULL);
> -    IFileSourceFilter_Release(file);
> -    if (FAILED(hr))
> -        return hr;
> -
> -    *pVal = SysAllocString(name);
> -    CoTaskMemFree(name);
> +    *pVal = SysAllocString(This->filename);
>      if (!*pVal)
>          return E_OUTOFMEMORY;
>  
> @@ -522,6 +512,7 @@ static HRESULT WINAPI MediaDet_put_Filename(IMediaDet* iface, BSTR newVal)
>      MediaDetImpl *This = impl_from_IMediaDet(iface);
>      IGraphBuilder *gb;
>      IBaseFilter *bf;
> +    WCHAR *filename;
>      HRESULT hr;
>  
>      TRACE("(%p)->(%s)\n", This, debugstr_w(newVal));
> @@ -537,14 +528,23 @@ static HRESULT WINAPI MediaDet_put_Filename(IMediaDet* iface, BSTR newVal)
>      if (FAILED(hr))
>          return hr;
>  
> +    if (!(filename = heap_alloc((wcslen(newVal) + 1) * sizeof(WCHAR))))

qedit is compiled with msvcrt, so this can be wcsdup().

> +    {
> +        IGraphBuilder_Release(gb);
> +        return E_OUTOFMEMORY;
> +    }
> +
>      if (FAILED(hr = IGraphBuilder_AddSourceFilter(gb, newVal, L"Reader", &bf)))
>      {
> +        heap_free(filename);
>          IGraphBuilder_Release(gb);
>          return hr;
>      }
>  
>      This->graph = gb;
>      This->source = bf;
> +    This->filename = filename;
> +    wcscpy(filename, newVal);
>      hr = GetSplitter(This);
>      if (FAILED(hr))
>          return hr;
> 



More information about the wine-devel mailing list