summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-23 21:26:04 +0100
committerwm4 <wm4@nowhere>2013-11-23 21:26:04 +0100
commit9f4820f6ec1721dc73335cb64b5a5e63170bf379 (patch)
tree9e65f7438d444021a32997518b328654be8e0b46
parent0e84dafdf084c7d9da30ef7b0e0b2ca05da68157 (diff)
downloadmpv-9f4820f6ec1721dc73335cb64b5a5e63170bf379.tar.bz2
mpv-9f4820f6ec1721dc73335cb64b5a5e63170bf379.tar.xz
audio: remove ad_driver.preinit
This never had any real use. Get rid of dec_audio.initialized too, as it's redundant.
-rw-r--r--audio/decode/ad.h1
-rw-r--r--audio/decode/ad_lavc.c6
-rw-r--r--audio/decode/ad_mpg123.c4
-rw-r--r--audio/decode/ad_spdif.c6
-rw-r--r--audio/decode/dec_audio.c27
-rw-r--r--audio/decode/dec_audio.h3
6 files changed, 13 insertions, 34 deletions
diff --git a/audio/decode/ad.h b/audio/decode/ad.h
index ed9f4fff75..9a696fb630 100644
--- a/audio/decode/ad.h
+++ b/audio/decode/ad.h
@@ -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);
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c
index 8663d5fc32..5155faabc9 100644
--- a/audio/decode/ad_lavc.c
+++ b/audio/decode/ad_lavc.c
@@ -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,
diff --git a/audio/decode/ad_mpg123.c b/audio/decode/ad_mpg123.c
index 8f168ebb95..aacc1cb76b 100644
--- a/audio/decode/ad_mpg123.c
+++ b/audio/decode/ad_mpg123.c
@@ -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,
diff --git a/audio/decode/ad_spdif.c b/audio/decode/ad_spdif.c
index e0c0e88671..059022e5e3 100644
--- a/audio/decode/ad_spdif.c
+++ b/audio/decode/ad_spdif.c
@@ -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,
diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c
index 566bade875..aede793791 100644
--- a/audio/decode/dec_audio.c
+++ b/audio/decode/dec_audio.c
@@ -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);
}
diff --git a/audio/decode/dec_audio.h b/audio/decode/dec_audio.h
index be5fc44dfc..aac2bd4719 100644
--- a/audio/decode/dec_audio.h
+++ b/audio/decode/dec_audio.h
@@ -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;
};