Commit graph

84 commits

Author SHA1 Message Date
Lennart Poettering
8a2a6b2004 adjust various data/library paths automatically if we are run from a build tree 2009-08-21 03:43:53 +02:00
Lennart Poettering
c5bd72509e core: check return value of getgrnam_r() instead of errno
According to POSIX getgrnam_r() returns the error code as return value,
and not in errno. Honour that.

Pointed out and inspired by a patch from Ted Percival.
2009-08-20 00:20:03 +02:00
Lennart Poettering
ef176ecb62 core-util: move personality resetting into core-util 2009-08-12 21:36:52 +02:00
Lennart Poettering
49fd8ee72e core-util: replace remaining fixed size destination string functions by _malloc() versions
This helps portability to GNU/Hurd.

Patch originally from Samuel Thibault but modified.

Closes ticket #546
2009-08-01 02:03:22 +02:00
Lennart Poettering
c6ea9fecc9 core-util: rework pa_strlcpy() to not rely on strncpy()
strncpy() is very slow since it resets the entire destination buffer.
Replace usage of strncpy by memcpy().
2009-08-01 02:01:58 +02:00
Lennart Poettering
e5c2256e36 pipe: replace PIPE_BUF macro pa pa_pipe_buf call
This should help portability to platforms that lack PIPE_BUF. Based on a
patch from Samuel Thibault.

See ticket #546
2009-08-01 01:59:58 +02:00
Lennart Poettering
5a0ef5fd13 daemon: replace colons by dash in per-machine directory names for compat with weird filesystems 2009-07-23 19:12:53 +02:00
Diego Elio 'Flameeyes' Pettenò
1ca7603109 Add missing headers includes for FreeBSD.
This removes the implicit declarations of send() and pthread_sigmask().
2009-06-29 17:42:07 +02:00
Diego Elio 'Flameeyes' Pettenò
bce211e416 Rename the flock variable to f_lock.
flock() is a function on FreeBSD, and the variable shadowed its definition.
2009-06-29 17:41:57 +02:00
Diego Elio 'Flameeyes' Pettenò
6f44792806 Only declare saved_errno when it's going to be used (on Linux). 2009-06-29 17:41:45 +02:00
Lennart Poettering
bacc5ca6f4 core: use rtkit to acquire high-priority scheduling 2009-06-19 04:45:19 +02:00
Lennart Poettering
8474fd7c62 core: ask RealtimeKit for RT scheduling 2009-06-19 04:19:08 +02:00
Lennart Poettering
0fa1ddf838 core-util: implement pa_maybe_prefix_path() 2009-06-17 03:13:59 +02:00
Lennart Poettering
7fa05bea7e core-util: implement pa_split_spaces_strv() 2009-06-17 03:13:32 +02:00
Lennart Poettering
c5dbf754b5 core-util: implement pa_xstrfreev() 2009-06-17 03:13:01 +02:00
Lennart Poettering
759a9d0cc5 core-util: introduce pa_disable_sigpipe() 2009-05-26 00:02:29 +02:00
Lennart Poettering
e2aba1521a core-util: fall back to sysconf(_SC_OPEN_MAX) to find maximum file descriptor 2009-05-22 01:31:56 +02:00
Lennart Poettering
a8f0d7ec1e core-util: introduce pa_get_host_name_malloc() and pa_get_user_name_malloc() 2009-04-29 01:54:44 +02:00
Lennart Poettering
ad447d1468 core-util: handle EINTR already inside of pa_read/pa_write 2009-04-18 23:21:11 +02:00
Lennart Poettering
1d8da03886 core-util: filter utf8 in pa_machine_id() 2009-04-13 22:21:08 +02:00
Lennart Poettering
1b4e5f197a core-util: add pa_session_id() 2009-04-13 22:20:48 +02:00
Maarten Bosmans
8bcb9c6910 various spelling fixes 2009-04-04 02:27:13 +02:00
Finn Thain
5e11972076 revive solaris module
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 with large buffers and
> support rewinding.

I've implemented rewind support, but I'm still not sure that I have
understood the concept; I take it that we "rewind" (from the point-of-view
of the renderer, not the sink) so that some rendered but as yet unplayed
portion of the memblock/buffers can then be rendered again?

> Please keep in mind that the system clock and the sound card clock
> deviate. If you use the system timers to do PCM scheduling ou might need
> a pa_smoother object that is able to estimate the deviation for you.

Actually, in an earlier version I did use a smoother (after reading about
that in the wiki). But because of the non-monotonic sample counter (bug?)
I decided that it probably wasn't worth the added complexity so I removed
it. I'll put the smoother back if I can figure out the problem with the
sample counter.

>
> > +    u->frame_size = pa_frame_size(&ss);
> >
> > -    if ((fd = open(p = pa_modargs_get_value(ma, "device", DEFAULT_DEVICE), mode | O_NONBLOCK)) < 0)
> > +    u->buffer_size = 16384;
>
> It would appear more appropriate to me if the buffer size is adjusted by
> the sample spec used.

Done.

