strmbase: Allocate sample list as a part of queue structure.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2016-11-25 12:10:45 +03:00 committed by Alexandre Julliard
parent 16dead4dd2
commit 89763f0e95
2 changed files with 15 additions and 22 deletions

View File

@ -49,7 +49,7 @@ static DWORD WINAPI OutputQueue_InitialThreadProc(LPVOID data)
static void OutputQueue_FreeSamples(OutputQueue *pOutputQueue)
{
struct list *cursor, *cursor2;
LIST_FOR_EACH_SAFE(cursor, cursor2, pOutputQueue->SampleList)
LIST_FOR_EACH_SAFE(cursor, cursor2, &pOutputQueue->SampleList)
{
QueuedEvent *qev = LIST_ENTRY(cursor, QueuedEvent, entry);
list_remove(cursor);
@ -86,14 +86,7 @@ HRESULT WINAPI OutputQueue_Construct(
This->bBatchExact = bBatchExact;
InitializeCriticalSection(&This->csQueue);
This->csQueue.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": OutputQueue.csQueue");
This->SampleList = HeapAlloc(GetProcessHeap(),0,sizeof(struct list));
if (!This->SampleList)
{
OutputQueue_Destroy(This);
*ppOutputQueue = NULL;
return E_OUTOFMEMORY;
}
list_init(This->SampleList);
list_init(&This->SampleList);
This->pInputPin = pInputPin;
IPin_AddRef(&pInputPin->pin.IPin_iface);
@ -130,8 +123,6 @@ HRESULT WINAPI OutputQueue_Destroy(OutputQueue *pOutputQueue)
DeleteCriticalSection(&pOutputQueue->csQueue);
CloseHandle(pOutputQueue->hProcessQueue);
HeapFree(GetProcessHeap(),0,pOutputQueue->SampleList);
IPin_Release(&pOutputQueue->pInputPin->pin.IPin_iface);
HeapFree(GetProcessHeap(),0,pOutputQueue);
return S_OK;
@ -168,11 +159,11 @@ HRESULT WINAPI OutputQueue_ReceiveMultiple(OutputQueue *pOutputQueue, IMediaSamp
qev->type = SAMPLE_PACKET;
qev->pSample = ppSamples[i];
IMediaSample_AddRef(ppSamples[i]);
list_add_tail(pOutputQueue->SampleList, &qev->entry);
list_add_tail(&pOutputQueue->SampleList, &qev->entry);
(*nSamplesProcessed)++;
}
if (!pOutputQueue->bBatchExact || list_count(pOutputQueue->SampleList) >= pOutputQueue->lBatchSize)
if (!pOutputQueue->bBatchExact || list_count(&pOutputQueue->SampleList) >= pOutputQueue->lBatchSize)
SetEvent(pOutputQueue->hProcessQueue);
LeaveCriticalSection(&pOutputQueue->csQueue);
}
@ -190,7 +181,7 @@ VOID WINAPI OutputQueue_SendAnyway(OutputQueue *pOutputQueue)
if (pOutputQueue->hThread)
{
EnterCriticalSection(&pOutputQueue->csQueue);
if (!list_empty(pOutputQueue->SampleList))
if (!list_empty(&pOutputQueue->SampleList))
{
pOutputQueue->bSendAnyway = TRUE;
SetEvent(pOutputQueue->hProcessQueue);
@ -213,7 +204,7 @@ VOID WINAPI OutputQueue_EOS(OutputQueue *pOutputQueue)
}
qev->type = EOS_PACKET;
qev->pSample = NULL;
list_add_tail(pOutputQueue->SampleList, &qev->entry);
list_add_tail(&pOutputQueue->SampleList, &qev->entry);
}
else
{
@ -235,14 +226,14 @@ DWORD WINAPI OutputQueueImpl_ThreadProc(OutputQueue *pOutputQueue)
do
{
EnterCriticalSection(&pOutputQueue->csQueue);
if (!list_empty(pOutputQueue->SampleList) &&
if (!list_empty(&pOutputQueue->SampleList) &&
(!pOutputQueue->bBatchExact ||
list_count(pOutputQueue->SampleList) >= pOutputQueue->lBatchSize ||
list_count(&pOutputQueue->SampleList) >= pOutputQueue->lBatchSize ||
pOutputQueue->bSendAnyway
)
)
{
while (!list_empty(pOutputQueue->SampleList))
while (!list_empty(&pOutputQueue->SampleList))
{
IMediaSample **ppSamples;
LONG nSamples;
@ -251,10 +242,10 @@ DWORD WINAPI OutputQueueImpl_ThreadProc(OutputQueue *pOutputQueue)
int i = 0;
/* First Pass Process Samples */
i = list_count(pOutputQueue->SampleList);
i = list_count(&pOutputQueue->SampleList);
ppSamples = HeapAlloc(GetProcessHeap(),0,sizeof(IMediaSample*) * i);
nSamples = 0;
LIST_FOR_EACH_SAFE(cursor, cursor2, pOutputQueue->SampleList)
LIST_FOR_EACH_SAFE(cursor, cursor2, &pOutputQueue->SampleList)
{
QueuedEvent *qev = LIST_ENTRY(cursor, QueuedEvent, entry);
if (qev->type == SAMPLE_PACKET)
@ -278,7 +269,7 @@ DWORD WINAPI OutputQueueImpl_ThreadProc(OutputQueue *pOutputQueue)
HeapFree(GetProcessHeap(),0,ppSamples);
/* Process Non-Samples */
LIST_FOR_EACH_SAFE(cursor, cursor2, pOutputQueue->SampleList)
LIST_FOR_EACH_SAFE(cursor, cursor2, &pOutputQueue->SampleList)
{
QueuedEvent *qev = LIST_ENTRY(cursor, QueuedEvent, entry);
if (qev->type == EOS_PACKET)

View File

@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "wine/list.h"
HRESULT WINAPI CopyMediaType(AM_MEDIA_TYPE * pDest, const AM_MEDIA_TYPE *pSrc);
void WINAPI FreeMediaType(AM_MEDIA_TYPE * pMediaType);
AM_MEDIA_TYPE * WINAPI CreateMediaType(AM_MEDIA_TYPE const * pSrc);
@ -351,7 +353,7 @@ typedef struct tagOutputQueue {
BOOL bTerminate;
BOOL bSendAnyway;
struct list *SampleList;
struct list SampleList;
const struct OutputQueueFuncTable* pFuncsTable;
} OutputQueue;