changeset 35885:3389262720da

Fix previous commit, off_t must be replaced by int64_t The commit replacing off_t by uint64_t was by accident, I meant to commit this variant. off_t must be replaced by a signed type to avoid breaking things like seeking backwards and also detecting errors from e.g. lseek without too complex hacks.
author reimar
date Sat, 16 Mar 2013 13:38:34 +0000
parents edd8273dc025
children 4921bccc0968
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, 47 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/stream/asf_mmst_streaming.c	Sat Mar 16 13:38:30 2013 +0000
+++ b/stream/asf_mmst_streaming.c	Sat Mar 16 13:38:34 2013 +0000
@@ -505,7 +505,7 @@
 
 }
 
-static int asf_mmst_streaming_seek( int fd, uint64_t pos, streaming_ctrl_t *streaming_ctrl )
+static int asf_mmst_streaming_seek( int fd, int64_t pos, streaming_ctrl_t *streaming_ctrl )
 {
 	return -1;
 	// Shut up gcc warning
--- a/stream/asf_streaming.c	Sat Mar 16 13:38:30 2013 +0000
+++ b/stream/asf_streaming.c	Sat Mar 16 13:38:34 2013 +0000
@@ -453,7 +453,7 @@
   return read;
 }
 
-static int asf_http_streaming_seek( int fd, uint64_t pos, streaming_ctrl_t *streaming_ctrl ) {
+static int asf_http_streaming_seek( int fd, int64_t pos, streaming_ctrl_t *streaming_ctrl ) {
 	return -1;
 	// to shut up gcc warning
 	fd++;
--- a/stream/network.c	Sat Mar 16 13:38:30 2013 +0000
+++ b/stream/network.c	Sat Mar 16 13:38:34 2013 +0000
@@ -197,7 +197,7 @@
 }
 
 int
-http_send_request( URL_t *url, uint64_t pos ) {
+http_send_request( URL_t *url, int64_t pos ) {
 	HTTP_header_t *http_hdr;
 	URL_t *server_url;
 	char str[256];
@@ -383,7 +383,7 @@
 }
 
 int
-http_seek( stream_t *stream, uint64_t pos ) {
+http_seek( stream_t *stream, int64_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, uint64_t pos, streaming_ctrl_t *stream_ctrl ) {
+nop_streaming_seek( int fd, int64_t pos, streaming_ctrl_t *stream_ctrl ) {
 	return -1;
 }
 
--- a/stream/network.h	Sat Mar 16 13:38:30 2013 +0000
+++ b/stream/network.h	Sat Mar 16 13:38:34 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, uint64_t pos, streaming_ctrl_t *stream_ctrl );
+int nop_streaming_seek( int fd, int64_t pos, streaming_ctrl_t *stream_ctrl );
 void streaming_ctrl_free( streaming_ctrl_t *streaming_ctrl );
 
-int http_send_request(URL_t *url, uint64_t pos);
+int http_send_request(URL_t *url, int64_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, uint64_t pos);
+int http_seek(stream_t *stream, int64_t pos);
 
 #endif /* MPLAYER_NETWORK_H */
--- a/stream/stream.c	Sat Mar 16 13:38:30 2013 +0000
+++ b/stream/stream.c	Sat Mar 16 13:38:34 2013 +0000
@@ -286,7 +286,7 @@
 #define MAX_RECONNECT_RETRIES 5
 #define RECONNECT_SLEEP_MS 1000
     int retry = 0;
-    uint64_t pos = s->pos;
+    int64_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, uint64_t newpos)
+int stream_seek_internal(stream_t *s, int64_t newpos)
 {
 if(newpos==0 || newpos!=s->pos){
   switch(s->type){
@@ -428,9 +428,9 @@
   return -1;
 }
 
-int stream_seek_long(stream_t *s, uint64_t pos){
+int stream_seek_long(stream_t *s, int64_t pos){
   int res;
-  uint64_t newpos=0;
+  int64_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&(~((uint64_t)STREAM_BUFFER_SIZE-1));
+      newpos = pos&(~((int64_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 13:38:30 2013 +0000
+++ b/stream/stream.h	Sat Mar 16 13:38:34 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, uint64_t pos, struct streaming_control *stream_ctrl );
+	int (*streaming_seek)( int fd, int64_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, uint64_t pos);
+  int (*seek)(struct stream *s, int64_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;
-  uint64_t pos,start_pos,end_pos;
+  int64_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, uint64_t pos);
+int stream_seek_long(stream_t *s, int64_t pos);
 void stream_capture_do(stream_t *s);
 
 #ifdef CONFIG_STREAM_CACHE
@@ -312,12 +312,12 @@
   return s->eof;
 }
 
-static inline uint64_t stream_tell(stream_t *s)
+static inline int64_t stream_tell(stream_t *s)
 {
   return s->pos+s->buf_pos-s->buf_len;
 }
 
-static inline int stream_seek(stream_t *s, uint64_t pos)
+static inline int stream_seek(stream_t *s, int64_t pos)
 {
 
   mp_dbg(MSGT_DEMUX, MSGL_DBG3, "seek to 0x%"PRIX64"\n", pos);
@@ -328,7 +328,7 @@
     pos = 0;
   }
   if(pos<s->pos){
-    uint64_t x=pos-(s->pos-s->buf_len);
+    int64_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, uint64_t len)
+static inline int stream_skip(stream_t *s, int64_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, uint64_t newpos);
+int stream_seek_internal(stream_t *s, int64_t newpos);
 
 extern int bluray_angle;
 extern int bluray_chapter;
--- a/stream/stream_bd.c	Sat Mar 16 13:38:30 2013 +0000
+++ b/stream/stream_bd.c	Sat Mar 16 13:38:34 2013 +0000
@@ -101,7 +101,7 @@
     stream_t     *title_file;
     struct AVAES *aescbc;
     struct AVAES *aeseed;
-    uint64_t      pos;
+    int64_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, uint64_t pos)
+static int bd_stream_seek(stream_t *s, int64_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 uint64_t bd_read(struct bd_priv *bd, uint8_t *buf, int len)
+static int64_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 13:38:30 2013 +0000
+++ b/stream/stream_bluray.c	Sat Mar 16 13:38:34 2013 +0000
@@ -87,10 +87,10 @@
     free(b);
 }
 
-static int bluray_stream_seek(stream_t *s, uint64_t pos)
+static int bluray_stream_seek(stream_t *s, int64_t pos)
 {
     struct bluray_priv_s *b = s->priv;
-    uint64_t p;
+    int64_t p;
 
     p = bd_seek(b->bd, pos);
     if (p == -1)
--- a/stream/stream_cdda.c	Sat Mar 16 13:38:30 2013 +0000
+++ b/stream/stream_cdda.c	Sat Mar 16 13:38:34 2013 +0000
@@ -170,7 +170,7 @@
   return CD_FRAMESIZE_RAW;
 }
 
-static int seek(stream_t* s, uint64_t newpos) {
+static int seek(stream_t* s, int64_t newpos) {
   cdda_priv* p = (cdda_priv*)s->priv;
   cd_track_t *cd_track;
   int sec;
--- a/stream/stream_cue.c	Sat Mar 16 13:38:30 2013 +0000
+++ b/stream/stream_cue.c	Sat Mar 16 13:38:34 2013 +0000
@@ -480,7 +480,7 @@
   return VCD_SECTOR_DATA * sector;
 }
 
-static int seek(stream_t *s, uint64_t newpos) {
+static int seek(stream_t *s, int64_t newpos) {
   s->pos=newpos;
   cue_set_msf(s->pos/VCD_SECTOR_DATA);
   return 1;
--- a/stream/stream_dvd.c	Sat Mar 16 13:38:30 2013 +0000
+++ b/stream/stream_dvd.c	Sat Mar 16 13:38:34 2013 +0000
@@ -416,7 +416,7 @@
 
 static int fill_buffer(stream_t *s, char *buf, int len)
 {
-  uint64_t pos;
+  int64_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, uint64_t newpos) {
+static int seek(stream_t *s, int64_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;
-    uint64_t pos;
+    int64_t pos;
 
     if(!vts_file || !tt_srpt)
        return 0;
@@ -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;
-    uint64_t pos = -1;
+    int64_t pos = -1;
     dvd_priv_t *d = stream->priv;
     vts_tmapt_t *vts_tmapt = vts_file->vts_tmapt;
 
--- a/stream/stream_dvdnav.c	Sat Mar 16 13:38:30 2013 +0000
+++ b/stream/stream_dvdnav.c	Sat Mar 16 13:38:34 2013 +0000
@@ -87,7 +87,7 @@
   stream_opts_fields
 };
 
-static int seek(stream_t *s, uint64_t newpos);
+static int seek(stream_t *s, int64_t newpos);
 static void show_audio_subs_languages(dvdnav_t *nav);
 
 static dvdnav_priv_t * new_dvdnav_stream(char * filename) {
@@ -285,7 +285,7 @@
 }
 
 
-static int seek(stream_t *s, uint64_t newpos) {
+static int seek(stream_t *s, int64_t newpos) {
   uint32_t sector = 0;
   dvdnav_priv_t *priv = s->priv;
 
--- a/stream/stream_ffmpeg.c	Sat Mar 16 13:38:30 2013 +0000
+++ b/stream/stream_ffmpeg.c	Sat Mar 16 13:38:34 2013 +0000
@@ -42,7 +42,7 @@
     return len;
 }
 
-static int seek(stream_t *s, uint64_t newpos)
+static int seek(stream_t *s, int64_t newpos)
 {
     s->pos = newpos;
     if (avio_seek(s->priv, s->pos, SEEK_SET) < 0) {
--- a/stream/stream_file.c	Sat Mar 16 13:38:30 2013 +0000
+++ b/stream/stream_file.c	Sat Mar 16 13:38:34 2013 +0000
@@ -78,7 +78,7 @@
   return len;
 }
 
-static int seek(stream_t *s, uint64_t newpos) {
+static int seek(stream_t *s, int64_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, uint64_t newpos) {
+static int seek_forward(stream_t *s, int64_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;
-  uint64_t len;
+  int64_t len;
   unsigned char *filename;
   struct stream_priv_s* p = (struct stream_priv_s*)opts;
 
--- a/stream/stream_ftp.c	Sat Mar 16 13:38:30 2013 +0000
+++ b/stream/stream_ftp.c	Sat Mar 16 13:38:34 2013 +0000
@@ -284,7 +284,7 @@
   return fd;
 }
 
-static int FtpOpenData(stream_t* s, uint64_t newpos) {
+static int FtpOpenData(stream_t* s, int64_t newpos) {
   struct stream_priv_s* p = s->priv;
   int resp;
   char rsp_txt[256];
@@ -332,7 +332,7 @@
   return (r <= 0) ? -1 : r;
 }
 
-static int seek(stream_t *s, uint64_t newpos) {
+static int seek(stream_t *s, int64_t newpos) {
   struct stream_priv_s* p = s->priv;
   int resp;
   char rsp_txt[256];
--- a/stream/stream_live555.c	Sat Mar 16 13:38:30 2013 +0000
+++ b/stream/stream_live555.c	Sat Mar 16 13:38:34 2013 +0000
@@ -29,7 +29,7 @@
 #include "libmpdemux/demuxer.h"
 #include "help_mp.h"
 
-static int _rtsp_streaming_seek(int fd, uint64_t pos, streaming_ctrl_t* streaming_ctrl) {
+static int _rtsp_streaming_seek(int fd, int64_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 13:38:30 2013 +0000
+++ b/stream/stream_nemesi.c	Sat Mar 16 13:38:34 2013 +0000
@@ -39,7 +39,7 @@
 
 char *rtsp_destination = NULL;
 
-static int rtsp_streaming_seek(int fd, uint64_t pos,
+static int rtsp_streaming_seek(int fd, int64_t pos,
                                streaming_ctrl_t* streaming_ctrl) {
     return -1;
 }
--- a/stream/stream_netstream.c	Sat Mar 16 13:38:30 2013 +0000
+++ b/stream/stream_netstream.c	Sat Mar 16 13:38:34 2013 +0000
@@ -188,7 +188,7 @@
 }
 
 
-static int seek(stream_t *s, uint64_t newpos) {
+static int seek(stream_t *s, int64_t newpos) {
   uint64_t pos = le2me_64(newpos);
   mp_net_stream_packet_t* pack;
 
--- a/stream/stream_smb.c	Sat Mar 16 13:38:30 2013 +0000
+++ b/stream/stream_smb.c	Sat Mar 16 13:38:34 2013 +0000
@@ -86,7 +86,7 @@
   return STREAM_UNSUPPORTED;
 }
 
-static int seek(stream_t *s, uint64_t newpos) {
+static int seek(stream_t *s, int64_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 13:38:30 2013 +0000
+++ b/stream/stream_vcd.c	Sat Mar 16 13:38:34 2013 +0000
@@ -83,7 +83,7 @@
   return vcd_read(s->priv,buffer);
 }
 
-static int seek(stream_t *s, uint64_t newpos) {
+static int seek(stream_t *s, int64_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 13:38:30 2013 +0000
+++ b/stream/stream_vstream.c	Sat Mar 16 13:38:34 2013 +0000
@@ -90,7 +90,7 @@
   return len;
 }
 
-static int seek(stream_t *s, uint64_t newpos) {
+static int seek(stream_t *s, int64_t newpos) {
   s->pos = newpos;
   return 1;
 }