[pulseaudio-discuss] [PATCH] Solaris: debug my latest enbugging, take 2

2009-08-24 Thread Finn Thain

Prevent partially played memchunks from getting lost.
If the sink has a memblock, don't leak it when rewinding.

diff --git a/src/modules/module-solaris.c b/src/modules/module-solaris.c
index 71f1407..a3b69b7 100644
--- a/src/modules/module-solaris.c
+++ b/src/modules/module-solaris.c
@@ -600,6 +600,10 @@ static void process_rewind(struct userdata *u) {
 pa_log_debug("Requested to rewind %lu bytes.", (unsigned long) 
rewind_nbytes);
 rewind_nbytes = PA_MIN(u->memchunk.length, rewind_nbytes);
 u->memchunk.length -= rewind_nbytes;
+if (u->memchunk.length <= 0 && u->memchunk.memblock) {
+pa_memblock_unref(u->memchunk.memblock);
+pa_memchunk_reset(&u->memchunk);
+}
 pa_log_debug("Rewound %lu bytes.", (unsigned long) rewind_nbytes);
 }
 
@@ -671,8 +675,8 @@ static void thread_func(void *userdata) {
 if (len < (size_t) u->minimum_request)
 break;
 
-if (u->memchunk.length < len)
-pa_sink_render(u->sink, len - u->memchunk.length, 
&u->memchunk);
+if (!u->memchunk.length)
+pa_sink_render(u->sink, u->sink->thread_info.max_request, 
&u->memchunk);
 
 len = PA_MIN(u->memchunk.length, len);
 
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] Solaris: debug my latest enbugging

2009-08-23 Thread Finn Thain

On Sun, 23 Aug 2009, I wrote:

>  pa_log_debug("Requested to rewind %lu bytes.", (unsigned long) 
> rewind_nbytes);
>  rewind_nbytes = PA_MIN(u->memchunk.length, rewind_nbytes);
>  u->memchunk.length -= rewind_nbytes;
> +if (!u->memchunk.length)
> +pa_memblock_unref(u->memchunk.memblock);

This patch is still wrong, so I'll send it again (sometimes it tries to 
unref a null memblock). Sorry for the noise.

Finn
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH] Solaris: debug my latest enbugging

2009-08-22 Thread Finn Thain

Stop the sink memblock leaking upon rewind. Prevent partially played 
memchunks from getting lost.


diff --git a/src/modules/module-solaris.c b/src/modules/module-solaris.c
index 71f1407..a3b69b7 100644
--- a/src/modules/module-solaris.c
+++ b/src/modules/module-solaris.c
@@ -600,6 +600,8 @@ static void process_rewind(struct userdata *u) {
 pa_log_debug("Requested to rewind %lu bytes.", (unsigned long) 
rewind_nbytes);
 rewind_nbytes = PA_MIN(u->memchunk.length, rewind_nbytes);
 u->memchunk.length -= rewind_nbytes;
+if (!u->memchunk.length)
+pa_memblock_unref(u->memchunk.memblock);
 pa_log_debug("Rewound %lu bytes.", (unsigned long) rewind_nbytes);
 }
 
@@ -671,8 +673,8 @@ static void thread_func(void *userdata) {
 if (len < (size_t) u->minimum_request)
 break;
 
-if (u->memchunk.length < len)
-pa_sink_render(u->sink, len - u->memchunk.length, 
&u->memchunk);
+if (!u->memchunk.length)
+pa_sink_render(u->sink, u->sink->thread_info.max_request, 
&u->memchunk);
 
 len = PA_MIN(u->memchunk.length, len);
 
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH 1/4] Solaris: bootstrap portability

2009-08-21 Thread Finn Thain


On Fri, 21 Aug 2009, Colin Guthrie wrote:

...
> 
> Just put an echo statement in there too. Should cover the bases for everyone.


Something like this?

--- a/bootstrap.sh  Tue Aug 18 20:55:33 2009
+++ b/bootstrap.sh  Tue Aug 18 20:58:15 2009
@@ -47,9 +47,9 @@
 esac
 
 if [ -f .git/hooks/pre-commit.sample -a ! -f .git/hooks/pre-commit ] ; then
-echo "Activating pre-commit hook."
-cp -pv  .git/hooks/pre-commit.sample .git/hooks/pre-commit
-chmod -v +x  .git/hooks/pre-commit
+cp -p .git/hooks/pre-commit.sample .git/hooks/pre-commit && \
+chmod +x .git/hooks/pre-commit && \
+echo "Activated pre-commit hook."
 fi
 
 if [ -f .tarball-version ]; then

Finn

> 
> Col
> 
> 
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 4/4] Solaris: fixed latency (resent)

2009-08-20 Thread Finn Thain

Set a fixed latency based on the given buffer size, which is constrained to
the 128 KB limit on buffered writes. Also fix an error path.

diff -ru pulseaudio-0.9.16-test5.orig/src/modules/module-solaris.c 
pulseaudio-0.9.16-test5/src/modules/module-solaris.c
--- pulseaudio-0.9.16-test5.orig/src/modules/module-solaris.c   Fri Aug 21 
00:54:33 2009
+++ pulseaudio-0.9.16-test5/src/modules/module-solaris.cFri Aug 21 
00:55:02 2009
@@ -136,6 +136,9 @@
 #define MAX_RENDER_HZ   (300)
 /* This render rate limit imposes a minimum latency, but without it we waste 
too much CPU time. */
 
