quartz/filesource: Clean up FileAsyncReader_RequestAllocator().
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
abac070387
commit
58b60edf53
|
@ -353,7 +353,7 @@ static void async_reader_destroy(struct strmbase_filter *iface)
|
||||||
{
|
{
|
||||||
for (i = 0; i < filter->max_requests; ++i)
|
for (i = 0; i < filter->max_requests; ++i)
|
||||||
CloseHandle(filter->requests[i].ovl.hEvent);
|
CloseHandle(filter->requests[i].ovl.hEvent);
|
||||||
CoTaskMemFree(filter->requests);
|
free(filter->requests);
|
||||||
}
|
}
|
||||||
CloseHandle(filter->file);
|
CloseHandle(filter->file);
|
||||||
filter->sample_cs.DebugInfo->Spare[0] = 0;
|
filter->sample_cs.DebugInfo->Spare[0] = 0;
|
||||||
|
@ -702,88 +702,54 @@ static ULONG WINAPI FileAsyncReader_Release(IAsyncReader * iface)
|
||||||
return IPin_Release(&filter->source.pin.IPin_iface);
|
return IPin_Release(&filter->source.pin.IPin_iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DEF_ALIGNMENT 1
|
static HRESULT WINAPI FileAsyncReader_RequestAllocator(IAsyncReader *iface,
|
||||||
|
IMemAllocator *preferred, ALLOCATOR_PROPERTIES *props, IMemAllocator **ret_allocator)
|
||||||
static HRESULT WINAPI FileAsyncReader_RequestAllocator(IAsyncReader * iface, IMemAllocator * pPreferred, ALLOCATOR_PROPERTIES * pProps, IMemAllocator ** ppActual)
|
|
||||||
{
|
{
|
||||||
AsyncReader *This = impl_from_IAsyncReader(iface);
|
AsyncReader *filter = impl_from_IAsyncReader(iface);
|
||||||
HRESULT hr = S_OK;
|
IMemAllocator *allocator;
|
||||||
|
unsigned int i;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE("%p->(%p, %p, %p)\n", This, pPreferred, pProps, ppActual);
|
TRACE("filter %p, preferred %p, props %p, ret_allocator %p.\n", filter, preferred, props, ret_allocator);
|
||||||
|
|
||||||
if (!pProps->cbAlign || (pProps->cbAlign % DEF_ALIGNMENT) != 0)
|
if (!props->cbAlign)
|
||||||
pProps->cbAlign = DEF_ALIGNMENT;
|
props->cbAlign = 1;
|
||||||
|
|
||||||
if (pPreferred)
|
*ret_allocator = NULL;
|
||||||
|
|
||||||
|
if (preferred)
|
||||||
|
IMemAllocator_AddRef(allocator = preferred);
|
||||||
|
else if (FAILED(hr = CoCreateInstance(&CLSID_MemoryAllocator, NULL,
|
||||||
|
CLSCTX_INPROC, &IID_IMemAllocator, (void **)&allocator)))
|
||||||
|
return hr;
|
||||||
|
|
||||||
|
if (FAILED(hr = IMemAllocator_SetProperties(allocator, props, props)))
|
||||||
{
|
{
|
||||||
hr = IMemAllocator_SetProperties(pPreferred, pProps, pProps);
|
IMemAllocator_Release(allocator);
|
||||||
/* FIXME: check we are still aligned */
|
return hr;
|
||||||
if (SUCCEEDED(hr))
|
|
||||||
{
|
|
||||||
IMemAllocator_AddRef(pPreferred);
|
|
||||||
*ppActual = pPreferred;
|
|
||||||
TRACE("FileAsyncReader_RequestAllocator -- %x\n", hr);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pPreferred = NULL;
|
if (filter->requests)
|
||||||
|
|
||||||
hr = CoCreateInstance(&CLSID_MemoryAllocator, NULL, CLSCTX_INPROC, &IID_IMemAllocator, (LPVOID *)&pPreferred);
|
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
|
||||||
{
|
{
|
||||||
hr = IMemAllocator_SetProperties(pPreferred, pProps, pProps);
|
for (i = 0; i < filter->max_requests; ++i)
|
||||||
/* FIXME: check we are still aligned */
|
CloseHandle(filter->requests[i].ovl.hEvent);
|
||||||
if (SUCCEEDED(hr))
|
free(filter->requests);
|
||||||
{
|
|
||||||
*ppActual = pPreferred;
|
|
||||||
TRACE("FileAsyncReader_RequestAllocator -- %x\n", hr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
filter->max_requests = props->cBuffers;
|
||||||
if (SUCCEEDED(hr))
|
TRACE("Maximum request count: %u.\n", filter->max_requests);
|
||||||
|
if (!(filter->requests = calloc(filter->max_requests, sizeof(filter->requests[0]))))
|
||||||
{
|
{
|
||||||
if (This->requests)
|
IMemAllocator_Release(allocator);
|
||||||
{
|
return E_OUTOFMEMORY;
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
for (i = 0; i < This->max_requests; ++i)
|
|
||||||
CloseHandle(This->requests[i].ovl.hEvent);
|
|
||||||
CoTaskMemFree(This->requests);
|
|
||||||
}
|
|
||||||
|
|
||||||
This->max_requests = pProps->cBuffers;
|
|
||||||
TRACE("Maximum request count: %u.\n", This->max_requests);
|
|
||||||
This->requests = CoTaskMemAlloc(sizeof(This->requests[0]) * pProps->cBuffers);
|
|
||||||
|
|
||||||
if (This->requests)
|
|
||||||
{
|
|
||||||
int x;
|
|
||||||
ZeroMemory(This->requests, sizeof(This->requests[0]) * pProps->cBuffers);
|
|
||||||
for (x = 0; x < This->max_requests; ++x)
|
|
||||||
This->requests[x].ovl.hEvent = CreateEventW(NULL, 0, 0, NULL);
|
|
||||||
This->allocProps = *pProps;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hr = E_OUTOFMEMORY;
|
|
||||||
CoTaskMemFree(This->requests);
|
|
||||||
This->max_requests = 0;
|
|
||||||
This->requests = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(hr))
|
for (i = 0; i < filter->max_requests; ++i)
|
||||||
{
|
filter->requests[i].ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
|
||||||
*ppActual = NULL;
|
filter->allocProps = *props;
|
||||||
if (pPreferred)
|
|
||||||
IMemAllocator_Release(pPreferred);
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("-- %x\n", hr);
|
*ret_allocator = allocator;
|
||||||
return hr;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI FileAsyncReader_Request(IAsyncReader *iface, IMediaSample *sample, DWORD_PTR cookie)
|
static HRESULT WINAPI FileAsyncReader_Request(IAsyncReader *iface, IMediaSample *sample, DWORD_PTR cookie)
|
||||||
|
|
Loading…
Reference in New Issue