[vlc-commits] demux: ty: fix all warnings
Francois Cartegnie
git at videolan.org
Mon Dec 24 12:06:37 CET 2018
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Dec 24 12:01:01 2018 +0100| [52dbf22859e581fa5af74600247e9a0340d47c38] | committer: Francois Cartegnie
demux: ty: fix all warnings
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=52dbf22859e581fa5af74600247e9a0340d47c38
---
modules/demux/ty.c | 75 +++++++++++++++++++++++++++++++++---------------------
1 file changed, 46 insertions(+), 29 deletions(-)
diff --git a/modules/demux/ty.c b/modules/demux/ty.c
index d985c359cc..a305ab03be 100644
--- a/modules/demux/ty.c
+++ b/modules/demux/ty.c
@@ -268,7 +268,7 @@ static ty_rec_hdr_t *parse_chunk_headers( const uint8_t *p_buf,
int i_num_recs, int *pi_payload_size);
static int probe_stream(demux_t *p_demux);
static void analyze_chunk(demux_t *p_demux, const uint8_t *p_chunk);
-static void parse_master(demux_t *p_demux);
+static int parse_master(demux_t *p_demux);
static int DemuxRecVideo( demux_t *p_demux, ty_rec_hdr_t *rec_hdr, block_t *p_block_in );
static int DemuxRecAudio( demux_t *p_demux, ty_rec_hdr_t *rec_hdr, block_t *p_block_in );
@@ -1044,12 +1044,12 @@ static int ty_stream_seek_pct(demux_t *p_demux, double seek_pct)
p_sys->i_cur_chunk = seek_pos / CHUNK_SIZE;
/* try to read the part header (master chunk) if it's there */
- if ( vlc_stream_Seek( p_demux->s, i_cur_part * TIVO_PART_LENGTH ))
+ if (vlc_stream_Seek( p_demux->s, i_cur_part * TIVO_PART_LENGTH ) ||
+ parse_master(p_demux) != VLC_SUCCESS)
{
/* can't seek stream */
return VLC_EGENERIC;
}
- parse_master(p_demux);
/* now for the actual chunk */
if ( vlc_stream_Seek( p_demux->s, p_sys->i_cur_chunk * CHUNK_SIZE))
@@ -1073,8 +1073,9 @@ static int ty_stream_seek_pct(demux_t *p_demux, double seek_pct)
l_skip_amt = 0;
for ( int i=0; i<p_sys->i_cur_rec; i++)
l_skip_amt += p_sys->rec_hdrs[i].l_rec_size;
- vlc_stream_Seek(p_demux->s, ((p_sys->i_cur_chunk-1) * CHUNK_SIZE) +
- (p_sys->i_num_recs * 16) + l_skip_amt + 4);
+ if( vlc_stream_Seek(p_demux->s, ((p_sys->i_cur_chunk-1) * CHUNK_SIZE) +
+ (p_sys->i_num_recs * 16) + l_skip_amt + 4) != VLC_SUCCESS )
+ return VLC_EGENERIC;
/* to hell with syncing any audio or video, just start reading records... :) */
/*p_sys->lastAudioPTS = p_sys->lastVideoPTS = VLC_TICK_INVALID;*/
@@ -1481,13 +1482,15 @@ static int ty_stream_seek_time(demux_t *p_demux, uint64_t l_seek_time)
msg_Dbg(p_demux, "skipping to prior segment.");
/* load previous part */
if (i_cur_part == 0) {
- vlc_stream_Seek(p_demux->s, l_cur_pos);
+ p_sys->eof = (vlc_stream_Seek(p_demux->s, l_cur_pos) != VLC_SUCCESS);
msg_Err(p_demux, "Attempt to seek past BOF");
return VLC_EGENERIC;
}
- vlc_stream_Seek(p_demux->s, (i_cur_part - 1) * TIVO_PART_LENGTH);
+ if(vlc_stream_Seek(p_demux->s, (i_cur_part - 1) * TIVO_PART_LENGTH) != VLC_SUCCESS)
+ return VLC_EGENERIC;
i_cur_part--;
- parse_master(p_demux);
+ if(parse_master(p_demux) != VLC_SUCCESS)
+ return VLC_EGENERIC;
}
/* maybe we need to go forward */
while (l_seek_time > p_sys->l_final_ty_pts) {
@@ -1495,13 +1498,15 @@ static int ty_stream_seek_time(demux_t *p_demux, uint64_t l_seek_time)
/* load next part */
if ((i_cur_part + 1) * TIVO_PART_LENGTH > p_sys->i_stream_size) {
/* error; restore previous file position */
- vlc_stream_Seek(p_demux->s, l_cur_pos);
+ p_sys->eof = (vlc_stream_Seek(p_demux->s, l_cur_pos) != VLC_SUCCESS);
msg_Err(p_demux, "seek error");
return VLC_EGENERIC;
}
- vlc_stream_Seek(p_demux->s, (i_cur_part + 1) * TIVO_PART_LENGTH);
+ if(vlc_stream_Seek(p_demux->s, (i_cur_part + 1) * TIVO_PART_LENGTH) != VLC_SUCCESS)
+ return VLC_EGENERIC;
i_cur_part++;
- parse_master(p_demux);
+ if(parse_master(p_demux) != VLC_SUCCESS)
+ return VLC_EGENERIC;
}
/* our target is somewhere within this part;
@@ -1525,13 +1530,15 @@ static int ty_stream_seek_time(demux_t *p_demux, uint64_t l_seek_time)
if (i == p_sys->i_seq_table_size) {
if ((i_cur_part + 1) * TIVO_PART_LENGTH > p_sys->i_stream_size) {
/* error; restore previous file position */
- vlc_stream_Seek(p_demux->s, l_cur_pos);
+ p_sys->eof = (vlc_stream_Seek(p_demux->s, l_cur_pos) != VLC_SUCCESS);
msg_Err(p_demux, "seek error");
return VLC_EGENERIC;
}
- vlc_stream_Seek(p_demux->s, (i_cur_part + 1) * TIVO_PART_LENGTH);
+ if(vlc_stream_Seek(p_demux->s, (i_cur_part + 1) * TIVO_PART_LENGTH) != VLC_SUCCESS)
+ return VLC_EGENERIC;
i_cur_part++;
- parse_master(p_demux);
+ if(parse_master(p_demux) != VLC_SUCCESS)
+ return VLC_EGENERIC;
i_seq_entry = 0;
}
@@ -1546,8 +1553,9 @@ static int ty_stream_seek_time(demux_t *p_demux, uint64_t l_seek_time)
/* check this chunk's SEQ header timestamp */
msg_Dbg(p_demux, "has SEQ. seeking to chunk at 0x%"PRIu64,
(i_cur_part * TIVO_PART_LENGTH) + l_chunk_offset);
- vlc_stream_Seek(p_demux->s, (i_cur_part * TIVO_PART_LENGTH) +
- l_chunk_offset);
+ if(vlc_stream_Seek(p_demux->s, (i_cur_part * TIVO_PART_LENGTH) +
+ l_chunk_offset) != VLC_SUCCESS)
+ return VLC_EGENERIC;
// TODO: we don't have to parse the full header set;
// just test the seq_rec entry for its timestamp
p_sys->i_stuff_cnt = 0;
@@ -1556,7 +1564,8 @@ static int ty_stream_seek_time(demux_t *p_demux, uint64_t l_seek_time)
if (p_sys->i_seq_rec < 0 || p_sys->i_seq_rec > p_sys->i_num_recs) {
msg_Err(p_demux, "no SEQ hdr in chunk; table had one.");
/* Seek to beginning of original chunk & reload it */
- vlc_stream_Seek(p_demux->s, (l_cur_pos / CHUNK_SIZE) * CHUNK_SIZE);
+ if(vlc_stream_Seek(p_demux->s, (l_cur_pos / CHUNK_SIZE) * CHUNK_SIZE) != VLC_SUCCESS)
+ p_sys->eof = true;
p_sys->i_stuff_cnt = 0;
get_chunk_header(p_demux);
return VLC_EGENERIC;
@@ -1589,7 +1598,8 @@ static int ty_stream_seek_time(demux_t *p_demux, uint64_t l_seek_time)
i_skip_cnt = 0;
for (int j=0; j<p_sys->i_seq_rec; j++)
i_skip_cnt += p_sys->rec_hdrs[j].l_rec_size;
- vlc_stream_Read(p_demux->s, NULL, i_skip_cnt);
+ if(vlc_stream_Read(p_demux->s, NULL, i_skip_cnt) != i_skip_cnt)
+ return VLC_EGENERIC;
p_sys->i_cur_rec = p_sys->i_seq_rec;
//p_sys->l_last_ty_pts = p_sys->rec_hdrs[p_sys->i_seq_rec].l_ty_pts;
//p_sys->l_last_ty_pts_sync = p_sys->lastAudioPTS;
@@ -1601,7 +1611,7 @@ static int ty_stream_seek_time(demux_t *p_demux, uint64_t l_seek_time)
/* parse a master chunk, filling the SEQ table and other variables.
* We assume the stream is currently pointing to it.
*/
-static void parse_master(demux_t *p_demux)
+static int parse_master(demux_t *p_demux)
{
demux_sys_t *p_sys = p_demux->p_sys;
uint8_t mst_buf[32];
@@ -1618,7 +1628,8 @@ static void parse_master(demux_t *p_demux)
free(p_sys->seq_table);
/* parse header info */
- vlc_stream_Read(p_demux->s, mst_buf, 32);
+ if( vlc_stream_Read(p_demux->s, mst_buf, 32) != 32 )
+ return VLC_EGENERIC;
uint32_t i_map_size = U32_AT(&mst_buf[20]); /* size of bitmask, in bytes */
uint32_t i = U32_AT(&mst_buf[28]); /* size of SEQ table, in bytes */
@@ -1629,7 +1640,7 @@ static void parse_master(demux_t *p_demux)
if(p_sys->i_seq_table_size == 0)
{
p_sys->seq_table = NULL;
- return;
+ return VLC_SUCCESS;
}
/* parse all the entries */
@@ -1637,16 +1648,19 @@ static void parse_master(demux_t *p_demux)
if (p_sys->seq_table == NULL)
{
p_sys->i_seq_table_size = 0;
- return;
+ return VLC_SUCCESS;
}
for (unsigned j=0; j<p_sys->i_seq_table_size; j++) {
- vlc_stream_Read(p_demux->s, mst_buf, 8);
+ if(vlc_stream_Read(p_demux->s, mst_buf, 8) != 8)
+ return VLC_EGENERIC;
p_sys->seq_table[j].l_timestamp = U64_AT(&mst_buf[0]);
if (i_map_size > 8) {
msg_Err(p_demux, "Unsupported SEQ bitmap size in master chunk");
- vlc_stream_Read(p_demux->s, NULL, i_map_size);
+ if(vlc_stream_Read(p_demux->s, NULL, i_map_size) != i_map_size)
+ return VLC_EGENERIC;
} else {
- vlc_stream_Read(p_demux->s, mst_buf + 8, i_map_size);
+ if(vlc_stream_Read(p_demux->s, mst_buf + 8, i_map_size) != i_map_size)
+ return VLC_EGENERIC;
memcpy(p_sys->seq_table[j].chunk_bitmask, &mst_buf[8], i_map_size);
}
}
@@ -1667,7 +1681,7 @@ static void parse_master(demux_t *p_demux)
i_pts_secs / 3600, (i_pts_secs / 60) % 60, i_pts_secs % 60 );
/* seek past this chunk */
- vlc_stream_Seek(p_demux->s, i_save_pos + CHUNK_SIZE);
+ return vlc_stream_Seek(p_demux->s, i_save_pos + CHUNK_SIZE);
}
@@ -1844,7 +1858,8 @@ static int get_chunk_header(demux_t *p_demux)
/* if we have left-over filler space from the last chunk, get that */
if (p_sys->i_stuff_cnt > 0) {
- vlc_stream_Read( p_demux->s, NULL, p_sys->i_stuff_cnt);
+ if(vlc_stream_Read(p_demux->s, NULL, p_sys->i_stuff_cnt) != p_sys->i_stuff_cnt)
+ return 0;
p_sys->i_stuff_cnt = 0;
}
@@ -1863,7 +1878,8 @@ static int get_chunk_header(demux_t *p_demux)
if( U32_AT( &p_peek[ 0 ] ) == TIVO_PES_FILEID )
{
/* parse master chunk */
- parse_master(p_demux);
+ if(parse_master(p_demux) != VLC_SUCCESS)
+ return 0;
return get_chunk_header(p_demux);
}
@@ -1893,7 +1909,8 @@ static int get_chunk_header(demux_t *p_demux)
p_sys->rec_hdrs = NULL;
/* skip past the 4 bytes we "peeked" earlier */
- vlc_stream_Read( p_demux->s, NULL, 4 );
+ if(vlc_stream_Read(p_demux->s, NULL, 4) != 4)
+ return 0;
/* read the record headers into a temp buffer */
p_hdr_buf = xmalloc(i_num_recs * 16);
More information about the vlc-commits
mailing list