Commit 0f1f42ea authored by Hidenori Takeshima's avatar Hidenori Takeshima Committed by Alexandre Julliard

Fixed some bugs.

Implemented some methods of CLSID_ACMWrapper.
parent 3a007359
......@@ -7,14 +7,12 @@ TODO
- merge some C sources
- implement filters
- restruct color-space converter
- add FilterData to winedefault.reg for Connect() and Render()
- sort active filters in filter graph
- sort regfilters in Merit order
- fix deadlocks in Receive/EndOfStream
- handle plug-in distributor
- handle seeking
- implement some interfaces as plug-ins(???)
- implement ACM drivers (g711)
- implement ACM wrapper (improve xform)
- implement mciqtz(mci driver for quartz)
- implement renderer
......
......@@ -99,6 +99,11 @@ CBaseFilterImpl_fnStop(IBaseFilter* iface)
hr = NOERROR;
EnterCriticalSection( &This->csFilter );
if ( This->bIntermediateState )
{
LeaveCriticalSection( &This->csFilter );
return VFW_S_STATE_INTERMEDIATE; /* FIXME? */
}
TRACE("(%p) state = %d\n",This,This->fstate);
if ( This->fstate == State_Running )
......@@ -132,6 +137,11 @@ CBaseFilterImpl_fnPause(IBaseFilter* iface)
hr = NOERROR;
EnterCriticalSection( &This->csFilter );
if ( This->bIntermediateState )
{
LeaveCriticalSection( &This->csFilter );
return VFW_E_WRONG_STATE; /* FIXME? */
}
TRACE("(%p) state = %d\n",This,This->fstate);
if ( This->fstate != State_Paused )
......@@ -159,6 +169,11 @@ CBaseFilterImpl_fnRun(IBaseFilter* iface,REFERENCE_TIME rtStart)
hr = NOERROR;
EnterCriticalSection( &This->csFilter );
if ( This->bIntermediateState )
{
LeaveCriticalSection( &This->csFilter );
return VFW_E_WRONG_STATE; /* FIXME? */
}
TRACE("(%p) state = %d\n",This,This->fstate);
This->rtStart = rtStart;
......
/*
* Implementation of CLSID_FilterMapper and CLSID_FilterMapper2.
*
* FIXME - stub.
* FIXME - some stubs
*
* Copyright (C) Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
*
......@@ -22,6 +22,7 @@
#include "config.h"
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
......@@ -840,6 +841,19 @@ err:
return hr;
}
struct MATCHED_ITEM
{
IMoniker* pMonFilter;
DWORD dwMerit;
};
static int sort_comp_merit(const void* p1,const void* p2)
{
const struct MATCHED_ITEM* pItem1 = (const struct MATCHED_ITEM*)p1;
const struct MATCHED_ITEM* pItem2 = (const struct MATCHED_ITEM*)p2;
return (int)pItem2->dwMerit - (int)pItem1->dwMerit;
}
static HRESULT WINAPI
IFilterMapper2_fnEnumMatchingFilters(IFilterMapper2* iface,
......@@ -859,7 +873,10 @@ IFilterMapper2_fnEnumMatchingFilters(IFilterMapper2* iface,
BYTE* pbFilterData = NULL;
DWORD cbFilterData = 0;
REGFILTER2* prf2 = NULL;
QUARTZ_CompList* pList = NULL;
QUARTZ_CompList* pListFilters = NULL;
struct MATCHED_ITEM* pItems = NULL;
struct MATCHED_ITEM* pItemsTmp;
int cItems = 0;
const REGFILTERPINS2* pRegFilterPin;
DWORD n;
BOOL bMatch;
......@@ -995,32 +1012,44 @@ IFilterMapper2_fnEnumMatchingFilters(IFilterMapper2* iface,
}
/* matched - add pFilter to the list. */
if ( pList == NULL )
pItemsTmp = QUARTZ_ReallocMem( pItems, sizeof(struct MATCHED_ITEM) * (cItems+1) );
if ( pItemsTmp == NULL )
{
pList = QUARTZ_CompList_Alloc();
if ( pList == NULL )
{
hr = E_OUTOFMEMORY;
goto err;
}
}
TRACE("matched\n");
hr = QUARTZ_CompList_AddComp(
pList, (IUnknown*)pFilter, NULL, 0 );
if ( FAILED(hr) )
hr = E_OUTOFMEMORY;
goto err;
}
pItems = pItemsTmp;
pItemsTmp = pItems + cItems; cItems ++;
pItemsTmp->pMonFilter = pFilter; pFilter = NULL;
pItemsTmp->dwMerit = prf2->dwMerit;
}
}
if ( pList == NULL )
if ( pItems == NULL || cItems == 0 )
{
hr = S_FALSE;
goto err;
}
FIXME("create IEnumMoniker - not sorted\n");
/* FIXME - should be sorted?(in Merit order) */
hr = QUARTZ_CreateEnumUnknown( &IID_IEnumMoniker, (void**)ppEnumMoniker, pList );
/* FIXME - sort in Merit order */
TRACE("sort in Merit order\n");
qsort( pItems, cItems, sizeof(struct MATCHED_ITEM), sort_comp_merit );
pListFilters = QUARTZ_CompList_Alloc();
if ( pListFilters == NULL )
{
hr = E_OUTOFMEMORY;
goto err;
}
for ( n = 0; n < cItems; n++ )
{
TRACE("merit %08lx\n",pItems[n].dwMerit);
hr = QUARTZ_CompList_AddComp( pListFilters, (IUnknown*)pItems[n].pMonFilter, NULL, 0 );
if ( FAILED(hr) )
goto err;
}
hr = QUARTZ_CreateEnumUnknown( &IID_IEnumMoniker, (void**)ppEnumMoniker, pListFilters );
if ( FAILED(hr) )
goto err;
......@@ -1040,8 +1069,17 @@ err:
QUARTZ_FreeMem(pbFilterData);
if ( prf2 != NULL )
QUARTZ_FreeMem(prf2);
if ( pList != NULL )
QUARTZ_CompList_Free( pList );
if ( pItems != NULL && cItems > 0 )
{
for ( n = 0; n < cItems; n++ )
{
if ( pItems[n].pMonFilter != NULL )
IMoniker_Release(pItems[n].pMonFilter);
}
QUARTZ_FreeMem(pItems);
}
if ( pListFilters != NULL )
QUARTZ_CompList_Free( pListFilters );
TRACE("returns %08lx\n",hr);
......
......@@ -108,6 +108,7 @@ static const QUARTZ_CLASSENTRY QUARTZ_ClassList[] =
{ &CLSID_URLReader, &QUARTZ_CreateURLReader },
{ &CLSID_AVIDec, &QUARTZ_CreateAVIDec },
{ &CLSID_Colour, &QUARTZ_CreateColour },
{ &CLSID_ACMWrapper, &QUARTZ_CreateACMWrapper },
{ &CLSID_FileWriter, &QUARTZ_CreateFileWriter },
{ NULL, NULL },
};
......
......@@ -389,9 +389,18 @@ static HRESULT CMPGParseImpl_GetStreamType( CParserImpl* pImpl, ULONG nStreamInd
pmpg1wav = (MPEG1WAVEFORMAT*)pmt->pbFormat;
switch ( hdrbuf[1] & 0x6 )
{
case 0x6: pmpg1wav->fwHeadLayer = ACM_MPEG_LAYER1;
case 0x4: pmpg1wav->fwHeadLayer = ACM_MPEG_LAYER2;
case 0x2: pmpg1wav->fwHeadLayer = ACM_MPEG_LAYER3;
case 0x6:
TRACE("layer 1\n");
pmpg1wav->fwHeadLayer = ACM_MPEG_LAYER1;
break;
case 0x4:
TRACE("layer 2\n");
pmpg1wav->fwHeadLayer = ACM_MPEG_LAYER2;
break;
case 0x2:
TRACE("layer 3\n");
pmpg1wav->fwHeadLayer = ACM_MPEG_LAYER3;
break;
default: return E_FAIL;
}
......@@ -412,10 +421,22 @@ static HRESULT CMPGParseImpl_GetStreamType( CParserImpl* pImpl, ULONG nStreamInd
switch ( hdrbuf[3] & 0xc0 )
{
case 0x00: pmpg1wav->fwHeadMode = ACM_MPEG_STEREO;
case 0x40: pmpg1wav->fwHeadMode = ACM_MPEG_JOINTSTEREO;
case 0x80: pmpg1wav->fwHeadMode = ACM_MPEG_DUALCHANNEL;
case 0xc0: pmpg1wav->fwHeadMode = ACM_MPEG_SINGLECHANNEL;
case 0x00:
TRACE("STEREO\n");
pmpg1wav->fwHeadMode = ACM_MPEG_STEREO;
break;
case 0x40:
TRACE("JOINTSTEREO\n");
pmpg1wav->fwHeadMode = ACM_MPEG_JOINTSTEREO;
break;
case 0x80:
TRACE("DUALCHANNEL\n");
pmpg1wav->fwHeadMode = ACM_MPEG_DUALCHANNEL;
break;
case 0xc0:
TRACE("SINGLECHANNEL\n");
pmpg1wav->fwHeadMode = ACM_MPEG_SINGLECHANNEL;
break;
}
pmpg1wav->fwHeadModeExt = (hdrbuf[3] & 0x30) >> 4; /* FIXME?? */
......@@ -436,9 +457,18 @@ static HRESULT CMPGParseImpl_GetStreamType( CParserImpl* pImpl, ULONG nStreamInd
pmpg1wav->wfx.nChannels = (pmpg1wav->fwHeadMode != ACM_MPEG_SINGLECHANNEL) ? 2 : 1;
switch ( hdrbuf[2] & 0x0c )
{
case 0x00: pmpg1wav->wfx.nSamplesPerSec = 44100;
case 0x01: pmpg1wav->wfx.nSamplesPerSec = 48000;
case 0x02: pmpg1wav->wfx.nSamplesPerSec = 32000;
case 0x00:
TRACE("44100Hz\n");
pmpg1wav->wfx.nSamplesPerSec = 44100;
break;
case 0x01:
TRACE("48000Hz\n");
pmpg1wav->wfx.nSamplesPerSec = 48000;
break;
case 0x02:
TRACE("32000Hz\n");
pmpg1wav->wfx.nSamplesPerSec = 32000;
break;
default: return E_FAIL;
}
pmpg1wav->wfx.nAvgBytesPerSec = pmpg1wav->dwHeadBitrate >> 3;
......
......@@ -465,6 +465,10 @@ DWORD WINAPI CParserImplThread_Entry( LPVOID pv )
}
}
This->m_dwThreadId = 0;
This->basefilter.bIntermediateState = FALSE;
SetEvent( This->m_hEventInit );
return 0;
}
......@@ -579,12 +583,21 @@ HRESULT CParserImpl_BeginThread( CParserImpl* This )
(LPVOID)This,
0, &This->m_dwThreadId );
if ( This->m_hThread == (HANDLE)NULL )
{
CloseHandle( This->m_hEventInit );
This->m_hEventInit = (HANDLE)NULL;
return E_FAIL;
}
hEvents[0] = This->m_hEventInit;
hEvents[1] = This->m_hThread;
dwRes = WaitForMultipleObjects(2,hEvents,FALSE,INFINITE);
ResetEvent( This->m_hEventInit );
CloseHandle( This->m_hThread );
This->m_hThread = (HANDLE)NULL;
if ( dwRes != WAIT_OBJECT_0 )
return E_FAIL;
......@@ -592,25 +605,26 @@ HRESULT CParserImpl_BeginThread( CParserImpl* This )
}
static
void CParserImpl_EndThread( CParserImpl* This )
BOOL CParserImpl_EndThread( CParserImpl* This, BOOL bAsync )
{
DWORD dwThreadId;
TRACE("(%p)\n",This);
if ( This->m_hThread != (HANDLE)NULL )
{
if ( PostThreadMessageA(
This->m_dwThreadId, QUARTZ_MSG_EXITTHREAD, 0, 0 ) )
{
WaitForSingleObject( This->m_hThread, INFINITE );
}
CloseHandle( This->m_hThread );
This->m_hThread = (HANDLE)NULL;
This->m_dwThreadId = 0;
}
dwThreadId = This->m_dwThreadId;
if ( This->m_hEventInit != (HANDLE)NULL )
{
if ( dwThreadId != 0 ) /* FIXME? */
PostThreadMessageA(
dwThreadId, QUARTZ_MSG_EXITTHREAD, 0, 0 );
if ( bAsync )
return FALSE;
WaitForSingleObject( This->m_hEventInit, INFINITE );
CloseHandle( This->m_hEventInit );
This->m_hEventInit = (HANDLE)NULL;
}
return TRUE;
}
static
......@@ -713,7 +727,7 @@ static HRESULT CParserImpl_OnInactive( CBaseFilterImpl* pImpl )
hr = CParserImpl_BeginThread(This);
if ( FAILED(hr) )
{
CParserImpl_EndThread(This);
CParserImpl_EndThread(This,FALSE);
return hr;
}
......@@ -726,8 +740,11 @@ static HRESULT CParserImpl_OnStop( CBaseFilterImpl* pImpl )
FIXME( "(%p)\n", This );
CParserImpl_EndThread(This);
This->basefilter.bIntermediateState = TRUE;
if ( !CParserImpl_EndThread(This,TRUE) )
return VFW_S_STATE_INTERMEDIATE;
This->basefilter.bIntermediateState = FALSE;
return NOERROR;
}
......@@ -857,8 +874,9 @@ static HRESULT CParserInPinImpl_OnDisconnect( CPinBaseImpl* pImpl )
{
CParserInPinImpl_THIS(pImpl,pin);
CParserImpl_OnInactive(&This->pParser->basefilter);
CParserImpl_OnStop(&This->pParser->basefilter);
/* assume the graph is already stopped */
/*CParserImpl_OnInactive(&This->pParser->basefilter);*/
/*CParserImpl_OnStop(&This->pParser->basefilter);*/
if ( This->pParser->m_pHandler->pUninitParser != NULL )
This->pParser->m_pHandler->pUninitParser(This->pParser);
CParserImpl_SetAsyncReader( This->pParser, NULL );
......
......@@ -121,5 +121,6 @@ HRESULT QUARTZ_CreateTransformBaseOutPin(
HRESULT QUARTZ_CreateAVIDec(IUnknown* punkOuter,void** ppobj);
HRESULT QUARTZ_CreateColour(IUnknown* punkOuter,void** ppobj);
HRESULT QUARTZ_CreateACMWrapper(IUnknown* punkOuter,void** ppobj);
#endif /* WINE_DSHOW_XFORM_H */
......@@ -527,6 +527,46 @@
30,74,79,33,00,00,00,00,60,00,00,00,60,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
# CLSID_MPEG1Splitter
[HKEY_CLASSES_ROOT\CLSID\{336475D0-942A-11CE-A870-00AA002FEAB5}]
@="MPEG1 Splitter"
[HKEY_CLASSES_ROOT\CLSID\{336475D0-942A-11CE-A870-00AA002FEAB5}\InprocServer32]
@="quartz.dll"
"ThreadingModel"="Both"
[HKEY_CLASSES_ROOT\CLSID\{083863F1-70DE-11D0-BD40-00A0C911CE86}\Instance\{336475D0-942A-11CE-A870-00AA002FEAB5}]
"CLSID"="{336475D0-942A-11CE-A870-00AA002FEAB5}"
"FriendlyName"="MPEG1 Splitter"
# FilterData of generic transform filter.
"FilterData"=hex:02,00,00,00,00,00,60,00,02,00,00,00,00,00,00,00,\
30,70,69,33,00,00,00,00,00,00,00,00,\
01,00,00,00,00,00,00,00,00,00,00,00,\
30,74,79,33,00,00,00,00,60,00,00,00,60,00,00,00,\
31,70,69,33,08,00,00,00,00,00,00,00,\
01,00,00,00,00,00,00,00,00,00,00,00,\
30,74,79,33,00,00,00,00,60,00,00,00,60,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
# CLSID_ACMWrapper
[HKEY_CLASSES_ROOT\CLSID\{6A08CF80-0E18-11CF-A24D-0020AFD79767}]
@="ACM Wrapper"
[HKEY_CLASSES_ROOT\CLSID\{6A08CF80-0E18-11CF-A24D-0020AFD79767}\InprocServer32]
@="quartz.dll"
"ThreadingModel"="Both"
[HKEY_CLASSES_ROOT\CLSID\{083863F1-70DE-11D0-BD40-00A0C911CE86}\Instance\{6A08CF80-0E18-11CF-A24D-0020AFD79767}]
"CLSID"="{6A08CF80-0E18-11CF-A24D-0020AFD79767}"
"FriendlyName"="ACM Wrapper"
# FilterData of generic transform filter.
"FilterData"=hex:02,00,00,00,00,00,60,00,02,00,00,00,00,00,00,00,\
30,70,69,33,00,00,00,00,00,00,00,00,\
01,00,00,00,00,00,00,00,00,00,00,00,\
30,74,79,33,00,00,00,00,60,00,00,00,60,00,00,00,\
31,70,69,33,08,00,00,00,00,00,00,00,\
01,00,00,00,00,00,00,00,00,00,00,00,\
30,74,79,33,00,00,00,00,60,00,00,00,60,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
#
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment