From 5c1b8d4aa1d35c806159cb22d52449774eb5186e Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 12 Jul 2013 22:05:43 +0200 Subject: stream: don't require streams to set a type Set the type only for streams that have special treatment in other parts of the code. --- stream/stream.c | 4 ---- stream/stream.h | 34 +++++++++++++--------------------- stream/stream_bluray.c | 1 - stream/stream_cdda.c | 1 - stream/stream_lavf.c | 1 - stream/stream_memory.c | 2 -- stream/stream_null.c | 2 -- stream/stream_smb.c | 1 - stream/stream_vcd.c | 1 - 9 files changed, 13 insertions(+), 34 deletions(-) (limited to 'stream') diff --git a/stream/stream.c b/stream/stream.c index 32ae0047be..39fc872169 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -175,8 +175,6 @@ static stream_t *open_stream_plugin(const stream_info_t *sinfo, s->cache_size = 320; } - if (s->type <= -2) - mp_msg(MSGT_OPEN, MSGL_WARN, "Warning streams need a type !!!!\n"); if (!s->seek) s->flags &= ~MP_STREAM_SEEK; if (s->seek && !(s->flags & MP_STREAM_SEEK)) @@ -595,7 +593,6 @@ static stream_t *new_stream(size_t min_size) memset(s, 0, sizeof(stream_t)); s->fd = -2; - s->type = -2; return s; } @@ -672,7 +669,6 @@ int stream_enable_cache(stream_t **stream, int64_t size, int64_t min, orig->buf_len = orig->buf_pos = 0; stream_t *cache = new_stream(0); - cache->type = STREAMTYPE_CACHE; cache->uncached_type = orig->type; cache->uncached_stream = orig; cache->flags |= MP_STREAM_SEEK; diff --git a/stream/stream.h b/stream/stream.h index 0d7e02ed4d..b80f31c44f 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -34,25 +34,17 @@ #define O_BINARY 0 #endif -#define STREAMTYPE_DUMMY -1 // for placeholders, when the actual reading is handled in the demuxer -#define STREAMTYPE_FILE 0 // read from seekable file -#define STREAMTYPE_VCD 1 // raw mode-2 CDROM reading, 2324 bytes/sector -#define STREAMTYPE_DVD 3 // libdvdread -#define STREAMTYPE_MEMORY 4 -#define STREAMTYPE_PLAYLIST 6 // FIXME!!! same as STREAMTYPE_FILE now -#define STREAMTYPE_CDDA 10 // raw audio CD reader -#define STREAMTYPE_SMB 11 // smb:// url, using libsmbclient (samba) -#define STREAMTYPE_VCDBINCUE 12 // vcd directly from bin/cue files -#define STREAMTYPE_DVB 13 -#define STREAMTYPE_VSTREAM 14 -#define STREAMTYPE_SDP 15 -#define STREAMTYPE_PVR 16 -#define STREAMTYPE_TV 17 -#define STREAMTYPE_MF 18 -#define STREAMTYPE_RADIO 19 -#define STREAMTYPE_BLURAY 20 -#define STREAMTYPE_AVDEVICE 21 -#define STREAMTYPE_CACHE 22 +enum streamtype { + STREAMTYPE_GENERIC = 0, + STREAMTYPE_FILE, + STREAMTYPE_RADIO, + STREAMTYPE_DVB, + STREAMTYPE_DVD, + STREAMTYPE_PVR, + STREAMTYPE_TV, + STREAMTYPE_MF, + STREAMTYPE_AVDEVICE, +}; #define STREAM_BUFFER_SIZE 2048 #define STREAM_MAX_SECTOR_SIZE (8 * 1024) @@ -143,8 +135,8 @@ typedef struct stream { void (*close)(struct stream *s); int fd; // file descriptor, see man open(2) - int type; // see STREAMTYPE_* - int uncached_type; // like (uncached_stream ? uncached_stream->type : type) + enum streamtype type; // see STREAMTYPE_* + enum streamtype uncached_type; // if stream is cache, type of wrapped str. int flags; // MP_STREAM_SEEK_* or'ed flags 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 diff --git a/stream/stream_bluray.c b/stream/stream_bluray.c index 505dafd5a9..bd8e491cd2 100644 --- a/stream/stream_bluray.c +++ b/stream/stream_bluray.c @@ -409,7 +409,6 @@ err_no_info: s->sector_size = BLURAY_SECTOR_SIZE; s->flags = MP_STREAM_SEEK; s->priv = b; - s->type = STREAMTYPE_BLURAY; s->url = strdup("br://"); mp_tmsg(MSGT_OPEN, MSGL_V, "Blu-ray successfully opened.\n"); diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c index 18855918ad..2f72d442bd 100644 --- a/stream/stream_cdda.c +++ b/stream/stream_cdda.c @@ -470,7 +470,6 @@ static int open_cdda(stream_t *st, int m, void *opts) st->priv = priv; st->start_pos = priv->start_sector * CDIO_CD_FRAMESIZE_RAW; st->end_pos = (priv->end_sector + 1) * CDIO_CD_FRAMESIZE_RAW; - st->type = STREAMTYPE_CDDA; st->sector_size = CDIO_CD_FRAMESIZE_RAW; st->fill_buffer = fill_buffer; diff --git a/stream/stream_lavf.c b/stream/stream_lavf.c index d0e7017b4d..6b8f25b56f 100644 --- a/stream/stream_lavf.c +++ b/stream/stream_lavf.c @@ -222,7 +222,6 @@ static int open_f(stream_t *stream, int mode, void *opts) int64_t size = avio_size(avio); if (size >= 0) stream->end_pos = size; - stream->type = STREAMTYPE_FILE; stream->seek = seek; if (!avio->seekable) stream->seek = NULL; diff --git a/stream/stream_memory.c b/stream/stream_memory.c index 3616972cc5..2e96a13e37 100644 --- a/stream/stream_memory.c +++ b/stream/stream_memory.c @@ -56,8 +56,6 @@ static int control(stream_t *s, int cmd, void *arg) static int open_f(stream_t *stream, int mode, void* opts) { - stream->type = STREAMTYPE_MEMORY; - stream->fill_buffer = fill_buffer; stream->seek = seek; stream->control = control; diff --git a/stream/stream_null.c b/stream/stream_null.c index c1965e6bd0..0d3efd9015 100644 --- a/stream/stream_null.c +++ b/stream/stream_null.c @@ -25,8 +25,6 @@ static int open_s(stream_t *stream,int mode, void* opts) { - stream->type = STREAMTYPE_DUMMY; - return 1; } diff --git a/stream/stream_smb.c b/stream/stream_smb.c index b1ebaecd00..d98d3485c1 100644 --- a/stream/stream_smb.c +++ b/stream/stream_smb.c @@ -165,7 +165,6 @@ static int open_f (stream_t *stream, int mode, void *opts) stream->seek = seek; if(mode == STREAM_READ) stream->end_pos = len; } - stream->type = STREAMTYPE_SMB; stream->fd = fd; stream->fill_buffer = fill_buffer; stream->write_buffer = write_buffer; diff --git a/stream/stream_vcd.c b/stream/stream_vcd.c index a8b7924030..8828f227d9 100644 --- a/stream/stream_vcd.c +++ b/stream/stream_vcd.c @@ -221,7 +221,6 @@ static int open_s(stream_t *stream,int mode, void* opts) #endif stream->fd = f; - stream->type = STREAMTYPE_VCD; stream->sector_size = VCD_SECTOR_DATA; stream->start_pos=ret; stream->end_pos=ret2; -- cgit v1.2.3