aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends/pulseaudio.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-03-14 23:48:46 -0700
committerChris Robinson <[email protected]>2018-03-14 23:48:46 -0700
commit2011421e18442d7dd31dbb84135786dd8bf6a478 (patch)
tree41797f6e3d627117e223ddad71a412840316664b /Alc/backends/pulseaudio.c
parent7c0e68a33e1d25dfe4676f600c072e0f3edc2853 (diff)
Release the PulseAudio mainloop lock sooner
Diffstat (limited to 'Alc/backends/pulseaudio.c')
-rw-r--r--Alc/backends/pulseaudio.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/Alc/backends/pulseaudio.c b/Alc/backends/pulseaudio.c
index be785707..74d1a149 100644
--- a/Alc/backends/pulseaudio.c
+++ b/Alc/backends/pulseaudio.c
@@ -1164,13 +1164,16 @@ static void ALCpulsePlayback_stop(ALCpulsePlayback *self)
static ClockLatency ALCpulsePlayback_getClockLatency(ALCpulsePlayback *self)
{
- pa_usec_t latency = 0;
ClockLatency ret;
+ pa_usec_t latency;
int neg, err;
pa_threaded_mainloop_lock(self->loop);
ret.ClockTime = GetDeviceClockTime(STATIC_CAST(ALCbackend,self)->mDevice);
- if((err=pa_stream_get_latency(self->stream, &latency, &neg)) != 0)
+ err = pa_stream_get_latency(self->stream, &latency, &neg);
+ pa_threaded_mainloop_unlock(self->loop);
+
+ if(UNLIKELY(err != 0))
{
/* FIXME: if err = -PA_ERR_NODATA, it means we were called too soon
* after starting the stream and no timing info has been received from
@@ -1181,9 +1184,9 @@ static ClockLatency ALCpulsePlayback_getClockLatency(ALCpulsePlayback *self)
latency = 0;
neg = 0;
}
- if(neg) latency = 0;
- ret.Latency = minu64(latency, U64(0xffffffffffffffff)/1000) * 1000;
- pa_threaded_mainloop_unlock(self->loop);
+ else if(UNLIKELY(neg))
+ latency = 0;
+ ret.Latency = (ALint64)minu64(latency, U64(0x7fffffffffffffff)/1000) * 1000;
return ret;
}
@@ -1715,21 +1718,24 @@ static ALCuint ALCpulseCapture_availableSamples(ALCpulseCapture *self)
static ClockLatency ALCpulseCapture_getClockLatency(ALCpulseCapture *self)
{
- pa_usec_t latency = 0;
ClockLatency ret;
+ pa_usec_t latency;
int neg, err;
pa_threaded_mainloop_lock(self->loop);
ret.ClockTime = GetDeviceClockTime(STATIC_CAST(ALCbackend,self)->mDevice);
- if((err=pa_stream_get_latency(self->stream, &latency, &neg)) != 0)
+ err = pa_stream_get_latency(self->stream, &latency, &neg);
+ pa_threaded_mainloop_unlock(self->loop);
+
+ if(UNLIKELY(err != 0))
{
ERR("Failed to get stream latency: 0x%x\n", err);
latency = 0;
neg = 0;
}
- if(neg) latency = 0;
- ret.Latency = minu64(latency, U64(0xffffffffffffffff)/1000) * 1000;
- pa_threaded_mainloop_unlock(self->loop);
+ else if(UNLIKELY(neg))
+ latency = 0;
+ ret.Latency = (ALint64)minu64(latency, U64(0x7fffffffffffffff)/1000) * 1000;
return ret;
}