summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/core-util.c
Commit message (Collapse)AuthorAgeFilesLines
* core-util: ensure that we chmod only the dir we ourselves createdKees Cook2010-05-081-5/+34
|
* core-util: introduce generic function pa_strip()Lennart Poettering2010-02-211-4/+24
|
* fix a number of warningsDaniel Mack2010-01-051-2/+2
| | | | | most of them were due to missing #ifdefs or wrong printf format type for [s]size_t.
* core: make cpuid code compile cleanly with 32bit PICLennart Poettering2009-11-111-2/+6
|
* core-util: add call to detect if we are called from within a VMLennart Poettering2009-11-051-0/+89
|
* daemon: make sure pa has its own session and process group, but is not its ↵Lennart Poettering2009-10-311-0/+16
| | | | leader so that we cannot acquire a tty ever
* use pa_fopen_cloexec() where applicableLennart Poettering2009-10-301-4/+4
|
* core-util: introduce pa_fopen_cloexec()Lennart Poettering2009-10-301-2/+27
|
* core-util: make sure to enable FD_CLOEXEC unconditionally to cope with ↵Lennart Poettering2009-10-301-3/+12
| | | | kernels that silently accept but ignore O_CLOEXEC
* use cloexec wrappers wherever applicableLennart Poettering2009-10-301-4/+1
|
* core-util: introduce FD_CLOEXEC wrappers for open/socket/pipe/acceptLennart Poettering2009-10-301-0/+79
|
* Merge branch 'master' into dbus-workTanu Kaskinen2009-10-021-19/+71
|\ | | | | | | | | Conflicts: src/daemon/daemon-conf.c
| * core-util: unify how we determine the temporary directoryLennart Poettering2009-09-171-10/+23
| |
| * Improve TMPDIR handlingLennart Poettering2009-09-171-1/+1
| | | | | | | | | | | | Patch from 'jnelson', http://pulseaudio.org/ticket/653
| * core-util: properly fill in exception array for pa_reset_sigs() ↵Lennart Poettering2009-09-081-1/+1
| | | | | | | | (llvm-clang-analyzer)
| * llvm-clang-analyzer: drop a few unnecessary assignments and other trivial fixesLennart Poettering2009-09-081-8/+5
| |
| * Merge branch 'master' of ssh://rootserver/home/lennart/git/public/pulseaudioLennart Poettering2009-09-021-0/+10
| |\
| | * core-util: call dbus_connection_set_exit_on_disconnect() on shared busses to ↵Lennart Poettering2009-09-021-0/+10
| | | | | | | | | | | | make sure dbus_shutdown() isn't fatal
| * | core-util: don't leak memory in pa_unset_env_recorded()Lennart Poettering2009-09-021-2/+4
| |/
| * core-util: add api for setting env vars and record them so that we can undo ↵Lennart Poettering2009-09-021-0/+30
| | | | | | | | them n fork
* | Merge branch 'master' of git://0pointer.de/pulseaudio into dbus-workTanu Kaskinen2009-08-301-6/+6
|\| | | | | | | | | Conflicts: src/modules/module-stream-restore.c
| * core-util: Fix logic of pa_make_path_absolute()Andy Shevchenko2009-08-281-6/+6
| | | | | | | | | | Make it works as described in commentary (when fn is NULL, pa_assert(fn) could break logic).
* | Merge branch 'master' of git://0pointer.de/pulseaudio into dbus-workTanu Kaskinen2009-08-241-95/+42
|\| | | | | | | | | Conflicts: src/Makefile.am
| * port a few things over to use xmalloc and friends instead of low-level libc ↵Lennart Poettering2009-08-231-1/+1
| | | | | | | | malloc/free directly
| * core: Add thread-safe group info functions with dynamic buffersTed Percival2009-08-221-86/+20
| | | | | | | | | | | | | | 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.
| * adjust various data/library paths automatically if we are run from a build treeLennart Poettering2009-08-211-0/+19
| |
| * core: check return value of getgrnam_r() instead of errnoLennart Poettering2009-08-201-40/+34
| | | | | | | | | | | | | | 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.
* | Merge branch 'master' of git://0pointer.de/pulseaudio into dbus-workTanu Kaskinen2009-08-161-15/+104
|\| | | | | | | | | | | | | | | | | | | 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
| * core-util: move personality resetting into core-utilLennart Poettering2009-08-121-0/+13
| |
| * core-util: replace remaining fixed size destination string functions by ↵Lennart Poettering2009-08-011-11/+63
| | | | | | | | | | | | | | | | | | | | _malloc() versions This helps portability to GNU/Hurd. Patch originally from Samuel Thibault but modified. Closes ticket #546
| * core-util: rework pa_strlcpy() to not rely on strncpy()Lennart Poettering2009-08-011-2/+10
| | | | | | | | | | strncpy() is very slow since it resets the entire destination buffer. Replace usage of strncpy by memcpy().
| * pipe: replace PIPE_BUF macro pa pa_pipe_buf callLennart Poettering2009-08-011-0/+16
| | | | | | | | | | | | | | This should help portability to platforms that lack PIPE_BUF. Based on a patch from Samuel Thibault. See ticket #546
| * daemon: replace colons by dash in per-machine directory names for compat ↵Lennart Poettering2009-07-231-2/+2
| | | | | | | | with weird filesystems
* | Finish the Core dbus interface.Tanu Kaskinen2009-07-211-0/+22
|/
* Add missing headers includes for FreeBSD.Diego Elio 'Flameeyes' Pettenò2009-06-291-0/+1
| | | | This removes the implicit declarations of send() and pthread_sigmask().
* Rename the flock variable to f_lock.Diego Elio 'Flameeyes' Pettenò2009-06-291-8/+8
| | | | flock() is a function on FreeBSD, and the variable shadowed its definition.
* Only declare saved_errno when it's going to be used (on Linux).Diego Elio 'Flameeyes' Pettenò2009-06-291-2/+1
|
* core: use rtkit to acquire high-priority schedulingLennart Poettering2009-06-191-104/+46
|
* core: ask RealtimeKit for RT schedulingLennart Poettering2009-06-191-18/+78
|
* core-util: implement pa_maybe_prefix_path()Lennart Poettering2009-06-171-0/+9
|
* core-util: implement pa_split_spaces_strv()Lennart Poettering2009-06-171-0/+24
|
* core-util: implement pa_xstrfreev()Lennart Poettering2009-06-171-0/+12
|
* core-util: introduce pa_disable_sigpipe()Lennart Poettering2009-05-261-0/+21
|
* core-util: fall back to sysconf(_SC_OPEN_MAX) to find maximum file descriptorLennart Poettering2009-05-221-4/+6
|
* core-util: introduce pa_get_host_name_malloc() and pa_get_user_name_malloc()Lennart Poettering2009-04-291-19/+46
|
* core-util: handle EINTR already inside of pa_read/pa_writeLennart Poettering2009-04-181-7/+32
|
* core-util: filter utf8 in pa_machine_id()Lennart Poettering2009-04-131-3/+6
|
* core-util: add pa_session_id()Lennart Poettering2009-04-131-0/+9
|
* various spelling fixesMaarten Bosmans2009-04-041-2/+2
|
* revive solaris moduleFinn Thain2009-03-311-10/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 > >