From fd10d437239195100b0f35c296023757ca1b52f7 Mon Sep 17 00:00:00 2001 From: voroshil Date: Sat, 24 Nov 2007 06:01:18 +0000 Subject: =?UTF-8?q?=D0=A1reate=20empty=20format=20arrays=20in=20case=20of?= =?UTF-8?q?=20error=20in=20init=5Fchain=5Fcommon.=20Fixes=20segfault=20for?= =?UTF-8?q?=20cards=20without=20audio=20capture=20pin=20in=20main=20captur?= =?UTF-8?q?e=20filter.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25153 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/tvi_dshow.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'stream') diff --git a/stream/tvi_dshow.c b/stream/tvi_dshow.c index 22c5c83be4..ba684dd236 100644 --- a/stream/tvi_dshow.c +++ b/stream/tvi_dshow.c @@ -2497,8 +2497,7 @@ static HRESULT init_chain_common(ICaptureGraphBuilder2 *pBuilder, chain_t *chain mp_msg(MSGT_TV, MSGL_DBG2, "Unable to use IAMStreamConfig for retriving available formats (Error:0x%x). Using EnumMediaTypes instead\n", (unsigned int)hr); hr = get_available_formats_pin(pBuilder, chain); if(FAILED(hr)){ - chain->arpmt = calloc(1, sizeof(AM_MEDIA_TYPE *)); - chain->arStreamCaps = calloc(1, sizeof(void*)); + return hr; } } chain->nFormatUsed = 0; @@ -2815,11 +2814,33 @@ static int init(priv_t * priv) if(FAILED(hr)) break; - // Audio chain initialization - init_chain_common(priv->pBuilder, priv->chains[1]); + /* + Audio chain initialization + Since absent audio stream is not fatal, + at least one NULL pointer should be kept in format arrays + (to avoid another additional check everywhere for array presence). + */ + hr = init_chain_common(priv->pBuilder, priv->chains[1]); + if(FAILED(hr)) + { + mp_msg(MSGT_TV, MSGL_V, "tvi_dshow: Unable to initialize audio chain (Error:0x%x). Audio disabled\n", (unsigned long)hr); + priv->chains[1]->arpmt=calloc(1, sizeof(AM_MEDIA_TYPE*)); + priv->chains[1]->arStreamCaps=calloc(1, sizeof(void*)); + } - // VBI chain initialization - init_chain_common(priv->pBuilder, priv->chains[2]); + /* + VBI chain initialization + Since absent VBI stream is not fatal, + at least one NULL pointer should be kept in format arrays + (to avoid another additional check everywhere for array presence). + */ + hr = init_chain_common(priv->pBuilder, priv->chains[2]); + if(FAILED(hr)) + { + mp_msg(MSGT_TV, MSGL_V, "tvi_dshow: Unable to initialize VBI chain (Error:0x%x). Teletext disabled\n", (unsigned long)hr); + priv->chains[2]->arpmt=calloc(1, sizeof(AM_MEDIA_TYPE*)); + priv->chains[2]->arStreamCaps=calloc(1, sizeof(void*)); + } if (!priv->chains[0]->pStreamConfig) mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TVI_DS_ChangingWidthHeightNotSupported); -- cgit v1.2.3