From dcfeb51b013131e5fe7f708751b2105017ec2e5c Mon Sep 17 00:00:00 2001 From: MelwareDE Date: Tue, 29 Jun 2010 10:21:31 +0000 Subject: [PATCH] Cancel Diva stream if stream control command returned error --- chan_capi.c | 19 +++++++++++++++++++ chan_capi_utils.c | 3 +++ 2 files changed, 22 insertions(+) diff --git a/chan_capi.c b/chan_capi.c index 33029cd..6df006b 100644 --- a/chan_capi.c +++ b/chan_capi.c @@ -5309,6 +5309,25 @@ static void capidev_handle_msg(_cmsg *CMSG) break; #ifdef DIVA_STREAMING case _DI_STREAM_CTRL: + wInfo = (unsigned short)(CMSG->Class >> 16); + if (wInfo != 0) { + int do_lock = (i == 0); + struct capi_pvt *ii = (i != 0) ? i : capi_find_interface_by_msgnum(wMsgNum); + + cc_log(LOG_ERROR, "stream error %04x for %s=%#x\n", wInfo, PLCI != 0 ? "PLCI" : "MsgNr", PLCI != 0 ? PLCI : wMsgNum); + + if (ii != 0) { + if (do_lock) { + cc_mutex_lock(&ii->lock); + } + capi_DivaStreamingRemove(ii); + if (do_lock) { + cc_mutex_unlock(&ii->lock); + } + } else { + cc_log(LOG_ERROR, "stream error %04x for MsgNr %04x, unexpected", wInfo, wMsgNum); + } + } break; #endif default: diff --git a/chan_capi_utils.c b/chan_capi_utils.c index 1fd2f5e..ae160e6 100644 --- a/chan_capi_utils.c +++ b/chan_capi_utils.c @@ -1236,6 +1236,9 @@ static int divaStreamingMessageRx (void* user_context, dword message, dword leng } else if (message_type == 0xff) { /* System message */ switch ((byte)(message >> 8)) { case DIVA_STREAM_MESSAGE_INIT: /* Stream active */ + if (pE->PLCI == 0 && pE->i != 0) { + pE->PLCI = pE->i->PLCI; + } cc_verbose(3, 0, VERBOSE_PREFIX_2 "%s: stream active (PLCI=%#x)\n", pE->vname, pE->PLCI); if (pE->diva_stream_state == DivaStreamCreated) { pE->diva_stream_state = DivaStreamActive;