Commit fbf85e3d authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

access: remove write-only info.i_pos usage

parent f3888615
...@@ -147,14 +147,6 @@ static inline int vlc_access_Seek(access_t *access, uint64_t offset) ...@@ -147,14 +147,6 @@ static inline int vlc_access_Seek(access_t *access, uint64_t offset)
return access->pf_seek(access, offset); return access->pf_seek(access, offset);
} }
/**
* Gets the read byte offset.
*/
static inline uint64_t vlc_access_Tell(const access_t *access)
{
return access->info.i_pos;
}
/** /**
* Checks if end-of-stream is reached. * Checks if end-of-stream is reached.
*/ */
......
...@@ -55,9 +55,7 @@ static ssize_t Read(access_t *p_access, uint8_t *p_data, size_t i_size) ...@@ -55,9 +55,7 @@ static ssize_t Read(access_t *p_access, uint8_t *p_data, size_t i_size)
i_read = archive_read_data(p_sys->p_archive, p_data, i_size); i_read = archive_read_data(p_sys->p_archive, p_data, i_size);
if (i_read > 0) if (i_read < 0)
p_access->info.i_pos += i_read;
else
i_read = 0; i_read = 0;
if (i_size > 0 && i_read <= 0) if (i_size > 0 && i_read <= 0)
...@@ -74,11 +72,7 @@ static int Seek(access_t *p_access, uint64_t i_pos) ...@@ -74,11 +72,7 @@ static int Seek(access_t *p_access, uint64_t i_pos)
return VLC_EGENERIC; return VLC_EGENERIC;
int64_t i_ret = archive_seek_data(p_sys->p_archive, i_pos, SEEK_SET); int64_t i_ret = archive_seek_data(p_sys->p_archive, i_pos, SEEK_SET);
if ( i_ret < ARCHIVE_OK ) return ( i_ret < ARCHIVE_OK ) ? VLC_EGENERIC : VLC_SUCCESS;
return VLC_EGENERIC;
p_access->info.i_pos = i_ret;
return VLC_SUCCESS;
} }
static int FindVolumes(access_t *p_access, struct archive *p_archive, const char *psz_uri, static int FindVolumes(access_t *p_access, struct archive *p_archive, const char *psz_uri,
......
...@@ -306,9 +306,7 @@ void OutCloseAvio(vlc_object_t *object) ...@@ -306,9 +306,7 @@ void OutCloseAvio(vlc_object_t *object)
static ssize_t Read(access_t *access, uint8_t *data, size_t size) static ssize_t Read(access_t *access, uint8_t *data, size_t size)
{ {
int r = avio_read(access->p_sys->context, data, size); int r = avio_read(access->p_sys->context, data, size);
if (r > 0) if (r <= 0) {
access->info.i_pos += r;
else {
access->info.b_eof = true; access->info.b_eof = true;
r = 0; r = 0;
} }
...@@ -375,7 +373,6 @@ static int Seek(access_t *access, uint64_t position) ...@@ -375,7 +373,6 @@ static int Seek(access_t *access, uint64_t position)
if (sys->size < 0 || position != sys->size) if (sys->size < 0 || position != sys->size)
return VLC_EGENERIC; return VLC_EGENERIC;
} }
access->info.i_pos = position;
access->info.b_eof = false; access->info.b_eof = false;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
...@@ -303,13 +303,11 @@ static block_t *Block( access_t *p_access ) ...@@ -303,13 +303,11 @@ static block_t *Block( access_t *p_access )
/* Try to skip one sector (in case of bad sectors) */ /* Try to skip one sector (in case of bad sectors) */
p_sys->i_sector++; p_sys->i_sector++;
p_access->info.i_pos += CDDA_DATA_SIZE;
return NULL; return NULL;
} }
/* Update a few values */ /* Update a few values */
p_sys->i_sector += i_blocks; p_sys->i_sector += i_blocks;
p_access->info.i_pos += p_block->i_buffer;
return p_block; return p_block;
} }
...@@ -324,7 +322,6 @@ static int Seek( access_t *p_access, uint64_t i_pos ) ...@@ -324,7 +322,6 @@ static int Seek( access_t *p_access, uint64_t i_pos )
/* Next sector to read */ /* Next sector to read */
p_sys->i_sector = p_sys->i_first_sector + i_pos / CDDA_DATA_SIZE; p_sys->i_sector = p_sys->i_first_sector + i_pos / CDDA_DATA_SIZE;
assert( p_sys->i_sector >= 0 ); assert( p_sys->i_sector >= 0 );
p_access->info.i_pos = i_pos;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
...@@ -93,10 +93,7 @@ static ssize_t Read(access_t *access, uint8_t *buf, size_t len) ...@@ -93,10 +93,7 @@ static ssize_t Read(access_t *access, uint8_t *buf, size_t len)
return 0; return 0;
} }
ssize_t ret = vlc_access_Read(a, buf, len); return vlc_access_Read(a, buf, len);
if (ret >= 0)
access->info.i_pos += ret;
return ret;
} }
static block_t *Block(access_t *access) static block_t *Block(access_t *access)
...@@ -121,10 +118,7 @@ static block_t *Block(access_t *access) ...@@ -121,10 +118,7 @@ static block_t *Block(access_t *access)
ssize_t ret = vlc_access_Read(a, block->p_buffer, block->i_buffer); ssize_t ret = vlc_access_Read(a, block->p_buffer, block->i_buffer);
if (ret >= 0) if (ret >= 0)
{
block->i_buffer = ret; block->i_buffer = ret;
access->info.i_pos += ret;
}
else else
{ {
block_Release(block); block_Release(block);
...@@ -144,9 +138,8 @@ static int Seek(access_t *access, uint64_t position) ...@@ -144,9 +138,8 @@ static int Seek(access_t *access, uint64_t position)
} }
sys->next = sys->first; sys->next = sys->first;
access->info.i_pos = 0;
for (;;) for (uint64_t offset = 0;;)
{ {
access_t *a = GetAccess(access); access_t *a = GetAccess(access);
if (a == NULL) if (a == NULL)
...@@ -161,16 +154,14 @@ static int Seek(access_t *access, uint64_t position) ...@@ -161,16 +154,14 @@ static int Seek(access_t *access, uint64_t position)
if (access_GetSize(a, &size)) if (access_GetSize(a, &size))
break; break;
if (position - access->info.i_pos < size) if (position - offset < size)
{ {
if (vlc_access_Seek(a, position - access->info.i_pos)) if (vlc_access_Seek(a, position - offset))
break; break;
access->info.i_pos = position;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
access->info.i_pos += size; offset += size;
vlc_access_Delete(a); vlc_access_Delete(a);
sys->access = NULL; sys->access = NULL;
} }
......
...@@ -791,7 +791,6 @@ static int AccessOpen( vlc_object_t *p_this ) ...@@ -791,7 +791,6 @@ static int AccessOpen( vlc_object_t *p_this )
p_access->pf_block = ReadCompressed; p_access->pf_block = ReadCompressed;
p_access->pf_control = AccessControl; p_access->pf_control = AccessControl;
p_access->pf_seek = NULL; p_access->pf_seek = NULL;
p_access->info.i_pos = 0;
p_access->info.b_eof = false; p_access->info.b_eof = false;
p_access->p_sys = p_sys; p_access->p_sys = p_sys;
......
...@@ -495,7 +495,6 @@ static bool get_path( access_t *p_access ) ...@@ -495,7 +495,6 @@ static bool get_path( access_t *p_access )
static int Seek( access_t *p_access, uint64_t i_pos ) static int Seek( access_t *p_access, uint64_t i_pos )
{ {
access_sys_t *p_sys = p_access->p_sys; access_sys_t *p_sys = p_access->p_sys;
int64_t i_ret;
if( i_pos >= INT64_MAX ) if( i_pos >= INT64_MAX )
return VLC_EGENERIC; return VLC_EGENERIC;
...@@ -503,10 +502,9 @@ static int Seek( access_t *p_access, uint64_t i_pos ) ...@@ -503,10 +502,9 @@ static int Seek( access_t *p_access, uint64_t i_pos )
msg_Dbg( p_access, "seeking to %"PRId64, i_pos ); msg_Dbg( p_access, "seeking to %"PRId64, i_pos );
/* seek cannot fail in bdsm, but the subsequent read can */ /* seek cannot fail in bdsm, but the subsequent read can */
i_ret = smb_fseek(p_sys->p_session, p_sys->i_fd, i_pos, SMB_SEEK_SET); smb_fseek(p_sys->p_session, p_sys->i_fd, i_pos, SMB_SEEK_SET);
p_access->info.b_eof = false; p_access->info.b_eof = false;
p_access->info.i_pos = i_ret;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -529,7 +527,6 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len ) ...@@ -529,7 +527,6 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
} }
if( i_read == 0 ) p_access->info.b_eof = true; if( i_read == 0 ) p_access->info.b_eof = true;
else if( i_read > 0 ) p_access->info.i_pos += i_read;
return i_read; return i_read;
} }
......
...@@ -294,7 +294,6 @@ static ssize_t Read (access_t *p_access, uint8_t *p_buffer, size_t i_len) ...@@ -294,7 +294,6 @@ static ssize_t Read (access_t *p_access, uint8_t *p_buffer, size_t i_len)
val = 0; val = 0;
} }
p_access->info.i_pos += val;
p_access->info.b_eof = !val; p_access->info.b_eof = !val;
return val; return val;
} }
...@@ -304,7 +303,6 @@ static ssize_t Read (access_t *p_access, uint8_t *p_buffer, size_t i_len) ...@@ -304,7 +303,6 @@ static ssize_t Read (access_t *p_access, uint8_t *p_buffer, size_t i_len)
*****************************************************************************/ *****************************************************************************/
static int FileSeek (access_t *p_access, uint64_t i_pos) static int FileSeek (access_t *p_access, uint64_t i_pos)
{ {
p_access->info.i_pos = i_pos;
p_access->info.b_eof = false; p_access->info.b_eof = false;
if (lseek (p_access->p_sys->fd, i_pos, SEEK_SET) == (off_t)-1) if (lseek (p_access->p_sys->fd, i_pos, SEEK_SET) == (off_t)-1)
......
...@@ -48,10 +48,7 @@ static ssize_t Read(access_t *access, uint8_t *buf, size_t len) ...@@ -48,10 +48,7 @@ static ssize_t Read(access_t *access, uint8_t *buf, size_t len)
val = 0; val = 0;
} }
if (val > 0) { if (val <= 0)
assert((size_t)val <= len);
access->info.i_pos += val;
} else
access->info.b_eof = true; access->info.b_eof = true;
return val; return val;
......
...@@ -199,9 +199,7 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len ) ...@@ -199,9 +199,7 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
return 0; return 0;
} }
} }
else if( i_ret > 0 ) else if( i_ret == 0 )
p_access->info.i_pos += i_ret;
else
p_access->info.b_eof = true; p_access->info.b_eof = true;
return i_ret; return i_ret;
...@@ -213,7 +211,6 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len ) ...@@ -213,7 +211,6 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
*****************************************************************************/ *****************************************************************************/
static int Seek( access_t *p_access, uint64_t i_pos ) static int Seek( access_t *p_access, uint64_t i_pos )
{ {
p_access->info.i_pos = i_pos;
p_access->info.b_eof = false; p_access->info.b_eof = false;
if (lseek( p_access->p_sys->fd, i_pos, SEEK_SET ) == (off_t)-1) if (lseek( p_access->p_sys->fd, i_pos, SEEK_SET ) == (off_t)-1)
......
...@@ -167,7 +167,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -167,7 +167,6 @@ static int Open( vlc_object_t *p_this )
p_access->pf_block = BlockRead; p_access->pf_block = BlockRead;
p_access->pf_seek = Seek; p_access->pf_seek = Seek;
p_access->pf_control = Control; p_access->pf_control = Control;
p_access->info.i_pos = 0;
p_access->info.b_eof = false; p_access->info.b_eof = false;
p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) ); p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
if( !p_sys ) if( !p_sys )
......
...@@ -374,14 +374,12 @@ static ssize_t Read( access_t *p_access, void *buf, size_t len ) ...@@ -374,14 +374,12 @@ static ssize_t Read( access_t *p_access, void *buf, size_t len )
else if( val == 0 ) else if( val == 0 )
p_access->info.b_eof = true; p_access->info.b_eof = true;
p_access->info.i_pos += val;
return val; return val;
} }
static int Seek( access_t* p_access, uint64_t i_pos ) static int Seek( access_t* p_access, uint64_t i_pos )
{ {
p_access->info.i_pos = i_pos;
p_access->info.b_eof = false; p_access->info.b_eof = false;
libssh2_sftp_seek( p_access->p_sys->file, i_pos ); libssh2_sftp_seek( p_access->p_sys->file, i_pos );
......
...@@ -318,7 +318,6 @@ static int Seek( access_t *p_access, uint64_t i_pos ) ...@@ -318,7 +318,6 @@ static int Seek( access_t *p_access, uint64_t i_pos )
} }
p_access->info.b_eof = false; p_access->info.b_eof = false;
p_access->info.i_pos = i_ret;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -342,7 +341,6 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len ) ...@@ -342,7 +341,6 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
} }
if( i_read == 0 ) p_access->info.b_eof = true; if( i_read == 0 ) p_access->info.b_eof = true;
else if( i_read > 0 ) p_access->info.i_pos += i_read;
return i_read; return i_read;
} }
......
...@@ -141,10 +141,10 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len ) ...@@ -141,10 +141,10 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
return 0; return 0;
i_read = vlc_recv_i11e( p_sys->fd, p_buffer, i_len, 0 ); i_read = vlc_recv_i11e( p_sys->fd, p_buffer, i_len, 0 );
if( i_read == 0 ) if( i_read > 0 )
;
else if( i_read == 0 )
p_access->info.b_eof = true; p_access->info.b_eof = true;
else if( i_read > 0 )
p_access->info.i_pos += i_read;
else if( errno != EINTR && errno != EAGAIN ) else if( errno != EINTR && errno != EAGAIN )
{ {
msg_Err( p_access, "receive error: %s", vlc_strerror_c(errno) ); msg_Err( p_access, "receive error: %s", vlc_strerror_c(errno) );
......
...@@ -246,7 +246,6 @@ static block_t *ReadBlock (access_t *access) ...@@ -246,7 +246,6 @@ static block_t *ReadBlock (access_t *access)
} }
block->i_buffer = val; block->i_buffer = val;
access->info.i_pos += val;
return block; return block;
} }
......
...@@ -163,8 +163,6 @@ VCDReadBlock( access_t * p_access ) ...@@ -163,8 +163,6 @@ VCDReadBlock( access_t * p_access )
{ {
vcdplayer_read_status_t read_status = vcdplayer_read(p_access, p_buf); vcdplayer_read_status_t read_status = vcdplayer_read(p_access, p_buf);
p_access->info.i_pos += M2F2_SECTOR_SIZE;
switch ( read_status ) { switch ( read_status ) {
case READ_END: case READ_END:
/* End reached. Return NULL to indicated this. */ /* End reached. Return NULL to indicated this. */
...@@ -172,15 +170,6 @@ VCDReadBlock( access_t * p_access ) ...@@ -172,15 +170,6 @@ VCDReadBlock( access_t * p_access )
(demux?) doesn't try to keep reading. If everything works out (demux?) doesn't try to keep reading. If everything works out
right this shouldn't have to happen. right this shouldn't have to happen.
*/ */
#if 0
if( p_access->info.i_pos != p_access->info.i_size ) {
msg_Warn( p_access,
"At end but pos (%llu) is not size (%llu). Adjusting.",
p_access->info.i_pos, p_access->info.i_size );
p_access->info.i_pos = p_access->info.i_size;
}
#endif
block_Release( p_block ); block_Release( p_block );
return NULL; return NULL;
...@@ -247,7 +236,6 @@ VCDSeek( access_t * p_access, uint64_t i_pos ) ...@@ -247,7 +236,6 @@ VCDSeek( access_t * p_access, uint64_t i_pos )
int i_seekpoint; int i_seekpoint;
/* Next sector to read */ /* Next sector to read */
p_access->info.i_pos = i_pos;
p_vcdplayer->i_lsn = (i_pos / (uint64_t) M2F2_SECTOR_SIZE) + p_vcdplayer->i_lsn = (i_pos / (uint64_t) M2F2_SECTOR_SIZE) +
p_vcdplayer->origin_lsn; p_vcdplayer->origin_lsn;
...@@ -671,17 +659,12 @@ VCDSetOrigin( access_t *p_access, lsn_t i_lsn, track_t i_track, ...@@ -671,17 +659,12 @@ VCDSetOrigin( access_t *p_access, lsn_t i_lsn, track_t i_track,
"chapter", _("Entry"), "Setting entry/segment"); "chapter", _("Entry"), "Setting entry/segment");
p_vcdplayer->i_cur_title = i_track - 1; p_vcdplayer->i_cur_title = i_track - 1;
if (p_vcdplayer->b_track_length) if (p_vcdplayer->b_track_length)
{
p_vcdplayer->size = p_vcdplayer->p_title[i_track-1]->i_size; p_vcdplayer->size = p_vcdplayer->p_title[i_track-1]->i_size;
p_access->info.i_pos = (uint64_t) M2F2_SECTOR_SIZE * else
(vcdinfo_get_track_lsn(p_vcdplayer->vcd, i_track)-i_lsn);
} else {
p_vcdplayer->size = M2F2_SECTOR_SIZE * (int64_t) p_vcdplayer->size = M2F2_SECTOR_SIZE * (int64_t)
vcdinfo_get_entry_sect_count(p_vcdplayer->vcd,p_itemid->num); vcdinfo_get_entry_sect_count(p_vcdplayer->vcd,p_itemid->num);
p_access->info.i_pos = 0; dbg_print( (INPUT_DBG_LSN|INPUT_DBG_PBC), "size: %"PRIu64,
} p_vcdplayer->size );
dbg_print( (INPUT_DBG_LSN|INPUT_DBG_PBC), "size: %"PRIu64", pos: %"PRIu64,
p_vcdplayer->size, p_access->info.i_pos );
p_vcdplayer->i_cur_chapter = p_itemid->num; p_vcdplayer->i_cur_chapter = p_itemid->num;
break; break;
...@@ -694,7 +677,6 @@ VCDSetOrigin( access_t *p_access, lsn_t i_lsn, track_t i_track, ...@@ -694,7 +677,6 @@ VCDSetOrigin( access_t *p_access, lsn_t i_lsn, track_t i_track,
*/ */
p_vcdplayer->i_cur_title = p_vcdplayer->i_titles - 1; p_vcdplayer->i_cur_title = p_vcdplayer->i_titles - 1;
p_vcdplayer->size = 0; /* No seeking on stills, please. */ p_vcdplayer->size = 0; /* No seeking on stills, please. */
p_access->info.i_pos = 0;
p_vcdplayer->i_cur_chapter = p_vcdplayer->i_entries p_vcdplayer->i_cur_chapter = p_vcdplayer->i_entries
+ p_vcdplayer->i_lids + p_itemid->num; + p_vcdplayer->i_lids + p_itemid->num;
break; break;
...@@ -702,7 +684,6 @@ VCDSetOrigin( access_t *p_access, lsn_t i_lsn, track_t i_track, ...@@ -702,7 +684,6 @@ VCDSetOrigin( access_t *p_access, lsn_t i_lsn, track_t i_track,
case VCDINFO_ITEM_TYPE_TRACK: case VCDINFO_ITEM_TYPE_TRACK:
p_vcdplayer->i_cur_title = i_track - 1; p_vcdplayer->i_cur_title = i_track - 1;
p_vcdplayer->size = p_vcdplayer->p_title[i_track - 1]->i_size; p_vcdplayer->size = p_vcdplayer->p_title[i_track - 1]->i_size;
p_access->info.i_pos = 0;
p_vcdplayer->i_cur_chapter = vcdinfo_track_get_entry(p_vcdplayer->vcd, p_vcdplayer->i_cur_chapter = vcdinfo_track_get_entry(p_vcdplayer->vcd,
i_track); i_track);
break; break;
...@@ -847,7 +828,6 @@ VCDOpen ( vlc_object_t *p_this ) ...@@ -847,7 +828,6 @@ VCDOpen ( vlc_object_t *p_this )
p_access->pf_control = VCDControl; p_access->pf_control = VCDControl;
p_access->pf_seek = VCDSeek; p_access->pf_seek = VCDSeek;
p_access->info.i_pos = 0;
p_access->info.b_eof = false; p_access->info.b_eof = false;
p_vcdplayer = malloc( sizeof(vcdplayer_t) ); p_vcdplayer = malloc( sizeof(vcdplayer_t) );
......
...@@ -179,7 +179,6 @@ int AccessOpen( vlc_object_t *p_this ) ...@@ -179,7 +179,6 @@ int AccessOpen( vlc_object_t *p_this )
/* Set callback */ /* Set callback */
ACCESS_SET_CALLBACKS( AccessRead, NULL, AccessControl, AccessSeek ); ACCESS_SET_CALLBACKS( AccessRead, NULL, AccessControl, AccessSeek );
p_access->info.i_pos = 0;
p_access->info.b_eof = false; p_access->info.b_eof = false;
i_ret = VLC_SUCCESS; i_ret = VLC_SUCCESS;
...@@ -274,7 +273,6 @@ static ssize_t AccessRead( access_t *p_access, uint8_t *p_buffer, size_t sz ) ...@@ -274,7 +273,6 @@ static ssize_t AccessRead( access_t *p_access, uint8_t *p_buffer, size_t sz )
int i_read = unzReadCurrentFile( file, p_buffer, sz ); int i_read = unzReadCurrentFile( file, p_buffer, sz );
p_access->info.i_pos = unztell( file );
return ( i_read >= 0 ? i_read : VLC_EGENERIC ); return ( i_read >= 0 ? i_read : VLC_EGENERIC );
} }
...@@ -292,7 +290,6 @@ static int AccessSeek( access_t *p_access, uint64_t seek_len ) ...@@ -292,7 +290,6 @@ static int AccessSeek( access_t *p_access, uint64_t seek_len )
if( unzSetOffset( file, seek_len ) < 0 ) if( unzSetOffset( file, seek_len ) < 0 )
return VLC_EGENERIC; return VLC_EGENERIC;
p_access->info.i_pos = unztell( file );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment