From 5c684e7e4c2fda5137aa16a3e13e394ef45a8aa1 Mon Sep 17 00:00:00 2001 From: voroshil Date: Sun, 18 Nov 2007 05:02:49 +0000 Subject: 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 --- stream/tvi_dshow.c | 89 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 71 insertions(+), 18 deletions(-) (limited to 'stream') diff --git a/stream/tvi_dshow.c b/stream/tvi_dshow.c index 75f745508b..3a8f77ed7d 100644 --- a/stream/tvi_dshow.c +++ b/stream/tvi_dshow.c @@ -2402,15 +2402,12 @@ static inline int audio_buf_size_from_video(int video_buf_size, int video_bitrat } /** - * \brief playback/capture real start - * - * \param priv driver's private data structure - * - * \return 1 if success, 0 - otherwise + * \brief build video stream chain in graph + * \param priv private data structure * - * 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; + } + 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->immediate_mode){ + + 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. */ -- cgit v1.2.3