changeset 35881:b5abdfe9bc61

Replace some uses of off_t by uint64_t. This allows code that does not rely on lseek etc. to work even on systems that do not support 64 bit off_t yet. Signed-off-by: Reimar Dffinger <Reimar.Doeffinger@gmx.de>
author reimar
date Sat, 16 Mar 2013 10:09:12 +0000
parents 25429dbfa18e
children 6bdb39d9a114
files stream/asf_mmst_streaming.c stream/asf_streaming.c stream/network.c stream/network.h stream/stream.c stream/stream.h stream/stream_bd.c stream/stream_bluray.c stream/stream_cdda.c stream/stream_cue.c stream/stream_dvd.c stream/stream_dvdnav.c stream/stream_ffmpeg.c stream/stream_file.c stream/stream_ftp.c stream/stream_live555.c stream/stream_nemesi.c stream/stream_netstream.c stream/stream_smb.c stream/stream_vcd.c stream/stream_vstream.c
diffstat 21 files changed, 57 insertions(+), 57 deletions(-) [+]
line wrap: on
line diff
--- a/stream/asf_mmst_streaming.c	Sat Mar 16 09:20:51 2013 +0000
+++ b/stream/asf_mmst_streaming.c	Sat Mar 16 10:09:12 2013 +0000
@@ -505,7 +505,7 @@
 
 }
 
-static int asf_mmst_streaming_seek( int fd, off_t pos, streaming_ctrl_t *streaming_ctrl )
+static int asf_mmst_streaming_seek( int fd, uint64_t pos, streaming_ctrl_t *streaming_ctrl )
 {
 	return -1;
 	// Shut up gcc warning
--- a/stream/asf_streaming.c	Sat Mar 16 09:20:51 2013 +0000
+++ b/stream/asf_streaming.c	Sat Mar 16 10:09:12 2013 +0000
@@ -453,7 +453,7 @@
   return read;
 }
 
