mirror of
https://github.com/mpv-player/mpv
synced 2025-01-24 00:23:27 +00:00
audio: remove ad_driver.preinit
This never had any real use. Get rid of dec_audio.initialized too, as it's redundant.
This commit is contained in:
parent
0e84dafdf0
commit
9f4820f6ec
@ -33,7 +33,6 @@ struct mp_decoder_list;
|
||||
struct ad_functions {
|
||||
const char *name;
|
||||
void (*add_decoders)(struct mp_decoder_list *list);
|
||||
int (*preinit)(struct dec_audio *da);
|
||||
int (*init)(struct dec_audio *da, const char *decoder);
|
||||
void (*uninit)(struct dec_audio *da);
|
||||
int (*control)(struct dec_audio *da, int cmd, void *arg);
|
||||
|
@ -128,11 +128,6 @@ static const char *find_pcm_decoder(const struct pcm_map *map, int format,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int preinit(struct dec_audio *da)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int setup_format(struct dec_audio *da)
|
||||
{
|
||||
struct priv *priv = da->priv;
|
||||
@ -404,7 +399,6 @@ static void add_decoders(struct mp_decoder_list *list)
|
||||
const struct ad_functions ad_lavc = {
|
||||
.name = "lavc",
|
||||
.add_decoders = add_decoders,
|
||||
.preinit = preinit,
|
||||
.init = init,
|
||||
.uninit = uninit,
|
||||
.control = control,
|
||||
|
@ -201,6 +201,9 @@ static int feed_new_packet(struct dec_audio *da)
|
||||
* erros in other places simply cannot occur. */
|
||||
static int init(struct dec_audio *da, const char *decoder)
|
||||
{
|
||||
if (!preinit(da))
|
||||
return 0;
|
||||
|
||||
struct ad_mpg123_context *con = da->priv;
|
||||
int ret;
|
||||
|
||||
@ -367,7 +370,6 @@ static void add_decoders(struct mp_decoder_list *list)
|
||||
const struct ad_functions ad_mpg123 = {
|
||||
.name = "mpg123",
|
||||
.add_decoders = add_decoders,
|
||||
.preinit = preinit,
|
||||
.init = init,
|
||||
.uninit = uninit,
|
||||
.control = control,
|
||||
|
@ -72,11 +72,6 @@ static void uninit(struct dec_audio *da)
|
||||
}
|
||||
}
|
||||
|
||||
static int preinit(struct dec_audio *da)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int init(struct dec_audio *da, const char *decoder)
|
||||
{
|
||||
struct spdifContext *spdif_ctx = talloc_zero(NULL, struct spdifContext);
|
||||
@ -254,7 +249,6 @@ static void add_decoders(struct mp_decoder_list *list)
|
||||
const struct ad_functions ad_spdif = {
|
||||
.name = "spdif",
|
||||
.add_decoders = add_decoders,
|
||||
.preinit = preinit,
|
||||
.init = init,
|
||||
.uninit = uninit,
|
||||
.control = control,
|
||||
|
@ -72,32 +72,24 @@ static void reinit_audio_buffer(struct dec_audio *da)
|
||||
|
||||
static void uninit_decoder(struct dec_audio *d_audio)
|
||||
{
|
||||
if (d_audio->initialized) {
|
||||
if (d_audio->ad_driver) {
|
||||
mp_tmsg(MSGT_DECAUDIO, MSGL_V, "Uninit audio decoder.\n");
|
||||
d_audio->ad_driver->uninit(d_audio);
|
||||
d_audio->initialized = 0;
|
||||
}
|
||||
d_audio->ad_driver = NULL;
|
||||
talloc_free(d_audio->priv);
|
||||
d_audio->priv = NULL;
|
||||
}
|
||||
|
||||
static int init_audio_codec(struct dec_audio *d_audio, const char *decoder)
|
||||
{
|
||||
assert(!d_audio->initialized);
|
||||
audio_resync_stream(d_audio);
|
||||
if (!d_audio->ad_driver->preinit(d_audio)) {
|
||||
mp_tmsg(MSGT_DECAUDIO, MSGL_ERR, "Audio decoder preinit failed.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!d_audio->ad_driver->init(d_audio, decoder)) {
|
||||
mp_tmsg(MSGT_DECAUDIO, MSGL_V, "Audio decoder init failed.\n");
|
||||
d_audio->ad_driver = NULL;
|
||||
uninit_decoder(d_audio);
|
||||
return 0;
|
||||
}
|
||||
|
||||
d_audio->initialized = 1;
|
||||
|
||||
if (!d_audio->decoded.channels.num || !d_audio->decoded.rate ||
|
||||
!d_audio->decoded.format)
|
||||
{
|
||||
@ -141,7 +133,8 @@ static const struct ad_functions *find_driver(const char *name)
|
||||
|
||||
int audio_init_best_codec(struct dec_audio *d_audio, char *audio_decoders)
|
||||
{
|
||||
assert(!d_audio->initialized);
|
||||
assert(!d_audio->ad_driver);
|
||||
audio_resync_stream(d_audio);
|
||||
|
||||
struct mp_decoder_entry *decoder = NULL;
|
||||
struct mp_decoder_list *list =
|
||||
@ -161,12 +154,11 @@ int audio_init_best_codec(struct dec_audio *d_audio, char *audio_decoders)
|
||||
decoder = sel;
|
||||
break;
|
||||
}
|
||||
d_audio->ad_driver = NULL;
|
||||
mp_tmsg(MSGT_DECAUDIO, MSGL_WARN, "Audio decoder init failed for "
|
||||
"%s:%s\n", sel->family, sel->decoder);
|
||||
}
|
||||
|
||||
if (d_audio->initialized) {
|
||||
if (d_audio->ad_driver) {
|
||||
d_audio->decoder_desc =
|
||||
talloc_asprintf(d_audio, "%s [%s:%s]", decoder->desc, decoder->family,
|
||||
decoder->decoder);
|
||||
@ -187,7 +179,7 @@ int audio_init_best_codec(struct dec_audio *d_audio, char *audio_decoders)
|
||||
}
|
||||
|
||||
talloc_free(list);
|
||||
return d_audio->initialized;
|
||||
return !!d_audio->ad_driver;
|
||||
}
|
||||
|
||||
void audio_uninit(struct dec_audio *d_audio)
|
||||
@ -356,7 +348,6 @@ void audio_resync_stream(struct dec_audio *d_audio)
|
||||
{
|
||||
d_audio->pts = MP_NOPTS_VALUE;
|
||||
d_audio->pts_offset = 0;
|
||||
if (!d_audio->initialized)
|
||||
return;
|
||||
d_audio->ad_driver->control(d_audio, ADCTRL_RESYNC_STREAM, NULL);
|
||||
if (d_audio->ad_driver)
|
||||
d_audio->ad_driver->control(d_audio, ADCTRL_RESYNC_STREAM, NULL);
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ struct dec_audio {
|
||||
struct sh_stream *header;
|
||||
struct mp_audio_buffer *decode_buffer;
|
||||
struct af_stream *afilter;
|
||||
int initialized;
|
||||
char *decoder_desc;
|
||||
// set by decoder
|
||||
struct mp_audio decoded; // format of decoded audio (no data, temporarily
|
||||
@ -43,7 +42,7 @@ struct dec_audio {
|
||||
double pts;
|
||||
// number of samples output by decoder after last known pts
|
||||
int pts_offset;
|
||||
// For free use by the decoder
|
||||
// For free use by the ad_driver
|
||||
void *priv;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user