Commit 25763b6a authored by Gildas Bazin's avatar Gildas Bazin

* modules/access/dshow/*: bug fixes.
parent fe574e12
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* dshow.c : DirectShow access module for vlc * dshow.c : DirectShow access module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: dshow.cpp,v 1.3 2003/08/25 22:57:40 gbazin Exp $ * $Id: dshow.cpp,v 1.4 2003/08/26 19:14:09 gbazin Exp $
* *
* Author: Gildas Bazin <gbazin@netcourrier.com> * Author: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -303,12 +303,13 @@ static int AccessOpen( vlc_object_t *p_this ) ...@@ -303,12 +303,13 @@ static int AccessOpen( vlc_object_t *p_this )
if( !p_sys->i_streams ) if( !p_sys->i_streams )
{ {
/* Uninitialize OLE/COM */
CoUninitialize();
/* Release directshow objects */ /* Release directshow objects */
p_sys->p_control->Release(); p_sys->p_control->Release();
p_sys->p_graph->Release(); p_sys->p_graph->Release();
/* Uninitialize OLE/COM */
CoUninitialize();
free( p_sys->p_header ); free( p_sys->p_header );
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
...@@ -336,7 +337,6 @@ static void AccessClose( vlc_object_t *p_this ) ...@@ -336,7 +337,6 @@ static void AccessClose( vlc_object_t *p_this )
p_sys->p_control->Stop(); p_sys->p_control->Stop();
p_sys->p_control->Release(); p_sys->p_control->Release();
#if 0
/* Remove filters from graph */ /* Remove filters from graph */
for( int i = 0; i < p_sys->i_streams; i++ ) for( int i = 0; i < p_sys->i_streams; i++ )
{ {
...@@ -346,7 +346,6 @@ static void AccessClose( vlc_object_t *p_this ) ...@@ -346,7 +346,6 @@ static void AccessClose( vlc_object_t *p_this )
p_sys->pp_streams[i]->p_capture_filter->Release(); p_sys->pp_streams[i]->p_capture_filter->Release();
} }
p_sys->p_graph->Release(); p_sys->p_graph->Release();
#endif
/* Uninitialize OLE/COM */ /* Uninitialize OLE/COM */
CoUninitialize(); CoUninitialize();
...@@ -705,7 +704,7 @@ static int Read( input_thread_t * p_input, byte_t * p_buffer, size_t i_len ) ...@@ -705,7 +704,7 @@ static int Read( input_thread_t * p_input, byte_t * p_buffer, size_t i_len )
} }
/* Get new sample/frame from next stream */ /* Get new sample/frame from next stream */
//if( p_sream->sample.p_sample ) p_stream->sample.p_sample->Release(); //if( p_stream->sample.p_sample ) p_stream->sample.p_sample->Release();
p_sys->i_current_stream = p_sys->i_current_stream =
(p_sys->i_current_stream + 1) % p_sys->i_streams; (p_sys->i_current_stream + 1) % p_sys->i_streams;
p_stream = p_sys->pp_streams[p_sys->i_current_stream]; p_stream = p_sys->pp_streams[p_sys->i_current_stream];
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* filter.c : DirectShow access module for vlc * filter.c : DirectShow access module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: filter.cpp,v 1.2 2003/08/25 21:45:04 gbazin Exp $ * $Id: filter.cpp,v 1.3 2003/08/26 19:14:10 gbazin Exp $
* *
* Author: Gildas Bazin <gbazin@netcourrier.com> * Author: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -180,11 +180,13 @@ STDMETHODIMP CapturePin::QueryInterface(REFIID riid, void **ppv) ...@@ -180,11 +180,13 @@ STDMETHODIMP CapturePin::QueryInterface(REFIID riid, void **ppv)
if( riid == IID_IUnknown || if( riid == IID_IUnknown ||
riid == IID_IPin ) riid == IID_IPin )
{ {
AddRef();
*ppv = (IPin *)this; *ppv = (IPin *)this;
return NOERROR; return NOERROR;
} }
if( riid == IID_IMemInputPin ) if( riid == IID_IMemInputPin )
{ {
AddRef();
*ppv = (IMemInputPin *)this; *ppv = (IMemInputPin *)this;
return NOERROR; return NOERROR;
} }
...@@ -200,8 +202,7 @@ STDMETHODIMP_(ULONG) CapturePin::AddRef() ...@@ -200,8 +202,7 @@ STDMETHODIMP_(ULONG) CapturePin::AddRef()
msg_Dbg( p_input, "CapturePin::AddRef" ); msg_Dbg( p_input, "CapturePin::AddRef" );
#endif #endif
i_ref++; return i_ref++;
return NOERROR;
}; };
STDMETHODIMP_(ULONG) CapturePin::Release() STDMETHODIMP_(ULONG) CapturePin::Release()
{ {
...@@ -212,7 +213,7 @@ STDMETHODIMP_(ULONG) CapturePin::Release() ...@@ -212,7 +213,7 @@ STDMETHODIMP_(ULONG) CapturePin::Release()
i_ref--; i_ref--;
if( !i_ref ) delete this; if( !i_ref ) delete this;
return NOERROR; return i_ref;
}; };
/* IPin methods */ /* IPin methods */
...@@ -252,6 +253,8 @@ STDMETHODIMP CapturePin::ConnectedTo( IPin **pPin ) ...@@ -252,6 +253,8 @@ STDMETHODIMP CapturePin::ConnectedTo( IPin **pPin )
msg_Dbg( p_input, "CapturePin::ConnectedTo" ); msg_Dbg( p_input, "CapturePin::ConnectedTo" );
#endif #endif
if( !p_connected_pin ) return VFW_E_NOT_CONNECTED;
p_connected_pin->AddRef(); p_connected_pin->AddRef();
*pPin = p_connected_pin; *pPin = p_connected_pin;
...@@ -452,21 +455,25 @@ STDMETHODIMP CaptureFilter::QueryInterface( REFIID riid, void **ppv ) ...@@ -452,21 +455,25 @@ STDMETHODIMP CaptureFilter::QueryInterface( REFIID riid, void **ppv )
if( riid == IID_IUnknown ) if( riid == IID_IUnknown )
{ {
AddRef();
*ppv = (IUnknown *)this; *ppv = (IUnknown *)this;
return NOERROR; return NOERROR;
} }
if( riid == IID_IPersist ) if( riid == IID_IPersist )
{ {
AddRef();
*ppv = (IPersist *)this; *ppv = (IPersist *)this;
return NOERROR; return NOERROR;
} }
if( riid == IID_IMediaFilter ) if( riid == IID_IMediaFilter )
{ {
AddRef();
*ppv = (IMediaFilter *)this; *ppv = (IMediaFilter *)this;
return NOERROR; return NOERROR;
} }
if( riid == IID_IBaseFilter ) if( riid == IID_IBaseFilter )
{ {
AddRef();
*ppv = (IBaseFilter *)this; *ppv = (IBaseFilter *)this;
return NOERROR; return NOERROR;
} }
...@@ -482,8 +489,7 @@ STDMETHODIMP_(ULONG) CaptureFilter::AddRef() ...@@ -482,8 +489,7 @@ STDMETHODIMP_(ULONG) CaptureFilter::AddRef()
msg_Dbg( p_input, "CaptureFilter::AddRef" ); msg_Dbg( p_input, "CaptureFilter::AddRef" );
#endif #endif
i_ref++; return i_ref++;
return NOERROR;
}; };
STDMETHODIMP_(ULONG) CaptureFilter::Release() STDMETHODIMP_(ULONG) CaptureFilter::Release()
{ {
...@@ -494,7 +500,7 @@ STDMETHODIMP_(ULONG) CaptureFilter::Release() ...@@ -494,7 +500,7 @@ STDMETHODIMP_(ULONG) CaptureFilter::Release()
i_ref--; i_ref--;
if( !i_ref ) delete this; if( !i_ref ) delete this;
return NOERROR; return i_ref;
}; };
/* IPersist method */ /* IPersist method */
...@@ -646,6 +652,7 @@ STDMETHODIMP CaptureEnumPins::QueryInterface( REFIID riid, void **ppv ) ...@@ -646,6 +652,7 @@ STDMETHODIMP CaptureEnumPins::QueryInterface( REFIID riid, void **ppv )
if( riid == IID_IUnknown || if( riid == IID_IUnknown ||
riid == IID_IEnumPins ) riid == IID_IEnumPins )
{ {
AddRef();
*ppv = (IEnumPins *)this; *ppv = (IEnumPins *)this;
return NOERROR; return NOERROR;
} }
...@@ -661,8 +668,7 @@ STDMETHODIMP_(ULONG) CaptureEnumPins::AddRef() ...@@ -661,8 +668,7 @@ STDMETHODIMP_(ULONG) CaptureEnumPins::AddRef()
msg_Dbg( p_input, "CaptureEnumPins::AddRef" ); msg_Dbg( p_input, "CaptureEnumPins::AddRef" );
#endif #endif
i_ref++; return i_ref++;
return NOERROR;
}; };
STDMETHODIMP_(ULONG) CaptureEnumPins::Release() STDMETHODIMP_(ULONG) CaptureEnumPins::Release()
{ {
...@@ -673,7 +679,7 @@ STDMETHODIMP_(ULONG) CaptureEnumPins::Release() ...@@ -673,7 +679,7 @@ STDMETHODIMP_(ULONG) CaptureEnumPins::Release()
i_ref--; i_ref--;
if( !i_ref ) delete this; if( !i_ref ) delete this;
return NOERROR; return i_ref;
}; };
/* IEnumPins */ /* IEnumPins */
...@@ -693,10 +699,9 @@ STDMETHODIMP CaptureEnumPins::Next( ULONG cPins, IPin ** ppPins, ...@@ -693,10 +699,9 @@ STDMETHODIMP CaptureEnumPins::Next( ULONG cPins, IPin ** ppPins,
pPin->AddRef(); pPin->AddRef();
*pcFetched = 1; *pcFetched = 1;
i_position++; i_position++;
return NOERROR;
} }
return S_FALSE; return *pcFetched == cPins ? NOERROR : S_FALSE;
}; };
STDMETHODIMP CaptureEnumPins::Skip( ULONG cPins ) STDMETHODIMP CaptureEnumPins::Skip( ULONG cPins )
{ {
...@@ -772,6 +777,7 @@ STDMETHODIMP CaptureEnumMediaTypes::QueryInterface( REFIID riid, void **ppv ) ...@@ -772,6 +777,7 @@ STDMETHODIMP CaptureEnumMediaTypes::QueryInterface( REFIID riid, void **ppv )
if( riid == IID_IUnknown || if( riid == IID_IUnknown ||
riid == IID_IEnumMediaTypes ) riid == IID_IEnumMediaTypes )
{ {
AddRef();
*ppv = (IEnumMediaTypes *)this; *ppv = (IEnumMediaTypes *)this;
return NOERROR; return NOERROR;
} }
...@@ -787,8 +793,7 @@ STDMETHODIMP_(ULONG) CaptureEnumMediaTypes::AddRef() ...@@ -787,8 +793,7 @@ STDMETHODIMP_(ULONG) CaptureEnumMediaTypes::AddRef()
msg_Dbg( p_input, "CaptureEnumMediaTypes::AddRef" ); msg_Dbg( p_input, "CaptureEnumMediaTypes::AddRef" );
#endif #endif
i_ref++; return i_ref++;
return NOERROR;
}; };
STDMETHODIMP_(ULONG) CaptureEnumMediaTypes::Release() STDMETHODIMP_(ULONG) CaptureEnumMediaTypes::Release()
{ {
...@@ -799,7 +804,7 @@ STDMETHODIMP_(ULONG) CaptureEnumMediaTypes::Release() ...@@ -799,7 +804,7 @@ STDMETHODIMP_(ULONG) CaptureEnumMediaTypes::Release()
i_ref--; i_ref--;
if( !i_ref ) delete this; if( !i_ref ) delete this;
return NOERROR; return i_ref;
}; };
/* IEnumMediaTypes */ /* IEnumMediaTypes */
...@@ -833,7 +838,7 @@ STDMETHODIMP CaptureEnumMediaTypes::Skip( ULONG cMediaTypes ) ...@@ -833,7 +838,7 @@ STDMETHODIMP CaptureEnumMediaTypes::Skip( ULONG cMediaTypes )
msg_Dbg( p_input, "CaptureEnumMediaTypes::Skip" ); msg_Dbg( p_input, "CaptureEnumMediaTypes::Skip" );
#endif #endif
if( cMediaTypes > 1 ) if( cMediaTypes > 0 )
{ {
return S_FALSE; return S_FALSE;
} }
......
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