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.
This commit is contained in:
wm4 2013-07-12 22:05:43 +02:00
parent cb45b1c65b
commit 5c1b8d4aa1
9 changed files with 13 additions and 34 deletions

View File

@ -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;

View File

@ -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

View File

@ -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");

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -25,8 +25,6 @@
static int open_s(stream_t *stream,int mode, void* opts)
{
stream->type = STREAMTYPE_DUMMY;
return 1;
}

View File

@ -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;

View File

@ -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;