+#define MAX_BUFFER_SIZE (128 * 1024)
+/* An attempt to buffer more than 128 KB causes write() to fail with errno == 
EAGAIN. */
+
 static uint64_t get_playback_buffered_bytes(struct userdata *u) {
 audio_info_t info;
 uint64_t played_bytes;
@@ -651,6 +654,7 @@
 void *p;
 ssize_t w;
 size_t len;
+int write_type = 1;
 
 /*
  * Since we cannot modify the size of the output buffer we 
fake it
@@ -668,38 +672,31 @@
 break;
 
 if (u->memchunk.length < len)
-pa_sink_render(u->sink, u->sink->thread_info.max_request, 
&u->memchunk);
+pa_sink_render(u->sink, len - u->memchunk.length, 
&u->memchunk);
 
+len = PA_MIN(u->memchunk.length, len);
+
 p = pa_memblock_acquire(u->memchunk.memblock);
-w = pa_write(u->fd, (uint8_t*) p + u->memchunk.index, 
u->memchunk.length, NULL);
+w = pa_write(u->fd, (uint8_t*) p + u->memchunk.index, len, 
&write_type);
 pa_memblock_release(u->memchunk.memblock);
 
 if (w <= 0) {
-switch (errno) {
-case EINTR:
-continue;
-case EAGAIN:
-/* If the buffer_size is too big, we get EAGAIN. 
Avoiding that limit by trial and error
- * is not ideal, but I don't know how to get the 
system to tell me what the limit is.
- */
-u->buffer_size = u->buffer_size * 18 / 25;
-u->buffer_size -= u->buffer_size % u->frame_size;
-u->buffer_size = PA_MAX(u->buffer_size, 2 * 
u->minimum_request);
-pa_sink_set_max_request_within_thread(u->sink, 
u->buffer_size);
-pa_sink_set_max_rewind_within_thread(u->sink, 
u->buffer_size);
-pa_log("EAGAIN. Buffer size is now %u bytes (%llu 
buffered)", u->buffer_size, buffered_bytes);
-break;
-default:
-pa_log("Failed to write data to DSP: %s", 
pa_cstrerror(errno));
-goto fail;
+if (errno == EINTR) {
+continue;
+} else if (errno == EAGAIN) {
+/* We may have realtime priority so yield the CPU to 
ensure that fd can become writable again. */
+pa_log_debug("EAGAIN with %llu bytes buffered.", 
buffered_bytes);
+break;
+} else {
+pa_log("Failed to write data to DSP: %s", 
pa_cstrerror(errno));
+goto fail;
 }
 } else {
 pa_assert(w % u->frame_size == 0);
 
 u->written_bytes += w;
-u->memchunk.length -= w;
-
 u->memchunk.index += w;
+u->memchunk.length -= w;
 if (u->memchunk.length <= 0) {
 pa_memblock_unref(u->memchunk.memblock);
 pa_memchunk_reset(&u->memchunk);
@@ -830,7 +827,7 @@
 pa_channel_map map;
 pa_modargs *ma = NULL;
 uint32_t buffer_length_msec;
-int fd;
+int fd = -1;
 pa_sink_new_data sink_new_data;
 pa_source_new_data source_new_data;
 char const *name;
@@ -882,9 +879,15 @@
 }
 u->buffer_size = pa_usec_to_bytes(1000 * buffer_length_msec, &ss);
 if (u->buffer_size < 2 * u->minimum_request) {
-pa_log("supplied buffer size argument is too small");
+pa_log("buffer_length argument cannot be smaller than %u",
+   (unsigned)(pa_bytes_to_usec(2 * u->minimum_request, &ss) / 
1000));
 goto fail;
 }
+if (u->buffer_size > MAX_BUFFER_SIZE) {
+pa_log("buffer_length argument cannot be greater than %u",
+   (unsigned)(pa_bytes_to_usec(MAX_BUFFER_SIZE, &ss) / 1000));
+goto fail;
+}
 
 u->device_name = pa_xstrdup(pa_modargs_get_value(ma, "device", 
DEFAULT_DEVICE));
 
@@ -945,6 +948,7 @@
 
 pa_source_set_asyncmsgq(u->source, u->thread_mq.inq);
 pa_sou

[pulseaudio-discuss] [PATCH 3/4] Solaris: use smoother (resent)

2009-08-20 Thread Finn Thain

Make use of the smoother, just in case.

--- pulseaudio-0.9.16-test4/src/modules/module-solaris.cTue Aug 18 
16:36:05 2009
+++ pulseaudio-0.9.16-test4/src/modules/module-solaris.cTue Aug 18 
16:36:13 2009
@@ -60,6 +60,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #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 < 24) {
 ++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);
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 2/4] Solaris: build fixes (resent)

2009-08-20 Thread Finn Thain

Fix bit rot due to recent flat volume changes.

--- pulseaudio-0.9.16-test5/src/modules/module-solaris.cThu Jul 23 
23:40:47 2009
+++ pulseaudio-0.9.16-test5/src/modules/module-solaris.cThu Aug 20 
14:44:59 2009
@@ -479,7 +479,7 @@
 if (u->fd >= 0) {
 AUDIO_INITINFO(&info);
 
-info.play.gain = pa_cvolume_max(&s->virtual_volume) * AUDIO_MAX_GAIN / 
PA_VOLUME_NORM;
+info.play.gain = pa_cvolume_max(&s->real_volume) * AUDIO_MAX_GAIN / 
PA_VOLUME_NORM;
 assert(info.play.gain <= AUDIO_MAX_GAIN);
 
 if (ioctl(u->fd, AUDIO_SETINFO, &info) < 0) {
@@ -501,8 +501,7 @@
 if (ioctl(u->fd, AUDIO_GETINFO, &info) < 0)
 pa_log("AUDIO_SETINFO: %s", pa_cstrerror(errno));
 else
-pa_cvolume_set(&s->virtual_volume, s->sample_spec.channels,
-info.play.gain * PA_VOLUME_NORM / AUDIO_MAX_GAIN);
+pa_cvolume_set(&s->real_volume, s->sample_spec.channels, 
info.play.gain * PA_VOLUME_NORM / AUDIO_MAX_GAIN);
 }
 }
 
@@ -515,7 +514,7 @@
 if (u->fd >= 0) {
 AUDIO_INITINFO(&info);
 
-info.play.gain = pa_cvolume_max(&s->virtual_volume) * AUDIO_MAX_GAIN / 
PA_VOLUME_NORM;
+info.play.gain = pa_cvolume_max(&s->volume) * AUDIO_MAX_GAIN / 
PA_VOLUME_NORM;
 assert(info.play.gain <= AUDIO_MAX_GAIN);
 
 if (ioctl(u->fd, AUDIO_SETINFO, &info) < 0) {
@@ -537,8 +536,7 @@
 if (ioctl(u->fd, AUDIO_GETINFO, &info) < 0)
 pa_log("AUDIO_SETINFO: %s", pa_cstrerror(errno));
 else
-pa_cvolume_set(&s->virtual_volume, s->sample_spec.channels,
-info.play.gain * PA_VOLUME_NORM / AUDIO_MAX_GAIN);
+pa_cvolume_set(&s->volume, s->sample_spec.channels, info.play.gain 
* PA_VOLUME_NORM / AUDIO_MAX_GAIN);
 }
 }
 
@@ -797,7 +795,7 @@
 pa_log_debug("caught signal");
 
 if (u->sink) {
-pa_sink_get_volume(u->sink, TRUE, FALSE);
+pa_sink_get_volume(u->sink, TRUE);
 pa_sink_get_mute(u->sink, TRUE);
 }
 
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH 2/4] Solaris: build fixes

2009-08-20 Thread Finn Thain


On Fri, 21 Aug 2009, Lennart Poettering wrote:

> On Fri, 21.08.09 03:49, Finn Thain (fth...@telegraphics.com.au) wrote:
> 
> > Fix bit rot due to recent flat volume changes.
> 
> Hmm, this patch got corrupted some way 

Sorry about that. For some reason "Do Not Send Flowed Text" was disabled 
in my mailer (alpine). I'll resend.

Finn

> (probably due to pasting it 
> inline in your mailer?) and doesn't apply to my tree. Tried a lot of
> tricks but was unsucessful in the end. Could you resend 
> this one (and the others too) and include it as an uncorrupted 
> attachment or -- preferably -- as proper git formatted patch?
> 
> Otherwise I'd be happy to merge your patches 2-3 without changes!
> 
> Thanks,
> 
> Lennart
> 
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH 1/4] Solaris: bootstrap portability

