From 3269bd178020c5d821e8b2d1fd807a38d63e93ce Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 12 Jul 2013 21:58:11 +0200 Subject: demux: rewrite probing and demuxer initialization Get rid of the strange and messy reliance on DEMUXER_TYPE_ constants. Instead of having two open functions for the demuxer callbacks (which somehow are both optional, but you can also decide to implement both...), just have one function. This function takes a parameter that tells the demuxer how strictly it should check for the file headers. This is a nice simplification and allows more flexibility. Remove the file extension code. This literally did nothing (anymore). Change demux_lavf so that we check our other builtin demuxers first before libavformat tries to guess by file extension. --- demux/demux_cue.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'demux/demux_cue.c') diff --git a/demux/demux_cue.c b/demux/demux_cue.c index 43ef910868..db2f40ea57 100644 --- a/demux/demux_cue.c +++ b/demux/demux_cue.c @@ -29,21 +29,21 @@ bool mp_probe_cue(struct bstr s); #define PROBE_SIZE 512 -static int try_open_file(struct demuxer *demuxer) +static int try_open_file(struct demuxer *demuxer, enum demux_check check) { struct stream *s = demuxer->stream; - char buf[PROBE_SIZE]; - int len = stream_read(s, buf, sizeof(buf)); - if (len <= 0) - return -1; - if (!mp_probe_cue((struct bstr) { buf, len })) - return -1; - stream_seek(s, 0); + if (check >= DEMUX_CHECK_UNSAFE) { + char buf[PROBE_SIZE]; + int len = stream_read(s, buf, sizeof(buf)); + if (len <= 0) + return -1; + if (!mp_probe_cue((struct bstr) { buf, len })) + return -1; + stream_seek(s, 0); + } demuxer->file_contents = stream_read_complete(s, demuxer, 1000000); if (demuxer->file_contents.start == NULL) return -1; - if (!mp_probe_cue((struct bstr) { buf, len })) - return -1; return 0; } @@ -54,6 +54,5 @@ const struct demuxer_desc demuxer_desc_cue = { .author = "Uoti Urpala", .comment = "", .type = DEMUXER_TYPE_CUE, - .safe_check = true, - .check_file = try_open_file, // no separate .open + .open = try_open_file, }; -- cgit v1.2.3