summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-07-21 21:51:03 +0200
committerwm4 <wm4@nowhere>2013-07-21 23:27:31 +0200
commit38f81c618eb55b3e022c33482986b515e25be554 (patch)
tree45ae0ccc9203c5b14e415274a93680da342cd27b /audio
parent38f712d96d12b75deea192846f1969f28fb73f07 (diff)
downloadmpv-38f81c618eb55b3e022c33482986b515e25be554.tar.bz2
mpv-38f81c618eb55b3e022c33482986b515e25be554.tar.xz
ao_pcm: use new option API
Diffstat (limited to 'audio')
-rw-r--r--audio/out/ao_pcm.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/audio/out/ao_pcm.c b/audio/out/ao_pcm.c
index 7cceaad1cb..cbfe4d4640 100644
--- a/audio/out/ao_pcm.c
+++ b/audio/out/ao_pcm.c
@@ -28,7 +28,7 @@
#include "talloc.h"
-#include "core/subopt-helper.h"
+#include "core/m_option.h"
#include "audio/format.h"
#include "audio/reorder_ch.h"
#include "ao.h"
@@ -111,23 +111,11 @@ static void write_wave_header(struct ao *ao, FILE *fp, uint64_t data_length)
static int init(struct ao *ao, char *params)
{
- struct priv *priv = talloc_zero(ao, struct priv);
- ao->priv = priv;
-
- const opt_t subopts[] = {
- {"waveheader", OPT_ARG_BOOL, &priv->waveheader, NULL},
- {"file", OPT_ARG_MSTRZ, &priv->outputfilename, NULL},
- {NULL}
- };
- // set defaults
- priv->waveheader = 1;
-
- if (subopt_parse(params, subopts) != 0)
- return -1;
+ struct priv *priv = ao->priv;
if (!priv->outputfilename)
priv->outputfilename =
- strdup(priv->waveheader ? "audiodump.wav" : "audiodump.pcm");
+ talloc_strdup(priv, priv->waveheader ? "audiodump.wav" : "audiodump.pcm");
if (priv->waveheader) {
// WAV files must have one of the following formats
@@ -201,7 +189,6 @@ static void uninit(struct ao *ao, bool cut_audio)
}
}
fclose(priv->fp);
- free(priv->outputfilename);
}
static int get_space(struct ao *ao)
@@ -218,6 +205,8 @@ static int play(struct ao *ao, void *data, int len, int flags)
return len;
}
+#define OPT_BASE_STRUCT struct priv
+
const struct ao_driver audio_out_pcm = {
.info = &(const struct ao_info) {
"RAW PCM/WAVE file writer audio output",
@@ -229,4 +218,11 @@ const struct ao_driver audio_out_pcm = {
.uninit = uninit,
.get_space = get_space,
.play = play,
+ .priv_size = sizeof(struct priv),
+ .priv_defaults = &(const struct priv) { .waveheader = 1 },
+ .options = (const struct m_option[]) {
+ OPT_STRING("file", outputfilename, 0),
+ OPT_FLAG("waveheader", waveheader, 0),
+ {0}
+ },
};