1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-25 08:12:17 +00:00

ao_alsa: simplify, remove no-block suboption

If no-block was given, the device would be opened with SND_PCM_NOBLOCK.
Also, after opening, blocking mode was unconditionally enabled anyway
with snd_pcm_nonblock(). Further, if opening with SND_PCM_NOBLOCK
failed, opening was retried without this flag.

This doesn't make any sense to me, and I've never heard of someone using
this suboption. I suspect it has to do with ancient ALSA bugs or API
caveats. Remove it and simplify the code.
This commit is contained in:
wm4 2014-12-05 01:23:09 +01:00
parent bc1b9aa984
commit d6606bcfff
2 changed files with 8 additions and 19 deletions

View File

@ -39,8 +39,6 @@ Available audio output drivers are:
``device=<device>``
Sets the device name. For ac3 output via S/PDIF, use an "iec958" or
"spdif" device, unless you really know how to set it correctly.
``no-block``
Sets noblock-mode.
``resample=yes``
Enable ALSA resampling plugin. (This is disabled by default, because
some drivers report incorrect audio delay in some cases.)

View File

@ -58,7 +58,6 @@ struct priv {
int buffersize; // in frames
int outburst; // in frames
int cfg_block;
char *cfg_device;
char *cfg_mixer_device;
char *cfg_mixer_name;
@ -405,7 +404,7 @@ static char *append_params(void *ta_parent, const char *device, const char *p)
abort();
}
static int try_open_device(struct ao *ao, const char *device, int open_mode)
static int try_open_device(struct ao *ao, const char *device)
{
struct priv *p = ao->priv;
@ -418,13 +417,13 @@ static int try_open_device(struct ao *ao, const char *device, int open_mode)
map_iec958_srate(ao->samplerate));
const char *ac3_device = append_params(tmp, device, params);
int err = snd_pcm_open
(&p->alsa, ac3_device, SND_PCM_STREAM_PLAYBACK, open_mode);
(&p->alsa, ac3_device, SND_PCM_STREAM_PLAYBACK, 0);
talloc_free(tmp);
if (!err)
return 0;
}
return snd_pcm_open(&p->alsa, device, SND_PCM_STREAM_PLAYBACK, open_mode);
return snd_pcm_open(&p->alsa, device, SND_PCM_STREAM_PLAYBACK, 0);
}
static void uninit(struct ao *ao)
@ -471,18 +470,12 @@ static int init(struct ao *ao)
MP_VERBOSE(ao, "using device: %s\n", device);
MP_VERBOSE(ao, "using ALSA version: %s\n", snd_asoundlib_version());
err = try_open_device(ao, device, p->cfg_block ? 0 : SND_PCM_NONBLOCK);
if (err < 0) {
if (err == -EBUSY && !user_set_device && strcmp(device, "default") != 0) {
MP_WARN(ao, "Device '%s' busy, retrying default.\n", device);
err = try_open_device(ao, "default", 0);
} else if (err != -EBUSY && !p->cfg_block) {
MP_WARN(ao, "Open in nonblock-mode "
"failed, trying to open in block-mode.\n");
err = try_open_device(ao, device, 0);
}
CHECK_ALSA_ERROR("Playback open error");
err = try_open_device(ao, device);
if (err == -EBUSY && !user_set_device && strcmp(device, "default") != 0) {
MP_WARN(ao, "Device '%s' busy, retrying default.\n", device);
err = try_open_device(ao, "default");
}
CHECK_ALSA_ERROR("Playback open error");
err = snd_pcm_nonblock(p->alsa, 0);
if (err < 0) {
@ -918,7 +911,6 @@ const struct ao_driver audio_out_alsa = {
.list_devs = list_devs,
.priv_size = sizeof(struct priv),
.priv_defaults = &(const struct priv) {
.cfg_block = 1,
.cfg_mixer_device = "default",
.cfg_mixer_name = "Master",
.cfg_mixer_index = 0,
@ -927,7 +919,6 @@ const struct ao_driver audio_out_alsa = {
.options = (const struct m_option[]) {
OPT_STRING("device", cfg_device, 0),
OPT_FLAG("resample", cfg_resample, 0),
OPT_FLAG("block", cfg_block, 0),
OPT_STRING("mixer-device", cfg_mixer_device, 0),
OPT_STRING("mixer-name", cfg_mixer_name, 0),
OPT_INTRANGE("mixer-index", cfg_mixer_index, 0, 0, 99),