> One last thing: it would probably be a good idea to allocate a pa_card
> object and attach the sink and the source to it.

It is possible to open /dev/audio twice by loading the solaris module
twice -- once for the sink (passing record=0) and once for source (passing
playback=0), thus giving seperate threads/LWPs for source and sink. It
might be misleading to allocate two cards in that situation?

> Right now pa_cards are mostly useful for switching profiles but even if
> you do not allow switching profiles on-the-fly it is of some value to
> find out via the cards object which source belongs to which sink.
>
> Otherwise I am happy!
>
> Thanks for your patch! I'd be thankful if you could fix the issues
> pointed out and prepare another patch on top of current git!

No problem. Patch follows. It also includes a portability fix for
pa_realpath and a fix for a bug in the pa_signal_new() error path that
causes signal data be freed if you attempt to register the same signal
twice.

> I hope I answered all your questions,

Your answers were very helpful, thanks.

Finn

>
> Lennart
>
>
2009-03-31 01:23:36 +02:00
Lennart Poettering
87d63b19a3 Small fix for MacOSX compat
Issue originally pointed out by Igor Zubkov.
2009-03-27 14:37:58 +01:00
Finn Thain
0329edd179 revive solaris module
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
2009-03-03 22:27:00 +01:00
Marc-André Lureau
800489eea9 pulsecore: don't leak p when make_random_dir_and_link() 2009-02-19 05:00:17 +01:00
Marc-André Lureau
f1dcbe0f5d pulsecore: don't leak d in case of error 2009-02-19 04:59:26 +01:00
Marc-André Lureau
4f1380b713 pulsecore: use r returned from fgets() 2009-02-19 04:56:44 +01:00
Lennart Poettering
7b8bed3e28 introduce pa_realpath() 2009-02-18 21:57:57 +01:00
Lennart Poettering
d85ef71675 export pa_match() 2009-02-18 21:57:16 +01:00
Lennart Poettering
04c3c6716b A few MacOS X portability fixes
Based on patches contributed by "Tron".

See bug #478.
2009-02-06 00:25:47 +01:00
Lennart Poettering
83ddc0936e add new calls pa_replace() and pa_unescape() 2009-02-04 17:19:15 +01:00
Lennart Poettering
4dc1916467 add API pa_ncpus() 2009-01-22 02:17:19 +01:00
Jared D. McNeill
c0e4e5a868 NetBSD doesn't know getgrnam_r()/getpwnam_r()
Signed-off-by: Lennart Poettering <lennart@poettering.net>
2009-01-22 02:17:10 +01:00
Lennart Poettering
c850aa0c5b Add new pa_reduce() and pa_gcd() functions 2009-01-10 02:53:57 +01:00
Lennart Poettering
8222f1200f add new API function pa_in_valgrind() to check for 2008-10-04 00:10:43 +02:00
Lennart Poettering
644f39d261 a few FreeBSD fixes, from alexis
Signed-off-by: Lennart Poettering <lennart@poettering.net>
2008-10-01 01:31:56 +02:00
Stelian Ionescu
564ef2b71f have make_random_dir respect $TMPDIR
with the attached patch, make_random_dir first tries to use $TMPDIR,
then $TMP finally defaulting to "/tmp"

Signed-off-by: Lennart Poettering <lennart@poettering.net>
2008-09-29 21:59:57 +02:00
Lennart Poettering
6188737021 make sure ~/.pulse exists before we create the runtime dir link beneath it 2008-09-12 17:39:08 +03:00
Lennart Poettering
33d349dcbb include build and runtime host information in debug output 2008-09-05 15:42:39 +03:00
Lennart Poettering
99d5ec6c93 Rework pa_machine_id() a bit
Guarantee this function never fails, use POSIX gethostid as last resort. Add
comments.
2008-09-03 18:30:27 +02:00
Lennart Poettering
0a1f654c20 call close() in a loop to catch EINTR 2008-08-26 15:44:55 +02:00
Lennart Poettering
dc9b8dce30 add a few missing casts 2008-08-20 03:33:06 +03:00
Lennart Poettering
b7026bf248 add a few more gcc warning flags and fix quite a few problems found by doing so 2008-08-19 22:39:54 +02:00
Lennart Poettering
9996213c41 free regex_t after use 2008-08-09 16:12:50 +02:00
Lennart Poettering
d8119afeef set errno properly in all functions from core-util.c 2008-08-09 03:46:46 +02:00
Lennart Poettering
9cf1a4e5c4 add locale support to pa_parse_boolean() 2008-08-09 03:46:23 +02:00
Lennart Poettering
75b28e97fa remove some leftover debug string 2008-08-07 02:29:44 +02:00
Lennart Poettering
ecb2bc4f04 Modify pa_state_path() to take an additional argument for prepending the machine id to the file name. 2008-08-07 02:28:47 +02:00
Lennart Poettering
bd05b36a1e Rework state/runtime directory logic
The runtime directory is now guaranteed to be in /tmp which will hopefully
provide support for POSIX file locking and UNIX sockets.

The state directory stays in $HOME.
2008-08-07 02:25:48 +02:00