make sure we don't hit an assert when we issue two rewind requests in a

single iteration

Closes rhbz 472757.
This commit is contained in:
Lennart Poettering 2008-12-21 17:55:29 +01:00
parent 0cb0d683be
commit 9e4599820a

View file

@ -1147,7 +1147,8 @@ void pa_sink_input_request_rewind(pa_sink_input *i, size_t nbytes /* in our sam
* implementor. This implies 'flush' is TRUE. */ * implementor. This implies 'flush' is TRUE. */
pa_sink_input_assert_ref(i); pa_sink_input_assert_ref(i);
pa_assert(i->thread_info.rewrite_nbytes == 0);
nbytes = PA_MAX(i->thread_info.rewrite_nbytes, nbytes);
/* pa_log_debug("request rewrite %lu", (unsigned long) nbytes); */ /* pa_log_debug("request rewrite %lu", (unsigned long) nbytes); */
@ -1175,6 +1176,7 @@ void pa_sink_input_request_rewind(pa_sink_input *i, size_t nbytes /* in our sam
nbytes = pa_resampler_request(i->thread_info.resampler, nbytes); nbytes = pa_resampler_request(i->thread_info.resampler, nbytes);
} }
if (i->thread_info.rewrite_nbytes != (size_t) -1) {
if (rewrite) { if (rewrite) {
/* Make sure to not overwrite over underruns */ /* Make sure to not overwrite over underruns */
if (nbytes > i->thread_info.playing_for) if (nbytes > i->thread_info.playing_for)
@ -1183,8 +1185,13 @@ void pa_sink_input_request_rewind(pa_sink_input *i, size_t nbytes /* in our sam
i->thread_info.rewrite_nbytes = nbytes; i->thread_info.rewrite_nbytes = nbytes;
} else } else
i->thread_info.rewrite_nbytes = (size_t) -1; i->thread_info.rewrite_nbytes = (size_t) -1;
}
i->thread_info.rewrite_flush = flush && i->thread_info.rewrite_nbytes != 0; i->thread_info.rewrite_flush =
i->thread_info.rewrite_flush ||
(flush && i->thread_info.rewrite_nbytes != 0);
if (nbytes != (size_t) -1) {
/* Transform to sink domain */ /* Transform to sink domain */
if (i->thread_info.resampler) if (i->thread_info.resampler)
@ -1195,6 +1202,7 @@ void pa_sink_input_request_rewind(pa_sink_input *i, size_t nbytes /* in our sam
else else
/* This call will make sure process_rewind() is called later */ /* This call will make sure process_rewind() is called later */
pa_sink_request_rewind(i->sink, 0); pa_sink_request_rewind(i->sink, 0);
}
} }
/* Called from main context */ /* Called from main context */