From 6832bf3060dc19d876e4f9d6e653f69a24651b96 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 6 Jun 2013 20:39:53 +0200 Subject: stream: cosmetics --- stream/stream.c | 22 ++++++---------------- stream/stream.h | 16 ++++++---------- 2 files changed, 12 insertions(+), 26 deletions(-) (limited to 'stream') diff --git a/stream/stream.c b/stream/stream.c index cc45164b62..5f45218383 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -289,8 +289,6 @@ stream_t *open_output_stream(const char *filename, struct MPOpts *options) return open_stream_full(filename, STREAM_WRITE, options, NULL); } -//=================== STREAMER ========================= - static int stream_reconnect(stream_t *s) { #define MAX_RECONNECT_RETRIES 5 @@ -486,12 +484,11 @@ static int stream_seek_unbuffered(stream_t *s, int64_t newpos) if (newpos == 0 || newpos != s->pos) { switch (s->type) { case STREAMTYPE_STREAM: - //s->pos=newpos; // real seek // Some streaming protocol allow to seek backward and forward // A function call that return -1 can tell that the protocol // doesn't support seeking. #ifdef CONFIG_NETWORKING - if (s->seek) { // new stream seek is much cleaner than streaming_ctrl one + if (s->seek) { if (!s->seek(s, newpos)) { mp_tmsg(MSGT_STREAM, MSGL_ERR, "Seek failed\n"); return 0; @@ -525,9 +522,6 @@ static int stream_seek_unbuffered(stream_t *s, int64_t newpos) return 0; } } -// putchar('.');fflush(stdout); -//} else { -// putchar('%');fflush(stdout); } return -1; } @@ -539,8 +533,6 @@ static int stream_seek_long(stream_t *s, int64_t pos) int res; int64_t newpos = 0; -// if( mp_msg_test(MSGT_STREAM,MSGL_DBG3) ) printf("seek_long to 0x%X\n",(unsigned int)pos); - s->buf_pos = s->buf_len = 0; if (s->mode == STREAM_WRITE) { @@ -557,6 +549,7 @@ static int stream_seek_long(stream_t *s, int64_t pos) mp_msg(MSGT_STREAM, MSGL_DBG3, "s->pos=%" PRIX64 " newpos=%" PRIX64 " new_bufpos=%" PRIX64 " buflen=%X \n", (int64_t)s->pos, (int64_t)newpos, (int64_t)pos, s->buf_len); + pos -= newpos; res = stream_seek_unbuffered(s, newpos); @@ -565,7 +558,7 @@ static int stream_seek_long(stream_t *s, int64_t pos) while (s->pos < newpos) { if (stream_fill_buffer(s) <= 0) - break; // EOF + break; // EOF } s->eof = 0; // EOF reset when seek succeeds. @@ -576,7 +569,7 @@ static int stream_seek_long(stream_t *s, int64_t pos) } pos -= s->buf_len; } -// Fill failed, but seek still is a success. + // Fill failed, but seek still is a success. s->pos += pos; s->buf_pos = 0; s->buf_len = 0; @@ -592,8 +585,7 @@ int stream_seek(stream_t *s, int64_t pos) mp_dbg(MSGT_DEMUX, MSGL_DBG3, "seek to 0x%llX\n", (long long)pos); if (pos < 0) { - mp_msg(MSGT_DEMUX, MSGL_ERR, - "Invalid seek to negative position %llx!\n", + mp_msg(MSGT_DEMUX, MSGL_ERR, "Invalid seek to negative position %llx!\n", (long long)pos); pos = 0; } @@ -602,7 +594,6 @@ int stream_seek(stream_t *s, int64_t pos) if (x >= 0) { s->buf_pos = x; s->eof = 0; -// putchar('*');fflush(stdout); return 1; } } @@ -621,12 +612,11 @@ int stream_skip(stream_t *s, int64_t len) int x = s->buf_len - s->buf_pos; if (x == 0) { if (!stream_fill_buffer(s)) - return 0; // EOF + return 0; // EOF x = s->buf_len - s->buf_pos; } if (x > len) x = len; - //memcpy(mem,&s->buf[s->buf_pos],x); s->buf_pos += x; len -= x; } diff --git a/stream/stream.h b/stream/stream.h index f86e64d431..73cfd6e87d 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -61,20 +61,17 @@ // Max buffer for initial probe. #define STREAM_MAX_BUFFER_SIZE (2 * 1024 * 1024) -/// atm it will always use mode == STREAM_READ -/// streams that use the new api should check the mode at open + +// stream->mode #define STREAM_READ 0 #define STREAM_WRITE 1 -/// Seek flags, if not mannualy set and s->seek isn't NULL -/// MP_STREAM_SEEK is automaticly set + +// stream->flags #define MP_STREAM_SEEK_BW 2 #define MP_STREAM_SEEK_FW 4 #define MP_STREAM_SEEK (MP_STREAM_SEEK_BW | MP_STREAM_SEEK_FW) -//////////// Open return code #define STREAM_REDIRECTED -2 -/// This can't open the requested protocol (used by stream wich have a -/// * protocol when they don't know the requested protocol) #define STREAM_UNSUPPORTED -1 #define STREAM_ERROR 0 #define STREAM_OK 1 @@ -121,6 +118,7 @@ typedef enum { streaming_playing_e } streaming_status; +// All this is for legacy http streams (and other things using tcp/udp) typedef struct streaming_control { URL_t *url; streaming_status status; @@ -144,9 +142,7 @@ typedef struct stream_info_st { const char *name; const char *author; const char *comment; - /// mode isn't used atm (ie always READ) but it shouldn't be ignored - /// opts is at least in it's defaults settings and may have been - /// altered by url parsing if enabled and the options string parsing. + // opts is set from ->opts int (*open)(struct stream *st, int mode, void *opts, int *file_format); const char *protocols[MAX_STREAM_PROTOCOLS]; const void *opts; -- cgit v1.2.3