summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-07-21 23:52:40 +0200
committerwm4 <wm4@nowhere>2013-07-21 23:52:40 +0200
commitecc5cb67f8b7ace9897982aba45769656e92a3d8 (patch)
tree6bc2955bff6b68325e34fcd8a9a9746794b3fd7c
parent5b91ba0a8dd052d5d52309e439398f693d390b1b (diff)
downloadmpv-ecc5cb67f8b7ace9897982aba45769656e92a3d8.tar.bz2
mpv-ecc5cb67f8b7ace9897982aba45769656e92a3d8.tar.xz
ao_oss: switch to new option API
-rw-r--r--audio/out/ao_oss.c61
1 files changed, 30 insertions, 31 deletions
diff --git a/audio/out/ao_oss.c b/audio/out/ao_oss.c
index 6a46bd4db1..b50c3efe3a 100644
--- a/audio/out/ao_oss.c
+++ b/audio/out/ao_oss.c
@@ -51,17 +51,21 @@
#include "ao.h"
struct priv {
- char *dsp;
int audio_fd;
int prepause_space;
- const char *oss_mixer_device;
int oss_mixer_channel;
audio_buf_info zz;
int audio_delay_method;
int buffersize;
int outburst;
+
+ char *dsp;
+ char *oss_mixer_device;
+ char *cfg_oss_mixer_channel;
};
+static const char *mixer_channels[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_NAMES;
+
static int format_table[][2] = {
{AFMT_U8, AF_FORMAT_U8},
{AFMT_S8, AF_FORMAT_S8},
@@ -193,40 +197,16 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
// return: 0=success -1=fail
static int init(struct ao *ao, char *params)
{
- char *mixer_channels[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_NAMES;
+ struct priv *p = ao->priv;
int oss_format;
- char *mdev = PATH_DEV_MIXER;
- char *mchan = talloc_strdup(ao, mixer_channels[SOUND_MIXER_PCM]);
+
+ const char *mchan = NULL;
+ if (p->cfg_oss_mixer_channel && p->cfg_oss_mixer_channel[0])
+ mchan = p->cfg_oss_mixer_channel;
mp_msg(MSGT_AO, MSGL_V, "ao2: %d Hz %d chans %s\n", ao->samplerate,
ao->channels.num, af_fmt2str_short(ao->format));
- struct priv *p = talloc(ao, struct priv);
- *p = (struct priv) {
- .dsp = PATH_DEV_DSP,
- .audio_fd = -1,
- .audio_delay_method = 2,
- .buffersize = -1,
- .outburst = 512,
- };
- ao->priv = p;
-
- if (params) {
- char *m, *c;
- m = strchr(params, ':');
- if (m) {
- c = strchr(m + 1, ':');
- if (c) {
- mchan = c + 1;
- c[0] = '\0';
- }
- mdev = m + 1;
- m[0] = '\0';
- }
- p->dsp = talloc_strdup(ao, params);
- }
- p->oss_mixer_device = talloc_strdup(p, mdev);
-
if (mchan) {
int fd, devs, i;
@@ -570,6 +550,8 @@ static float get_delay(struct ao *ao)
return ((float)p->buffersize) / (float)ao->bps;
}
+#define OPT_BASE_STRUCT struct priv
+
const struct ao_driver audio_out_oss = {
.info = &(const struct ao_info) {
"OSS/ioctl audio output",
@@ -586,4 +568,21 @@ const struct ao_driver audio_out_oss = {
.pause = audio_pause,
.resume = audio_resume,
.reset = reset,
+ .priv_size = sizeof(struct priv),
+ .priv_defaults = &(const struct priv) {
+ .audio_fd = -1,
+ .audio_delay_method = 2,
+ .buffersize = -1,
+ .outburst = 512,
+ .oss_mixer_channel = SOUND_MIXER_PCM,
+
+ .dsp = PATH_DEV_DSP,
+ .oss_mixer_device = PATH_DEV_MIXER,
+ },
+ .options = (const struct m_option[]) {
+ OPT_STRING("device", dsp, 0),
+ OPT_STRING("mixer-device", oss_mixer_device, 0),
+ OPT_STRING("mixer-channel", cfg_oss_mixer_channel, 0),
+ {0}
+ },
};