-static int asf_http_streaming_seek( int fd, off_t pos, streaming_ctrl_t *streaming_ctrl ) {
+static int asf_http_streaming_seek( int fd, uint64_t pos, streaming_ctrl_t *streaming_ctrl ) {
 	return -1;
 	// to shut up gcc warning
 	fd++;
--- a/stream/network.c	Sat Mar 16 09:20:51 2013 +0000
+++ b/stream/network.c	Sat Mar 16 10:09:12 2013 +0000
@@ -197,7 +197,7 @@
 }
 
 int
-http_send_request( URL_t *url, off_t pos ) {
+http_send_request( URL_t *url, uint64_t pos ) {
 	HTTP_header_t *http_hdr;
 	URL_t *server_url;
 	char str[256];
@@ -383,7 +383,7 @@
 }
 
 int
-http_seek( stream_t *stream, off_t pos ) {
+http_seek( stream_t *stream, uint64_t pos ) {
 	HTTP_header_t *http_hdr = NULL;
 	int fd;
 	if( stream==NULL ) return 0;
@@ -479,7 +479,7 @@
 }
 
 int
-nop_streaming_seek( int fd, off_t pos, streaming_ctrl_t *stream_ctrl ) {
+nop_streaming_seek( int fd, uint64_t pos, streaming_ctrl_t *stream_ctrl ) {
 	return -1;
 }
 
--- a/stream/network.h	Sat Mar 16 09:20:51 2013 +0000
+++ b/stream/network.h	Sat Mar 16 10:09:12 2013 +0000
@@ -76,10 +76,10 @@
 int streaming_bufferize( streaming_ctrl_t *streaming_ctrl, char *buffer, int size);
 
 int nop_streaming_read( int fd, char *buffer, int size, streaming_ctrl_t *stream_ctrl );
-int nop_streaming_seek( int fd, off_t pos, streaming_ctrl_t *stream_ctrl );
+int nop_streaming_seek( int fd, uint64_t pos, streaming_ctrl_t *stream_ctrl );
 void streaming_ctrl_free( streaming_ctrl_t *streaming_ctrl );
 
-int http_send_request(URL_t *url, off_t pos);
+int http_send_request(URL_t *url, uint64_t pos);
 HTTP_header_t *http_read_response(int fd);
 
 int http_authenticate(HTTP_header_t *http_hdr, URL_t *url, int *auth_retry);
@@ -87,6 +87,6 @@
 URL_t *url_new_with_proxy(const char *urlstr);
 
 void fixup_network_stream_cache(stream_t *stream);
-int http_seek(stream_t *stream, off_t pos);
+int http_seek(stream_t *stream, uint64_t pos);
 
 #endif /* MPLAYER_NETWORK_H */
--- a/stream/stream.c	Sat Mar 16 09:20:51 2013 +0000
+++ b/stream/stream.c	Sat Mar 16 10:09:12 2013 +0000
@@ -286,7 +286,7 @@
 #define MAX_RECONNECT_RETRIES 5
 #define RECONNECT_SLEEP_MS 1000
     int retry = 0;
-    off_t pos = s->pos;
+    uint64_t pos = s->pos;
     // Seeking is used as a hack to make network streams
     // reopen the connection, ideally they would implement
     // e.g. a STREAM_CTRL_RECONNECT to do this
@@ -380,7 +380,7 @@
   return rd;
 }
 
-int stream_seek_internal(stream_t *s, off_t newpos)
+int stream_seek_internal(stream_t *s, uint64_t newpos)
 {
 if(newpos==0 || newpos!=s->pos){
   switch(s->type){
@@ -428,9 +428,9 @@
   return -1;
 }
 
-int stream_seek_long(stream_t *s,off_t pos){
+int stream_seek_long(stream_t *s, uint64_t pos){
   int res;
-off_t newpos=0;
+  uint64_t newpos=0;
 
 //  if( mp_msg_test(MSGT_STREAM,MSGL_DBG3) ) printf("seek_long to 0x%X\n",(unsigned int)pos);
 
@@ -445,7 +445,7 @@
   if(s->sector_size)
       newpos = (pos/s->sector_size)*s->sector_size;
   else
-      newpos = pos&(~((off_t)STREAM_BUFFER_SIZE-1));
+      newpos = pos&(~((uint64_t)STREAM_BUFFER_SIZE-1));
 
 if( mp_msg_test(MSGT_STREAM,MSGL_DBG3) ){
   mp_msg(MSGT_STREAM,MSGL_DBG3, "s->pos=%"PRIX64"  newpos=%"PRIX64"  new_bufpos=%"PRIX64"  buflen=%X  \n",
--- a/stream/stream.h	Sat Mar 16 09:20:51 2013 +0000
+++ b/stream/stream.h	Sat Mar 16 10:09:12 2013 +0000
@@ -128,7 +128,7 @@
 	unsigned int buffer_pos;
 	unsigned int bandwidth;	// The downstream available
 	int (*streaming_read)( int fd, char *buffer, int buffer_size, struct streaming_control *stream_ctrl );
-	int (*streaming_seek)( int fd, off_t pos, struct streaming_control *stream_ctrl );
+	int (*streaming_seek)( int fd, uint64_t pos, struct streaming_control *stream_ctrl );
 	void *data;
 } streaming_ctrl_t;
 
@@ -155,7 +155,7 @@
   // Write
   int (*write_buffer)(struct stream *s, char* buffer, int len);
   // Seek
-  int (*seek)(struct stream *s,off_t pos);
+  int (*seek)(struct stream *s, uint64_t pos);
   // Control
   // Will be later used to let streams like dvd and cdda report
   // their structure (ie tracks, chapters, etc)
@@ -169,7 +169,7 @@
   int sector_size; // sector size (seek will be aligned on this size if non 0)
   int read_chunk; // maximum amount of data to read at once to limit latency (0 for default)
   unsigned int buf_pos,buf_len;
-  off_t pos,start_pos,end_pos;
+  uint64_t pos,start_pos,end_pos;
   int eof;
   int mode; //STREAM_READ or STREAM_WRITE
   unsigned int cache_pid;
@@ -188,7 +188,7 @@
 #endif
 
 int stream_fill_buffer(stream_t *s);
-int stream_seek_long(stream_t *s, off_t pos);
+int stream_seek_long(stream_t *s, uint64_t pos);
 void stream_capture_do(stream_t *s);
 
 #ifdef CONFIG_STREAM_CACHE
@@ -312,12 +312,12 @@
   return s->eof;
 }
 
-static inline off_t stream_tell(stream_t *s)
+static inline uint64_t stream_tell(stream_t *s)
 {
   return s->pos+s->buf_pos-s->buf_len;
 }
 
-static inline int stream_seek(stream_t *s, off_t pos)
+static inline int stream_seek(stream_t *s, uint64_t pos)
 {
 
   mp_dbg(MSGT_DEMUX, MSGL_DBG3, "seek to 0x%"PRIX64"\n", pos);
@@ -328,7 +328,7 @@
     pos = 0;
   }
   if(pos<s->pos){
-    off_t x=pos-(s->pos-s->buf_len);
+    uint64_t x=pos-(s->pos-s->buf_len);
     if(x>=0){
       s->buf_pos=x;
 //      putchar('*');fflush(stdout);
@@ -339,7 +339,7 @@
   return cache_stream_seek_long(s,pos);
 }
 
-static inline int stream_skip(stream_t *s, off_t len)
+static inline int stream_skip(stream_t *s, uint64_t len)
 {
   if( len<0 || (len>2*STREAM_BUFFER_SIZE && (s->flags & MP_STREAM_SEEK_FW)) ) {
     // negative or big skip!
@@ -375,7 +375,7 @@
 /// Internal read function bypassing the stream buffer
 int stream_read_internal(stream_t *s, void *buf, int len);
 /// Internal seek function bypassing the stream buffer
-int stream_seek_internal(stream_t *s, off_t newpos);
+int stream_seek_internal(stream_t *s, uint64_t newpos);
 
 extern int bluray_angle;
 extern int bluray_chapter;
--- a/stream/stream_bd.c	Sat Mar 16 09:20:51 2013 +0000
+++ b/stream/stream_bd.c	Sat Mar 16 10:09:12 2013 +0000
@@ -101,7 +101,7 @@
     stream_t     *title_file;
     struct AVAES *aescbc;
     struct AVAES *aeseed;
-    off_t         pos;
+    uint64_t      pos;
     struct uks    uks;
     int           nr_lang_maps;
     struct lang_map *lang_maps;
@@ -117,7 +117,7 @@
     free(bd);
 }
 
-static int bd_stream_seek(stream_t *s, off_t pos)
+static int bd_stream_seek(stream_t *s, uint64_t pos)
 {
     struct bd_priv *bd = s->priv;
 
@@ -275,7 +275,7 @@
 }
 
 // NOTE: we assume buf is sufficiently aligned to 64 bit read/writes
-static off_t bd_read(struct bd_priv *bd, uint8_t *buf, int len)
+static uint64_t bd_read(struct bd_priv *bd, uint8_t *buf, int len)
 {
     int read_len;
     int unit_offset = bd->pos % BD_UNIT_SIZE;
--- a/stream/stream_bluray.c	Sat Mar 16 09:20:51 2013 +0000
+++ b/stream/stream_bluray.c	Sat Mar 16 10:09:12 2013 +0000
@@ -87,10 +87,10 @@
     free(b);
 }
 
-static int bluray_stream_seek(stream_t *s, off_t pos)
+static int bluray_stream_seek(stream_t *s, uint64_t pos)
 {
     struct bluray_priv_s *b = s->priv;
-    off_t p;
+    uint64_t p;
 
     p = bd_seek(b->bd, pos);
     if (p == -1)
--- a/stream/stream_cdda.c	Sat Mar 16 09:20:51 2013 +0000
+++ b/stream/stream_cdda.c	Sat Mar 16 10:09:12 2013 +0000
@@ -170,7 +170,7 @@
   return CD_FRAMESIZE_RAW;
 }
 
-static int seek(stream_t* s,off_t newpos) {
+static int seek(stream_t* s, uint64_t newpos) {
   cdda_priv* p = (cdda_priv*)s->priv;
   cd_track_t *cd_track;
   int sec;
--- a/stream/stream_cue.c	Sat Mar 16 09:20:51 2013 +0000
+++ b/stream/stream_cue.c	Sat Mar 16 10:09:12 2013 +0000
@@ -480,7 +480,7 @@
   return VCD_SECTOR_DATA * sector;
 }
 
-static int seek(stream_t *s,off_t newpos) {
+static int seek(stream_t *s, uint64_t newpos) {
   s->pos=newpos;
   cue_set_msf(s->pos/VCD_SECTOR_DATA);
   return 1;
--- a/stream/stream_dvd.c	Sat Mar 16 09:20:51 2013 +0000
+++ b/stream/stream_dvd.c	Sat Mar 16 10:09:12 2013 +0000
@@ -416,7 +416,7 @@
 
 static int fill_buffer(stream_t *s, char *buf, int len)
 {
-  off_t pos;
+  uint64_t pos;
   if (len < 2048)
     return -1;
   pos = dvd_read_sector(s->priv, buf);
@@ -426,7 +426,7 @@
   return 2048; // full sector
 }
 
-static int seek(stream_t *s, off_t newpos) {
+static int seek(stream_t *s, uint64_t newpos) {
   s->pos=newpos; // real seek
   dvd_seek(s->priv,s->pos/2048);
   return 1;
@@ -504,7 +504,7 @@
     dvd_priv_t *d = stream->priv;
     ptt_info_t ptt;
     pgc_t *pgc;
-    off_t pos;
+    uint64_t pos;
 
     if(!vts_file || !tt_srpt)
        return 0;
@@ -533,7 +533,7 @@
     d->packs_left     = -1;
     d->angle_seek     = 0;
 
-    pos = (off_t) d->cur_pack * 2048;
+    pos = d->cur_pack * 2048ull;
     mp_msg(MSGT_OPEN,MSGL_V,"\r\nSTREAM_DVD, seeked to chapter: %d, cell: %u, pos: %"PRIu64"\n",
         chapter, d->cur_pack, pos);
 
@@ -597,7 +597,7 @@
     unsigned int i, j, k, timeunit, ac_time, tmap_sector=0, cell_sector=0, vobu_sector=0;
     int t=0;
     double tm, duration;
-    off_t pos = -1;
+    uint64_t pos = -1;
     dvd_priv_t *d = stream->priv;
     vts_tmapt_t *vts_tmapt = vts_file->vts_tmapt;
 
@@ -624,7 +624,7 @@
       }
     }
 
-    pos = ((off_t)cell_sector)<<11;
+    pos = cell_sector * 2048ull;
     stream_seek(stream, pos);
     do {
       stream_skip(stream, 2048);
@@ -632,7 +632,7 @@
     } while(!t);
     tm = dvd_get_current_time(stream, -1);
 
-    pos = ((off_t)tmap_sector)<<11;
+    pos = tmap_sector * 2048ull;
     stream_seek(stream, pos);
     //now get current time in terms of the cell+cell time offset
     memset(&d->dsi_pack.dsi_gi.c_eltm, 0, sizeof(dvd_time_t));
@@ -641,7 +641,7 @@
           break;
         tm = dvd_get_current_time(stream, -1);
     };
-    tmap_sector = stream->pos >> 11;
+    tmap_sector = stream->pos / 2048;
 
     //search closest VOBU sector
     k=(vts_file->vts_vobu_admap->last_byte + 1 - VOBU_ADMAP_SIZE)/4; //entries in the vobu admap
@@ -650,7 +650,7 @@
         break;
     }
     vobu_sector = vts_file->vts_vobu_admap->vobu_start_sectors[i-1];
-    pos = ((off_t)vobu_sector) << 11;
+    pos = vobu_sector * 2048ull;
     stream_seek(stream, pos);
 
     return 1;
@@ -1059,8 +1059,8 @@
     stream->seek = seek;
     stream->control = control;
     stream->close = stream_dvd_close;
-    stream->start_pos = (off_t)d->cur_pack*2048;
-    stream->end_pos = (off_t)(d->cur_pgc->cell_playback[d->last_cell-1].last_sector)*2048;
+    stream->start_pos = d->cur_pack*2048ull;
+    stream->end_pos = d->cur_pgc->cell_playback[d->last_cell-1].last_sector*2048ull;
     *file_format = DEMUXER_TYPE_MPEG_PS;
     mp_msg(MSGT_DVD,MSGL_V,"DVD start=%d end=%d  \n",d->cur_pack,d->cur_pgc->cell_playback[d->last_cell-1].last_sector);
     stream->priv = (void*)d;
--- a/stream/stream_dvdnav.c	Sat Mar 16 09:20:51 2013 +0000
+++ b/stream/stream_dvdnav.c	Sat Mar 16 10:09:12 2013 +0000
@@ -87,7 +87,7 @@
   stream_opts_fields
 };
 
-static int seek(stream_t *s, off_t newpos);
+static int seek(stream_t *s, uint64_t newpos);
 static void show_audio_subs_languages(dvdnav_t *nav);
 
 static dvdnav_priv_t * new_dvdnav_stream(char * filename) {
@@ -276,7 +276,7 @@
 
   status = dvdnav_get_position(priv->dvdnav, &pos, &len);
   if(status == DVDNAV_STATUS_OK && len) {
-    stream->end_pos = (off_t) len * 2048;
+    stream->end_pos = len * 2048ull;
     stream->seek = seek;
   } else {
     stream->seek = NULL;
@@ -285,7 +285,7 @@
 }
 
 
-static int seek(stream_t *s, off_t newpos) {
+static int seek(stream_t *s, uint64_t newpos) {
   uint32_t sector = 0;
   dvdnav_priv_t *priv = s->priv;
 
--- a/stream/stream_ffmpeg.c	Sat Mar 16 09:20:51 2013 +0000
+++ b/stream/stream_ffmpeg.c	Sat Mar 16 10:09:12 2013 +0000
@@ -42,7 +42,7 @@
     return len;
 }
 
-static int seek(stream_t *s, off_t newpos)
+static int seek(stream_t *s, uint64_t newpos)
 {
     s->pos = newpos;
     if (avio_seek(s->priv, s->pos, SEEK_SET) < 0) {
--- a/stream/stream_file.c	Sat Mar 16 09:20:51 2013 +0000
+++ b/stream/stream_file.c	Sat Mar 16 10:09:12 2013 +0000
@@ -78,7 +78,7 @@
   return len;
 }
 
-static int seek(stream_t *s,off_t newpos) {
+static int seek(stream_t *s, uint64_t newpos) {
   s->pos = newpos;
   if(lseek(s->fd,s->pos,SEEK_SET)<0) {
     s->eof=1;
@@ -87,7 +87,7 @@
   return 1;
 }
 
-static int seek_forward(stream_t *s,off_t newpos) {
+static int seek_forward(stream_t *s, uint64_t newpos) {
   if(newpos<s->pos){
     mp_msg(MSGT_STREAM,MSGL_INFO,"Cannot seek backward in linear streams!\n");
     return 0;
@@ -143,7 +143,7 @@
 static int open_f(stream_t *stream,int mode, void* opts, int* file_format) {
   int f;
   mode_t m = 0;
-  off_t len;
+  uint64_t len;
   unsigned char *filename;
   struct stream_priv_s* p = (struct stream_priv_s*)opts;
 
--- a/stream/stream_ftp.c	Sat Mar 16 09:20:51 2013 +0000
+++ b/stream/stream_ftp.c	Sat Mar 16 10:09:12 2013 +0000
@@ -284,7 +284,7 @@
   return fd;
 }
 
-static int FtpOpenData(stream_t* s,off_t newpos) {
+static int FtpOpenData(stream_t* s, uint64_t newpos) {
   struct stream_priv_s* p = s->priv;
   int resp;
   char rsp_txt[256];
@@ -295,7 +295,7 @@
   if(s->fd < 0) return 0;
 
   if(newpos > 0) {
-    snprintf(p->cmd_buf,CMD_BUFSIZE,"REST %"PRId64, (int64_t)newpos);
+    snprintf(p->cmd_buf,CMD_BUFSIZE,"REST %"PRIu64, newpos);
 
     resp = FtpSendCmd(p->cmd_buf,p,rsp_txt);
     if(resp != 3) {
@@ -332,7 +332,7 @@
   return (r <= 0) ? -1 : r;
 }
 
-static int seek(stream_t *s,off_t newpos) {
+static int seek(stream_t *s, uint64_t newpos) {
   struct stream_priv_s* p = s->priv;
   int resp;
   char rsp_txt[256];
--- a/stream/stream_live555.c	Sat Mar 16 09:20:51 2013 +0000
+++ b/stream/stream_live555.c	Sat Mar 16 10:09:12 2013 +0000
@@ -29,7 +29,7 @@
 #include "libmpdemux/demuxer.h"
 #include "help_mp.h"
 
-static int _rtsp_streaming_seek(int fd, off_t pos, streaming_ctrl_t* streaming_ctrl) {
+static int _rtsp_streaming_seek(int fd, uint64_t pos, streaming_ctrl_t* streaming_ctrl) {
   return -1; // For now, we don't handle RTSP stream seeking
 }
 
--- a/stream/stream_nemesi.c	Sat Mar 16 09:20:51 2013 +0000
+++ b/stream/stream_nemesi.c	Sat Mar 16 10:09:12 2013 +0000
@@ -39,7 +39,7 @@
 
 char *rtsp_destination = NULL;
 
-static int rtsp_streaming_seek(int fd, off_t pos,
+static int rtsp_streaming_seek(int fd, uint64_t pos,
                                streaming_ctrl_t* streaming_ctrl) {
     return -1;
 }
--- a/stream/stream_netstream.c	Sat Mar 16 09:20:51 2013 +0000
+++ b/stream/stream_netstream.c	Sat Mar 16 10:09:12 2013 +0000
@@ -188,8 +188,8 @@
 }
 
 
-static int seek(stream_t *s,off_t newpos) {
-  uint64_t pos = le2me_64((uint64_t)newpos);
+static int seek(stream_t *s, uint64_t newpos) {
+  uint64_t pos = le2me_64(newpos);
   mp_net_stream_packet_t* pack;
 
   pack = send_net_stream_cmd(s,NET_STREAM_SEEK,(char*)&pos,8);
--- a/stream/stream_smb.c	Sat Mar 16 09:20:51 2013 +0000
+++ b/stream/stream_smb.c	Sat Mar 16 10:09:12 2013 +0000
@@ -86,7 +86,7 @@
   return STREAM_UNSUPPORTED;
 }
 
-static int seek(stream_t *s,off_t newpos) {
+static int seek(stream_t *s, uint64_t newpos) {
   s->pos = newpos;
   if(smbc_lseek(s->fd,s->pos,SEEK_SET)<0) {
     s->eof=1;
--- a/stream/stream_vcd.c	Sat Mar 16 09:20:51 2013 +0000
+++ b/stream/stream_vcd.c	Sat Mar 16 10:09:12 2013 +0000
@@ -83,7 +83,7 @@
   return vcd_read(s->priv,buffer);
 }
 
-static int seek(stream_t *s,off_t newpos) {
+static int seek(stream_t *s, uint64_t newpos) {
   s->pos = newpos;
   vcd_set_msf(s->priv,s->pos/VCD_SECTOR_DATA);
   return 1;
--- a/stream/stream_vstream.c	Sat Mar 16 09:20:51 2013 +0000
+++ b/stream/stream_vstream.c	Sat Mar 16 10:09:12 2013 +0000
@@ -90,7 +90,7 @@
   return len;
 }
 
-static int seek(stream_t *s,off_t newpos) {
+static int seek(stream_t *s, uint64_t newpos) {
   s->pos = newpos;
   return 1;
 }