2009-01-26 15:06:44 +00:00
|
|
|
/*
|
|
|
|
* null audio output driver
|
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* This file is part of mpv.
|
2009-01-26 15:06:44 +00:00
|
|
|
*
|
audio/out: change license of some core files to LGPL
All contributors of the current code have agreed. ao.c requires a
"driver" entry for each audio output - we assume that if someone who
didn't agree to LGPL added a line, it's fine for ao.c to be LGPL
anyway. If the affected audio output is not disabled at compilation
time, the resulting binary will be GPL anyway, and ootherwise the
code is not included.
The audio output code itself was inspired or partially copied from
libao in 7a2eec4b59f4 (thus why MPlayer's audio code is named libao2).
Just to be sure we got permission from Aaron Holtzman, Jack Moffitt, and
Stan Seibert, who according to libao's SVN history and README are the
initial author. (Something similar was done for libvo, although the
commit relicensing it forgot to mention it.)
242aa6ebd40: anders mostly disagreed with the LGPL relicensing, but we
got permission for this particular commit.
0ef8e555735: nick could not be reached, but the include statement was
removed again anyway.
879e05a7c17: iive agreed to LGPL v3+ only, but this line of code was
removed anyway, so ao_null.c can be LGPL v2.1+.
9dd8f241ac2: patch author could not be reached, but the corresponding
code (old slave mode interface) was completely removed later.
2017-05-20 09:35:25 +00:00
|
|
|
* mpv is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2009-01-26 15:06:44 +00:00
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* mpv is distributed in the hope that it will be useful,
|
2009-01-26 15:06:44 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
audio/out: change license of some core files to LGPL
All contributors of the current code have agreed. ao.c requires a
"driver" entry for each audio output - we assume that if someone who
didn't agree to LGPL added a line, it's fine for ao.c to be LGPL
anyway. If the affected audio output is not disabled at compilation
time, the resulting binary will be GPL anyway, and ootherwise the
code is not included.
The audio output code itself was inspired or partially copied from
libao in 7a2eec4b59f4 (thus why MPlayer's audio code is named libao2).
Just to be sure we got permission from Aaron Holtzman, Jack Moffitt, and
Stan Seibert, who according to libao's SVN history and README are the
initial author. (Something similar was done for libvo, although the
commit relicensing it forgot to mention it.)
242aa6ebd40: anders mostly disagreed with the LGPL relicensing, but we
got permission for this particular commit.
0ef8e555735: nick could not be reached, but the include statement was
removed again anyway.
879e05a7c17: iive agreed to LGPL v3+ only, but this line of code was
removed anyway, so ao_null.c can be LGPL v2.1+.
9dd8f241ac2: patch author could not be reached, but the corresponding
code (old slave mode interface) was completely removed later.
2017-05-20 09:35:25 +00:00
|
|
|
* GNU Lesser General Public License for more details.
|
2009-01-26 15:06:44 +00:00
|
|
|
*
|
audio/out: change license of some core files to LGPL
All contributors of the current code have agreed. ao.c requires a
"driver" entry for each audio output - we assume that if someone who
didn't agree to LGPL added a line, it's fine for ao.c to be LGPL
anyway. If the affected audio output is not disabled at compilation
time, the resulting binary will be GPL anyway, and ootherwise the
code is not included.
The audio output code itself was inspired or partially copied from
libao in 7a2eec4b59f4 (thus why MPlayer's audio code is named libao2).
Just to be sure we got permission from Aaron Holtzman, Jack Moffitt, and
Stan Seibert, who according to libao's SVN history and README are the
initial author. (Something similar was done for libvo, although the
commit relicensing it forgot to mention it.)
242aa6ebd40: anders mostly disagreed with the LGPL relicensing, but we
got permission for this particular commit.
0ef8e555735: nick could not be reached, but the include statement was
removed again anyway.
879e05a7c17: iive agreed to LGPL v3+ only, but this line of code was
removed anyway, so ao_null.c can be LGPL v2.1+.
9dd8f241ac2: patch author could not be reached, but the corresponding
code (old slave mode interface) was completely removed later.
2017-05-20 09:35:25 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
2009-01-26 15:06:44 +00:00
|
|
|
*/
|
|
|
|
|
2013-11-17 15:08:39 +00:00
|
|
|
/*
|
|
|
|
* Note: this does much more than just ignoring audio output. It simulates
|
|
|
|
* (to some degree) an ideal AO.
|
|
|
|
*/
|
|
|
|
|
2001-06-02 23:25:43 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2015-01-30 20:30:54 +00:00
|
|
|
#include <math.h>
|
2011-05-04 14:03:55 +00:00
|
|
|
|
2016-01-11 18:03:40 +00:00
|
|
|
#include "mpv_talloc.h"
|
2001-06-02 23:25:43 +00:00
|
|
|
|
2011-05-04 14:03:55 +00:00
|
|
|
#include "osdep/timer.h"
|
2013-12-17 01:02:25 +00:00
|
|
|
#include "options/m_option.h"
|
2014-04-17 20:35:05 +00:00
|
|
|
#include "common/common.h"
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "common/msg.h"
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "audio/format.h"
|
|
|
|
#include "ao.h"
|
2014-03-07 14:24:32 +00:00
|
|
|
#include "internal.h"
|
2001-06-02 23:25:43 +00:00
|
|
|
|
2011-05-04 14:03:55 +00:00
|
|
|
struct priv {
|
2013-11-13 18:39:18 +00:00
|
|
|
bool paused;
|
2013-05-25 16:31:06 +00:00
|
|
|
double last_time;
|
2013-11-17 15:08:39 +00:00
|
|
|
float buffered; // samples
|
|
|
|
int buffersize; // samples
|
audio: redo internal AO API
This affects "pull" AOs only: ao_alsa, ao_pulse, ao_openal, ao_pcm,
ao_lavc. There are changes to the other AOs too, but that's only about
renaming ao_driver.resume to ao_driver.start.
ao_openal is broken because I didn't manage to fix it, so it exits with
an error message. If you want it, why don't _you_ put effort into it? I
see no reason to waste my own precious lifetime over this (I realize the
irony).
ao_alsa loses the poll() mechanism, but it was mostly broken and didn't
really do what it was supposed to. There doesn't seem to be anything in
the ALSA API to watch the playback status without polling (unless you
want to use raw UNIX signals).
No idea if ao_pulse is correct, or whether it's subtly broken now. There
is no documentation, so I can't tell what is correct, without reverse
engineering the whole project. I recommend using ALSA.
This was supposed to be just a simple fix, but somehow it expanded scope
like a train wreck. Very high chance of regressions, but probably only
for the AOs listed above. The rest you can figure out from reading the
diff.
2020-05-31 13:00:35 +00:00
|
|
|
bool playing;
|
2013-11-13 18:47:41 +00:00
|
|
|
|
2023-02-20 03:32:50 +00:00
|
|
|
bool untimed;
|
2013-11-17 15:08:39 +00:00
|
|
|
float bufferlen; // seconds
|
2014-03-07 14:24:49 +00:00
|
|
|
float speed; // multiplier
|
2014-05-04 14:54:47 +00:00
|
|
|
float latency_sec; // seconds
|
|
|
|
float latency; // samples
|
2023-02-20 03:32:50 +00:00
|
|
|
bool broken_eof;
|
|
|
|
bool broken_delay;
|
2013-11-17 15:08:39 +00:00
|
|
|
|
|
|
|
// Minimal unit of audio samples that can be written at once. If play() is
|
|
|
|
// called with sizes not aligned to this, a rounded size will be returned.
|
|
|
|
// (This is not needed by the AO API, but many AOs behave this way.)
|
|
|
|
int outburst; // samples
|
2015-04-27 21:18:54 +00:00
|
|
|
|
2016-08-05 10:23:42 +00:00
|
|
|
struct m_channels channel_layouts;
|
2018-01-29 05:08:52 +00:00
|
|
|
int format;
|
2001-06-02 23:25:43 +00:00
|
|
|
};
|
|
|
|
|
2011-05-04 14:03:55 +00:00
|
|
|
static void drain(struct ao *ao)
|
|
|
|
{
|
|
|
|
struct priv *priv = ao->priv;
|
2001-06-02 23:25:43 +00:00
|
|
|
|
2013-11-13 18:47:41 +00:00
|
|
|
if (ao->untimed) {
|
|
|
|
priv->buffered = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-11-13 18:39:18 +00:00
|
|
|
if (priv->paused)
|
|
|
|
return;
|
|
|
|
|
2013-05-25 16:31:06 +00:00
|
|
|
double now = mp_time_sec();
|
2013-11-17 15:08:39 +00:00
|
|
|
if (priv->buffered > 0) {
|
2014-03-07 14:24:49 +00:00
|
|
|
priv->buffered -= (now - priv->last_time) * ao->samplerate * priv->speed;
|
2020-06-02 18:30:59 +00:00
|
|
|
if (priv->buffered < 0)
|
2013-11-17 15:08:39 +00:00
|
|
|
priv->buffered = 0;
|
|
|
|
}
|
2011-05-04 14:03:55 +00:00
|
|
|
priv->last_time = now;
|
2001-06-02 23:25:43 +00:00
|
|
|
}
|
|
|
|
|
2013-07-22 20:57:51 +00:00
|
|
|
static int init(struct ao *ao)
|
2011-05-04 14:03:55 +00:00
|
|
|
{
|
2013-11-13 18:47:41 +00:00
|
|
|
struct priv *priv = ao->priv;
|
|
|
|
|
2018-01-29 05:08:52 +00:00
|
|
|
if (priv->format)
|
|
|
|
ao->format = priv->format;
|
|
|
|
|
2013-11-13 18:47:41 +00:00
|
|
|
ao->untimed = priv->untimed;
|
2013-05-09 16:06:26 +00:00
|
|
|
|
2015-04-27 21:18:54 +00:00
|
|
|
struct mp_chmap_sel sel = {.tmp = ao};
|
2016-08-05 10:23:42 +00:00
|
|
|
if (priv->channel_layouts.num_chmaps) {
|
|
|
|
for (int n = 0; n < priv->channel_layouts.num_chmaps; n++)
|
|
|
|
mp_chmap_sel_add_map(&sel, &priv->channel_layouts.chmaps[n]);
|
2015-04-27 21:18:54 +00:00
|
|
|
} else {
|
|
|
|
mp_chmap_sel_add_any(&sel);
|
|
|
|
}
|
2013-05-09 16:06:26 +00:00
|
|
|
if (!ao_chmap_sel_adjust(ao, &sel, &ao->channels))
|
2014-07-26 18:26:57 +00:00
|
|
|
mp_chmap_from_channels(&ao->channels, 2);
|
2013-05-09 16:06:26 +00:00
|
|
|
|
2014-05-04 14:54:47 +00:00
|
|
|
priv->latency = priv->latency_sec * ao->samplerate;
|
|
|
|
|
2013-11-17 15:08:39 +00:00
|
|
|
// A "buffer" for this many seconds of audio
|
|
|
|
int bursts = (int)(ao->samplerate * priv->bufferlen + 1) / priv->outburst;
|
2020-06-09 14:49:05 +00:00
|
|
|
ao->device_buffer = priv->outburst * bursts + priv->latency;
|
2013-11-10 22:38:41 +00:00
|
|
|
|
2013-05-25 16:31:06 +00:00
|
|
|
priv->last_time = mp_time_sec();
|
2011-05-04 14:03:55 +00:00
|
|
|
|
|
|
|
return 0;
|
2001-06-02 23:25:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// close audio device
|
2014-03-08 23:49:39 +00:00
|
|
|
static void uninit(struct ao *ao)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-01-12 19:33:44 +00:00
|
|
|
// stop playing and empty buffers (for seeking)
|
2011-05-04 14:03:55 +00:00
|
|
|
static void reset(struct ao *ao)
|
|
|
|
{
|
|
|
|
struct priv *priv = ao->priv;
|
2024-01-12 19:33:44 +00:00
|
|
|
priv->paused = false;
|
2013-11-10 22:38:41 +00:00
|
|
|
priv->buffered = 0;
|
audio: redo internal AO API
This affects "pull" AOs only: ao_alsa, ao_pulse, ao_openal, ao_pcm,
ao_lavc. There are changes to the other AOs too, but that's only about
renaming ao_driver.resume to ao_driver.start.
ao_openal is broken because I didn't manage to fix it, so it exits with
an error message. If you want it, why don't _you_ put effort into it? I
see no reason to waste my own precious lifetime over this (I realize the
irony).
ao_alsa loses the poll() mechanism, but it was mostly broken and didn't
really do what it was supposed to. There doesn't seem to be anything in
the ALSA API to watch the playback status without polling (unless you
want to use raw UNIX signals).
No idea if ao_pulse is correct, or whether it's subtly broken now. There
is no documentation, so I can't tell what is correct, without reverse
engineering the whole project. I recommend using ALSA.
This was supposed to be just a simple fix, but somehow it expanded scope
like a train wreck. Very high chance of regressions, but probably only
for the AOs listed above. The rest you can figure out from reading the
diff.
2020-05-31 13:00:35 +00:00
|
|
|
priv->playing = false;
|
2001-06-02 23:25:43 +00:00
|
|
|
}
|
|
|
|
|
audio: redo internal AO API
This affects "pull" AOs only: ao_alsa, ao_pulse, ao_openal, ao_pcm,
ao_lavc. There are changes to the other AOs too, but that's only about
renaming ao_driver.resume to ao_driver.start.
ao_openal is broken because I didn't manage to fix it, so it exits with
an error message. If you want it, why don't _you_ put effort into it? I
see no reason to waste my own precious lifetime over this (I realize the
irony).
ao_alsa loses the poll() mechanism, but it was mostly broken and didn't
really do what it was supposed to. There doesn't seem to be anything in
the ALSA API to watch the playback status without polling (unless you
want to use raw UNIX signals).
No idea if ao_pulse is correct, or whether it's subtly broken now. There
is no documentation, so I can't tell what is correct, without reverse
engineering the whole project. I recommend using ALSA.
This was supposed to be just a simple fix, but somehow it expanded scope
like a train wreck. Very high chance of regressions, but probably only
for the AOs listed above. The rest you can figure out from reading the
diff.
2020-05-31 13:00:35 +00:00
|
|
|
static void start(struct ao *ao)
|
2001-06-05 18:40:44 +00:00
|
|
|
{
|
2013-11-13 18:39:18 +00:00
|
|
|
struct priv *priv = ao->priv;
|
|
|
|
|
audio: redo internal AO API
This affects "pull" AOs only: ao_alsa, ao_pulse, ao_openal, ao_pcm,
ao_lavc. There are changes to the other AOs too, but that's only about
renaming ao_driver.resume to ao_driver.start.
ao_openal is broken because I didn't manage to fix it, so it exits with
an error message. If you want it, why don't _you_ put effort into it? I
see no reason to waste my own precious lifetime over this (I realize the
irony).
ao_alsa loses the poll() mechanism, but it was mostly broken and didn't
really do what it was supposed to. There doesn't seem to be anything in
the ALSA API to watch the playback status without polling (unless you
want to use raw UNIX signals).
No idea if ao_pulse is correct, or whether it's subtly broken now. There
is no documentation, so I can't tell what is correct, without reverse
engineering the whole project. I recommend using ALSA.
This was supposed to be just a simple fix, but somehow it expanded scope
like a train wreck. Very high chance of regressions, but probably only
for the AOs listed above. The rest you can figure out from reading the
diff.
2020-05-31 13:00:35 +00:00
|
|
|
if (priv->paused)
|
|
|
|
MP_ERR(ao, "illegal state: start() while paused\n");
|
2013-11-13 18:39:18 +00:00
|
|
|
|
|
|
|
drain(ao);
|
|
|
|
priv->paused = false;
|
|
|
|
priv->last_time = mp_time_sec();
|
audio: redo internal AO API
This affects "pull" AOs only: ao_alsa, ao_pulse, ao_openal, ao_pcm,
ao_lavc. There are changes to the other AOs too, but that's only about
renaming ao_driver.resume to ao_driver.start.
ao_openal is broken because I didn't manage to fix it, so it exits with
an error message. If you want it, why don't _you_ put effort into it? I
see no reason to waste my own precious lifetime over this (I realize the
irony).
ao_alsa loses the poll() mechanism, but it was mostly broken and didn't
really do what it was supposed to. There doesn't seem to be anything in
the ALSA API to watch the playback status without polling (unless you
want to use raw UNIX signals).
No idea if ao_pulse is correct, or whether it's subtly broken now. There
is no documentation, so I can't tell what is correct, without reverse
engineering the whole project. I recommend using ALSA.
This was supposed to be just a simple fix, but somehow it expanded scope
like a train wreck. Very high chance of regressions, but probably only
for the AOs listed above. The rest you can figure out from reading the
diff.
2020-05-31 13:00:35 +00:00
|
|
|
priv->playing = true;
|
2001-06-05 18:40:44 +00:00
|
|
|
}
|
|
|
|
|
audio: redo internal AO API
This affects "pull" AOs only: ao_alsa, ao_pulse, ao_openal, ao_pcm,
ao_lavc. There are changes to the other AOs too, but that's only about
renaming ao_driver.resume to ao_driver.start.
ao_openal is broken because I didn't manage to fix it, so it exits with
an error message. If you want it, why don't _you_ put effort into it? I
see no reason to waste my own precious lifetime over this (I realize the
irony).
ao_alsa loses the poll() mechanism, but it was mostly broken and didn't
really do what it was supposed to. There doesn't seem to be anything in
the ALSA API to watch the playback status without polling (unless you
want to use raw UNIX signals).
No idea if ao_pulse is correct, or whether it's subtly broken now. There
is no documentation, so I can't tell what is correct, without reverse
engineering the whole project. I recommend using ALSA.
This was supposed to be just a simple fix, but somehow it expanded scope
like a train wreck. Very high chance of regressions, but probably only
for the AOs listed above. The rest you can figure out from reading the
diff.
2020-05-31 13:00:35 +00:00
|
|
|
static bool set_pause(struct ao *ao, bool paused)
|
2011-05-04 14:03:55 +00:00
|
|
|
{
|
|
|
|
struct priv *priv = ao->priv;
|
2001-06-02 23:25:43 +00:00
|
|
|
|
audio: redo internal AO API
This affects "pull" AOs only: ao_alsa, ao_pulse, ao_openal, ao_pcm,
ao_lavc. There are changes to the other AOs too, but that's only about
renaming ao_driver.resume to ao_driver.start.
ao_openal is broken because I didn't manage to fix it, so it exits with
an error message. If you want it, why don't _you_ put effort into it? I
see no reason to waste my own precious lifetime over this (I realize the
irony).
ao_alsa loses the poll() mechanism, but it was mostly broken and didn't
really do what it was supposed to. There doesn't seem to be anything in
the ALSA API to watch the playback status without polling (unless you
want to use raw UNIX signals).
No idea if ao_pulse is correct, or whether it's subtly broken now. There
is no documentation, so I can't tell what is correct, without reverse
engineering the whole project. I recommend using ALSA.
This was supposed to be just a simple fix, but somehow it expanded scope
like a train wreck. Very high chance of regressions, but probably only
for the AOs listed above. The rest you can figure out from reading the
diff.
2020-05-31 13:00:35 +00:00
|
|
|
if (!priv->playing)
|
|
|
|
MP_ERR(ao, "illegal state: set_pause() while not playing\n");
|
|
|
|
|
|
|
|
if (priv->paused != paused) {
|
|
|
|
|
|
|
|
drain(ao);
|
|
|
|
priv->paused = paused;
|
|
|
|
if (!priv->paused)
|
|
|
|
priv->last_time = mp_time_sec();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2001-06-02 23:25:43 +00:00
|
|
|
}
|
|
|
|
|
audio: redo internal AO API
This affects "pull" AOs only: ao_alsa, ao_pulse, ao_openal, ao_pcm,
ao_lavc. There are changes to the other AOs too, but that's only about
renaming ao_driver.resume to ao_driver.start.
ao_openal is broken because I didn't manage to fix it, so it exits with
an error message. If you want it, why don't _you_ put effort into it? I
see no reason to waste my own precious lifetime over this (I realize the
irony).
ao_alsa loses the poll() mechanism, but it was mostly broken and didn't
really do what it was supposed to. There doesn't seem to be anything in
the ALSA API to watch the playback status without polling (unless you
want to use raw UNIX signals).
No idea if ao_pulse is correct, or whether it's subtly broken now. There
is no documentation, so I can't tell what is correct, without reverse
engineering the whole project. I recommend using ALSA.
This was supposed to be just a simple fix, but somehow it expanded scope
like a train wreck. Very high chance of regressions, but probably only
for the AOs listed above. The rest you can figure out from reading the
diff.
2020-05-31 13:00:35 +00:00
|
|
|
static bool audio_write(struct ao *ao, void **data, int samples)
|
2011-05-04 14:03:55 +00:00
|
|
|
{
|
|
|
|
struct priv *priv = ao->priv;
|
2013-11-17 15:08:39 +00:00
|
|
|
|
2014-04-17 20:35:05 +00:00
|
|
|
if (priv->buffered <= 0)
|
|
|
|
priv->buffered = priv->latency; // emulate fixed latency
|
|
|
|
|
audio: redo internal AO API
This affects "pull" AOs only: ao_alsa, ao_pulse, ao_openal, ao_pcm,
ao_lavc. There are changes to the other AOs too, but that's only about
renaming ao_driver.resume to ao_driver.start.
ao_openal is broken because I didn't manage to fix it, so it exits with
an error message. If you want it, why don't _you_ put effort into it? I
see no reason to waste my own precious lifetime over this (I realize the
irony).
ao_alsa loses the poll() mechanism, but it was mostly broken and didn't
really do what it was supposed to. There doesn't seem to be anything in
the ALSA API to watch the playback status without polling (unless you
want to use raw UNIX signals).
No idea if ao_pulse is correct, or whether it's subtly broken now. There
is no documentation, so I can't tell what is correct, without reverse
engineering the whole project. I recommend using ALSA.
This was supposed to be just a simple fix, but somehow it expanded scope
like a train wreck. Very high chance of regressions, but probably only
for the AOs listed above. The rest you can figure out from reading the
diff.
2020-05-31 13:00:35 +00:00
|
|
|
priv->buffered += samples;
|
|
|
|
return true;
|
2001-06-02 23:25:43 +00:00
|
|
|
}
|
|
|
|
|
audio: redo internal AO API
This affects "pull" AOs only: ao_alsa, ao_pulse, ao_openal, ao_pcm,
ao_lavc. There are changes to the other AOs too, but that's only about
renaming ao_driver.resume to ao_driver.start.
ao_openal is broken because I didn't manage to fix it, so it exits with
an error message. If you want it, why don't _you_ put effort into it? I
see no reason to waste my own precious lifetime over this (I realize the
irony).
ao_alsa loses the poll() mechanism, but it was mostly broken and didn't
really do what it was supposed to. There doesn't seem to be anything in
the ALSA API to watch the playback status without polling (unless you
want to use raw UNIX signals).
No idea if ao_pulse is correct, or whether it's subtly broken now. There
is no documentation, so I can't tell what is correct, without reverse
engineering the whole project. I recommend using ALSA.
This was supposed to be just a simple fix, but somehow it expanded scope
like a train wreck. Very high chance of regressions, but probably only
for the AOs listed above. The rest you can figure out from reading the
diff.
2020-05-31 13:00:35 +00:00
|
|
|
static void get_state(struct ao *ao, struct mp_pcm_state *state)
|
2011-05-04 14:03:55 +00:00
|
|
|
{
|
|
|
|
struct priv *priv = ao->priv;
|
2001-06-02 23:25:43 +00:00
|
|
|
|
2011-05-04 14:03:55 +00:00
|
|
|
drain(ao);
|
2014-03-07 14:24:49 +00:00
|
|
|
|
2020-06-09 14:49:05 +00:00
|
|
|
state->free_samples = ao->device_buffer - priv->latency - priv->buffered;
|
audio: redo internal AO API
This affects "pull" AOs only: ao_alsa, ao_pulse, ao_openal, ao_pcm,
ao_lavc. There are changes to the other AOs too, but that's only about
renaming ao_driver.resume to ao_driver.start.
ao_openal is broken because I didn't manage to fix it, so it exits with
an error message. If you want it, why don't _you_ put effort into it? I
see no reason to waste my own precious lifetime over this (I realize the
irony).
ao_alsa loses the poll() mechanism, but it was mostly broken and didn't
really do what it was supposed to. There doesn't seem to be anything in
the ALSA API to watch the playback status without polling (unless you
want to use raw UNIX signals).
No idea if ao_pulse is correct, or whether it's subtly broken now. There
is no documentation, so I can't tell what is correct, without reverse
engineering the whole project. I recommend using ALSA.
This was supposed to be just a simple fix, but somehow it expanded scope
like a train wreck. Very high chance of regressions, but probably only
for the AOs listed above. The rest you can figure out from reading the
diff.
2020-05-31 13:00:35 +00:00
|
|
|
state->free_samples = state->free_samples / priv->outburst * priv->outburst;
|
|
|
|
state->queued_samples = priv->buffered;
|
|
|
|
|
|
|
|
// Note how get_state returns the delay in audio device time (instead of
|
2014-03-07 14:24:49 +00:00
|
|
|
// adjusting for speed), since most AOs seem to also do that.
|
audio: redo internal AO API
This affects "pull" AOs only: ao_alsa, ao_pulse, ao_openal, ao_pcm,
ao_lavc. There are changes to the other AOs too, but that's only about
renaming ao_driver.resume to ao_driver.start.
ao_openal is broken because I didn't manage to fix it, so it exits with
an error message. If you want it, why don't _you_ put effort into it? I
see no reason to waste my own precious lifetime over this (I realize the
irony).
ao_alsa loses the poll() mechanism, but it was mostly broken and didn't
really do what it was supposed to. There doesn't seem to be anything in
the ALSA API to watch the playback status without polling (unless you
want to use raw UNIX signals).
No idea if ao_pulse is correct, or whether it's subtly broken now. There
is no documentation, so I can't tell what is correct, without reverse
engineering the whole project. I recommend using ALSA.
This was supposed to be just a simple fix, but somehow it expanded scope
like a train wreck. Very high chance of regressions, but probably only
for the AOs listed above. The rest you can figure out from reading the
diff.
2020-05-31 13:00:35 +00:00
|
|
|
state->delay = priv->buffered;
|
2014-04-17 20:35:05 +00:00
|
|
|
|
|
|
|
// Drivers with broken EOF handling usually always report the same device-
|
|
|
|
// level delay that is additional to the buffer time.
|
|
|
|
if (priv->broken_eof && priv->buffered < priv->latency)
|
audio: redo internal AO API
This affects "pull" AOs only: ao_alsa, ao_pulse, ao_openal, ao_pcm,
ao_lavc. There are changes to the other AOs too, but that's only about
renaming ao_driver.resume to ao_driver.start.
ao_openal is broken because I didn't manage to fix it, so it exits with
an error message. If you want it, why don't _you_ put effort into it? I
see no reason to waste my own precious lifetime over this (I realize the
irony).
ao_alsa loses the poll() mechanism, but it was mostly broken and didn't
really do what it was supposed to. There doesn't seem to be anything in
the ALSA API to watch the playback status without polling (unless you
want to use raw UNIX signals).
No idea if ao_pulse is correct, or whether it's subtly broken now. There
is no documentation, so I can't tell what is correct, without reverse
engineering the whole project. I recommend using ALSA.
This was supposed to be just a simple fix, but somehow it expanded scope
like a train wreck. Very high chance of regressions, but probably only
for the AOs listed above. The rest you can figure out from reading the
diff.
2020-05-31 13:00:35 +00:00
|
|
|
state->delay = priv->latency;
|
2014-04-17 20:35:05 +00:00
|
|
|
|
audio: redo internal AO API
This affects "pull" AOs only: ao_alsa, ao_pulse, ao_openal, ao_pcm,
ao_lavc. There are changes to the other AOs too, but that's only about
renaming ao_driver.resume to ao_driver.start.
ao_openal is broken because I didn't manage to fix it, so it exits with
an error message. If you want it, why don't _you_ put effort into it? I
see no reason to waste my own precious lifetime over this (I realize the
irony).
ao_alsa loses the poll() mechanism, but it was mostly broken and didn't
really do what it was supposed to. There doesn't seem to be anything in
the ALSA API to watch the playback status without polling (unless you
want to use raw UNIX signals).
No idea if ao_pulse is correct, or whether it's subtly broken now. There
is no documentation, so I can't tell what is correct, without reverse
engineering the whole project. I recommend using ALSA.
This was supposed to be just a simple fix, but somehow it expanded scope
like a train wreck. Very high chance of regressions, but probably only
for the AOs listed above. The rest you can figure out from reading the
diff.
2020-05-31 13:00:35 +00:00
|
|
|
state->delay /= ao->samplerate;
|
2015-01-30 20:30:54 +00:00
|
|
|
|
|
|
|
if (priv->broken_delay) { // Report only multiples of outburst
|
|
|
|
double q = priv->outburst / (double)ao->samplerate;
|
audio: redo internal AO API
This affects "pull" AOs only: ao_alsa, ao_pulse, ao_openal, ao_pcm,
ao_lavc. There are changes to the other AOs too, but that's only about
renaming ao_driver.resume to ao_driver.start.
ao_openal is broken because I didn't manage to fix it, so it exits with
an error message. If you want it, why don't _you_ put effort into it? I
see no reason to waste my own precious lifetime over this (I realize the
irony).
ao_alsa loses the poll() mechanism, but it was mostly broken and didn't
really do what it was supposed to. There doesn't seem to be anything in
the ALSA API to watch the playback status without polling (unless you
want to use raw UNIX signals).
No idea if ao_pulse is correct, or whether it's subtly broken now. There
is no documentation, so I can't tell what is correct, without reverse
engineering the whole project. I recommend using ALSA.
This was supposed to be just a simple fix, but somehow it expanded scope
like a train wreck. Very high chance of regressions, but probably only
for the AOs listed above. The rest you can figure out from reading the
diff.
2020-05-31 13:00:35 +00:00
|
|
|
if (state->delay > 0)
|
|
|
|
state->delay = (int)(state->delay / q) * q;
|
2015-01-30 20:30:54 +00:00
|
|
|
}
|
|
|
|
|
2020-06-02 18:30:59 +00:00
|
|
|
state->playing = priv->playing && priv->buffered > 0;
|
2001-06-02 23:25:43 +00:00
|
|
|
}
|
2011-05-04 14:03:55 +00:00
|
|
|
|
2013-11-13 18:47:41 +00:00
|
|
|
#define OPT_BASE_STRUCT struct priv
|
|
|
|
|
2011-05-04 14:03:55 +00:00
|
|
|
const struct ao_driver audio_out_null = {
|
2013-10-23 17:07:27 +00:00
|
|
|
.description = "Null audio output",
|
|
|
|
.name = "null",
|
2011-05-04 14:03:55 +00:00
|
|
|
.init = init,
|
|
|
|
.uninit = uninit,
|
|
|
|
.reset = reset,
|
audio: redo internal AO API
This affects "pull" AOs only: ao_alsa, ao_pulse, ao_openal, ao_pcm,
ao_lavc. There are changes to the other AOs too, but that's only about
renaming ao_driver.resume to ao_driver.start.
ao_openal is broken because I didn't manage to fix it, so it exits with
an error message. If you want it, why don't _you_ put effort into it? I
see no reason to waste my own precious lifetime over this (I realize the
irony).
ao_alsa loses the poll() mechanism, but it was mostly broken and didn't
really do what it was supposed to. There doesn't seem to be anything in
the ALSA API to watch the playback status without polling (unless you
want to use raw UNIX signals).
No idea if ao_pulse is correct, or whether it's subtly broken now. There
is no documentation, so I can't tell what is correct, without reverse
engineering the whole project. I recommend using ALSA.
This was supposed to be just a simple fix, but somehow it expanded scope
like a train wreck. Very high chance of regressions, but probably only
for the AOs listed above. The rest you can figure out from reading the
diff.
2020-05-31 13:00:35 +00:00
|
|
|
.get_state = get_state,
|
|
|
|
.set_pause = set_pause,
|
|
|
|
.write = audio_write,
|
|
|
|
.start = start,
|
2013-11-13 18:47:41 +00:00
|
|
|
.priv_size = sizeof(struct priv),
|
2013-11-17 15:08:39 +00:00
|
|
|
.priv_defaults = &(const struct priv) {
|
2013-11-19 21:14:23 +00:00
|
|
|
.bufferlen = 0.2,
|
2013-11-17 15:08:39 +00:00
|
|
|
.outburst = 256,
|
2014-03-07 14:24:49 +00:00
|
|
|
.speed = 1,
|
2013-11-17 15:08:39 +00:00
|
|
|
},
|
2013-11-13 18:47:41 +00:00
|
|
|
.options = (const struct m_option[]) {
|
2023-02-20 03:32:50 +00:00
|
|
|
{"untimed", OPT_BOOL(untimed)},
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
{"buffer", OPT_FLOAT(bufferlen), M_RANGE(0, 100)},
|
|
|
|
{"outburst", OPT_INT(outburst), M_RANGE(1, 100000)},
|
|
|
|
{"speed", OPT_FLOAT(speed), M_RANGE(0, 10000)},
|
|
|
|
{"latency", OPT_FLOAT(latency_sec), M_RANGE(0, 100)},
|
2023-02-20 03:32:50 +00:00
|
|
|
{"broken-eof", OPT_BOOL(broken_eof)},
|
|
|
|
{"broken-delay", OPT_BOOL(broken_delay)},
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
{"channel-layouts", OPT_CHANNELS(channel_layouts)},
|
|
|
|
{"format", OPT_AUDIOFORMAT(format)},
|
2013-11-13 18:47:41 +00:00
|
|
|
{0}
|
|
|
|
},
|
2016-11-25 20:00:39 +00:00
|
|
|
.options_prefix = "ao-null",
|
2011-05-04 14:03:55 +00:00
|
|
|
};
|