summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demux/demux.c6
-rw-r--r--demux/demux_lavf.c10
2 files changed, 9 insertions, 7 deletions
diff --git a/demux/demux.c b/demux/demux.c
index 1bf0277873..c0b0c2fb65 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -3104,7 +3104,6 @@ static void demux_init_cuesheet(struct demuxer *demuxer)
// Calling this after opening was completed is not allowed. Also, if opening
// failed, this must not be called (or trying another demuxer would fail).
// Useful so that e.g. subtitles don't keep the file or socket open.
-// Replaces it with a dummy stream for dumb reasons.
// If there's ever the situation where we can't allow the demuxer to close
// the stream, this function could ignore the request.
void demux_close_stream(struct demuxer *demuxer)
@@ -3117,9 +3116,8 @@ void demux_close_stream(struct demuxer *demuxer)
MP_VERBOSE(demuxer, "demuxer read all data; closing stream\n");
free_stream(demuxer->stream);
- demuxer->stream = stream_memory_open(demuxer->global, NULL, 0); // dummy
- demuxer->stream->cancel = demuxer->cancel;
- in->d_user->stream = demuxer->stream;
+ demuxer->stream = NULL;
+ in->d_user->stream = NULL;
}
static void demux_init_ccs(struct demuxer *demuxer, struct demux_opts *opts)
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c
index 374714b769..c2f6a65395 100644
--- a/demux/demux_lavf.c
+++ b/demux/demux_lavf.c
@@ -290,6 +290,8 @@ static int mp_read(void *opaque, uint8_t *buf, int size)
struct demuxer *demuxer = opaque;
lavf_priv_t *priv = demuxer->priv;
struct stream *stream = priv->stream;
+ if (!stream)
+ return 0;
int ret = stream_read_partial(stream, buf, size);
@@ -303,6 +305,8 @@ static int64_t mp_seek(void *opaque, int64_t pos, int whence)
struct demuxer *demuxer = opaque;
lavf_priv_t *priv = demuxer->priv;
struct stream *stream = priv->stream;
+ if (!stream)
+ return -1;
MP_TRACE(demuxer, "mp_seek(%p, %"PRId64", %s)\n", stream, pos,
whence == SEEK_END ? "end" :
@@ -345,7 +349,7 @@ static int64_t mp_read_seek(void *opaque, int stream_idx, int64_t ts, int flags)
.flags = flags,
};
- if (stream_control(stream, STREAM_CTRL_AVSEEK, &cmd) == STREAM_OK) {
+ if (stream && stream_control(stream, STREAM_CTRL_AVSEEK, &cmd) == STREAM_OK) {
stream_drop_buffers(stream);
return 0;
}
@@ -1106,7 +1110,7 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
if (priv->own_stream)
free_stream(priv->stream);
priv->own_stream = false;
- priv->stream = demuxer->stream;
+ priv->stream = NULL;
}
return 0;
@@ -1227,7 +1231,7 @@ static void demux_seek_lavf(demuxer_t *demuxer, double seek_pts, int flags)
if (flags & SEEK_FACTOR) {
struct stream *s = priv->stream;
- int64_t end = stream_get_size(s);
+ int64_t end = s ? stream_get_size(s) : -1;
if (end > 0 && demuxer->ts_resets_possible &&
!(priv->avif_flags & AVFMT_NO_BYTE_SEEK))
{