2009-08-20 Thread Finn Thain


On Fri, 21 Aug 2009, Lennart Poettering wrote:

> On Fri, 21.08.09 03:49, Finn Thain (fth...@telegraphics.com.au) wrote:
> 
> >
> > On Solaris, cp and chmod don't have a -v option.
> >
> > --- pulseaudio/bootstrap.sh Tue Aug 18 20:55:33 2009
> > +++ pulseaudio/bootstrap.sh Tue Aug 18 20:58:15 2009
> > @@ -48,8 +48,8 @@
> >
> >  if [ -f .git/hooks/pre-commit.sample -a ! -f .git/hooks/pre-commit ] ; then
> >  echo "Activating pre-commit hook."
> > -cp -pv  .git/hooks/pre-commit.sample .git/hooks/pre-commit
> > -chmod -v +x  .git/hooks/pre-commit
> > +cp -p  .git/hooks/pre-commit.sample .git/hooks/pre-commit
> > +chmod +x  .git/hooks/pre-commit
> >  fi
> 
> Hmm, I don't really like this one. I put the -v in there to show the
> use that we are activating the git commit hook. Maybe there is another
> way to handle this so that we still get the effect of -v, at least on
> Linux?

I'm not fussed. Anyone needing to generate a configure script using 
exactly the right autotools versions has bigger problems to worry about 
than removing -v options. After spending hours on it, I couldn't get 
autoconf (installed on a prefix) to work properly anyway.

Finn

> 
> Lennart
> 
> 
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 3/4] Solaris: use smoother

2009-08-20 Thread Finn Thain


Make use of the smoother, just in case.

--- pulseaudio-0.9.16-test4/src/modules/module-solaris.cTue Aug 18 
16:36:05 2009
+++ pulseaudio-0.9.16-test4/src/modules/module-solaris.cTue Aug 18 
16:36:13 2009
@@ -60,6 +60,7 @@
 #include 
 #include 
 #include 
+#include 

 #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 < 24) {
 ++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
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 2/4] Solaris: build fixes

2009-08-20 Thread Finn Thain


Fix bit rot due to recent flat volume changes.

--- pulseaudio-0.9.16-test5/src/modules/module-solaris.cThu Jul 23 
23:40:47 2009
+++ pulseaudio-0.9.16-test5/src/modules/module-solaris.cThu Aug 20 
14:44:59 2009
@@ -479,7 +479,7 @@
 if (u->fd >= 0) {
 AUDIO_INITINFO(&info);

-info.play.gain = pa_cvolume_max(&s->virtual_volume) * AUDIO_MAX_GAIN / 
PA_VOLUME_NORM;
+info.play.gain = pa_cvolume_max(&s->real_volume) * AUDIO_MAX_GAIN / 
PA_VOLUME_NORM;
 assert(info.play.gain <= AUDIO_MAX_GAIN);

 if (ioctl(u->fd, AUDIO_SETINFO, &info) < 0) {
@@ -501,8 +501,7 @@
 if (ioctl(u->fd, AUDIO_GETINFO, &info) < 0)
 pa_log("AUDIO_SETINFO: %s", pa_cstrerror(errno));
 else
-pa_cvolume_set(&s->virtual_volume, s->sample_spec.channels,
-info.play.gain * PA_VOLUME_NORM / AUDIO_MAX_GAIN);
+pa_cvolume_set(&s->real_volume, s->sample_spec.channels, 
info.play.gain * PA_VOLUME_NORM / AUDIO_MAX_GAIN);
 }
 }

@@ -515,7 +514,7 @@
 if (u->fd >= 0) {
 AUDIO_INITINFO(&info);

-info.play.gain = pa_cvolume_max(&s->virtual_volume) * AUDIO_MAX_GAIN / 
PA_VOLUME_NORM;
+info.play.gain = pa_cvolume_max(&s->volume) * AUDIO_MAX_GAIN / 
PA_VOLUME_NORM;
 assert(info.play.gain <= AUDIO_MAX_GAIN);

 if (ioctl(u->fd, AUDIO_SETINFO, &info) < 0) {
@@ -537,8 +536,7 @@
 if (ioctl(u->fd, AUDIO_GETINFO, &info) < 0)
 pa_log("AUDIO_SETINFO: %s", pa_cstrerror(errno));
 else
-pa_cvolume_set(&s->virtual_volume, s->sample_spec.channels,
-info.play.gain * PA_VOLUME_NORM / AUDIO_MAX_GAIN);
+pa_cvolume_set(&s->volume, s->sample_spec.channels, info.play.gain 
* PA_VOLUME_NORM / AUDIO_MAX_GAIN);
 }
 }

@@ -797,7 +795,7 @@
 pa_log_debug("caught signal");

 if (u->sink) {
-pa_sink_get_volume(u->sink, TRUE, FALSE);
+pa_sink_get_volume(u->sink, TRUE);
 pa_sink_get_mute(u->sink, TRUE);
 }

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 4/4] Solaris: fixed latency

2009-08-20 Thread Finn Thain


Set a fixed latency based on the given buffer size, which is constrained 
to the 128 KB limit on buffered writes. Also fix an error path.


--- pulseaudio-0.9.16-test5/src/modules/module-solaris.cFri Aug 21 
00:54:33 2009
+++ pulseaudio-0.9.16-test5/src/modules/module-solaris.cFri Aug 21 
00:55:02 2009
@@ -136,6 +136,9 @@
 #define MAX_RENDER_HZ   (300)
 /* This render rate limit imposes a minimum latency, but without it we waste 
too much CPU time. */

+#define MAX_BUFFER_SIZE (128 * 1024)
+/* An attempt to buffer more than 128 KB causes write() to fail with errno == 
EAGAIN. */
+
 static uint64_t get_playback_buffered_bytes(struct userdata *u) {
 audio_info_t info;
 uint64_t played_bytes;
@@ -651,6 +654,7 @@
 void *p;
 ssize_t w;
 size_t len;
+int write_type = 1;

 /*
  * Since we cannot modify the size of the output buffer we 
fake it
@@ -668,38 +672,31 @@
 break;

 if (u->memchunk.length < len)
-pa_sink_render(u->sink, u->sink->thread_info.max_request, 
&u->memchunk);
+pa_sink_render(u->sink, len - u->memchunk.length, 
&u->memchunk);

+len = PA_MIN(u->memchunk.length, len);
+
 p = pa_memblock_acquire(u->memchunk.memblock);
-w = pa_write(u->fd, (uint8_t*) p + u->memchunk.index, 
u->memchunk.length, NULL);
+w = pa_write(u->fd, (uint8_t*) p + u->memchunk.index, len, 
&write_type);
 pa_memblock_release(u->memchunk.memblock);

 if (w <= 0) {
-switch (errno) {
-case EINTR:
-continue;
-case EAGAIN:
-/* If the buffer_size is too big, we get EAGAIN. 
Avoiding that limit by trial and error
- * is not ideal, but I don't know how to get the 
system to tell me what the limit is.
- */
-u->buffer_size = u->buffer_size * 18 / 25;
-u->buffer_size -= u->buffer_size % u->frame_size;
-u->buffer_size = PA_MAX(u->buffer_size, 2 * 
u->minimum_request);
-pa_sink_set_max_request_within_thread(u->sink, 
u->buffer_size);
-pa_sink_set_max_rewind_within_thread(u->sink, 
u->buffer_size);
-pa_log("EAGAIN. Buffer size is now %u bytes (%llu 
buffered)", u->buffer_size, buffered_bytes);
-break;
-default:
-pa_log("Failed to write data to DSP: %s", 
pa_cstrerror(errno));
-goto fail;
+if (errno == EINTR) {
+continue;
+} else if (errno == EAGAIN) {
+/* We may have realtime priority so yield the CPU to 
ensure that fd can become writable again. */
+pa_log_debug("EAGAIN with %llu bytes buffered.", 
buffered_bytes);
+break;
+} else {
+pa_log("Failed to write data to DSP: %s", 
pa_cstrerror(errno));
+goto fail;
 }
 } else {
 pa_assert(w % u->frame_size == 0);

 u->written_bytes += w;
-u->memchunk.length -= w;
-
 u->memchunk.index += w;
+u->memchunk.length -= w;
 if (u->memchunk.length <= 0) {
 pa_memblock_unref(u->memchunk.memblock);
 pa_memchunk_reset(&u->memchunk);
@@ -830,7 +827,7 @@
 pa_channel_map map;
 pa_modargs *ma = NULL;
 uint32_t buffer_length_msec;
-int fd;
+int fd = -1;
 pa_sink_new_data sink_new_data;
 pa_source_new_data source_new_data;
 char const *name;
@@ -882,9 +879,15 @@
 }
 u->buffer_size = pa_usec_to_bytes(1000 * buffer_length_msec, &ss);
 if (u->buffer_size < 2 * u->minimum_request) {
-pa_log("supplied buffer size argument is too small");
+pa_log("buffer_length argument cannot be smaller than %u",
+   (unsigned)(pa_bytes_to_usec(2 * u->minimum_request, &ss) / 
1000));
 goto fail;
 }
+if (u->buffer_size > MAX_BUFFER_SIZE) {
+pa_log("buffer_length argument cannot be greater than %u",
+   (unsigned)(pa_bytes_to_usec(MAX_BUFFER_SIZE, &ss) / 1000));
+goto fail;
+}

 u->device_name = pa_xstrdup(pa_modargs_get_value(ma, "device", 
DEFAULT_DEVICE));

@@ -945,6 +948,7 @@

 pa_source_set_asyncmsgq(u->source, u->thread_mq.inq);
 pa_source_set_rtpoll(u->source, u->rtpoll);
+pa_source_set_fixed_latency(u->source, pa_bytes_to_usec(u->buffer_size, 
&u->sou

[pulseaudio-discuss] [PATCH 1/4] Solaris: bootstrap portability

2009-08-20 Thread Finn Thain


On Solaris, cp and chmod don't have a -v option.

--- pulseaudio/bootstrap.sh Tue Aug 18 20:55:33 2009
+++ pulseaudio/bootstrap.sh Tue Aug 18 20:58:15 2009
@@ -48,8 +48,8 @@

 if [ -f .git/hooks/pre-commit.sample -a ! -f .git/hooks/pre-commit ] ; then
 echo "Activating pre-commit hook."
-cp -pv  .git/hooks/pre-commit.sample .git/hooks/pre-commit
-chmod -v +x  .git/hooks/pre-commit
+cp -p  .git/hooks/pre-commit.sample .git/hooks/pre-commit
+chmod +x  .git/hooks/pre-commit
 fi

 if [ -f .tarball-version ]; then
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Per-app flat volume adjustment is highly unintuitive, if mathematically consistent.

2009-05-26 Thread Finn Thain


On Wed, 27 May 2009, Lennart Poettering wrote:

> You are misunderstanding the flat volume logic.

Probably.

But since attenuator knobs don't tweak each other (rather I am in 
control), I think you can read what I wrote as arguing against flat volume 
logic, on the grounds of intuitive behaviour.

Finn

> In flat vol the hardware volume is always configured to the *maxmimum* 
> of all stream volumes. And if the streams have different volumes then 
> some of them will be attenuated digitally, *nothing* will be amplified 
> digitally.
> 
> So, if someone wants playback of exactly one stream a bit louder, then 
> this will have the effect that the output device volume will be 
> increased and digital attenuation happens for all other streams.
> 
> Which seems to be exactly hat you are asking for, which in turn makes me 
> wonder what your mail is actually about?
> 
> Lennart
> 
> 
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Per-app flat volume adjustment is highly unintuitive, if mathematically consistent.

2009-05-26 Thread Finn Thain

Lennart wrote:

> 
> Now, I must admit that this all is a bit hard to grasp. And thus not 
> exactly the definition of easy to use. We had a couple of discussions on 
> this very ML about this. So far noone came up with a way to fix this in 
> a way that would be completely convincing.

I can't claim to grasp it, but...
 
> I think the core problem is that it is impossible to figure out what the 
> user actually wants. When he increases a volume of a stream he might A) 
> want it a bit louder then whatever else is currently playing and would 
> be pissed off if the other stream would get louder at the same time or 
> B) want it a bit louder because everything that's playing is just too 
> silent and he would be pissed off if only one stream would get louder 
> and not all.

It seems to me that these problems would go away if you accept that 
boost/compression should not be a function of volume. (Use a seperate 
module!) If PA can't satisfy audiophiles, then PA will not earn a great 
reputation with the layman who trusts experts either.

Every sensible volume control I can think of is conceptually an 
attenuator, i.e. zero decibels at maximum (even if it is implemented as 
amplifier gain control internally). That's why a slider is appropriate as 
a GUI element here. (VLC player notwithstanding. I carefully leave it at 
100% and never touch it. The 400% upper bound is both non-intuitive, 
arbitrary and likely to distort.)

So, if as you claim, the user "might A) want it a bit louder then whatever 
else is currently playing and would be pissed off if the other stream 
would get louder at the same time", I think that user has probably never 
used a volume control or mixer (i.e. an attenuator). It doesn't make sense 
(in my mind) to optimise for this unusual situation.

Finn
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] 0.9.15 solaris module build failure

2009-04-18 Thread Finn Thain


On Sun, 19 Apr 2009, Lennart Poettering wrote:

> On Fri, 17.04.09 22:58, Finn Thain (fth...@telegraphics.com.au) wrote:
> 
> > Lennart wrote,
> > 
> > >
> > > Hmm, yes. As it seems I broke the build for non-dbus builds.
> > 
> > Well, you also broke the solaris module between 0.9.15-test8 and 
> > 0.9.15.
> >
> > Have you considered release candidates?
> 
> Uh. sorry. The pre-releases were supposed to act as RCs. However due to 
> the Fedora freeze I rushed out the final release with out having a final 
> rc.
>
> Like it or not, but for me as upstream only the complete build for 
> Fedora is release relevant.

I understand. But it seems to me that you might have rushed out test9 for 
fedora instead of final.

> Support for builds with weirder settings or other operating systems 
> won't delay my releases unless circumstances allow it and I am in a good 
> mood. ;-)

That's your call, of course. You do realise that this means that those of 
us working on and using those setups have almost no chance of zero-defect 
releases, unlike fedora? (This is an issue for fedora if fedora users want 
easy interoperability with other setups. For my purposes, the example that 
springs to mind is a fedora guest domain with a pulseaudio setup like mine 
running in dom0.)

> That said, I am of course always happy to merge patches for those setups 
> as well!
>
> > Patch follows. It would be nice if API changes could be made without 
> > breaking things when the effort to avoid that is trivial.
> 
> Hmm, no. The internal APIs are explicitly declared unstable. I will of 
> course try to be nice and not do unnecessary API changes. But otherwise 
> I take the liberty to value clean internal APIs over API stability.

But I didn't ask for a stable API...

> Patch is applied! Thanks!
>
> One more things: for sinks/sources that do not allow dynamic 
> reconfiguration of latencies it is a good idea to set 
> sink->fixed_latency resp. source->fixed_latency to the upper limit of 
> the latency of the device. i.e. to the size of your hw playback buffer.
> 
> This value is used to size the per-client buffer when the client asks 
> for a specific overall latency. By default this value is set to 250ms 
> which is probably wrong for your Solaris driver.
> 
> It is OK if pa_sink_latency() returns values higher or lower than this 
> value. However setting this correctly improves the accuracy if a client 
> requests a specific latency it actually gets it.

OK, I will look into implementing dynamic latency or fixed latency. Thanks 
for the heads-up.

Finn

> Lennart
> 
> 
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] 0.9.15 solaris module build failure

2009-04-17 Thread Finn Thain


Lennart wrote,

>
> Hmm, yes. As it seems I broke the build for non-dbus builds.

Well, you also broke the solaris module between 0.9.15-test8 and 0.9.15.

Have you considered release candidates?

Patch follows. It would be nice if API changes could be made without 
breaking things when the effort to avoid that is trivial.

Finn



--- pulseaudio-0.9.15/src/modules/module-solaris.c.orig Fri Apr 17 14:12:05 2009
+++ pulseaudio-0.9.15/src/modules/module-solaris.c  Fri Apr 17 14:32:03 2009
@@ -794,7 +794,7 @@
 pa_log_debug("caught signal");
 
 if (u->sink) {
-pa_sink_get_volume(u->sink, TRUE);
+pa_sink_get_volume(u->sink, TRUE, FALSE);
 pa_sink_get_mute(u->sink, TRUE);
 }
 
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] revive solaris module

2009-04-05 Thread Finn Thain


On Tue, 31 Mar 2009, Lennart Poettering wrote:

[snip]
> 
> I have now merged your patch. I had to change a few things to make it 
> apply cleanly. Since I have no access to Solaris I am unable to test 
> this though, so please check if things still work for you.
> 
> I also worked around the realpath() issue mostly. It should work fine on 
> Solaris now, as well.

Thanks. 0.9.15-test7 seems to work fine.

The only new issue is that configure --without-dbus no longer builds. I 
don't need dbus for my purposes (network audio server) and it seems that 
dbus is not included with Solaris. A patch for this follows.

Finn

> Thanks again for your contributions.
> 
> Lennart
> 
> 


diff -ru pulseaudio-0.9.15-test7.orig/src/pulse/context.c 
pulseaudio-0.9.15-test7/src/pulse/context.c
--- pulseaudio-0.9.15-test7.orig/src/pulse/context.cTue Mar 31 09:31:39 2009
+++ pulseaudio-0.9.15-test7/src/pulse/context.c Thu Apr  2 18:16:00 2009
@@ -104,7 +104,10 @@
 [PA_COMMAND_RECORD_BUFFER_ATTR_CHANGED] = pa_command_stream_buffer_attr
 };
 static void context_free(pa_context *c);
+
+#ifdef HAVE_DBUS
 static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *message, 
void *userdata);
+#endif
 
 pa_context *pa_context_new(pa_mainloop_api *mainloop, const char *name) {
 return pa_context_new_with_proplist(mainloop, name, NULL);
@@ -144,7 +147,9 @@
 if (name)
 pa_proplist_sets(c->proplist, PA_PROP_APPLICATION_NAME, name);
 
+#ifdef HAVE_DBUS
 c->system_bus = c->session_bus = NULL;
+#endif
 c->mainloop = mainloop;
 c->client = NULL;
 c->pstream = NULL;
@@ -241,6 +246,7 @@
 
 context_unlink(c);
 
+#ifdef HAVE_DBUS
 if (c->system_bus) {
 
dbus_connection_remove_filter(pa_dbus_wrap_connection_get(c->system_bus), 
filter_cb, c);
 pa_dbus_wrap_connection_free(c->system_bus);
@@ -250,6 +256,7 @@
 
dbus_connection_remove_filter(pa_dbus_wrap_connection_get(c->session_bus), 
filter_cb, c);
 pa_dbus_wrap_connection_free(c->session_bus);
 }
+#endif
 
 if (c->record_streams)
 pa_dynarray_free(c->record_streams, NULL, NULL);
@@ -742,6 +749,7 @@
 
 static void on_connection(pa_socket_client *client, pa_iochannel*io, void 
*userdata);
 
+#ifdef HAVE_DBUS
 static void track_pulseaudio_on_dbus(pa_context *c, DBusBusType type, 
pa_dbus_wrap_connection **conn) {
 DBusError error;
 
@@ -767,6 +775,7 @@
  finish:
 dbus_error_free(&error);
 }
+#endif
 
 static int try_next_connection(pa_context *c) {
 char *u = NULL;
@@ -800,6 +809,7 @@
 }
 #endif
 
+#ifdef HAVE_DBUS
 if (c->no_fail && !c->server_specified) {
 if (!c->system_bus)
 track_pulseaudio_on_dbus(c, DBUS_BUS_SYSTEM, 
&c->system_bus);
@@ -806,6 +816,7 @@
 if (!c->session_bus)
 track_pulseaudio_on_dbus(c, DBUS_BUS_SESSION, 
&c->session_bus);
 } else
+#endif
 pa_context_fail(c, PA_ERR_CONNECTIONREFUSED);
 
 goto finish;
@@ -864,6 +875,7 @@
 pa_context_unref(c);
 }
 
+#ifdef HAVE_DBUS
 static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *message, 
void *userdata) {
 pa_context *c = userdata;
 pa_bool_t is_session;
@@ -895,6 +909,7 @@
 finish:
 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 }
+#endif
 
 int pa_context_connect(
 pa_context *c,
diff -ru pulseaudio-0.9.15-test7.orig/src/pulse/internal.h 
pulseaudio-0.9.15-test7/src/pulse/internal.h
--- pulseaudio-0.9.15-test7.orig/src/pulse/internal.h   Wed Apr  1 07:33:15 2009
+++ pulseaudio-0.9.15-test7/src/pulse/internal.hThu Apr  2 18:16:00 2009
@@ -42,7 +42,9 @@
 #include 
 #include 
 #include 
+#ifdef HAVE_DBUS
 #include 
+#endif
 
 #include "client-conf.h"
 
@@ -51,8 +53,10 @@
 struct pa_context {
 PA_REFCNT_DECLARE;
 
+#ifdef HAVE_DBUS
 pa_dbus_wrap_connection *system_bus;
 pa_dbus_wrap_connection *session_bus;
+#endif
 
 pa_proplist *proplist;
 pa_mainloop_api* mainloop;
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] revive solaris module

2009-03-27 Thread Finn Thain


On Fri, 27 Mar 2009, Lennart Poettering wrote:

> On Sat, 07.03.09 16:48, Finn Thain (fth...@telegraphics.com.au) wrote:
> 
> > 
> > 
> > 
> > On Wed, 4 Mar 2009, Lennart Poettering wrote:
> > 
> > [snip]
> > > > This patch disables link map/library versioning unless ld is GNU 
> > > > ld. Another approach for solaris would be to use that linker's -M 
> > > > option, but I couldn't make that work (due to undefined mainloop, 
> > > > browse and simple symbols when linking pacat. I can post the 
> > > > errors if anyone is intested.)
> > > 
> > > The linking in PA is a bit weird since we have a cyclic dependency 
> > > between libpulse and libpulsecommon which however is not explicit.
> > 
> > Could that affect the pacat link somehow?
> 
> No. It shouldn't. pacat only accesses symbols from libpulse, not from 
> libpulsecommon.
>
> > What are the implications for client apps that link with the 
> > non-versioned libraries I've been building on solaris?
> 
> Not sure. It will certainly built though. As long as no app accesses 
> symbols it shouldn't be accessing things should be fine when building a 
> version that doesn't hide anything.

OK.
 
> > > > +case EAGAIN:
> > > > +u->buffer_size = u->buffer_size * 18 / 25;
> > > > +u->buffer_size -= u->buffer_size % 
> > > > u->frame_size;
> > > > +u->buffer_size = PA_MAX(u->buffer_size, 
> > > > (int32_t)MIN_BUFFER_SIZE);
> > > > +pa_sink_set_max_request(u->sink, 
> > > > u->buffer_size);
> > > > +pa_log("EAGAIN. Buffer size is now %u 
> > > > bytes (%llu buffered)", u->buffer_size, buffered_bytes);
> > > > +break;
> > > 
> > > Hmm, care to explain this?
> > 
> > EAGAIN happens when the user requests a buffer size that is too large for 
> > the STREAMS layer to accept. We end up looping with EAGAIN every time we 
> > try to write out the rest of the buffer, which burns enough CPU time to 
> > trip the CPU limit.
> > 
> > So, I reduce the buffer size with each EAGAIN. This gets us reasonably 
> > close to the largest usable buffer size. (Perhaps there's a better way to 
> > determine what that limit is, but I don't know how.)
> 
> And you are sure that EAGAIN may only be thrown in this case? This
> interpretation of EAGAIn is completely different from how things are
> understood on Unix otherwise.
> 
> Normally on Unix write() would do a partial write if the destination
> buffer is shorter than the source buffer. It would then return how
> much it wrote so that the caller can handle that. Only if nothing at
> all can be written (and O_NDELAY is enabled) EAGAIN would be
> returned. 
> 
> Are you really sure this interpretation of EAGAIN of yours is correct?

The only interpretation here was my suggestion that STREAMS was the cause. 
That is guesswork on my part.

If you are asking "am I sure that my observation of this behaviour is 
correct?" then yes, I am.

Perhaps a better solution is to use blocking writes. Would that be OK with 
you?

> > > > +pa_rtpoll_set_timer_absolute(u->rtpoll, xtime0 + 
> > > > pa_bytes_to_usec(buffered_bytes / 2, &u->sink->sample_spec));
> > > > +} else {
> > > > +pa_rtpoll_set_timer_disabled(u->rtpoll);
> > > >  }
> > > 
> > > Hmm, you schedule audio via timers? Is that a good idea?
> > 
> > Perhaps not. I won't know until I test on more hardware.
> > 
> > But, given that we have rt priority and high resolution timers on solaris, 
> > I think it is OK in theory...
> > 
> > The reason I used a timer was to minimise CPU usage and avoid the CPU 
> > limit. Recall that getting woken up by poll is not an option for playback 
> > unfortunately. 
> 
> Why?

Because we artificially limit the amount of queued writes (so called 
"buffer size"). That was the algorithm in 0.9.14 too -- before I started 
hacking on it. I think the intention is to limit latency.

> > We can arrange for a signal when the FD becomes writable, but that 
> > throws out the whole buffer size concept, which acts to reduce 
> > latency.
> 
> > > That really only makes sense if you have to deal with large buffers 
> > > and support rewindi

Re: [pulseaudio-discuss] [PATCH] revive solaris module

2009-03-06 Thread Finn Thain


On Wed, 4 Mar 2009, Lennart Poettering wrote:

[snip]
> > This patch disables link map/library versioning unless ld is GNU ld. 
> > Another approach for solaris would be to use that linker's -M option, 
> > but I couldn't make that work (due to undefined mainloop, browse and 
> > simple symbols when linking pacat. I can post the errors if anyone is 
> > intested.)
> 
> The linking in PA is a bit weird since we have a cyclic dependency 
> between libpulse and libpulsecommon which however is not explicit.

Could that affect the pacat link somehow?

What are the implications for client apps that link with the non-versioned 
libraries I've been building on solaris?

[snip]
> >  struct userdata {
> >  pa_core *core;
> > @@ -87,15 +92,24 @@ struct userdata {
> >  
> >  pa_memchunk memchunk;
> >  
> > -unsigned int page_size;
> > -
> >  uint32_t frame_size;
> > -uint32_t buffer_size;
> > -unsigned int written_bytes, read_bytes;
> > +int32_t buffer_size;
> > +volatile uint64_t written_bytes, read_bytes;
> > +pa_mutex *written_bytes_lock;
> 
> Hmm, we generally try do do things without locking in PA. This smells as 
> if it was solvable using atomic ints as well.
> 
> Actually, looking at this again I get the impression these mutex are 
> completely unnecessary here. All functions that lock these mutexes are 
> called from the IO thread so no locking should be nessary.
> 
> Please don't use volatile here. I am pretty sure it is a misuse. Also 
> see http://kernel.org/doc/Documentation/volatile-considered-harmful.txt 
> which applies here too I think.

OK, I've removed the locks. For some reason I thought that the get_latency 
function was called from two different threads.

> > +static void sink_set_volume(pa_sink *s) {
> > +struct userdata *u;
> > +audio_info_t info;
> > +
> > +pa_assert_se(u = s->userdata);
> > +
> > +if (u->fd >= 0) {
> > +AUDIO_INITINFO(&info);
> > +
> > +info.play.gain = pa_cvolume_avg(&s->virtual_volume) * 
> > AUDIO_MAX_GAIN / PA_VOLUME_NORM;
> > +assert(info.play.gain <= AUDIO_MAX_GAIN);
> 
> I'd prefer if you'd use pa_cvolume_max here instead of pa_cvolume_avg() 
> because this makes the volume independant of the balance.
> 
> > -info.play.error = 0;
> > +info.play.gain = pa_cvolume_avg(&s->virtual_volume) * 
> > AUDIO_MAX_GAIN / PA_VOLUME_NORM;
> > +assert(info.play.gain <= AUDIO_MAX_GAIN);
> 
> Same here. (i.e. for the source)

Done and done.
 
> > +if (u->sink->thread_info.rewind_requested)
> > +pa_sink_process_rewind(u->sink, 0);
> 
> This is correct.
> 
> >  
> >  err = ioctl(u->fd, AUDIO_GETINFO, &info);
> >  pa_assert(err >= 0);
> 
> Hmm, if at all this should be pa_assert_se(), not pa_assert() (so that 
> it is not defined away by -DNDEBUG). However I'd prefer if the error 
> would be could correctly. (I see that this code is not yours, but 
> still...)

Done.
 
> > +case EINTR:
> > +break;
> 
> I think you should simply try again in this case...

Done.

> > +case EAGAIN:
> > +u->buffer_size = u->buffer_size * 18 / 25;
> > +u->buffer_size -= u->buffer_size % 
> > u->frame_size;
> > +u->buffer_size = PA_MAX(u->buffer_size, 
> > (int32_t)MIN_BUFFER_SIZE);
> > +pa_sink_set_max_request(u->sink, 
> > u->buffer_size);
> > +pa_log("EAGAIN. Buffer size is now %u bytes 
> > (%llu buffered)", u->buffer_size, buffered_bytes);
> > +break;
> 
> Hmm, care to explain this?

EAGAIN happens when the user requests a buffer size that is too large for 
the STREAMS layer to accept. We end up looping with EAGAIN every time we 
try to write out the rest of the buffer, which burns enough CPU time to 
trip the CPU limit.

So, I reduce the buffer size with each EAGAIN. This gets us reasonably 
close to the largest usable buffer size. (Perhaps there's a better way to 
determine what that limit is, but I don't know how.)

> > +
> > +pa_rtpoll_set_timer_absolute(u->rtpoll, xtime0 + 
> > pa_bytes_to_usec(buffered_bytes / 2, &u->sink->sample_spec));
> > +} else {
> > +pa_rtpoll_set_timer_disabled(u->rtpoll);
> >  }
> 
> Hmm, you schedule audio via timers? Is that a good idea?

Perhaps not. I won't know until I test on more hardware.

But, given that we have rt priority and high resolution timers on solaris, 
I think it is OK in theory...

The reason I used a timer was to minimise CPU usage and avoid the CPU 
limit. Recall that getting woken up by poll is not an option for playback 
unfortunately. We can arrange for a signal when the FD becomes writable, 
but that throws out the whole buffer size concept, which acts to reduce 
latency.

> That really only makes sense if you have to deal 

Re: [pulseaudio-discuss] [PATCH] revive solaris module

2009-03-01 Thread Finn Thain


On Sun, 1 Mar 2009, Sergio wrote:

> Finn Thain a ?crit :
> 
> > When I posted that patch I had not actually tried to link any other 
> > solaris apps with the pulseaudio client libraries. But Csound piqued 
> > my curiosity. So I ported it to solaris. If you want the patch and 
> > build scripts let me know.
> >   
> I commited the attached patch (SConstruct and source files) in the 
> Csound forum : not very complete, but sufficient to work with CS (some 
> extra opcodes, FLTK widgets, etc.)

Did any part of your patch get committed upstream? I admit I haven't 
looked in the Csound repo...

My patch covers some of the same ground that you already covered. I've 
done a few things differently: e.g. sunos5 == solaris. Also, you changed 
the type of len_t. The system provided one is u_longlong_t, whereas the 
old one was long. Also I've avoided built-in macros like "sun".

So I think it might be best to move Sun Pro parts of your patch, and the 
double precision arithmetic parts, and any multi-arch parts into seperate 
patches.

I think my patch is wrong WRT to the 64 bit python checks in SConstruct. 
And I patched some stuff that I've not compiled since beause I didn't 
build the deps yet, and some modules I've not patched at all (for the same 
reason).

But this is all a bit off-topic for this mailing list. We should move this 
thread to email or to a different list.

> 
> 
> > The realtime scheduling works (both csound and pulseaudio).
> >   
> 
> Here a little synthesis of my issue with Pulseaudio-09.6/Csound
> 
> https://tango.0pointer.de/pipermail/pulseaudio-discuss/2008-December/002705.html
> 
> 
> But now the best is probably that i build Pulseaudio-09.14 with the 
> patch you posted some days ago.

That would be great. It needs wider testing. Especially things like 64-bit 
hardware including SPARC, also slower CPUs and more ./configure options etc.

I've uploaded my Csound patch and the script I used to build everything -- 

http://www.telegraphics.com.au/~fthain/pulseaudio/

Hopefully it will save you some effort. For example there's a bunch of 
packages that I build just so I could run bootstrap.sh for pulseaudio. 
Unfortunately there's no easy way around that until we have a pulseaudio 
release with a new configure script.

Finn

> 
> Cheers,
> 
> Sergio
> 
> ___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] revive solaris module

2009-03-01 Thread Finn Thain


On Sun, 1 Mar 2009, Sergio wrote:

> Thomas Wagner a écrit :
> > Sounds really great!
> >
> > I'm running pulseaudio 0.9.5 on Solaris Express X86 for a while, but 
> > the newer pulsaudio releases use atomic_ops and this is not available 
> > on Solaris. The atomic operations delivered with Solaris are not a 
> > drop-in replacement.
> >
> > If anyone want to help solving this, this would enable to use the 
> > current pulsaudio releases as well.
> >   
> Hi Thomas,
> 
> Last year i builded libatomic_ops-1.2 with Sunstudio 12, unfortunately i 
> can't remember if i had difficulties or not with, but that gave me two 
> static libraries called libatomic_ops.a and libatomic_ops_gpl.a.

I've been using libatomic_ops-1.2 also (Solaris Express x86, gcc).
Unless that doesn't work on SPARC, I don't think we need the Sun ops?

Finn

> Cheers,
> 
> Sergio
> 
> ___
> pulseaudio-discuss mailing list
> pulseaudio-discuss@mail.0pointer.de
> https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
> 
> ___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] revive solaris module

2009-02-28 Thread Finn Thain


On Thu, 26 Feb 2009, Sergio wrote:

> Finn Thain a ?crit :
> > Hi All,
> >
> > This patch fixes the solaris audio device source and sink, and fixes some
> > portability issues that break the build on solaris. Questions and comments
> > welcomed.
> >   
> Hi Finn,
> 
> Great work !

Thanks :)
 
> Just a question : are you (for luck) also a Csound user ?

The reason I set out to get pulseaudio working on solaris again was to 
send audio from a linux app running in a Xen guest domain to a pulseaudio 
server running in the solaris privileged domain. (PCI passthrough isn't 
possible on this old hardware.)

When I posted that patch I had not actually tried to link any other 
solaris apps with the pulseaudio client libraries. But Csound piqued my 
curiosity. So I ported it to solaris. If you want the patch and build 
scripts let me know.

> I builded successfuly Pulseaudio-09.06 with Sunstudio 12 on my Sparc 
> Ultra 45 : it works well, plays files, etc., only i never was able to 
> use it as realtime renderer for Csound, which provides a Pulseaudio 
> entry module (really working on Linux).

The realtime scheduling works (both csound and pulseaudio).

Finn

> 
> Cheers,
> 
> Sergio
> 
> 
> ___
> pulseaudio-discuss mailing list
> pulseaudio-discuss@mail.0pointer.de
> https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
> 
> ___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH] revive solaris module

