Ignore:
Timestamp:
Oct 6, 2001, 10:56:18 AM (24 years ago)
Author:
sandervl
Message:

Wine 20011004 resync

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/quartz/ifgraph.c

    r6710 r6952  
    22 * Implementation of IFilterGraph.
    33 *
    4  * FIXME - stub.
    5  * FIXME - implement IGraphBuilder / IFilterGraph2.
     4 * FIXME - create a thread to process some methods correctly.
     5 *
     6 * FIXME - ReconnectEx
     7 * FIXME - process Pause/Stop asynchronously and notify when completed.
     8 *
    69 *
    710 * hidenori@a2.ctktv.ne.jp
     
    1316#include "winbase.h"
    1417#include "wingdi.h"
     18#include "winuser.h"
    1519#include "winerror.h"
    1620#include "wine/obj_base.h"
     
    2125#include "vfwmsgs.h"
    2226#include "wine/unicode.h"
     27#include "evcode.h"
    2328
    2429#include "debugtools.h"
     
    2833#include "fgraph.h"
    2934#include "enumunk.h"
     35#include "sysclock.h"
    3036
    3137
     
    7581
    7682
     83static HRESULT CFilterGraph_GraphChanged( CFilterGraph* This )
     84{
     85        /* IDistributorNotify_NotifyGraphChange() */
     86
     87        IMediaEventSink_Notify(CFilterGraph_IMediaEventSink(This),
     88                        EC_GRAPH_CHANGED, 0, 0);
     89        EnterCriticalSection( &This->m_csGraphVersion );
     90        This->m_lGraphVersion ++;
     91        LeaveCriticalSection( &This->m_csGraphVersion );
     92
     93        return NOERROR;
     94}
     95
     96
    7797/****************************************************************************/
    7898
     
    111131{
    112132        CFilterGraph_THIS(iface,fgraph);
     133        FILTER_STATE fs;
    113134        FILTER_INFO     info;
    114135        HRESULT hr;
     
    120141
    121142        QUARTZ_CompList_Lock( This->m_pFilterList );
     143
     144        hr = IMediaFilter_GetState(CFilterGraph_IMediaFilter(This),0,&fs);
     145        if ( hr == VFW_S_STATE_INTERMEDIATE )
     146                hr = VFW_E_STATE_CHANGED;
     147        if ( fs != State_Stopped )
     148                hr = VFW_E_NOT_STOPPED;
     149        if ( FAILED(hr) )
     150                goto end;
     151
     152        TRACE( "(%p) search the specified name.\n",This );
    122153
    123154        if ( pName != NULL )
     
    180211
    181212name_ok:
     213        TRACE( "(%p) add this filter.\n",This );
     214
    182215        /* register this filter. */
    183216        hr = QUARTZ_CompList_AddComp(
     
    188221
    189222        hr = IBaseFilter_JoinFilterGraph(pFilter,(IFilterGraph*)iface,pName);
    190         if ( FAILED(hr) )
    191         {
     223        if ( SUCCEEDED(hr) )
     224        {
     225                EnterCriticalSection( &This->m_csClock );
     226                hr = IBaseFilter_SetSyncSource( pFilter, This->m_pClock );
     227                LeaveCriticalSection( &This->m_csClock );
     228        }
     229        if ( FAILED(hr) )
     230        {
     231                IBaseFilter_JoinFilterGraph(pFilter,NULL,pName);
    192232                QUARTZ_CompList_RemoveComp(
    193233                        This->m_pFilterList,(IUnknown*)pFilter);
     
    195235        }
    196236
    197         EnterCriticalSection( &This->m_csGraphVersion );
    198         This->m_lGraphVersion ++;
    199         LeaveCriticalSection( &This->m_csGraphVersion );
     237        hr = CFilterGraph_GraphChanged(This);
     238        if ( FAILED(hr) )
     239                goto end;
    200240
    201241        hr = hrSucceeded;
     
    203243        QUARTZ_CompList_Unlock( This->m_pFilterList );
    204244
     245        TRACE( "(%p) return %08lx\n", This, hr );
     246
    205247        return hr;
    206248}
     
    211253        CFilterGraph_THIS(iface,fgraph);
    212254        QUARTZ_CompListItem*    pItem;
     255        FILTER_STATE fs;
    213256        HRESULT hr = NOERROR;
    214257
     
    217260        QUARTZ_CompList_Lock( This->m_pFilterList );
    218261
     262        hr = IMediaFilter_GetState(CFilterGraph_IMediaFilter(This),0,&fs);
     263        if ( hr == VFW_S_STATE_INTERMEDIATE )
     264                hr = VFW_E_STATE_CHANGED;
     265        if ( fs != State_Stopped )
     266                hr = VFW_E_NOT_STOPPED;
     267        if ( FAILED(hr) )
     268                goto end;
     269
     270        hr = S_FALSE; /* FIXME? */
    219271        pItem = QUARTZ_CompList_SearchComp(
    220272                This->m_pFilterList, (IUnknown*)pFilter );
     
    222274        {
    223275                CFilterGraph_DisconnectAllPins(pFilter);
     276                IBaseFilter_SetSyncSource( pFilter, NULL );
    224277                hr = IBaseFilter_JoinFilterGraph(
    225278                        pFilter, NULL, QUARTZ_CompList_GetDataPtr(pItem) );
     
    228281        }
    229282
    230         EnterCriticalSection( &This->m_csGraphVersion );
    231         This->m_lGraphVersion ++;
    232         LeaveCriticalSection( &This->m_csGraphVersion );
    233 
     283        hr = CFilterGraph_GraphChanged(This);
     284        if ( FAILED(hr) )
     285                goto end;
     286
     287end:;
    234288        QUARTZ_CompList_Unlock( This->m_pFilterList );
    235289
     
    332386        pConnTo = NULL;
    333387        hr = IPin_ConnectedTo(pIn,&pConnTo);
    334         if ( FAILED(hr) )
    335                 goto end;
    336         if ( pConnTo != NULL )
     388        if ( hr == NOERROR && pConnTo != NULL )
    337389        {
    338390                IPin_Release(pConnTo);
     391                hr = VFW_E_ALREADY_CONNECTED;
    339392                goto end;
    340393        }
     
    342395        pConnTo = NULL;
    343396        hr = IPin_ConnectedTo(pOut,&pConnTo);
    344         if ( FAILED(hr) )
    345                 goto end;
    346         if ( pConnTo != NULL )
     397        if ( hr == NOERROR && pConnTo != NULL )
    347398        {
    348399                IPin_Release(pConnTo);
    349                 goto end;
    350         }
    351 
    352         hr = IPin_Connect(pIn,pOut,pmt);
    353         if ( FAILED(hr) )
    354                 goto end;
     400                hr = VFW_E_ALREADY_CONNECTED;
     401                goto end;
     402        }
     403
     404        TRACE("(%p) try to connect %p<->%p\n",This,pIn,pOut);
    355405        hr = IPin_Connect(pOut,pIn,pmt);
    356406        if ( FAILED(hr) )
    357407        {
     408                TRACE("(%p)->Connect(%p,%p) hr = %08lx\n",pOut,pIn,pmt,hr);
     409                IPin_Disconnect(pOut);
    358410                IPin_Disconnect(pIn);
    359411                goto end;
    360412        }
    361413
    362         EnterCriticalSection( &This->m_csGraphVersion );
    363         This->m_lGraphVersion ++;
    364         LeaveCriticalSection( &This->m_csGraphVersion );
     414        hr = CFilterGraph_GraphChanged(This);
     415        if ( FAILED(hr) )
     416                goto end;
    365417
    366418end:
     
    384436        CFilterGraph_THIS(iface,fgraph);
    385437
    386         FIXME( "(%p)->(%p) stub!\n",This,pPin );
    387 
    388         EnterCriticalSection( &This->m_csGraphVersion );
    389         This->m_lGraphVersion ++;
    390         LeaveCriticalSection( &This->m_csGraphVersion );
    391 
    392         return E_NOTIMPL;
     438        TRACE( "(%p)->(%p)\n",This,pPin );
     439
     440        return IFilterGraph2_ReconnectEx(iface,pPin,NULL);
    393441}
    394442
     
    397445{
    398446        CFilterGraph_THIS(iface,fgraph);
    399 
    400         FIXME( "(%p)->(%p) stub!\n",This,pPin );
    401 
    402         EnterCriticalSection( &This->m_csGraphVersion );
    403         This->m_lGraphVersion ++;
    404         LeaveCriticalSection( &This->m_csGraphVersion );
    405 
    406         return E_NOTIMPL;
     447        IPin* pConnTo;
     448        HRESULT hr;
     449
     450        TRACE( "(%p)->(%p)\n",This,pPin );
     451
     452        QUARTZ_CompList_Lock( This->m_pFilterList );
     453
     454        pConnTo = NULL;
     455        hr = IPin_ConnectedTo(pPin,&pConnTo);
     456        if ( hr == NOERROR && pConnTo != NULL )
     457        {
     458                IPin_Disconnect(pConnTo);
     459                IPin_Release(pConnTo);
     460        }
     461        hr = IPin_Disconnect(pPin);
     462        if ( FAILED(hr) )
     463                goto end;
     464
     465        hr = CFilterGraph_GraphChanged(This);
     466        if ( FAILED(hr) )
     467                goto end;
     468
     469end:
     470        QUARTZ_CompList_Unlock( This->m_pFilterList );
     471
     472        return hr;
    407473}
    408474
     
    411477{
    412478        CFilterGraph_THIS(iface,fgraph);
     479        IUnknown* punk;
     480        IReferenceClock* pClock;
     481        HRESULT hr;
    413482
    414483        FIXME( "(%p)->() stub!\n", This );
    415         return E_NOTIMPL;
     484
     485        /* FIXME - search all filters. */
     486
     487        hr = QUARTZ_CreateSystemClock( NULL, (void**)&punk );
     488        if ( FAILED(hr) )
     489                return hr;
     490        hr = IUnknown_QueryInterface( punk, &IID_IReferenceClock, (void**)&pClock );    IUnknown_Release( punk );
     491        if ( FAILED(hr) )
     492                return hr;
     493
     494        hr = IMediaFilter_SetSyncSource(
     495                CFilterGraph_IMediaFilter(This), pClock );
     496        IReferenceClock_Release( pClock );
     497
     498        return hr;
    416499}
    417500
     
    580663{
    581664        CFilterGraph_THIS(iface,fgraph);
     665        HRESULT hr;
    582666
    583667        FIXME( "(%p)->(%p,%p) stub!\n",This,pPin,pmt );
    584668
    585         EnterCriticalSection( &This->m_csGraphVersion );
    586         This->m_lGraphVersion ++;
    587         LeaveCriticalSection( &This->m_csGraphVersion );
     669        /* reconnect asynchronously. */
     670
     671        hr = CFilterGraph_GraphChanged(This);
    588672
    589673        return E_NOTIMPL;
     
    657741                if ( pItem == NULL )
    658742                        break;
    659                 IFilterGraph2_fnRemoveFilter(
     743                IFilterGraph2_RemoveFilter(
    660744                        (IFilterGraph2*)(&pfg->fgraph),
    661745                        (IBaseFilter*)QUARTZ_CompList_GetItemPtr(pItem) );
Note: See TracChangeset for help on using the changeset viewer.