summaryrefslogtreecommitdiff
path: root/audio
diff options
context:
space:
mode:
authorJames Cowgill <jcowgill@debian.org>2018-10-03 09:34:10 +0100
committerJames Cowgill <jcowgill@debian.org>2018-10-03 09:34:10 +0100
commita6680ec06c4f17bb7b60c18ebd611ef40c5c6d68 (patch)
tree00780369c30413610781ace95a12b87fe7d79fe8 /audio
parentf4faf74f8747c113bd8c1f99e6b6fb1983f11e0d (diff)
New upstream version 0.29.1
Diffstat (limited to 'audio')
-rw-r--r--audio/filter/af_rubberband.c2
-rw-r--r--audio/format.c38
-rw-r--r--audio/format.h3
-rw-r--r--audio/out/ao_alsa.c18
-rw-r--r--audio/out/ao_jack.c3
-rw-r--r--audio/out/ao_openal.c14
-rw-r--r--audio/out/ao_pulse.c6
7 files changed, 36 insertions, 48 deletions
diff --git a/audio/filter/af_rubberband.c b/audio/filter/af_rubberband.c
index 6c8c773..c7b6317 100644
--- a/audio/filter/af_rubberband.c
+++ b/audio/filter/af_rubberband.c
@@ -167,6 +167,7 @@ static void process(struct mp_filter *f)
if (eof) {
mp_pin_in_write(f->ppins[1], MP_EOF_FRAME);
rubberband_reset(p->rubber);
+ p->rubber_delay = 0;
TA_FREEP(&p->pending);
p->sent_final = false;
return;
@@ -263,6 +264,7 @@ static void reset(struct mp_filter *f)
if (p->rubber)
rubberband_reset(p->rubber);
+ p->rubber_delay = 0;
p->sent_final = false;
TA_FREEP(&p->pending);
}
diff --git a/audio/format.c b/audio/format.c
index 8a13698..f56546a 100644
--- a/audio/format.c
+++ b/audio/format.c
@@ -55,12 +55,6 @@ bool af_fmt_is_int(int format)
return format && !af_fmt_is_spdif(format) && !af_fmt_is_float(format);
}
-// false for interleaved and AF_FORMAT_UNKNOWN
-bool af_fmt_is_planar(int format)
-{
- return format && af_fmt_to_planar(format) == format;
-}
-
bool af_fmt_is_spdif(int format)
{
return af_format_sample_alignment(format) > 1;
@@ -79,23 +73,30 @@ static const int planar_formats[][2] = {
{AF_FORMAT_DOUBLEP, AF_FORMAT_DOUBLE},
};
+bool af_fmt_is_planar(int format)
+{
+ for (int n = 0; n < MP_ARRAY_SIZE(planar_formats); n++) {
+ if (planar_formats[n][0] == format)
+ return true;
+ }
+ return false;
+}
+
// Return the planar format corresponding to the given format.
-// If the format is already planar, return it.
-// Return 0 if there's no equivalent.
+// If the format is already planar or if there's no equivalent,
+// return it.
int af_fmt_to_planar(int format)
{
for (int n = 0; n < MP_ARRAY_SIZE(planar_formats); n++) {
if (planar_formats[n][1] == format)
return planar_formats[n][0];
- if (planar_formats[n][0] == format)
- return format;
}
- return 0;
+ return format;
}
// Return the interleaved format corresponding to the given format.
-// If the format is already interleaved, return it.
-// Always succeeds if format is actually planar; otherwise return 0.
+// If the format is already interleaved or if there's no equivalent,
+// return it.
int af_fmt_from_planar(int format)
{
for (int n = 0; n < MP_ARRAY_SIZE(planar_formats); n++) {
@@ -134,17 +135,6 @@ const char *af_fmt_to_str(int format)
return "??";
}
-int af_fmt_seconds_to_bytes(int format, float seconds, int channels, int samplerate)
-{
- assert(!af_fmt_is_planar(format));
- int bps = af_fmt_to_bytes(format);
- int framelen = channels * bps;
- int bytes = seconds * bps * samplerate;
- if (bytes % framelen)
- bytes += framelen - (bytes % framelen);
- return bytes;
-}
-
void af_fill_silence(void *dst, size_t bytes, int format)
{
memset(dst, af_fmt_is_unsigned(format) ? 0x80 : 0, bytes);
diff --git a/audio/format.h b/audio/format.h
index 0afc656..24e1c54 100644
--- a/audio/format.h
+++ b/audio/format.h
@@ -64,9 +64,6 @@ bool af_fmt_is_pcm(int format);
int af_fmt_to_planar(int format);
int af_fmt_from_planar(int format);
-// Amount of bytes that contain audio of the given duration, aligned to frames.
-int af_fmt_seconds_to_bytes(int format, float seconds, int channels, int samplerate);
-
void af_fill_silence(void *dst, size_t bytes, int format);
void af_get_best_sample_formats(int src_format, int *out_formats);
diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c
index 32f08be..df78a67 100644
--- a/audio/out/ao_alsa.c
+++ b/audio/out/ao_alsa.c
@@ -940,12 +940,24 @@ static int get_space(struct ao *ao)
{
struct priv *p = ao->priv;
+ // in case of pausing or the device still being configured,
+ // just return our buffer size.
+ if (p->paused || snd_pcm_state(p->alsa) == SND_PCM_STATE_SETUP)
+ return p->buffersize;
+
snd_pcm_sframes_t space = snd_pcm_avail(p->alsa);
if (space < 0) {
- MP_ERR(ao, "Error received from snd_pcm_avail (%ld, %s)!\n",
- space, snd_strerror(space));
- if (space == -EPIPE) // EOF
+ if (space == -EPIPE) {
+ MP_WARN(ao, "ALSA XRUN hit, attempting to recover...\n");
+ int err = snd_pcm_prepare(p->alsa);
+ CHECK_ALSA_ERROR("Unable to recover from under/overrun!");
return p->buffersize;
+ }
+
+ MP_ERR(ao, "Error received from snd_pcm_avail "
+ "(%ld, %s with ALSA state %s)!\n",
+ space, snd_strerror(space),
+ snd_pcm_state_name(snd_pcm_state(p->alsa)));
// request a reload of the AO if device is not present,
// then error out.
diff --git a/audio/out/ao_jack.c b/audio/out/ao_jack.c
index b5413f7..0d5a2da 100644
--- a/audio/out/ao_jack.c
+++ b/audio/out/ao_jack.c
@@ -143,7 +143,8 @@ connect_to_outports(struct ao *ao)
if (!port_name)
port_flags |= JackPortIsPhysical;
- matching_ports = jack_get_ports(p->client, port_name, NULL, port_flags);
+ const char *port_type = JACK_DEFAULT_AUDIO_TYPE; // exclude MIDI ports
+ matching_ports = jack_get_ports(p->client, port_name, port_type, port_flags);
if (!matching_ports || !matching_ports[0]) {
MP_FATAL(ao, "no ports to connect to\n");
diff --git a/audio/out/ao_openal.c b/audio/out/ao_openal.c
index c1f405b..53571b6 100644
--- a/audio/out/ao_openal.c
+++ b/audio/out/ao_openal.c
@@ -24,19 +24,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
-
-#ifdef __APPLE__
-#ifndef AL_FORMAT_MONO_FLOAT32
-#define AL_FORMAT_MONO_FLOAT32 0x10010
-#endif
-#ifndef AL_FORMAT_STEREO_FLOAT32
-#define AL_FORMAT_STEREO_FLOAT32 0x10011
-#endif
-#ifndef AL_FORMAT_MONO_DOUBLE_EXT
-#define AL_FORMAT_MONO_DOUBLE_EXT 0x10012
-#endif
-#include <OpenAL/MacOSX_OALExtensions.h>
-#else
#ifdef OPENAL_AL_H
#include <OpenAL/alc.h>
#include <OpenAL/al.h>
@@ -46,7 +33,6 @@
#include <AL/al.h>
#include <AL/alext.h>
#endif
-#endif // __APPLE__
#include "common/msg.h"
diff --git a/audio/out/ao_pulse.c b/audio/out/ao_pulse.c
index ed45ba6..e288841 100644
--- a/audio/out/ao_pulse.c
+++ b/audio/out/ao_pulse.c
@@ -454,11 +454,11 @@ static int init(struct ao *ao)
pa_stream_set_write_callback(priv->stream, stream_request_cb, ao);
pa_stream_set_latency_update_callback(priv->stream,
stream_latency_update_cb, ao);
- int buf_size = af_fmt_seconds_to_bytes(ao->format, priv->cfg_buffer / 1000.0,
- ao->channels.num, ao->samplerate);
+ uint32_t buf_size = ao->samplerate * (priv->cfg_buffer / 1000.0) *
+ af_fmt_to_bytes(ao->format) * ao->channels.num;
pa_buffer_attr bufattr = {
.maxlength = -1,
- .tlength = buf_size > 0 ? buf_size : (uint32_t)-1,
+ .tlength = buf_size > 0 ? buf_size : -1,
.prebuf = -1,
.minreq = -1,
.fragsize = -1,