Commit graph

104 commits

Author SHA1 Message Date
Lennart Poettering
752727a13d core-util: introduce pa_fopen_cloexec() 2009-10-30 04:20:24 +01:00
Lennart Poettering
a698ee3f52 core-util: make sure to enable FD_CLOEXEC unconditionally to cope with kernels that silently accept but ignore O_CLOEXEC 2009-10-30 04:16:59 +01:00
Lennart Poettering
65e7bc18a9 use cloexec wrappers wherever applicable 2009-10-30 03:32:38 +01:00
Lennart Poettering
9c1a98953f core-util: introduce FD_CLOEXEC wrappers for open/socket/pipe/accept 2009-10-30 03:30:42 +01:00
Tanu Kaskinen
019331d25b Merge branch 'master' into dbus-work
Conflicts:
	src/daemon/daemon-conf.c
2009-10-02 17:24:44 +03:00
Lennart Poettering
7b76ea3784 core-util: unify how we determine the temporary directory 2009-09-17 21:06:54 +02:00
Lennart Poettering
2d9168ceb3 Improve TMPDIR handling
Patch from 'jnelson',

http://pulseaudio.org/ticket/653
2009-09-17 20:58:36 +02:00
Lennart Poettering
31ae7deefa core-util: properly fill in exception array for pa_reset_sigs() (llvm-clang-analyzer) 2009-09-08 23:52:58 +02:00
Lennart Poettering
f5046759cd llvm-clang-analyzer: drop a few unnecessary assignments and other trivial fixes 2009-09-08 23:46:23 +02:00
Lennart Poettering
51fc1763a1 Merge branch 'master' of ssh://rootserver/home/lennart/git/public/pulseaudio 2009-09-02 04:06:04 +02:00
Lennart Poettering
297afadbef core-util: don't leak memory in pa_unset_env_recorded() 2009-09-02 04:05:34 +02:00
Lennart Poettering
767c7c7cf4 core-util: call dbus_connection_set_exit_on_disconnect() on shared busses to make sure dbus_shutdown() isn't fatal 2009-09-02 04:03:18 +02:00
Lennart Poettering
5f929963d1 core-util: add api for setting env vars and record them so that we can undo them n fork 2009-09-02 00:34:27 +02:00
Tanu Kaskinen
0ad2d55cbe Merge branch 'master' of git://0pointer.de/pulseaudio into dbus-work
Conflicts:
	src/modules/module-stream-restore.c
2009-08-30 20:07:31 +03:00
Andy Shevchenko
ae383539d7 core-util: Fix logic of pa_make_path_absolute()
Make it works as described in commentary (when fn is NULL, pa_assert(fn) could
break logic).
2009-08-28 17:12:26 +02:00
Tanu Kaskinen
2f3fc2f1d6 Merge branch 'master' of git://0pointer.de/pulseaudio into dbus-work
Conflicts:
	src/Makefile.am
2009-08-24 14:43:11 +03:00
Lennart Poettering
a0f01ddc95 port a few things over to use xmalloc and friends instead of low-level libc malloc/free directly 2009-08-23 21:49:37 +02:00
Ted Percival
15eb03a5b3 core: Add thread-safe group info functions with dynamic buffers
Provides getgrgid, getgrnam, getpwuid & getpwnam replacements that are
thread safe (a la getgrgid_r() and friends) that internally
handle allocating big-enough buffers to avoid ERANGE errors
on large users or groups.
2009-08-22 00:53:39 +02:00
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
Tanu Kaskinen
bcaba0b1b4 Merge branch 'master' of git://0pointer.de/pulseaudio into dbus-work
Conflicts:
	src/Makefile.am
	src/daemon/daemon-conf.c
	src/daemon/daemon.conf.in
	src/modules/module-stream-restore.c
	src/pulse/client-conf.c
	src/pulsecore/namereg.c
2009-08-16 21:25:48 +03: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
Tanu Kaskinen
9347e90fed Finish the Core dbus interface. 2009-07-21 00:02:27 +03: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