access: remove write-only info.i_pos usage

This commit is contained in:
Rémi Denis-Courmont 2015-09-01 21:36:28 +03:00
parent f3888615a1
commit fbf85e3da7
17 changed files with 17 additions and 87 deletions

View File

@ -147,14 +147,6 @@ static inline int vlc_access_Seek(access_t *access, uint64_t 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.
*/

View File

@ -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);
if (i_read > 0)
p_access->info.i_pos += i_read;
else
if (i_read < 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)
return VLC_EGENERIC;
int64_t i_ret = archive_seek_data(p_sys->p_archive, i_pos, SEEK_SET);
if ( i_ret < ARCHIVE_OK )
return VLC_EGENERIC;
p_access->info.i_pos = i_ret;
return VLC_SUCCESS;
return ( i_ret < ARCHIVE_OK ) ? VLC_EGENERIC : VLC_SUCCESS;
}
static int FindVolumes(access_t *p_access, struct archive *p_archive, const char *psz_uri,

View File

@ -306,9 +306,7 @@ void OutCloseAvio(vlc_object_t *object)
static ssize_t Read(access_t *access, uint8_t *data, size_t size)
{
int r = avio_read(access->p_sys->context, data, size);
if (r > 0)
access->info.i_pos += r;
else {
if (r <= 0) {
access->info.b_eof = true;
r = 0;
}
@ -375,7 +373,6 @@ static int Seek(access_t *access, uint64_t position)
if (sys->size < 0 || position != sys->size)
return VLC_EGENERIC;
}
access->info.i_pos = position;
access->info.b_eof = false;
return VLC_SUCCESS;
}

View File

@ -303,13 +303,11 @@ static block_t *Block( access_t *p_access )
/* Try to skip one sector (in case of bad sectors) */
p_sys->i_sector++;
p_access->info.i_pos += CDDA_DATA_SIZE;
return NULL;
}
/* Update a few values */
p_sys->i_sector += i_blocks;
p_access->info.i_pos += p_block->i_buffer;
return p_block;
}
@ -324,7 +322,6 @@ static int Seek( access_t *p_access, uint64_t i_pos )
/* Next sector to read */
p_sys->i_sector = p_sys->i_first_sector + i_pos / CDDA_DATA_SIZE;
assert( p_sys->i_sector >= 0 );
p_access->info.i_pos = i_pos;
return VLC_SUCCESS;
}

View File

@ -93,10 +93,7 @@ static ssize_t Read(access_t *access, uint8_t *buf, size_t len)
return 0;
}
ssize_t ret = vlc_access_Read(a, buf, len);
if (ret >= 0)
access->info.i_pos += ret;
return ret;
return vlc_access_Read(a, buf, len);
}
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);
if (ret >= 0)
{
block->i_buffer = ret;
access->info.i_pos += ret;
}
else
{
block_Release(block);
@ -144,9 +138,8 @@ static int Seek(access_t *access, uint64_t position)
}
sys->next = sys->first;
access->info.i_pos = 0;
for (;;)
for (uint64_t offset = 0;;)
{
access_t *a = GetAccess(access);
if (a == NULL)
@ -161,16 +154,14 @@ static int Seek(access_t *access, uint64_t position)
if (access_GetSize(a, &size))
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;
access->info.i_pos = position;
return VLC_SUCCESS;
}
access->info.i_pos += size;
offset += size;
vlc_access_Delete(a);
sys->access = NULL;
}

View File

@ -791,7 +791,6 @@ static int AccessOpen( vlc_object_t *p_this )
p_access->pf_block = ReadCompressed;
p_access->pf_control = AccessControl;
p_access->pf_seek = NULL;
p_access->info.i_pos = 0;
p_access->info.b_eof = false;
p_access->p_sys = p_sys;

View File

