[vlc-commits] access: dvb: scan: use fixed packet buffer
Francois Cartegnie
git at videolan.org
Thu Apr 21 20:23:55 CEST 2016
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Apr 20 15:02:30 2016 +0200| [8583802633ad0f0873acd3926fe7ae2b43f5d486] | committer: Francois Cartegnie
access: dvb: scan: use fixed packet buffer
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8583802633ad0f0873acd3926fe7ae2b43f5d486
---
modules/access/dvb/access.c | 12 ++++--------
modules/access/dvb/dvb.h | 2 ++
modules/access/dvb/scan.c | 34 +++++++++++-----------------------
modules/access/dvb/scan.h | 2 +-
4 files changed, 18 insertions(+), 32 deletions(-)
diff --git a/modules/access/dvb/access.c b/modules/access/dvb/access.c
index 97f1ed5..5d61616 100644
--- a/modules/access/dvb/access.c
+++ b/modules/access/dvb/access.c
@@ -99,7 +99,6 @@ static block_t *BlockScan( access_t * );
#define DVB_READ_ONCE 20
#define DVB_READ_ONCE_START 2
#define DVB_READ_ONCE_SCAN 1
-#define TS_PACKET_SIZE 188
#define DVB_SCAN_MAX_SIGNAL_TIME (1000*1000)
#define DVB_SCAN_MAX_LOCK_TIME (5000*1000)
@@ -355,19 +354,16 @@ static block_t *BlockScan( access_t *p_access )
if( i_probe_start == 0 )
i_probe_start = mdate();
- block_t *p_block = block_Alloc( DVB_READ_ONCE_SCAN * TS_PACKET_SIZE );
-
- if( ( i_ret = read( p_sys->i_handle, p_block->p_buffer,
- DVB_READ_ONCE_SCAN * TS_PACKET_SIZE ) ) <= 0 )
+ ssize_t i_read = read( p_sys->i_handle, &p_sys->packet, TS_PACKET_SIZE );
+ if( i_read <= 0 )
{
msg_Warn( p_access, "read failed: %s", vlc_strerror_c(errno) );
- block_Release( p_block );
continue;
}
- p_block->i_buffer = i_ret;
/* */
- if( scan_session_Push( session, p_block ) )
+ if( i_read == TS_PACKET_SIZE &&
+ scan_session_Push( session, &p_sys->packet ) )
{
msg_Dbg( p_access, "finished scanning current frequency" );
break;
diff --git a/modules/access/dvb/dvb.h b/modules/access/dvb/dvb.h
index 9c5eadf..fee35bf 100644
--- a/modules/access/dvb/dvb.h
+++ b/modules/access/dvb/dvb.h
@@ -49,6 +49,7 @@ typedef struct
} frontend_status_t;
#define MAX_DEMUX 256
+#define TS_PACKET_SIZE 188
struct scan_t;
struct scan_parameter_t;
@@ -70,6 +71,7 @@ struct access_sys_t
/* Scan */
struct scan_t *scan;
+ uint8_t packet[TS_PACKET_SIZE];
};
#define VIDEO0_TYPE 1
diff --git a/modules/access/dvb/scan.c b/modules/access/dvb/scan.c
index bc55f46..a2ec09e 100644
--- a/modules/access/dvb/scan.c
+++ b/modules/access/dvb/scan.c
@@ -1523,37 +1523,33 @@ block_t *scan_GetM3U( scan_t *p_scan )
return p_playlist ? block_ChainGather( p_playlist ) : NULL;
}
-bool scan_session_Push( scan_session_t *p_scan, block_t *p_block )
+#define dvbpsi_packet_push(a,b) dvbpsi_packet_push(a, (uint8_t *)b)
+
+bool scan_session_Push( scan_session_t *p_scan, const uint8_t *p_packet )
{
- if( p_block->i_buffer < 188 || p_block->p_buffer[0] != 0x47 )
- {
- block_Release( p_block );
+ if( p_packet[0] != 0x47 )
return false;
- }
/* */
- const int i_pid = ( (p_block->p_buffer[1]&0x1f)<<8) | p_block->p_buffer[2];
+ const int i_pid = ( (p_packet[1]&0x1f)<<8) | p_packet[2];
if( i_pid == 0x00 )
{
if( !p_scan->p_pathandle )
{
p_scan->p_pathandle = dvbpsi_new( &dvbpsi_messages, DVBPSI_MSG_DEBUG );
if( !p_scan->p_pathandle )
- {
- block_Release( p_block );
return false;
- }
+
p_scan->p_pathandle->p_sys = (void *) VLC_OBJECT(p_scan->p_obj);
if( !dvbpsi_pat_attach( p_scan->p_pathandle, (dvbpsi_pat_callback)PATCallBack, p_scan ) )
{
dvbpsi_delete( p_scan->p_pathandle );
p_scan->p_pathandle = NULL;
- block_Release( p_block );
return false;
}
}
if( p_scan->p_pathandle )
- dvbpsi_packet_push( p_scan->p_pathandle, p_block->p_buffer );
+ dvbpsi_packet_push( p_scan->p_pathandle, p_packet );
}
else if( i_pid == 0x11 )
{
@@ -1561,22 +1557,19 @@ bool scan_session_Push( scan_session_t *p_scan, block_t *p_block )
{
p_scan->p_sdthandle = dvbpsi_new( &dvbpsi_messages, DVBPSI_MSG_DEBUG );
if( !p_scan->p_sdthandle )
- {
- block_Release( p_block );
return false;
- }
+
p_scan->p_sdthandle->p_sys = (void *) VLC_OBJECT(p_scan->p_obj);
if( !dvbpsi_AttachDemux( p_scan->p_sdthandle, (dvbpsi_demux_new_cb_t)PSINewTableCallBack, p_scan ) )
{
dvbpsi_delete( p_scan->p_sdthandle );
p_scan->p_sdthandle = NULL;
- block_Release( p_block );
return false;
}
}
if( p_scan->p_sdthandle )
- dvbpsi_packet_push( p_scan->p_sdthandle, p_block->p_buffer );
+ dvbpsi_packet_push( p_scan->p_sdthandle, p_packet );
}
else if( p_scan->b_use_nit ) /*if( i_pid == p_scan->i_nit_pid )*/
{
@@ -1584,25 +1577,20 @@ bool scan_session_Push( scan_session_t *p_scan, block_t *p_block )
{
p_scan->p_nithandle = dvbpsi_new( &dvbpsi_messages, DVBPSI_MSG_DEBUG );
if( !p_scan->p_nithandle )
- {
- block_Release( p_block );
return false;
- }
+
p_scan->p_nithandle->p_sys = (void *) VLC_OBJECT(p_scan->p_obj);
if( !dvbpsi_AttachDemux( p_scan->p_nithandle, (dvbpsi_demux_new_cb_t)PSINewTableCallBack, p_scan ) )
{
dvbpsi_delete( p_scan->p_nithandle );
p_scan->p_nithandle = NULL;
- block_Release( p_block );
return false;
}
}
if( p_scan->p_nithandle )
- dvbpsi_packet_push( p_scan->p_nithandle, p_block->p_buffer );
+ dvbpsi_packet_push( p_scan->p_nithandle, p_packet );
}
- block_Release( p_block );
-
return p_scan->local.p_pat && p_scan->local.p_sdt &&
(!p_scan->b_use_nit || p_scan->local.p_nit);
}
diff --git a/modules/access/dvb/scan.h b/modules/access/dvb/scan.h
index 6b4a306..dc5ce7a 100644
--- a/modules/access/dvb/scan.h
+++ b/modules/access/dvb/scan.h
@@ -90,6 +90,6 @@ typedef struct scan_session_t scan_session_t;
scan_session_t *scan_session_New( scan_t *, const scan_tuner_config_t * );
void scan_session_Destroy( scan_t *, scan_session_t * );
-bool scan_session_Push( scan_session_t *p_scan, block_t *p_block );
+bool scan_session_Push( scan_session_t *p_scan, const uint8_t * );
void scan_session_SetSNR( scan_session_t *p_scan, int i_snr );
unsigned scan_session_GetTablesTimeout( const scan_session_t * );
More information about the vlc-commits
mailing list