Move chains building code into separate routines.

This makes code more readable and will allow
building particular chain before start().



git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25085 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
voroshil 2007-11-18 05:02:49 +00:00
parent afa755a662
commit 5c684e7e4c
1 changed files with 71 additions and 18 deletions

View File

@ -2402,15 +2402,12 @@ static inline int audio_buf_size_from_video(int video_buf_size, int video_bitrat
}
/**
* \brief playback/capture real start
* \brief build video stream chain in graph
* \param priv private data structure
*
* \param priv driver's private data structure
*
* \return 1 if success, 0 - otherwise
*
* TODO: move some code from init() here
*/
static int start(priv_t * priv)
* \return S_OK if chain was built successfully, apropriate error code otherwise
*/
static HRESULT build_video_chain(priv_t *priv)
{
HRESULT hr;
@ -2421,14 +2418,6 @@ static int start(priv_t * priv)
}
}
if (!priv->immediate_mode && priv->pAudioStreamConfig) {
hr = OLE_CALL_ARGS(priv->pAudioStreamConfig, SetFormat,
priv->pmtAudio);
if (FAILED(hr)) {
mp_msg(MSGT_TV,MSGL_ERR,MSGTR_TVI_DS_UnableSelectAudioFormat, (unsigned int)hr);
}
}
priv->v_buf=calloc(1,sizeof(grabber_ringbuffer_t));
if (priv->tv_param->buffer_size >= 0) {
@ -2441,9 +2430,33 @@ static int start(priv_t * priv)
hr=build_sub_graph(priv, priv->pVideoFilter, priv->v_buf, priv->pmtVideo,&PIN_CATEGORY_CAPTURE);
if(FAILED(hr)){
mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_UnableBuildVideoSubGraph,(unsigned int)hr);
return 0;
return hr;
}
if(priv->pmtAudio && !priv->immediate_mode){
return S_OK;
}
/**
* \brief build audio stream chain in graph
* \param priv private data structure
*
* \return S_OK if chain was built successfully, apropriate error code otherwise
*/
static HRESULT build_audio_chain(priv_t *priv)
{
HRESULT hr;
if(priv->immediate_mode)
return S_OK;
if (priv->pAudioStreamConfig) {
hr = OLE_CALL_ARGS(priv->pAudioStreamConfig, SetFormat,
priv->pmtAudio);
if (FAILED(hr)) {
mp_msg(MSGT_TV,MSGL_ERR,MSGTR_TVI_DS_UnableSelectAudioFormat, (unsigned int)hr);
}
}
if(priv->pmtAudio){
priv->a_buf=calloc(1,sizeof(grabber_ringbuffer_t));
/* let the audio buffer be the same size (in seconds) than video one */
@ -2458,8 +2471,20 @@ static int start(priv_t * priv)
return 0;
}
}
return S_OK;
}
/**
* \brief build VBI stream chain in graph
* \param priv private data structure
*
* \return S_OK if chain was built successfully, apropriate error code otherwise
*/
static HRESULT build_vbi_chain(priv_t *priv)
{
#ifdef HAVE_TV_TELETEXT
HRESULT hr;
if(priv->tv_param->tdevice)
{
priv->vbi_buf=calloc(1,sizeof(grabber_ringbuffer_t));
@ -2474,6 +2499,34 @@ static int start(priv_t * priv)
}
}
#endif
return S_OK;
}
/**
* \brief playback/capture real start
*
* \param priv driver's private data structure
*
* \return 1 if success, 0 - otherwise
*
* TODO: move some code from init() here
*/
static int start(priv_t * priv)
{
HRESULT hr;
hr = build_video_chain(priv);
if(FAILED(hr))
return 0;
hr = build_audio_chain(priv);
if(FAILED(hr))
return 0;
hr = build_vbi_chain(priv);
if(FAILED(hr))
return 0;
/*
Graph is ready to capture. Starting graph.
*/