summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_oss.c
diff options
context:
space:
mode:
authorrim <rozhuk.im@gmail.com>2023-02-12 19:22:47 +0200
committerDudemanguy <random342@airmail.cc>2023-05-11 01:53:55 +0000
commit5afc0da5304401d3f7f4d3e27402943b63f6cc71 (patch)
tree4caa93a5daf3152d02549b890e4aef40fd16c51c /audio/out/ao_oss.c
parent4502522a7aee093c923e79a65e4684ea2634af30 (diff)
downloadmpv-5afc0da5304401d3f7f4d3e27402943b63f6cc71.tar.bz2
mpv-5afc0da5304401d3f7f4d3e27402943b63f6cc71.tar.xz
ao_oss: return actual OSS playing state
fix: https://github.com/mpv-player/mpv/issues/10640
Diffstat (limited to 'audio/out/ao_oss.c')
-rw-r--r--audio/out/ao_oss.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/audio/out/ao_oss.c b/audio/out/ao_oss.c
index daa35da9d2..8d7dd63871 100644
--- a/audio/out/ao_oss.c
+++ b/audio/out/ao_oss.c
@@ -4,7 +4,7 @@
* Original author: A'rpi
* Support for >2 output channels added 2001-11-25
* - Steve Davies <steve@daviesfam.org>
- * Rozhuk Ivan <rozhuk.im@gmail.com> 2020
+ * Rozhuk Ivan <rozhuk.im@gmail.com> 2020-2023
*
* This file is part of mpv.
*
@@ -52,7 +52,6 @@
struct priv {
int dsp_fd;
- bool playing;
double bps; /* Bytes per second. */
};
@@ -240,7 +239,6 @@ static int init(struct ao *ao)
ao->samplerate = samplerate;
ao->channels = channels;
p->bps = (channels.num * samplerate * af_fmt_to_bytes(format));
- p->playing = false;
return 0;
@@ -260,7 +258,6 @@ static void uninit(struct ao *ao)
ioctl(p->dsp_fd, SNDCTL_DSP_HALT, NULL);
close(p->dsp_fd);
p->dsp_fd = -1;
- p->playing = false;
}
static int control(struct ao *ao, enum aocontrol cmd, void *arg)
@@ -298,7 +295,6 @@ static void reset(struct ao *ao)
int trig = 0;
/* Clear buf and do not start playback after data written. */
- p->playing = false;
if (ioctl(p->dsp_fd, SNDCTL_DSP_HALT, NULL) == -1 ||
ioctl(p->dsp_fd, SNDCTL_DSP_SETTRIGGER, &trig) == -1)
{
@@ -318,7 +314,6 @@ static void start(struct ao *ao)
MP_WARN_IOCTL_ERR(ao);
return;
}
- p->playing = true;
}
static bool audio_write(struct ao *ao, void **data, int samples)
@@ -335,13 +330,11 @@ static bool audio_write(struct ao *ao, void **data, int samples)
continue;
MP_WARN(ao, "audio_write: write() fail, err = %i: %s.\n",
errno, strerror(errno));
- p->playing = false;
return false;
}
if ((size_t)rc != size) {
MP_WARN(ao, "audio_write: unexpected partial write: required: %zu, written: %zu.\n",
size, (size_t)rc);
- p->playing = false;
return false;
}
@@ -358,7 +351,6 @@ static void get_state(struct ao *ao, struct mp_pcm_state *state)
ioctl(p->dsp_fd, SNDCTL_DSP_GETODELAY, &odelay) == -1)
{
MP_WARN_IOCTL_ERR(ao);
- p->playing = false;
memset(state, 0x00, sizeof(struct mp_pcm_state));
state->delay = 0.0;
return;
@@ -366,7 +358,7 @@ static void get_state(struct ao *ao, struct mp_pcm_state *state)
state->free_samples = (info.bytes / ao->sstride);
state->queued_samples = (ao->device_buffer - state->free_samples);
state->delay = (odelay / p->bps);
- state->playing = p->playing;
+ state->playing = (state->queued_samples != 0);
}
static void list_devs(struct ao *ao, struct ao_device_list *list)
@@ -404,6 +396,5 @@ const struct ao_driver audio_out_oss = {
.priv_size = sizeof(struct priv),
.priv_defaults = &(const struct priv) {
.dsp_fd = -1,
- .playing = false,
},
};