1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-22 06:42:03 +00:00

af: remove force option

Dangerous and misleading. If it turns out that this is actually needed
to make certain setups work right, it should be added back in a better
way (in a way it doesn't cause random crashes).
This commit is contained in:
wm4 2013-03-28 22:38:47 +01:00
parent bc268b313e
commit f9a6b1c3f8

View File

@ -421,37 +421,24 @@ int af_reinit(struct af_stream *s)
af = af->next; af = af->next;
break; break;
case AF_FALSE: { // Configuration filter is needed case AF_FALSE: { // Configuration filter is needed
// Do auto insertion only if force is not specified int progress = 0;
if ((AF_INIT_TYPE_MASK & s->cfg.force) != AF_INIT_FORCE) { if (af_fix_channels(s, &af, in) == AF_OK)
int progress = 0; progress = 1;
if (af_fix_channels(s, &af, in) == AF_OK) if (af_fix_format_conversion(s, &af, in) == AF_OK)
progress = 1; progress = 1;
if (af_fix_format_conversion(s, &af, in) == AF_OK) if (progress) {
progress = 1; retry++;
if (progress) { continue;
retry++;
continue;
}
goto negotiate_error;
} else {
mp_msg(
MSGT_AFILTER, MSGL_ERR,
"[libaf] Automatic filter insertion disabled "
"but formats do not match. Giving up.\n");
return AF_ERROR;
} }
break; goto negotiate_error;
} }
case AF_DETACH: { // Filter is redundant and wants to be unloaded case AF_DETACH: { // Filter is redundant and wants to be unloaded
// Do auto remove only if force is not specified struct af_instance *aft = af->prev;
if ((AF_INIT_TYPE_MASK & s->cfg.force) != AF_INIT_FORCE) { af_remove(s, af);
struct af_instance *aft = af->prev; if (aft)
af_remove(s, af); af = aft->next;
if (aft) else
af = aft->next; af = s->first; // Restart configuration
else
af = s->first; // Restart configuration
}
break; break;
} }
default: default:
@ -558,46 +545,44 @@ int af_init(struct af_stream *s)
return -1; return -1;
// Check output format // Check output format
if ((AF_INIT_TYPE_MASK & s->cfg.force) != AF_INIT_FORCE) { struct af_instance *af = NULL; // New filter
struct af_instance *af = NULL; // New filter // Check output frequency if not OK fix with resample
// Check output frequency if not OK fix with resample if (s->output.rate && s->last->data->rate != s->output.rate) {
if (s->output.rate && s->last->data->rate != s->output.rate) { // try to find a filter that can change samplrate
// try to find a filter that can change samplrate af = af_control_any_rev(s, AF_CONTROL_RESAMPLE_RATE | AF_CONTROL_SET,
af = af_control_any_rev(s, AF_CONTROL_RESAMPLE_RATE | AF_CONTROL_SET, &(s->output.rate));
&(s->output.rate)); if (!af) {
if (!af) { char *resampler = "lavrresample";
char *resampler = "lavrresample"; if ((AF_INIT_TYPE_MASK & s->cfg.force) == AF_INIT_SLOW) {
if ((AF_INIT_TYPE_MASK & s->cfg.force) == AF_INIT_SLOW) { if (af_is_conversion_filter(s->first))
if (af_is_conversion_filter(s->first)) af = af_append(s, s->first, resampler);
af = af_append(s, s->first, resampler); else
else af = af_prepend(s, s->first, resampler);
af = af_prepend(s, s->first, resampler); } else {
} else { if (af_is_conversion_filter(s->last))
if (af_is_conversion_filter(s->last)) af = af_prepend(s, s->last, resampler);
af = af_prepend(s, s->last, resampler); else
else af = af_append(s, s->last, resampler);
af = af_append(s, s->last, resampler);
}
// Init the new filter
if (!af)
return -1;
af->auto_inserted = true;
if (af->control(af, AF_CONTROL_RESAMPLE_RATE | AF_CONTROL_SET,
&(s->output.rate)) != AF_OK)
return -1;
} }
if (AF_OK != af_reinit(s)) // Init the new filter
if (!af)
return -1;
af->auto_inserted = true;
if (af->control(af, AF_CONTROL_RESAMPLE_RATE | AF_CONTROL_SET,
&(s->output.rate)) != AF_OK)
return -1; return -1;
} }
if (AF_OK != fixup_output_format(s)) { if (AF_OK != af_reinit(s))
// Something is stuffed audio out will not work
mp_msg(
MSGT_AFILTER, MSGL_ERR,
"[libaf] Unable to setup filter system can not"
" meet sound-card demands, please send a bug report. \n");
af_uninit(s);
return -1; return -1;
} }
if (AF_OK != fixup_output_format(s)) {
// Something is stuffed audio out will not work
mp_msg(
MSGT_AFILTER, MSGL_ERR,
"[libaf] Unable to setup filter system can not"
" meet sound-card demands, please send a bug report. \n");
af_uninit(s);
return -1;
} }
return 0; return 0;
} }