This commit moves the remaining callbacks of stream/demux: pf_read/
pf_block/pf_seek/pf_readdir and pf_demux into their operations table,
aiming at unifying all the callbacks under a unique place.
This is a follow-up to the introduction of typed controls callbacks
for stream and demux.
Like for the typed controls callbacks if no operation is provided
(ie, stream_t/demux_t.ops is NULL) by a module, the legacy pf_* will be
used instead as a fallback.
The commit doesn't migrate any of modules yet.
This commit introduce a typed virtual table for operations on demux,
aiming at replacing the legacy pf_control() callback which is using
va_list. As a counterpart to the typed virtual table, typed methods
are also introduce.
The operations can be implemented by the modules directly right now
and will be used when possible. This is done to provide type safety
at every level.
When no operation is provided (ie, demux_t.ops is NULL) by a module
implementation, the legacy pf_control will be used instead as a
fallback.
The commit doesn't migrate any of modules yet.
We don't need to know it's a pointer and can save 2 characters.
No functional changes. This is simply renaming "dec->p_fmt_in",
"decoder->p_fmt_in", "dec.p_fmt_in" and "packetizer->p_fmt_in"
if in "any" mode and falling back to an extension based match, and if the
`asprintf()` call fails to create the extension based shortcut search
string, the consensus is that it should give up rather than proceed to try
an "any" based demux module load.
note that the `modbuf = NULL` statement was just resetting the undefined
state of the variable from the failed `asprintf()` call to ensure that the
later `free(modbuf)` was valid. it is not needed now that we go down the
error path.
note, the init of `s->psz_filepath` in `vlc_stream_CustomNew()` is not
strictly necessary to avoid `free()` on an initialised attribute, since
`calloc()` is actually involved in the object creation - much of the
initialisation done in `vlc_stream_CustomNew()` is actually redundant.
upon `asprintf()` failure, the pointer variable used to capture
the result is left in an undefined state.
here, should such failure occur, the later `free(modbuf)` call
would be invalid. we must reset this variable to null upon
failure to fix this.
note that `modbuf` is not the same variable as `module`, which
seems to be causing some confusion in review. this patch has
absolutely no impact upon the operation of this function other
than fixing the bug just described only. it **does not** cause
the module search to operate upon a null search string. it does
not change the search string at all.
note that `module` initially holds a search string owned by the
caller of the function. the function may though need to replace
this with a new string that it must allocate on the heap. for
the purposes of ensuring that the function later only releases
the new string, a copy of the allocated string pointer is kept
in the `modbuf` variable. in fact the string pointer in `module`
is only replaced with the newly allocated one upon success of
`asprintf()`. thus, should the allocation fail, `module` will
remain as `"any"` (the allocation only occurs under an `"any"`
based search). the patch thus does not alter the search string,
and thus does not impact module loading in any way.
The two fields of the union have types demux_t and stream_t, which are
the same type (demux_t is a typedef of stream_t).
Signed-off-by: Thomas Guillem <thomas@gllm.fr>
This makes the demux_Demux() function handle a demuxer plugin that
exposes a pf_readdir function, and invoke it if the demuxer does not
provide a pf_demux function.
There are two sets of file extension to demux module mapping:
- The "strong" set contains file extensions deemed reliable, either
because the demux probe is reasonably strict and safe, or because
the extension is rarely mismatched.
- The "quick" set contains file extensions that are not considered
reliable. This is essentially "mp3" which is supposedly (?) often
misused for non-MPGA (or non-raw ES) files.
The quick set cannot be used in normal parsing, as it could pick the
the wrong demuxer (that is to say, MPEG ES). It was introduced in the
original preparsing changeset, presumably to limit the overhead.
There are however no obvious reasons not to use the strong set for
preparsing. This patch does exactly that, and then removes duplicated
mappings for Ogg and WMA.
Objects have one strong reference held by their "owner", and zero or
more weak references generated by vlc_object_hold() et al. This
provides a separate function to remove the strong reference than
vlc_object_release() to remove weak ones.
With this sole change, this is really only an annotation though.
This adds a separate control for (re)setting selection to the default
program. This removes the semi-useless first variable argument to
DEMUX_SET_GROUP.