aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-08-02 22:27:32 -0700
committerChris Robinson <[email protected]>2010-08-02 22:27:32 -0700
commit3bece35bbdd34d05bc06c59320f834a96dc53ef0 (patch)
tree933c82e50f0a5067df6fa6f44e10ae7bd8b5f5a9
parentae41ad5d1ed2c9b41cf5bbb7aa78848a043ee1f8 (diff)
Prevent getting bad time values when pa_stream_get_time fails
Also makes sure that reported time won't go backwards
-rw-r--r--Alc/pulseaudio.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/Alc/pulseaudio.c b/Alc/pulseaudio.c
index b5e6f4ab..44ae427a 100644
--- a/Alc/pulseaudio.c
+++ b/Alc/pulseaudio.c
@@ -138,6 +138,7 @@ typedef struct {
pa_threaded_mainloop *loop;
ALuint64 baseTime;
+ pa_usec_t lastTime;
ALvoid *thread;
volatile ALboolean killNow;
@@ -1004,8 +1005,10 @@ static void pulse_stop_playback(ALCdevice *device) //{{{
ppa_threaded_mainloop_lock(data->loop);
- if(ppa_stream_get_time(data->stream, &usec) != PA_ERR_NODATA)
- data->baseTime += usec*1000;
+ if(ppa_stream_get_time(data->stream, &usec) != PA_OK)
+ usec = data->lastTime;
+ data->baseTime += usec*1000;
+ data->lastTime = 0;
#if PA_CHECK_VERSION(0,9,15)
if(ppa_stream_set_buffer_attr_callback)
@@ -1241,8 +1244,10 @@ static ALuint64 pulse_get_time(ALCdevice *Device) //{{{
pa_usec_t usec;
ppa_threaded_mainloop_lock(data->loop);
- if(!data->stream || ppa_stream_get_time(data->stream, &usec) == PA_ERR_NODATA)
- usec = 0;
+ if(!data->stream || ppa_stream_get_time(data->stream, &usec) != PA_OK)
+ usec = data->lastTime;
+ else
+ data->lastTime = usec;
ppa_threaded_mainloop_unlock(data->loop);
return data->baseTime + usec*1000;