mirror of https://github.com/mpv-player/mpv
ao_oss: switch to new option API
This commit is contained in:
parent
5b91ba0a8d
commit
ecc5cb67f8
|
@ -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}
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue