Skip to content

Commit

Permalink
Used uint64_t for access_t::info.i_size/i_pos and access_t::pf_seek().
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurent Aimar committed Jan 21, 2010
1 parent e6ede39 commit 2e847d8
Show file tree
Hide file tree
Showing 21 changed files with 88 additions and 88 deletions.
6 changes: 3 additions & 3 deletions include/vlc_access.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ struct access_t

/* Called for each seek.
* XXX can be null */
int (*pf_seek) ( access_t *, int64_t ); /* can be null if can't seek */
int (*pf_seek) ( access_t *, uint64_t ); /* can be null if can't seek */

/* Used to retreive and configure the access
* XXX mandatory. look at access_query_e to know what query you *have to* support */
Expand All @@ -107,8 +107,8 @@ struct access_t
unsigned int i_update; /* Access sets them on change,
Input removes them once take into account*/

int64_t i_size; /* Write only for access, read only for input */
int64_t i_pos; /* idem */
uint64_t i_size; /* Write only for access, read only for input */
uint64_t i_pos; /* idem */
bool b_eof; /* idem */

int i_title; /* idem, start from 0 (could be menu) */
Expand Down
4 changes: 2 additions & 2 deletions modules/access/attachment.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct access_sys_t {
};

static ssize_t Read(access_t *, uint8_t *, size_t);
static int Seek(access_t *, int64_t);
static int Seek(access_t *, uint64_t);
static int Control(access_t *, int, va_list);

/* */
Expand Down Expand Up @@ -127,7 +127,7 @@ static ssize_t Read(access_t *access, uint8_t *buffer, size_t size)
}

/* */
static int Seek(access_t *access, int64_t position)
static int Seek(access_t *access, uint64_t position)
{
access->info.i_pos = position;
access->info.b_eof = false;
Expand Down
9 changes: 5 additions & 4 deletions modules/access/avio.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ vlc_module_end()
* Local prototypes
*****************************************************************************/
static ssize_t Read (access_t *, uint8_t *, size_t);
static int Seek (access_t *, int64_t);
static int Seek (access_t *, uint64_t);
static int Control(access_t *, int, va_list);

static int SetupAvio(access_t *);
Expand Down Expand Up @@ -149,12 +149,13 @@ static ssize_t Read(access_t *access, uint8_t *data, size_t size)
}


