Prevent getting bad time values when pa_stream_get_time fails

Also makes sure that reported time won't go backwards
This commit is contained in:
Chris Robinson 2010-08-02 22:27:32 -07:00
parent ae41ad5d1e
commit 3bece35bbd

View File

@ -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;