Commit c14d222d authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

aout: do not allow visualization in audio-filter and simplify

--audio-visual should be used instead. Using --audio-filter does not
play well with video output recycling.
parent f0e288ac
...@@ -42,22 +42,26 @@ ...@@ -42,22 +42,26 @@
#include <libvlc.h> #include <libvlc.h>
#include "aout_internal.h" #include "aout_internal.h"
static filter_t *FindFilter (vlc_object_t *obj, const char *type, static filter_t *CreateFilter (vlc_object_t *obj, const char *type,
const char *name, const char *name, bool force,
const audio_sample_format_t *infmt, const audio_sample_format_t *infmt,
const audio_sample_format_t *outfmt) const audio_sample_format_t *outfmt)
{ {
filter_t *filter = vlc_custom_create (obj, sizeof (*filter), type); filter_t *filter = vlc_custom_create (obj, sizeof (*filter), type);
if (unlikely(filter == NULL)) if (unlikely(filter == NULL))
return NULL; return NULL;
/*filter->p_owner not set here */
filter->fmt_in.audio = *infmt; filter->fmt_in.audio = *infmt;
filter->fmt_in.i_codec = infmt->i_format; filter->fmt_in.i_codec = infmt->i_format;
filter->fmt_out.audio = *outfmt; filter->fmt_out.audio = *outfmt;
filter->fmt_out.i_codec = outfmt->i_format; filter->fmt_out.i_codec = outfmt->i_format;
filter->p_module = module_need (filter, type, name, false); filter->p_module = module_need (filter, type, name, force);
if (filter->p_module == NULL) if (filter->p_module == NULL)
{ {
/* If probing failed, formats shall not have been modified. */
assert (AOUT_FMTS_IDENTICAL(&filter->fmt_in.audio, infmt));
assert (AOUT_FMTS_IDENTICAL(&filter->fmt_out.audio, outfmt));
vlc_object_release (filter); vlc_object_release (filter);
filter = NULL; filter = NULL;
} }
...@@ -70,15 +74,15 @@ static filter_t *FindConverter (vlc_object_t *obj, ...@@ -70,15 +74,15 @@ static filter_t *FindConverter (vlc_object_t *obj,
const audio_sample_format_t *infmt, const audio_sample_format_t *infmt,
const audio_sample_format_t *outfmt) const audio_sample_format_t *outfmt)
{ {
return FindFilter (obj, "audio converter", NULL, infmt, outfmt); return CreateFilter (obj, "audio converter", NULL, false, infmt, outfmt);
} }
static filter_t *FindResampler (vlc_object_t *obj, static filter_t *FindResampler (vlc_object_t *obj,
const audio_sample_format_t *infmt, const audio_sample_format_t *infmt,
const audio_sample_format_t *outfmt) const audio_sample_format_t *outfmt)
{ {
return FindFilter (obj, "audio resampler", "$audio-resampler", return CreateFilter (obj, "audio resampler", "$audio-resampler", false,
infmt, outfmt); infmt, outfmt);
} }
/** /**
...@@ -327,41 +331,42 @@ vout_thread_t *aout_filter_RequestVout (filter_t *filter, vout_thread_t *vout, ...@@ -327,41 +331,42 @@ vout_thread_t *aout_filter_RequestVout (filter_t *filter, vout_thread_t *vout,
owner->recycle_vout); owner->recycle_vout);
} }
static filter_t *CreateFilter (vlc_object_t *parent, const char *name, static int AppendFilter(vlc_object_t *obj, const char *type, const char *name,
const audio_sample_format_t *restrict infmt, filter_t **filters, unsigned *count,
const audio_sample_format_t *restrict outfmt, audio_sample_format_t *restrict infmt,
bool visu) const audio_sample_format_t *restrict outfmt)
{ {
filter_t *filter = vlc_custom_create (parent, sizeof (*filter), const unsigned max = AOUT_MAX_FILTERS;
"audio filter"); if (*count >= max)
if (unlikely(filter == NULL))
return NULL;
/*filter->p_owner = NOT NEEDED;*/
filter->fmt_in.i_codec = infmt->i_format;
filter->fmt_in.audio = *infmt;
filter->fmt_out.i_codec = outfmt->i_format;
filter->fmt_out.audio = *outfmt;
if (!visu)
{ {
filter->p_module = module_need (filter, "audio filter", name, true); msg_Err (obj, "maximum of %u filters reached", max);
if (filter->p_module != NULL) return -1;
return filter; }
/* If probing failed, formats shall not have been modified. */ filter_t *filter = CreateFilter (obj, type, name, true, infmt, outfmt);
assert (AOUT_FMTS_IDENTICAL(&filter->fmt_in.audio, infmt)); if (filter == NULL)
assert (AOUT_FMTS_IDENTICAL(&filter->fmt_out.audio, outfmt)); {
msg_Err (obj, "cannot add user %s \"%s\" (skipped)", type, name);
return -1;
} }
filter->p_module = module_need (filter, "visualization", name, true); /* convert to the filter input format if necessary */
if (filter->p_module != NULL) if (aout_FiltersPipelineCreate (filter, filters, count, max - 1, infmt,
return filter; &filter->fmt_in.audio))
{
msg_Err (filter, "cannot add user %s \"%s\" (skipped)", type, name);
module_unneed (filter, filter->p_module);
vlc_object_release (filter);
return -1;
}
vlc_object_release (filter); assert (*count < max);
return NULL; filters[(*count)++] = filter;
*infmt = filter->fmt_out.audio;
return 0;
} }
/** /**
* Sets up the audio filters. * Sets up the audio filters.
*/ */
...@@ -401,74 +406,38 @@ int aout_FiltersNew (audio_output_t *aout, ...@@ -401,74 +406,38 @@ int aout_FiltersNew (audio_output_t *aout,
return 0; return 0;
} }
const char *scaletempo = /* parse user filter lists */
var_InheritBool (aout, "audio-time-stretch") ? "scaletempo" : NULL; if (var_InheritBool (aout, "audio-time-stretch"))
char *filters = var_InheritString (aout, "audio-filter");
char *visual = var_InheritString (aout, "audio-visual");
if (visual != NULL && !strcasecmp (visual, "none"))
{ {
free (visual); if (AppendFilter(VLC_OBJECT(aout), "audio filter", "scaletempo",
visual = NULL; owner->filters, &owner->nb_filters,
&input_format, &output_format) == 0)
owner->rate_filter = owner->filters[owner->nb_filters - 1];
} }
owner->request_vout = *request_vout;
owner->recycle_vout = visual != NULL;
/* parse user filter lists */
const char *list[AOUT_MAX_FILTERS];
unsigned n = 0;
if (scaletempo != NULL) char *filters = var_InheritString (aout, "audio-filter");
list[n++] = scaletempo;
if (filters != NULL) if (filters != NULL)
{ {
char *p = filters, *name; char *p = filters, *name;
while ((name = strsep (&p, " :")) != NULL && n < AOUT_MAX_FILTERS) while ((name = strsep (&p, " :")) != NULL)
list[n++] = name;
}
if (visual != NULL && n < AOUT_MAX_FILTERS)
list[n++] = visual;
for (unsigned i = 0; i < n; i++)
{
const char *name = list[i];
if (owner->nb_filters >= AOUT_MAX_FILTERS)
{ {
msg_Err (aout, "maximum of %u filters reached", AOUT_MAX_FILTERS); AppendFilter(VLC_OBJECT(aout), "audio filter", name,
msg_Err (aout, "cannot add user filter %s (skipped)", name); owner->filters, &owner->nb_filters,
break; &input_format, &output_format);
} }
free (filters);
}
filter_t *filter = CreateFilter (VLC_OBJECT(aout), name, char *visual = var_InheritString (aout, "audio-visual");
&input_format, &output_format, owner->request_vout = *request_vout;
name == visual); owner->recycle_vout = visual != NULL;
if (filter == NULL) if (visual != NULL && strcasecmp (visual, "none"))
{ {
msg_Err (aout, "cannot add user filter %s (skipped)", name); AppendFilter(VLC_OBJECT(aout), "visualization", visual,
continue; owner->filters, &owner->nb_filters,
} &input_format, &output_format);
/* convert to the filter input format if necessary */
if (aout_FiltersPipelineCreate (aout, owner->filters,
&owner->nb_filters,
AOUT_MAX_FILTERS - 1,
&input_format, &filter->fmt_in.audio))
{
msg_Err (aout, "cannot add user filter %s (skipped)", name);
module_unneed (filter, filter->p_module);
vlc_object_release (filter);
continue;
}
assert (owner->nb_filters < AOUT_MAX_FILTERS);
owner->filters[owner->nb_filters++] = filter;
input_format = filter->fmt_out.audio;
if (name == scaletempo)
owner->rate_filter = filter;
} }
free (visual); free (visual);
free (filters);
/* convert to the output format (minus resampling) if necessary */ /* convert to the output format (minus resampling) if necessary */
output_format.i_rate = input_format.i_rate; output_format.i_rate = input_format.i_rate;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment