Make use of the smoother, just in case.

--- pulseaudio-0.9.16-test4/src/modules/module-solaris.c        Tue Aug 18 
16:36:05 2009
+++ pulseaudio-0.9.16-test4/src/modules/module-solaris.c        Tue Aug 18 
16:36:13 2009
@@ -60,6 +60,7 @@
 #include <pulsecore/thread-mq.h>
 #include <pulsecore/rtpoll.h>
 #include <pulsecore/thread.h>
+#include <pulsecore/time-smoother.h>

 #include "module-solaris-symdef.h"

@@ -110,6 +111,8 @@
     uint32_t prev_playback_samples, prev_record_samples;

     int32_t minimum_request;
+
+    pa_smoother *smoother;
 };

 static const char* const valid_modargs[] = {
@@ -145,7 +148,12 @@

     /* Handle wrap-around of the device's sample counter, which is a uint_32. 
*/
     if (u->prev_playback_samples > info.play.samples) {
-        /* Unfortunately info.play.samples can sometimes go backwards, even 
before it wraps! */
+        /*
+         * Unfortunately info.play.samples can sometimes go backwards, even 
before it wraps!
+ * The bug seems to be absent on Solaris x86 nv117 with audio810 driver, at least on this (UP) machine. + * The bug is present on a different (SMP) machine running Solaris x86 nv103 with audioens driver.
+         * An earlier revision of this file mentions the same bug 
independently (unknown configuration).
+         */
         if (u->prev_playback_samples + info.play.samples < 240000) {
             ++u->play_samples_msw;
         } else {
@@ -155,6 +163,8 @@
     u->prev_playback_samples = info.play.samples;
     played_bytes = (((uint64_t)u->play_samples_msw << 32) + info.play.samples) * 
u->frame_size;

+    pa_smoother_put(u->smoother, pa_rtclock_now(), pa_bytes_to_usec(played_bytes, 
&u->sink->sample_spec));
+
     return u->written_bytes - played_bytes;
 }

@@ -387,6 +397,8 @@

                     pa_assert(PA_SINK_IS_OPENED(u->sink->thread_info.state));

+                    pa_smoother_pause(u->smoother, pa_rtclock_now());
+
                     if (!u->source || u->source_suspended) {
                         if (suspend(u) < 0)
                             return -1;
@@ -398,6 +410,8 @@
                 case PA_SINK_RUNNING:

                     if (u->sink->thread_info.state == PA_SINK_SUSPENDED) {
+                        pa_smoother_resume(u->smoother, pa_rtclock_now(), 
TRUE);
+
                         if (!u->source || u->source_suspended) {
                             if (unsuspend(u) < 0)
                                 return -1;
@@ -606,11 +620,13 @@

     pa_thread_mq_install(&u->thread_mq);

+    pa_smoother_set_time_offset(u->smoother, pa_rtclock_now());
+
     for (;;) {
         /* Render some data and write it to the dsp */

         if (u->sink && PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
-            pa_usec_t xtime0;
+            pa_usec_t xtime0, ysleep_interval, xsleep_interval;
             uint64_t buffered_bytes;

             if (u->sink->thread_info.rewind_requested)
@@ -629,6 +645,8 @@
                 info.play.error = 0;
                 if (ioctl(u->fd, AUDIO_SETINFO, &info) < 0)
                     pa_log("AUDIO_SETINFO: %s", pa_cstrerror(errno));
+
+                pa_smoother_reset(u->smoother, pa_rtclock_now(), TRUE);
             }

             for (;;) {
@@ -691,7 +709,9 @@
                 }
             }

-            pa_rtpoll_set_timer_absolute(u->rtpoll, xtime0 + 
pa_bytes_to_usec(buffered_bytes / 2, &u->sink->sample_spec));
+            ysleep_interval = pa_bytes_to_usec(buffered_bytes / 2, 
&u->sink->sample_spec);
+            xsleep_interval = pa_smoother_translate(u->smoother, xtime0, 
ysleep_interval);
+            pa_rtpoll_set_timer_absolute(u->rtpoll, xtime0 + 
PA_MIN(xsleep_interval, ysleep_interval));
         } else
             pa_rtpoll_set_timer_disabled(u->rtpoll);

@@ -838,6 +858,9 @@

     u = pa_xnew0(struct userdata, 1);

+    if (!(u->smoother = pa_smoother_new(PA_USEC_PER_SEC, PA_USEC_PER_SEC * 2, 
TRUE, TRUE, 10, pa_rtclock_now(), TRUE)))
+        goto fail;
+
     /*
      * For a process (or several processes) to use the same audio device for 
both
      * record and playback at the same time, the device's mixer must be 
enabled.
@@ -1075,6 +1098,9 @@
     if (u->fd >= 0)
         close(u->fd);

+    if (u->smoother)
+        pa_smoother_free(u->smoother);
+
     pa_xfree(u->device_name);

     pa_xfree(u);
Only in pulseaudio-0.9.16-test4/src/modules: module-solaris.c.orig
_______________________________________________
pulseaudio-discuss mailing list
[email protected]
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss

Reply via email to