summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-07-22 14:41:56 +0200
committerwm4 <wm4@nowhere>2013-07-22 14:41:56 +0200
commitf86b94f9b4623baa999961681e44b9a838834de5 (patch)
treee06a91d29b16b735d0235acaa56a59a14e522c4b /audio
parent0b160e125723baa42aa3e880945817e518946bd2 (diff)
downloadmpv-f86b94f9b4623baa999961681e44b9a838834de5.tar.bz2
mpv-f86b94f9b4623baa999961681e44b9a838834de5.tar.xz
audio/decode: remove macro crap
Declare decoders directly, instead of using the LIBAD_EXTERN macro. This is simpler (no weird magic) and more extensible.
Diffstat (limited to 'audio')
-rw-r--r--audio/decode/ad.c46
-rw-r--r--audio/decode/ad.h11
-rw-r--r--audio/decode/ad_internal.h48
-rw-r--r--audio/decode/ad_lavc.c17
-rw-r--r--audio/decode/ad_mpg123.c15
-rw-r--r--audio/decode/ad_spdif.c16
-rw-r--r--audio/decode/dec_audio.c23
7 files changed, 61 insertions, 115 deletions
diff --git a/audio/decode/ad.c b/audio/decode/ad.c
deleted file mode 100644
index 846cd146d1..0000000000
--- a/audio/decode/ad.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * audio decoder interface
- *
- * This file is part of MPlayer.
- *
- * MPlayer is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * MPlayer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "config.h"
-
-#include "stream/stream.h"
-#include "demux/demux.h"
-#include "demux/stheader.h"
-#include "ad.h"
-
-/* Missed vorbis, mad, dshow */
-
-extern const ad_functions_t mpcodecs_ad_mpg123;
-extern const ad_functions_t mpcodecs_ad_lavc;
-extern const ad_functions_t mpcodecs_ad_spdif;
-
-const ad_functions_t * const mpcodecs_ad_drivers[] =
-{
-#ifdef CONFIG_MPG123
- &mpcodecs_ad_mpg123,
-#endif
- &mpcodecs_ad_lavc,
- &mpcodecs_ad_spdif,
- NULL
-};
diff --git a/audio/decode/ad.h b/audio/decode/ad.h
index 1c8a211f5b..3b18c7e977 100644
--- a/audio/decode/ad.h
+++ b/audio/decode/ad.h
@@ -21,14 +21,14 @@
#include "core/codecs.h"
#include "demux/stheader.h"
+#include "demux/demux.h"
-typedef struct mp_codec_info ad_info_t;
+#include "audio/format.h"
struct mp_decoder_list;
/* interface of video decoder drivers */
-typedef struct ad_functions
-{
+struct ad_functions {
const char *name;
void (*add_decoders)(struct mp_decoder_list *list);
int (*preinit)(sh_audio_t *sh);
@@ -37,10 +37,7 @@ typedef struct ad_functions
int (*control)(sh_audio_t *sh, int cmd, void *arg);
int (*decode_audio)(sh_audio_t *sh, unsigned char *buffer, int minlen,
int maxlen);
-} ad_functions_t;
-
-// NULL terminated array of all drivers
-extern const ad_functions_t * const mpcodecs_ad_drivers[];
+};
#define ADCTRL_RESYNC_STREAM 1 // resync, called after seeking
diff --git a/audio/decode/ad_internal.h b/audio/decode/ad_internal.h
deleted file mode 100644
index 61bf306a5e..0000000000
--- a/audio/decode/ad_internal.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * This file is part of MPlayer.
- *
- * MPlayer is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * MPlayer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef MPLAYER_AD_INTERNAL_H
-#define MPLAYER_AD_INTERNAL_H
-
-#include "core/codecs.h"
-#include "audio/format.h"
-
-#include "stream/stream.h"
-#include "demux/demux.h"
-#include "demux/stheader.h"
-
-#include "ad.h"
-
-static void add_decoders(struct mp_decoder_list *list);
-static int init(sh_audio_t *sh, const char *decoder);
-static int preinit(sh_audio_t *sh);
-static void uninit(sh_audio_t *sh);
-static int control(sh_audio_t *sh, int cmd, void *arg);
-static int decode_audio(sh_audio_t *sh,unsigned char *buffer,int minlen,int maxlen);
-
-#define LIBAD_EXTERN(x) const ad_functions_t mpcodecs_ad_##x = {\
- #x, \
- add_decoders, \
- preinit,\
- init,\
- uninit,\
- control,\
- decode_audio\
-};
-
-#endif /* MPLAYER_AD_INTERNAL_H */
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c
index 96d176eaa0..da7c5aeaad 100644
--- a/audio/decode/ad_lavc.c
+++ b/audio/decode/ad_lavc.c
@@ -35,15 +35,13 @@
#include "core/options.h"
#include "core/av_opts.h"
-#include "ad_internal.h"
+#include "ad.h"
#include "audio/reorder_ch.h"
#include "audio/fmt-conversion.h"
#include "compat/mpbswap.h"
#include "compat/libav.h"
-LIBAD_EXTERN(lavc)
-
struct priv {
AVCodecContext *avctx;
AVFrame *avframe;
@@ -55,6 +53,9 @@ struct priv {
struct demux_packet *packet;
};
+static void uninit(sh_audio_t *sh);
+static int decode_audio(sh_audio_t *sh,unsigned char *buffer,int minlen,int maxlen);
+
#define OPT_BASE_STRUCT struct MPOpts
const m_option_t ad_lavc_decode_opts_conf[] = {
@@ -467,3 +468,13 @@ static void add_decoders(struct mp_decoder_list *list)
mp_add_decoder(list, "lavc", "pcm", "pcm", "Raw PCM");
mp_add_decoder(list, "lavc", "mp-pcm", "mp-pcm", "Raw PCM");
}
+
+const struct ad_functions ad_lavc = {
+ .name = "lavc",
+ .add_decoders = add_decoders,
+ .preinit = preinit,
+ .init = init,
+ .uninit = uninit,
+ .control = control,
+ .decode_audio = decode_audio,
+};
diff --git a/audio/decode/ad_mpg123.c b/audio/decode/ad_mpg123.c
index 8d97468e06..d8cc702234 100644
--- a/audio/decode/ad_mpg123.c
+++ b/audio/decode/ad_mpg123.c
@@ -24,9 +24,8 @@
#include "config.h"
-#include "ad_internal.h"
-
-LIBAD_EXTERN(mpg123)
+#include "ad.h"
+#include "core/mp_msg.h"
/* Reducing the ifdeffery to two main variants:
* 1. most compatible to any libmpg123 version
@@ -472,3 +471,13 @@ static void add_decoders(struct mp_decoder_list *list)
mp_add_decoder(list, "mpg123", "mp3", "mp3",
"High-performance decoder using libmpg123");
}
+
+const struct ad_functions ad_mpg123 = {
+ .name = "mpg123",
+ .add_decoders = add_decoders,
+ .preinit = preinit,
+ .init = init,
+ .uninit = uninit,
+ .control = control,
+ .decode_audio = decode_audio,
+};
diff --git a/audio/decode/ad_spdif.c b/audio/decode/ad_spdif.c
index d0fa43aa25..f3a6e3dd1f 100644
--- a/audio/decode/ad_spdif.c
+++ b/audio/decode/ad_spdif.c
@@ -28,9 +28,7 @@
#include "core/mp_msg.h"
#include "core/av_common.h"
#include "core/options.h"
-#include "ad_internal.h"
-
-LIBAD_EXTERN(spdif)
+#include "ad.h"
#define FILENAME_SPDIFENC "spdif"
#define OUTBUF_SIZE 65536
@@ -43,6 +41,8 @@ struct spdifContext {
uint8_t pb_buffer[OUTBUF_SIZE];
};
+static void uninit(sh_audio_t *sh);
+
static int read_packet(void *p, uint8_t *buf, int buf_size)
{
// spdifenc does not use read callback.
@@ -267,3 +267,13 @@ 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,
+ .decode_audio = decode_audio,
+};
diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c
index d6b57dd2b5..48a3512ee6 100644
--- a/audio/decode/dec_audio.c
+++ b/audio/decode/dec_audio.c
@@ -41,6 +41,19 @@
#include "audio/filter/af.h"
+extern const struct ad_functions ad_mpg123;
+extern const struct ad_functions ad_lavc;
+extern const struct ad_functions ad_spdif;
+
+static const struct ad_functions * const ad_drivers[] = {
+#ifdef CONFIG_MPG123
+ &ad_mpg123,
+#endif
+ &ad_lavc,
+ &ad_spdif,
+ NULL
+};
+
struct af_cfg af_cfg = {0}; // Configuration for audio filters
static int init_audio_codec(sh_audio_t *sh_audio, const char *decoder)
@@ -90,8 +103,8 @@ static int init_audio_codec(sh_audio_t *sh_audio, const char *decoder)
struct mp_decoder_list *mp_audio_decoder_list(void)
{
struct mp_decoder_list *list = talloc_zero(NULL, struct mp_decoder_list);
- for (int i = 0; mpcodecs_ad_drivers[i] != NULL; i++)
- mpcodecs_ad_drivers[i]->add_decoders(list);
+ for (int i = 0; ad_drivers[i] != NULL; i++)
+ ad_drivers[i]->add_decoders(list);
return list;
}
@@ -106,9 +119,9 @@ static struct mp_decoder_list *mp_select_audio_decoders(const char *codec,
static const struct ad_functions *find_driver(const char *name)
{
- for (int i = 0; mpcodecs_ad_drivers[i] != NULL; i++) {
- if (strcmp(mpcodecs_ad_drivers[i]->name, name) == 0)
- return mpcodecs_ad_drivers[i];
+ for (int i = 0; ad_drivers[i] != NULL; i++) {
+ if (strcmp(ad_drivers[i]->name, name) == 0)
+ return ad_drivers[i];
}
return NULL;
}