From patchwork Mon Dec 30 12:48:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Roth?= X-Patchwork-Id: 3419151 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4C9B09F37A for ; Mon, 30 Dec 2013 12:49:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8FD87200ED for ; Mon, 30 Dec 2013 12:49:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AB4EE200E6 for ; Mon, 30 Dec 2013 12:49:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755705Ab3L3MtZ (ORCPT ); Mon, 30 Dec 2013 07:49:25 -0500 Received: from mail-ea0-f179.google.com ([209.85.215.179]:58190 "EHLO mail-ea0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755619Ab3L3MtY (ORCPT ); Mon, 30 Dec 2013 07:49:24 -0500 Received: by mail-ea0-f179.google.com with SMTP id r15so5084541ead.38 for ; Mon, 30 Dec 2013 04:49:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=L9BhWGdeqmz3rNDFgSo8r/cZ5mRyG7MrlHyjKFhScng=; b=FyJdDtofvHX69w/L0KaXYmKxMaHke7SAcaCC21fZLY09h/puJIJyROUVXTI9O+IG/m fmDqxSwLvVTOP8B76vbeDYWxP4dVSJRP6SCWFHx8IjnyzW/1uB365/wCGccK1fkYulDx j/t8e0m0T8tD7yr72fvzr+YsRMSpU7GFyowxNnh/fpCYjY395ZEtV5ZBZTca80nVTPlS b365CFyJd1cHWzsCju8jnTW9my4fbNbeNHyA8PBFvgzzhA4XSUEvlv01N5gNQkOcMpkv 32eIYySG711RZyUpVQgBPqscylxU93gPnINe4+6xX+tDQAXp1B29mdXmecNZc9nZUL1P 3r5g== X-Received: by 10.14.251.68 with SMTP id a44mr1491824ees.64.1388407763735; Mon, 30 Dec 2013 04:49:23 -0800 (PST) Received: from neutrino.exnihilo (140-227.61-188.cust.bluewin.ch. [188.61.227.140]) by mx.google.com with ESMTPSA id z42sm108428856eeo.17.2013.12.30.04.49.22 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 30 Dec 2013 04:49:22 -0800 (PST) From: =?UTF-8?q?Andr=C3=A9=20Roth?= To: linux-media@vger.kernel.org Cc: =?UTF-8?q?Andr=C3=A9=20Roth?= Subject: [PATCH 01/18] libdvbv5: fix reading multisection tables Date: Mon, 30 Dec 2013 13:48:34 +0100 Message-Id: <1388407731-24369-1-git-send-email-neolynx@gmail.com> X-Mailer: git-send-email 1.8.3.2 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: André Roth --- lib/libdvbv5/dvb-scan.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c index e9ccc72..520bf9c 100644 --- a/lib/libdvbv5/dvb-scan.c +++ b/lib/libdvbv5/dvb-scan.c @@ -96,9 +96,13 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, uint8_t *buf = NULL; uint8_t *tbl = NULL; ssize_t table_length = 0; + + // handle sections + int start_id = -1; + int start_section = -1; int first_section = -1; int last_section = -1; - int table_id = -1; + /*int table_id = -1;*/ int sections = 0; struct dmx_sct_filter_params f; struct dvb_table_header *h; @@ -108,7 +112,6 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, *table = NULL; // FIXME: verify known table - memset(&f, 0, sizeof(f)); f.pid = pid; f.filter.filter[0] = tid; @@ -185,24 +188,27 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, h = (struct dvb_table_header *)buf; dvb_table_header_init(h); + + /* dvb_logdbg( "dvb_read_section: id %d, section %d/%d, current: %d", h->id, h->section_id, h->last_section, h->current_next ); */ + if (start_id == h->id && start_section == h->section_id) { + dvb_logdbg( "dvb_read_section: section repeated, reading done" ); + break; + } + if (start_id == -1) start_id = h->id; + if (start_section == -1) start_section = h->section_id; + if (id != -1 && h->id != id) { /* search for a specific table id */ continue; - } else { - if (table_id == -1) - table_id = h->id; - else if (h->id != table_id) { - dvb_logwarn("dvb_read_section: table ID mismatch reading multi section table: %d != %d", h->id, table_id); - continue; - } } + /*dvb_logerr("dvb_read_section: got section %d, last %d, filter %d", h->section_id, h->last_section, id );*/ /* handle the sections */ if (first_section == -1) first_section = h->section_id; - else if (h->section_id == first_section) + else if (start_id == h->id && h->section_id == first_section) break; - if (last_section == -1) + if (last_section == -1 || h->last_section > last_section) last_section = h->last_section; if (!tbl) { @@ -228,10 +234,14 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, else dvb_logerr("dvb_read_section: no initializer for table %d", tid); - if (++sections == last_section + 1) + if (id != -1 && ++sections == last_section + 1) { + dvb_logerr("dvb_read_section: ++sections == last_section + 1"); break; + } } - free(buf); + + if (buf) + free(buf); dvb_dmx_stop(dmx_fd);