Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/qedit/mediadet.c | 30 ++++++++++++++---------------- dlls/qedit/tests/mediadet.c | 4 ++-- 2 files changed, 16 insertions(+), 18 deletions(-)
diff --git a/dlls/qedit/mediadet.c b/dlls/qedit/mediadet.c index 56ecc2f..b134a03 100644 --- a/dlls/qedit/mediadet.c +++ b/dlls/qedit/mediadet.c @@ -41,6 +41,7 @@ typedef struct MediaDetImpl { IGraphBuilder *graph; IBaseFilter *source; IBaseFilter *splitter; + WCHAR *filename; LONG num_streams; LONG cur_stream; IPin *cur_pin; @@ -66,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) free(This->filename); + This->filename = NULL; This->num_streams = -1; This->cur_stream = 0; } @@ -522,9 +525,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);
@@ -534,21 +534,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;
@@ -560,6 +549,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)); @@ -575,14 +565,22 @@ static HRESULT WINAPI MediaDet_put_Filename(IMediaDet* iface, BSTR newVal) if (FAILED(hr)) return hr;
+ if (!(filename = wcsdup(newVal))) + { + IGraphBuilder_Release(gb); + return E_OUTOFMEMORY; + } + if (FAILED(hr = IGraphBuilder_AddSourceFilter(gb, newVal, L"Source", &bf))) { + free(filename); IGraphBuilder_Release(gb); return hr; }
This->graph = gb; This->source = bf; + This->filename = filename; hr = get_splitter(This); if (FAILED(hr)) return hr; diff --git a/dlls/qedit/tests/mediadet.c b/dlls/qedit/tests/mediadet.c index 067adf1..f9aa3b3 100644 --- a/dlls/qedit/tests/mediadet.c +++ b/dlls/qedit/tests/mediadet.c @@ -643,7 +643,7 @@ static void test_mediadet(void)
filename = NULL; hr = IMediaDet_get_Filename(pM, &filename); - todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(hr == S_OK, "Got hr %#x.\n", hr); ok(!filename, "Got filename %s.\n", debugstr_w(filename)); SysFreeString(filename);
@@ -659,7 +659,7 @@ static void test_mediadet(void) filename = NULL; hr = IMediaDet_get_Filename(pM, &filename); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(!filename, "Got filename %s.\n", debugstr_w(filename)); + ok(!filename, "Got filename %s.\n", debugstr_w(filename)); SysFreeString(filename);
/* It still looks for a downstream source and splits it into video+audio in this case. */