mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
audio/filter: use new option API
Make the VF/VO/AO option parser available to audio filters. No audio filter uses this yet, but it's still a quite intrusive change. In particular, the commands for manipulating filters at runtime completely change. We delete the old code, and use the same infrastructure as for video filters. (This forces complete reinitialization of the filter chain, which hopefully isn't a problem for any use cases. The old code forced reinitialization too, but it could potentially allow a filter to cache things; e.g. consider loaded ladspa plugins and such.)
This commit is contained in:
@@ -54,8 +54,6 @@ static const struct ad_functions * const ad_drivers[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
struct af_cfg af_cfg = {0}; // Configuration for audio filters
|
||||
|
||||
static int init_audio_codec(sh_audio_t *sh_audio, const char *decoder)
|
||||
{
|
||||
assert(!sh_audio->initialized);
|
||||
@@ -180,7 +178,6 @@ void uninit_audio(sh_audio_t *sh_audio)
|
||||
{
|
||||
if (sh_audio->afilter) {
|
||||
mp_msg(MSGT_DECAUDIO, MSGL_V, "Uninit audio filters...\n");
|
||||
af_uninit(sh_audio->afilter);
|
||||
af_destroy(sh_audio->afilter);
|
||||
sh_audio->afilter = NULL;
|
||||
}
|
||||
@@ -199,9 +196,10 @@ int init_audio_filters(sh_audio_t *sh_audio, int in_samplerate,
|
||||
int *out_samplerate, struct mp_chmap *out_channels,
|
||||
int *out_format)
|
||||
{
|
||||
if (!sh_audio->afilter)
|
||||
sh_audio->afilter = af_new(sh_audio->opts);
|
||||
struct af_stream *afs = sh_audio->afilter;
|
||||
if (!afs)
|
||||
afs = af_new(sh_audio->opts);
|
||||
|
||||
// input format: same as codec's output format:
|
||||
afs->input.rate = in_samplerate;
|
||||
mp_audio_set_channels(&afs->input, &sh_audio->channels);
|
||||
@@ -212,9 +210,6 @@ int init_audio_filters(sh_audio_t *sh_audio, int in_samplerate,
|
||||
mp_audio_set_channels(&afs->output, out_channels);
|
||||
mp_audio_set_format(&afs->output, *out_format);
|
||||
|
||||
// filter config:
|
||||
memcpy(&afs->cfg, &af_cfg, sizeof(struct af_cfg));
|
||||
|
||||
char *s_from = mp_audio_config_to_str(&afs->input);
|
||||
char *s_to = mp_audio_config_to_str(&afs->output);
|
||||
mp_tmsg(MSGT_DECAUDIO, MSGL_V,
|
||||
@@ -223,9 +218,9 @@ int init_audio_filters(sh_audio_t *sh_audio, int in_samplerate,
|
||||
talloc_free(s_to);
|
||||
|
||||
// let's autoprobe it!
|
||||
if (0 != af_init(afs)) {
|
||||
sh_audio->afilter = NULL;
|
||||
if (af_init(afs) != 0) {
|
||||
af_destroy(afs);
|
||||
sh_audio->afilter = NULL;
|
||||
return 0; // failed :(
|
||||
}
|
||||
|
||||
@@ -233,8 +228,6 @@ int init_audio_filters(sh_audio_t *sh_audio, int in_samplerate,
|
||||
*out_channels = afs->output.channels;
|
||||
*out_format = afs->output.format;
|
||||
|
||||
// ok!
|
||||
sh_audio->afilter = (void *) afs;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,4 @@ int init_audio_filters(sh_audio_t *sh_audio, int in_samplerate,
|
||||
int *out_samplerate, struct mp_chmap *out_channels,
|
||||
int *out_format);
|
||||
|
||||
extern struct af_cfg af_cfg;
|
||||
|
||||
#endif /* MPLAYER_DEC_AUDIO_H */
|
||||
|
||||
Reference in New Issue
Block a user