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

access: info.i_size -> control(ACCESS_GET_SIZE)

parent f9053346
......@@ -43,6 +43,7 @@ enum access_query_e
ACCESS_CAN_FASTSEEK, /* arg1= bool* cannot fail */
ACCESS_CAN_PAUSE, /* arg1= bool* cannot fail */
ACCESS_CAN_CONTROL_PACE,/* arg1= bool* cannot fail */
ACCESS_GET_SIZE=6, /* arg1= uin64_t* */
/* */
ACCESS_GET_PTS_DELAY = 0x101,/* arg1= int64_t* cannot fail */
......@@ -107,7 +108,6 @@ struct access_t
unsigned int i_update; /* Access sets them on change,
Input removes them once take into account*/
uint64_t i_size; /* Write only for access, read only for input */
uint64_t i_pos; /* idem */
bool b_eof; /* idem */
......@@ -137,10 +137,17 @@ static inline int access_Control( access_t *p_access, int i_query, ... )
return i_result;
}
static inline uint64_t access_GetSize( access_t *p_access )
{
uint64_t val;
if( access_Control( p_access, ACCESS_GET_SIZE, &val ) )
val = 0;
return val;
}
static inline void access_InitFields( access_t *p_a )
{
p_a->info.i_update = 0;
p_a->info.i_size = 0;
p_a->info.i_pos = 0;
p_a->info.b_eof = false;
p_a->info.i_title = 0;
......
......@@ -73,8 +73,10 @@ static int UrlInterruptCallback(void *access)
return !vlc_object_alive((vlc_object_t*)access);
}
struct access_sys_t {
struct access_sys_t
{
AVIOContext *context;
uint64_t size;
};
struct sout_access_out_sys_t {
......@@ -185,10 +187,10 @@ int OpenAvio(vlc_object_t *object)
seekable = sys->context->seekable;
#endif
msg_Dbg(access, "%sseekable, size=%"PRIi64, seekable ? "" : "not ", size);
sys->size = size > 0 ? size : 0;
/* */
access_InitFields(access);
access->info.i_size = size > 0 ? size : 0;
access->pf_read = Read;
access->pf_block = NULL;
......@@ -368,7 +370,7 @@ static int Seek(access_t *access, uint64_t position)
if (ret < 0) {
errno = AVUNERROR(ret);
msg_Err(access, "Seek to %"PRIu64" failed: %m", position);
if (access->info.i_size <= 0 || position != access->info.i_size)
if (sys->size == 0 || position != sys->size)
return VLC_EGENERIC;
}
access->info.i_pos = position;
......@@ -431,6 +433,9 @@ static int Control(access_t *access, int query, va_list args)
b = va_arg(args, bool *);
*b = true; /* FIXME */
return VLC_SUCCESS;
case ACCESS_GET_SIZE:
*va_arg(args, uint64_t *) = sys->size;
return VLC_SUCCESS;
case ACCESS_GET_PTS_DELAY: {
int64_t *delay = va_arg(args, int64_t *);
*delay = DEFAULT_PTS_DELAY; /* FIXME */
......
......@@ -96,6 +96,7 @@ vlc_module_end ()
struct access_sys_t
{
vcddev_t *vcddev; /* vcd device descriptor */
uint64_t size;
/* Current position */
int i_sector; /* Current Sector */
......@@ -219,7 +220,7 @@ static int Open( vlc_object_t *p_this )
}
p_sys->i_sector = p_sys->i_first_sector;
p_access->info.i_size = (p_sys->i_last_sector - p_sys->i_first_sector)
p_sys->size = (p_sys->i_last_sector - p_sys->i_first_sector)
* (int64_t)CDDA_DATA_SIZE;
}
......@@ -333,7 +334,9 @@ static int Control( access_t *p_access, int i_query, va_list args )
case ACCESS_CAN_CONTROL_PACE:
*va_arg( args, bool* ) = true;
break;
case ACCESS_GET_SIZE:
*va_arg( args, uint64_t * ) = p_access->p_sys->size;
break;
case ACCESS_GET_PTS_DELAY:
*va_arg( args, int64_t * ) =
INT64_C(1000) * var_InheritInteger( p_access, "disc-caching" );
......
......@@ -814,7 +814,6 @@ static int AccessOpen( vlc_object_t *p_this )
p_access->pf_control = AccessControl;
p_access->pf_seek = NULL;
p_access->info.i_update = 0;
p_access->info.i_size = 0;
p_access->info.i_pos = 0;
p_access->info.b_eof = false;
p_access->info.i_title = 0;
......
......@@ -68,8 +68,8 @@ struct access_sys_t
{
int fd;
/* */
bool b_pace_control;
uint64_t size;
};
#if !defined (_WIN32) && !defined (__OS2__)
......@@ -226,8 +226,8 @@ int FileOpen( vlc_object_t *p_this )
{
p_access->pf_read = FileRead;
p_access->pf_seek = FileSeek;
p_access->info.i_size = st.st_size;
p_sys->b_pace_control = true;
p_sys->size = st.st_size;
/* Demuxers will need the beginning of the file for probing. */
posix_fadvise (fd, 0, 4096, POSIX_FADV_WILLNEED);
......@@ -245,6 +245,7 @@ int FileOpen( vlc_object_t *p_this )
p_access->pf_read = StreamRead;
p_access->pf_seek = NoSeek;
p_sys->b_pace_control = strcasecmp (p_access->psz_access, "stream");
p_sys->size = 0;
}
return VLC_SUCCESS;
......@@ -302,12 +303,12 @@ static ssize_t FileRead (access_t *p_access, uint8_t *p_buffer, size_t i_len)
p_access->info.i_pos += val;
p_access->info.b_eof = !val;
if (p_access->info.i_pos >= p_access->info.i_size)
if (p_access->info.i_pos >= p_sys->size)
{
struct stat st;
if (fstat (fd, &st) == 0)
p_access->info.i_size = st.st_size;
p_sys->size = st.st_size;
}
return val;
}
......@@ -387,6 +388,10 @@ static int FileControl( access_t *p_access, int i_query, va_list args )
*pb_bool = p_sys->b_pace_control;
break;
case ACCESS_GET_SIZE:
*va_arg( args, uint64_t * ) = p_sys->size;
break;
/* */
case ACCESS_GET_PTS_DELAY:
pi_64 = (int64_t*)va_arg( args, int64_t * );
......
......@@ -109,6 +109,7 @@ struct access_sys_t
char sz_epsv_ip[NI_MAXNUMERICHOST];
bool out;
bool directory;
uint64_t size;
};
#define GET_OUT_SYS( p_this ) \
((access_sys_t *)(((sout_access_out_t *)(p_this))->p_sys))
......@@ -475,6 +476,7 @@ static int InOpen( vlc_object_t *p_this )
p_sys->fd_data = -1;
p_sys->out = false;
p_sys->directory = false;
p_sys->size = 0;
if( parseURL( &p_sys->url, p_access->psz_location ) )
goto exit_error;
......@@ -491,9 +493,9 @@ static int InOpen( vlc_object_t *p_this )
else
if ( ftp_RecvCommand( p_this, p_sys, NULL, &psz_arg ) == 2 )
{
p_access->info.i_size = atoll( &psz_arg[4] );
p_sys->size = atoll( &psz_arg[4] );
free( psz_arg );
msg_Dbg( p_access, "file size: %"PRIu64, p_access->info.i_size );
msg_Dbg( p_access, "file size: %"PRIu64, p_sys->size );
}
else
if( ftp_SendCommand( p_this, p_sys, "CWD %s", p_sys->url.psz_path ) < 0 )
......@@ -728,6 +730,9 @@ static int Control( access_t *p_access, int i_query, va_list args )
pb_bool = (bool*)va_arg( args, bool* );
*pb_bool = true; /* FIXME */
break;
case ACCESS_GET_SIZE:
*va_arg( args, uint64_t * ) = p_access->p_sys->size;
break;
/* */
case ACCESS_GET_PTS_DELAY:
......
......@@ -213,7 +213,6 @@ static int Open( vlc_object_t *p_this )
p_sys->p_file_info->type == GNOME_VFS_FILE_TYPE_BLOCK_DEVICE )
{
p_sys->b_seekable = true;
p_access->info.i_size = (int64_t)(p_sys->p_file_info->size);
}
else if( p_sys->p_file_info->type == GNOME_VFS_FILE_TYPE_FIFO
|| p_sys->p_file_info->type == GNOME_VFS_FILE_TYPE_SOCKET )
......@@ -226,7 +225,7 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC;
}
if( p_sys->b_seekable && !p_access->info.i_size )
if( p_sys->b_seekable && !p_sys->p_file_info->size )
{
/* FIXME that's bad because all others access will be probed */
msg_Warn( p_access, "file %s is empty, aborting", psz_name );
......@@ -288,8 +287,8 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
}
p_access->info.i_pos += (int64_t)i_read_len;
if( p_access->info.i_pos >= p_access->info.i_size
&& p_access->info.i_size != 0 && p_sys->b_local )
if( p_access->info.i_pos >= p_sys->p_file_info->size
&& p_sys->p_file_info->size != 0 && p_sys->b_local )
{
gnome_vfs_file_info_clear( p_sys->p_file_info );
i_ret = gnome_vfs_get_file_info_from_handle( p_sys->p_handle,
......@@ -297,8 +296,6 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
if( i_ret )
msg_Warn( p_access, "couldn't get file properties again (%s)",
gnome_vfs_result_to_string( i_ret ) );
else
p_access->info.i_size = (int64_t)(p_sys->p_file_info->size);
}
return (int)i_read_len;
}
......@@ -361,6 +358,10 @@ static int Control( access_t *p_access, int i_query, va_list args )
*pb_bool = p_sys->b_pace_control;
break;
case ACCESS_GET_SIZE:
*va_arg( args, uint64_t * ) = p_sys->p_file_info->size;
break;
case ACCESS_GET_PTS_DELAY:
pi_64 = (int64_t*)va_arg( args, int64_t * );
*pi_64 = DEFAULT_PTS_DELAY; /* FIXME */
......
......@@ -176,6 +176,7 @@ struct access_sys_t
char *psz_icy_title;
uint64_t i_remaining;
uint64_t size;
bool b_seekable;
bool b_reconnect;
......@@ -281,7 +282,7 @@ static int OpenWithCookies( vlc_object_t *p_this, const char *psz_access,
p_sys->i_remaining = 0;
p_sys->b_persist = false;
p_sys->b_has_size = false;
p_access->info.i_size = 0;
p_sys->size = 0;
p_access->info.i_pos = 0;
p_access->info.b_eof = false;
......@@ -732,7 +733,7 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
if( p_sys->b_has_size )
{
/* Remaining bytes in the file */
uint64_t remainder = p_access->info.i_size - p_access->info.i_pos;
uint64_t remainder = p_sys->size - p_access->info.i_pos;
if( remainder < i_len )
i_len = remainder;
......@@ -805,7 +806,7 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
p_access->info.i_pos += i_read;
if( p_sys->b_has_size )
{
assert( p_access->info.i_pos <= p_access->info.i_size );
assert( p_access->info.i_pos <= p_sys->size );
assert( (unsigned)i_read <= p_sys->i_remaining );
p_sys->i_remaining -= i_read;
}
......@@ -929,14 +930,15 @@ static ssize_t ReadCompressed( access_t *p_access, uint8_t *p_buffer,
*****************************************************************************/
static int Seek( access_t *p_access, uint64_t i_pos )
{
msg_Dbg( p_access, "trying to seek to %"PRId64, i_pos );
access_sys_t *p_sys = p_access->p_sys;
msg_Dbg( p_access, "trying to seek to %"PRId64, i_pos );
Disconnect( p_access );
if( p_access->info.i_size
&& i_pos >= p_access->info.i_size ) {
if( p_sys->size && i_pos >= p_sys->size )
{
msg_Err( p_access, "seek too far" );
int retval = Seek( p_access, p_access->info.i_size - 1 );
int retval = Seek( p_access, p_sys->size - 1 );
if( retval == VLC_SUCCESS ) {
uint8_t p_buffer[2];
Read( p_access, p_buffer, 1);
......@@ -1058,7 +1060,7 @@ static int Connect( access_t *p_access, uint64_t i_tell )
p_sys->i_remaining = 0;
p_sys->b_persist = false;
p_sys->b_has_size = false;
p_access->info.i_size = 0;
p_sys->size = 0;
p_access->info.i_pos = i_tell;
p_access->info.b_eof = false;
......@@ -1337,25 +1339,25 @@ static int Request( access_t *p_access, uint64_t i_tell )
if( !strcasecmp( psz, "Content-Length" ) )
{
uint64_t i_size = i_tell + (p_sys->i_remaining = (uint64_t)atoll( p ));
if(i_size > p_access->info.i_size) {
if(i_size > p_sys->size) {
p_sys->b_has_size = true;
p_access->info.i_size = i_size;
p_sys->size = i_size;
}
msg_Dbg( p_access, "this frame size=%"PRIu64, p_sys->i_remaining );
}
else if( !strcasecmp( psz, "Content-Range" ) ) {
uint64_t i_ntell = i_tell;
uint64_t i_nend = (p_access->info.i_size > 0)?(p_access->info.i_size - 1):i_tell;
uint64_t i_nsize = p_access->info.i_size;
uint64_t i_nend = (p_sys->size > 0) ? (p_sys->size - 1) : i_tell;
uint64_t i_nsize = p_sys->size;
sscanf(p,"bytes %"SCNu64"-%"SCNu64"/%"SCNu64,&i_ntell,&i_nend,&i_nsize);
if(i_nend > i_ntell ) {
p_access->info.i_pos = i_ntell;
p_sys->i_icy_offset = i_ntell;
p_sys->i_remaining = i_nend+1-i_ntell;
uint64_t i_size = (i_nsize > i_nend) ? i_nsize : (i_nend + 1);
if(i_size > p_access->info.i_size) {
if(i_size > p_sys->size) {
p_sys->b_has_size = true;
p_access->info.i_size = i_size;
p_sys->size = i_size;
}
msg_Dbg( p_access, "stream size=%"PRIu64",pos=%"PRIu64",remaining=%"PRIu64,
i_nsize, i_ntell, p_sys->i_remaining);
......
......@@ -309,7 +309,6 @@ static int OpenAccess(vlc_object_t *object)
access->pf_block = Block;
access->pf_seek = NULL;
access->p_sys = (access_sys_t*)sys;
access->info.i_size = var_InheritInteger(object, "imem-size");
return VLC_SUCCESS;
}
......@@ -344,6 +343,11 @@ static int ControlAccess(access_t *access, int i_query, va_list args)
*b = true;
return VLC_SUCCESS;
}
case ACCESS_GET_SIZE: {
uint64_t *s = va_arg(args, uint64_t *);
*s = var_InheritInteger(access, "imem-size");
return VLC_SUCCESS;
}
case ACCESS_GET_PTS_DELAY: {
int64_t *delay = va_arg(args, int64_t *);
*delay = DEFAULT_PTS_DELAY; /* FIXME? */
......
......@@ -185,11 +185,6 @@ int MMSHOpen( access_t *p_access )
goto error;
}
if( !p_sys->b_broadcast )
{
p_access->info.i_size = p_sys->asfh.i_file_size;
}
return VLC_SUCCESS;
error:
......@@ -245,6 +240,13 @@ static int Control( access_t *p_access, int i_query, va_list args )
*pb_bool = true;
break;
case ACCESS_GET_SIZE:
{
uint64_t *s = va_arg( args, uint64_t * );
*s = p_sys->b_broadcast ? 0 : p_sys->asfh.i_file_size;
return VLC_SUCCESS;
}
/* */
case ACCESS_GET_PTS_DELAY:
pi_64 = (int64_t*)va_arg( args, int64_t * );
......
......@@ -176,7 +176,7 @@ int MMSTUOpen( access_t *p_access )
else
{
p_sys->b_seekable = true;
p_access->info.i_size =
p_sys->i_size =
(uint64_t)p_sys->i_header +
(uint64_t)p_sys->i_packet_count * (uint64_t)p_sys->i_packet_length;
}
......@@ -250,6 +250,10 @@ static int Control( access_t *p_access, int i_query, va_list args )
*pb_bool = true;
break;
case ACCESS_GET_SIZE:
*va_arg( args, uint64_t * ) = p_sys->i_size;
break;
/* */
case ACCESS_GET_PTS_DELAY:
pi_64 = (int64_t*)va_arg( args, int64_t * );
......
......@@ -43,6 +43,7 @@ struct access_sys_t
char sz_bind_addr[NI_MAXNUMERICHOST]; /* used by udp */
vlc_url_t url;
uint64_t i_size;
asf_header_t asfh;
......
......@@ -153,11 +153,6 @@ static int Open( vlc_object_t *p_this )
}
p_sys->fd = fd;
struct stat st;
if( fstat( fd, &st ) )
msg_Err( p_access, "fstat(%d): %m", fd );
p_access->info.i_size = st.st_size;
return VLC_SUCCESS;
}
......@@ -229,6 +224,7 @@ static int Seek( access_t *p_access, uint64_t i_pos )
*****************************************************************************/
static int Control( access_t *p_access, int i_query, va_list args )
{
access_sys_t *sys = p_access->p_sys;
bool *pb_bool;
int64_t *pi_64;
......@@ -247,6 +243,19 @@ static int Control( access_t *p_access, int i_query, va_list args )
*pb_bool = true;
break;
case ACCESS_GET_SIZE:
{
uint64_t *s = va_arg( args, uint64_t * );
struct stat st;
if( fstat( sys->fd, &st ) )
{
msg_Err( p_access, "fstat error: %m" );
return VLC_EGENERIC;
}
*s = st.st_size;
break;
}
case ACCESS_GET_PTS_DELAY:
pi_64 = ( int64_t* )va_arg( args, int64_t * );
*pi_64 = INT64_C(1000)
......
......@@ -123,7 +123,8 @@ static ssize_t Read(access_t *access, uint8_t *data, size_t size)
static int Control(access_t *access, int query, va_list args)
{
stream_t *s = access->p_sys->s;
access_sys_t *sys = access->p_sys;
stream_t *s = sys->s;
if (!s)
return VLC_EGENERIC;
......@@ -143,6 +144,9 @@ static int Control(access_t *access, int query, va_list args)
*b = true;
return VLC_SUCCESS;
}
case ACCESS_GET_SIZE:
*va_arg(args, uint64_t *) = sys->file->size;
return VLC_SUCCESS;
case ACCESS_GET_PTS_DELAY: {
int64_t *delay = va_arg(args, int64_t *);
*delay = DEFAULT_PTS_DELAY;
......@@ -198,7 +202,6 @@ static int Open(vlc_object_t *object)
access->pf_seek = Seek;
access_InitFields(access);
access->info.i_size = file->size;
rar_file_chunk_t dummy = {
.mrl = base,
......
......@@ -160,7 +160,6 @@ static int Open( vlc_object_t *p_this )
p_access->pf_seek = Seek;
p_access->pf_control = Control;
p_access->info.i_update = 0;
p_access->info.i_size = 0;
p_access->info.i_pos = 0;
p_access->info.b_eof = false;
p_access->info.i_title = 0;
......
......@@ -80,6 +80,7 @@ struct access_sys_t
LIBSSH2_SESSION* ssh_session;
LIBSSH2_SFTP* sftp_session;
LIBSSH2_SFTP_HANDLE* file;
uint64_t filesize;
size_t i_read_size;
};
......@@ -233,7 +234,7 @@ static int Open( vlc_object_t* p_this )
msg_Err( p_access, "Impossible to get information about the remote file %s", url.psz_path );
goto error;
}
p_access->info.i_size = attributes.filesize;
p_sys->filesize = attributes.filesize;
p_sys->i_read_size = var_InheritInteger( p_access, "sftp-readsize" );
......@@ -269,12 +270,14 @@ static void Close( vlc_object_t* p_this )
static block_t* Block( access_t* p_access )
{
access_sys_t *p_sys = p_access->p_sys;
if( p_access->info.b_eof )
return NULL;
/* Allocate the buffer we need */
size_t i_len = __MIN( p_access->p_sys->i_read_size, p_access->info.i_size -
p_access->info.i_pos );
size_t i_len = __MIN( p_sys->i_read_size,
p_sys->filesize - p_access->info.i_pos );
block_t* p_block = block_Alloc( i_len );
if( !p_block )
return NULL;
......@@ -335,6 +338,10 @@ static int Control( access_t* p_access, int i_query, va_list args )
*pb_bool = true;
break;
case ACCESS_GET_SIZE:
*va_arg( args, uint64_t * ) = p_access->p_sys->filesize;
break;
case ACCESS_GET_PTS_DELAY:
pi_64 = (int64_t*)va_arg( args, int64_t* );
*pi_64 = INT64_C(1000)
......
......@@ -91,6 +91,7 @@ static int Control( access_t *, int, va_list );
struct access_sys_t
{
int i_smb;
uint64_t size;
};
#ifdef _WIN32
......@@ -234,7 +235,7 @@ static int Open( vlc_object_t *p_this )
msg_Err( p_access, "stat failed (%m)" );
}
else
p_access->info.i_size = filestat.st_size;
p_sys->size = filestat.st_size;
free( psz_uri );
......@@ -318,6 +319,10 @@ static int Control( access_t *p_access, int i_query, va_list args )
*va_arg( args, bool* ) = true;
break;
case ACCESS_GET_SIZE:
*va_arg( args, uint64_t * ) = p_access->p_sys->size;
break;
case ACCESS_GET_PTS_DELAY:
*va_arg( args, int64_t * ) = INT64_C(1000)
* var_InheritInteger( p_access, "network-caching" );
......
......@@ -199,7 +199,6 @@ static int Open( vlc_object_t *p_this )
p_access->info.i_title = i_title;
p_access->info.i_seekpoint = i_chapter;
p_access->info.i_size = p_sys->title[i_title]->i_size;
p_access->info.i_pos = (uint64_t)( p_sys->i_sector - p_sys->p_sectors[1+i_title] ) *
VCD_DATA_SIZE;
......@@ -245,6 +244,11 @@ static int Control( access_t *p_access, int i_query, va_list args )
*va_arg( args, bool* ) = true;
break;
case ACCESS_GET_SIZE:
*va_arg( args, uint64_t * ) =
p_sys->title[p_access->info.i_title]->i_size;
break;
/* */
case ACCESS_GET_PTS_DELAY:
*va_arg( args, int64_t * ) = INT64_C(1000)
......@@ -276,7 +280,6 @@ static int Control( access_t *p_access, int i_query, va_list args )
INPUT_UPDATE_TITLE|INPUT_UPDATE_SEEKPOINT;
p_access->info.i_title = i;
p_access->info.i_seekpoint = 0;
p_access->info.i_size = p_sys->title[i]->i_size;
p_access->info.i_pos = 0;
/* Next sector to read */
......@@ -339,7 +342,6 @@ static block_t *Block( access_t *p_access )
INPUT_UPDATE_TITLE | INPUT_UPDATE_SEEKPOINT;
p_access->info.i_title++;
p_access->info.i_seekpoint = 0;
p_access->info.i_size = p_sys->title[p_access->info.i_title]->i_size;
p_access->info.i_pos = 0;
}
......
......@@ -675,16 +675,16 @@ VCDSetOrigin( access_t *p_access, lsn_t i_lsn, track_t i_track,
p_access->info.i_title = i_track-1;
if (p_vcdplayer->b_track_length)
{
p_access->info.i_size = p_vcdplayer->p_title[i_track-1]->i_size;
p_access->p_sys->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 {
p_access->info.i_size = M2F2_SECTOR_SIZE * (int64_t)
p_access->p_sys->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_access->info.i_size, p_access->info.i_pos );
p_access->p_sys->size, p_access->info.i_pos );
p_access->info.i_seekpoint = p_itemid->num;
break;
......@@ -696,7 +696,7 @@ VCDSetOrigin( access_t *p_access, lsn_t i_lsn, track_t i_track,
the entry seekpoints and (zeroed) lid seekpoints.
*/
p_access->info.i_title = p_vcdplayer->i_titles - 1;
p_access->info.i_size = 0; /* No seeking on stills, please. */
p_access->p_sys->size = 0; /* No seeking on stills, please. */
p_access->info.i_pos = 0;
p_access->info.i_seekpoint = p_vcdplayer->i_entries
+ p_vcdplayer->i_lids + p_itemid->num;
......@@ -704,7 +704,7 @@ VCDSetOrigin( access_t *p_access, lsn_t i_lsn, track_t i_track,
case VCDINFO_ITEM_TYPE_TRACK:
p_access->info.i_title = i_track-1;
p_access->info.i_size = p_vcdplayer->p_title[i_track-1]->i_size;
p_access->p_sys->size = p_vcdplayer->p_title[i_track-1]->i_size;
p_access->info.i_pos = 0;
p_access->info.i_seekpoint = vcdinfo_track_get_entry(p_vcdplayer->vcd,
i_track);
......@@ -853,7 +853,6 @@ VCDOpen ( vlc_object_t *p_this )
p_access->pf_seek = VCDSeek;
p_access->info.i_update = 0;
p_access->info.i_size = 0;
p_access->info.i_pos = 0;
p_access->info.b_eof = false;
p_access->info.i_title = 0;
......@@ -866,6 +865,7 @@ VCDOpen ( vlc_object_t *p_this )
p_vcdplayer->i_debug = var_InheritInteger( p_this, MODULE_STRING "-debug" );
p_access->p_sys = (access_sys_t *) p_vcdplayer;
p_access->p_sys->size = 0;
/* Set where to log errors messages from libcdio. */
p_vcd_access = p_access;
......
......@@ -160,6 +160,7 @@ typedef struct vcdplayer_input_s
bool b_track_length; /* Use track as max unit in seek */
input_thread_t *p_input;
access_t *p_access;
uint64_t size;
} vcdplayer_t;
......
......@@ -114,6 +114,7 @@ struct access_sys_t
{
/* file sizes of all parts */
size_array_t file_sizes;
uint64_t size; /* total size */
/* index and fd of current open file */
unsigned i_current_file;
......@@ -379,7 +380,7 @@ static int Seek( access_t *p_access, uint64_t i_pos )
access_sys_t *p_sys = p_access->p_sys;
/* might happen if called by ACCESS_SET_SEEKPOINT */
i_pos = __MIN( i_pos, p_access->info.i_size );
i_pos = __MIN( i_pos, p_sys->size );
p_access->info.i_pos = i_pos;
p_access->info.b_eof = false;
......@@ -478,7 +479,7 @@ static bool ImportNextFile( access_t *p_access )
free( psz_path );
ARRAY_APPEND( p_sys->file_sizes, st.st_size );
p_access->info.i_size += st.st_size;
p_sys->size += st.st_size;
return true;
}
......@@ -571,7 +572,7 @@ static void UpdateFileSize( access_t *p_access )
access_sys_t *p_sys = p_access->p_sys;
struct stat st;
if( p_access->info.i_size >= p_access->info.i_pos )
if( p_sys->size >= p_access->info.i_pos )
return;
/* TODO: not sure if this can happen or what to do in this case */
......@@ -580,9 +581,9 @@ static void UpdateFileSize( access_t *p_access )
if( (uint64_t)st.st_size <= CURRENT_FILE_SIZE )
return;
p_access->info.i_size -= CURRENT_FILE_SIZE;
p_sys->size -= CURRENT_FILE_SIZE;
CURRENT_FILE_SIZE = st.st_size;
p_access->info.i_size += CURRENT_FILE_SIZE;
p_sys->size += CURRENT_FILE_SIZE;
}
/*****************************************************************************
......@@ -808,7 +809,7 @@ static void ImportMarks( access_t *p_access )
}
p_marks->psz_name = strdup( _("VDR Cut Marks") );