summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/modules/alsa/alsa-sink.c6
-rw-r--r--src/modules/alsa/alsa-source.c4
-rw-r--r--src/pulse/stream.c2
-rw-r--r--src/pulsecore/time-smoother.c41
-rw-r--r--src/pulsecore/time-smoother.h2
5 files changed, 30 insertions, 25 deletions
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 46562cbd..7fc602be 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -899,9 +899,13 @@ static int unsuspend(struct userdata *u) {
if (build_pollfd(u) < 0)
goto fail;
+ u->write_count = 0;
+ pa_smoother_reset(u->smoother, pa_rtclock_now(), TRUE);
+
u->first = TRUE;
u->since_start = 0;
+
pa_log_info("Resumed successfully...");
return 0;
@@ -1204,7 +1208,7 @@ static int process_rewind(struct userdata *u) {
if (rewind_nbytes <= 0)
pa_log_info("Tried rewind, but was apparently not possible.");
else {
- u->write_count -= out_frames * u->frame_size;
+ u->write_count -= rewind_nbytes;
pa_log_debug("Rewound %lu bytes.", (unsigned long) rewind_nbytes);
pa_sink_process_rewind(u->sink, rewind_nbytes);
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index 8a1fbe5f..ed9c1480 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -854,7 +854,9 @@ static int unsuspend(struct userdata *u) {
/* FIXME: We need to reload the volume somehow */
snd_pcm_start(u->pcm_handle);
- pa_smoother_resume(u->smoother, pa_rtclock_now(), TRUE);
+
+ u->read_count = 0;
+ pa_smoother_reset(u->smoother, pa_rtclock_now(), TRUE);
pa_log_info("Resumed successfully...");
diff --git a/src/pulse/stream.c b/src/pulse/stream.c
index 5baf5c2c..a22816ae 100644
--- a/src/pulse/stream.c
+++ b/src/pulse/stream.c
@@ -827,7 +827,7 @@ static void create_stream_complete(pa_stream *s) {
if (s->flags & PA_STREAM_AUTO_TIMING_UPDATE) {
s->auto_timing_interval_usec = AUTO_TIMING_INTERVAL_START_USEC;
pa_assert(!s->auto_timing_update_event);
- s->auto_timing_update_event = pa_context_rttime_new(s->context, pa_rtclock_now() + s->auto_timing_interval_usec, &auto_timing_update_callback, s);
+ s->auto_timing_update_event = pa_context_rttime_new(s->context, pa_rtclock_now() + s->auto_timing_interval_usec, &auto_timing_update_callback, s);
request_auto_timing_update(s, TRUE);
}
diff --git a/src/pulsecore/time-smoother.c b/src/pulsecore/time-smoother.c
index 9d5a0705..1289f2b6 100644
--- a/src/pulsecore/time-smoother.c
+++ b/src/pulsecore/time-smoother.c
@@ -108,29 +108,11 @@ pa_smoother* pa_smoother_new(
s = pa_xnew(pa_smoother, 1);
s->adjust_time = adjust_time;
s->history_time = history_time;
- s->time_offset = 0;
+ s->min_history = min_history;
s->monotonic = monotonic;
-
- s->px = s->py = 0;
- s->dp = 1;
-
- s->ex = s->ey = s->ry = 0;
- s->de = 1;
-
- s->history_idx = 0;
- s->n_history = 0;
-
- s->last_y = s->last_x = 0;
-
- s->abc_valid = FALSE;
-
- s->paused = FALSE;
s->smoothing = smoothing;
- s->min_history = min_history;
-
- s->paused = paused;
- s->time_offset = s->pause_time = time_offset;
+ pa_smoother_reset(s, time_offset, paused);
return s;
}
@@ -514,9 +496,26 @@ pa_usec_t pa_smoother_translate(pa_smoother *s, pa_usec_t x, pa_usec_t y_delay)
return (pa_usec_t) llrint((double) y_delay / nde);
}
-void pa_smoother_reset(pa_smoother *s) {
+void pa_smoother_reset(pa_smoother *s, pa_usec_t time_offset, pa_bool_t paused) {
pa_assert(s);
+ s->px = s->py = 0;
+ s->dp = 1;
+
+ s->ex = s->ey = s->ry = 0;
+ s->de = 1;
+
+ s->history_idx = 0;
s->n_history = 0;
+
+ s->last_y = s->last_x = 0;
+
s->abc_valid = FALSE;
+
+ s->paused = paused;
+ s->time_offset = s->pause_time = time_offset;
+
+ /* #ifdef DEBUG_DATA */
+ pa_log_debug("reset()");
+/* #endif */
}
diff --git a/src/pulsecore/time-smoother.h b/src/pulsecore/time-smoother.h
index 5244a7e7..63d33e48 100644
--- a/src/pulsecore/time-smoother.h
+++ b/src/pulsecore/time-smoother.h
@@ -52,7 +52,7 @@ void pa_smoother_set_time_offset(pa_smoother *s, pa_usec_t x_offset);
void pa_smoother_pause(pa_smoother *s, pa_usec_t x);
void pa_smoother_resume(pa_smoother *s, pa_usec_t x, pa_bool_t abrupt);
-void pa_smoother_reset(pa_smoother *s);
+void pa_smoother_reset(pa_smoother *s, pa_usec_t time_offset, pa_bool_t paused);
void pa_smoother_fix_now(pa_smoother *s);