@ -495,7 +495,6 @@ static bool get_path( access_t *p_access )
static int Seek( access_t *p_access, uint64_t i_pos )
{
access_sys_t *p_sys = p_access->p_sys;
int64_t i_ret;
if( i_pos >= INT64_MAX )
return VLC_EGENERIC;
@ -503,10 +502,9 @@ static int Seek( access_t *p_access, uint64_t i_pos )
msg_Dbg( p_access, "seeking to %"PRId64, i_pos );
/* 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.i_pos = i_ret;
return VLC_SUCCESS;
}
@ -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;
else if( i_read > 0 ) p_access->info.i_pos += i_read;
return i_read;
}

View File

@ -294,7 +294,6 @@ static ssize_t Read (access_t *p_access, uint8_t *p_buffer, size_t i_len)
val = 0;
}
p_access->info.i_pos += val;
p_access->info.b_eof = !val;
return val;
}
@ -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)
{
p_access->info.i_pos = i_pos;
p_access->info.b_eof = false;
if (lseek (p_access->p_sys->fd, i_pos, SEEK_SET) == (off_t)-1)

View File

@ -48,10 +48,7 @@ static ssize_t Read(access_t *access, uint8_t *buf, size_t len)
val = 0;
}
if (val > 0) {
assert((size_t)val <= len);
access->info.i_pos += val;
} else
if (val <= 0)
access->info.b_eof = true;
return val;

View File

@ -199,9 +199,7 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
return 0;
}
}
else if( i_ret > 0 )
p_access->info.i_pos += i_ret;
else
else if( i_ret == 0 )
p_access->info.b_eof = true;
return i_ret;
@ -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 )
{
p_access->info.i_pos = i_pos;
p_access->info.b_eof = false;
if (lseek( p_access->p_sys->fd, i_pos, SEEK_SET ) == (off_t)-1)

View File

@ -167,7 +167,6 @@ static int Open( vlc_object_t *p_this )
p_access->pf_block = BlockRead;
p_access->pf_seek = Seek;
p_access->pf_control = Control;
p_access->info.i_pos = 0;
p_access->info.b_eof = false;
p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
if( !p_sys )

View File

@ -374,14 +374,12 @@ static ssize_t Read( access_t *p_access, void *buf, size_t len )
else if( val == 0 )
p_access->info.b_eof = true;
p_access->info.i_pos += val;
return val;
}
static int Seek( access_t* p_access, uint64_t i_pos )
{
p_access->info.i_pos = i_pos;
p_access->info.b_eof = false;
libssh2_sftp_seek( p_access->p_sys->file, i_pos );

View File

@ -318,7 +318,6 @@ static int Seek( access_t *p_access, uint64_t i_pos )
}
p_access->info.b_eof = false;
p_access->info.i_pos = i_ret;
return VLC_SUCCESS;
}
@ -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;
else if( i_read > 0 ) p_access->info.i_pos += i_read;
return i_read;
}

View File

@ -141,10 +141,10 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
return 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;
else if( i_read > 0 )
p_access->info.i_pos += i_read;
else if( errno != EINTR && errno != EAGAIN )
{
msg_Err( p_access, "receive error: %s", vlc_strerror_c(errno) );

View File

@ -246,7 +246,6 @@ static block_t *ReadBlock (access_t *access)
}
block->i_buffer = val;
access->info.i_pos += val;
return block;
}

View File

@ -163,8 +163,6 @@ VCDReadBlock( access_t * p_access )
{
vcdplayer_read_status_t read_status = vcdplayer_read(p_access, p_buf);
p_access->info.i_pos += M2F2_SECTOR_SIZE;
switch ( read_status ) {
case READ_END:
/* End reached. Return NULL to indicated this. */
@ -172,15 +170,6 @@ VCDReadBlock( access_t * p_access )
(demux?) doesn't try to keep reading. If everything works out
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 );
return NULL;
@ -247,7 +236,6 @@ VCDSeek( access_t * p_access, uint64_t i_pos )
int i_seekpoint;
/* Next sector to read */
p_access->info.i_pos = i_pos;
p_vcdplayer->i_lsn = (i_pos / (uint64_t) M2F2_SECTOR_SIZE) +
p_vcdplayer->origin_lsn;
@ -671,17 +659,12 @@ VCDSetOrigin( access_t *p_access, lsn_t i_lsn, track_t i_track,
"chapter", _("Entry"), "Setting entry/segment");
p_vcdplayer->i_cur_title = i_track - 1;
if (p_vcdplayer->b_track_length)
{
p_vcdplayer->size = p_vcdplayer->p_title[i_track-1]->i_size;
p_access->info.i_pos = (uint64_t) M2F2_SECTOR_SIZE *
(vcdinfo_get_track_lsn(p_vcdplayer->vcd, i_track)-i_lsn);
} else {
else
p_vcdplayer->size = M2F2_SECTOR_SIZE * (int64_t)
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", pos: %"PRIu64,
p_vcdplayer->size, p_access->info.i_pos );
dbg_print( (INPUT_DBG_LSN|INPUT_DBG_PBC), "size: %"PRIu64,
p_vcdplayer->size );
p_vcdplayer->i_cur_chapter = p_itemid->num;
break;
@ -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->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_lids + p_itemid->num;
break;
@ -702,7 +684,6 @@ VCDSetOrigin( access_t *p_access, lsn_t i_lsn, track_t i_track,
case VCDINFO_ITEM_TYPE_TRACK:
p_vcdplayer->i_cur_title = i_track - 1;
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,
i_track);
break;
@ -847,7 +828,6 @@ VCDOpen ( vlc_object_t *p_this )
p_access->pf_control = VCDControl;
p_access->pf_seek = VCDSeek;
p_access->info.i_pos = 0;
p_access->info.b_eof = false;
p_vcdplayer = malloc( sizeof(vcdplayer_t) );

View File

@ -179,7 +179,6 @@ int AccessOpen( vlc_object_t *p_this )
/* Set callback */
ACCESS_SET_CALLBACKS( AccessRead, NULL, AccessControl, AccessSeek );
p_access->info.i_pos = 0;
p_access->info.b_eof = false;
i_ret = VLC_SUCCESS;
@ -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 );
p_access->info.i_pos = unztell( file );
return ( i_read >= 0 ? i_read : VLC_EGENERIC );
}
@ -292,7 +290,6 @@ static int AccessSeek( access_t *p_access, uint64_t seek_len )
if( unzSetOffset( file, seek_len ) < 0 )
return VLC_EGENERIC;
p_access->info.i_pos = unztell( file );
return VLC_SUCCESS;
}