2009-02-26 Thread Finn Thain

Hi All,

This patch fixes the solaris audio device source and sink, and fixes some 
portability issues that break the build on solaris. Questions and comments 
welcomed.

I've tested this patch only with OpenSolaris Express snv 103. Eventually I 
hope to be able to test a few older releases and older hardware (though it 
is hard to say whether there is much interest in those).

This is my first brush with pulseaudio and so I read the wiki docs and 
some of the source code but I'm still unsure of a few things. In 
particular I'm wondering about rewind processing, corking and what (if 
anything) the module needs for those. I'm also unclear on the implications 
of thread_info.buffer_size, .fragment_size and .max_request, and whether 
my code is correct or not.

This patch disables link map/library versioning unless ld is GNU ld. 
Another approach for solaris would be to use that linker's -M option, but 
I couldn't make that work (due to undefined mainloop, browse and simple 
symbols when linking pacat. I can post the errors if anyone is intested.)

Thanks,
Finn Thain


diff --git a/bootstrap.sh b/bootstrap.sh
index e64f342..9c23f0d 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -58,7 +58,7 @@ else
 
 rm -f Makefile.am~ configure.ac~
 # Evil, evil, evil, evil hack
-sed 's/read dummy/\#/' `which gettextize` | sh -s -- --copy --force
+sed 's/read dummy/\#/' `which gettextize` | sh -s --copy --force
 test -f Makefile.am~ && mv Makefile.am~ Makefile.am
 test -f configure.ac~ && mv configure.ac~ configure.ac
 
diff --git a/configure.ac b/configure.ac
index fbe134c..7f0b96d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -70,14 +70,17 @@ fi
 
 case $host in
*-*-solaris* )
-  AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, Needed to get declarations for 
msg_control and msg_controllen on Solaris)
-  AC_DEFINE(_XOPEN_SOURCE,  2, Needed to get declarations for 
msg_control and msg_controllen on Solaris)
+  AC_DEFINE(_XOPEN_SOURCE,600, Needed to get declarations for 
msg_control and msg_controllen on Solaris)
   AC_DEFINE(__EXTENSIONS__, 1, Needed to get declarations for 
msg_control and msg_controllen on Solaris)
   ;;
 esac
 
  Checks for programs. 
 
+# libtool
+
+AC_PROG_LIBTOOL
+
 # mkdir -p
 
 AC_PROG_MKDIR_P
@@ -92,11 +95,20 @@ AC_USE_SYSTEM_EXTENSIONS
 
 # M4
 
-AC_PATH_PROG([M4], [m4 gm4], [no])
+AC_CHECK_PROGS([M4], gm4 m4, no)
 if test "x$M4" = xno ; then
AC_MSG_ERROR([m4 missing])
 fi
 
+# Linker
+
+AC_PROG_LD
+AC_PROG_LD_GNU
+
+AC_SUBST(HAVE_GNU_LD)
+AM_CONDITIONAL([HAVE_GNU_LD], [test "x$HAVE_GNU_LD" = x1])
+
+
 dnl Compiler flags
 DESIRED_FLAGS="-Wall -W -Wextra -pipe -Wno-long-long -Winline -Wvla 
-Wno-overlength-strings -Wunsafe-loop-optimizations -Wundef -Wformat=2 
-Wlogical-op -Wsign-compare -Wformat-security -Wmissing-include-dirs 
-Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Winit-self 
-Wdeclaration-after-statement -Wfloat-equal -Wmissing-prototypes 
-Wstrict-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn 
-Wshadow -Wendif-labels -Wcast-align -Wstrict-aliasing=2 -Wwrite-strings 
-Wno-unused-parameter -ffast-math -Wp,-D_FORTIFY_SOURCE=2 -fno-common 
-fdiagnostics-show-option"
 
@@ -985,7 +997,7 @@ if test "x$HAVE_HAL" = x1 ; then
dbus=yes
 fi
 
-if test "x${dbus}" != xno || test "x${bluez}" != xno || "x${hal}" != xno ; then
+if test "x${dbus}" != xno || test "x${bluez}" != xno || test "x${hal}" != xno 
; then
 
 PKG_CHECK_MODULES(DBUS, [ dbus-1 >= 1.0.0 ],
 [
diff --git a/src/Makefile.am b/src/Makefile.am
index 811b120..9aa9179 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -684,8 +684,11 @@ libpulse_la_SOURCES = \
pulse/xmalloc.c pulse/xmalloc.h
 
 libpulse_la_CFLAGS = $(AM_CFLAGS)
-libpulse_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBPULSE_VERSION_INFO) 
-Wl,-version-script=$(srcdir)/map-file
 libpulse_la_LIBADD = $(AM_LIBADD) $(WINSOCK_LIBS) $(LTLIBICONV) 
libpulsecomm...@pa_majorminormicro@.la
+libpulse_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBPULSE_VERSION_INFO)
+if HAVE_GNU_LD
+libpulse_la_LDFLAGS += -Wl,-version-script=$(srcdir)/map-file
+endif
 
 if HAVE_X11
 libpulse_la_SOURCES += pulse/client-conf-x11.c pulse/client-conf-x11.h
@@ -696,17 +699,26 @@ endif
 libpulse_simple_la_SOURCES = pulse/simple.c pulse/simple.h
 libpulse_simple_la_CFLAGS = $(AM_CFLAGS)
 libpulse_simple_la_LIBADD = $(AM_LIBADD) libpulse.la 
libpulsecomm...@pa_majorminormicro@.la
-libpulse_simple_la_LDFLAGS = $(AM_LDFLAGS) -version-info 
$(LIBPULSE_SIMPLE_VERSION_INFO) -Wl,-version-script=$(srcdir)/map-file
+libpulse_simple_la_LDFLAGS = $(AM_LDFLAGS) -version-info 
$(LIBPULSE_SIMPLE_VERSION_INFO)
+if HAVE_GNU_LD
+libpulse_simple_la_LDFLAGS += -Wl,-version-script=$(srcdir)/map-file
+endi