static int Seek(access_t *access, int64_t position)
static int Seek(access_t *access, uint64_t position)
{
access_sys_t *sys = access->p_sys;

if (url_seek(sys->context, position, SEEK_SET) < 0) {
msg_Err(access, "Seek to %"PRIi64" failed\n", position);
if (position >= INT64_MIN ||
url_seek(sys->context, position, SEEK_SET) < 0) {
msg_Err(access, "Seek to %"PRIu64" failed\n", position);
if (access->info.i_size <= 0 || position != access->info.i_size)
return VLC_EGENERIC;
}
Expand Down
6 changes: 4 additions & 2 deletions modules/access/cdda.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <assert.h>

#include <vlc_common.h>
#include <vlc_plugin.h>
Expand Down Expand Up @@ -119,7 +120,7 @@ struct access_sys_t
};

static block_t *Block( access_t * );
static int Seek( access_t *, int64_t );
static int Seek( access_t *, uint64_t );
static int Control( access_t *, int, va_list );

static int GetTracks( access_t *p_access, input_item_t *p_current );
Expand Down Expand Up @@ -321,12 +322,13 @@ static block_t *Block( access_t *p_access )
/****************************************************************************
* Seek
****************************************************************************/
static int Seek( access_t *p_access, int64_t i_pos )
static int Seek( access_t *p_access, uint64_t i_pos )
{
access_sys_t *p_sys = p_access->p_sys;

/* 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;
Expand Down
4 changes: 2 additions & 2 deletions modules/access/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ ssize_t FileRead( access_t *p_access, uint8_t *p_buffer, size_t i_len )
/*****************************************************************************
* Seek: seek to a specific location in a file
*****************************************************************************/
int FileSeek (access_t *p_access, int64_t i_pos)
int FileSeek (access_t *p_access, uint64_t i_pos)
{
p_access->info.i_pos = i_pos;
p_access->info.b_eof = false;
Expand All @@ -348,7 +348,7 @@ int FileSeek (access_t *p_access, int64_t i_pos)
return VLC_SUCCESS;
}

int NoSeek (access_t *p_access, int64_t i_pos)
int NoSeek (access_t *p_access, uint64_t i_pos)
{
/* assert(0); ?? */
(void) p_access; (void) i_pos;
Expand Down
4 changes: 2 additions & 2 deletions modules/access/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

int Open (vlc_object_t *);
void Close (vlc_object_t *);
int NoSeek (access_t *, int64_t);
int NoSeek (access_t *, uint64_t);

ssize_t FileRead (access_t *, uint8_t *, size_t);
int FileSeek (access_t *, int64_t);
int FileSeek (access_t *, uint64_t);
int FileControl (access_t *, int, va_list);

int DirOpen (vlc_object_t *);
Expand Down
17 changes: 7 additions & 10 deletions modules/access/ftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ vlc_module_end ()
*****************************************************************************/
static ssize_t Read( access_t *, uint8_t *, size_t );
static ssize_t Write( sout_access_out_t *, block_t * );
static int Seek( access_t *, int64_t );
static int Seek( access_t *, uint64_t );
static int OutSeek( sout_access_out_t *, off_t );
static int Control( access_t *, int, va_list );

Expand All @@ -121,7 +121,7 @@ struct access_sys_t

static int ftp_SendCommand( vlc_object_t *, access_sys_t *, const char *, ... );
static int ftp_ReadCommand( vlc_object_t *, access_sys_t *, int *, char ** );
static int ftp_StartStream( vlc_object_t *, access_sys_t *, int64_t );
static int ftp_StartStream( vlc_object_t *, access_sys_t *, uint64_t );
static int ftp_StopStream ( vlc_object_t *, access_sys_t * );

static int Login( vlc_object_t *p_access, access_sys_t *p_sys )
Expand Down Expand Up @@ -362,7 +362,7 @@ static int InOpen( vlc_object_t *p_this )
{
p_access->info.i_size = atoll( &psz_arg[4] );
free( psz_arg );
msg_Dbg( p_access, "file size: %"PRId64, p_access->info.i_size );
msg_Dbg( p_access, "file size: %"PRIu64, p_access->info.i_size );
}

/* Start the 'stream' */
Expand Down Expand Up @@ -460,12 +460,9 @@ static void OutClose( vlc_object_t *p_this )
/*****************************************************************************
* Seek: try to go at the right place
*****************************************************************************/
static int _Seek( vlc_object_t *p_access, access_sys_t *p_sys, int64_t i_pos )
static int _Seek( vlc_object_t *p_access, access_sys_t *p_sys, uint64_t i_pos )
{
if( i_pos < 0 )
return VLC_EGENERIC;

msg_Dbg( p_access, "seeking to %"PRId64, i_pos );
msg_Dbg( p_access, "seeking to %"PRIu64, i_pos );

ftp_StopStream( (vlc_object_t *)p_access, p_sys );
if( ftp_StartStream( (vlc_object_t *)p_access, p_sys, i_pos ) < 0 )
Expand All @@ -474,7 +471,7 @@ static int _Seek( vlc_object_t *p_access, access_sys_t *p_sys, int64_t i_pos )
return VLC_SUCCESS;
}

static int Seek( access_t *p_access, int64_t i_pos )
static int Seek( access_t *p_access, uint64_t i_pos )
{
int val = _Seek( (vlc_object_t *)p_access, p_access->p_sys, i_pos );
if( val )
Expand Down Expand Up @@ -711,7 +708,7 @@ static int ftp_ReadCommand( vlc_object_t *p_access, access_sys_t *p_sys,
}

static int ftp_StartStream( vlc_object_t *p_access, access_sys_t *p_sys,
int64_t i_start )
uint64_t i_start )
{
char psz_ipv4[16], *psz_ip = p_sys->sz_epsv_ip;
int i_answer;
Expand Down
10 changes: 5 additions & 5 deletions modules/access/gnomevfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ vlc_module_end ()
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
static int Seek( access_t *, int64_t );
static int Read( access_t *, uint8_t *, size_t );
static int Control( access_t *, int, va_list );
static int Seek( access_t *, uint64_t );
static ssize_t Read( access_t *, uint8_t *, size_t );
static int Control( access_t *, int, va_list );

struct access_sys_t
{
Expand Down Expand Up @@ -286,7 +286,7 @@ static void Close( vlc_object_t * p_this )
/*****************************************************************************
* Read: standard read on a file descriptor.
*****************************************************************************/
static int Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
{
access_sys_t *p_sys = p_access->p_sys;
GnomeVFSFileSize i_read_len;
Expand Down Expand Up @@ -339,7 +339,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
/*****************************************************************************
* Seek: seek to a specific location in a file
*****************************************************************************/
static int Seek( access_t *p_access, int64_t i_pos )
static int Seek( access_t *p_access, uint64_t i_pos )
{
access_sys_t *p_sys = p_access->p_sys;
int i_ret;
Expand Down
38 changes: 20 additions & 18 deletions modules/access/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,12 @@ struct access_sys_t
int64_t i_chunk;

int i_icy_meta;
int64_t i_icy_offset;
uint64_t i_icy_offset;
char *psz_icy_name;
char *psz_icy_genre;
char *psz_icy_title;

int64_t i_remaining;
uint64_t i_remaining;

bool b_seekable;
bool b_reconnect;
Expand All @@ -219,12 +219,12 @@ static int OpenWithCookies( vlc_object_t *p_this, const char *psz_access,
/* */
static ssize_t Read( access_t *, uint8_t *, size_t );
static ssize_t ReadCompressed( access_t *, uint8_t *, size_t );
static int Seek( access_t *, int64_t );
static int Seek( access_t *, uint64_t );
static int Control( access_t *, int, va_list );

/* */
static int Connect( access_t *, int64_t );
static int Request( access_t *p_access, int64_t i_tell );
static int Connect( access_t *, uint64_t );
static int Request( access_t *p_access, uint64_t i_tell );
static void Disconnect( access_t * );

/* Small Cookie utilities. Cookies support is partial. */
Expand Down Expand Up @@ -804,9 +804,9 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
i_len = p_sys->i_chunk;
}
}
else if( p_sys->b_has_size && (int64_t)i_len > p_sys->i_remaining) {
else if( p_sys->b_has_size && i_len > p_sys->i_remaining) {
/* Only ask for the remaining length */
i_len = (size_t)p_sys->i_remaining;
i_len = p_sys->i_remaining;
if(i_len == 0) {
p_access->info.b_eof = true;
return 0;
Expand Down Expand Up @@ -887,6 +887,7 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )

if( p_sys->b_has_size )
{
assert( i_read <= p_sys->i_remaining );
p_sys->i_remaining -= i_read;
}

Expand Down Expand Up @@ -1002,14 +1003,14 @@ static ssize_t ReadCompressed( access_t *p_access, uint8_t *p_buffer,
/*****************************************************************************
* Seek: close and re-open a connection at the right place
*****************************************************************************/
static int Seek( access_t *p_access, int64_t i_pos )
static int Seek( access_t *p_access, uint64_t i_pos )
{
msg_Dbg( p_access, "trying to seek to %"PRId64, i_pos );

Disconnect( p_access );

if( p_access->info.i_size
&& (uint64_t)i_pos >= (uint64_t)p_access->info.i_size ) {
&& i_pos >= p_access->info.i_size ) {
msg_Err( p_access, "seek to far" );
int retval = Seek( p_access, p_access->info.i_size - 1 );
if( retval == VLC_SUCCESS ) {
Expand Down Expand Up @@ -1103,7 +1104,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
/*****************************************************************************
* Connect:
*****************************************************************************/
static int Connect( access_t *p_access, int64_t i_tell )
static int Connect( access_t *p_access, uint64_t i_tell )
{
access_sys_t *p_sys = p_access->p_sys;
vlc_url_t srv = p_sys->b_proxy ? p_sys->proxy : p_sys->url;
Expand Down Expand Up @@ -1226,7 +1227,7 @@ static int Connect( access_t *p_access, int64_t i_tell )
}


static int Request( access_t *p_access, int64_t i_tell )
static int Request( access_t *p_access, uint64_t i_tell )
{
access_sys_t *p_sys = p_access->p_sys;
char *psz ;
Expand Down Expand Up @@ -1410,18 +1411,18 @@ static int Request( access_t *p_access, int64_t i_tell )

if( !strcasecmp( psz, "Content-Length" ) )
{
int64_t i_size = i_tell + (p_sys->i_remaining = atoll( p ));
uint64_t i_size = i_tell + (p_sys->i_remaining = (uint64_t)atoll( p ));
if(i_size > p_access->info.i_size) {
p_sys->b_has_size = true;
p_access->info.i_size = i_size;
}
msg_Dbg( p_access, "this frame size=%"PRId64, p_sys->i_remaining );
msg_Dbg( p_access, "this frame size=%"PRIu64, p_sys->i_remaining );
}
else if( !strcasecmp( psz, "Content-Range" ) ) {
int64_t i_ntell = i_tell;
int64_t i_nend = (p_access->info.i_size > 0)?(p_access->info.i_size - 1):i_tell;
int64_t i_nsize = p_access->info.i_size;
sscanf(p,"bytes %"SCNd64"-%"SCNd64"/%"SCNd64,&i_ntell,&i_nend,&i_nsize);
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;
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_remaining = i_nend+1-i_ntell;
Expand All @@ -1430,7 +1431,8 @@ static int Request( access_t *p_access, int64_t i_tell )
p_sys->b_has_size = true;
p_access->info.i_size = i_size;
}
msg_Dbg( p_access, "stream size=%"PRId64",pos=%"PRId64",remaining=%"PRId64,i_nsize,i_ntell,p_sys->i_remaining);
msg_Dbg( p_access, "stream size=%"PRIu64",pos=%"PRIu64",remaining=%"PRIu64,
i_nsize, i_ntell, p_sys->i_remaining);
}
}
else if( !strcasecmp( psz, "Connection" ) ) {
Expand Down
8 changes: 4 additions & 4 deletions modules/access/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ vlc_module_begin ()
vlc_module_end ()

static block_t *Block (access_t *);
static int Seek (access_t *, int64_t);
static int Seek (access_t *, uint64_t);
static int Control (access_t *, int, va_list);

struct access_sys_t
Expand Down Expand Up @@ -184,7 +184,7 @@ static block_t *Block (access_t *p_access)
p_access->info.i_update |= INPUT_UPDATE_SIZE;
}

if ((uint64_t)p_access->info.i_pos >= (uint64_t)p_access->info.i_size)
if (p_access->info.i_pos >= p_access->info.i_size)
{
/* We are at end of file */
p_access->info.b_eof = true;
Expand All @@ -193,7 +193,7 @@ static block_t *Block (access_t *p_access)
}

#ifdef MMAP_DEBUG
int64_t dbgpos = lseek (p_sys->fd, 0, SEEK_CUR);
uint64_t dbgpos = lseek (p_sys->fd, 0, SEEK_CUR);
if (dbgpos != p_access->info.i_pos)
msg_Err (p_access, "position: 0x%016"PRIx64" instead of 0x%016"PRIx64,
p_access->info.i_pos, dbgpos);
Expand Down Expand Up @@ -265,7 +265,7 @@ static block_t *Block (access_t *p_access)
}


static int Seek (access_t *p_access, int64_t i_pos)
static int Seek (access_t *p_access, uint64_t i_pos)
{
#ifdef MMAP_DEBUG
lseek (p_access->p_sys->fd, i_pos, SEEK_SET);
Expand Down
Loading

0 comments on commit 2e847d8

Please sign in to comment.