From 1a5df71be95ee93531f08e16293f2dfe20a47dc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Pierret=20=28fepitre=29?= Date: Wed, 2 Dec 2020 23:24:40 +0100 Subject: [PATCH] Add pulseaudio-14.0 headers --- archlinux/PKGBUILD | 2 +- pulse/pulsecore-14.0/arpa-inet.h | 21 + pulse/pulsecore-14.0/asyncmsgq.h | 81 +++ pulse/pulsecore-14.0/asyncq.h | 64 +++ pulse/pulsecore-14.0/atomic.h | 683 +++++++++++++++++++++++ pulse/pulsecore-14.0/aupdate.h | 100 ++++ pulse/pulsecore-14.0/auth-cookie.h | 34 ++ pulse/pulsecore-14.0/authkey.h | 29 + pulse/pulsecore-14.0/avahi-wrap.h | 30 + pulse/pulsecore-14.0/bitset.h | 35 ++ pulse/pulsecore-14.0/card.h | 147 +++++ pulse/pulsecore-14.0/cli-command.h | 44 ++ pulse/pulsecore-14.0/cli-text.h | 39 ++ pulse/pulsecore-14.0/cli.h | 40 ++ pulse/pulsecore-14.0/client.h | 83 +++ pulse/pulsecore-14.0/conf-parser.h | 87 +++ pulse/pulsecore-14.0/core-error.h | 39 ++ pulse/pulsecore-14.0/core-format.h | 59 ++ pulse/pulsecore-14.0/core-rtclock.h | 53 ++ pulse/pulsecore-14.0/core-scache.h | 68 +++ pulse/pulsecore-14.0/core-subscribe.h | 37 ++ pulse/pulsecore-14.0/core-util.h | 323 +++++++++++ pulse/pulsecore-14.0/core.h | 287 ++++++++++ pulse/pulsecore-14.0/cpu-arm.h | 53 ++ pulse/pulsecore-14.0/cpu-orc.h | 31 + pulse/pulsecore-14.0/cpu-x86.h | 59 ++ pulse/pulsecore-14.0/cpu.h | 49 ++ pulse/pulsecore-14.0/creds.h | 64 +++ pulse/pulsecore-14.0/database.h | 59 ++ pulse/pulsecore-14.0/dbus-shared.h | 40 ++ pulse/pulsecore-14.0/dbus-util.h | 114 ++++ pulse/pulsecore-14.0/device-port.h | 100 ++++ pulse/pulsecore-14.0/dynarray.h | 73 +++ pulse/pulsecore-14.0/endianmacros.h | 160 ++++++ pulse/pulsecore-14.0/esound.h | 204 +++++++ pulse/pulsecore-14.0/fdsem.h | 53 ++ pulse/pulsecore-14.0/ffmpeg/avcodec.h | 81 +++ pulse/pulsecore-14.0/ffmpeg/dsputil.h | 1 + pulse/pulsecore-14.0/filter/biquad.h | 45 ++ pulse/pulsecore-14.0/filter/crossover.h | 29 + pulse/pulsecore-14.0/filter/lfe-filter.h | 39 ++ pulse/pulsecore-14.0/flist.h | 70 +++ pulse/pulsecore-14.0/g711.h | 40 ++ pulse/pulsecore-14.0/hashmap.h | 101 ++++ pulse/pulsecore-14.0/hook-list.h | 71 +++ pulse/pulsecore-14.0/i18n.h | 62 ++ pulse/pulsecore-14.0/idxset.h | 116 ++++ pulse/pulsecore-14.0/iochannel.h | 89 +++ pulse/pulsecore-14.0/ioline.h | 63 +++ pulse/pulsecore-14.0/ipacl.h | 30 + pulse/pulsecore-14.0/llist.h | 111 ++++ pulse/pulsecore-14.0/lock-autospawn.h | 30 + pulse/pulsecore-14.0/log.h | 155 +++++ pulse/pulsecore-14.0/ltdl-helper.h | 29 + pulse/pulsecore-14.0/macro.h | 272 +++++++++ pulse/pulsecore-14.0/mcalign.h | 81 +++ pulse/pulsecore-14.0/mem.h | 60 ++ pulse/pulsecore-14.0/memblock.h | 159 ++++++ pulse/pulsecore-14.0/memblockq.h | 187 +++++++ pulse/pulsecore-14.0/memchunk.h | 56 ++ pulse/pulsecore-14.0/memfd-wrappers.h | 69 +++ pulse/pulsecore-14.0/memtrap.h | 49 ++ pulse/pulsecore-14.0/message-handler.h | 50 ++ pulse/pulsecore-14.0/mime-type.h | 31 + pulse/pulsecore-14.0/mix.h | 62 ++ pulse/pulsecore-14.0/modargs.h | 98 ++++ pulse/pulsecore-14.0/modinfo.h | 44 ++ pulse/pulsecore-14.0/module.h | 129 +++++ pulse/pulsecore-14.0/msgobject.h | 46 ++ pulse/pulsecore-14.0/mutex.h | 57 ++ pulse/pulsecore-14.0/namereg.h | 43 ++ pulse/pulsecore-14.0/native-common.h | 209 +++++++ pulse/pulsecore-14.0/object.h | 117 ++++ pulse/pulsecore-14.0/once.h | 71 +++ pulse/pulsecore-14.0/packet.h | 45 ++ pulse/pulsecore-14.0/parseaddr.h | 46 ++ pulse/pulsecore-14.0/pdispatch.h | 56 ++ pulse/pulsecore-14.0/pid.h | 28 + pulse/pulsecore-14.0/pipe.h | 29 + pulse/pulsecore-14.0/play-memblockq.h | 47 ++ pulse/pulsecore-14.0/play-memchunk.h | 36 ++ pulse/pulsecore-14.0/poll.h | 62 ++ pulse/pulsecore-14.0/proplist-util.h | 28 + pulse/pulsecore-14.0/protocol-cli.h | 36 ++ pulse/pulsecore-14.0/protocol-dbus.h | 215 +++++++ pulse/pulsecore-14.0/protocol-esound.h | 56 ++ pulse/pulsecore-14.0/protocol-http.h | 41 ++ pulse/pulsecore-14.0/protocol-native.h | 88 +++ pulse/pulsecore-14.0/protocol-simple.h | 55 ++ pulse/pulsecore-14.0/pstream-util.h | 39 ++ pulse/pulsecore-14.0/pstream.h | 76 +++ pulse/pulsecore-14.0/queue.h | 41 ++ pulse/pulsecore-14.0/random.h | 29 + pulse/pulsecore-14.0/ratelimit.h | 55 ++ pulse/pulsecore-14.0/refcnt.h | 79 +++ pulse/pulsecore-14.0/remap.h | 60 ++ pulse/pulsecore-14.0/resampler.h | 181 ++++++ pulse/pulsecore-14.0/rtkit.h | 79 +++ pulse/pulsecore-14.0/rtpoll.h | 100 ++++ pulse/pulsecore-14.0/sample-util.h | 154 +++++ pulse/pulsecore-14.0/sconv-s16be.h | 67 +++ pulse/pulsecore-14.0/sconv-s16le.h | 67 +++ pulse/pulsecore-14.0/sconv.h | 41 ++ pulse/pulsecore-14.0/semaphore.h | 46 ++ pulse/pulsecore-14.0/shared.h | 55 ++ pulse/pulsecore-14.0/shm.h | 61 ++ pulse/pulsecore-14.0/sink-input.h | 469 ++++++++++++++++ pulse/pulsecore-14.0/sink.h | 575 +++++++++++++++++++ pulse/pulsecore-14.0/sioman.h | 26 + pulse/pulsecore-14.0/sndfile-util.h | 50 ++ pulse/pulsecore-14.0/socket-client.h | 48 ++ pulse/pulsecore-14.0/socket-server.h | 53 ++ pulse/pulsecore-14.0/socket-util.h | 44 ++ pulse/pulsecore-14.0/socket.h | 20 + pulse/pulsecore-14.0/sound-file-stream.h | 27 + pulse/pulsecore-14.0/sound-file.h | 31 + pulse/pulsecore-14.0/source-output.h | 410 ++++++++++++++ pulse/pulsecore-14.0/source.h | 493 ++++++++++++++++ pulse/pulsecore-14.0/srbchannel.h | 57 ++ pulse/pulsecore-14.0/start-child.h | 28 + pulse/pulsecore-14.0/strbuf.h | 40 ++ pulse/pulsecore-14.0/stream-util.h | 48 ++ pulse/pulsecore-14.0/strlist.h | 54 ++ pulse/pulsecore-14.0/tagstruct.h | 106 ++++ pulse/pulsecore-14.0/thread-mq.h | 57 ++ pulse/pulsecore-14.0/thread.h | 117 ++++ pulse/pulsecore-14.0/time-smoother.h | 57 ++ pulse/pulsecore-14.0/tokenizer.h | 30 + pulse/pulsecore-14.0/typedefs.h | 37 ++ pulse/pulsecore-14.0/usergroup.h | 49 ++ pulse/pulsecore-14.0/winerrno.h | 89 +++ pulse/pulsecore-14.0/x11prop.h | 32 ++ pulse/pulsecore-14.0/x11wrap.h | 60 ++ rpm_spec/gui-agent.spec.in | 2 +- 134 files changed, 11701 insertions(+), 2 deletions(-) create mode 100644 pulse/pulsecore-14.0/arpa-inet.h create mode 100644 pulse/pulsecore-14.0/asyncmsgq.h create mode 100644 pulse/pulsecore-14.0/asyncq.h create mode 100644 pulse/pulsecore-14.0/atomic.h create mode 100644 pulse/pulsecore-14.0/aupdate.h create mode 100644 pulse/pulsecore-14.0/auth-cookie.h create mode 100644 pulse/pulsecore-14.0/authkey.h create mode 100644 pulse/pulsecore-14.0/avahi-wrap.h create mode 100644 pulse/pulsecore-14.0/bitset.h create mode 100644 pulse/pulsecore-14.0/card.h create mode 100644 pulse/pulsecore-14.0/cli-command.h create mode 100644 pulse/pulsecore-14.0/cli-text.h create mode 100644 pulse/pulsecore-14.0/cli.h create mode 100644 pulse/pulsecore-14.0/client.h create mode 100644 pulse/pulsecore-14.0/conf-parser.h create mode 100644 pulse/pulsecore-14.0/core-error.h create mode 100644 pulse/pulsecore-14.0/core-format.h create mode 100644 pulse/pulsecore-14.0/core-rtclock.h create mode 100644 pulse/pulsecore-14.0/core-scache.h create mode 100644 pulse/pulsecore-14.0/core-subscribe.h create mode 100644 pulse/pulsecore-14.0/core-util.h create mode 100644 pulse/pulsecore-14.0/core.h create mode 100644 pulse/pulsecore-14.0/cpu-arm.h create mode 100644 pulse/pulsecore-14.0/cpu-orc.h create mode 100644 pulse/pulsecore-14.0/cpu-x86.h create mode 100644 pulse/pulsecore-14.0/cpu.h create mode 100644 pulse/pulsecore-14.0/creds.h create mode 100644 pulse/pulsecore-14.0/database.h create mode 100644 pulse/pulsecore-14.0/dbus-shared.h create mode 100644 pulse/pulsecore-14.0/dbus-util.h create mode 100644 pulse/pulsecore-14.0/device-port.h create mode 100644 pulse/pulsecore-14.0/dynarray.h create mode 100644 pulse/pulsecore-14.0/endianmacros.h create mode 100644 pulse/pulsecore-14.0/esound.h create mode 100644 pulse/pulsecore-14.0/fdsem.h create mode 100644 pulse/pulsecore-14.0/ffmpeg/avcodec.h create mode 100644 pulse/pulsecore-14.0/ffmpeg/dsputil.h create mode 100644 pulse/pulsecore-14.0/filter/biquad.h create mode 100644 pulse/pulsecore-14.0/filter/crossover.h create mode 100644 pulse/pulsecore-14.0/filter/lfe-filter.h create mode 100644 pulse/pulsecore-14.0/flist.h create mode 100644 pulse/pulsecore-14.0/g711.h create mode 100644 pulse/pulsecore-14.0/hashmap.h create mode 100644 pulse/pulsecore-14.0/hook-list.h create mode 100644 pulse/pulsecore-14.0/i18n.h create mode 100644 pulse/pulsecore-14.0/idxset.h create mode 100644 pulse/pulsecore-14.0/iochannel.h create mode 100644 pulse/pulsecore-14.0/ioline.h create mode 100644 pulse/pulsecore-14.0/ipacl.h create mode 100644 pulse/pulsecore-14.0/llist.h create mode 100644 pulse/pulsecore-14.0/lock-autospawn.h create mode 100644 pulse/pulsecore-14.0/log.h create mode 100644 pulse/pulsecore-14.0/ltdl-helper.h create mode 100644 pulse/pulsecore-14.0/macro.h create mode 100644 pulse/pulsecore-14.0/mcalign.h create mode 100644 pulse/pulsecore-14.0/mem.h create mode 100644 pulse/pulsecore-14.0/memblock.h create mode 100644 pulse/pulsecore-14.0/memblockq.h create mode 100644 pulse/pulsecore-14.0/memchunk.h create mode 100644 pulse/pulsecore-14.0/memfd-wrappers.h create mode 100644 pulse/pulsecore-14.0/memtrap.h create mode 100644 pulse/pulsecore-14.0/message-handler.h create mode 100644 pulse/pulsecore-14.0/mime-type.h create mode 100644 pulse/pulsecore-14.0/mix.h create mode 100644 pulse/pulsecore-14.0/modargs.h create mode 100644 pulse/pulsecore-14.0/modinfo.h create mode 100644 pulse/pulsecore-14.0/module.h create mode 100644 pulse/pulsecore-14.0/msgobject.h create mode 100644 pulse/pulsecore-14.0/mutex.h create mode 100644 pulse/pulsecore-14.0/namereg.h create mode 100644 pulse/pulsecore-14.0/native-common.h create mode 100644 pulse/pulsecore-14.0/object.h create mode 100644 pulse/pulsecore-14.0/once.h create mode 100644 pulse/pulsecore-14.0/packet.h create mode 100644 pulse/pulsecore-14.0/parseaddr.h create mode 100644 pulse/pulsecore-14.0/pdispatch.h create mode 100644 pulse/pulsecore-14.0/pid.h create mode 100644 pulse/pulsecore-14.0/pipe.h create mode 100644 pulse/pulsecore-14.0/play-memblockq.h create mode 100644 pulse/pulsecore-14.0/play-memchunk.h create mode 100644 pulse/pulsecore-14.0/poll.h create mode 100644 pulse/pulsecore-14.0/proplist-util.h create mode 100644 pulse/pulsecore-14.0/protocol-cli.h create mode 100644 pulse/pulsecore-14.0/protocol-dbus.h create mode 100644 pulse/pulsecore-14.0/protocol-esound.h create mode 100644 pulse/pulsecore-14.0/protocol-http.h create mode 100644 pulse/pulsecore-14.0/protocol-native.h create mode 100644 pulse/pulsecore-14.0/protocol-simple.h create mode 100644 pulse/pulsecore-14.0/pstream-util.h create mode 100644 pulse/pulsecore-14.0/pstream.h create mode 100644 pulse/pulsecore-14.0/queue.h create mode 100644 pulse/pulsecore-14.0/random.h create mode 100644 pulse/pulsecore-14.0/ratelimit.h create mode 100644 pulse/pulsecore-14.0/refcnt.h create mode 100644 pulse/pulsecore-14.0/remap.h create mode 100644 pulse/pulsecore-14.0/resampler.h create mode 100644 pulse/pulsecore-14.0/rtkit.h create mode 100644 pulse/pulsecore-14.0/rtpoll.h create mode 100644 pulse/pulsecore-14.0/sample-util.h create mode 100644 pulse/pulsecore-14.0/sconv-s16be.h create mode 100644 pulse/pulsecore-14.0/sconv-s16le.h create mode 100644 pulse/pulsecore-14.0/sconv.h create mode 100644 pulse/pulsecore-14.0/semaphore.h create mode 100644 pulse/pulsecore-14.0/shared.h create mode 100644 pulse/pulsecore-14.0/shm.h create mode 100644 pulse/pulsecore-14.0/sink-input.h create mode 100644 pulse/pulsecore-14.0/sink.h create mode 100644 pulse/pulsecore-14.0/sioman.h create mode 100644 pulse/pulsecore-14.0/sndfile-util.h create mode 100644 pulse/pulsecore-14.0/socket-client.h create mode 100644 pulse/pulsecore-14.0/socket-server.h create mode 100644 pulse/pulsecore-14.0/socket-util.h create mode 100644 pulse/pulsecore-14.0/socket.h create mode 100644 pulse/pulsecore-14.0/sound-file-stream.h create mode 100644 pulse/pulsecore-14.0/sound-file.h create mode 100644 pulse/pulsecore-14.0/source-output.h create mode 100644 pulse/pulsecore-14.0/source.h create mode 100644 pulse/pulsecore-14.0/srbchannel.h create mode 100644 pulse/pulsecore-14.0/start-child.h create mode 100644 pulse/pulsecore-14.0/strbuf.h create mode 100644 pulse/pulsecore-14.0/stream-util.h create mode 100644 pulse/pulsecore-14.0/strlist.h create mode 100644 pulse/pulsecore-14.0/tagstruct.h create mode 100644 pulse/pulsecore-14.0/thread-mq.h create mode 100644 pulse/pulsecore-14.0/thread.h create mode 100644 pulse/pulsecore-14.0/time-smoother.h create mode 100644 pulse/pulsecore-14.0/tokenizer.h create mode 100644 pulse/pulsecore-14.0/typedefs.h create mode 100644 pulse/pulsecore-14.0/usergroup.h create mode 100644 pulse/pulsecore-14.0/winerrno.h create mode 100644 pulse/pulsecore-14.0/x11prop.h create mode 100644 pulse/pulsecore-14.0/x11wrap.h diff --git a/archlinux/PKGBUILD b/archlinux/PKGBUILD index 0b3f0403..2444b2db 100644 --- a/archlinux/PKGBUILD +++ b/archlinux/PKGBUILD @@ -71,7 +71,7 @@ install -D $srcdir/PKGBUILD-z-qubes-session.sh $pkgdir/etc/X11/xinit/xinitrc.d/z package_qubes-vm-pulseaudio() { pkgdesc="Pulseaudio support for Qubes VM" -depends=( 'alsa-lib' 'alsa-utils' 'pulseaudio-alsa' 'pulseaudio<14.0') +depends=('alsa-lib' 'alsa-utils' 'pulseaudio-alsa' 'pulseaudio<14.1') install=PKGBUILD-pulseaudio.install pa_ver=$((pkg-config --modversion libpulse 2>/dev/null || echo 0.0) | cut -f 1 -d "-") diff --git a/pulse/pulsecore-14.0/arpa-inet.h b/pulse/pulsecore-14.0/arpa-inet.h new file mode 100644 index 00000000..d940f704 --- /dev/null +++ b/pulse/pulsecore-14.0/arpa-inet.h @@ -0,0 +1,21 @@ +#ifndef fooarpa_inethfoo +#define fooarpa_inethfoo + +#if defined(HAVE_ARPA_INET_H) + +#include + +#elif defined(OS_IS_WIN32) + +/* On Windows winsock2.h (here included via pulsecore/socket.h) provides most of the functionality of arpa/inet.h, except for + * the inet_ntop and inet_pton functions, which are implemented here. */ + +#include + +const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt); + +int inet_pton(int af, const char *src, void *dst); + +#endif + +#endif diff --git a/pulse/pulsecore-14.0/asyncmsgq.h b/pulse/pulsecore-14.0/asyncmsgq.h new file mode 100644 index 00000000..367ccac2 --- /dev/null +++ b/pulse/pulsecore-14.0/asyncmsgq.h @@ -0,0 +1,81 @@ +#ifndef foopulseasyncmsgqhfoo +#define foopulseasyncmsgqhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include + +#include +#include +#include + +/* A simple asynchronous message queue, based on pa_asyncq. In + * contrast to pa_asyncq this one is multiple-writer safe, though + * still not multiple-reader safe. This queue is intended to be used + * for controlling real-time threads from normal-priority + * threads. Multiple-writer-safety is accomplished by using a mutex on + * the writer side. This queue is thus not useful for communication + * between several real-time threads. + * + * The queue takes messages consisting of: + * "Object" for which this messages is intended (may be NULL) + * A numeric message code + * Arbitrary userdata pointer (may be NULL) + * A memchunk (may be NULL) + * + * There are two functions for submitting messages: _post and + * _send. The former just enqueues the message asynchronously, the + * latter waits for completion, synchronously. */ + +enum { + PA_MESSAGE_SHUTDOWN = -1/* A generic message to inform the handler of this queue to quit */ +}; + +typedef struct pa_asyncmsgq pa_asyncmsgq; + +pa_asyncmsgq* pa_asyncmsgq_new(unsigned size); +pa_asyncmsgq* pa_asyncmsgq_ref(pa_asyncmsgq *q); + +void pa_asyncmsgq_unref(pa_asyncmsgq* q); + +void pa_asyncmsgq_post(pa_asyncmsgq *q, pa_msgobject *object, int code, const void *userdata, int64_t offset, const pa_memchunk *memchunk, pa_free_cb_t userdata_free_cb); +int pa_asyncmsgq_send(pa_asyncmsgq *q, pa_msgobject *object, int code, const void *userdata, int64_t offset, const pa_memchunk *memchunk); + +int pa_asyncmsgq_get(pa_asyncmsgq *q, pa_msgobject **object, int *code, void **userdata, int64_t *offset, pa_memchunk *memchunk, bool wait); +int pa_asyncmsgq_dispatch(pa_msgobject *object, int code, void *userdata, int64_t offset, pa_memchunk *memchunk); +void pa_asyncmsgq_done(pa_asyncmsgq *q, int ret); +int pa_asyncmsgq_wait_for(pa_asyncmsgq *a, int code); +int pa_asyncmsgq_process_one(pa_asyncmsgq *a); + +void pa_asyncmsgq_flush(pa_asyncmsgq *a, bool run); + +/* For the reading side */ +int pa_asyncmsgq_read_fd(pa_asyncmsgq *q); +int pa_asyncmsgq_read_before_poll(pa_asyncmsgq *a); +void pa_asyncmsgq_read_after_poll(pa_asyncmsgq *a); + +/* For the write side */ +int pa_asyncmsgq_write_fd(pa_asyncmsgq *q); +void pa_asyncmsgq_write_before_poll(pa_asyncmsgq *a); +void pa_asyncmsgq_write_after_poll(pa_asyncmsgq *a); + +bool pa_asyncmsgq_dispatching(pa_asyncmsgq *a); + +#endif diff --git a/pulse/pulsecore-14.0/asyncq.h b/pulse/pulsecore-14.0/asyncq.h new file mode 100644 index 00000000..8c86762e --- /dev/null +++ b/pulse/pulsecore-14.0/asyncq.h @@ -0,0 +1,64 @@ +#ifndef foopulseasyncqhfoo +#define foopulseasyncqhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include +#include +#include + +/* A simple, asynchronous, lock-free (if requested also wait-free) + * queue. Not multiple-reader/multiple-writer safe. If that is + * required both sides can be protected by a mutex each. --- Which is + * not a bad thing in most cases, since this queue is intended for + * communication between a normal thread and a single real-time + * thread. Only the real-time side needs to be lock-free/wait-free. + * + * If the queue is full and another entry shall be pushed, or when the + * queue is empty and another entry shall be popped and the "wait" + * argument is non-zero, the queue will block on a UNIX FIFO object -- + * that will probably require locking on the kernel side -- which + * however is probably not problematic, because we do it only on + * starvation or overload in which case we have to block anyway. */ + +typedef struct pa_asyncq pa_asyncq; + +pa_asyncq* pa_asyncq_new(unsigned size); +void pa_asyncq_free(pa_asyncq* q, pa_free_cb_t free_cb); + +void* pa_asyncq_pop(pa_asyncq *q, bool wait); +int pa_asyncq_push(pa_asyncq *q, void *p, bool wait); + +/* Similar to pa_asyncq_push(), but if the queue is full, postpone the + * appending of the item locally and delay until + * pa_asyncq_before_poll_post() is called. */ +void pa_asyncq_post(pa_asyncq*l, void *p); + +/* For the reading side */ +int pa_asyncq_read_fd(pa_asyncq *q); +int pa_asyncq_read_before_poll(pa_asyncq *a); +void pa_asyncq_read_after_poll(pa_asyncq *a); + +/* For the writing side */ +int pa_asyncq_write_fd(pa_asyncq *q); +void pa_asyncq_write_before_poll(pa_asyncq *a); +void pa_asyncq_write_after_poll(pa_asyncq *a); + +#endif diff --git a/pulse/pulsecore-14.0/atomic.h b/pulse/pulsecore-14.0/atomic.h new file mode 100644 index 00000000..e5c14010 --- /dev/null +++ b/pulse/pulsecore-14.0/atomic.h @@ -0,0 +1,683 @@ +#ifndef foopulseatomichfoo +#define foopulseatomichfoo + +/*** + This file is part of PulseAudio. + + Copyright 2006-2008 Lennart Poettering + Copyright 2008 Nokia Corporation + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include + +/* + * atomic_ops guarantees us that sizeof(AO_t) == sizeof(void*). It is + * not guaranteed however, that sizeof(AO_t) == sizeof(size_t). + * however very likely. + * + * For now we do only full memory barriers. Eventually we might want + * to support more elaborate memory barriers, in which case we will add + * suffixes to the function names. + * + * On gcc >= 4.1 we use the builtin atomic functions. otherwise we use + * libatomic_ops + */ + +#ifndef PACKAGE +#error "Please include config.h before including this file!" +#endif + +#ifdef HAVE_ATOMIC_BUILTINS + +/* __sync based implementation */ + +typedef struct pa_atomic { + volatile int value; +} pa_atomic_t; + +#define PA_ATOMIC_INIT(v) { .value = (v) } + +#ifdef HAVE_ATOMIC_BUILTINS_MEMORY_MODEL + +/* __atomic based implementation */ + +static inline int pa_atomic_load(const pa_atomic_t *a) { + return __atomic_load_n(&a->value, __ATOMIC_SEQ_CST); +} + +static inline void pa_atomic_store(pa_atomic_t *a, int i) { + __atomic_store_n(&a->value, i, __ATOMIC_SEQ_CST); +} + +#else + +static inline int pa_atomic_load(const pa_atomic_t *a) { + __sync_synchronize(); + return a->value; +} + +static inline void pa_atomic_store(pa_atomic_t *a, int i) { + a->value = i; + __sync_synchronize(); +} + +#endif + + +/* Returns the previously set value */ +static inline int pa_atomic_add(pa_atomic_t *a, int i) { + return __sync_fetch_and_add(&a->value, i); +} + +/* Returns the previously set value */ +static inline int pa_atomic_sub(pa_atomic_t *a, int i) { + return __sync_fetch_and_sub(&a->value, i); +} + +/* Returns the previously set value */ +static inline int pa_atomic_inc(pa_atomic_t *a) { + return pa_atomic_add(a, 1); +} + +/* Returns the previously set value */ +static inline int pa_atomic_dec(pa_atomic_t *a) { + return pa_atomic_sub(a, 1); +} + +/* Returns true when the operation was successful. */ +static inline bool pa_atomic_cmpxchg(pa_atomic_t *a, int old_i, int new_i) { + return __sync_bool_compare_and_swap(&a->value, old_i, new_i); +} + +typedef struct pa_atomic_ptr { + volatile unsigned long value; +} pa_atomic_ptr_t; + +#define PA_ATOMIC_PTR_INIT(v) { .value = (long) (v) } + +#ifdef HAVE_ATOMIC_BUILTINS_MEMORY_MODEL + +/* __atomic based implementation */ + +static inline void* pa_atomic_ptr_load(const pa_atomic_ptr_t *a) { + return (void*) __atomic_load_n(&a->value, __ATOMIC_SEQ_CST); +} + +static inline void pa_atomic_ptr_store(pa_atomic_ptr_t *a, void* p) { + __atomic_store_n(&a->value, (unsigned long) p, __ATOMIC_SEQ_CST); +} + +#else + +static inline void* pa_atomic_ptr_load(const pa_atomic_ptr_t *a) { + __sync_synchronize(); + return (void*) a->value; +} + +static inline void pa_atomic_ptr_store(pa_atomic_ptr_t *a, void *p) { + a->value = (unsigned long) p; + __sync_synchronize(); +} + +#endif + +static inline bool pa_atomic_ptr_cmpxchg(pa_atomic_ptr_t *a, void *old_p, void* new_p) { + return __sync_bool_compare_and_swap(&a->value, (long) old_p, (long) new_p); +} + +#elif defined(__NetBSD__) && defined(HAVE_SYS_ATOMIC_H) + +/* NetBSD 5.0+ atomic_ops(3) implementation */ + +#include + +typedef struct pa_atomic { + volatile unsigned int value; +} pa_atomic_t; + +#define PA_ATOMIC_INIT(v) { .value = (unsigned int) (v) } + +static inline int pa_atomic_load(const pa_atomic_t *a) { + membar_sync(); + return (int) a->value; +} + +static inline void pa_atomic_store(pa_atomic_t *a, int i) { + a->value = (unsigned int) i; + membar_sync(); +} + +/* Returns the previously set value */ +static inline int pa_atomic_add(pa_atomic_t *a, int i) { + int nv = (int) atomic_add_int_nv(&a->value, i); + return nv - i; +} + +/* Returns the previously set value */ +static inline int pa_atomic_sub(pa_atomic_t *a, int i) { + int nv = (int) atomic_add_int_nv(&a->value, -i); + return nv + i; +} + +/* Returns the previously set value */ +static inline int pa_atomic_inc(pa_atomic_t *a) { + int nv = (int) atomic_inc_uint_nv(&a->value); + return nv - 1; +} + +/* Returns the previously set value */ +static inline int pa_atomic_dec(pa_atomic_t *a) { + int nv = (int) atomic_dec_uint_nv(&a->value); + return nv + 1; +} + +/* Returns true when the operation was successful. */ +static inline bool pa_atomic_cmpxchg(pa_atomic_t *a, int old_i, int new_i) { + unsigned int r = atomic_cas_uint(&a->value, (unsigned int) old_i, (unsigned int) new_i); + return (int) r == old_i; +} + +typedef struct pa_atomic_ptr { + volatile void *value; +} pa_atomic_ptr_t; + +#define PA_ATOMIC_PTR_INIT(v) { .value = (v) } + +static inline void* pa_atomic_ptr_load(const pa_atomic_ptr_t *a) { + membar_sync(); + return (void *) a->value; +} + +static inline void pa_atomic_ptr_store(pa_atomic_ptr_t *a, void *p) { + a->value = p; + membar_sync(); +} + +static inline bool pa_atomic_ptr_cmpxchg(pa_atomic_ptr_t *a, void *old_p, void* new_p) { + void *r = atomic_cas_ptr(&a->value, old_p, new_p); + return r == old_p; +} + +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) + +#include +#include +#include +#include + +#if __FreeBSD_version < 600000 +#if defined(__i386__) || defined(__amd64__) +#if defined(__amd64__) +#define atomic_load_acq_64 atomic_load_acq_long +#endif +static inline u_int atomic_fetchadd_int(volatile u_int *p, u_int v) { + __asm __volatile( + " " __XSTRING(MPLOCKED) " " + " xaddl %0, %1 ; " + "# atomic_fetchadd_int" + : "+r" (v), + "=m" (*p) + : "m" (*p)); + + return (v); +} +#elif defined(__sparc__) && defined(__arch64__) +#define atomic_load_acq_64 atomic_load_acq_long +#define atomic_fetchadd_int atomic_add_int +#elif defined(__ia64__) +#define atomic_load_acq_64 atomic_load_acq_long +static inline uint32_t +atomic_fetchadd_int(volatile uint32_t *p, uint32_t v) { + uint32_t value; + + do { + value = *p; + } while (!atomic_cmpset_32(p, value, value + v)); + return (value); +} +#endif +#endif + +typedef struct pa_atomic { + volatile unsigned long value; +} pa_atomic_t; + +#define PA_ATOMIC_INIT(v) { .value = (v) } + +static inline int pa_atomic_load(const pa_atomic_t *a) { + return (int) atomic_load_acq_int((unsigned int *) &a->value); +} + +static inline void pa_atomic_store(pa_atomic_t *a, int i) { + atomic_store_rel_int((unsigned int *) &a->value, i); +} + +static inline int pa_atomic_add(pa_atomic_t *a, int i) { + return atomic_fetchadd_int((unsigned int *) &a->value, i); +} + +static inline int pa_atomic_sub(pa_atomic_t *a, int i) { + return atomic_fetchadd_int((unsigned int *) &a->value, -(i)); +} + +static inline int pa_atomic_inc(pa_atomic_t *a) { + return atomic_fetchadd_int((unsigned int *) &a->value, 1); +} + +static inline int pa_atomic_dec(pa_atomic_t *a) { + return atomic_fetchadd_int((unsigned int *) &a->value, -1); +} + +static inline int pa_atomic_cmpxchg(pa_atomic_t *a, int old_i, int new_i) { + return atomic_cmpset_int((unsigned int *) &a->value, old_i, new_i); +} + +typedef struct pa_atomic_ptr { + volatile unsigned long value; +} pa_atomic_ptr_t; + +#define PA_ATOMIC_PTR_INIT(v) { .value = (unsigned long) (v) } + +static inline void* pa_atomic_ptr_load(const pa_atomic_ptr_t *a) { +#ifdef atomic_load_acq_64 + return (void*) atomic_load_acq_ptr((unsigned long *) &a->value); +#else + return (void*) atomic_load_acq_ptr((unsigned int *) &a->value); +#endif +} + +static inline void pa_atomic_ptr_store(pa_atomic_ptr_t *a, void *p) { +#ifdef atomic_load_acq_64 + atomic_store_rel_ptr(&a->value, (unsigned long) p); +#else + atomic_store_rel_ptr((unsigned int *) &a->value, (unsigned int) p); +#endif +} + +static inline int pa_atomic_ptr_cmpxchg(pa_atomic_ptr_t *a, void *old_p, void* new_p) { +#ifdef atomic_load_acq_64 + return atomic_cmpset_ptr(&a->value, (unsigned long) old_p, (unsigned long) new_p); +#else + return atomic_cmpset_ptr((unsigned int *) &a->value, (unsigned int) old_p, (unsigned int) new_p); +#endif +} + +#elif defined(__GNUC__) && (defined(__amd64__) || defined(__x86_64__)) + +#warn "The native atomic operations implementation for AMD64 has not been tested thoroughly. libatomic_ops is known to not work properly on AMD64 and your gcc version is too old for the gcc-builtin atomic ops support. You have three options now: test the native atomic operations implementation for AMD64, fix libatomic_ops, or upgrade your GCC." + +/* Adapted from glibc */ + +typedef struct pa_atomic { + volatile int value; +} pa_atomic_t; + +#define PA_ATOMIC_INIT(v) { .value = (v) } + +static inline int pa_atomic_load(const pa_atomic_t *a) { + return a->value; +} + +static inline void pa_atomic_store(pa_atomic_t *a, int i) { + a->value = i; +} + +static inline int pa_atomic_add(pa_atomic_t *a, int i) { + int result; + + __asm __volatile ("lock; xaddl %0, %1" + : "=r" (result), "=m" (a->value) + : "0" (i), "m" (a->value)); + + return result; +} + +static inline int pa_atomic_sub(pa_atomic_t *a, int i) { + return pa_atomic_add(a, -i); +} + +static inline int pa_atomic_inc(pa_atomic_t *a) { + return pa_atomic_add(a, 1); +} + +static inline int pa_atomic_dec(pa_atomic_t *a) { + return pa_atomic_sub(a, 1); +} + +static inline bool pa_atomic_cmpxchg(pa_atomic_t *a, int old_i, int new_i) { + int result; + + __asm__ __volatile__ ("lock; cmpxchgl %2, %1" + : "=a" (result), "=m" (a->value) + : "r" (new_i), "m" (a->value), "0" (old_i)); + + return result == old_i; +} + +typedef struct pa_atomic_ptr { + volatile unsigned long value; +} pa_atomic_ptr_t; + +#define PA_ATOMIC_PTR_INIT(v) { .value = (long) (v) } + +static inline void* pa_atomic_ptr_load(const pa_atomic_ptr_t *a) { + return (void*) a->value; +} + +static inline void pa_atomic_ptr_store(pa_atomic_ptr_t *a, void *p) { + a->value = (unsigned long) p; +} + +static inline bool pa_atomic_ptr_cmpxchg(pa_atomic_ptr_t *a, void *old_p, void* new_p) { + void *result; + + __asm__ __volatile__ ("lock; cmpxchgq %q2, %1" + : "=a" (result), "=m" (a->value) + : "r" (new_p), "m" (a->value), "0" (old_p)); + + return result == old_p; +} + +#elif defined(ATOMIC_ARM_INLINE_ASM) + +/* + These should only be enabled if we have ARMv6 or better. +*/ + +typedef struct pa_atomic { + volatile int value; +} pa_atomic_t; + +#define PA_ATOMIC_INIT(v) { .value = (v) } + +static inline void pa_memory_barrier(void) { +#ifdef ATOMIC_ARM_MEMORY_BARRIER_ENABLED + asm volatile ("mcr p15, 0, r0, c7, c10, 5 @ dmb"); +#endif +} + +static inline int pa_atomic_load(const pa_atomic_t *a) { + pa_memory_barrier(); + return a->value; +} + +static inline void pa_atomic_store(pa_atomic_t *a, int i) { + a->value = i; + pa_memory_barrier(); +} + +/* Returns the previously set value */ +static inline int pa_atomic_add(pa_atomic_t *a, int i) { + unsigned long not_exclusive; + int new_val, old_val; + + pa_memory_barrier(); + do { + asm volatile ("ldrex %0, [%3]\n" + "add %2, %0, %4\n" + "strex %1, %2, [%3]\n" + : "=&r" (old_val), "=&r" (not_exclusive), "=&r" (new_val) + : "r" (&a->value), "Ir" (i) + : "cc"); + } while(not_exclusive); + pa_memory_barrier(); + + return old_val; +} + +/* Returns the previously set value */ +static inline int pa_atomic_sub(pa_atomic_t *a, int i) { + unsigned long not_exclusive; + int new_val, old_val; + + pa_memory_barrier(); + do { + asm volatile ("ldrex %0, [%3]\n" + "sub %2, %0, %4\n" + "strex %1, %2, [%3]\n" + : "=&r" (old_val), "=&r" (not_exclusive), "=&r" (new_val) + : "r" (&a->value), "Ir" (i) + : "cc"); + } while(not_exclusive); + pa_memory_barrier(); + + return old_val; +} + +static inline int pa_atomic_inc(pa_atomic_t *a) { + return pa_atomic_add(a, 1); +} + +static inline int pa_atomic_dec(pa_atomic_t *a) { + return pa_atomic_sub(a, 1); +} + +static inline bool pa_atomic_cmpxchg(pa_atomic_t *a, int old_i, int new_i) { + unsigned long not_equal, not_exclusive; + + pa_memory_barrier(); + do { + asm volatile ("ldrex %0, [%2]\n" + "subs %0, %0, %3\n" + "mov %1, %0\n" + "strexeq %0, %4, [%2]\n" + : "=&r" (not_exclusive), "=&r" (not_equal) + : "r" (&a->value), "Ir" (old_i), "r" (new_i) + : "cc"); + } while(not_exclusive && !not_equal); + pa_memory_barrier(); + + return !not_equal; +} + +typedef struct pa_atomic_ptr { + volatile unsigned long value; +} pa_atomic_ptr_t; + +#define PA_ATOMIC_PTR_INIT(v) { .value = (long) (v) } + +static inline void* pa_atomic_ptr_load(const pa_atomic_ptr_t *a) { + pa_memory_barrier(); + return (void*) a->value; +} + +static inline void pa_atomic_ptr_store(pa_atomic_ptr_t *a, void *p) { + a->value = (unsigned long) p; + pa_memory_barrier(); +} + +static inline bool pa_atomic_ptr_cmpxchg(pa_atomic_ptr_t *a, void *old_p, void* new_p) { + unsigned long not_equal, not_exclusive; + + pa_memory_barrier(); + do { + asm volatile ("ldrex %0, [%2]\n" + "subs %0, %0, %3\n" + "mov %1, %0\n" + "strexeq %0, %4, [%2]\n" + : "=&r" (not_exclusive), "=&r" (not_equal) + : "r" (&a->value), "Ir" (old_p), "r" (new_p) + : "cc"); + } while(not_exclusive && !not_equal); + pa_memory_barrier(); + + return !not_equal; +} + +#elif defined(ATOMIC_ARM_LINUX_HELPERS) + +/* See file arch/arm/kernel/entry-armv.S in your kernel sources for more + information about these functions. The arm kernel helper functions first + appeared in 2.6.16. + Apply --disable-atomic-arm-linux-helpers flag to configure if you prefer + inline asm implementation or you have an obsolete Linux kernel. +*/ +/* Memory barrier */ +typedef void (__kernel_dmb_t)(void); +#define __kernel_dmb (*(__kernel_dmb_t *)0xffff0fa0) + +static inline void pa_memory_barrier(void) { +#ifndef ATOMIC_ARM_MEMORY_BARRIER_ENABLED + __kernel_dmb(); +#endif +} + +/* Atomic exchange (__kernel_cmpxchg_t contains memory barriers if needed) */ +typedef int (__kernel_cmpxchg_t)(int oldval, int newval, volatile int *ptr); +#define __kernel_cmpxchg (*(__kernel_cmpxchg_t *)0xffff0fc0) + +/* This is just to get rid of all warnings */ +typedef int (__kernel_cmpxchg_u_t)(unsigned long oldval, unsigned long newval, volatile unsigned long *ptr); +#define __kernel_cmpxchg_u (*(__kernel_cmpxchg_u_t *)0xffff0fc0) + +typedef struct pa_atomic { + volatile int value; +} pa_atomic_t; + +#define PA_ATOMIC_INIT(v) { .value = (v) } + +static inline int pa_atomic_load(const pa_atomic_t *a) { + pa_memory_barrier(); + return a->value; +} + +static inline void pa_atomic_store(pa_atomic_t *a, int i) { + a->value = i; + pa_memory_barrier(); +} + +/* Returns the previously set value */ +static inline int pa_atomic_add(pa_atomic_t *a, int i) { + int old_val; + do { + old_val = a->value; + } while(__kernel_cmpxchg(old_val, old_val + i, &a->value)); + return old_val; +} + +/* Returns the previously set value */ +static inline int pa_atomic_sub(pa_atomic_t *a, int i) { + int old_val; + do { + old_val = a->value; + } while(__kernel_cmpxchg(old_val, old_val - i, &a->value)); + return old_val; +} + +/* Returns the previously set value */ +static inline int pa_atomic_inc(pa_atomic_t *a) { + return pa_atomic_add(a, 1); +} + +/* Returns the previously set value */ +static inline int pa_atomic_dec(pa_atomic_t *a) { + return pa_atomic_sub(a, 1); +} + +/* Returns true when the operation was successful. */ +static inline bool pa_atomic_cmpxchg(pa_atomic_t *a, int old_i, int new_i) { + bool failed; + do { + failed = !!__kernel_cmpxchg(old_i, new_i, &a->value); + } while(failed && a->value == old_i); + return !failed; +} + +typedef struct pa_atomic_ptr { + volatile unsigned long value; +} pa_atomic_ptr_t; + +#define PA_ATOMIC_PTR_INIT(v) { .value = (unsigned long) (v) } + +static inline void* pa_atomic_ptr_load(const pa_atomic_ptr_t *a) { + pa_memory_barrier(); + return (void*) a->value; +} + +static inline void pa_atomic_ptr_store(pa_atomic_ptr_t *a, void *p) { + a->value = (unsigned long) p; + pa_memory_barrier(); +} + +static inline bool pa_atomic_ptr_cmpxchg(pa_atomic_ptr_t *a, void *old_p, void* new_p) { + bool failed; + do { + failed = !!__kernel_cmpxchg_u((unsigned long) old_p, (unsigned long) new_p, &a->value); + } while(failed && a->value == (unsigned long) old_p); + return !failed; +} + +#else + +/* libatomic_ops based implementation */ + +#include + +typedef struct pa_atomic { + volatile AO_t value; +} pa_atomic_t; + +#define PA_ATOMIC_INIT(v) { .value = (AO_t) (v) } + +static inline int pa_atomic_load(const pa_atomic_t *a) { + return (int) AO_load_full((AO_t*) &a->value); +} + +static inline void pa_atomic_store(pa_atomic_t *a, int i) { + AO_store_full(&a->value, (AO_t) i); +} + +static inline int pa_atomic_add(pa_atomic_t *a, int i) { + return (int) AO_fetch_and_add_full(&a->value, (AO_t) i); +} + +static inline int pa_atomic_sub(pa_atomic_t *a, int i) { + return (int) AO_fetch_and_add_full(&a->value, (AO_t) -i); +} + +static inline int pa_atomic_inc(pa_atomic_t *a) { + return (int) AO_fetch_and_add1_full(&a->value); +} + +static inline int pa_atomic_dec(pa_atomic_t *a) { + return (int) AO_fetch_and_sub1_full(&a->value); +} + +static inline bool pa_atomic_cmpxchg(pa_atomic_t *a, int old_i, int new_i) { + return AO_compare_and_swap_full(&a->value, (unsigned long) old_i, (unsigned long) new_i); +} + +typedef struct pa_atomic_ptr { + volatile AO_t value; +} pa_atomic_ptr_t; + +#define PA_ATOMIC_PTR_INIT(v) { .value = (AO_t) (v) } + +static inline void* pa_atomic_ptr_load(const pa_atomic_ptr_t *a) { + return (void*) AO_load_full((AO_t*) &a->value); +} + +static inline void pa_atomic_ptr_store(pa_atomic_ptr_t *a, void *p) { + AO_store_full(&a->value, (AO_t) p); +} + +static inline bool pa_atomic_ptr_cmpxchg(pa_atomic_ptr_t *a, void *old_p, void* new_p) { + return AO_compare_and_swap_full(&a->value, (AO_t) old_p, (AO_t) new_p); +} + +#endif + +#endif diff --git a/pulse/pulsecore-14.0/aupdate.h b/pulse/pulsecore-14.0/aupdate.h new file mode 100644 index 00000000..347b8536 --- /dev/null +++ b/pulse/pulsecore-14.0/aupdate.h @@ -0,0 +1,100 @@ +#ifndef foopulsecoreaupdatehfoo +#define foopulsecoreaupdatehfoo + +/*** + This file is part of PulseAudio. + + Copyright 2009 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +typedef struct pa_aupdate pa_aupdate; + +pa_aupdate *pa_aupdate_new(void); +void pa_aupdate_free(pa_aupdate *a); + +/* Will return 0, or 1, depending on which copy of the data the caller + * should look at */ +unsigned pa_aupdate_read_begin(pa_aupdate *a); +void pa_aupdate_read_end(pa_aupdate *a); + +/* Will return 0, or 1, depending which copy of the data the caller + * should modify */ +unsigned pa_aupdate_write_begin(pa_aupdate *a); +void pa_aupdate_write_end(pa_aupdate *a); + +/* Will return 0, or 1, depending which copy of the data the caller + * should modify. Each time called this will return the opposite of + * the previous pa_aupdate_write_begin() / pa_aupdate_write_swap() + * call. Should only be called between pa_aupdate_write_begin() and + * pa_aupdate_write_end() */ +unsigned pa_aupdate_write_swap(pa_aupdate *a); + +/* + * This infrastructure allows lock-free updates of arbitrary data + * structures in an rcu'ish way: two copies of the data structure + * should be existing. One side ('the reader') has read access to one + * of the two data structure at a time. It does not have to lock it, + * however it needs to signal that it is using it/stopped using + * it. The other side ('the writer') modifies the second data structure, + * and then atomically swaps the two data structures, followed by a + * modification of the other one. + * + * This is intended to be used for cases where the reader side needs + * to be fast while the writer side can be slow. + * + * The reader side is signal handler safe. + * + * The writer side lock is not recursive. The reader side is. + * + * There may be multiple readers and multiple writers at the same + * time. + * + * Usage is like this: + * + * static struct foo bar[2]; + * static pa_aupdate *a; + * + * reader() { + * unsigned j; + * + * j = pa_update_read_begin(a); + * + * ... read the data structure bar[j] ... + * + * pa_update_read_end(a); + * } + * + * writer() { + * unsigned j; + * + * j = pa_update_write_begin(a); + * + * ... update the data structure bar[j] ... + * + * j = pa_update_write_swap(a); + * + * ... update the data structure bar[j], the same way as above ... + * + * pa_update_write_end(a) + * } + * + * In some cases keeping both structures up-to-date might not be + * necessary, since they are fully rebuilt on each iteration + * anyway. In that case you may leave the _write_swap() call out, it + * will then be done implicitly in the _write_end() invocation. + */ + +#endif diff --git a/pulse/pulsecore-14.0/auth-cookie.h b/pulse/pulsecore-14.0/auth-cookie.h new file mode 100644 index 00000000..01f5244a --- /dev/null +++ b/pulse/pulsecore-14.0/auth-cookie.h @@ -0,0 +1,34 @@ +#ifndef fooauthcookiehfoo +#define fooauthcookiehfoo + +/*** + This file is part of PulseAudio. + + Copyright 2008 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +typedef struct pa_auth_cookie pa_auth_cookie; + +pa_auth_cookie* pa_auth_cookie_get(pa_core *c, const char *cn, bool create, size_t size); +pa_auth_cookie* pa_auth_cookie_create(pa_core *c, const void *data, size_t size); +pa_auth_cookie* pa_auth_cookie_ref(pa_auth_cookie *c); +void pa_auth_cookie_unref(pa_auth_cookie *c); + +const uint8_t* pa_auth_cookie_read(pa_auth_cookie *, size_t size); + +#endif diff --git a/pulse/pulsecore-14.0/authkey.h b/pulse/pulsecore-14.0/authkey.h new file mode 100644 index 00000000..7af9253c --- /dev/null +++ b/pulse/pulsecore-14.0/authkey.h @@ -0,0 +1,29 @@ +#ifndef fooauthkeyhfoo +#define fooauthkeyhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include + +int pa_authkey_load(const char *fn, bool create, void *data, size_t length); + +int pa_authkey_save(const char *path, const void *data, size_t length); + +#endif diff --git a/pulse/pulsecore-14.0/avahi-wrap.h b/pulse/pulsecore-14.0/avahi-wrap.h new file mode 100644 index 00000000..c7a97191 --- /dev/null +++ b/pulse/pulsecore-14.0/avahi-wrap.h @@ -0,0 +1,30 @@ +#ifndef fooavahiwrapperhfoo +#define fooavahiwrapperhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include + +#include + +AvahiPoll* pa_avahi_poll_new(pa_mainloop_api *api); +void pa_avahi_poll_free(AvahiPoll *p); + +#endif diff --git a/pulse/pulsecore-14.0/bitset.h b/pulse/pulsecore-14.0/bitset.h new file mode 100644 index 00000000..32fa82d4 --- /dev/null +++ b/pulse/pulsecore-14.0/bitset.h @@ -0,0 +1,35 @@ +#ifndef foopulsecorebitsethfoo +#define foopulsecorebitsethfoo + +/*** + This file is part of PulseAudio. + + Copyright 2009 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include + +#define PA_BITSET_ELEMENTS(n) (((n)+31)/32) +#define PA_BITSET_SIZE(n) (PA_BITSET_ELEMENTS(n)*4) + +typedef uint32_t pa_bitset_t; + +void pa_bitset_set(pa_bitset_t *b, unsigned k, bool v); +bool pa_bitset_get(const pa_bitset_t *b, unsigned k); +bool pa_bitset_equals(const pa_bitset_t *b, unsigned n, ...); + +#endif diff --git a/pulse/pulsecore-14.0/card.h b/pulse/pulsecore-14.0/card.h new file mode 100644 index 00000000..a11e33d0 --- /dev/null +++ b/pulse/pulsecore-14.0/card.h @@ -0,0 +1,147 @@ +#ifndef foopulsecardhfoo +#define foopulsecardhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2009 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include +#include +#include +#include + +/* This enum replaces pa_port_available_t (defined in pulse/def.h) for + * internal use, so make sure both enum types stay in sync. */ +typedef enum pa_available { + PA_AVAILABLE_UNKNOWN = 0, + PA_AVAILABLE_NO = 1, + PA_AVAILABLE_YES = 2, +} pa_available_t; + +struct pa_card_profile { + pa_card *card; + char *name; + char *description; + + /* Identifiers for the profile's input and output parts, i e, if two different profiles + have the same input_name string, they have the same source(s). + Same for output_name and sink(s). + Can be NULL (and in case of an input- or output- only profile, the other direction + will be NULL). */ + char *input_name; + char *output_name; + + unsigned priority; + pa_available_t available; /* PA_AVAILABLE_UNKNOWN, PA_AVAILABLE_NO or PA_AVAILABLE_YES */ + + /* We probably want to have different properties later on here */ + unsigned n_sinks; + unsigned n_sources; + + unsigned max_sink_channels; + unsigned max_source_channels; + + /* .. followed by some implementation specific data */ +}; + +#define PA_CARD_PROFILE_DATA(d) ((void*) ((uint8_t*) d + PA_ALIGN(sizeof(pa_card_profile)))) + +struct pa_card { + uint32_t index; + pa_core *core; + + char *name; + + pa_proplist *proplist; + pa_module *module; + char *driver; + + pa_idxset *sinks; + pa_idxset *sources; + + pa_hashmap *profiles; + pa_card_profile *active_profile; + + pa_hashmap *ports; + pa_device_port *preferred_input_port; + pa_device_port *preferred_output_port; + + bool save_profile:1; + + pa_suspend_cause_t suspend_cause; + + bool linked; + + void *userdata; + + int (*set_profile)(pa_card *c, pa_card_profile *profile); +}; + +typedef struct pa_card_new_data { + char *name; + pa_proplist *proplist; + + const char *driver; + pa_module *module; + + pa_hashmap *profiles; + pa_hashmap *ports; + pa_device_port *preferred_input_port; + pa_device_port *preferred_output_port; + + bool namereg_fail:1; +} pa_card_new_data; + +typedef struct { + pa_card *card; + pa_direction_t direction; +} pa_card_preferred_port_changed_hook_data; + +const char *pa_available_to_string(pa_available_t available); + +pa_card_profile *pa_card_profile_new(const char *name, const char *description, size_t extra); +void pa_card_profile_free(pa_card_profile *c); + +/* The profile's available status has changed */ +void pa_card_profile_set_available(pa_card_profile *c, pa_available_t available); + +pa_card_new_data *pa_card_new_data_init(pa_card_new_data *data); +void pa_card_new_data_set_name(pa_card_new_data *data, const char *name); +void pa_card_new_data_set_preferred_port(pa_card_new_data *data, pa_direction_t direction, pa_device_port *port); +void pa_card_new_data_done(pa_card_new_data *data); + +pa_card *pa_card_new(pa_core *c, pa_card_new_data *data); + +/* Select the initial card profile according to the configured policies. This + * must be called between pa_card_new() and pa_card_put(), after the port and + * profile availabilities have been initialized. */ +void pa_card_choose_initial_profile(pa_card *card); + +void pa_card_put(pa_card *c); +void pa_card_free(pa_card *c); + +void pa_card_add_profile(pa_card *c, pa_card_profile *profile); + +int pa_card_set_profile(pa_card *c, pa_card_profile *profile, bool save); + +void pa_card_set_preferred_port(pa_card *c, pa_direction_t direction, pa_device_port *port); + +int pa_card_suspend(pa_card *c, bool suspend, pa_suspend_cause_t cause); + +#endif diff --git a/pulse/pulsecore-14.0/cli-command.h b/pulse/pulsecore-14.0/cli-command.h new file mode 100644 index 00000000..3513341b --- /dev/null +++ b/pulse/pulsecore-14.0/cli-command.h @@ -0,0 +1,44 @@ +#ifndef fooclicommandhfoo +#define fooclicommandhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include + +/* Execute a single CLI command. Write the results to the string + * buffer *buf. If *fail is non-zero the function will return -1 when + * one or more of the executed commands failed. *fail + * may be modified by the function call. */ +int pa_cli_command_execute_line(pa_core *c, const char *s, pa_strbuf *buf, bool *fail); + +/* Execute a whole file of CLI commands */ +int pa_cli_command_execute_file(pa_core *c, const char *fn, pa_strbuf *buf, bool *fail); + +/* Execute a whole file of CLI commands */ +int pa_cli_command_execute_file_stream(pa_core *c, FILE *f, pa_strbuf *buf, bool *fail); + +/* Split the specified string into lines and run pa_cli_command_execute_line() for each. */ +int pa_cli_command_execute(pa_core *c, const char *s, pa_strbuf *buf, bool *fail); + +/* Same as pa_cli_command_execute_line() but also take ifstate var. */ +int pa_cli_command_execute_line_stateful(pa_core *c, const char *s, pa_strbuf *buf, bool *fail, int *ifstate); + +#endif diff --git a/pulse/pulsecore-14.0/cli-text.h b/pulse/pulsecore-14.0/cli-text.h new file mode 100644 index 00000000..b89be50a --- /dev/null +++ b/pulse/pulsecore-14.0/cli-text.h @@ -0,0 +1,39 @@ +#ifndef fooclitexthfoo +#define fooclitexthfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +/* Some functions to generate pretty formatted listings of + * entities. The returned strings have to be freed manually. */ + +char *pa_sink_input_list_to_string(pa_core *c); +char *pa_source_output_list_to_string(pa_core *c); +char *pa_sink_list_to_string(pa_core *core); +char *pa_source_list_to_string(pa_core *c); +char *pa_card_list_to_string(pa_core *c); +char *pa_client_list_to_string(pa_core *c); +char *pa_module_list_to_string(pa_core *c); +char *pa_scache_list_to_string(pa_core *c); + +char *pa_full_status_string(pa_core *c); + +#endif diff --git a/pulse/pulsecore-14.0/cli.h b/pulse/pulsecore-14.0/cli.h new file mode 100644 index 00000000..37d5ff93 --- /dev/null +++ b/pulse/pulsecore-14.0/cli.h @@ -0,0 +1,40 @@ +#ifndef fooclihfoo +#define fooclihfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include +#include + +typedef struct pa_cli pa_cli; + +typedef void (*pa_cli_eof_cb_t)(pa_cli *c, void *userdata); + +/* Create a new command line session on the specified io channel owned by the specified module */ +pa_cli* pa_cli_new(pa_core *core, pa_iochannel *io, pa_module *m); +void pa_cli_free(pa_cli *cli); + +/* Set a callback function that is called whenever the command line session is terminated */ +void pa_cli_set_eof_callback(pa_cli *cli, pa_cli_eof_cb_t cb, void *userdata); + +pa_module *pa_cli_get_module(pa_cli *c); + +#endif diff --git a/pulse/pulsecore-14.0/client.h b/pulse/pulsecore-14.0/client.h new file mode 100644 index 00000000..c6952e3c --- /dev/null +++ b/pulse/pulsecore-14.0/client.h @@ -0,0 +1,83 @@ +#ifndef foopulseclienthfoo +#define foopulseclienthfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +#include +#include +#include +#include + +/* Every connection to the server should have a pa_client + * attached. That way the user may generate a listing of all connected + * clients easily and kill them if they want.*/ + +struct pa_client { + uint32_t index; + pa_core *core; + + pa_proplist *proplist; + pa_module *module; + char *driver; + + pa_idxset *sink_inputs; + pa_idxset *source_outputs; + + void *userdata; + + void (*kill)(pa_client *c); + + void (*send_event)(pa_client *c, const char *name, pa_proplist *data); +}; + +typedef struct pa_client_new_data { + pa_proplist *proplist; + const char *driver; + pa_module *module; +} pa_client_new_data; + +pa_client_new_data *pa_client_new_data_init(pa_client_new_data *data); +void pa_client_new_data_done(pa_client_new_data *data); + +pa_client *pa_client_new(pa_core *c, pa_client_new_data *data); + +/* This function should be called only by the code that created the client */ +void pa_client_free(pa_client *c); + +/* Code that didn't create the client should call this function to + * request destruction of the client */ +void pa_client_kill(pa_client *c); + +/* Rename the client */ +void pa_client_set_name(pa_client *c, const char *name); + +void pa_client_update_proplist(pa_client *c, pa_update_mode_t mode, pa_proplist *p); + +void pa_client_send_event(pa_client *c, const char *event, pa_proplist *data); + +typedef struct pa_client_send_event_hook_data { + pa_client *client; + const char *event; + pa_proplist *data; +} pa_client_send_event_hook_data; + +#endif diff --git a/pulse/pulsecore-14.0/conf-parser.h b/pulse/pulsecore-14.0/conf-parser.h new file mode 100644 index 00000000..7dc0ff9d --- /dev/null +++ b/pulse/pulsecore-14.0/conf-parser.h @@ -0,0 +1,87 @@ +#ifndef fooconfparserhfoo +#define fooconfparserhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +#include + +/* An abstract parser for simple, line based, shallow configuration + * files consisting of variable assignments only. */ + +typedef struct pa_config_parser_state pa_config_parser_state; + +typedef int (*pa_config_parser_cb_t)(pa_config_parser_state *state); + +/* Wraps info for parsing a specific configuration variable */ +typedef struct pa_config_item { + const char *lvalue; /* name of the variable */ + pa_config_parser_cb_t parse; /* Function that is called to parse the variable's value */ + void *data; /* Where to store the variable's data */ + const char *section; +} pa_config_item; + +struct pa_config_parser_state { + const char *filename; + unsigned lineno; + char *section; + char *lvalue; + char *rvalue; + void *data; /* The data pointer of the current pa_config_item. */ + void *userdata; /* The pointer that was given to pa_config_parse(). */ + + /* Private data to be used only by conf-parser.c. */ + const pa_config_item *item_table; + char buf[4096]; + pa_proplist *proplist; + bool in_proplist; +}; + +/* The configuration file parsing routine. Expects a table of + * pa_config_items in *t that is terminated by an item where lvalue is + * NULL. + * + * If use_dot_d is true, then after parsing the file named by the filename + * argument, the function will parse all files ending with ".conf" in + * alphabetical order from a directory whose name is filename + ".d", if such + * directory exists. + * + * Some configuration files may contain a Properties section, which + * is a bit special. Normally all accepted lvalues must be predefined + * in the pa_config_item table, but in the Properties section the + * pa_config_item table is ignored, and all lvalues are accepted (as + * long as they are valid proplist keys). If the proplist pointer is + * non-NULL, the parser will parse any section named "Properties" as + * properties, and those properties will be merged into the given + * proplist. If proplist is NULL, then sections named "Properties" + * are not allowed at all in the configuration file. */ +int pa_config_parse(const char *filename, FILE *f, const pa_config_item *t, pa_proplist *proplist, bool use_dot_d, + void *userdata); + +/* Generic parsers for integers, size_t, booleans and strings */ +int pa_config_parse_int(pa_config_parser_state *state); +int pa_config_parse_unsigned(pa_config_parser_state *state); +int pa_config_parse_size(pa_config_parser_state *state); +int pa_config_parse_bool(pa_config_parser_state *state); +int pa_config_parse_not_bool(pa_config_parser_state *state); +int pa_config_parse_string(pa_config_parser_state *state); + +#endif diff --git a/pulse/pulsecore-14.0/core-error.h b/pulse/pulsecore-14.0/core-error.h new file mode 100644 index 00000000..f4af5d58 --- /dev/null +++ b/pulse/pulsecore-14.0/core-error.h @@ -0,0 +1,39 @@ +#ifndef foocoreerrorhfoo +#define foocoreerrorhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +/** \file + * Error management */ + +PA_C_DECL_BEGIN + +/** A wrapper around the standard strerror() function that converts the + * string to UTF-8. The function is thread safe but the returned string is + * only guaranteed to exist until the thread exits or pa_cstrerror() is + * called again from the same thread. */ +const char* pa_cstrerror(int errnum); + +PA_C_DECL_END + +#endif diff --git a/pulse/pulsecore-14.0/core-format.h b/pulse/pulsecore-14.0/core-format.h new file mode 100644 index 00000000..e2e02fe7 --- /dev/null +++ b/pulse/pulsecore-14.0/core-format.h @@ -0,0 +1,59 @@ +#ifndef foocoreformathfoo +#define foocoreformathfoo + +/*** + This file is part of PulseAudio. + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +#include + +/* Convert a sample spec and an optional channel map to a new PCM format info + * object (remember to free it). If map is NULL, then the channel map will be + * left unspecified. If some fields of the sample spec should be ignored, pass + * false for set_format, set_rate and set_channels as appropriate, then those + * fields will be left unspecified. This function returns NULL if the input is + * invalid (for example, setting the sample rate was requested, but the rate + * in ss is invalid). + * + * pa_format_info_from_sample_spec() exists too. This "version 2" was created, + * because the original function doesn't provide the possibility of ignoring + * some of the sample spec fields. That functionality can't be added to the + * original function, because the function is a part of the public API and + * adding parameters to it would break the API. */ +pa_format_info *pa_format_info_from_sample_spec2(const pa_sample_spec *ss, const pa_channel_map *map, bool set_format, + bool set_rate, bool set_channels); + +/* Convert the format info into a sample spec and a channel map. If the format + * info doesn't contain some information, the fallback sample spec and channel + * map are used to populate the output. + * + * pa_format_info_to_sample_spec() exists too. This "version 2" was created, + * because the original function doesn't provide the possibility of specifying + * a fallback sample spec and channel map. That functionality can't be added to + * the original function, because the function is part of the public API and + * adding parameters to it would break the API. */ +int pa_format_info_to_sample_spec2(const pa_format_info *f, pa_sample_spec *ss, pa_channel_map *map, + const pa_sample_spec *fallback_ss, const pa_channel_map *fallback_map); + +/* For compressed formats. Converts the format info into a sample spec and a + * channel map that an ALSA device can use as its configuration parameters when + * playing back the compressed data. That is, the returned sample spec doesn't + * describe the audio content, but the device parameters. */ +int pa_format_info_to_sample_spec_fake(const pa_format_info *f, pa_sample_spec *ss, pa_channel_map *map); + +#endif diff --git a/pulse/pulsecore-14.0/core-rtclock.h b/pulse/pulsecore-14.0/core-rtclock.h new file mode 100644 index 00000000..89ad237b --- /dev/null +++ b/pulse/pulsecore-14.0/core-rtclock.h @@ -0,0 +1,53 @@ +#ifndef foopulsertclockhfoo +#define foopulsertclockhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include +#include + +struct timeval; + +/* Something like pulse/timeval.h but based on CLOCK_MONOTONIC */ + +struct timeval *pa_rtclock_get(struct timeval *ts); + +pa_usec_t pa_rtclock_age(const struct timeval *tv); +bool pa_rtclock_hrtimer(void); +void pa_rtclock_hrtimer_enable(void); + +/* timer with a resolution better than this are considered high-resolution */ +#define PA_HRTIMER_THRESHOLD_USEC 10 + +/* bit to set in tv.tv_usec to mark that the timeval is in monotonic time */ +#define PA_TIMEVAL_RTCLOCK ((time_t) (1LU << 30)) + +struct timeval* pa_rtclock_from_wallclock(struct timeval *tv); + +#ifdef HAVE_CLOCK_GETTIME +struct timespec; + +pa_usec_t pa_timespec_load(const struct timespec *ts); +struct timespec* pa_timespec_store(struct timespec *ts, pa_usec_t v); +#endif + +struct timeval* pa_timeval_rtstore(struct timeval *tv, pa_usec_t v, bool rtclock); + +#endif diff --git a/pulse/pulsecore-14.0/core-scache.h b/pulse/pulsecore-14.0/core-scache.h new file mode 100644 index 00000000..f0eacaa5 --- /dev/null +++ b/pulse/pulsecore-14.0/core-scache.h @@ -0,0 +1,68 @@ +#ifndef foocorescachehfoo +#define foocorescachehfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include +#include + +#define PA_SCACHE_ENTRY_SIZE_MAX (1024*1024*16) + +typedef struct pa_scache_entry { + uint32_t index; + pa_core *core; + + char *name; + + pa_cvolume volume; + bool volume_is_set; + pa_sample_spec sample_spec; + pa_channel_map channel_map; + pa_memchunk memchunk; + + char *filename; + + bool lazy; + time_t last_used_time; + + pa_proplist *proplist; +} pa_scache_entry; + +int pa_scache_add_item(pa_core *c, const char *name, const pa_sample_spec *ss, const pa_channel_map *map, const pa_memchunk *chunk, pa_proplist *p, uint32_t *idx); +int pa_scache_add_file(pa_core *c, const char *name, const char *filename, uint32_t *idx); +int pa_scache_add_file_lazy(pa_core *c, const char *name, const char *filename, uint32_t *idx); + +int pa_scache_add_directory_lazy(pa_core *c, const char *pathname); + +int pa_scache_remove_item(pa_core *c, const char *name); +int pa_scache_play_item(pa_core *c, const char *name, pa_sink *sink, pa_volume_t volume, pa_proplist *p, uint32_t *sink_input_idx); +int pa_scache_play_item_by_name(pa_core *c, const char *name, const char*sink_name, pa_volume_t volume, pa_proplist *p, uint32_t *sink_input_idx); +void pa_scache_free_all(pa_core *c); + +const char *pa_scache_get_name_by_id(pa_core *c, uint32_t id); +uint32_t pa_scache_get_id_by_name(pa_core *c, const char *name); + +size_t pa_scache_total_size(pa_core *c); + +void pa_scache_unload_unused(pa_core *c); + +#endif diff --git a/pulse/pulsecore-14.0/core-subscribe.h b/pulse/pulsecore-14.0/core-subscribe.h new file mode 100644 index 00000000..6032dc35 --- /dev/null +++ b/pulse/pulsecore-14.0/core-subscribe.h @@ -0,0 +1,37 @@ +#ifndef foocoresubscribehfoo +#define foocoresubscribehfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +typedef struct pa_subscription pa_subscription; +typedef struct pa_subscription_event pa_subscription_event; + +#include +#include + +typedef void (*pa_subscription_cb_t)(pa_core *c, pa_subscription_event_type_t t, uint32_t idx, void *userdata); + +pa_subscription* pa_subscription_new(pa_core *c, pa_subscription_mask_t m, pa_subscription_cb_t cb, void *userdata); +void pa_subscription_free(pa_subscription*s); +void pa_subscription_free_all(pa_core *c); + +void pa_subscription_post(pa_core *c, pa_subscription_event_type_t t, uint32_t idx); + +#endif diff --git a/pulse/pulsecore-14.0/core-util.h b/pulse/pulsecore-14.0/core-util.h new file mode 100644 index 00000000..9440af91 --- /dev/null +++ b/pulse/pulsecore-14.0/core-util.h @@ -0,0 +1,323 @@ +#ifndef foocoreutilhfoo +#define foocoreutilhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006-2007 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include +#include +#include +#include +#include + +#ifdef HAVE_SYS_RESOURCE_H +#include +#endif + +#include +#include + +#include +#include +#include + +#ifndef PACKAGE +#error "Please include config.h before including this file!" +#endif + +struct timeval; + +/* These resource limits are pretty new on Linux, let's define them + * here manually, in case the kernel is newer than the glibc */ +#if !defined(RLIMIT_NICE) && defined(__linux__) +#define RLIMIT_NICE 13 +#endif +#if !defined(RLIMIT_RTPRIO) && defined(__linux__) +#define RLIMIT_RTPRIO 14 +#endif +#if !defined(RLIMIT_RTTIME) && defined(__linux__) +#define RLIMIT_RTTIME 15 +#endif + +void pa_make_fd_nonblock(int fd); +void pa_make_fd_block(int fd); +bool pa_is_fd_nonblock(int fd); + +void pa_make_fd_cloexec(int fd); + +int pa_make_secure_dir(const char* dir, mode_t m, uid_t uid, gid_t gid, bool update_perms); +int pa_make_secure_parent_dir(const char *fn, mode_t, uid_t uid, gid_t gid, bool update_perms); + +ssize_t pa_read(int fd, void *buf, size_t count, int *type); +ssize_t pa_write(int fd, const void *buf, size_t count, int *type); +ssize_t pa_loop_read(int fd, void*data, size_t size, int *type); +ssize_t pa_loop_write(int fd, const void*data, size_t size, int *type); + +int pa_close(int fd); + +void pa_check_signal_is_blocked(int sig); + +char *pa_sprintf_malloc(const char *format, ...) PA_GCC_PRINTF_ATTR(1,2); +char *pa_vsprintf_malloc(const char *format, va_list ap); + +char *pa_strlcpy(char *b, const char *s, size_t l); + +char *pa_parent_dir(const char *fn); + +int pa_raise_priority(int nice_level); +void pa_reset_priority(void); + +int pa_parse_boolean(const char *s) PA_GCC_PURE; + +int pa_parse_volume(const char *s, pa_volume_t *volume); + +static inline const char *pa_yes_no(bool b) { + return b ? "yes" : "no"; +} + +static inline const char *pa_yes_no_localised(bool b) { + return b ? _("yes") : _("no"); +} + +static inline const char *pa_strnull(const char *x) { + return x ? x : "(null)"; +} + +static inline const char *pa_strempty(const char *x) { + return x ? x : ""; +} + +static inline const char *pa_strna(const char *x) { + return x ? x : "n/a"; +} + +char *pa_split(const char *c, const char *delimiters, const char **state); +const char *pa_split_in_place(const char *c, const char *delimiters, size_t *n, const char **state); +char *pa_split_spaces(const char *c, const char **state); +const char *pa_split_spaces_in_place(const char *c, size_t *n, const char **state); + +char *pa_strip_nl(char *s); +char *pa_strip(char *s); + +const char *pa_sig2str(int sig) PA_GCC_PURE; + +int pa_own_uid_in_group(const char *name, gid_t *gid); +int pa_uid_in_group(uid_t uid, const char *name); +gid_t pa_get_gid_of_group(const char *name); +int pa_check_in_group(gid_t g); + +int pa_lock_fd(int fd, int b); + +int pa_lock_lockfile(const char *fn); +int pa_unlock_lockfile(const char *fn, int fd); + +char *pa_hexstr(const uint8_t* d, size_t dlength, char *s, size_t slength); +size_t pa_parsehex(const char *p, uint8_t *d, size_t dlength); + +bool pa_startswith(const char *s, const char *pfx) PA_GCC_PURE; +bool pa_endswith(const char *s, const char *sfx) PA_GCC_PURE; + +FILE *pa_open_config_file(const char *global, const char *local, const char *env, char **result); +char* pa_find_config_file(const char *global, const char *local, const char *env); + +char *pa_get_runtime_dir(void); +char *pa_get_state_dir(void); +char *pa_get_home_dir_malloc(void); +int pa_append_to_home_dir(const char *path, char **_r); +int pa_get_config_home_dir(char **_r); +int pa_append_to_config_home_dir(const char *path, char **_r); +char *pa_get_binary_name_malloc(void); +char *pa_runtime_path(const char *fn); +char *pa_state_path(const char *fn, bool prepend_machine_id); + +int pa_atoi(const char *s, int32_t *ret_i); +int pa_atou(const char *s, uint32_t *ret_u); +int pa_atol(const char *s, long *ret_l); +int pa_atod(const char *s, double *ret_d); + +size_t pa_snprintf(char *str, size_t size, const char *format, ...); +size_t pa_vsnprintf(char *str, size_t size, const char *format, va_list ap); + +char *pa_truncate_utf8(char *c, size_t l); + +int pa_match(const char *expr, const char *v); +bool pa_is_regex_valid(const char *expr); + +char *pa_getcwd(void); +char *pa_make_path_absolute(const char *p); +bool pa_is_path_absolute(const char *p); + +void *pa_will_need(const void *p, size_t l); + +static inline int pa_is_power_of_two(unsigned n) { + return !(n & (n - 1)); +} + +static inline unsigned pa_ulog2(unsigned n) { + + if (n <= 1) + return 0; + +#if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) + return 8U * (unsigned) sizeof(unsigned) - (unsigned) __builtin_clz(n) - 1; +#else +{ + unsigned r = 0; + + for (;;) { + n = n >> 1; + + if (!n) + return r; + + r++; + } +} +#endif +} + +static inline unsigned pa_make_power_of_two(unsigned n) { + + if (pa_is_power_of_two(n)) + return n; + + return 1U << (pa_ulog2(n) + 1); +} + +void pa_close_pipe(int fds[2]); + +char *pa_readlink(const char *p); + +int pa_close_all(int except_fd, ...); +int pa_close_allv(const int except_fds[]); +int pa_unblock_sigs(int except, ...); +int pa_unblock_sigsv(const int except[]); +int pa_reset_sigs(int except, ...); +int pa_reset_sigsv(const int except[]); + +void pa_set_env(const char *key, const char *value); +void pa_unset_env(const char *key); +void pa_set_env_and_record(const char *key, const char *value); +void pa_unset_env_recorded(void); + +bool pa_in_system_mode(void); + +#define pa_streq(a,b) (!strcmp((a),(b))) +#define pa_strneq(a,b,n) (!strncmp((a),(b),(n))) + +/* Like pa_streq, but does not blow up on NULL pointers. */ +static inline bool pa_safe_streq(const char *a, const char *b) { + if (a == NULL || b == NULL) + return a == b; + return pa_streq(a, b); +} + +bool pa_str_in_list_spaces(const char *needle, const char *haystack); +bool pa_str_in_list(const char *haystack, const char *delimiters, const char *needle); + +char* pa_str_strip_suffix(const char *str, const char *suffix); + +char *pa_get_host_name_malloc(void); +char *pa_get_user_name_malloc(void); + +char *pa_machine_id(void); +char *pa_session_id(void); +char *pa_uname_string(void); + +#ifdef HAVE_VALGRIND_MEMCHECK_H +bool pa_in_valgrind(void); +#else +static inline bool pa_in_valgrind(void) { + return false; +} +#endif + +unsigned pa_gcd(unsigned a, unsigned b); +void pa_reduce(unsigned *num, unsigned *den); + +unsigned pa_ncpus(void); + +/* Replaces all occurrences of `a' in `s' with `b'. The caller has to free the + * returned string. All parameters must be non-NULL and additionally `a' must + * not be a zero-length string. + */ +char *pa_replace(const char*s, const char*a, const char *b); + +/* Escapes p by inserting backslashes in front of backslashes. chars is a + * regular (i.e. NULL-terminated) string containing additional characters that + * should be escaped. chars can be NULL. The caller has to free the returned + * string. */ +char *pa_escape(const char *p, const char *chars); + +/* Does regular backslash unescaping. Returns the argument p. */ +char *pa_unescape(char *p); + +char *pa_realpath(const char *path); + +void pa_disable_sigpipe(void); + +void pa_xfreev(void**a); + +static inline void pa_xstrfreev(char **a) { + pa_xfreev((void**) a); +} + +char **pa_split_spaces_strv(const char *s); + +char* pa_maybe_prefix_path(const char *path, const char *prefix); + +/* Returns size of the specified pipe or 4096 on failure */ +size_t pa_pipe_buf(int fd); + +void pa_reset_personality(void); + +bool pa_run_from_build_tree(void) PA_GCC_CONST; + +const char *pa_get_temp_dir(void); + +int pa_open_cloexec(const char *fn, int flags, mode_t mode); +int pa_socket_cloexec(int domain, int type, int protocol); +int pa_pipe_cloexec(int pipefd[2]); +int pa_accept_cloexec(int sockfd, struct sockaddr *addr, socklen_t *addrlen); +FILE* pa_fopen_cloexec(const char *path, const char *mode); + +void pa_nullify_stdfds(void); + +char *pa_read_line_from_file(const char *fn); +bool pa_running_in_vm(void); + +#ifdef OS_IS_WIN32 +char *pa_win32_get_toplevel(HANDLE handle); +#endif + +size_t pa_page_size(void); + +/* Rounds down */ +static inline void* PA_PAGE_ALIGN_PTR(const void *p) { + return (void*) (((size_t) p) & ~(pa_page_size() - 1)); +} + +/* Rounds up */ +static inline size_t PA_PAGE_ALIGN(size_t l) { + size_t page_size = pa_page_size(); + return (l + page_size - 1) & ~(page_size - 1); +} + +#endif diff --git a/pulse/pulsecore-14.0/core.h b/pulse/pulsecore-14.0/core.h new file mode 100644 index 00000000..57924b94 --- /dev/null +++ b/pulse/pulsecore-14.0/core.h @@ -0,0 +1,287 @@ +#ifndef foocorehfoo +#define foocorehfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include +#include +#include + +/* This is a bitmask that encodes the cause why a sink/source is + * suspended. + * + * When adding new causes, remember to update pa_suspend_cause_to_string() and + * PA_SUSPEND_CAUSE_TO_STRING_BUF_SIZE! */ +typedef enum pa_suspend_cause { + PA_SUSPEND_USER = 1, /* Exposed to the user via some protocol */ + PA_SUSPEND_APPLICATION = 2, /* Used by the device reservation logic */ + PA_SUSPEND_IDLE = 4, /* Used by module-suspend-on-idle */ + PA_SUSPEND_SESSION = 8, /* Used by module-hal for mark inactive sessions */ + PA_SUSPEND_PASSTHROUGH = 16, /* Used to suspend monitor sources when the sink is in passthrough mode */ + PA_SUSPEND_INTERNAL = 32, /* This is used for short period server-internal suspends, such as for sample rate updates */ + PA_SUSPEND_UNAVAILABLE = 64, /* Used by device implementations that have to suspend when the device is unavailable */ + PA_SUSPEND_ALL = 0xFFFF /* Magic cause that can be used to resume forcibly */ +} pa_suspend_cause_t; + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef enum pa_server_type { + PA_SERVER_TYPE_UNSET, + PA_SERVER_TYPE_USER, + PA_SERVER_TYPE_SYSTEM, + PA_SERVER_TYPE_NONE +} pa_server_type_t; + +typedef enum pa_core_state { + PA_CORE_STARTUP, + PA_CORE_RUNNING, + PA_CORE_SHUTDOWN +} pa_core_state_t; + +typedef enum pa_core_hook { + PA_CORE_HOOK_SINK_NEW, + PA_CORE_HOOK_SINK_FIXATE, + PA_CORE_HOOK_SINK_PUT, + PA_CORE_HOOK_SINK_UNLINK, + PA_CORE_HOOK_SINK_UNLINK_POST, + PA_CORE_HOOK_SINK_STATE_CHANGED, + PA_CORE_HOOK_SINK_PROPLIST_CHANGED, + PA_CORE_HOOK_SINK_PORT_CHANGED, + PA_CORE_HOOK_SINK_FLAGS_CHANGED, + PA_CORE_HOOK_SINK_VOLUME_CHANGED, + PA_CORE_HOOK_SINK_MUTE_CHANGED, + PA_CORE_HOOK_SINK_PORT_LATENCY_OFFSET_CHANGED, + PA_CORE_HOOK_SOURCE_NEW, + PA_CORE_HOOK_SOURCE_FIXATE, + PA_CORE_HOOK_SOURCE_PUT, + PA_CORE_HOOK_SOURCE_UNLINK, + PA_CORE_HOOK_SOURCE_UNLINK_POST, + PA_CORE_HOOK_SOURCE_STATE_CHANGED, + PA_CORE_HOOK_SOURCE_PROPLIST_CHANGED, + PA_CORE_HOOK_SOURCE_PORT_CHANGED, + PA_CORE_HOOK_SOURCE_FLAGS_CHANGED, + PA_CORE_HOOK_SOURCE_VOLUME_CHANGED, + PA_CORE_HOOK_SOURCE_MUTE_CHANGED, + PA_CORE_HOOK_SOURCE_PORT_LATENCY_OFFSET_CHANGED, + PA_CORE_HOOK_SINK_INPUT_NEW, + PA_CORE_HOOK_SINK_INPUT_FIXATE, + PA_CORE_HOOK_SINK_INPUT_PUT, + PA_CORE_HOOK_SINK_INPUT_UNLINK, + PA_CORE_HOOK_SINK_INPUT_UNLINK_POST, + PA_CORE_HOOK_SINK_INPUT_MOVE_START, + PA_CORE_HOOK_SINK_INPUT_MOVE_FINISH, + PA_CORE_HOOK_SINK_INPUT_MOVE_FAIL, + PA_CORE_HOOK_SINK_INPUT_STATE_CHANGED, + PA_CORE_HOOK_SINK_INPUT_PROPLIST_CHANGED, + PA_CORE_HOOK_SINK_INPUT_VOLUME_CHANGED, + PA_CORE_HOOK_SINK_INPUT_MUTE_CHANGED, + PA_CORE_HOOK_SINK_INPUT_SEND_EVENT, + PA_CORE_HOOK_SOURCE_OUTPUT_NEW, + PA_CORE_HOOK_SOURCE_OUTPUT_FIXATE, + PA_CORE_HOOK_SOURCE_OUTPUT_PUT, + PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK, + PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK_POST, + PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_START, + PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_FINISH, + PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_FAIL, + PA_CORE_HOOK_SOURCE_OUTPUT_STATE_CHANGED, + PA_CORE_HOOK_SOURCE_OUTPUT_PROPLIST_CHANGED, + PA_CORE_HOOK_SOURCE_OUTPUT_VOLUME_CHANGED, + PA_CORE_HOOK_SOURCE_OUTPUT_MUTE_CHANGED, + PA_CORE_HOOK_SOURCE_OUTPUT_SEND_EVENT, + PA_CORE_HOOK_CLIENT_NEW, + PA_CORE_HOOK_CLIENT_PUT, + PA_CORE_HOOK_CLIENT_UNLINK, + PA_CORE_HOOK_CLIENT_PROPLIST_CHANGED, + PA_CORE_HOOK_CLIENT_SEND_EVENT, + PA_CORE_HOOK_CARD_NEW, + PA_CORE_HOOK_CARD_CHOOSE_INITIAL_PROFILE, + PA_CORE_HOOK_CARD_PUT, + PA_CORE_HOOK_CARD_UNLINK, + PA_CORE_HOOK_CARD_PREFERRED_PORT_CHANGED, + PA_CORE_HOOK_CARD_PROFILE_CHANGED, + PA_CORE_HOOK_CARD_PROFILE_ADDED, + PA_CORE_HOOK_CARD_PROFILE_AVAILABLE_CHANGED, + PA_CORE_HOOK_CARD_SUSPEND_CHANGED, + PA_CORE_HOOK_PORT_AVAILABLE_CHANGED, + PA_CORE_HOOK_PORT_LATENCY_OFFSET_CHANGED, + PA_CORE_HOOK_DEFAULT_SINK_CHANGED, + PA_CORE_HOOK_DEFAULT_SOURCE_CHANGED, + PA_CORE_HOOK_MODULE_NEW, + PA_CORE_HOOK_MODULE_PROPLIST_CHANGED, + PA_CORE_HOOK_MODULE_UNLINK, + PA_CORE_HOOK_SAMPLE_CACHE_NEW, + PA_CORE_HOOK_SAMPLE_CACHE_CHANGED, + PA_CORE_HOOK_SAMPLE_CACHE_UNLINK, + PA_CORE_HOOK_MAX +} pa_core_hook_t; + +/* The core structure of PulseAudio. Every PulseAudio daemon contains + * exactly one of these. It is used for storing kind of global + * variables for the daemon. */ + +struct pa_core { + pa_msgobject parent; + + pa_core_state_t state; + + /* A random value which may be used to identify this instance of + * PulseAudio. Not cryptographically secure in any way. */ + uint32_t cookie; + + pa_mainloop_api *mainloop; + + /* idxset of all kinds of entities */ + pa_idxset *clients, *cards, *sinks, *sources, *sink_inputs, *source_outputs, *modules, *scache; + + /* Some hashmaps for all sorts of entities */ + pa_hashmap *namereg, *shared, *message_handlers; + + /* The default sink/source as configured by the user. If the user hasn't + * explicitly configured anything, these are set to NULL. These are strings + * instead of sink/source pointers, because that allows us to reference + * devices that don't currently exist. That's useful for remembering that + * a hotplugged USB sink was previously set as the default sink. */ + char *configured_default_sink; + char *configured_default_source; + + /* The effective default sink/source. If no sink or source is explicitly + * configured as the default, we pick the device that ranks highest + * according to the compare_sinks() and compare_sources() functions in + * core.c. pa_core_update_default_sink/source() has to be called whenever + * anything changes that might change the comparison results. */ + pa_sink *default_sink; + pa_source *default_source; + + pa_channel_map default_channel_map; + pa_sample_spec default_sample_spec; + uint32_t alternate_sample_rate; + unsigned default_n_fragments, default_fragment_size_msec; + unsigned deferred_volume_safety_margin_usec; + int deferred_volume_extra_delay_usec; + unsigned lfe_crossover_freq; + + pa_defer_event *module_defer_unload_event; + pa_hashmap *modules_pending_unload; /* pa_module -> pa_module (hashmap-as-a-set) */ + + pa_defer_event *subscription_defer_event; + PA_LLIST_HEAD(pa_subscription, subscriptions); + PA_LLIST_HEAD(pa_subscription_event, subscription_event_queue); + pa_subscription_event *subscription_event_last; + + /* The mempool is used for data we write to, it's readonly for the client. */ + pa_mempool *mempool; + + /* Shared memory size, as specified either by daemon configuration + * or PA daemon defaults (~ 64 MiB). */ + size_t shm_size; + + pa_silence_cache silence_cache; + + pa_time_event *exit_event; + pa_time_event *scache_auto_unload_event; + + int exit_idle_time, scache_idle_time; + + bool flat_volumes:1; + bool rescue_streams:1; + bool disallow_module_loading:1; + bool disallow_exit:1; + bool running_as_daemon:1; + bool realtime_scheduling:1; + bool avoid_resampling:1; + bool disable_remixing:1; + bool remixing_use_all_sink_channels:1; + bool remixing_produce_lfe:1; + bool remixing_consume_lfe:1; + bool deferred_volume:1; + + pa_resample_method_t resample_method; + int realtime_priority; + + pa_server_type_t server_type; + pa_cpu_info cpu_info; + + /* hooks */ + pa_hook hooks[PA_CORE_HOOK_MAX]; +}; + +PA_DECLARE_PUBLIC_CLASS(pa_core); +#define PA_CORE(o) pa_core_cast(o) + +enum { + PA_CORE_MESSAGE_UNLOAD_MODULE, + PA_CORE_MESSAGE_MAX +}; + +pa_core* pa_core_new(pa_mainloop_api *m, bool shared, bool enable_memfd, size_t shm_size); + +void pa_core_set_configured_default_sink(pa_core *core, const char *sink); +void pa_core_set_configured_default_source(pa_core *core, const char *source); + +/* These should be called whenever something changes that may affect the + * default sink or source choice. + * + * If the default source choice happens between two monitor sources, the + * monitored sinks are compared, so if the default sink changes, the default + * source may change too. However, pa_core_update_default_sink() calls + * pa_core_update_default_source() internally, so it's sufficient to only call + * pa_core_update_default_sink() when something happens that affects the sink + * ordering. */ +void pa_core_update_default_sink(pa_core *core); +void pa_core_update_default_source(pa_core *core); + +void pa_core_set_exit_idle_time(pa_core *core, int time); + +/* Check whether no one is connected to this core */ +void pa_core_check_idle(pa_core *c); + +int pa_core_exit(pa_core *c, bool force, int retval); + +void pa_core_maybe_vacuum(pa_core *c); + +/* wrapper for c->mainloop->time_*() RT time events */ +pa_time_event* pa_core_rttime_new(pa_core *c, pa_usec_t usec, pa_time_event_cb_t cb, void *userdata); +void pa_core_rttime_restart(pa_core *c, pa_time_event *e, pa_usec_t usec); + +static const size_t PA_SUSPEND_CAUSE_TO_STRING_BUF_SIZE = + sizeof("USER|APPLICATION|IDLE|SESSION|PASSTHROUGH|INTERNAL|UNAVAILABLE"); + +/* Converts the given suspend cause to a string. The string is written to the + * provided buffer. The same buffer is the return value of this function. */ +const char *pa_suspend_cause_to_string(pa_suspend_cause_t cause, char buf[PA_SUSPEND_CAUSE_TO_STRING_BUF_SIZE]); + +void pa_core_move_streams_to_newly_available_preferred_sink(pa_core *c, pa_sink *s); + +void pa_core_move_streams_to_newly_available_preferred_source(pa_core *c, pa_source *s); + +#endif diff --git a/pulse/pulsecore-14.0/cpu-arm.h b/pulse/pulsecore-14.0/cpu-arm.h new file mode 100644 index 00000000..dfdda325 --- /dev/null +++ b/pulse/pulsecore-14.0/cpu-arm.h @@ -0,0 +1,53 @@ +#ifndef foocpuarmhfoo +#define foocpuarmhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2009 Wim Taymans + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include + +#ifndef PACKAGE +#error "Please include config.h before including this file!" +#endif + +typedef enum pa_cpu_arm_flag { + PA_CPU_ARM_V6 = (1 << 0), + PA_CPU_ARM_V7 = (1 << 1), + PA_CPU_ARM_VFP = (1 << 2), + PA_CPU_ARM_EDSP = (1 << 3), + PA_CPU_ARM_NEON = (1 << 4), + PA_CPU_ARM_VFPV3 = (1 << 5), + PA_CPU_ARM_CORTEX_A8 = (1 << 6), +} pa_cpu_arm_flag_t; + +void pa_cpu_get_arm_flags(pa_cpu_arm_flag_t *flags); +bool pa_cpu_init_arm(pa_cpu_arm_flag_t *flags); + +/* some optimized functions */ +void pa_volume_func_init_arm(pa_cpu_arm_flag_t flags); + +#ifdef HAVE_NEON +void pa_convert_func_init_neon(pa_cpu_arm_flag_t flags); +void pa_mix_func_init_neon(pa_cpu_arm_flag_t flags); +void pa_remap_func_init_neon(pa_cpu_arm_flag_t flags); +#endif + +#endif /* foocpuarmhfoo */ diff --git a/pulse/pulsecore-14.0/cpu-orc.h b/pulse/pulsecore-14.0/cpu-orc.h new file mode 100644 index 00000000..edfacea8 --- /dev/null +++ b/pulse/pulsecore-14.0/cpu-orc.h @@ -0,0 +1,31 @@ +#ifndef foocpuorchfoo +#define foocpuorchfoo + +/*** + This file is part of PulseAudio. + + Copyright 2010 Arun Raghavan + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +/* Orc-optimised bits */ + +bool pa_cpu_init_orc(pa_cpu_info cpu_info); + +void pa_volume_func_init_orc(void); + +#endif /* foocpuorchfoo */ diff --git a/pulse/pulsecore-14.0/cpu-x86.h b/pulse/pulsecore-14.0/cpu-x86.h new file mode 100644 index 00000000..eff20148 --- /dev/null +++ b/pulse/pulsecore-14.0/cpu-x86.h @@ -0,0 +1,59 @@ +#ifndef foocpux86hfoo +#define foocpux86hfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2009 Wim Taymans + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include + +typedef enum pa_cpu_x86_flag { + PA_CPU_X86_MMX = (1 << 0), + PA_CPU_X86_MMXEXT = (1 << 1), + PA_CPU_X86_SSE = (1 << 2), + PA_CPU_X86_SSE2 = (1 << 3), + PA_CPU_X86_SSE3 = (1 << 4), + PA_CPU_X86_SSSE3 = (1 << 5), + PA_CPU_X86_SSE4_1 = (1 << 6), + PA_CPU_X86_SSE4_2 = (1 << 7), + PA_CPU_X86_3DNOW = (1 << 8), + PA_CPU_X86_3DNOWEXT = (1 << 9), + PA_CPU_X86_CMOV = (1 << 10) +} pa_cpu_x86_flag_t; + +void pa_cpu_get_x86_flags(pa_cpu_x86_flag_t *flags); +bool pa_cpu_init_x86 (pa_cpu_x86_flag_t *flags); + +#if defined (__i386__) +typedef int32_t pa_reg_x86; +#elif defined (__amd64__) +typedef int64_t pa_reg_x86; +#endif + +/* some optimized functions */ +void pa_volume_func_init_mmx(pa_cpu_x86_flag_t flags); +void pa_volume_func_init_sse(pa_cpu_x86_flag_t flags); + +void pa_remap_func_init_mmx(pa_cpu_x86_flag_t flags); +void pa_remap_func_init_sse(pa_cpu_x86_flag_t flags); + +void pa_convert_func_init_sse (pa_cpu_x86_flag_t flags); + +#endif /* foocpux86hfoo */ diff --git a/pulse/pulsecore-14.0/cpu.h b/pulse/pulsecore-14.0/cpu.h new file mode 100644 index 00000000..e65c4fb6 --- /dev/null +++ b/pulse/pulsecore-14.0/cpu.h @@ -0,0 +1,49 @@ +#ifndef foocpuhfoo +#define foocpuhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2010 Arun Raghavan + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include + +typedef enum { + PA_CPU_UNDEFINED = 0, + PA_CPU_X86, + PA_CPU_ARM, +} pa_cpu_type_t; + +typedef struct pa_cpu_info pa_cpu_info; + +struct pa_cpu_info { + pa_cpu_type_t cpu_type; + + union { + pa_cpu_x86_flag_t x86; + pa_cpu_arm_flag_t arm; + } flags; + bool force_generic_code; +}; + +void pa_cpu_init(pa_cpu_info *cpu_info); + +void pa_remap_func_init(const pa_cpu_info *cpu_info); +void pa_mix_func_init(const pa_cpu_info *cpu_info); + +#endif /* foocpuhfoo */ diff --git a/pulse/pulsecore-14.0/creds.h b/pulse/pulsecore-14.0/creds.h new file mode 100644 index 00000000..9fdbb4f7 --- /dev/null +++ b/pulse/pulsecore-14.0/creds.h @@ -0,0 +1,64 @@ +#ifndef foocredshfoo +#define foocredshfoo + +/*** + This file is part of PulseAudio. + + Copyright 2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include + +#ifndef PACKAGE +#error "Please include config.h before including this file!" +#endif + +#include +#include + +#define MAX_ANCIL_DATA_FDS 2 + +typedef struct pa_creds pa_creds; +typedef struct pa_cmsg_ancil_data pa_cmsg_ancil_data; + +#if defined(SCM_CREDENTIALS) + +#define HAVE_CREDS 1 + +struct pa_creds { + gid_t gid; + uid_t uid; +}; + +/* Struct for handling ancillary data, i e, extra data that can be sent together with a message + * over unix pipes. Supports sending and receiving credentials and file descriptors. */ +struct pa_cmsg_ancil_data { + pa_creds creds; + bool creds_valid; + int nfd; + + /* Don't close these fds by your own. Check pa_cmsg_ancil_data_close_fds() */ + int fds[MAX_ANCIL_DATA_FDS]; + bool close_fds_on_cleanup; +}; + +void pa_cmsg_ancil_data_close_fds(struct pa_cmsg_ancil_data *ancil); + +#else +#undef HAVE_CREDS +#endif + +#endif diff --git a/pulse/pulsecore-14.0/database.h b/pulse/pulsecore-14.0/database.h new file mode 100644 index 00000000..3a1c7cea --- /dev/null +++ b/pulse/pulsecore-14.0/database.h @@ -0,0 +1,59 @@ +#ifndef foopulsecoredatabasehfoo +#define foopulsecoredatabasehfoo + +/*** + This file is part of PulseAudio. + + Copyright 2009 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include + +#include + +/* A little abstraction over simple databases, such as gdbm, tdb, and + * so on. We only make minimal assumptions about the supported + * backend: it does not need to support locking, it does not have to + * be arch independent. */ + +typedef struct pa_database pa_database; + +typedef struct pa_datum { + void *data; + size_t size; +} pa_datum; + +void pa_datum_free(pa_datum *d); + +/* This will append a suffix to the filename */ +pa_database* pa_database_open(const char *fn, bool for_write); +void pa_database_close(pa_database *db); + +pa_datum* pa_database_get(pa_database *db, const pa_datum *key, pa_datum* data); + +int pa_database_set(pa_database *db, const pa_datum *key, const pa_datum* data, bool overwrite); +int pa_database_unset(pa_database *db, const pa_datum *key); + +int pa_database_clear(pa_database *db); + +signed pa_database_size(pa_database *db); + +pa_datum* pa_database_first(pa_database *db, pa_datum *key, pa_datum *data /* may be NULL */); +pa_datum* pa_database_next(pa_database *db, const pa_datum *key, pa_datum *next, pa_datum *data /* may be NULL */); + +int pa_database_sync(pa_database *db); + +#endif diff --git a/pulse/pulsecore-14.0/dbus-shared.h b/pulse/pulsecore-14.0/dbus-shared.h new file mode 100644 index 00000000..3d552e9c --- /dev/null +++ b/pulse/pulsecore-14.0/dbus-shared.h @@ -0,0 +1,40 @@ +#ifndef foodbussharedhfoo +#define foodbussharedhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006, 2009 Lennart Poettering + Copyright 2006 Shams E. King + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +#include +#include + +typedef struct pa_dbus_connection pa_dbus_connection; + +/* return a pa_dbus_connection of the specified type for the given core, + * like dbus_bus_get(), but integrates the connection with the pa_core */ +pa_dbus_connection* pa_dbus_bus_get(pa_core *c, DBusBusType type, DBusError *error); + +DBusConnection* pa_dbus_connection_get(pa_dbus_connection *conn); + +pa_dbus_connection* pa_dbus_connection_ref(pa_dbus_connection *conn); +void pa_dbus_connection_unref(pa_dbus_connection *conn); + +#endif diff --git a/pulse/pulsecore-14.0/dbus-util.h b/pulse/pulsecore-14.0/dbus-util.h new file mode 100644 index 00000000..cc3abda8 --- /dev/null +++ b/pulse/pulsecore-14.0/dbus-util.h @@ -0,0 +1,114 @@ +#ifndef foodbusutilhfoo +#define foodbusutilhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2006 Shams E. King + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +#include +#include +#include + +#include + +/* A wrap connection is not shared or refcounted, it is available in client side */ +typedef struct pa_dbus_wrap_connection pa_dbus_wrap_connection; + +pa_dbus_wrap_connection* pa_dbus_wrap_connection_new(pa_mainloop_api *mainloop, bool use_rtclock, DBusBusType type, DBusError *error); +pa_dbus_wrap_connection* pa_dbus_wrap_connection_new_from_existing( + pa_mainloop_api *mainloop, + bool use_rtclock, + DBusConnection *conn); +void pa_dbus_wrap_connection_free(pa_dbus_wrap_connection* conn); + +DBusConnection* pa_dbus_wrap_connection_get(pa_dbus_wrap_connection *conn); + +int pa_dbus_add_matches(DBusConnection *c, DBusError *error, ...) PA_GCC_SENTINEL; +void pa_dbus_remove_matches(DBusConnection *c, ...) PA_GCC_SENTINEL; + +typedef struct pa_dbus_pending pa_dbus_pending; + +struct pa_dbus_pending { + DBusConnection *connection; + DBusMessage *message; + DBusPendingCall *pending; + + void *context_data; + void *call_data; + + PA_LLIST_FIELDS(pa_dbus_pending); +}; + +pa_dbus_pending *pa_dbus_pending_new(DBusConnection *c, DBusMessage *m, DBusPendingCall *pending, void *context_data, void *call_data); +void pa_dbus_pending_free(pa_dbus_pending *p); + +/* Sync up a list of pa_dbus_pending_call objects */ +void pa_dbus_sync_pending_list(pa_dbus_pending **p); + +/* Free up a list of pa_dbus_pending_call objects */ +void pa_dbus_free_pending_list(pa_dbus_pending **p); + +/* When receiving a DBusMessage with type DBUS_MESSAGE_TYPE_ERROR, the + * DBusMessage may or may not contain an error message (a human-readable + * explanation of what went wrong). Extracting the error message from the + * DBusMessage object is a bit tedious, so here's a helper function that does + * that. If the DBusMessage doesn't contain any error message, + * "" is returned. */ +const char *pa_dbus_get_error_message(DBusMessage *m); + +/* Sends an error message as the reply to the given message. */ +void pa_dbus_send_error( + DBusConnection *c, + DBusMessage *in_reply_to, + const char *name, + const char *format, ...) PA_GCC_PRINTF_ATTR(4, 5); + +void pa_dbus_send_empty_reply(DBusConnection *c, DBusMessage *in_reply_to); +void pa_dbus_send_basic_value_reply(DBusConnection *c, DBusMessage *in_reply_to, int type, void *data); +void pa_dbus_send_basic_variant_reply(DBusConnection *c, DBusMessage *in_reply_to, int type, void *data); +void pa_dbus_send_basic_array_variant_reply( + DBusConnection *c, + DBusMessage *in_reply_to, + int item_type, + void *array, + unsigned n); +void pa_dbus_send_proplist_variant_reply(DBusConnection *c, DBusMessage *in_reply_to, pa_proplist *proplist); + +void pa_dbus_append_basic_array(DBusMessageIter *iter, int item_type, const void *array, unsigned n); +void pa_dbus_append_basic_array_variant(DBusMessageIter *iter, int item_type, const void *array, unsigned n); +void pa_dbus_append_basic_variant(DBusMessageIter *iter, int type, void *data); +void pa_dbus_append_basic_variant_dict_entry(DBusMessageIter *dict_iter, const char *key, int type, void *data); +void pa_dbus_append_basic_array_variant_dict_entry( + DBusMessageIter *dict_iter, + const char *key, + int item_type, + const void *array, + unsigned n); +void pa_dbus_append_proplist(DBusMessageIter *iter, pa_proplist *proplist); +void pa_dbus_append_proplist_variant(DBusMessageIter *iter, pa_proplist *proplist); +void pa_dbus_append_proplist_variant_dict_entry(DBusMessageIter *dict_iter, const char *key, pa_proplist *proplist); + +/* Returns a new proplist that the caller has to free. If the proplist contains + * invalid keys, an error reply is sent and NULL is returned. The iterator must + * point to "a{say}" element. This function calls dbus_message_iter_next(iter) + * before returning. */ +pa_proplist *pa_dbus_get_proplist_arg(DBusConnection *c, DBusMessage *msg, DBusMessageIter *iter); + +#endif diff --git a/pulse/pulsecore-14.0/device-port.h b/pulse/pulsecore-14.0/device-port.h new file mode 100644 index 00000000..7178ff2a --- /dev/null +++ b/pulse/pulsecore-14.0/device-port.h @@ -0,0 +1,100 @@ +#ifndef foopulsedeviceporthfoo +#define foopulsedeviceporthfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + Copyright 2011 David Henningsson, Canonical Ltd. + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include +#include +#include +#include +#include +#include + +struct pa_device_port { + pa_object parent; /* Needed for reference counting */ + pa_core *core; + pa_card *card; + + char *name; + char *description; + char *preferred_profile; + pa_device_port_type_t type; + + unsigned priority; + pa_available_t available; /* PA_AVAILABLE_UNKNOWN, PA_AVAILABLE_NO or PA_AVAILABLE_YES */ + char *availability_group; /* a string indentifier which determine the group of devices handling the available state simulteneously */ + + pa_proplist *proplist; + pa_hashmap *profiles; /* Does not own the profiles */ + pa_direction_t direction; + int64_t latency_offset; + + /* Free the extra implementation specific data. Called before other members are freed. */ + void (*impl_free)(pa_device_port *port); + + /* .. followed by some implementation specific data */ +}; + +PA_DECLARE_PUBLIC_CLASS(pa_device_port); +#define PA_DEVICE_PORT(s) (pa_device_port_cast(s)) + +#define PA_DEVICE_PORT_DATA(d) ((void*) ((uint8_t*) d + PA_ALIGN(sizeof(pa_device_port)))) + +typedef struct pa_device_port_new_data { + char *name; + char *description; + pa_available_t available; + char *availability_group; + pa_direction_t direction; + pa_device_port_type_t type; +} pa_device_port_new_data; + +pa_device_port_new_data *pa_device_port_new_data_init(pa_device_port_new_data *data); +void pa_device_port_new_data_set_name(pa_device_port_new_data *data, const char *name); +void pa_device_port_new_data_set_description(pa_device_port_new_data *data, const char *description); +void pa_device_port_new_data_set_available(pa_device_port_new_data *data, pa_available_t available); +void pa_device_port_new_data_set_availability_group(pa_device_port_new_data *data, const char *group); +void pa_device_port_new_data_set_direction(pa_device_port_new_data *data, pa_direction_t direction); +void pa_device_port_new_data_set_type(pa_device_port_new_data *data, pa_device_port_type_t type); +void pa_device_port_new_data_done(pa_device_port_new_data *data); + +pa_device_port *pa_device_port_new(pa_core *c, pa_device_port_new_data *data, size_t extra); + +/* The port's available status has changed */ +void pa_device_port_set_available(pa_device_port *p, pa_available_t available); + +void pa_device_port_set_latency_offset(pa_device_port *p, int64_t offset); +void pa_device_port_set_preferred_profile(pa_device_port *p, const char *new_pp); + +pa_device_port *pa_device_port_find_best(pa_hashmap *ports); + +pa_sink *pa_device_port_get_sink(pa_device_port *p); + +pa_source *pa_device_port_get_source(pa_device_port *p); + +#endif diff --git a/pulse/pulsecore-14.0/dynarray.h b/pulse/pulsecore-14.0/dynarray.h new file mode 100644 index 00000000..4c0925e7 --- /dev/null +++ b/pulse/pulsecore-14.0/dynarray.h @@ -0,0 +1,73 @@ +#ifndef foopulsecoredynarrayhfoo +#define foopulsecoredynarrayhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2008 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include + +typedef struct pa_dynarray pa_dynarray; + +/* Implementation of a simple dynamically sized array for storing pointers. + * + * When the array is created, a free callback can be provided, which will be + * then used when removing items from the array and when freeing the array. If + * the free callback is not provided, the memory management of the stored items + * is the responsibility of the array user. If there is need to remove items + * from the array without freeing them, while also having the free callback + * set, the functions with "steal" in their name can be used. + * + * Removing items from the middle of the array causes the last item to be + * moved to the place of the removed item. That is, array ordering is not + * preserved. + * + * The array doesn't support storing NULL pointers. */ + +pa_dynarray* pa_dynarray_new(pa_free_cb_t free_cb); +void pa_dynarray_free(pa_dynarray *array); + +void pa_dynarray_append(pa_dynarray *array, void *p); + +/* Returns the element at index i, or NULL if i is out of bounds. */ +void *pa_dynarray_get(pa_dynarray *array, unsigned i); + +/* Returns the last element, or NULL if the array is empty. */ +void *pa_dynarray_last(pa_dynarray *array); + +/* Returns -PA_ERR_NOENTITY if i is out of bounds, and zero otherwise. */ +int pa_dynarray_remove_by_index(pa_dynarray *array, unsigned i); + +/* Returns -PA_ERR_NOENTITY if p is not found in the array, and zero + * otherwise. If the array contains multiple occurrences of p, only one of + * them is removed (and it's unspecified which one). */ +int pa_dynarray_remove_by_data(pa_dynarray *array, void *p); + +/* Returns the removed item, or NULL if the array is empty. */ +void *pa_dynarray_steal_last(pa_dynarray *array); + +unsigned pa_dynarray_size(pa_dynarray *array); + +/* Returns -PA_ERR_NOENTITY if i is out of bounds, and zero otherwise. + * Here i is the location index in the array like 0, ..., array->entries */ +int pa_dynarray_insert_by_index(pa_dynarray *array, void *p, unsigned i); + +#define PA_DYNARRAY_FOREACH(elem, array, idx) \ + for ((idx) = 0; ((elem) = pa_dynarray_get(array, idx)); (idx)++) + +#endif diff --git a/pulse/pulsecore-14.0/endianmacros.h b/pulse/pulsecore-14.0/endianmacros.h new file mode 100644 index 00000000..c4cb8a22 --- /dev/null +++ b/pulse/pulsecore-14.0/endianmacros.h @@ -0,0 +1,160 @@ +#ifndef fooendianmacroshfoo +#define fooendianmacroshfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +#ifndef PACKAGE +#error "Please include config.h before including this file!" +#endif + +#ifdef HAVE_BYTESWAP_H +#include +#endif + +#ifdef HAVE_BYTESWAP_H +#define PA_INT16_SWAP(x) ((int16_t) bswap_16((uint16_t) x)) +#define PA_UINT16_SWAP(x) ((uint16_t) bswap_16((uint16_t) x)) +#define PA_INT32_SWAP(x) ((int32_t) bswap_32((uint32_t) x)) +#define PA_UINT32_SWAP(x) ((uint32_t) bswap_32((uint32_t) x)) +#else +#define PA_INT16_SWAP(x) ( (int16_t) ( ((uint16_t) (x) >> 8) | ((uint16_t) (x) << 8) ) ) +#define PA_UINT16_SWAP(x) ( (uint16_t) ( ((uint16_t) (x) >> 8) | ((uint16_t) (x) << 8) ) ) +#define PA_INT32_SWAP(x) ( (int32_t) ( ((uint32_t) (x) >> 24) | ((uint32_t) (x) << 24) | (((uint32_t) (x) & 0xFF00) << 8) | ((((uint32_t) (x)) >> 8) & 0xFF00) ) ) +#define PA_UINT32_SWAP(x) ( (uint32_t) ( ((uint32_t) (x) >> 24) | ((uint32_t) (x) << 24) | (((uint32_t) (x) & 0xFF00) << 8) | ((((uint32_t) (x)) >> 8) & 0xFF00) ) ) +#endif + +static inline uint32_t PA_READ24BE(const uint8_t *p) { + return + ((uint32_t) p[0] << 16) | + ((uint32_t) p[1] << 8) | + ((uint32_t) p[2]); +} + +static inline uint32_t PA_READ24LE(const uint8_t *p) { + return + ((uint32_t) p[2] << 16) | + ((uint32_t) p[1] << 8) | + ((uint32_t) p[0]); +} + +static inline void PA_WRITE24BE(uint8_t *p, uint32_t u) { + p[0] = (uint8_t) (u >> 16); + p[1] = (uint8_t) (u >> 8); + p[2] = (uint8_t) u; +} + +static inline void PA_WRITE24LE(uint8_t *p, uint32_t u) { + p[2] = (uint8_t) (u >> 16); + p[1] = (uint8_t) (u >> 8); + p[0] = (uint8_t) u; +} + +static inline float PA_READ_FLOAT32RE(const void *p) { + union { + float f; + uint32_t u; + } t; + + t.u = PA_UINT32_SWAP(*(uint32_t *) p); + return t.f; +} + +static inline void PA_WRITE_FLOAT32RE(void *p, float x) { + union { + float f; + uint32_t u; + } t; + + t.f = x; + *(uint32_t *) p = PA_UINT32_SWAP(t.u); +} + +#define PA_MAYBE_INT16_SWAP(c,x) ((c) ? PA_INT16_SWAP(x) : (x)) +#define PA_MAYBE_UINT16_SWAP(c,x) ((c) ? PA_UINT16_SWAP(x) : (x)) + +#define PA_MAYBE_INT32_SWAP(c,x) ((c) ? PA_INT32_SWAP(x) : (x)) +#define PA_MAYBE_UINT32_SWAP(c,x) ((c) ? PA_UINT32_SWAP(x) : (x)) + +#ifdef WORDS_BIGENDIAN + #define PA_INT16_FROM_LE(x) PA_INT16_SWAP(x) + #define PA_INT16_FROM_BE(x) ((int16_t)(x)) + + #define PA_INT16_TO_LE(x) PA_INT16_SWAP(x) + #define PA_INT16_TO_BE(x) ((int16_t)(x)) + + #define PA_UINT16_FROM_LE(x) PA_UINT16_SWAP(x) + #define PA_UINT16_FROM_BE(x) ((uint16_t)(x)) + + #define PA_UINT16_TO_LE(x) PA_UINT16_SWAP(x) + #define PA_UINT16_TO_BE(x) ((uint16_t)(x)) + + #define PA_INT32_FROM_LE(x) PA_INT32_SWAP(x) + #define PA_INT32_FROM_BE(x) ((int32_t)(x)) + + #define PA_INT32_TO_LE(x) PA_INT32_SWAP(x) + #define PA_INT32_TO_BE(x) ((int32_t)(x)) + + #define PA_UINT32_FROM_LE(x) PA_UINT32_SWAP(x) + #define PA_UINT32_FROM_BE(x) ((uint32_t)(x)) + + #define PA_UINT32_TO_LE(x) PA_UINT32_SWAP(x) + #define PA_UINT32_TO_BE(x) ((uint32_t)(x)) + + #define PA_READ24NE(x) PA_READ24BE(x) + #define PA_WRITE24NE(x,y) PA_WRITE24BE((x),(y)) + + #define PA_READ24RE(x) PA_READ24LE(x) + #define PA_WRITE24RE(x,y) PA_WRITE24LE((x),(y)) +#else + #define PA_INT16_FROM_LE(x) ((int16_t)(x)) + #define PA_INT16_FROM_BE(x) PA_INT16_SWAP(x) + + #define PA_INT16_TO_LE(x) ((int16_t)(x)) + #define PA_INT16_TO_BE(x) PA_INT16_SWAP(x) + + #define PA_UINT16_FROM_LE(x) ((uint16_t)(x)) + #define PA_UINT16_FROM_BE(x) PA_UINT16_SWAP(x) + + #define PA_UINT16_TO_LE(x) ((uint16_t)(x)) + #define PA_UINT16_TO_BE(x) PA_UINT16_SWAP(x) + + #define PA_INT32_FROM_LE(x) ((int32_t)(x)) + #define PA_INT32_FROM_BE(x) PA_INT32_SWAP(x) + + #define PA_INT32_TO_LE(x) ((int32_t)(x)) + #define PA_INT32_TO_BE(x) PA_INT32_SWAP(x) + + #define PA_UINT32_FROM_LE(x) ((uint32_t)(x)) + #define PA_UINT32_FROM_BE(x) PA_UINT32_SWAP(x) + + #define PA_UINT32_TO_LE(x) ((uint32_t)(x)) + #define PA_UINT32_TO_BE(x) PA_UINT32_SWAP(x) + + #define PA_READ24NE(x) PA_READ24LE(x) + #define PA_WRITE24NE(x,y) PA_WRITE24LE((x),(y)) + + #define PA_READ24RE(x) PA_READ24BE(x) + #define PA_WRITE24RE(x,y) PA_WRITE24BE((x),(y)) +#endif + +#endif diff --git a/pulse/pulsecore-14.0/esound.h b/pulse/pulsecore-14.0/esound.h new file mode 100644 index 00000000..4ca0e042 --- /dev/null +++ b/pulse/pulsecore-14.0/esound.h @@ -0,0 +1,204 @@ +#ifndef fooesoundhfoo +#define fooesoundhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +/* Most of the following is blatantly stolen from esound. */ + +/* path and name of the default EsounD domain socket */ +#define ESD_UNIX_SOCKET_DIR "/tmp/.esd" +#define ESD_UNIX_SOCKET_NAME "/tmp/.esd/socket" + +/* length of the audio buffer size */ +#define ESD_BUF_SIZE (4 * 1024) +/* maximum size we can write(). Otherwise we might overflow */ +#define ESD_MAX_WRITE_SIZE (21 * 4096) + +/* length of the authentication key, octets */ +#define ESD_KEY_LEN (16) + +/* default port for the EsounD server */ +#define ESD_DEFAULT_PORT (16001) + +/* default sample rate for the EsounD server */ +#define ESD_DEFAULT_RATE (44100) + +/* maximum length of a stream/sample name */ +#define ESD_NAME_MAX (128) + +/* a magic number to identify the relative endianness of a client */ +#define ESD_ENDIAN_KEY ((uint32_t) (('E' << 24) + ('N' << 16) + ('D' << 8) + ('N'))) + +#define ESD_VOLUME_BASE (256) + +/*************************************/ +/* what can we do to/with the EsounD */ +enum esd_proto { + ESD_PROTO_CONNECT, /* implied on initial client connection */ + + /* pseudo "security" functionality */ + ESD_PROTO_LOCK, /* disable "foreign" client connections */ + ESD_PROTO_UNLOCK, /* enable "foreign" client connections */ + + /* stream functionality: play, record, monitor */ + ESD_PROTO_STREAM_PLAY, /* play all following data as a stream */ + ESD_PROTO_STREAM_REC, /* record data from card as a stream */ + ESD_PROTO_STREAM_MON, /* send mixed buffer output as a stream */ + + /* sample functionality: cache, free, play, loop, EOL, kill */ + ESD_PROTO_SAMPLE_CACHE, /* cache a sample in the server */ + ESD_PROTO_SAMPLE_FREE, /* release a sample in the server */ + ESD_PROTO_SAMPLE_PLAY, /* play a cached sample */ + ESD_PROTO_SAMPLE_LOOP, /* loop a cached sample, til eoloop */ + ESD_PROTO_SAMPLE_STOP, /* stop a looping sample when done */ + ESD_PROTO_SAMPLE_KILL, /* stop the looping sample immediately */ + + /* free and reclaim /dev/dsp functionality */ + ESD_PROTO_STANDBY, /* release /dev/dsp and ignore all data */ + ESD_PROTO_RESUME, /* reclaim /dev/dsp and play sounds again */ + + /* TODO: move these to a more logical place. NOTE: will break the protocol */ + ESD_PROTO_SAMPLE_GETID, /* get the ID for an already-cached sample */ + ESD_PROTO_STREAM_FILT, /* filter mixed buffer output as a stream */ + + /* esd remote management */ + ESD_PROTO_SERVER_INFO, /* get server info (ver, sample rate, format) */ + ESD_PROTO_ALL_INFO, /* get all info (server info, players, samples) */ + ESD_PROTO_SUBSCRIBE, /* track new and removed players and samples */ + ESD_PROTO_UNSUBSCRIBE, /* stop tracking updates */ + + /* esd remote control */ + ESD_PROTO_STREAM_PAN, /* set stream panning */ + ESD_PROTO_SAMPLE_PAN, /* set default sample panning */ + + /* esd status */ + ESD_PROTO_STANDBY_MODE, /* see if server is in standby, autostandby, etc */ + + /* esd latency */ + ESD_PROTO_LATENCY, /* retrieve latency between write()'s and output */ + + ESD_PROTO_MAX /* for bounds checking */ +}; + +/******************/ +/* The EsounD api */ + +/* the properties of a sound buffer are logically or'd */ + +/* bits of stream/sample data */ +#define ESD_MASK_BITS ( 0x000F ) +#define ESD_BITS8 ( 0x0000 ) +#define ESD_BITS16 ( 0x0001 ) + +/* how many interleaved channels of data */ +#define ESD_MASK_CHAN ( 0x00F0 ) +#define ESD_MONO ( 0x0010 ) +#define ESD_STEREO ( 0x0020 ) + +/* whether it's a stream or a sample */ +#define ESD_MASK_MODE ( 0x0F00 ) +#define ESD_STREAM ( 0x0000 ) +#define ESD_SAMPLE ( 0x0100 ) +#define ESD_ADPCM ( 0x0200 ) /* TODO: anyone up for this? =P */ + +/* the function of the stream/sample, and common functions */ +#define ESD_MASK_FUNC ( 0xF000 ) +#define ESD_PLAY ( 0x1000 ) +/* functions for streams only */ +#define ESD_MONITOR ( 0x0000 ) +#define ESD_RECORD ( 0x2000 ) +/* functions for samples only */ +#define ESD_STOP ( 0x0000 ) +#define ESD_LOOP ( 0x2000 ) + +typedef int esd_format_t; +typedef int esd_proto_t; + +/*******************************************************************/ +/* esdmgr.c - functions to implement a "sound manager" for esd */ + +/* structures to retrieve information about streams/samples from the server */ +typedef struct esd_server_info { + + int version; /* server version encoded as an int */ + esd_format_t format; /* magic int with the format info */ + int rate; /* sample rate */ + +} esd_server_info_t; + +typedef struct esd_player_info { + + struct esd_player_info *next; /* point to next entry in list */ + esd_server_info_t *server; /* the server that contains this stream */ + + int source_id; /* either a stream fd or sample id */ + char name[ ESD_NAME_MAX ]; /* name of stream for remote control */ + int rate; /* sample rate */ + int left_vol_scale; /* volume scaling */ + int right_vol_scale; + + esd_format_t format; /* magic int with the format info */ + +} esd_player_info_t; + +typedef struct esd_sample_info { + + struct esd_sample_info *next; /* point to next entry in list */ + esd_server_info_t *server; /* the server that contains this sample */ + + int sample_id; /* either a stream fd or sample id */ + char name[ ESD_NAME_MAX ]; /* name of stream for remote control */ + int rate; /* sample rate */ + int left_vol_scale; /* volume scaling */ + int right_vol_scale; + + esd_format_t format; /* magic int with the format info */ + int length; /* total buffer length */ + +} esd_sample_info_t; + +typedef struct esd_info { + + esd_server_info_t *server; + esd_player_info_t *player_list; + esd_sample_info_t *sample_list; + +} esd_info_t; + +enum esd_standby_mode { + ESM_ERROR, ESM_ON_STANDBY, ESM_ON_AUTOSTANDBY, ESM_RUNNING +}; +typedef int esd_standby_mode_t; + +enum esd_client_state { + ESD_STREAMING_DATA, /* data from here on is streamed data */ + ESD_CACHING_SAMPLE, /* midway through caching a sample */ + ESD_NEEDS_REQDATA, /* more data needed to complete request */ + ESD_NEXT_REQUEST, /* proceed to next request */ + ESD_CLIENT_STATE_MAX /* place holder */ +}; +typedef int esd_client_state_t; + +/* the endian key is transferred in binary, if it's read into int, */ +/* and matches ESD_ENDIAN_KEY (ENDN), then the endianness of the */ +/* server and the client match; if it's SWAP_ENDIAN_KEY, swap data */ +#define ESD_SWAP_ENDIAN_KEY (PA_UINT32_SWAP(ESD_ENDIAN_KEY)) + +#endif diff --git a/pulse/pulsecore-14.0/fdsem.h b/pulse/pulsecore-14.0/fdsem.h new file mode 100644 index 00000000..ae1bbe90 --- /dev/null +++ b/pulse/pulsecore-14.0/fdsem.h @@ -0,0 +1,53 @@ +#ifndef foopulsefdsemhfoo +#define foopulsefdsemhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include + +/* A simple, asynchronous semaphore which uses fds for sleeping. In + * the best case all functions are lock-free unless sleeping is + * required. */ + +#include + +typedef struct pa_fdsem pa_fdsem; + +typedef struct pa_fdsem_data { + pa_atomic_t waiting; + pa_atomic_t signalled; + pa_atomic_t in_pipe; +} pa_fdsem_data; + +pa_fdsem *pa_fdsem_new(void); +pa_fdsem *pa_fdsem_open_shm(pa_fdsem_data *data, int event_fd); +pa_fdsem *pa_fdsem_new_shm(pa_fdsem_data *data); +void pa_fdsem_free(pa_fdsem *f); + +void pa_fdsem_post(pa_fdsem *f); +void pa_fdsem_wait(pa_fdsem *f); +int pa_fdsem_try(pa_fdsem *f); + +int pa_fdsem_get(pa_fdsem *f); + +int pa_fdsem_before_poll(pa_fdsem *f); +int pa_fdsem_after_poll(pa_fdsem *f); + +#endif diff --git a/pulse/pulsecore-14.0/ffmpeg/avcodec.h b/pulse/pulsecore-14.0/ffmpeg/avcodec.h new file mode 100644 index 00000000..079c2529 --- /dev/null +++ b/pulse/pulsecore-14.0/ffmpeg/avcodec.h @@ -0,0 +1,81 @@ +/* + * copyright (c) 2001 Fabrice Bellard + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, see . + */ + +#ifndef AVCODEC_H +#define AVCODEC_H + +/* Just a heavily bastardized version of the original file from + * ffmpeg, just enough to get resample2.c to compile without + * modification -- Lennart */ + +#if !defined(PACKAGE) && defined(HAVE_CONFIG_H) +#include +#endif + +#include +#include +#include +#include +#include +#include + +#define av_mallocz(l) calloc(1, (l)) +#define av_malloc(l) malloc(l) +#define av_realloc(p,l) realloc((p),(l)) +#define av_free(p) free(p) + +static inline void av_freep(void *k) { + void **p = k; + + if (p) { + free(*p); + *p = NULL; + } +} + +static inline int av_clip(int a, int amin, int amax) +{ + if (a < amin) return amin; + else if (a > amax) return amax; + else return a; +} + +#define av_log(a,b,c) + +#define FFABS(a) ((a) >= 0 ? (a) : (-(a))) +#define FFSIGN(a) ((a) > 0 ? 1 : -1) + +#define FFMAX(a,b) ((a) > (b) ? (a) : (b)) +#define FFMIN(a,b) ((a) > (b) ? (b) : (a)) + +struct AVResampleContext; +struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff); +int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx); +void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance); +void av_resample_close(struct AVResampleContext *c); +void av_build_filter(int16_t *filter, double factor, int tap_count, int phase_count, int scale, int type); + +/* + * crude lrintf for non-C99 systems. + */ +#ifndef HAVE_LRINTF +#define lrintf(x) ((long int)(x)) +#endif + +#endif /* AVCODEC_H */ diff --git a/pulse/pulsecore-14.0/ffmpeg/dsputil.h b/pulse/pulsecore-14.0/ffmpeg/dsputil.h new file mode 100644 index 00000000..8da742d0 --- /dev/null +++ b/pulse/pulsecore-14.0/ffmpeg/dsputil.h @@ -0,0 +1 @@ +/* empty file, just here to allow us to compile an unmodified resampler2.c */ diff --git a/pulse/pulsecore-14.0/filter/biquad.h b/pulse/pulsecore-14.0/filter/biquad.h new file mode 100644 index 00000000..bb8f2fb9 --- /dev/null +++ b/pulse/pulsecore-14.0/filter/biquad.h @@ -0,0 +1,45 @@ +/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef BIQUAD_H_ +#define BIQUAD_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* The biquad filter parameters. The transfer function H(z) is (b0 + b1 * z^(-1) + * + b2 * z^(-2)) / (1 + a1 * z^(-1) + a2 * z^(-2)). The previous two inputs + * are stored in x1 and x2, and the previous two outputs are stored in y1 and + * y2. + * + * We use double during the coefficients calculation for better accurary, but + * float is used during the actual filtering for faster computation. + */ +struct biquad { + float b0, b1, b2; + float a1, a2; +}; + +/* The type of the biquad filters */ +enum biquad_type { + BQ_LOWPASS, + BQ_HIGHPASS, +}; + +/* Initialize a biquad filter parameters from its type and parameters. + * Args: + * bq - The biquad filter we want to set. + * type - The type of the biquad filter. + * frequency - The value should be in the range [0, 1]. It is relative to + * half of the sampling rate. + */ +void biquad_set(struct biquad *bq, enum biquad_type type, double freq); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* BIQUAD_H_ */ diff --git a/pulse/pulsecore-14.0/filter/crossover.h b/pulse/pulsecore-14.0/filter/crossover.h new file mode 100644 index 00000000..c5c97658 --- /dev/null +++ b/pulse/pulsecore-14.0/filter/crossover.h @@ -0,0 +1,29 @@ +/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef CROSSOVER_H_ +#define CROSSOVER_H_ + +#include "biquad.h" +/* An LR4 filter is two biquads with the same parameters connected in series: + * + * x -- [BIQUAD] -- y -- [BIQUAD] -- z + * + * Both biquad filter has the same parameter b[012] and a[12], + * The variable [xyz][12] keep the history values. + */ +struct lr4 { + struct biquad bq; + float x1, x2; + float y1, y2; + float z1, z2; +}; + +void lr4_set(struct lr4 *lr4, enum biquad_type type, float freq); + +void lr4_process_float32(struct lr4 *lr4, int samples, int channels, float *src, float *dest); +void lr4_process_s16(struct lr4 *lr4, int samples, int channels, short *src, short *dest); + +#endif /* CROSSOVER_H_ */ diff --git a/pulse/pulsecore-14.0/filter/lfe-filter.h b/pulse/pulsecore-14.0/filter/lfe-filter.h new file mode 100644 index 00000000..54d695b9 --- /dev/null +++ b/pulse/pulsecore-14.0/filter/lfe-filter.h @@ -0,0 +1,39 @@ +#ifndef foolfefilterhfoo +#define foolfefilterhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2014 David Henningsson, Canonical Ltd. + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA. +***/ + +#include +#include +#include +#include + +typedef struct pa_lfe_filter pa_lfe_filter_t; + +pa_lfe_filter_t * pa_lfe_filter_new(const pa_sample_spec* ss, const pa_channel_map* cm, float crossover_freq, size_t maxrewind); +void pa_lfe_filter_free(pa_lfe_filter_t *); +void pa_lfe_filter_reset(pa_lfe_filter_t *); +void pa_lfe_filter_rewind(pa_lfe_filter_t *, size_t amount); +pa_memchunk * pa_lfe_filter_process(pa_lfe_filter_t *filter, pa_memchunk *buf); +void pa_lfe_filter_update_rate(pa_lfe_filter_t *, uint32_t new_rate); + +#endif diff --git a/pulse/pulsecore-14.0/flist.h b/pulse/pulsecore-14.0/flist.h new file mode 100644 index 00000000..03412082 --- /dev/null +++ b/pulse/pulsecore-14.0/flist.h @@ -0,0 +1,70 @@ +#ifndef foopulseflisthfoo +#define foopulseflisthfoo + +/*** + This file is part of PulseAudio. + + Copyright 2006-2008 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include +#include + +#include +#include + +/* A multiple-reader multipler-write lock-free free list implementation */ + +typedef struct pa_flist pa_flist; + +pa_flist * pa_flist_new(unsigned size); +/* Name string is copied and added to flist structure. The original is + * responsibility of the caller. The name is only used for debug printing. */ +pa_flist * pa_flist_new_with_name(unsigned size, const char *name); +void pa_flist_free(pa_flist *l, pa_free_cb_t free_cb); + +/* Please note that this routine might fail! */ +int pa_flist_push(pa_flist*l, void *p); +void* pa_flist_pop(pa_flist*l); + +/* Please note that the destructor stuff is not really necessary, we do + * this just to make valgrind output more useful. */ + +#define PA_STATIC_FLIST_DECLARE(name, size, free_cb) \ + static struct { \ + pa_flist *volatile flist; \ + pa_once once; \ + } name##_flist = { NULL, PA_ONCE_INIT }; \ + static void name##_flist_init(void) { \ + name##_flist.flist = \ + pa_flist_new_with_name(size, __FILE__ ": " #name); \ + } \ + static inline pa_flist* name##_flist_get(void) { \ + pa_run_once(&name##_flist.once, name##_flist_init); \ + return name##_flist.flist; \ + } \ + static void name##_flist_destructor(void) PA_GCC_DESTRUCTOR; \ + static void name##_flist_destructor(void) { \ + if (!pa_in_valgrind()) \ + return; \ + if (name##_flist.flist) \ + pa_flist_free(name##_flist.flist, (free_cb)); \ + } \ + struct __stupid_useless_struct_to_allow_trailing_semicolon + +#define PA_STATIC_FLIST_GET(name) (name##_flist_get()) + +#endif diff --git a/pulse/pulsecore-14.0/g711.h b/pulse/pulsecore-14.0/g711.h new file mode 100644 index 00000000..37ebcf72 --- /dev/null +++ b/pulse/pulsecore-14.0/g711.h @@ -0,0 +1,40 @@ +#ifndef foog711hfoo +#define foog711hfoo + +/* g711.h - include for G711 u-law and a-law conversion routines +** +** Copyright (C) 2001 Chris Bagwell +** +** Permission to use, copy, modify, and distribute this software and its +** documentation for any purpose and without fee is hereby granted, provided +** that the above copyright notice appear in all copies and that both that +** copyright notice and this permission notice appear in supporting +** documentation. This software is provided "as is" without express or +** implied warranty. +*/ + +/** Copied from sox -- Lennart Poettering */ + +#include + +#ifdef FAST_ALAW_CONVERSION +extern uint8_t _st_13linear2alaw[0x2000]; +extern int16_t _st_alaw2linear16[256]; +#define st_13linear2alaw(sw) (_st_13linear2alaw[(sw + 0x1000)]) +#define st_alaw2linear16(uc) (_st_alaw2linear16[uc]) +#else +unsigned char st_13linear2alaw(int16_t pcm_val); +int16_t st_alaw2linear16(unsigned char); +#endif + +#ifdef FAST_ULAW_CONVERSION +extern uint8_t _st_14linear2ulaw[0x4000]; +extern int16_t _st_ulaw2linear16[256]; +#define st_14linear2ulaw(sw) (_st_14linear2ulaw[(sw + 0x2000)]) +#define st_ulaw2linear16(uc) (_st_ulaw2linear16[uc]) +#else +unsigned char st_14linear2ulaw(int16_t pcm_val); +int16_t st_ulaw2linear16(unsigned char); +#endif + +#endif diff --git a/pulse/pulsecore-14.0/hashmap.h b/pulse/pulsecore-14.0/hashmap.h new file mode 100644 index 00000000..c18a564f --- /dev/null +++ b/pulse/pulsecore-14.0/hashmap.h @@ -0,0 +1,101 @@ +#ifndef foopulsecorehashmaphfoo +#define foopulsecorehashmaphfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2008 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +#include + +/* Simple Implementation of a hash table. Memory management is the + * user's job. It's a good idea to have the key pointer point to a + * string in the value data. The insertion order is preserved when + * iterating. */ + +typedef struct pa_hashmap pa_hashmap; + +/* Create a new hashmap. Use the specified functions for hashing and comparing objects in the map */ +pa_hashmap *pa_hashmap_new(pa_hash_func_t hash_func, pa_compare_func_t compare_func); + +/* Create a new hashmap. Use the specified functions for hashing and comparing objects in the map, and functions to free the key + * and value (either or both can be NULL). */ +pa_hashmap *pa_hashmap_new_full(pa_hash_func_t hash_func, pa_compare_func_t compare_func, pa_free_cb_t key_free_func, pa_free_cb_t value_free_func); + +/* Free the hash table. */ +void pa_hashmap_free(pa_hashmap*); + +/* Add an entry to the hashmap. Returns non-zero when the entry already exists */ +int pa_hashmap_put(pa_hashmap *h, void *key, void *value); + +/* Return an entry from the hashmap */ +void* pa_hashmap_get(const pa_hashmap *h, const void *key); + +/* Returns the data of the entry while removing */ +void* pa_hashmap_remove(pa_hashmap *h, const void *key); + +/* Removes the entry and frees the entry data. Returns a negative value if the + * entry is not found. FIXME: This function shouldn't be needed. + * pa_hashmap_remove() should free the entry data, and the current semantics of + * pa_hashmap_remove() should be implemented by a function called + * pa_hashmap_steal(). */ +int pa_hashmap_remove_and_free(pa_hashmap *h, const void *key); + +/* Remove all entries but don't free the hashmap */ +void pa_hashmap_remove_all(pa_hashmap *h); + +/* Return the current number of entries of the hashmap */ +unsigned pa_hashmap_size(const pa_hashmap *h); + +/* Return true if the hashmap is empty */ +bool pa_hashmap_isempty(const pa_hashmap *h); + +/* May be used to iterate through the hashmap. Initially the opaque + pointer *state has to be set to NULL. The hashmap may not be + modified during iteration -- except for deleting the current entry + via pa_hashmap_remove(). The key of the entry is returned in *key, + if key is non-NULL. After the last entry in the hashmap NULL is + returned. */ +void *pa_hashmap_iterate(const pa_hashmap *h, void **state, const void**key); + +/* Same as pa_hashmap_iterate() but goes backwards */ +void *pa_hashmap_iterate_backwards(const pa_hashmap *h, void **state, const void**key); + +/* Remove the oldest entry in the hashmap and return it */ +void *pa_hashmap_steal_first(pa_hashmap *h); + +/* Return the oldest entry in the hashmap */ +void* pa_hashmap_first(const pa_hashmap *h); + +/* Return the newest entry in the hashmap */ +void* pa_hashmap_last(const pa_hashmap *h); + +/* A macro to ease iteration through all entries */ +#define PA_HASHMAP_FOREACH(e, h, state) \ + for ((state) = NULL, (e) = pa_hashmap_iterate((h), &(state), NULL); (e); (e) = pa_hashmap_iterate((h), &(state), NULL)) + +/* A macro to ease itration through all key, value pairs */ +#define PA_HASHMAP_FOREACH_KV(k, e, h, state) \ + for ((state) = NULL, (e) = pa_hashmap_iterate((h), &(state), (const void **) &(k)); (e); (e) = pa_hashmap_iterate((h), &(state), (const void **) &(k))) + +/* A macro to ease iteration through all entries, backwards */ +#define PA_HASHMAP_FOREACH_BACKWARDS(e, h, state) \ + for ((state) = NULL, (e) = pa_hashmap_iterate_backwards((h), &(state), NULL); (e); (e) = pa_hashmap_iterate_backwards((h), &(state), NULL)) + +#endif diff --git a/pulse/pulsecore-14.0/hook-list.h b/pulse/pulsecore-14.0/hook-list.h new file mode 100644 index 00000000..63037e72 --- /dev/null +++ b/pulse/pulsecore-14.0/hook-list.h @@ -0,0 +1,71 @@ +#ifndef foohooklistfoo +#define foohooklistfoo + +/*** + This file is part of PulseAudio. + + Copyright 2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include + +typedef struct pa_hook_slot pa_hook_slot; +typedef struct pa_hook pa_hook; + +typedef enum pa_hook_result { + PA_HOOK_OK = 0, + PA_HOOK_STOP = 1, + PA_HOOK_CANCEL = -1 +} pa_hook_result_t; + +typedef enum pa_hook_priority { + PA_HOOK_EARLY = -100, + PA_HOOK_NORMAL = 0, + PA_HOOK_LATE = 100 +} pa_hook_priority_t; + +typedef pa_hook_result_t (*pa_hook_cb_t)( + void *hook_data, + void *call_data, + void *slot_data); + +struct pa_hook_slot { + bool dead; + pa_hook *hook; + pa_hook_priority_t priority; + pa_hook_cb_t callback; + void *data; + PA_LLIST_FIELDS(pa_hook_slot); +}; + +struct pa_hook { + PA_LLIST_HEAD(pa_hook_slot, slots); + int n_firing, n_dead; + + void *data; +}; + +void pa_hook_init(pa_hook *hook, void *data); +void pa_hook_done(pa_hook *hook); + +pa_hook_slot* pa_hook_connect(pa_hook *hook, pa_hook_priority_t prio, pa_hook_cb_t cb, void *data); +void pa_hook_slot_free(pa_hook_slot *slot); + +pa_hook_result_t pa_hook_fire(pa_hook *hook, void *data); + +bool pa_hook_is_firing(pa_hook *hook); + +#endif diff --git a/pulse/pulsecore-14.0/i18n.h b/pulse/pulsecore-14.0/i18n.h new file mode 100644 index 00000000..edf894fa --- /dev/null +++ b/pulse/pulsecore-14.0/i18n.h @@ -0,0 +1,62 @@ +#ifndef foopulsei18nhfoo +#define foopulsei18nhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2008 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include + +PA_C_DECL_BEGIN + +#ifdef ENABLE_NLS + +#if !defined(GETTEXT_PACKAGE) +#error "Something is very wrong here, config.h needs to be included first" +#endif + +#include + +#define _(String) dgettext(GETTEXT_PACKAGE, String) +#ifdef gettext_noop +#define N_(String) gettext_noop(String) +#else +#define N_(String) (String) +#endif + +#else /* NLS is disabled */ + +#define _(String) (String) +#define N_(String) (String) +#define textdomain(String) (String) +#define gettext(String) (String) +#define dgettext(Domain,String) (String) +#define dcgettext(Domain,String,Type) (String) +#define ngettext(SingularString,PluralString,N) (PluralString) +#define dngettext(Domain,SingularString,PluralString,N) (PluralString) +#define dcngettext(Domain,SingularString,PluralString,N,Type) (PluralString) +#define bindtextdomain(Domain,Directory) (Domain) +#define bind_textdomain_codeset(Domain,Codeset) (Codeset) + +#endif /* ENABLE_NLS */ + +void pa_init_i18n(void); + +PA_C_DECL_END + +#endif diff --git a/pulse/pulsecore-14.0/idxset.h b/pulse/pulsecore-14.0/idxset.h new file mode 100644 index 00000000..7acb202f --- /dev/null +++ b/pulse/pulsecore-14.0/idxset.h @@ -0,0 +1,116 @@ +#ifndef foopulsecoreidxsethfoo +#define foopulsecoreidxsethfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2008 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include + +#include + +#include + +/* A combination of a set and a dynamic array. Entries are indexable + * both through an automatically generated numeric index and the + * entry's data pointer. As usual, memory management is the user's + * job. */ + +/* A special index value denoting the invalid index. */ +#define PA_IDXSET_INVALID ((uint32_t) -1) + +/* Generic implementations for hash and comparison functions. Just + * compares the pointer or calculates the hash value directly from the + * pointer value. */ +unsigned pa_idxset_trivial_hash_func(const void *p); +int pa_idxset_trivial_compare_func(const void *a, const void *b); + +/* Generic implementations for hash and comparison functions for strings. */ +unsigned pa_idxset_string_hash_func(const void *p); +int pa_idxset_string_compare_func(const void *a, const void *b); + +typedef unsigned (*pa_hash_func_t)(const void *p); +typedef int (*pa_compare_func_t)(const void *a, const void *b); +typedef void *(*pa_copy_func_t)(const void *p); + +typedef struct pa_idxset pa_idxset; + +/* Instantiate a new idxset with the specified hash and comparison functions */ +pa_idxset* pa_idxset_new(pa_hash_func_t hash_func, pa_compare_func_t compare_func); + +/* Free the idxset. When the idxset is not empty the specified function is called for every entry contained */ +void pa_idxset_free(pa_idxset *s, pa_free_cb_t free_cb); + +/* Store a new item in the idxset. The index of the item is returned in *idx */ +int pa_idxset_put(pa_idxset*s, void *p, uint32_t *idx); + +/* Get the entry by its idx */ +void* pa_idxset_get_by_index(pa_idxset*s, uint32_t idx); + +/* Get the entry by its data. The index is returned in *idx */ +void* pa_idxset_get_by_data(pa_idxset*s, const void *p, uint32_t *idx); + +/* Similar to pa_idxset_get_by_index(), but removes the entry from the idxset. */ +void* pa_idxset_remove_by_index(pa_idxset*s, uint32_t idx); + +/* Similar to pa_idxset_get_by_data(), but removes the entry from the idxset */ +void* pa_idxset_remove_by_data(pa_idxset*s, const void *p, uint32_t *idx); + +/* If free_cb is not NULL, it's called for each entry. */ +void pa_idxset_remove_all(pa_idxset *s, pa_free_cb_t free_cb); + +/* This may be used to iterate through all entries. When called with + an invalid index value it returns the first entry, otherwise the + next following. The function is best called with *idx = + PA_IDXSET_VALID first. It is safe to manipulate the idxset between + the calls. It is not guaranteed that all entries have already been + returned before the an entry is returned the second time.*/ +void* pa_idxset_rrobin(pa_idxset *s, uint32_t *idx); + +/* Iterate through the idxset. At first iteration state should be NULL */ +void *pa_idxset_iterate(pa_idxset *s, void **state, uint32_t *idx); + +/* Return the oldest entry in the idxset and remove it. If idx is not NULL fill in its index in *idx */ +void* pa_idxset_steal_first(pa_idxset *s, uint32_t *idx); + +/* Return the oldest entry in the idxset. Fill in its index in *idx. */ +void* pa_idxset_first(pa_idxset *s, uint32_t *idx); + +/* Return the entry following the entry indexed by *idx. After the + * call *index contains the index of the returned + * object. pa_idxset_first() and pa_idxset_next() may be used to + * iterate through the set.*/ +void *pa_idxset_next(pa_idxset *s, uint32_t *idx); + +/* Return the current number of entries in the idxset */ +unsigned pa_idxset_size(pa_idxset*s); + +/* Return true of the idxset is empty */ +bool pa_idxset_isempty(pa_idxset *s); + +/* Duplicate the idxset. This will not copy the actual indexes. If copy_func is + * set, each entry is copied using the provided function, otherwise a shallow + * copy will be made. */ +pa_idxset *pa_idxset_copy(pa_idxset *s, pa_copy_func_t copy_func); + +/* A macro to ease iteration through all entries */ +#define PA_IDXSET_FOREACH(e, s, idx) \ + for ((e) = pa_idxset_first((s), &(idx)); (e); (e) = pa_idxset_next((s), &(idx))) + +#endif diff --git a/pulse/pulsecore-14.0/iochannel.h b/pulse/pulsecore-14.0/iochannel.h new file mode 100644 index 00000000..c81c5e31 --- /dev/null +++ b/pulse/pulsecore-14.0/iochannel.h @@ -0,0 +1,89 @@ +#ifndef fooiochannelhfoo +#define fooiochannelhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#ifndef PACKAGE +#error "Please include config.h before including this file!" +#endif + +#include + +#include +#include +#include + +/* A wrapper around UNIX file descriptors for attaching them to the a + main event loop. Every time new data may be read or be written to + the channel a callback function is called. It is safe to destroy + the calling iochannel object from the callback */ + +typedef struct pa_iochannel pa_iochannel; + +/* Create a new IO channel for the specified file descriptors for +input resp. output. It is safe to pass the same file descriptor for +both parameters (in case of full-duplex channels). For a simplex +channel specify -1 for the other direction. */ + +pa_iochannel* pa_iochannel_new(pa_mainloop_api*m, int ifd, int ofd); +void pa_iochannel_free(pa_iochannel*io); + +/* Returns: length written on success, 0 if a retry is needed, negative value + * on error. */ +ssize_t pa_iochannel_write(pa_iochannel*io, const void*data, size_t l); +ssize_t pa_iochannel_read(pa_iochannel*io, void*data, size_t l); + +#ifdef HAVE_CREDS +bool pa_iochannel_creds_supported(pa_iochannel *io); +int pa_iochannel_creds_enable(pa_iochannel *io); + +ssize_t pa_iochannel_write_with_fds(pa_iochannel*io, const void*data, size_t l, int nfd, const int *fds); +ssize_t pa_iochannel_write_with_creds(pa_iochannel*io, const void*data, size_t l, const pa_creds *ucred); +ssize_t pa_iochannel_read_with_ancil_data(pa_iochannel*io, void*data, size_t l, pa_cmsg_ancil_data *ancil_data); +#endif + +bool pa_iochannel_is_readable(pa_iochannel*io); +bool pa_iochannel_is_writable(pa_iochannel*io); +bool pa_iochannel_is_hungup(pa_iochannel*io); + +/* Don't close the file descriptors when the io channel is freed. By + * default the file descriptors are closed. */ +void pa_iochannel_set_noclose(pa_iochannel*io, bool b); + +/* Set the callback function that is called whenever data becomes available for read or write */ +typedef void (*pa_iochannel_cb_t)(pa_iochannel*io, void *userdata); +void pa_iochannel_set_callback(pa_iochannel*io, pa_iochannel_cb_t callback, void *userdata); + +/* In case the file descriptor is a socket, return a pretty-printed string in *s which describes the peer connected */ +void pa_iochannel_socket_peer_to_string(pa_iochannel*io, char*s, size_t l); + +/* Use setsockopt() to tune the receive and send buffers of TCP sockets */ +int pa_iochannel_socket_set_rcvbuf(pa_iochannel*io, size_t l); +int pa_iochannel_socket_set_sndbuf(pa_iochannel*io, size_t l); + +bool pa_iochannel_socket_is_local(pa_iochannel *io); + +pa_mainloop_api* pa_iochannel_get_mainloop_api(pa_iochannel *io); + +int pa_iochannel_get_recv_fd(pa_iochannel *io); +int pa_iochannel_get_send_fd(pa_iochannel *io); + +#endif diff --git a/pulse/pulsecore-14.0/ioline.h b/pulse/pulsecore-14.0/ioline.h new file mode 100644 index 00000000..7b6dff32 --- /dev/null +++ b/pulse/pulsecore-14.0/ioline.h @@ -0,0 +1,63 @@ +#ifndef fooiolinehfoo +#define fooiolinehfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +#include + +/* An ioline wraps an iochannel for line based communication. A + * callback function is called whenever a new line has been received + * from the client */ + +typedef struct pa_ioline pa_ioline; + +typedef void (*pa_ioline_cb_t)(pa_ioline*io, const char *s, void *userdata); +typedef void (*pa_ioline_drain_cb_t)(pa_ioline *io, void *userdata); + +pa_ioline* pa_ioline_new(pa_iochannel *io); +void pa_ioline_unref(pa_ioline *l); +pa_ioline* pa_ioline_ref(pa_ioline *l); +void pa_ioline_close(pa_ioline *l); + +/* Write a string to the channel */ +void pa_ioline_puts(pa_ioline *s, const char *c); + +/* Write a string to the channel */ +void pa_ioline_printf(pa_ioline *s, const char *format, ...) PA_GCC_PRINTF_ATTR(2,3); + +/* Set the callback function that is called for every received line */ +void pa_ioline_set_callback(pa_ioline*io, pa_ioline_cb_t callback, void *userdata); + +/* Set the callback function that is called when everything has been written */ +void pa_ioline_set_drain_callback(pa_ioline*io, pa_ioline_drain_cb_t callback, void *userdata); + +/* Make sure to close the ioline object as soon as the send buffer is emptied */ +void pa_ioline_defer_close(pa_ioline *io); + +/* Returns true when everything was written */ +bool pa_ioline_is_drained(pa_ioline *io); + +/* Detaches from the iochannel and returns it. Data that has already + * been read will not be available in the detached iochannel */ +pa_iochannel* pa_ioline_detach_iochannel(pa_ioline *l); + +#endif diff --git a/pulse/pulsecore-14.0/ipacl.h b/pulse/pulsecore-14.0/ipacl.h new file mode 100644 index 00000000..034248ab --- /dev/null +++ b/pulse/pulsecore-14.0/ipacl.h @@ -0,0 +1,30 @@ +#ifndef foopulsecoreipaclhfoo +#define foopulsecoreipaclhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +typedef struct pa_ip_acl pa_ip_acl; + +pa_ip_acl* pa_ip_acl_new(const char *s); +void pa_ip_acl_free(pa_ip_acl *acl); +int pa_ip_acl_check(pa_ip_acl *acl, int fd); + +#endif diff --git a/pulse/pulsecore-14.0/llist.h b/pulse/pulsecore-14.0/llist.h new file mode 100644 index 00000000..a9412fab --- /dev/null +++ b/pulse/pulsecore-14.0/llist.h @@ -0,0 +1,111 @@ +#ifndef foollistfoo +#define foollistfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include + +/* Some macros for maintaining doubly linked lists */ + +/* The head of the linked list. Use this in the structure that shall + * contain the head of the linked list */ +#define PA_LLIST_HEAD(t,name) \ + t *name + +/* The pointers in the linked list's items. Use this in the item structure */ +#define PA_LLIST_FIELDS(t) \ + t *next, *prev + +/* Initialize the list's head */ +#define PA_LLIST_HEAD_INIT(t,item) \ + do { \ + (item) = (t*) NULL; } \ + while(0) + +/* Initialize a list item */ +#define PA_LLIST_INIT(t,item) \ + do { \ + t *_item = (item); \ + pa_assert(_item); \ + _item->prev = _item->next = NULL; \ + } while(0) + +/* Prepend an item to the list */ +#define PA_LLIST_PREPEND(t,head,item) \ + do { \ + t **_head = &(head), *_item = (item); \ + pa_assert(_item); \ + if ((_item->next = *_head)) \ + _item->next->prev = _item; \ + _item->prev = NULL; \ + *_head = _item; \ + } while (0) + +/* Remove an item from the list */ +#define PA_LLIST_REMOVE(t,head,item) \ + do { \ + t **_head = &(head), *_item = (item); \ + pa_assert(_item); \ + if (_item->next) \ + _item->next->prev = _item->prev; \ + if (_item->prev) \ + _item->prev->next = _item->next; \ + else { \ + pa_assert(*_head == _item); \ + *_head = _item->next; \ + } \ + _item->next = _item->prev = NULL; \ + } while(0) + +/* Find the head of the list */ +#define PA_LLIST_FIND_HEAD(t,item,head) \ + do { \ + t **_head = (head), *_item = (item); \ + *_head = _item; \ + pa_assert(_head); \ + while ((*_head)->prev) \ + *_head = (*_head)->prev; \ + } while (0) + +/* Insert an item after another one (a = where, b = what) */ +#define PA_LLIST_INSERT_AFTER(t,head,a,b) \ + do { \ + t **_head = &(head), *_a = (a), *_b = (b); \ + pa_assert(_b); \ + if (!_a) { \ + if ((_b->next = *_head)) \ + _b->next->prev = _b; \ + _b->prev = NULL; \ + *_head = _b; \ + } else { \ + if ((_b->next = _a->next)) \ + _b->next->prev = _b; \ + _b->prev = _a; \ + _a->next = _b; \ + } \ + } while (0) + +#define PA_LLIST_FOREACH(i,head) \ + for (i = (head); i; i = i->next) + +#define PA_LLIST_FOREACH_SAFE(i,n,head) \ + for (i = (head); i && ((n = i->next), 1); i = n) + +#endif diff --git a/pulse/pulsecore-14.0/lock-autospawn.h b/pulse/pulsecore-14.0/lock-autospawn.h new file mode 100644 index 00000000..9fc0ab13 --- /dev/null +++ b/pulse/pulsecore-14.0/lock-autospawn.h @@ -0,0 +1,30 @@ +#ifndef foopulselockautospawnhfoo +#define foopulselockautospawnhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2008 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include + +int pa_autospawn_lock_init(void); +int pa_autospawn_lock_acquire(bool block); +void pa_autospawn_lock_release(void); +void pa_autospawn_lock_done(bool after_fork); + +#endif diff --git a/pulse/pulsecore-14.0/log.h b/pulse/pulsecore-14.0/log.h new file mode 100644 index 00000000..803ed5a4 --- /dev/null +++ b/pulse/pulsecore-14.0/log.h @@ -0,0 +1,155 @@ +#ifndef foologhfoo +#define foologhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include + +#include +#include + +/* A simple logging subsystem */ + +/* Where to log to */ +typedef enum pa_log_target_type { + PA_LOG_STDERR, /* default */ + PA_LOG_SYSLOG, +#ifdef HAVE_SYSTEMD_JOURNAL + PA_LOG_JOURNAL, /* systemd journal */ +#endif + PA_LOG_NULL, /* to /dev/null */ + PA_LOG_FILE, /* to a user specified file */ + PA_LOG_NEWFILE, /* with an automatic suffix to avoid overwriting anything */ +} pa_log_target_type_t; + +typedef enum pa_log_level { + PA_LOG_ERROR = 0, /* Error messages */ + PA_LOG_WARN = 1, /* Warning messages */ + PA_LOG_NOTICE = 2, /* Notice messages */ + PA_LOG_INFO = 3, /* Info messages */ + PA_LOG_DEBUG = 4, /* Debug messages */ + PA_LOG_LEVEL_MAX +} pa_log_level_t; + +typedef enum pa_log_flags { + PA_LOG_COLORS = 0x01, /* Show colorful output */ + PA_LOG_PRINT_TIME = 0x02, /* Show time */ + PA_LOG_PRINT_FILE = 0x04, /* Show source file */ + PA_LOG_PRINT_META = 0x08, /* Show extended location information */ + PA_LOG_PRINT_LEVEL = 0x10, /* Show log level prefix */ +} pa_log_flags_t; + +typedef enum pa_log_merge { + PA_LOG_SET, + PA_LOG_UNSET, + PA_LOG_RESET +} pa_log_merge_t; + +typedef struct { + pa_log_target_type_t type; + char *file; +} pa_log_target; + +/* Set an identification for the current daemon. Used when logging to syslog. */ +void pa_log_set_ident(const char *p); + +/* Set a log target. */ +int pa_log_set_target(pa_log_target *t); + +/* Maximal log level */ +void pa_log_set_level(pa_log_level_t l); + +/* Set flags */ +void pa_log_set_flags(pa_log_flags_t flags, pa_log_merge_t merge); + +/* Enable backtrace */ +void pa_log_set_show_backtrace(unsigned nlevels); + +/* Skip the first backtrace frames */ +void pa_log_set_skip_backtrace(unsigned nlevels); + +void pa_log_level_meta( + pa_log_level_t level, + const char*file, + int line, + const char *func, + const char *format, ...) PA_GCC_PRINTF_ATTR(5,6); + +void pa_log_levelv_meta( + pa_log_level_t level, + const char*file, + int line, + const char *func, + const char *format, + va_list ap); + +void pa_log_level( + pa_log_level_t level, + const char *format, ...) PA_GCC_PRINTF_ATTR(2,3); + +void pa_log_levelv( + pa_log_level_t level, + const char *format, + va_list ap); + +pa_log_target *pa_log_target_new(pa_log_target_type_t type, const char *file); + +void pa_log_target_free(pa_log_target *t); + +pa_log_target *pa_log_parse_target(const char *string); + +char *pa_log_target_to_string(const pa_log_target *t); + +#if __STDC_VERSION__ >= 199901L + +/* ISO varargs available */ + +#define pa_log_debug(...) pa_log_level_meta(PA_LOG_DEBUG, __FILE__, __LINE__, __func__, __VA_ARGS__) +#define pa_log_info(...) pa_log_level_meta(PA_LOG_INFO, __FILE__, __LINE__, __func__, __VA_ARGS__) +#define pa_log_notice(...) pa_log_level_meta(PA_LOG_NOTICE, __FILE__, __LINE__, __func__, __VA_ARGS__) +#define pa_log_warn(...) pa_log_level_meta(PA_LOG_WARN, __FILE__, __LINE__, __func__, __VA_ARGS__) +#define pa_log_error(...) pa_log_level_meta(PA_LOG_ERROR, __FILE__, __LINE__, __func__, __VA_ARGS__) +#define pa_logl(level, ...) pa_log_level_meta(level, __FILE__, __LINE__, __func__, __VA_ARGS__) + +#else + +#define LOG_FUNC(suffix, level) \ +PA_GCC_UNUSED static void pa_log_##suffix(const char *format, ...) { \ + va_list ap; \ + va_start(ap, format); \ + pa_log_levelv_meta(level, NULL, 0, NULL, format, ap); \ + va_end(ap); \ +} + +LOG_FUNC(debug, PA_LOG_DEBUG) +LOG_FUNC(info, PA_LOG_INFO) +LOG_FUNC(notice, PA_LOG_NOTICE) +LOG_FUNC(warn, PA_LOG_WARN) +LOG_FUNC(error, PA_LOG_ERROR) + +#endif + +#define pa_log pa_log_error + +bool pa_log_ratelimit(pa_log_level_t level); + +#endif diff --git a/pulse/pulsecore-14.0/ltdl-helper.h b/pulse/pulsecore-14.0/ltdl-helper.h new file mode 100644 index 00000000..d3219ba7 --- /dev/null +++ b/pulse/pulsecore-14.0/ltdl-helper.h @@ -0,0 +1,29 @@ +#ifndef foopulsecoreltdlhelperhfoo +#define foopulsecoreltdlhelperhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +typedef void (*pa_void_func_t)(void); + +pa_void_func_t pa_load_sym(lt_dlhandle handle, const char*module, const char *symbol); + +#endif diff --git a/pulse/pulsecore-14.0/macro.h b/pulse/pulsecore-14.0/macro.h new file mode 100644 index 00000000..ec8d31c2 --- /dev/null +++ b/pulse/pulsecore-14.0/macro.h @@ -0,0 +1,272 @@ +#ifndef foopulsemacrohfoo +#define foopulsemacrohfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef PACKAGE +#error "Please include config.h before including this file!" +#endif + +/* Rounds down */ +static inline void* PA_ALIGN_PTR(const void *p) { + return (void*) (((size_t) p) & ~(sizeof(void*) - 1)); +} + +/* Rounds up */ +static inline size_t PA_ALIGN(size_t l) { + return ((l + sizeof(void*) - 1) & ~(sizeof(void*) - 1)); +} + +#if defined(__GNUC__) + #define PA_UNUSED __attribute__ ((unused)) +#else + #define PA_UNUSED +#endif + +#define PA_ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0])) + +#if defined(__GNUC__) + #define PA_DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n))) +#else + #define PA_DECLARE_ALIGNED(n,t,v) t v +#endif + +#ifdef __GNUC__ +#define typeof __typeof__ +#endif + +/* The users of PA_MIN and PA_MAX, PA_CLAMP, PA_ROUND_UP should be + * aware that these macros on non-GCC executed code with side effects + * twice. It is thus considered misuse to use code with side effects + * as arguments to MIN and MAX. */ + +#ifdef __GNUC__ +#define PA_MAX(a,b) \ + __extension__ ({ \ + typeof(a) _a = (a); \ + typeof(b) _b = (b); \ + _a > _b ? _a : _b; \ + }) +#else +#define PA_MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif + +#ifdef __GNUC__ +#define PA_MIN(a,b) \ + __extension__ ({ \ + typeof(a) _a = (a); \ + typeof(b) _b = (b); \ + _a < _b ? _a : _b; \ + }) +#else +#define PA_MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifdef __GNUC__ +#define PA_ROUND_UP(a, b) \ + __extension__ ({ \ + typeof(a) _a = (a); \ + typeof(b) _b = (b); \ + ((_a + _b - 1) / _b) * _b; \ + }) +#else +#define PA_ROUND_UP(a, b) ((((a) + (b) - 1) / (b)) * (b)) +#endif + +#ifdef __GNUC__ +#define PA_ROUND_DOWN(a, b) \ + __extension__ ({ \ + typeof(a) _a = (a); \ + typeof(b) _b = (b); \ + (_a / _b) * _b; \ + }) +#else +#define PA_ROUND_DOWN(a, b) (((a) / (b)) * (b)) +#endif + +#ifdef __GNUC__ +#define PA_CLIP_SUB(a, b) \ + __extension__ ({ \ + typeof(a) _a = (a); \ + typeof(b) _b = (b); \ + _a > _b ? _a - _b : 0; \ + }) +#else +#define PA_CLIP_SUB(a, b) ((a) > (b) ? (a) - (b) : 0) +#endif + +#ifdef __GNUC__ +#define PA_PRETTY_FUNCTION __PRETTY_FUNCTION__ +#else +#define PA_PRETTY_FUNCTION "" +#endif + +#define pa_return_if_fail(expr) \ + do { \ + if (PA_UNLIKELY(!(expr))) { \ + pa_log_debug("Assertion '%s' failed at %s:%u, function %s.", #expr , __FILE__, __LINE__, PA_PRETTY_FUNCTION); \ + return; \ + } \ + } while(false) + +#define pa_return_val_if_fail(expr, val) \ + do { \ + if (PA_UNLIKELY(!(expr))) { \ + pa_log_debug("Assertion '%s' failed at %s:%u, function %s.", #expr , __FILE__, __LINE__, PA_PRETTY_FUNCTION); \ + return (val); \ + } \ + } while(false) + +#define pa_return_null_if_fail(expr) pa_return_val_if_fail(expr, NULL) + +/* pa_assert_se() is an assert which guarantees side effects of x, + * i.e. is never optimized away, regardless of NDEBUG or FASTPATH. */ +#ifndef __COVERITY__ +#define pa_assert_se(expr) \ + do { \ + if (PA_UNLIKELY(!(expr))) { \ + pa_log_error("Assertion '%s' failed at %s:%u, function %s(). Aborting.", #expr , __FILE__, __LINE__, PA_PRETTY_FUNCTION); \ + abort(); \ + } \ + } while (false) +#else +#define pa_assert_se(expr) \ + do { \ + int _unique_var = (expr); \ + if (!_unique_var) \ + abort(); \ + } while (false) +#endif + +/* Does exactly nothing */ +#define pa_nop() do {} while (false) + +/* pa_assert() is an assert that may be optimized away by defining + * NDEBUG. pa_assert_fp() is an assert that may be optimized away by + * defining FASTPATH. It is supposed to be used in inner loops. It's + * there for extra paranoia checking and should probably be removed in + * production builds. */ +#ifdef NDEBUG +#define pa_assert(expr) pa_nop() +#define pa_assert_fp(expr) pa_nop() +#elif defined (FASTPATH) +#define pa_assert(expr) pa_assert_se(expr) +#define pa_assert_fp(expr) pa_nop() +#else +#define pa_assert(expr) pa_assert_se(expr) +#define pa_assert_fp(expr) pa_assert_se(expr) +#endif + +#ifdef NDEBUG +#define pa_assert_not_reached() abort() +#else +#define pa_assert_not_reached() \ + do { \ + pa_log_error("Code should not be reached at %s:%u, function %s(). Aborting.", __FILE__, __LINE__, PA_PRETTY_FUNCTION); \ + abort(); \ + } while (false) +#endif + +/* A compile time assertion */ +#define pa_assert_cc(expr) \ + do { \ + switch (0) { \ + case 0: \ + case !!(expr): \ + ; \ + } \ + } while (false) + +#define PA_PTR_TO_UINT(p) ((unsigned int) ((uintptr_t) (p))) +#define PA_UINT_TO_PTR(u) ((void*) ((uintptr_t) (u))) + +#define PA_PTR_TO_UINT32(p) ((uint32_t) ((uintptr_t) (p))) +#define PA_UINT32_TO_PTR(u) ((void*) ((uintptr_t) (u))) + +#define PA_PTR_TO_INT(p) ((int) ((intptr_t) (p))) +#define PA_INT_TO_PTR(u) ((void*) ((intptr_t) (u))) + +#define PA_PTR_TO_INT32(p) ((int32_t) ((intptr_t) (p))) +#define PA_INT32_TO_PTR(u) ((void*) ((intptr_t) (u))) + +#ifdef OS_IS_WIN32 +#define PA_PATH_SEP "\\" +#define PA_PATH_SEP_CHAR '\\' +#else +#define PA_PATH_SEP "/" +#define PA_PATH_SEP_CHAR '/' +#endif + +#if defined(__GNUC__) && defined(__ELF__) + +#define PA_WARN_REFERENCE(sym, msg) \ + __asm__(".section .gnu.warning." #sym); \ + __asm__(".asciz \"" msg "\""); \ + __asm__(".previous") + +#else + +#define PA_WARN_REFERENCE(sym, msg) + +#endif + +#if defined(__i386__) || defined(__x86_64__) +#define PA_DEBUG_TRAP __asm__("int $3") +#else +#define PA_DEBUG_TRAP raise(SIGTRAP) +#endif + +#define pa_memzero(x,l) (memset((x), 0, (l))) +#define pa_zero(x) (pa_memzero(&(x), sizeof(x))) + +#define PA_INT_TYPE_SIGNED(type) (!!((type) 0 > (type) -1)) + +#define PA_INT_TYPE_HALF(type) ((type) 1 << (sizeof(type)*8 - 2)) + +#define PA_INT_TYPE_MAX(type) \ + ((type) (PA_INT_TYPE_SIGNED(type) \ + ? (PA_INT_TYPE_HALF(type) - 1 + PA_INT_TYPE_HALF(type)) \ + : (type) -1)) + +#define PA_INT_TYPE_MIN(type) \ + ((type) (PA_INT_TYPE_SIGNED(type) \ + ? (-1 - PA_INT_TYPE_MAX(type)) \ + : (type) 0)) + +/* The '#' preprocessor operator doesn't expand any macros that are in the + * parameter, which is why we need a separate macro for those cases where the + * parameter contains a macro that needs expanding. */ +#define PA_STRINGIZE(x) #x +#define PA_EXPAND_AND_STRINGIZE(x) PA_STRINGIZE(x) + +/* We include this at the very last place */ +#include + +#endif diff --git a/pulse/pulsecore-14.0/mcalign.h b/pulse/pulsecore-14.0/mcalign.h new file mode 100644 index 00000000..353e66ad --- /dev/null +++ b/pulse/pulsecore-14.0/mcalign.h @@ -0,0 +1,81 @@ +#ifndef foomcalignhfoo +#define foomcalignhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include +#include + +/* An alignment object, used for aligning memchunks to multiples of + * the frame size. */ + +/* Method of operation: the user creates a new mcalign object by + * calling pa_mcalign_new() with the appropriate aligning + * granularity. After that they may call pa_mcalign_push() for an input + * memchunk. After exactly one memchunk the user has to call + * pa_mcalign_pop() until it returns -1. If pa_mcalign_pop() returns + * 0, the memchunk *c is valid and aligned to the granularity. Some + * pseudocode illustrating this: + * + * pa_mcalign *a = pa_mcalign_new(4, NULL); + * + * for (;;) { + * pa_memchunk input; + * + * ... fill input ... + * + * pa_mcalign_push(m, &input); + * pa_memblock_unref(input.memblock); + * + * for (;;) { + * pa_memchunk output; + * + * if (pa_mcalign_pop(m, &output) < 0) + * break; + * + * ... consume output ... + * + * pa_memblock_unref(output.memblock); + * } + * } + * + * pa_memchunk_free(a); + * */ + +typedef struct pa_mcalign pa_mcalign; + +pa_mcalign *pa_mcalign_new(size_t base); +void pa_mcalign_free(pa_mcalign *m); + +/* Push a new memchunk into the aligner. The caller of this routine + * has to free the memchunk by himself. */ +void pa_mcalign_push(pa_mcalign *m, const pa_memchunk *c); + +/* Pop a new memchunk from the aligner. Returns 0 when successful, + * nonzero otherwise. */ +int pa_mcalign_pop(pa_mcalign *m, pa_memchunk *c); + +/* If we pass l bytes in now, how many bytes would we get out? */ +size_t pa_mcalign_csize(pa_mcalign *m, size_t l); + +/* Flush what's still stored in the aligner */ +void pa_mcalign_flush(pa_mcalign *m); + +#endif diff --git a/pulse/pulsecore-14.0/mem.h b/pulse/pulsecore-14.0/mem.h new file mode 100644 index 00000000..cba14104 --- /dev/null +++ b/pulse/pulsecore-14.0/mem.h @@ -0,0 +1,60 @@ +#ifndef foopulsememhfoo +#define foopulsememhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2016 Ahmed S. Darwish + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include + +#include +#include + +typedef enum pa_mem_type { + PA_MEM_TYPE_SHARED_POSIX, /* Data is shared and created using POSIX shm_open() */ + PA_MEM_TYPE_SHARED_MEMFD, /* Data is shared and created using Linux memfd_create() */ + PA_MEM_TYPE_PRIVATE, /* Data is private and created using classic memory allocation + (posix_memalign(), malloc() or anonymous mmap()) */ +} pa_mem_type_t; + +static inline const char *pa_mem_type_to_string(pa_mem_type_t type) { + switch (type) { + case PA_MEM_TYPE_SHARED_POSIX: + return "shared posix-shm"; + case PA_MEM_TYPE_SHARED_MEMFD: + return "shared memfd"; + case PA_MEM_TYPE_PRIVATE: + return "private"; + } + + pa_assert_not_reached(); +} + +static inline bool pa_mem_type_is_shared(pa_mem_type_t t) { + return (t == PA_MEM_TYPE_SHARED_POSIX) || (t == PA_MEM_TYPE_SHARED_MEMFD); +} + +static inline bool pa_memfd_is_locally_supported() { +#if defined(HAVE_CREDS) && defined(HAVE_MEMFD) + return true; +#else + return false; +#endif +} + +#endif diff --git a/pulse/pulsecore-14.0/memblock.h b/pulse/pulsecore-14.0/memblock.h new file mode 100644 index 00000000..4273c098 --- /dev/null +++ b/pulse/pulsecore-14.0/memblock.h @@ -0,0 +1,159 @@ +#ifndef foopulsememblockhfoo +#define foopulsememblockhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +typedef struct pa_memblock pa_memblock; + +#include +#include + +#include +#include +#include +#include +#include + +/* A pa_memblock is a reference counted memory block. PulseAudio + * passes references to pa_memblocks around instead of copying + * data. See pa_memchunk for a structure that describes parts of + * memory blocks. */ + +/* The type of memory this block points to */ +typedef enum pa_memblock_type { + PA_MEMBLOCK_POOL, /* Memory is part of the memory pool */ + PA_MEMBLOCK_POOL_EXTERNAL, /* Data memory is part of the memory pool but the pa_memblock structure itself is not */ + PA_MEMBLOCK_APPENDED, /* The data is appended to the memory block */ + PA_MEMBLOCK_USER, /* User supplied memory, to be freed with free_cb */ + PA_MEMBLOCK_FIXED, /* Data is a pointer to fixed memory that needs not to be freed */ + PA_MEMBLOCK_IMPORTED, /* Memory is imported from another process via shm */ + PA_MEMBLOCK_TYPE_MAX +} pa_memblock_type_t; + +typedef struct pa_mempool pa_mempool; +typedef struct pa_mempool_stat pa_mempool_stat; +typedef struct pa_memimport_segment pa_memimport_segment; +typedef struct pa_memimport pa_memimport; +typedef struct pa_memexport pa_memexport; + +typedef void (*pa_memimport_release_cb_t)(pa_memimport *i, uint32_t block_id, void *userdata); +typedef void (*pa_memexport_revoke_cb_t)(pa_memexport *e, uint32_t block_id, void *userdata); + +/* Please note that updates to this structure are not locked, + * i.e. n_allocated might be updated at a point in time where + * n_accumulated is not yet. Take these values with a grain of salt, + * they are here for purely statistical reasons.*/ +struct pa_mempool_stat { + pa_atomic_t n_allocated; + pa_atomic_t n_accumulated; + pa_atomic_t n_imported; + pa_atomic_t n_exported; + pa_atomic_t allocated_size; + pa_atomic_t accumulated_size; + pa_atomic_t imported_size; + pa_atomic_t exported_size; + + pa_atomic_t n_too_large_for_pool; + pa_atomic_t n_pool_full; + + pa_atomic_t n_allocated_by_type[PA_MEMBLOCK_TYPE_MAX]; + pa_atomic_t n_accumulated_by_type[PA_MEMBLOCK_TYPE_MAX]; +}; + +/* Allocate a new memory block of type PA_MEMBLOCK_MEMPOOL or PA_MEMBLOCK_APPENDED, depending on the size */ +pa_memblock *pa_memblock_new(pa_mempool *, size_t length); + +/* Allocate a new memory block of type PA_MEMBLOCK_MEMPOOL. If the requested size is too large, return NULL */ +pa_memblock *pa_memblock_new_pool(pa_mempool *, size_t length); + +/* Allocate a new memory block of type PA_MEMBLOCK_USER */ +pa_memblock *pa_memblock_new_user(pa_mempool *, void *data, size_t length, pa_free_cb_t free_cb, void *free_cb_data, bool read_only); + +/* A special case of pa_memblock_new_user: take a memory buffer previously allocated with pa_xmalloc() */ +static inline pa_memblock *pa_memblock_new_malloced(pa_mempool *p, void *data, size_t length) { + return pa_memblock_new_user(p, data, length, pa_xfree, data, 0); +} + +/* Allocate a new memory block of type PA_MEMBLOCK_FIXED */ +pa_memblock *pa_memblock_new_fixed(pa_mempool *, void *data, size_t length, bool read_only); + +void pa_memblock_unref(pa_memblock*b); +pa_memblock* pa_memblock_ref(pa_memblock*b); + +/* This special unref function has to be called by the owner of the +memory of a static memory block when they want to release all +references to the memory. This causes the memory to be copied and +converted into a pool of malloc'ed memory block. Please note that this +function is not multiple caller safe, i.e. needs to be locked +manually if called from more than one thread at the same time. */ +void pa_memblock_unref_fixed(pa_memblock*b); + +bool pa_memblock_is_ours(pa_memblock *b); +bool pa_memblock_is_read_only(pa_memblock *b); +bool pa_memblock_is_silence(pa_memblock *b); +bool pa_memblock_ref_is_one(pa_memblock *b); +void pa_memblock_set_is_silence(pa_memblock *b, bool v); + +void* pa_memblock_acquire(pa_memblock *b); +void *pa_memblock_acquire_chunk(const pa_memchunk *c); +void pa_memblock_release(pa_memblock *b); + +size_t pa_memblock_get_length(pa_memblock *b); + +/* Note! Always unref the returned pool after use */ +pa_mempool * pa_memblock_get_pool(pa_memblock *b); + +pa_memblock *pa_memblock_will_need(pa_memblock *b); + +/* The memory block manager */ +pa_mempool *pa_mempool_new(pa_mem_type_t type, size_t size, bool per_client); +void pa_mempool_unref(pa_mempool *p); +pa_mempool* pa_mempool_ref(pa_mempool *p); +const pa_mempool_stat* pa_mempool_get_stat(pa_mempool *p); +void pa_mempool_vacuum(pa_mempool *p); +int pa_mempool_get_shm_id(pa_mempool *p, uint32_t *id); +bool pa_mempool_is_shared(pa_mempool *p); +bool pa_mempool_is_memfd_backed(const pa_mempool *p); +bool pa_mempool_is_global(pa_mempool *p); +bool pa_mempool_is_per_client(pa_mempool *p); +bool pa_mempool_is_remote_writable(pa_mempool *p); +void pa_mempool_set_is_remote_writable(pa_mempool *p, bool writable); +size_t pa_mempool_block_size_max(pa_mempool *p); + +int pa_mempool_take_memfd_fd(pa_mempool *p); +int pa_mempool_get_memfd_fd(pa_mempool *p); + +/* For receiving blocks from other nodes */ +pa_memimport* pa_memimport_new(pa_mempool *p, pa_memimport_release_cb_t cb, void *userdata); +void pa_memimport_free(pa_memimport *i); +int pa_memimport_attach_memfd(pa_memimport *i, uint32_t shm_id, int memfd_fd, bool writable); +pa_memblock* pa_memimport_get(pa_memimport *i, pa_mem_type_t type, uint32_t block_id, + uint32_t shm_id, size_t offset, size_t size, bool writable); +int pa_memimport_process_revoke(pa_memimport *i, uint32_t block_id); + +/* For sending blocks to other nodes */ +pa_memexport* pa_memexport_new(pa_mempool *p, pa_memexport_revoke_cb_t cb, void *userdata); +void pa_memexport_free(pa_memexport *e); +int pa_memexport_put(pa_memexport *e, pa_memblock *b, pa_mem_type_t *type, uint32_t *block_id, + uint32_t *shm_id, size_t *offset, size_t * size); +int pa_memexport_process_release(pa_memexport *e, uint32_t id); + +#endif diff --git a/pulse/pulsecore-14.0/memblockq.h b/pulse/pulsecore-14.0/memblockq.h new file mode 100644 index 00000000..96e41cc3 --- /dev/null +++ b/pulse/pulsecore-14.0/memblockq.h @@ -0,0 +1,187 @@ +#ifndef foomemblockqhfoo +#define foomemblockqhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include +#include + +#include +#include +#include + +/* A memblockq is a queue of pa_memchunks (yep, the name is not + * perfect). It is similar to the ring buffers used by most other + * audio software. In contrast to a ring buffer this memblockq data + * type doesn't need to copy any data around, it just maintains + * references to reference counted memory blocks. */ + +typedef struct pa_memblockq pa_memblockq; + +/* Parameters: + + - name: name for debugging purposes + + - idx: start value for both read and write index + + - maxlength: maximum length of queue. If more data is pushed into + the queue, the operation will fail. Must not be 0. + + - tlength: the target length of the queue. Pass 0 for the default. + + - ss: Sample spec describing the queue contents. Only multiples + of the frame size as implied by the sample spec are + allowed into the queue or can be popped from it. + + - prebuf: If the queue runs empty wait until this many bytes are in + queue again before passing the first byte out. If set + to 0 pa_memblockq_pop() will return a silence memblock + if no data is in the queue and will never fail. Pass + (size_t) -1 for the default. + + - minreq: pa_memblockq_pop_missing() will only return values greater + than this value. Pass 0 for the default. + + - maxrewind: how many bytes of history to keep in the queue + + - silence: return this memchunk when reading uninitialized data +*/ +pa_memblockq* pa_memblockq_new( + const char *name, + int64_t idx, + size_t maxlength, + size_t tlength, + const pa_sample_spec *sample_spec, + size_t prebuf, + size_t minreq, + size_t maxrewind, + pa_memchunk *silence); + +void pa_memblockq_free(pa_memblockq*bq); + +/* Push a new memory chunk into the queue. */ +int pa_memblockq_push(pa_memblockq* bq, const pa_memchunk *chunk); + +/* Push a new memory chunk into the queue, but filter it through a + * pa_mcalign object. Don't mix this with pa_memblockq_seek() unless + * you know what you do. */ +int pa_memblockq_push_align(pa_memblockq* bq, const pa_memchunk *chunk); + +/* Manipulate the write pointer */ +void pa_memblockq_seek(pa_memblockq *bq, int64_t offset, pa_seek_mode_t seek, bool account); + +/* Return a copy of the next memory chunk in the queue. It is not + * removed from the queue. There are two reasons this function might + * fail: 1. prebuffering is active, 2. queue is empty and no silence + * memblock was passed at initialization. If the queue is not empty, + * but we're currently at a hole in the queue and no silence memblock + * was passed we return the length of the hole in chunk->length. */ +int pa_memblockq_peek(pa_memblockq* bq, pa_memchunk *chunk); + +/* Much like pa_memblockq_peek, but guarantees that the returned chunk + * will have a length of the block size passed. You must configure a + * silence memchunk for this memblockq if you use this call. */ +int pa_memblockq_peek_fixed_size(pa_memblockq *bq, size_t block_size, pa_memchunk *chunk); + +/* Drop the specified bytes from the queue. */ +void pa_memblockq_drop(pa_memblockq *bq, size_t length); + +/* Rewind the read index. If the history is shorter than the specified length we'll point to silence afterwards. */ +void pa_memblockq_rewind(pa_memblockq *bq, size_t length); + +/* Test if the pa_memblockq is currently readable, that is, more data than base */ +bool pa_memblockq_is_readable(pa_memblockq *bq); + +/* Return the length of the queue in bytes */ +size_t pa_memblockq_get_length(pa_memblockq *bq); + +/* Return the number of bytes that are missing since the last call to + * this function, reset the internal counter to 0. */ +size_t pa_memblockq_pop_missing(pa_memblockq *bq); + +/* Directly moves the data from the source memblockq into bq */ +int pa_memblockq_splice(pa_memblockq *bq, pa_memblockq *source); + +/* Set the queue to silence, set write index to read index */ +void pa_memblockq_flush_write(pa_memblockq *bq, bool account); + +/* Set the queue to silence, set write read index to write index*/ +void pa_memblockq_flush_read(pa_memblockq *bq); + +/* Ignore prebuf for now */ +void pa_memblockq_prebuf_disable(pa_memblockq *bq); + +/* Force prebuf */ +void pa_memblockq_prebuf_force(pa_memblockq *bq); + +/* Return the maximum length of the queue in bytes */ +size_t pa_memblockq_get_maxlength(pa_memblockq *bq); + +/* Get Target length */ +size_t pa_memblockq_get_tlength(pa_memblockq *bq); + +/* Return the prebuffer length in bytes */ +size_t pa_memblockq_get_prebuf(pa_memblockq *bq); + +/* Returns the minimal request value */ +size_t pa_memblockq_get_minreq(pa_memblockq *bq); + +/* Returns the maximal rewind value */ +size_t pa_memblockq_get_maxrewind(pa_memblockq *bq); + +/* Return the base unit in bytes */ +size_t pa_memblockq_get_base(pa_memblockq *bq); + +/* Return the current read index */ +int64_t pa_memblockq_get_read_index(pa_memblockq *bq); + +/* Return the current write index */ +int64_t pa_memblockq_get_write_index(pa_memblockq *bq); + +/* Change metrics. Always call in order. */ +void pa_memblockq_set_maxlength(pa_memblockq *memblockq, size_t maxlength); /* might modify tlength, prebuf, minreq too */ +void pa_memblockq_set_tlength(pa_memblockq *memblockq, size_t tlength); /* might modify minreq, too */ +void pa_memblockq_set_minreq(pa_memblockq *memblockq, size_t minreq); /* might modify prebuf, too */ +void pa_memblockq_set_prebuf(pa_memblockq *memblockq, size_t prebuf); +void pa_memblockq_set_maxrewind(pa_memblockq *memblockq, size_t maxrewind); /* Set the maximum history size */ +void pa_memblockq_set_silence(pa_memblockq *memblockq, pa_memchunk *silence); + +/* Apply the data from pa_buffer_attr */ +void pa_memblockq_apply_attr(pa_memblockq *memblockq, const pa_buffer_attr *a); +void pa_memblockq_get_attr(pa_memblockq *bq, pa_buffer_attr *a); + +/* Call pa_memchunk_will_need() for every chunk in the queue from the current read pointer to the end */ +void pa_memblockq_willneed(pa_memblockq *bq); + +/* Check whether the memblockq is completely empty, i.e. no data + * neither left nor right of the read pointer, and hence no buffered + * data for the future nor data in the backlog. */ +bool pa_memblockq_is_empty(pa_memblockq *bq); + +/* Drop everything in the queue, but don't modify the indexes */ +void pa_memblockq_silence(pa_memblockq *bq); + +/* Check whether we currently are in prebuf state */ +bool pa_memblockq_prebuf_active(pa_memblockq *bq); + +/* Return how many items are currently stored in the queue */ +unsigned pa_memblockq_get_nblocks(pa_memblockq *bq); + +#endif diff --git a/pulse/pulsecore-14.0/memchunk.h b/pulse/pulsecore-14.0/memchunk.h new file mode 100644 index 00000000..2b197129 --- /dev/null +++ b/pulse/pulsecore-14.0/memchunk.h @@ -0,0 +1,56 @@ +#ifndef foomemchunkhfoo +#define foomemchunkhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +typedef struct pa_memchunk pa_memchunk; + +#include + +/* A memchunk describes a part of a memblock. In contrast to the memblock, a + * memchunk is not allocated dynamically or reference counted, instead + * it is usually stored on the stack and copied around */ + +struct pa_memchunk { + pa_memblock *memblock; + size_t index, length; +}; + +/* Make a memchunk writable, i.e. make sure that the caller may have + * exclusive access to the memblock and it is not read-only. If needed + * the memblock in the structure is replaced by a copy. If min is not + * 0 it is made sure that the returned memblock is at least of the + * specified size, i.e. is enlarged if necessary. */ +pa_memchunk* pa_memchunk_make_writable(pa_memchunk *c, size_t min); + +/* Invalidate a memchunk. This does not free the containing memblock, + * but sets all members to zero. */ +pa_memchunk* pa_memchunk_reset(pa_memchunk *c); + +/* Map a memory chunk back into memory if it was swapped out */ +pa_memchunk *pa_memchunk_will_need(const pa_memchunk *c); + +/* Copy the data in the src memchunk to the dst memchunk */ +pa_memchunk* pa_memchunk_memcpy(pa_memchunk *dst, pa_memchunk *src); + +/* Return true if any field is set != 0 */ +bool pa_memchunk_isset(pa_memchunk *c); + +#endif diff --git a/pulse/pulsecore-14.0/memfd-wrappers.h b/pulse/pulsecore-14.0/memfd-wrappers.h new file mode 100644 index 00000000..c7aadfd3 --- /dev/null +++ b/pulse/pulsecore-14.0/memfd-wrappers.h @@ -0,0 +1,69 @@ +#ifndef foopulsememfdwrappershfoo +#define foopulsememfdwrappershfoo + +/*** + This file is part of PulseAudio. + + Copyright 2016 Ahmed S. Darwish + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#if defined(HAVE_MEMFD) && !defined(HAVE_MEMFD_CREATE) + +#include +#include + +/* + * Before glibc version 2.27 there was no wrapper for memfd_create(2), + * so we have to provide our own. + * + * Also define memfd fcntl sealing macros. While they are already + * defined in the kernel header file , that file as + * a whole conflicts with the original glibc header . + */ + +static inline int memfd_create(const char *name, unsigned int flags) { + return syscall(SYS_memfd_create, name, flags); +} + +/* memfd_create(2) flags */ + +#ifndef MFD_CLOEXEC +#define MFD_CLOEXEC 0x0001U +#endif + +#ifndef MFD_ALLOW_SEALING +#define MFD_ALLOW_SEALING 0x0002U +#endif + +/* fcntl() seals-related flags */ + +#ifndef F_LINUX_SPECIFIC_BASE +#define F_LINUX_SPECIFIC_BASE 1024 +#endif + +#ifndef F_ADD_SEALS +#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9) +#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10) + +#define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */ +#define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */ +#define F_SEAL_GROW 0x0004 /* prevent file from growing */ +#define F_SEAL_WRITE 0x0008 /* prevent writes */ +#endif + +#endif /* HAVE_MEMFD && !HAVE_MEMFD_CREATE */ + +#endif diff --git a/pulse/pulsecore-14.0/memtrap.h b/pulse/pulsecore-14.0/memtrap.h new file mode 100644 index 00000000..cf3e99ea --- /dev/null +++ b/pulse/pulsecore-14.0/memtrap.h @@ -0,0 +1,49 @@ +#ifndef foopulsecorememtraphfoo +#define foopulsecorememtraphfoo + +/*** + This file is part of PulseAudio. + + Copyright 2009 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include + +#include + +/* This subsystem will trap SIGBUS on specific memory regions. The + * regions will be remapped to anonymous memory (i.e. writable NUL + * bytes) on SIGBUS, so that execution of the main program can + * continue though with memory having changed beneath its hands. With + * pa_memtrap_is_good() it is possible to query if a memory region is + * still 'good' i.e. no SIGBUS has happened yet for it. + * + * Intended usage is to handle memory mapped in which is controlled by + * other processes that might execute ftruncate() or when mapping inb + * hardware resources that might get invalidated when unplugged. */ + +typedef struct pa_memtrap pa_memtrap; + +pa_memtrap* pa_memtrap_add(const void *start, size_t size); +pa_memtrap *pa_memtrap_update(pa_memtrap *m, const void *start, size_t size); + +void pa_memtrap_remove(pa_memtrap *m); + +bool pa_memtrap_is_good(pa_memtrap *m); + +void pa_memtrap_install(void); + +#endif diff --git a/pulse/pulsecore-14.0/message-handler.h b/pulse/pulsecore-14.0/message-handler.h new file mode 100644 index 00000000..be94510f --- /dev/null +++ b/pulse/pulsecore-14.0/message-handler.h @@ -0,0 +1,50 @@ +#ifndef foocoremessageshfoo +#define foocoremessageshfoo + +/*** + This file is part of PulseAudio. + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +/* Message handler types and functions */ + +/* Prototype for message callback */ +typedef int (*pa_message_handler_cb_t)( + const char *object_path, + const char *message, + const char *message_parameters, + char **response, + void *userdata); + +/* Message handler object */ +struct pa_message_handler { + char *object_path; + char *description; + pa_message_handler_cb_t callback; + void *userdata; +}; + +/* Handler registration */ +void pa_message_handler_register(pa_core *c, const char *object_path, const char *description, pa_message_handler_cb_t cb, void *userdata); +void pa_message_handler_unregister(pa_core *c, const char *object_path); + +/* Send message to the specified object path */ +int pa_message_handler_send_message(pa_core *c, const char *object_path, const char *message, const char *message_parameters, char **response); + +/* Set handler description */ +int pa_message_handler_set_description(pa_core *c, const char *object_path, const char *description); +#endif diff --git a/pulse/pulsecore-14.0/mime-type.h b/pulse/pulsecore-14.0/mime-type.h new file mode 100644 index 00000000..f07f4558 --- /dev/null +++ b/pulse/pulsecore-14.0/mime-type.h @@ -0,0 +1,31 @@ +#ifndef foopulsecoremimetypehfoo +#define foopulsecoremimetypehfoo +/*** + This file is part of PulseAudio. + + Copyright 2009 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include +#include + +bool pa_sample_spec_is_mime(const pa_sample_spec *ss, const pa_channel_map *cm); +void pa_sample_spec_mimefy(pa_sample_spec *ss, pa_channel_map *cm); +char *pa_sample_spec_to_mime_type(const pa_sample_spec *ss, const pa_channel_map *cm); +char *pa_sample_spec_to_mime_type_mimefy(const pa_sample_spec *_ss, const pa_channel_map *_cm); + +#endif diff --git a/pulse/pulsecore-14.0/mix.h b/pulse/pulsecore-14.0/mix.h new file mode 100644 index 00000000..8102bcd9 --- /dev/null +++ b/pulse/pulsecore-14.0/mix.h @@ -0,0 +1,62 @@ +#ifndef foomixhfoo +#define foomixhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + Copyright 2013 Peter Meerwald + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include +#include + +typedef struct pa_mix_info { + pa_memchunk chunk; + pa_cvolume volume; + void *userdata; + + /* The following fields are used internally by pa_mix(), should + * not be initialised by the caller of pa_mix(). */ + void *ptr; + union { + int32_t i; + float f; + } linear[PA_CHANNELS_MAX]; +} pa_mix_info; + +size_t pa_mix( + pa_mix_info channels[], + unsigned nchannels, + void *data, + size_t length, + const pa_sample_spec *spec, + const pa_cvolume *volume, + bool mute); + +typedef void (*pa_do_mix_func_t) (pa_mix_info streams[], unsigned nstreams, unsigned channels, void *data, unsigned length); + +pa_do_mix_func_t pa_get_mix_func(pa_sample_format_t f); +void pa_set_mix_func(pa_sample_format_t f, pa_do_mix_func_t func); + +void pa_volume_memchunk( + pa_memchunk*c, + const pa_sample_spec *spec, + const pa_cvolume *volume); + +#endif diff --git a/pulse/pulsecore-14.0/modargs.h b/pulse/pulsecore-14.0/modargs.h new file mode 100644 index 00000000..96132a3a --- /dev/null +++ b/pulse/pulsecore-14.0/modargs.h @@ -0,0 +1,98 @@ +#ifndef foomodargshfoo +#define foomodargshfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include +#include +#include +#include +#include +#include + +typedef struct pa_modargs pa_modargs; + +/* A generic parser for module arguments */ + +/* Parse the string args. The NULL-terminated array keys contains all valid arguments. */ +pa_modargs *pa_modargs_new(const char *args, const char* const keys[]); +/* Parse the string args, and add any keys that are not already present. */ +int pa_modargs_append(pa_modargs *ma, const char *args, const char* const* valid_keys); +void pa_modargs_free(pa_modargs*ma); + +/* Return the module argument for the specified name as a string. If + * the argument was not specified, return def instead.*/ +const char *pa_modargs_get_value(pa_modargs *ma, const char *key, const char *def); + +/* Return a module argument as unsigned 32bit value in *value. If the argument + * was not specified, *value remains unchanged. */ +int pa_modargs_get_value_u32(pa_modargs *ma, const char *key, uint32_t *value); +int pa_modargs_get_value_s32(pa_modargs *ma, const char *key, int32_t *value); +int pa_modargs_get_value_boolean(pa_modargs *ma, const char *key, bool *value); + +/* Return a module argument as double value in *value. If the argument was not + * specified, *value remains unchanged. */ +int pa_modargs_get_value_double(pa_modargs *ma, const char *key, double *value); + +/* Return a module argument as pa_volume_t value in *value. If the argument + * was not specified, *value remains unchanged. */ +int pa_modargs_get_value_volume(pa_modargs *ma, const char *key, pa_volume_t *value); + +/* Return sample rate from the "rate" argument. If the argument was not + * specified, *rate remains unchanged. */ +int pa_modargs_get_sample_rate(pa_modargs *ma, uint32_t *rate); + +/* Return sample spec data from the three arguments "rate", "format" and + * "channels". If the argument was not specified, *ss remains unchanged. */ +int pa_modargs_get_sample_spec(pa_modargs *ma, pa_sample_spec *ss); + +/* Return channel map data from the argument "channel_map" if name is NULL, + * otherwise read from the specified argument. If the argument was not + * specified, *map remains unchanged. */ +int pa_modargs_get_channel_map(pa_modargs *ma, const char *name, pa_channel_map *map); + +/* Return resample method from the argument "resample_method". If the argument + * was not specified, *method remains unchanged. */ +int pa_modargs_get_resample_method(pa_modargs *ma, pa_resample_method_t *method); + +/* Combination of pa_modargs_get_sample_spec() and +pa_modargs_get_channel_map(). Not always suitable, since this routine +initializes the map parameter based on the channels field of the ss +structure if no channel_map is found, using pa_channel_map_init_auto() */ + +int pa_modargs_get_sample_spec_and_channel_map(pa_modargs *ma, pa_sample_spec *ss, pa_channel_map *map, pa_channel_map_def_t def); + +/* Return alternate sample rate from "alternate_sample_rate" parameter. If the + * argument was not specified, *alternate_rate remains unchanged. */ +int pa_modargs_get_alternate_sample_rate(pa_modargs *ma, uint32_t *alternate_rate); + +int pa_modargs_get_proplist(pa_modargs *ma, const char *name, pa_proplist *p, pa_update_mode_t m); + +/* Iterate through the module argument list. The user should allocate a + * state variable of type void* and initialize it with NULL. A pointer + * to this variable should then be passed to pa_modargs_iterate() + * which should be called in a loop until it returns NULL which + * signifies EOL. On each invocation this function will return the + * key string for the next entry. The keys in the argument list do not + * have any particular order. */ +const char *pa_modargs_iterate(pa_modargs *ma, void **state); + +#endif diff --git a/pulse/pulsecore-14.0/modinfo.h b/pulse/pulsecore-14.0/modinfo.h new file mode 100644 index 00000000..5b99b77d --- /dev/null +++ b/pulse/pulsecore-14.0/modinfo.h @@ -0,0 +1,44 @@ +#ifndef foomodinfohfoo +#define foomodinfohfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +/* Some functions for reading module meta data from PulseAudio modules */ +#include + +typedef struct pa_modinfo { + char *author; + char *description; + char *usage; + char *version; + char *deprecated; + bool load_once; +} pa_modinfo; + +/* Read meta data from an libtool handle */ +pa_modinfo *pa_modinfo_get_by_handle(lt_dlhandle dl, const char *module_name); + +/* Read meta data from a module file */ +pa_modinfo *pa_modinfo_get_by_name(const char *name); + +/* Free meta data */ +void pa_modinfo_free(pa_modinfo *i); + +#endif diff --git a/pulse/pulsecore-14.0/module.h b/pulse/pulsecore-14.0/module.h new file mode 100644 index 00000000..f918ea60 --- /dev/null +++ b/pulse/pulsecore-14.0/module.h @@ -0,0 +1,129 @@ +#ifndef foomodulehfoo +#define foomodulehfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include + +typedef struct pa_module pa_module; + +#include +#include + +#include + +enum { + PA_MODULE_ERR_UNSPECIFIED = 1, + PA_MODULE_ERR_SKIP = 2 +}; + +struct pa_module { + pa_core *core; + char *name, *argument; + uint32_t index; + + lt_dlhandle dl; + + int (*init)(pa_module*m); + void (*done)(pa_module*m); + int (*get_n_used)(pa_module *m); + + void *userdata; + + bool load_once:1; + bool unload_requested:1; + + pa_proplist *proplist; + pa_dynarray *hooks; +}; + +bool pa_module_exists(const char *name); + +int pa_module_load(pa_module** m, pa_core *c, const char *name, const char *argument); + +void pa_module_unload(pa_module *m, bool force); +void pa_module_unload_by_index(pa_core *c, uint32_t idx, bool force); + +void pa_module_unload_request(pa_module *m, bool force); +void pa_module_unload_request_by_index(pa_core *c, uint32_t idx, bool force); + +void pa_module_unload_all(pa_core *c); + +int pa_module_get_n_used(pa_module*m); + +void pa_module_update_proplist(pa_module *m, pa_update_mode_t mode, pa_proplist *p); + +void pa_module_hook_connect(pa_module *m, pa_hook *hook, pa_hook_priority_t prio, pa_hook_cb_t cb, void *data); + +#define PA_MODULE_AUTHOR(s) \ + const char *pa__get_author(void) { return s; } \ + struct __stupid_useless_struct_to_allow_trailing_semicolon + +#define PA_MODULE_DESCRIPTION(s) \ + const char *pa__get_description(void) { return s; } \ + struct __stupid_useless_struct_to_allow_trailing_semicolon + +#define PA_MODULE_USAGE(s) \ + const char *pa__get_usage(void) { return s; } \ + struct __stupid_useless_struct_to_allow_trailing_semicolon + +#define PA_MODULE_VERSION(s) \ + const char * pa__get_version(void) { return s; } \ + struct __stupid_useless_struct_to_allow_trailing_semicolon + +#define PA_MODULE_DEPRECATED(s) \ + const char * pa__get_deprecated(void) { return s; } \ + struct __stupid_useless_struct_to_allow_trailing_semicolon + +#define PA_MODULE_LOAD_ONCE(b) \ + bool pa__load_once(void) { return b; } \ + struct __stupid_useless_struct_to_allow_trailing_semicolon + +/* Check if we're defining a module (usually defined via compiler flags) */ +#ifdef PA_MODULE_NAME + +/* Jump through some double-indirection hoops to get PA_MODULE_NAME substituted before the concatenation */ +#define _MACRO_CONCAT1(a, b) a ## b +#define _MACRO_CONCAT(a, b) _MACRO_CONCAT1(a, b) + +#define pa__init _MACRO_CONCAT(PA_MODULE_NAME, _LTX_pa__init) +#define pa__done _MACRO_CONCAT(PA_MODULE_NAME, _LTX_pa__done) +#define pa__get_author _MACRO_CONCAT(PA_MODULE_NAME, _LTX_pa__get_author) +#define pa__get_description _MACRO_CONCAT(PA_MODULE_NAME, _LTX_pa__get_description) +#define pa__get_usage _MACRO_CONCAT(PA_MODULE_NAME, _LTX_pa__get_usage) +#define pa__get_version _MACRO_CONCAT(PA_MODULE_NAME, _LTX_pa__get_version) +#define pa__get_deprecated _MACRO_CONCAT(PA_MODULE_NAME, _LTX_pa__get_deprecated) +#define pa__load_once _MACRO_CONCAT(PA_MODULE_NAME, _LTX_pa__load_once) +#define pa__get_n_used _MACRO_CONCAT(PA_MODULE_NAME, _LTX_pa__get_n_used) + +int pa__init(pa_module*m); +void pa__done(pa_module*m); +int pa__get_n_used(pa_module*m); + +const char* pa__get_author(void); +const char* pa__get_description(void); +const char* pa__get_usage(void); +const char* pa__get_version(void); +const char* pa__get_deprecated(void); +bool pa__load_once(void); +#endif /* PA_MODULE_NAME */ + +#endif diff --git a/pulse/pulsecore-14.0/msgobject.h b/pulse/pulsecore-14.0/msgobject.h new file mode 100644 index 00000000..dfb519d9 --- /dev/null +++ b/pulse/pulsecore-14.0/msgobject.h @@ -0,0 +1,46 @@ +#ifndef foopulsemsgobjecthfoo +#define foopulsemsgobjecthfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +#include +#include +#include + +typedef struct pa_msgobject pa_msgobject; + +struct pa_msgobject { + pa_object parent; + int (*process_msg)(pa_msgobject *o, int code, void *userdata, int64_t offset, pa_memchunk *chunk); +}; + +pa_msgobject *pa_msgobject_new_internal(size_t size, const char *type_id, bool (*check_type)(const char *type_name)); + +#define pa_msgobject_new(type) ((type*) pa_msgobject_new_internal(sizeof(type), type##_type_id, type##_check_type)) +#define pa_msgobject_free ((void (*) (pa_msgobject* o)) pa_object_free) + +#define PA_MSGOBJECT(o) pa_msgobject_cast(o) + +PA_DECLARE_PUBLIC_CLASS(pa_msgobject); + +#endif diff --git a/pulse/pulsecore-14.0/mutex.h b/pulse/pulsecore-14.0/mutex.h new file mode 100644 index 00000000..9cdd8575 --- /dev/null +++ b/pulse/pulsecore-14.0/mutex.h @@ -0,0 +1,57 @@ +#ifndef foopulsemutexhfoo +#define foopulsemutexhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include +#include + +typedef struct pa_mutex pa_mutex; + +/* Please think twice before enabling priority inheritance. This is no + * magic wand! Use it only when the potentially prioritized threads are + * good candidates for it. Don't use this blindly! Also, note that + * only very few operating systems actually implement this, hence this + * is merely a hint. */ +pa_mutex* pa_mutex_new(bool recursive, bool inherit_priority); + +void pa_mutex_free(pa_mutex *m); +void pa_mutex_lock(pa_mutex *m); +bool pa_mutex_try_lock(pa_mutex *m); +void pa_mutex_unlock(pa_mutex *m); + +typedef struct pa_cond pa_cond; + +pa_cond *pa_cond_new(void); +void pa_cond_free(pa_cond *c); +void pa_cond_signal(pa_cond *c, int broadcast); +int pa_cond_wait(pa_cond *c, pa_mutex *m); + +/* Static mutexes are basically just atomically updated pointers to pa_mutex objects */ + +typedef struct pa_static_mutex { + pa_atomic_ptr_t ptr; +} pa_static_mutex; + +#define PA_STATIC_MUTEX_INIT { PA_ATOMIC_PTR_INIT(NULL) } + +pa_mutex* pa_static_mutex_get(pa_static_mutex *m, bool recursive, bool inherit_priority); + +#endif diff --git a/pulse/pulsecore-14.0/namereg.h b/pulse/pulsecore-14.0/namereg.h new file mode 100644 index 00000000..eb3475ad --- /dev/null +++ b/pulse/pulsecore-14.0/namereg.h @@ -0,0 +1,43 @@ +#ifndef foonamereghfoo +#define foonamereghfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include + +#define PA_NAME_MAX 128 + +typedef enum pa_namereg_type { + PA_NAMEREG_SINK, + PA_NAMEREG_SOURCE, + PA_NAMEREG_SAMPLE, + PA_NAMEREG_CARD +} pa_namereg_type_t; + +const char *pa_namereg_register(pa_core *c, const char *name, pa_namereg_type_t type, void *data, bool fail); +void pa_namereg_unregister(pa_core *c, const char *name); +void* pa_namereg_get(pa_core *c, const char *name, pa_namereg_type_t type); + +bool pa_namereg_is_valid_name(const char *name); +bool pa_namereg_is_valid_name_or_wildcard(const char *name, pa_namereg_type_t type); +char* pa_namereg_make_valid_name(const char *name); + +#endif diff --git a/pulse/pulsecore-14.0/native-common.h b/pulse/pulsecore-14.0/native-common.h new file mode 100644 index 00000000..70338b9f --- /dev/null +++ b/pulse/pulsecore-14.0/native-common.h @@ -0,0 +1,209 @@ +#ifndef foonativecommonhfoo +#define foonativecommonhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include +#include + +#include +#include +#include + +PA_C_DECL_BEGIN + +enum { + /* Generic commands */ + PA_COMMAND_ERROR, + PA_COMMAND_TIMEOUT, /* pseudo command */ + PA_COMMAND_REPLY, + + /* CLIENT->SERVER */ + PA_COMMAND_CREATE_PLAYBACK_STREAM, /* Payload changed in v9, v12 (0.9.0, 0.9.8) */ + PA_COMMAND_DELETE_PLAYBACK_STREAM, + PA_COMMAND_CREATE_RECORD_STREAM, /* Payload changed in v9, v12 (0.9.0, 0.9.8) */ + PA_COMMAND_DELETE_RECORD_STREAM, + PA_COMMAND_EXIT, + PA_COMMAND_AUTH, + PA_COMMAND_SET_CLIENT_NAME, + PA_COMMAND_LOOKUP_SINK, + PA_COMMAND_LOOKUP_SOURCE, + PA_COMMAND_DRAIN_PLAYBACK_STREAM, + PA_COMMAND_STAT, + PA_COMMAND_GET_PLAYBACK_LATENCY, + PA_COMMAND_CREATE_UPLOAD_STREAM, + PA_COMMAND_DELETE_UPLOAD_STREAM, + PA_COMMAND_FINISH_UPLOAD_STREAM, + PA_COMMAND_PLAY_SAMPLE, + PA_COMMAND_REMOVE_SAMPLE, + + PA_COMMAND_GET_SERVER_INFO, + PA_COMMAND_GET_SINK_INFO, + PA_COMMAND_GET_SINK_INFO_LIST, + PA_COMMAND_GET_SOURCE_INFO, + PA_COMMAND_GET_SOURCE_INFO_LIST, + PA_COMMAND_GET_MODULE_INFO, + PA_COMMAND_GET_MODULE_INFO_LIST, + PA_COMMAND_GET_CLIENT_INFO, + PA_COMMAND_GET_CLIENT_INFO_LIST, + PA_COMMAND_GET_SINK_INPUT_INFO, /* Payload changed in v11 (0.9.7) */ + PA_COMMAND_GET_SINK_INPUT_INFO_LIST, /* Payload changed in v11 (0.9.7) */ + PA_COMMAND_GET_SOURCE_OUTPUT_INFO, + PA_COMMAND_GET_SOURCE_OUTPUT_INFO_LIST, + PA_COMMAND_GET_SAMPLE_INFO, + PA_COMMAND_GET_SAMPLE_INFO_LIST, + PA_COMMAND_SUBSCRIBE, + + PA_COMMAND_SET_SINK_VOLUME, + PA_COMMAND_SET_SINK_INPUT_VOLUME, + PA_COMMAND_SET_SOURCE_VOLUME, + + PA_COMMAND_SET_SINK_MUTE, + PA_COMMAND_SET_SOURCE_MUTE, + + PA_COMMAND_CORK_PLAYBACK_STREAM, + PA_COMMAND_FLUSH_PLAYBACK_STREAM, + PA_COMMAND_TRIGGER_PLAYBACK_STREAM, + + PA_COMMAND_SET_DEFAULT_SINK, + PA_COMMAND_SET_DEFAULT_SOURCE, + + PA_COMMAND_SET_PLAYBACK_STREAM_NAME, + PA_COMMAND_SET_RECORD_STREAM_NAME, + + PA_COMMAND_KILL_CLIENT, + PA_COMMAND_KILL_SINK_INPUT, + PA_COMMAND_KILL_SOURCE_OUTPUT, + + PA_COMMAND_LOAD_MODULE, + PA_COMMAND_UNLOAD_MODULE, + + /* Obsolete */ + PA_COMMAND_ADD_AUTOLOAD___OBSOLETE, + PA_COMMAND_REMOVE_AUTOLOAD___OBSOLETE, + PA_COMMAND_GET_AUTOLOAD_INFO___OBSOLETE, + PA_COMMAND_GET_AUTOLOAD_INFO_LIST___OBSOLETE, + + PA_COMMAND_GET_RECORD_LATENCY, + PA_COMMAND_CORK_RECORD_STREAM, + PA_COMMAND_FLUSH_RECORD_STREAM, + PA_COMMAND_PREBUF_PLAYBACK_STREAM, + + /* SERVER->CLIENT */ + PA_COMMAND_REQUEST, + PA_COMMAND_OVERFLOW, + PA_COMMAND_UNDERFLOW, + PA_COMMAND_PLAYBACK_STREAM_KILLED, + PA_COMMAND_RECORD_STREAM_KILLED, + PA_COMMAND_SUBSCRIBE_EVENT, + + /* A few more client->server commands */ + + /* Supported since protocol v10 (0.9.5) */ + PA_COMMAND_MOVE_SINK_INPUT, + PA_COMMAND_MOVE_SOURCE_OUTPUT, + + /* Supported since protocol v11 (0.9.7) */ + PA_COMMAND_SET_SINK_INPUT_MUTE, + + PA_COMMAND_SUSPEND_SINK, + PA_COMMAND_SUSPEND_SOURCE, + + /* Supported since protocol v12 (0.9.8) */ + PA_COMMAND_SET_PLAYBACK_STREAM_BUFFER_ATTR, + PA_COMMAND_SET_RECORD_STREAM_BUFFER_ATTR, + + PA_COMMAND_UPDATE_PLAYBACK_STREAM_SAMPLE_RATE, + PA_COMMAND_UPDATE_RECORD_STREAM_SAMPLE_RATE, + + /* SERVER->CLIENT */ + PA_COMMAND_PLAYBACK_STREAM_SUSPENDED, + PA_COMMAND_RECORD_STREAM_SUSPENDED, + PA_COMMAND_PLAYBACK_STREAM_MOVED, + PA_COMMAND_RECORD_STREAM_MOVED, + + /* Supported since protocol v13 (0.9.11) */ + PA_COMMAND_UPDATE_RECORD_STREAM_PROPLIST, + PA_COMMAND_UPDATE_PLAYBACK_STREAM_PROPLIST, + PA_COMMAND_UPDATE_CLIENT_PROPLIST, + PA_COMMAND_REMOVE_RECORD_STREAM_PROPLIST, + PA_COMMAND_REMOVE_PLAYBACK_STREAM_PROPLIST, + PA_COMMAND_REMOVE_CLIENT_PROPLIST, + + /* SERVER->CLIENT */ + PA_COMMAND_STARTED, + + /* Supported since protocol v14 (0.9.12) */ + PA_COMMAND_EXTENSION, + + /* Supported since protocol v15 (0.9.15) */ + PA_COMMAND_GET_CARD_INFO, + PA_COMMAND_GET_CARD_INFO_LIST, + PA_COMMAND_SET_CARD_PROFILE, + + PA_COMMAND_CLIENT_EVENT, + PA_COMMAND_PLAYBACK_STREAM_EVENT, + PA_COMMAND_RECORD_STREAM_EVENT, + + /* SERVER->CLIENT */ + PA_COMMAND_PLAYBACK_BUFFER_ATTR_CHANGED, + PA_COMMAND_RECORD_BUFFER_ATTR_CHANGED, + + /* Supported since protocol v16 (0.9.16) */ + PA_COMMAND_SET_SINK_PORT, + PA_COMMAND_SET_SOURCE_PORT, + + /* Supported since protocol v22 (1.0) */ + PA_COMMAND_SET_SOURCE_OUTPUT_VOLUME, + PA_COMMAND_SET_SOURCE_OUTPUT_MUTE, + + /* Supported since protocol v27 (3.0) */ + PA_COMMAND_SET_PORT_LATENCY_OFFSET, + + /* Supported since protocol v30 (6.0) */ + /* BOTH DIRECTIONS */ + PA_COMMAND_ENABLE_SRBCHANNEL, + PA_COMMAND_DISABLE_SRBCHANNEL, + + /* Supported since protocol v31 (9.0) + * BOTH DIRECTIONS */ + PA_COMMAND_REGISTER_MEMFD_SHMID, + + PA_COMMAND_MAX +}; + +#define PA_NATIVE_COOKIE_LENGTH 256 +#define PA_NATIVE_COOKIE_FILE "cookie" +#define PA_NATIVE_COOKIE_FILE_FALLBACK ".pulse-cookie" + +#define PA_NATIVE_DEFAULT_PORT 4713 + +#define PA_NATIVE_COOKIE_PROPERTY_NAME "protocol-native-cookie" +#define PA_NATIVE_SERVER_PROPERTY_NAME "protocol-native-server" + +#define PA_NATIVE_DEFAULT_UNIX_SOCKET "native" + +int pa_common_command_register_memfd_shmid(pa_pstream *p, pa_pdispatch *pd, uint32_t version, + uint32_t command, pa_tagstruct *t); + +PA_C_DECL_END + +#endif diff --git a/pulse/pulsecore-14.0/object.h b/pulse/pulsecore-14.0/object.h new file mode 100644 index 00000000..15e8365b --- /dev/null +++ b/pulse/pulsecore-14.0/object.h @@ -0,0 +1,117 @@ +#ifndef foopulseobjecthfoo +#define foopulseobjecthfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +#include +#include +#include + +typedef struct pa_object pa_object; + +struct pa_object { + PA_REFCNT_DECLARE; + const char *type_id; + void (*free)(pa_object *o); + bool (*check_type)(const char *type_name); +}; + +pa_object *pa_object_new_internal(size_t size, const char *type_id, bool (*check_type)(const char *type_id)); +#define pa_object_new(type) ((type*) pa_object_new_internal(sizeof(type), type##_type_id, type##_check_type)) + +#define pa_object_free ((void (*) (pa_object* _obj)) pa_xfree) + +bool pa_object_check_type(const char *type_id); + +extern const char pa_object_type_id[]; + +static inline bool pa_object_isinstance(void *o) { + pa_object *obj = (pa_object*) o; + return obj ? obj->check_type(pa_object_type_id) : true; +} + +pa_object *pa_object_ref(pa_object *o); +void pa_object_unref(pa_object *o); + +static inline int pa_object_refcnt(pa_object *o) { + return o ? PA_REFCNT_VALUE(o) : 0; +} + +static inline pa_object* pa_object_cast(void *o) { + pa_object *obj = (pa_object*) o; + pa_assert(!obj || obj->check_type(pa_object_type_id)); + return obj; +} + +#define pa_object_assert_ref(o) pa_assert(pa_object_refcnt(o) > 0) + +#define PA_OBJECT(o) pa_object_cast(o) + +#define PA_DECLARE_CLASS_COMMON(c) \ + static inline bool c##_isinstance(void *o) { \ + pa_object *obj = (pa_object*) o; \ + return obj ? obj->check_type(c##_type_id) : true; \ + } \ + static inline c* c##_cast(void *o) { \ + pa_assert(c##_isinstance(o)); \ + return (c*) o; \ + } \ + static inline c* c##_ref(c *o) { \ + return (c *) ((void *) pa_object_ref(PA_OBJECT(o))); \ + } \ + static inline void c##_unref(c* o) { \ + pa_object_unref(PA_OBJECT(o)); \ + } \ + static inline int c##_refcnt(c* o) { \ + return pa_object_refcnt(PA_OBJECT(o)); \ + } \ + static inline void c##_assert_ref(c *o) { \ + pa_object_assert_ref(PA_OBJECT(o)); \ + } \ + struct __stupid_useless_struct_to_allow_trailing_semicolon + +#define PA_DECLARE_PUBLIC_CLASS(c) \ + extern const char c##_type_id[]; \ + PA_DECLARE_CLASS_COMMON(c); \ + bool c##_check_type(const char *type_id) + +#define PA_DEFINE_PUBLIC_CLASS(c, parent) \ + const char c##_type_id[] = #c; \ + bool c##_check_type(const char *type_id) { \ + if (type_id == c##_type_id) \ + return true; \ + return parent##_check_type(type_id); \ + } \ + struct __stupid_useless_struct_to_allow_trailing_semicolon + +#define PA_DEFINE_PRIVATE_CLASS(c, parent) \ + static const char c##_type_id[] = #c; \ + PA_DECLARE_CLASS_COMMON(c); \ + static bool c##_check_type(const char *type_id) { \ + if (type_id == c##_type_id) \ + return true; \ + return parent##_check_type(type_id); \ + } \ + struct __stupid_useless_struct_to_allow_trailing_semicolon + +#endif diff --git a/pulse/pulsecore-14.0/once.h b/pulse/pulsecore-14.0/once.h new file mode 100644 index 00000000..8cd7894f --- /dev/null +++ b/pulse/pulsecore-14.0/once.h @@ -0,0 +1,71 @@ +#ifndef foopulseoncehfoo +#define foopulseoncehfoo + +/*** + This file is part of PulseAudio. + + Copyright 2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include +#include + +typedef struct pa_once { + pa_static_mutex mutex; + pa_atomic_t done; +} pa_once; + +#define PA_ONCE_INIT \ + { \ + .mutex = PA_STATIC_MUTEX_INIT, \ + .done = PA_ATOMIC_INIT(0) \ + } + +/* Not to be called directly, use the macros defined below instead */ +bool pa_once_begin(pa_once *o); +void pa_once_end(pa_once *o); + +#define PA_ONCE_BEGIN \ + do { \ + static pa_once _once = PA_ONCE_INIT; \ + if (pa_once_begin(&_once)) {{ + +#define PA_ONCE_END \ + } \ + pa_once_end(&_once); \ + } \ + } while(0) + +/* + + Usage of these macros is like this: + + void foo() { + + PA_ONCE_BEGIN { + + ... stuff to be called just once ... + + } PA_ONCE_END; + } + +*/ + +/* Same API but calls a function */ +typedef void (*pa_once_func_t) (void); +void pa_run_once(pa_once *o, pa_once_func_t f); + +#endif diff --git a/pulse/pulsecore-14.0/packet.h b/pulse/pulsecore-14.0/packet.h new file mode 100644 index 00000000..20609871 --- /dev/null +++ b/pulse/pulsecore-14.0/packet.h @@ -0,0 +1,45 @@ +#ifndef foopackethfoo +#define foopackethfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include +#include + +typedef struct pa_packet pa_packet; + +/* create empty packet (either of type appended or dynamic depending + * on length) */ +pa_packet* pa_packet_new(size_t length); + +/* create packet (either of type appended or dynamic depending on length) + * and copy data */ +pa_packet* pa_packet_new_data(const void* data, size_t length); + +/* data must have been malloc()ed; the packet takes ownership of the memory, + * i.e. memory is free()d with the packet */ +pa_packet* pa_packet_new_dynamic(void* data, size_t length); + +const void* pa_packet_data(pa_packet *p, size_t *l); + +pa_packet* pa_packet_ref(pa_packet *p); +void pa_packet_unref(pa_packet *p); + +#endif diff --git a/pulse/pulsecore-14.0/parseaddr.h b/pulse/pulsecore-14.0/parseaddr.h new file mode 100644 index 00000000..6bb4d852 --- /dev/null +++ b/pulse/pulsecore-14.0/parseaddr.h @@ -0,0 +1,46 @@ +#ifndef foopulsecoreparseaddrhfoo +#define foopulsecoreparseaddrhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include + +#include + +typedef enum pa_parsed_address_type { + PA_PARSED_ADDRESS_UNIX, + PA_PARSED_ADDRESS_TCP4, + PA_PARSED_ADDRESS_TCP6, + PA_PARSED_ADDRESS_TCP_AUTO +} pa_parsed_address_type_t; + +typedef struct pa_parsed_address { + pa_parsed_address_type_t type; + char *path_or_host; + uint16_t port; +} pa_parsed_address; + +int pa_parse_address(const char *a, pa_parsed_address *ret_p); + +bool pa_is_ip_address(const char *a); + +bool pa_is_ip6_address(const char *a); + +#endif diff --git a/pulse/pulsecore-14.0/pdispatch.h b/pulse/pulsecore-14.0/pdispatch.h new file mode 100644 index 00000000..af769819 --- /dev/null +++ b/pulse/pulsecore-14.0/pdispatch.h @@ -0,0 +1,56 @@ +#ifndef foopdispatchhfoo +#define foopdispatchhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include + +#include +#include + +#include +#include +#include + +typedef struct pa_pdispatch pa_pdispatch; + +typedef void (*pa_pdispatch_cb_t)(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata); +typedef void (*pa_pdispatch_drain_cb_t)(pa_pdispatch *pd, void *userdata); + +pa_pdispatch* pa_pdispatch_new(pa_mainloop_api *m, bool use_rtclock, const pa_pdispatch_cb_t *table, unsigned entries); +void pa_pdispatch_unref(pa_pdispatch *pd); +pa_pdispatch* pa_pdispatch_ref(pa_pdispatch *pd); + +int pa_pdispatch_run(pa_pdispatch *pd, pa_packet *p, pa_cmsg_ancil_data *ancil_data, void *userdata); + +void pa_pdispatch_register_reply(pa_pdispatch *pd, uint32_t tag, int timeout, pa_pdispatch_cb_t callback, void *userdata, pa_free_cb_t free_cb); + +int pa_pdispatch_is_pending(pa_pdispatch *pd); + +void pa_pdispatch_set_drain_callback(pa_pdispatch *pd, pa_pdispatch_drain_cb_t callback, void *userdata); + +/* Remove all reply slots with the give userdata parameter */ +void pa_pdispatch_unregister_reply(pa_pdispatch *pd, void *userdata); + +const pa_creds * pa_pdispatch_creds(pa_pdispatch *pd); +pa_cmsg_ancil_data *pa_pdispatch_take_ancil_data(pa_pdispatch *pd); + +#endif diff --git a/pulse/pulsecore-14.0/pid.h b/pulse/pulsecore-14.0/pid.h new file mode 100644 index 00000000..ff0356b1 --- /dev/null +++ b/pulse/pulsecore-14.0/pid.h @@ -0,0 +1,28 @@ +#ifndef foopidhfoo +#define foopidhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +int pa_pid_file_create(const char *procname); +int pa_pid_file_remove(void); +int pa_pid_file_check_running(pid_t *pid, const char *procname); +int pa_pid_file_kill(int sig, pid_t *pid, const char *procname); + +#endif diff --git a/pulse/pulsecore-14.0/pipe.h b/pulse/pulsecore-14.0/pipe.h new file mode 100644 index 00000000..54e98191 --- /dev/null +++ b/pulse/pulsecore-14.0/pipe.h @@ -0,0 +1,29 @@ +#ifndef foopipehfoo +#define foopipehfoo + +/*** + This file is part of PulseAudio. + + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#ifndef HAVE_PIPE + +int pipe(int filedes[2]); + +#endif + +#endif diff --git a/pulse/pulsecore-14.0/play-memblockq.h b/pulse/pulsecore-14.0/play-memblockq.h new file mode 100644 index 00000000..c13aceda --- /dev/null +++ b/pulse/pulsecore-14.0/play-memblockq.h @@ -0,0 +1,47 @@ +#ifndef fooplaymemblockqhfoo +#define fooplaymemblockqhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include + +pa_sink_input* pa_memblockq_sink_input_new( + pa_sink *sink, + const pa_sample_spec *ss, + const pa_channel_map *map, + pa_memblockq *q, + pa_cvolume *volume, + pa_proplist *p, + pa_sink_input_flags_t flags); + +void pa_memblockq_sink_input_set_queue(pa_sink_input *i, pa_memblockq *q); + +int pa_play_memblockq( + pa_sink *sink, + const pa_sample_spec *ss, + const pa_channel_map *map, + pa_memblockq *q, + pa_cvolume *cvolume, + pa_proplist *p, + pa_sink_input_flags_t flags, + uint32_t *sink_input_index); + +#endif diff --git a/pulse/pulsecore-14.0/play-memchunk.h b/pulse/pulsecore-14.0/play-memchunk.h new file mode 100644 index 00000000..7c56fe3c --- /dev/null +++ b/pulse/pulsecore-14.0/play-memchunk.h @@ -0,0 +1,36 @@ +#ifndef fooplaychunkhfoo +#define fooplaychunkhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include + +int pa_play_memchunk( + pa_sink *sink, + const pa_sample_spec *ss, + const pa_channel_map *map, + const pa_memchunk *chunk, + pa_cvolume *cvolume, + pa_proplist *p, + pa_sink_input_flags_t flags, + uint32_t *sink_input_index); + +#endif diff --git a/pulse/pulsecore-14.0/poll.h b/pulse/pulsecore-14.0/poll.h new file mode 100644 index 00000000..4af1b994 --- /dev/null +++ b/pulse/pulsecore-14.0/poll.h @@ -0,0 +1,62 @@ +/*** + This file is part of PulseAudio. + + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +/*** + Based on work for the GNU C Library. + Copyright (C) 1994,96,97,98,99,2000,2001,2004 Free Software Foundation, Inc. +***/ + +#if defined(HAVE_POLL_H) +#include +#else + +/* Event types that can be polled for. These bits may be set in `events' + to indicate the interesting event types; they will appear in `revents' + to indicate the status of the file descriptor. */ +#define POLLIN 0x001 /* There is data to read. */ +#define POLLPRI 0x002 /* There is urgent data to read. */ +#define POLLOUT 0x004 /* Writing now will not block. */ + +/* Event types always implicitly polled for. These bits need not be set in + `events', but they will appear in `revents' to indicate the status of + the file descriptor. */ +#define POLLERR 0x008 /* Error condition. */ +#define POLLHUP 0x010 /* Hung up. */ +#define POLLNVAL 0x020 /* Invalid polling request. */ + +/* Data structure describing a polling request. */ +struct pollfd { + int fd; /* File descriptor to poll. */ + short int events; /* Types of events poller cares about. */ + short int revents; /* Types of events that actually occurred. */ +}; + +/* Poll the file descriptors described by the NFDS structures starting at + FDS. If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for + an event to occur; if TIMEOUT is -1, block until an event occurs. + Returns the number of file descriptors with events, zero if timed out, + or -1 for errors. */ + +#endif /* HAVE_POLL_H */ + +#if defined(HAVE_POLL_H) && !defined(OS_IS_DARWIN) +#define pa_poll(fds,nfds,timeout) poll((fds),(nfds),(timeout)) +#else +int pa_poll(struct pollfd *fds, unsigned long nfds, int timeout); +#endif diff --git a/pulse/pulsecore-14.0/proplist-util.h b/pulse/pulsecore-14.0/proplist-util.h new file mode 100644 index 00000000..17f231f2 --- /dev/null +++ b/pulse/pulsecore-14.0/proplist-util.h @@ -0,0 +1,28 @@ +#ifndef fooproplistutilutilhfoo +#define fooproplistutilutilhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2008 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include + +void pa_init_proplist(pa_proplist *p); +char *pa_proplist_get_stream_group(pa_proplist *pl, const char *prefix, const char *cache); + +#endif diff --git a/pulse/pulsecore-14.0/protocol-cli.h b/pulse/pulsecore-14.0/protocol-cli.h new file mode 100644 index 00000000..fde6e388 --- /dev/null +++ b/pulse/pulsecore-14.0/protocol-cli.h @@ -0,0 +1,36 @@ +#ifndef fooprotocolclihfoo +#define fooprotocolclihfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include +#include +#include + +typedef struct pa_cli_protocol pa_cli_protocol; + +pa_cli_protocol* pa_cli_protocol_get(pa_core *core); +pa_cli_protocol* pa_cli_protocol_ref(pa_cli_protocol *p); +void pa_cli_protocol_unref(pa_cli_protocol *p); +void pa_cli_protocol_connect(pa_cli_protocol *p, pa_iochannel *io, pa_module *m); +void pa_cli_protocol_disconnect(pa_cli_protocol *o, pa_module *m); + +#endif diff --git a/pulse/pulsecore-14.0/protocol-dbus.h b/pulse/pulsecore-14.0/protocol-dbus.h new file mode 100644 index 00000000..fdc1ae95 --- /dev/null +++ b/pulse/pulsecore-14.0/protocol-dbus.h @@ -0,0 +1,215 @@ +#ifndef fooprotocoldbushfoo +#define fooprotocoldbushfoo + +/*** + This file is part of PulseAudio. + + Copyright 2009 Tanu Kaskinen + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +#include +#include + +#define PA_DBUS_DEFAULT_PORT 24883 +#define PA_DBUS_SOCKET_NAME "dbus-socket" + +#define PA_DBUS_SYSTEM_SOCKET_PATH PA_SYSTEM_RUNTIME_PATH PA_PATH_SEP PA_DBUS_SOCKET_NAME + +#define PA_DBUS_CORE_INTERFACE "org.PulseAudio.Core1" +#define PA_DBUS_CORE_OBJECT_PATH "/org/pulseaudio/core1" + +#define PA_DBUS_ERROR_NO_SUCH_INTERFACE PA_DBUS_CORE_INTERFACE ".NoSuchInterfaceError" +#define PA_DBUS_ERROR_NO_SUCH_PROPERTY PA_DBUS_CORE_INTERFACE ".NoSuchPropertyError" +#define PA_DBUS_ERROR_NOT_FOUND PA_DBUS_CORE_INTERFACE ".NotFoundError" + +/* Returns the default address of the server type in the escaped form. For + * PA_SERVER_TYPE_NONE an empty string is returned. The caller frees the + * string. */ +char *pa_get_dbus_address_from_server_type(pa_server_type_t server_type); + +typedef struct pa_dbus_protocol pa_dbus_protocol; + +/* This function either creates a new pa_dbus_protocol object, or if one + * already exists, increases the reference count. */ +pa_dbus_protocol* pa_dbus_protocol_get(pa_core *c); + +pa_dbus_protocol* pa_dbus_protocol_ref(pa_dbus_protocol *p); +void pa_dbus_protocol_unref(pa_dbus_protocol *p); + +/* Called when a received message needs handling. Completely ignoring the + * message isn't a good idea; if you can't handle the message, reply with an + * error. + * + * The message signature is already checked against the introspection data, so + * you don't have to do that yourself. + * + * All messages are method calls. */ +typedef void (*pa_dbus_receive_cb_t)(DBusConnection *conn, DBusMessage *msg, void *userdata); + +/* A specialized version of pa_dbus_receive_cb_t: the additional iterator + * argument points to the element inside the new value variant. + * + * The new value signature is checked against the introspection data, so you + * don't have to do that yourself. */ +typedef void (*pa_dbus_set_property_cb_t)(DBusConnection *conn, DBusMessage *msg, DBusMessageIter *iter, void *userdata); + +typedef struct pa_dbus_arg_info { + const char *name; + const char *type; + const char *direction; /* NULL for signal arguments. */ +} pa_dbus_arg_info; + +typedef struct pa_dbus_signal_info { + const char *name; + const pa_dbus_arg_info *arguments; /* NULL, if the signal has no args. */ + unsigned n_arguments; +} pa_dbus_signal_info; + +typedef struct pa_dbus_method_handler { + const char *method_name; + const pa_dbus_arg_info *arguments; /* NULL, if the method has no args. */ + unsigned n_arguments; + pa_dbus_receive_cb_t receive_cb; +} pa_dbus_method_handler; + +typedef struct pa_dbus_property_handler { + const char *property_name; + const char *type; + + /* The access mode for the property is determined by checking whether + * get_cb or set_cb is NULL. */ + pa_dbus_receive_cb_t get_cb; + pa_dbus_set_property_cb_t set_cb; +} pa_dbus_property_handler; + +typedef struct pa_dbus_interface_info { + const char* name; + const pa_dbus_method_handler *method_handlers; /* NULL, if the interface has no methods. */ + unsigned n_method_handlers; + const pa_dbus_property_handler *property_handlers; /* NULL, if the interface has no properties. */ + unsigned n_property_handlers; + const pa_dbus_receive_cb_t get_all_properties_cb; /* May be NULL, in which case GetAll returns an error. */ + const pa_dbus_signal_info *signals; /* NULL, if the interface has no signals. */ + unsigned n_signals; +} pa_dbus_interface_info; + +/* The following functions may only be called from the main thread. */ + +/* Registers the given interface to the given object path. It doesn't matter + * whether or not the object has already been registered; if it is, then its + * interface set is extended. + * + * Introspection requests are handled automatically. + * + * Userdata is passed to all the callbacks. + * + * Fails and returns a negative number if the object already has the interface + * registered. */ +int pa_dbus_protocol_add_interface(pa_dbus_protocol *p, const char *path, const pa_dbus_interface_info *info, void *userdata); + +/* Returns a negative number if the given object doesn't have the given + * interface registered. */ +int pa_dbus_protocol_remove_interface(pa_dbus_protocol *p, const char* path, const char* interface); + +/* Fails and returns a negative number if the connection is already + * registered. */ +int pa_dbus_protocol_register_connection(pa_dbus_protocol *p, DBusConnection *conn, pa_client *client); + +/* Returns a negative number if the connection isn't registered. */ +int pa_dbus_protocol_unregister_connection(pa_dbus_protocol *p, DBusConnection *conn); + +/* Returns NULL if the connection isn't registered. */ +pa_client *pa_dbus_protocol_get_client(pa_dbus_protocol *p, DBusConnection *conn); + +/* Enables signal receiving for the given connection. The connection must have + * been registered earlier. The signal string must contain both the signal + * interface and the signal name, concatenated using a period as the separator. + * + * If the signal argument is NULL, all signals will be sent to the connection, + * otherwise calling this function only adds the given signal to the list of + * signals that will be delivered to the connection. + * + * The objects argument is a list of object paths. If the list is not empty, + * only signals from the given objects are delivered. If this function is + * called multiple time for the same connection and signal, the latest call + * always replaces the previous object list. */ +void pa_dbus_protocol_add_signal_listener( + pa_dbus_protocol *p, + DBusConnection *conn, + const char *signal, + char **objects, + unsigned n_objects); + +/* Disables the delivery of the signal for the given connection. The connection + * must have been registered. If signal is NULL, all signals are disabled. If + * signal is non-NULL and _add_signal_listener() was previously called with + * NULL signal (causing all signals to be enabled), this function doesn't do + * anything. Also, if the signal wasn't enabled before, this function doesn't + * do anything in that case either. */ +void pa_dbus_protocol_remove_signal_listener(pa_dbus_protocol *p, DBusConnection *conn, const char *signal); + +/* Sends the given signal to all interested clients. By default no signals are + * sent - clients have to explicitly to request signals by calling + * .Core1.ListenForSignal. That method's handler then calls + * pa_dbus_protocol_add_signal_listener(). */ +void pa_dbus_protocol_send_signal(pa_dbus_protocol *p, DBusMessage *signal); + +/* Returns an array of extension identifier strings. The strings pointers point + * to the internal copies, so don't free the strings. The caller must free the + * array, however. Also, do not save the returned pointer or any of the string + * pointers, because the contained strings may be freed at any time. If you + * need to save the array, copy it. */ +const char **pa_dbus_protocol_get_extensions(pa_dbus_protocol *p, unsigned *n); + +/* Modules that want to provide a D-Bus interface for clients should register + * an identifier that the clients can use to check whether the additional + * functionality is available. + * + * This function registers the extension with the given name. It is recommended + * that the name follows the D-Bus interface naming convention, so that the + * names remain unique in case there will be at some point in the future + * extensions that aren't included with the main PulseAudio source tree. For + * in-tree extensions the convention is to use the org.PulseAudio.Ext + * namespace. + * + * It is suggested that the name contains a version number, and whenever the + * extension interface is modified in non-backwards compatible way, the version + * number is incremented. + * + * Fails and returns a negative number if the extension is already registered. + */ +int pa_dbus_protocol_register_extension(pa_dbus_protocol *p, const char *name); + +/* Returns a negative number if the extension isn't registered. */ +int pa_dbus_protocol_unregister_extension(pa_dbus_protocol *p, const char *name); + +/* All hooks have the pa_dbus_protocol object as hook data. */ +typedef enum pa_dbus_protocol_hook { + PA_DBUS_PROTOCOL_HOOK_EXTENSION_REGISTERED, /* Extension name as call data. */ + PA_DBUS_PROTOCOL_HOOK_EXTENSION_UNREGISTERED, /* Extension name as call data. */ + PA_DBUS_PROTOCOL_HOOK_MAX +} pa_dbus_protocol_hook_t; + +pa_hook_slot *pa_dbus_protocol_hook_connect( + pa_dbus_protocol *p, + pa_dbus_protocol_hook_t hook, + pa_hook_priority_t prio, + pa_hook_cb_t cb, + void *data); + +#endif diff --git a/pulse/pulsecore-14.0/protocol-esound.h b/pulse/pulsecore-14.0/protocol-esound.h new file mode 100644 index 00000000..62086403 --- /dev/null +++ b/pulse/pulsecore-14.0/protocol-esound.h @@ -0,0 +1,56 @@ +#ifndef fooprotocolesoundhfoo +#define fooprotocolesoundhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include +#include +#include +#include +#include + +typedef struct pa_esound_protocol pa_esound_protocol; + +typedef struct pa_esound_options { + PA_REFCNT_DECLARE; + + pa_module *module; + + bool auth_anonymous; + pa_ip_acl *auth_ip_acl; + pa_auth_cookie *auth_cookie; + + char *default_sink, *default_source; +} pa_esound_options; + +pa_esound_protocol* pa_esound_protocol_get(pa_core*core); +pa_esound_protocol* pa_esound_protocol_ref(pa_esound_protocol *p); +void pa_esound_protocol_unref(pa_esound_protocol *p); +void pa_esound_protocol_connect(pa_esound_protocol *p, pa_iochannel *io, pa_esound_options *o); +void pa_esound_protocol_disconnect(pa_esound_protocol *p, pa_module *m); + +pa_esound_options* pa_esound_options_new(void); +pa_esound_options* pa_esound_options_ref(pa_esound_options *o); +void pa_esound_options_unref(pa_esound_options *o); +int pa_esound_options_parse(pa_esound_options *o, pa_core *c, pa_modargs *ma); + +#endif diff --git a/pulse/pulsecore-14.0/protocol-http.h b/pulse/pulsecore-14.0/protocol-http.h new file mode 100644 index 00000000..89a65183 --- /dev/null +++ b/pulse/pulsecore-14.0/protocol-http.h @@ -0,0 +1,41 @@ +#ifndef fooprotocolhttphfoo +#define fooprotocolhttphfoo + +/*** + This file is part of PulseAudio. + + Copyright 2005-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include +#include +#include +#include + +typedef struct pa_http_protocol pa_http_protocol; + +pa_http_protocol* pa_http_protocol_get(pa_core *core); +pa_http_protocol* pa_http_protocol_ref(pa_http_protocol *p); +void pa_http_protocol_unref(pa_http_protocol *p); +void pa_http_protocol_connect(pa_http_protocol *p, pa_iochannel *io, pa_module *m); +void pa_http_protocol_disconnect(pa_http_protocol *p, pa_module *m); + +void pa_http_protocol_add_server_string(pa_http_protocol *p, const char *name); +void pa_http_protocol_remove_server_string(pa_http_protocol *p, const char *name); +pa_strlist *pa_http_protocol_servers(pa_http_protocol *p); + +#endif diff --git a/pulse/pulsecore-14.0/protocol-native.h b/pulse/pulsecore-14.0/protocol-native.h new file mode 100644 index 00000000..0347fdf4 --- /dev/null +++ b/pulse/pulsecore-14.0/protocol-native.h @@ -0,0 +1,88 @@ +#ifndef fooprotocolnativehfoo +#define fooprotocolnativehfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct pa_native_protocol pa_native_protocol; + +typedef struct pa_native_connection pa_native_connection; + +typedef struct pa_native_options { + PA_REFCNT_DECLARE; + + pa_module *module; + + bool auth_anonymous; + bool srbchannel; + char *auth_group; + pa_ip_acl *auth_ip_acl; + pa_auth_cookie *auth_cookie; +} pa_native_options; + +typedef enum pa_native_hook { + PA_NATIVE_HOOK_SERVERS_CHANGED, + PA_NATIVE_HOOK_CONNECTION_PUT, + PA_NATIVE_HOOK_CONNECTION_UNLINK, + PA_NATIVE_HOOK_MAX +} pa_native_hook_t; + +pa_native_protocol* pa_native_protocol_get(pa_core *core); +pa_native_protocol* pa_native_protocol_ref(pa_native_protocol *p); +void pa_native_protocol_unref(pa_native_protocol *p); +void pa_native_protocol_connect(pa_native_protocol *p, pa_iochannel *io, pa_native_options *a); +void pa_native_protocol_disconnect(pa_native_protocol *p, pa_module *m); + +pa_hook *pa_native_protocol_hooks(pa_native_protocol *p); + +void pa_native_protocol_add_server_string(pa_native_protocol *p, const char *name); +void pa_native_protocol_remove_server_string(pa_native_protocol *p, const char *name); +pa_strlist *pa_native_protocol_servers(pa_native_protocol *p); + +typedef int (*pa_native_protocol_ext_cb_t)( + pa_native_protocol *p, + pa_module *m, + pa_native_connection *c, + uint32_t tag, + pa_tagstruct *t); + +int pa_native_protocol_install_ext(pa_native_protocol *p, pa_module *m, pa_native_protocol_ext_cb_t cb); +void pa_native_protocol_remove_ext(pa_native_protocol *p, pa_module *m); + +pa_pstream* pa_native_connection_get_pstream(pa_native_connection *c); +pa_client* pa_native_connection_get_client(pa_native_connection *c); + +pa_native_options* pa_native_options_new(void); +pa_native_options* pa_native_options_ref(pa_native_options *o); +void pa_native_options_unref(pa_native_options *o); +int pa_native_options_parse(pa_native_options *o, pa_core *c, pa_modargs *ma); + +#endif diff --git a/pulse/pulsecore-14.0/protocol-simple.h b/pulse/pulsecore-14.0/protocol-simple.h new file mode 100644 index 00000000..0a72cd7e --- /dev/null +++ b/pulse/pulsecore-14.0/protocol-simple.h @@ -0,0 +1,55 @@ +#ifndef fooprotocolsimplehfoo +#define fooprotocolsimplehfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include +#include +#include + +typedef struct pa_simple_protocol pa_simple_protocol; + +typedef struct pa_simple_options { + PA_REFCNT_DECLARE; + + pa_module *module; + + char *default_sink, *default_source; + + pa_sample_spec sample_spec; + pa_channel_map channel_map; + + bool record:1; + bool playback:1; +} pa_simple_options; + +pa_simple_protocol* pa_simple_protocol_get(pa_core*core); +pa_simple_protocol* pa_simple_protocol_ref(pa_simple_protocol *p); +void pa_simple_protocol_unref(pa_simple_protocol *p); +void pa_simple_protocol_connect(pa_simple_protocol *p, pa_iochannel *io, pa_simple_options *o); +void pa_simple_protocol_disconnect(pa_simple_protocol *p, pa_module *m); + +pa_simple_options* pa_simple_options_new(void); +pa_simple_options* pa_simple_options_ref(pa_simple_options *o); +void pa_simple_options_unref(pa_simple_options *o); +int pa_simple_options_parse(pa_simple_options *o, pa_core *c, pa_modargs *ma); + +#endif diff --git a/pulse/pulsecore-14.0/pstream-util.h b/pulse/pulsecore-14.0/pstream-util.h new file mode 100644 index 00000000..1191d480 --- /dev/null +++ b/pulse/pulsecore-14.0/pstream-util.h @@ -0,0 +1,39 @@ +#ifndef foopstreamutilhfoo +#define foopstreamutilhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include +#include +#include +#include + +/* The tagstruct is freed!*/ +void pa_pstream_send_tagstruct_with_creds(pa_pstream *p, pa_tagstruct *t, const pa_creds *creds); +void pa_pstream_send_tagstruct_with_fds(pa_pstream *p, pa_tagstruct *t, int nfd, const int *fds, bool close_fds); + +#define pa_pstream_send_tagstruct(p, t) pa_pstream_send_tagstruct_with_creds((p), (t), NULL) + +void pa_pstream_send_error(pa_pstream *p, uint32_t tag, uint32_t error); +void pa_pstream_send_simple_ack(pa_pstream *p, uint32_t tag); + +int pa_pstream_register_memfd_mempool(pa_pstream *p, pa_mempool *pool, const char **fail_reason); + +#endif diff --git a/pulse/pulsecore-14.0/pstream.h b/pulse/pulsecore-14.0/pstream.h new file mode 100644 index 00000000..2bff270a --- /dev/null +++ b/pulse/pulsecore-14.0/pstream.h @@ -0,0 +1,76 @@ +#ifndef foopstreamhfoo +#define foopstreamhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +typedef struct pa_pstream pa_pstream; + +typedef void (*pa_pstream_packet_cb_t)(pa_pstream *p, pa_packet *packet, pa_cmsg_ancil_data *ancil_data, void *userdata); +typedef void (*pa_pstream_memblock_cb_t)(pa_pstream *p, uint32_t channel, int64_t offset, pa_seek_mode_t seek, const pa_memchunk *chunk, void *userdata); +typedef void (*pa_pstream_notify_cb_t)(pa_pstream *p, void *userdata); +typedef void (*pa_pstream_block_id_cb_t)(pa_pstream *p, uint32_t block_id, void *userdata); + +pa_pstream* pa_pstream_new(pa_mainloop_api *m, pa_iochannel *io, pa_mempool *p); + +pa_pstream* pa_pstream_ref(pa_pstream*p); +void pa_pstream_unref(pa_pstream*p); + +void pa_pstream_unlink(pa_pstream *p); + +int pa_pstream_attach_memfd_shmid(pa_pstream *p, unsigned shm_id, int memfd_fd); + +void pa_pstream_send_packet(pa_pstream*p, pa_packet *packet, pa_cmsg_ancil_data *ancil_data); +void pa_pstream_send_memblock(pa_pstream*p, uint32_t channel, int64_t offset, pa_seek_mode_t seek, const pa_memchunk *chunk); +void pa_pstream_send_release(pa_pstream *p, uint32_t block_id); +void pa_pstream_send_revoke(pa_pstream *p, uint32_t block_id); + +void pa_pstream_set_receive_packet_callback(pa_pstream *p, pa_pstream_packet_cb_t cb, void *userdata); +void pa_pstream_set_receive_memblock_callback(pa_pstream *p, pa_pstream_memblock_cb_t cb, void *userdata); +void pa_pstream_set_drain_callback(pa_pstream *p, pa_pstream_notify_cb_t cb, void *userdata); +void pa_pstream_set_die_callback(pa_pstream *p, pa_pstream_notify_cb_t cb, void *userdata); +void pa_pstream_set_release_callback(pa_pstream *p, pa_pstream_block_id_cb_t cb, void *userdata); +void pa_pstream_set_revoke_callback(pa_pstream *p, pa_pstream_block_id_cb_t cb, void *userdata); + +bool pa_pstream_is_pending(pa_pstream *p); + +void pa_pstream_enable_shm(pa_pstream *p, bool enable); +void pa_pstream_enable_memfd(pa_pstream *p); +bool pa_pstream_get_shm(pa_pstream *p); +bool pa_pstream_get_memfd(pa_pstream *p); + +/* Enables shared ringbuffer channel. Note that the srbchannel is now owned by the pstream. + Setting srb to NULL will free any existing srbchannel. */ +void pa_pstream_set_srbchannel(pa_pstream *p, pa_srbchannel *srb); + +#endif diff --git a/pulse/pulsecore-14.0/queue.h b/pulse/pulsecore-14.0/queue.h new file mode 100644 index 00000000..14cc5550 --- /dev/null +++ b/pulse/pulsecore-14.0/queue.h @@ -0,0 +1,41 @@ +#ifndef foopulsecorequeuehfoo +#define foopulsecorequeuehfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2008 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include + +typedef struct pa_queue pa_queue; + +/* A simple implementation of the abstract data type queue. Stores + * pointers as members. The memory has to be managed by the caller. */ + +pa_queue* pa_queue_new(void); + +/* Free the queue and run the specified callback function for every + * remaining entry. The callback function may be NULL. */ +void pa_queue_free(pa_queue *q, pa_free_cb_t free_func); + +void pa_queue_push(pa_queue *q, void *p); +void* pa_queue_pop(pa_queue *q); + +int pa_queue_isempty(pa_queue *q); + +#endif diff --git a/pulse/pulsecore-14.0/random.h b/pulse/pulsecore-14.0/random.h new file mode 100644 index 00000000..7c7755d9 --- /dev/null +++ b/pulse/pulsecore-14.0/random.h @@ -0,0 +1,29 @@ +#ifndef foorandomhfoo +#define foorandomhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include + +void pa_random_seed(void); +void pa_random(void *ret_data, size_t length); + +#endif diff --git a/pulse/pulsecore-14.0/ratelimit.h b/pulse/pulsecore-14.0/ratelimit.h new file mode 100644 index 00000000..d1e2f225 --- /dev/null +++ b/pulse/pulsecore-14.0/ratelimit.h @@ -0,0 +1,55 @@ +#ifndef foopulsecoreratelimithfoo +#define foopulsecoreratelimithfoo + +/*** + This file is part of PulseAudio. + + Copyright 2009 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include +#include +#include + +typedef struct pa_ratelimit { + pa_usec_t interval; + unsigned burst; + unsigned n_printed, n_missed; + pa_usec_t begin; +} pa_ratelimit; + +#define PA_DEFINE_RATELIMIT(_name, _interval, _burst) \ + pa_ratelimit _name = { \ + .interval = (_interval), \ + .burst = (_burst), \ + .n_printed = 0, \ + .n_missed = 0, \ + .begin = 0 \ + } + +#define PA_INIT_RATELIMIT(v, _interval, _burst) \ + do { \ + pa_ratelimit *r = &(v); \ + r->interval = (_interval); \ + r->burst = (_burst); \ + r->n_printed = 0; \ + r->n_missed = 0; \ + r->begin = 0; \ + } while (false); + +bool pa_ratelimit_test(pa_ratelimit *r, pa_log_level_t t); + +#endif diff --git a/pulse/pulsecore-14.0/refcnt.h b/pulse/pulsecore-14.0/refcnt.h new file mode 100644 index 00000000..2e818abe --- /dev/null +++ b/pulse/pulsecore-14.0/refcnt.h @@ -0,0 +1,79 @@ +#ifndef foopulserefcnthfoo +#define foopulserefcnthfoo + +/*** + This file is part of PulseAudio. + + Copyright 2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include +#include +#include + +/* #define DEBUG_REF */ + +#define PA_REFCNT_DECLARE \ + pa_atomic_t _ref + +#define PA_REFCNT_VALUE(p) \ + pa_atomic_load(&(p)->_ref) + +#define PA_REFCNT_INIT_ZERO(p) \ + pa_atomic_store(&(p)->_ref, 0) + +#ifndef DEBUG_REF + +#define PA_REFCNT_INIT(p) \ + pa_atomic_store(&(p)->_ref, 1) + +#define PA_REFCNT_INC(p) \ + pa_atomic_inc(&(p)->_ref) + +#define PA_REFCNT_DEC(p) \ + (pa_atomic_dec(&(p)->_ref)-1) + +#else + +/* If you need to debug ref counting problems define DEBUG_REF and + * set $PULSE_LOG_BACKTRACE=5 or suchlike in the shell when running + * PA */ + +#define PA_REFCNT_INIT(p) \ + do { \ + pa_atomic_store(&(p)->_ref, 1); \ + pa_log("REF: Init %p", p); \ + } while (false) + +#define PA_REFCNT_INC(p) \ + do { \ + pa_atomic_inc(&(p)->_ref); \ + pa_log("REF: Inc %p", p); \ + } while (false) \ + +#define PA_REFCNT_DEC(p) \ + ({ \ + int _j = (pa_atomic_dec(&(p)->_ref)-1); \ + if (_j <= 0) \ + pa_log("REF: Done %p", p); \ + else \ + pa_log("REF: Dec %p", p); \ + _j; \ + }) + +#endif + +#endif diff --git a/pulse/pulsecore-14.0/remap.h b/pulse/pulsecore-14.0/remap.h new file mode 100644 index 00000000..473f0cea --- /dev/null +++ b/pulse/pulsecore-14.0/remap.h @@ -0,0 +1,60 @@ +#ifndef fooremapfoo +#define fooremapfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2009 Wim Taymans + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +typedef struct pa_remap pa_remap_t; + +typedef void (*pa_do_remap_func_t) (pa_remap_t *m, void *d, const void *s, unsigned n); + +struct pa_remap { + pa_sample_format_t format; + pa_sample_spec i_ss, o_ss; + float map_table_f[PA_CHANNELS_MAX][PA_CHANNELS_MAX]; + int32_t map_table_i[PA_CHANNELS_MAX][PA_CHANNELS_MAX]; + pa_do_remap_func_t do_remap; + void *state; /* optional state information for the remap function */ +}; + +void pa_init_remap_func(pa_remap_t *m); + +/* custom installation of init functions */ +typedef void (*pa_init_remap_func_t) (pa_remap_t *m); + +pa_init_remap_func_t pa_get_init_remap_func(void); +void pa_set_init_remap_func(pa_init_remap_func_t func); + +/* Check if remapping can be performed by just copying some or all input + * channels' data to output channels. Returns true and a table of input + * channel indices, or false otherwise. + * + * The table contains an entry for each output channels. Each table entry given + * either the input channel index to be copied, or -1 indicating that the + * output channel is not used and hence zero. + */ +bool pa_setup_remap_arrange(const pa_remap_t *m, int8_t arrange[PA_CHANNELS_MAX]); + +void pa_set_remap_func(pa_remap_t *m, pa_do_remap_func_t func_s16, + pa_do_remap_func_t func_s32, pa_do_remap_func_t func_float); + +#endif /* fooremapfoo */ diff --git a/pulse/pulsecore-14.0/resampler.h b/pulse/pulsecore-14.0/resampler.h new file mode 100644 index 00000000..5a264b34 --- /dev/null +++ b/pulse/pulsecore-14.0/resampler.h @@ -0,0 +1,181 @@ +#ifndef fooresamplerhfoo +#define fooresamplerhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include +#include +#include +#include +#include +#include + +typedef struct pa_resampler pa_resampler; +typedef struct pa_resampler_impl pa_resampler_impl; + +struct pa_resampler_impl { + void (*free)(pa_resampler *r); + void (*update_rates)(pa_resampler *r); + + /* Returns the number of leftover frames in the input buffer. */ + unsigned (*resample)(pa_resampler *r, const pa_memchunk *in, unsigned in_n_frames, pa_memchunk *out, unsigned *out_n_frames); + + void (*reset)(pa_resampler *r); + void *data; +}; + +typedef enum pa_resample_method { + PA_RESAMPLER_INVALID = -1, + PA_RESAMPLER_SRC_SINC_BEST_QUALITY = 0, /* = SRC_SINC_BEST_QUALITY */ + PA_RESAMPLER_SRC_SINC_MEDIUM_QUALITY = 1, /* = SRC_SINC_MEDIUM_QUALITY */ + PA_RESAMPLER_SRC_SINC_FASTEST = 2, /* = SRC_SINC_FASTEST */ + PA_RESAMPLER_SRC_ZERO_ORDER_HOLD = 3, /* = SRC_ZERO_ORDER_HOLD */ + PA_RESAMPLER_SRC_LINEAR = 4, /* = SRC_LINEAR */ + PA_RESAMPLER_TRIVIAL, + PA_RESAMPLER_SPEEX_FLOAT_BASE, + PA_RESAMPLER_SPEEX_FLOAT_MAX = PA_RESAMPLER_SPEEX_FLOAT_BASE + 10, + PA_RESAMPLER_SPEEX_FIXED_BASE, + PA_RESAMPLER_SPEEX_FIXED_MAX = PA_RESAMPLER_SPEEX_FIXED_BASE + 10, + PA_RESAMPLER_FFMPEG, + PA_RESAMPLER_AUTO, /* automatic select based on sample format */ + PA_RESAMPLER_COPY, + PA_RESAMPLER_PEAKS, + PA_RESAMPLER_SOXR_MQ, + PA_RESAMPLER_SOXR_HQ, + PA_RESAMPLER_SOXR_VHQ, + PA_RESAMPLER_MAX +} pa_resample_method_t; + +typedef enum pa_resample_flags { + PA_RESAMPLER_VARIABLE_RATE = 0x0001U, + PA_RESAMPLER_NO_REMAP = 0x0002U, /* implies NO_REMIX */ + PA_RESAMPLER_NO_REMIX = 0x0004U, + PA_RESAMPLER_NO_FILL_SINK = 0x0010U, + PA_RESAMPLER_PRODUCE_LFE = 0x0020U, + PA_RESAMPLER_CONSUME_LFE = 0x0040U, +} pa_resample_flags_t; + +struct pa_resampler { + pa_resample_method_t method; + pa_resample_flags_t flags; + + pa_sample_spec i_ss, o_ss; + pa_channel_map i_cm, o_cm; + size_t i_fz, o_fz, w_fz, w_sz; + pa_mempool *mempool; + + pa_memchunk to_work_format_buf; + pa_memchunk remap_buf; + pa_memchunk resample_buf; + pa_memchunk from_work_format_buf; + size_t to_work_format_buf_size; + size_t remap_buf_size; + size_t resample_buf_size; + size_t from_work_format_buf_size; + + /* points to buffer before resampling stage, remap or to_work */ + pa_memchunk *leftover_buf; + size_t *leftover_buf_size; + + /* have_leftover points to leftover_in_remap or leftover_in_to_work */ + bool *have_leftover; + bool leftover_in_remap; + bool leftover_in_to_work; + + pa_sample_format_t work_format; + uint8_t work_channels; + + pa_convert_func_t to_work_format_func; + pa_convert_func_t from_work_format_func; + + pa_remap_t remap; + bool map_required; + + pa_lfe_filter_t *lfe_filter; + + pa_resampler_impl impl; +}; + +pa_resampler* pa_resampler_new( + pa_mempool *pool, + const pa_sample_spec *a, + const pa_channel_map *am, + const pa_sample_spec *b, + const pa_channel_map *bm, + unsigned crossover_freq, + pa_resample_method_t resample_method, + pa_resample_flags_t flags); + +void pa_resampler_free(pa_resampler *r); + +/* Returns the size of an input memory block which is required to return the specified amount of output data */ +size_t pa_resampler_request(pa_resampler *r, size_t out_length); + +/* Inverse of pa_resampler_request() */ +size_t pa_resampler_result(pa_resampler *r, size_t in_length); + +/* Returns the maximum size of input blocks we can process without needing bounce buffers larger than the mempool tile size. */ +size_t pa_resampler_max_block_size(pa_resampler *r); + +/* Pass the specified memory chunk to the resampler and return the newly resampled data */ +void pa_resampler_run(pa_resampler *r, const pa_memchunk *in, pa_memchunk *out); + +/* Change the input rate of the resampler object */ +void pa_resampler_set_input_rate(pa_resampler *r, uint32_t rate); + +/* Change the output rate of the resampler object */ +void pa_resampler_set_output_rate(pa_resampler *r, uint32_t rate); + +/* Reinitialize state of the resampler, possibly due to seeking or other discontinuities */ +void pa_resampler_reset(pa_resampler *r); + +/* Rewind resampler */ +void pa_resampler_rewind(pa_resampler *r, size_t out_frames); + +/* Return the resampling method of the resampler object */ +pa_resample_method_t pa_resampler_get_method(pa_resampler *r); + +/* Try to parse the resampler method */ +pa_resample_method_t pa_parse_resample_method(const char *string); + +/* return a human readable string for the specified resampling method. Inverse of pa_parse_resample_method() */ +const char *pa_resample_method_to_string(pa_resample_method_t m); + +/* Return 1 when the specified resampling method is supported */ +int pa_resample_method_supported(pa_resample_method_t m); + +const pa_channel_map* pa_resampler_input_channel_map(pa_resampler *r); +const pa_sample_spec* pa_resampler_input_sample_spec(pa_resampler *r); +const pa_channel_map* pa_resampler_output_channel_map(pa_resampler *r); +const pa_sample_spec* pa_resampler_output_sample_spec(pa_resampler *r); + +/* Implementation specific init functions */ +int pa_resampler_ffmpeg_init(pa_resampler *r); +int pa_resampler_libsamplerate_init(pa_resampler *r); +int pa_resampler_peaks_init(pa_resampler *r); +int pa_resampler_speex_init(pa_resampler *r); +int pa_resampler_trivial_init(pa_resampler*r); +int pa_resampler_soxr_init(pa_resampler *r); + +/* Resampler-specific quirks */ +bool pa_speex_is_fixed_point(void); + +#endif diff --git a/pulse/pulsecore-14.0/rtkit.h b/pulse/pulsecore-14.0/rtkit.h new file mode 100644 index 00000000..30cde72b --- /dev/null +++ b/pulse/pulsecore-14.0/rtkit.h @@ -0,0 +1,79 @@ +/*-*- Mode: C; c-basic-offset: 8 -*-*/ + +#ifndef foortkithfoo +#define foortkithfoo + +/*** + Copyright 2009 Lennart Poettering + Copyright 2010 David Henningsson + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation files + (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Software, + and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +***/ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* This is the reference implementation for a client for + * RealtimeKit. You don't have to use this, but if do, just copy these + * sources into your repository */ + +#define RTKIT_SERVICE_NAME "org.freedesktop.RealtimeKit1" +#define RTKIT_OBJECT_PATH "/org/freedesktop/RealtimeKit1" + +/* This is mostly equivalent to sched_setparam(thread, SCHED_RR, { + * .sched_priority = priority }). 'thread' needs to be a kernel thread + * id as returned by gettid(), not a pthread_t! If 'thread' is 0 the + * current thread is used. The returned value is a negative errno + * style error code, or 0 on success. */ +int rtkit_make_realtime(DBusConnection *system_bus, pid_t thread, int priority); + +/* This is mostly equivalent to setpriority(PRIO_PROCESS, thread, + * nice_level). 'thread' needs to be a kernel thread id as returned by + * gettid(), not a pthread_t! If 'thread' is 0 the current thread is + * used. The returned value is a negative errno style error code, or 0 + * on success.*/ +int rtkit_make_high_priority(DBusConnection *system_bus, pid_t thread, int nice_level); + +/* Return the maximum value of realtime priority available. Realtime requests + * above this value will fail. A negative value is an errno style error code. + */ +int rtkit_get_max_realtime_priority(DBusConnection *system_bus); + +/* Retrieve the minimum value of nice level available. High prio requests + * below this value will fail. The returned value is a negative errno + * style error code, or 0 on success.*/ +int rtkit_get_min_nice_level(DBusConnection *system_bus, int* min_nice_level); + +/* Return the maximum value of RLIMIT_RTTIME to set before attempting a + * realtime request. A negative value is an errno style error code. + */ +long long rtkit_get_rttime_usec_max(DBusConnection *system_bus); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/pulse/pulsecore-14.0/rtpoll.h b/pulse/pulsecore-14.0/rtpoll.h new file mode 100644 index 00000000..121b51e3 --- /dev/null +++ b/pulse/pulsecore-14.0/rtpoll.h @@ -0,0 +1,100 @@ +#ifndef foopulsertpollhfoo +#define foopulsertpollhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include +#include + +#include +#include +#include +#include + +/* An implementation of a "real-time" poll loop. Basically, this is + * yet another wrapper around poll(). However it has certain + * advantages over pa_mainloop and suchlike: + * + * 1) High resolution timers are used + * + * 2) It allows raw access to the pollfd data to users + * + * 3) It allows arbitrary functions to be run before entering the + * actual poll() and after it. + * + * Only a single interval timer is supported. */ + +typedef struct pa_rtpoll pa_rtpoll; +typedef struct pa_rtpoll_item pa_rtpoll_item; + +typedef enum pa_rtpoll_priority { + PA_RTPOLL_EARLY = -100, /* For very important stuff, like handling control messages */ + PA_RTPOLL_NORMAL = 0, /* For normal stuff */ + PA_RTPOLL_LATE = +100, /* For housekeeping */ + PA_RTPOLL_NEVER = INT_MAX, /* For stuff that doesn't register any callbacks, but only fds to listen on */ +} pa_rtpoll_priority_t; + +pa_rtpoll *pa_rtpoll_new(void); +void pa_rtpoll_free(pa_rtpoll *p); + +/* Sleep on the rtpoll until the time event, or any of the fd events + * is triggered. Returns negative on error, positive if the loop + * should continue to run, 0 when the loop should be terminated + * cleanly. */ +int pa_rtpoll_run(pa_rtpoll *f); + +void pa_rtpoll_set_timer_absolute(pa_rtpoll *p, pa_usec_t usec); +void pa_rtpoll_set_timer_relative(pa_rtpoll *p, pa_usec_t usec); +void pa_rtpoll_set_timer_disabled(pa_rtpoll *p); + +/* Return true when the elapsed timer was the reason for + * the last pa_rtpoll_run() invocation to finish */ +bool pa_rtpoll_timer_elapsed(pa_rtpoll *p); + +/* A new fd wakeup item for pa_rtpoll */ +pa_rtpoll_item *pa_rtpoll_item_new(pa_rtpoll *p, pa_rtpoll_priority_t prio, unsigned n_fds); +void pa_rtpoll_item_free(pa_rtpoll_item *i); + +/* Please note that this pointer might change on every call and when + * pa_rtpoll_run() is called. Hence: call this immediately before + * using the pointer and don't save the result anywhere */ +struct pollfd *pa_rtpoll_item_get_pollfd(pa_rtpoll_item *i, unsigned *n_fds); + +/* Set the callback that shall be called when there's time to do some work: If the + * callback returns a value > 0, the poll is skipped and the next + * iteration of the loop will start immediately. */ +void pa_rtpoll_item_set_work_callback(pa_rtpoll_item *i, int (*work_cb)(pa_rtpoll_item *i), void *userdata); + +/* Set the callback that shall be called immediately before entering + * the sleeping poll: If the callback returns a value > 0, the poll is + * skipped and the next iteration of the loop will start immediately. */ +void pa_rtpoll_item_set_before_callback(pa_rtpoll_item *i, int (*before_cb)(pa_rtpoll_item *i), void *userdata); + +/* Set the callback that shall be called immediately after having + * entered the sleeping poll */ +void pa_rtpoll_item_set_after_callback(pa_rtpoll_item *i, void (*after_cb)(pa_rtpoll_item *i), void *userdata); + +void* pa_rtpoll_item_get_work_userdata(pa_rtpoll_item *i); + +pa_rtpoll_item *pa_rtpoll_item_new_fdsem(pa_rtpoll *p, pa_rtpoll_priority_t prio, pa_fdsem *s); +pa_rtpoll_item *pa_rtpoll_item_new_asyncmsgq_read(pa_rtpoll *p, pa_rtpoll_priority_t prio, pa_asyncmsgq *q); +pa_rtpoll_item *pa_rtpoll_item_new_asyncmsgq_write(pa_rtpoll *p, pa_rtpoll_priority_t prio, pa_asyncmsgq *q); + +#endif diff --git a/pulse/pulsecore-14.0/sample-util.h b/pulse/pulsecore-14.0/sample-util.h new file mode 100644 index 00000000..0732e8dc --- /dev/null +++ b/pulse/pulsecore-14.0/sample-util.h @@ -0,0 +1,154 @@ +#ifndef foosampleutilhfoo +#define foosampleutilhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include + +#include +#include +#include +#include + +#include +#include + +typedef struct pa_silence_cache { + pa_memblock* blocks[PA_SAMPLE_MAX]; +} pa_silence_cache; + +void pa_silence_cache_init(pa_silence_cache *cache); +void pa_silence_cache_done(pa_silence_cache *cache); + +void *pa_silence_memory(void *p, size_t length, const pa_sample_spec *spec); +pa_memchunk* pa_silence_memchunk(pa_memchunk *c, const pa_sample_spec *spec); +pa_memblock* pa_silence_memblock(pa_memblock *b, const pa_sample_spec *spec); + +pa_memchunk* pa_silence_memchunk_get(pa_silence_cache *cache, pa_mempool *pool, pa_memchunk* ret, const pa_sample_spec *spec, size_t length); + +size_t pa_frame_align(size_t l, const pa_sample_spec *ss) PA_GCC_PURE; + +bool pa_frame_aligned(size_t l, const pa_sample_spec *ss) PA_GCC_PURE; + +void pa_interleave(const void *src[], unsigned channels, void *dst, size_t ss, unsigned n); +void pa_deinterleave(const void *src, void *dst[], unsigned channels, size_t ss, unsigned n); + +void pa_sample_clamp(pa_sample_format_t format, void *dst, size_t dstr, const void *src, size_t sstr, unsigned n); + +static inline int32_t pa_mult_s16_volume(int16_t v, int32_t cv) { +#ifdef HAVE_FAST_64BIT_OPERATIONS + /* Multiply with 64 bit integers on 64 bit platforms */ + return (v * (int64_t) cv) >> 16; +#else + /* Multiplying the 32 bit volume factor with the + * 16 bit sample might result in an 48 bit value. We + * want to do without 64 bit integers and hence do + * the multiplication independently for the HI and + * LO part of the volume. */ + + int32_t hi = cv >> 16; + int32_t lo = cv & 0xFFFF; + return ((v * lo) >> 16) + (v * hi); +#endif +} + +pa_usec_t pa_bytes_to_usec_round_up(uint64_t length, const pa_sample_spec *spec); +size_t pa_usec_to_bytes_round_up(pa_usec_t t, const pa_sample_spec *spec); + +void pa_memchunk_dump_to_file(pa_memchunk *c, const char *fn); + +void pa_memchunk_sine(pa_memchunk *c, pa_mempool *pool, unsigned rate, unsigned freq); + +typedef void (*pa_do_volume_func_t) (void *samples, const void *volumes, unsigned channels, unsigned length); + +pa_do_volume_func_t pa_get_volume_func(pa_sample_format_t f); +void pa_set_volume_func(pa_sample_format_t f, pa_do_volume_func_t func); + +size_t pa_convert_size(size_t size, const pa_sample_spec *from, const pa_sample_spec *to); + +#define PA_CHANNEL_POSITION_MASK_LEFT \ + (PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_FRONT_LEFT) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_REAR_LEFT) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_SIDE_LEFT) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_FRONT_LEFT) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_REAR_LEFT)) \ + +#define PA_CHANNEL_POSITION_MASK_RIGHT \ + (PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_FRONT_RIGHT) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_REAR_RIGHT) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_SIDE_RIGHT) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_FRONT_RIGHT) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_REAR_RIGHT)) + +#define PA_CHANNEL_POSITION_MASK_CENTER \ + (PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_FRONT_CENTER) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_REAR_CENTER) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_CENTER) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_FRONT_CENTER) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_REAR_CENTER)) + +#define PA_CHANNEL_POSITION_MASK_FRONT \ + (PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_FRONT_LEFT) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_FRONT_RIGHT) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_FRONT_CENTER) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_FRONT_LEFT) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_FRONT_RIGHT) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_FRONT_CENTER)) + +#define PA_CHANNEL_POSITION_MASK_REAR \ + (PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_REAR_LEFT) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_REAR_RIGHT) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_REAR_CENTER) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_REAR_LEFT) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_REAR_RIGHT) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_REAR_CENTER)) + +#define PA_CHANNEL_POSITION_MASK_LFE \ + PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_LFE) + +#define PA_CHANNEL_POSITION_MASK_HFE \ + (PA_CHANNEL_POSITION_MASK_REAR | PA_CHANNEL_POSITION_MASK_FRONT \ + | PA_CHANNEL_POSITION_MASK_LEFT | PA_CHANNEL_POSITION_MASK_RIGHT \ + | PA_CHANNEL_POSITION_MASK_CENTER) + +#define PA_CHANNEL_POSITION_MASK_SIDE_OR_TOP_CENTER \ + (PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_SIDE_LEFT) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_SIDE_RIGHT) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_CENTER)) + +#define PA_CHANNEL_POSITION_MASK_TOP \ + (PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_CENTER) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_FRONT_LEFT) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_FRONT_RIGHT) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_FRONT_CENTER) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_REAR_LEFT) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_REAR_RIGHT) \ + | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_TOP_REAR_CENTER)) + +#define PA_CHANNEL_POSITION_MASK_ALL \ + ((pa_channel_position_mask_t) (PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_MAX)-1)) + +#endif diff --git a/pulse/pulsecore-14.0/sconv-s16be.h b/pulse/pulsecore-14.0/sconv-s16be.h new file mode 100644 index 00000000..83b05fd8 --- /dev/null +++ b/pulse/pulsecore-14.0/sconv-s16be.h @@ -0,0 +1,67 @@ +#ifndef foosconv_s16befoo +#define foosconv_s16befoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +void pa_sconv_s16be_to_float32ne(unsigned n, const int16_t *a, float *b); +void pa_sconv_s16be_from_float32ne(unsigned n, const float *a, int16_t *b); +void pa_sconv_s16be_to_float32re(unsigned n, const int16_t *a, float *b); +void pa_sconv_s16be_from_float32re(unsigned n, const float *a, int16_t *b); + +void pa_sconv_s32be_to_float32ne(unsigned n, const int32_t *a, float *b); +void pa_sconv_s32be_from_float32ne(unsigned n, const float *a, int32_t *b); +void pa_sconv_s32be_to_float32re(unsigned n, const int32_t *a, float *b); +void pa_sconv_s32be_from_float32re(unsigned n, const float *a, int32_t *b); + +void pa_sconv_s24be_to_float32ne(unsigned n, const uint8_t *a, float *b); +void pa_sconv_s24be_from_float32ne(unsigned n, const float *a, uint8_t *b); +void pa_sconv_s24be_to_float32re(unsigned n, const uint8_t *a, float *b); +void pa_sconv_s24be_from_float32re(unsigned n, const float *a, uint8_t *b); + +void pa_sconv_s24_32be_to_float32ne(unsigned n, const uint32_t *a, float *b); +void pa_sconv_s24_32be_from_float32ne(unsigned n, const float *a, uint32_t *b); +void pa_sconv_s24_32be_to_float32re(unsigned n, const uint8_t *a, float *b); +void pa_sconv_s24_32be_from_float32re(unsigned n, const float *a, uint8_t *b); + +void pa_sconv_s32be_to_s16ne(unsigned n, const int32_t *a, int16_t *b); +void pa_sconv_s32be_from_s16ne(unsigned n, const int16_t *a, int32_t *b); +void pa_sconv_s32be_to_s16re(unsigned n, const int32_t *a, int16_t *b); +void pa_sconv_s32be_from_s16re(unsigned n, const int16_t *a, int32_t *b); + +void pa_sconv_s24be_to_s16ne(unsigned n, const uint8_t *a, int16_t *b); +void pa_sconv_s24be_from_s16ne(unsigned n, const int16_t *a, uint8_t *b); +void pa_sconv_s24be_to_s16re(unsigned n, const uint8_t *a, int16_t *b); +void pa_sconv_s24be_from_s16re(unsigned n, const int16_t *a, uint8_t *b); + +void pa_sconv_s24_32be_to_s16ne(unsigned n, const uint32_t *a, int16_t *b); +void pa_sconv_s24_32be_from_s16ne(unsigned n, const int16_t *a, uint32_t *b); +void pa_sconv_s24_32be_to_s16re(unsigned n, const uint8_t *a, int16_t *b); +void pa_sconv_s24_32be_from_s16re(unsigned n, const int16_t *a, uint8_t *b); + +#ifdef WORDS_BIGENDIAN +#define pa_sconv_float32be_to_s16ne pa_sconv_s16be_from_float32ne +#define pa_sconv_float32be_from_s16ne pa_sconv_s16be_to_float32ne +#define pa_sconv_float32le_to_s16ne pa_sconv_s16be_from_float32re +#define pa_sconv_float32le_from_s16ne pa_sconv_s16be_to_float32re +#endif + +#endif diff --git a/pulse/pulsecore-14.0/sconv-s16le.h b/pulse/pulsecore-14.0/sconv-s16le.h new file mode 100644 index 00000000..53013735 --- /dev/null +++ b/pulse/pulsecore-14.0/sconv-s16le.h @@ -0,0 +1,67 @@ +#ifndef foosconv_s16lefoo +#define foosconv_s16lefoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +void pa_sconv_s16le_to_float32ne(unsigned n, const int16_t *a, float *b); +void pa_sconv_s16le_from_float32ne(unsigned n, const float *a, int16_t *b); +void pa_sconv_s16le_to_float32re(unsigned n, const int16_t *a, float *b); +void pa_sconv_s16le_from_float32re(unsigned n, const float *a, int16_t *b); + +void pa_sconv_s32le_to_float32ne(unsigned n, const int32_t *a, float *b); +void pa_sconv_s32le_from_float32ne(unsigned n, const float *a, int32_t *b); +void pa_sconv_s32le_to_float32re(unsigned n, const int32_t *a, float *b); +void pa_sconv_s32le_from_float32re(unsigned n, const float *a, int32_t *b); + +void pa_sconv_s24le_to_float32ne(unsigned n, const uint8_t *a, float *b); +void pa_sconv_s24le_from_float32ne(unsigned n, const float *a, uint8_t *b); +void pa_sconv_s24le_to_float32re(unsigned n, const uint8_t *a, float *b); +void pa_sconv_s24le_from_float32re(unsigned n, const float *a, uint8_t *b); + +void pa_sconv_s24_32le_to_float32ne(unsigned n, const uint32_t *a, float *b); +void pa_sconv_s24_32le_from_float32ne(unsigned n, const float *a, uint32_t *b); +void pa_sconv_s24_32le_to_float32re(unsigned n, const uint32_t *a, float *b); +void pa_sconv_s24_32le_from_float32re(unsigned n, const float *a, uint32_t *b); + +void pa_sconv_s32le_to_s16ne(unsigned n, const int32_t *a, int16_t *b); +void pa_sconv_s32le_from_s16ne(unsigned n, const int16_t *a, int32_t *b); +void pa_sconv_s32le_to_s16re(unsigned n, const int32_t *a, int16_t *b); +void pa_sconv_s32le_from_s16re(unsigned n, const int16_t *a, int32_t *b); + +void pa_sconv_s24le_to_s16ne(unsigned n, const uint8_t *a, int16_t *b); +void pa_sconv_s24le_from_s16ne(unsigned n, const int16_t *a, uint8_t *b); +void pa_sconv_s24le_to_s16re(unsigned n, const uint8_t *a, int16_t *b); +void pa_sconv_s24le_from_s16re(unsigned n, const int16_t *a, uint8_t *b); + +void pa_sconv_s24_32le_to_s16ne(unsigned n, const uint32_t *a, int16_t *b); +void pa_sconv_s24_32le_from_s16ne(unsigned n, const int16_t *a, uint32_t *b); +void pa_sconv_s24_32le_to_s16re(unsigned n, const uint32_t *a, int16_t *b); +void pa_sconv_s24_32le_from_s16re(unsigned n, const int16_t *a, uint32_t *b); + +#ifndef WORDS_BIGENDIAN +#define pa_sconv_float32be_to_s16ne pa_sconv_s16le_from_float32re +#define pa_sconv_float32be_from_s16ne pa_sconv_s16le_to_float32re +#define pa_sconv_float32le_to_s16ne pa_sconv_s16le_from_float32ne +#define pa_sconv_float32le_from_s16ne pa_sconv_s16le_to_float32ne +#endif + +#endif diff --git a/pulse/pulsecore-14.0/sconv.h b/pulse/pulsecore-14.0/sconv.h new file mode 100644 index 00000000..c457429d --- /dev/null +++ b/pulse/pulsecore-14.0/sconv.h @@ -0,0 +1,41 @@ +#ifndef foosconvhfoo +#define foosconvhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include + +typedef void (*pa_convert_func_t)(unsigned n, const void *a, void *b); + +pa_convert_func_t pa_get_convert_to_float32ne_function(pa_sample_format_t f) PA_GCC_PURE; +pa_convert_func_t pa_get_convert_from_float32ne_function(pa_sample_format_t f) PA_GCC_PURE; + +pa_convert_func_t pa_get_convert_to_s16ne_function(pa_sample_format_t f) PA_GCC_PURE; +pa_convert_func_t pa_get_convert_from_s16ne_function(pa_sample_format_t f) PA_GCC_PURE; + +void pa_set_convert_to_float32ne_function(pa_sample_format_t f, pa_convert_func_t func); +void pa_set_convert_from_float32ne_function(pa_sample_format_t f, pa_convert_func_t func); + +void pa_set_convert_to_s16ne_function(pa_sample_format_t f, pa_convert_func_t func); +void pa_set_convert_from_s16ne_function(pa_sample_format_t f, pa_convert_func_t func); + +#endif diff --git a/pulse/pulsecore-14.0/semaphore.h b/pulse/pulsecore-14.0/semaphore.h new file mode 100644 index 00000000..4c746f13 --- /dev/null +++ b/pulse/pulsecore-14.0/semaphore.h @@ -0,0 +1,46 @@ +#ifndef foopulsesemaphorehfoo +#define foopulsesemaphorehfoo + +/*** + This file is part of PulseAudio. + + Copyright 2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include +#include + +typedef struct pa_semaphore pa_semaphore; + +pa_semaphore* pa_semaphore_new(unsigned value); +void pa_semaphore_free(pa_semaphore *m); + +void pa_semaphore_post(pa_semaphore *m); +void pa_semaphore_wait(pa_semaphore *m); + +/* Static semaphores are basically just atomically updated pointers to + * pa_semaphore objects */ + +typedef struct pa_static_semaphore { + pa_atomic_ptr_t ptr; +} pa_static_semaphore; + +#define PA_STATIC_SEMAPHORE_INIT { PA_ATOMIC_PTR_INIT(NULL) } + +/* When you call this make sure to pass always the same value parameter! */ +pa_semaphore* pa_static_semaphore_get(pa_static_semaphore *m, unsigned value); + +#endif diff --git a/pulse/pulsecore-14.0/shared.h b/pulse/pulsecore-14.0/shared.h new file mode 100644 index 00000000..19ac462c --- /dev/null +++ b/pulse/pulsecore-14.0/shared.h @@ -0,0 +1,55 @@ +#ifndef foosharedshfoo +#define foosharedshfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include + +/* The shared property subsystem is to be used to share data between + * modules. Consider them to be kind of "global" variables for a + * core. Why not use the hashmap functions directly? The hashmap + * functions copy neither the key nor value, while this property + * system copies the key. Users of this system have to think about + * reference counting themselves. */ + +/* Note: please don't confuse this with the proplist framework in + * pulse/proplist.[ch]! */ + +/* Return a pointer to the value of the specified shared property. */ +void* pa_shared_get(pa_core *c, const char *name); + +/* Set the shared property 'name' to 'data'. This function fails in + * case a property by this name already exists. The property data is + * not copied or reference counted. This is the caller's job. */ +int pa_shared_set(pa_core *c, const char *name, void *data); + +/* Remove the specified shared property. Return non-zero on failure */ +int pa_shared_remove(pa_core *c, const char *name); + +/* A combination of pa_shared_remove() and pa_shared_set(); this function + * first tries to remove the property by this name and then sets the + * property. Return non-zero on failure. */ +int pa_shared_replace(pa_core *c, const char *name, void *data); + +/* Dump the current set of shared properties */ +void pa_shared_dump(pa_core *c, pa_strbuf *s); + +#endif diff --git a/pulse/pulsecore-14.0/shm.h b/pulse/pulsecore-14.0/shm.h new file mode 100644 index 00000000..67a2114a --- /dev/null +++ b/pulse/pulsecore-14.0/shm.h @@ -0,0 +1,61 @@ +#ifndef foopulseshmhfoo +#define foopulseshmhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include + +#include +#include + +typedef struct pa_shm { + pa_mem_type_t type; + unsigned id; + void *ptr; + size_t size; + + /* Only for type = PA_MEM_TYPE_SHARED_POSIX */ + bool do_unlink:1; + + /* Only for type = PA_MEM_TYPE_SHARED_MEMFD + * + * To avoid fd leaks, we keep this fd open only until we pass it + * to the other PA endpoint over unix domain socket. + * + * When we don't have ownership for the memfd fd in question (e.g. + * pa_shm_attach()), or the file descriptor has now been closed, + * this is set to -1. + * + * For the special case of a global mempool, we keep this fd + * always open. Check comments on top of pa_mempool_new() for + * rationale. */ + int fd; +} pa_shm; + +int pa_shm_create_rw(pa_shm *m, pa_mem_type_t type, size_t size, mode_t mode); +int pa_shm_attach(pa_shm *m, pa_mem_type_t type, unsigned id, int memfd_fd, bool writable); + +void pa_shm_punch(pa_shm *m, size_t offset, size_t size); + +void pa_shm_free(pa_shm *m); + +int pa_shm_cleanup(void); + +#endif diff --git a/pulse/pulsecore-14.0/sink-input.h b/pulse/pulsecore-14.0/sink-input.h new file mode 100644 index 00000000..d3de6e3f --- /dev/null +++ b/pulse/pulsecore-14.0/sink-input.h @@ -0,0 +1,469 @@ +#ifndef foopulsesinkinputhfoo +#define foopulsesinkinputhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef enum pa_sink_input_state { + PA_SINK_INPUT_INIT, /*< The stream is not active yet, because pa_sink_input_put() has not been called yet */ + PA_SINK_INPUT_RUNNING, /*< The stream is alive and kicking */ + PA_SINK_INPUT_CORKED, /*< The stream was corked on user request */ + PA_SINK_INPUT_UNLINKED /*< The stream is dead */ + /* FIXME: we need a state for MOVING here */ +} pa_sink_input_state_t; + +static inline bool PA_SINK_INPUT_IS_LINKED(pa_sink_input_state_t x) { + return x == PA_SINK_INPUT_RUNNING || x == PA_SINK_INPUT_CORKED; +} + +typedef enum pa_sink_input_flags { + PA_SINK_INPUT_VARIABLE_RATE = 1, + PA_SINK_INPUT_DONT_MOVE = 2, + PA_SINK_INPUT_START_CORKED = 4, + PA_SINK_INPUT_NO_REMAP = 8, + PA_SINK_INPUT_NO_REMIX = 16, + PA_SINK_INPUT_FIX_FORMAT = 32, + PA_SINK_INPUT_FIX_RATE = 64, + PA_SINK_INPUT_FIX_CHANNELS = 128, + PA_SINK_INPUT_DONT_INHIBIT_AUTO_SUSPEND = 256, + PA_SINK_INPUT_NO_CREATE_ON_SUSPEND = 512, + PA_SINK_INPUT_KILL_ON_SUSPEND = 1024, + PA_SINK_INPUT_PASSTHROUGH = 2048 +} pa_sink_input_flags_t; + +struct pa_sink_input { + pa_msgobject parent; + + uint32_t index; + pa_core *core; + + pa_sink_input_state_t state; + pa_sink_input_flags_t flags; + + char *driver; /* may be NULL */ + pa_proplist *proplist; + + pa_module *module; /* may be NULL */ + pa_client *client; /* may be NULL */ + + pa_sink *sink; /* NULL while we are being moved */ + + /* This is set to true when creating the sink input if the sink was + * requested by the application that created the sink input. This is + * sometimes useful for determining whether the sink input should be + * moved by some automatic policy. If the sink input is moved away from the + * sink that the application requested, this flag is reset to false. */ + bool sink_requested_by_application; + + pa_sink *origin_sink; /* only set by filter sinks */ + + /* A sink input may be connected to multiple source outputs + * directly, so that they don't get mixed data of the entire + * source. */ + pa_idxset *direct_outputs; + + pa_sample_spec sample_spec; + pa_channel_map channel_map; + pa_format_info *format; + + pa_sink_input *sync_prev, *sync_next; + + /* Also see http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/Developer/Volumes/ */ + pa_cvolume volume; /* The volume clients are informed about */ + pa_cvolume reference_ratio; /* The ratio of the stream's volume to the sink's reference volume */ + pa_cvolume real_ratio; /* The ratio of the stream's volume to the sink's real volume */ + /* volume_factor is an internally used "additional volume" that can be used + * by modules without having the volume visible to clients. volume_factor + * calculated by merging all the individual items in volume_factor_items. + * Modules must not modify these variables directly, instead + * pa_sink_input_add/remove_volume_factor() have to be used to add and + * remove items, or pa_sink_input_new_data_add_volume_factor() during input + * creation time. */ + pa_cvolume volume_factor; + pa_hashmap *volume_factor_items; + pa_cvolume soft_volume; /* The internal software volume we apply to all PCM data while it passes through. Usually calculated as real_ratio * volume_factor */ + + pa_cvolume volume_factor_sink; /* A second volume factor in format of the sink this stream is connected to. */ + pa_hashmap *volume_factor_sink_items; + + bool volume_writable:1; + + bool muted:1; + + /* if true then the volume and the mute state of this sink-input + * are worth remembering, module-stream-restore looks for + * this.*/ + bool save_volume:1, save_muted:1; + + /* if users move the sink-input to a sink, and the sink is not default_sink, + * the sink->name will be saved in preferred_sink. And later if sink-input + * is moved to other sinks for some reason, it still can be restored to the + * preferred_sink at an appropriate time */ + char *preferred_sink; + + pa_resample_method_t requested_resample_method, actual_resample_method; + + /* Returns the chunk of audio data and drops it from the + * queue. Returns -1 on failure. Called from IO thread context. If + * data needs to be generated from scratch then please in the + * specified length request_nbytes. This is an optimization + * only. If less data is available, it's fine to return a smaller + * block. If more data is already ready, it is better to return + * the full block. */ + int (*pop) (pa_sink_input *i, size_t request_nbytes, pa_memchunk *chunk); /* may NOT be NULL */ + + /* This is called when the playback buffer has actually played back + all available data. Return true unless there is more data to play back. + Called from IO context. */ + bool (*process_underrun) (pa_sink_input *i); + + /* Rewind the queue by the specified number of bytes. Called just + * before peek() if it is called at all. Only called if the sink + * input driver ever plans to call + * pa_sink_input_request_rewind(). Called from IO context. */ + void (*process_rewind) (pa_sink_input *i, size_t nbytes); /* may NOT be NULL */ + + /* Called whenever the maximum rewindable size of the sink + * changes. Called from IO context. */ + void (*update_max_rewind) (pa_sink_input *i, size_t nbytes); /* may be NULL */ + + /* Called whenever the maximum request size of the sink + * changes. Called from IO context. */ + void (*update_max_request) (pa_sink_input *i, size_t nbytes); /* may be NULL */ + + /* Called whenever the configured latency of the sink + * changes. Called from IO context. */ + void (*update_sink_requested_latency) (pa_sink_input *i); /* may be NULL */ + + /* Called whenever the latency range of the sink changes. Called + * from IO context. */ + void (*update_sink_latency_range) (pa_sink_input *i); /* may be NULL */ + + /* Called whenever the fixed latency of the sink changes, if there + * is one. Called from IO context. */ + void (*update_sink_fixed_latency) (pa_sink_input *i); /* may be NULL */ + + /* If non-NULL this function is called when the input is first + * connected to a sink or when the rtpoll/asyncmsgq fields + * change. You usually don't need to implement this function + * unless you rewrite a sink that is piggy-backed onto + * another. Called from IO thread context */ + void (*attach) (pa_sink_input *i); /* may be NULL */ + + /* If non-NULL this function is called when the output is + * disconnected from its sink. Called from IO thread context */ + void (*detach) (pa_sink_input *i); /* may be NULL */ + + /* If non-NULL called whenever the sink this input is attached + * to suspends or resumes or if the suspend cause changes. + * Called from main context */ + void (*suspend) (pa_sink_input *i, pa_sink_state_t old_state, pa_suspend_cause_t old_suspend_cause); /* may be NULL */ + + /* If non-NULL called whenever the sink this input is attached + * to suspends or resumes. Called from IO context */ + void (*suspend_within_thread) (pa_sink_input *i, bool b); /* may be NULL */ + + /* If non-NULL called whenever the sink input is moved to a new + * sink. Called from main context after the sink input has been + * detached from the old sink and before it has been attached to + * the new sink. If dest is NULL the move was executed in two + * phases and the second one failed; the stream will be destroyed + * after this call. */ + void (*moving) (pa_sink_input *i, pa_sink *dest); /* may be NULL */ + + /* Supposed to unlink and destroy this stream. Called from main + * context. */ + void (*kill) (pa_sink_input *i); /* may NOT be NULL */ + + /* Return the current latency (i.e. length of buffered audio) of + this stream. Called from main context. This is added to what the + PA_SINK_INPUT_MESSAGE_GET_LATENCY message sent to the IO thread + returns */ + pa_usec_t (*get_latency) (pa_sink_input *i); /* may be NULL */ + + /* If non-NULL this function is called from thread context if the + * state changes. The old state is found in thread_info.state. */ + void (*state_change) (pa_sink_input *i, pa_sink_input_state_t state); /* may be NULL */ + + /* If non-NULL this function is called before this sink input is + * move to a sink and if it returns false the move will not + * be allowed */ + bool (*may_move_to) (pa_sink_input *i, pa_sink *s); /* may be NULL */ + + /* If non-NULL this function is used to dispatch asynchronous + * control events. Called from main context. */ + void (*send_event)(pa_sink_input *i, const char *event, pa_proplist* data); /* may be NULL */ + + /* If non-NULL this function is called whenever the sink input + * volume changes. Called from main context */ + void (*volume_changed)(pa_sink_input *i); /* may be NULL */ + + /* If non-NULL this function is called whenever the sink input + * mute status changes. Called from main context */ + void (*mute_changed)(pa_sink_input *i); /* may be NULL */ + + struct { + pa_sink_input_state_t state; + + pa_cvolume soft_volume; + bool muted:1; + + bool attached:1; /* True only between ->attach() and ->detach() calls */ + + /* rewrite_nbytes: 0: rewrite nothing, (size_t) -1: rewrite everything, otherwise how many bytes to rewrite */ + bool rewrite_flush:1, dont_rewind_render:1; + size_t rewrite_nbytes; + uint64_t underrun_for, playing_for; + uint64_t underrun_for_sink; /* Like underrun_for, but in sink sample spec */ + + pa_sample_spec sample_spec; + + pa_resampler *resampler; /* may be NULL */ + + /* We maintain a history of resampled audio data here. */ + pa_memblockq *render_memblockq; + + pa_sink_input *sync_prev, *sync_next; + + /* The requested latency for the sink */ + pa_usec_t requested_sink_latency; + + pa_hashmap *direct_outputs; + } thread_info; + + void *userdata; +}; + +PA_DECLARE_PUBLIC_CLASS(pa_sink_input); +#define PA_SINK_INPUT(o) pa_sink_input_cast(o) + +enum { + PA_SINK_INPUT_MESSAGE_SET_SOFT_VOLUME, + PA_SINK_INPUT_MESSAGE_SET_SOFT_MUTE, + PA_SINK_INPUT_MESSAGE_GET_LATENCY, + PA_SINK_INPUT_MESSAGE_SET_RATE, + PA_SINK_INPUT_MESSAGE_SET_STATE, + PA_SINK_INPUT_MESSAGE_SET_REQUESTED_LATENCY, + PA_SINK_INPUT_MESSAGE_GET_REQUESTED_LATENCY, + PA_SINK_INPUT_MESSAGE_MAX +}; + +typedef struct pa_sink_input_send_event_hook_data { + pa_sink_input *sink_input; + const char *event; + pa_proplist *data; +} pa_sink_input_send_event_hook_data; + +typedef struct pa_sink_input_new_data { + pa_sink_input_flags_t flags; + + pa_proplist *proplist; + + const char *driver; + pa_module *module; + pa_client *client; + + pa_sink *sink; + bool sink_requested_by_application; + pa_sink *origin_sink; + + pa_resample_method_t resample_method; + + pa_sink_input *sync_base; + + pa_sample_spec sample_spec; + pa_channel_map channel_map; + pa_format_info *format; + pa_idxset *req_formats; + pa_idxset *nego_formats; + + pa_cvolume volume; + bool muted:1; + pa_hashmap *volume_factor_items, *volume_factor_sink_items; + + bool sample_spec_is_set:1; + bool channel_map_is_set:1; + + bool volume_is_set:1; + bool muted_is_set:1; + + bool volume_is_absolute:1; + + bool volume_writable:1; + + bool save_volume:1, save_muted:1; + + char *preferred_sink; +} pa_sink_input_new_data; + +pa_sink_input_new_data* pa_sink_input_new_data_init(pa_sink_input_new_data *data); +void pa_sink_input_new_data_set_sample_spec(pa_sink_input_new_data *data, const pa_sample_spec *spec); +void pa_sink_input_new_data_set_channel_map(pa_sink_input_new_data *data, const pa_channel_map *map); +bool pa_sink_input_new_data_is_passthrough(pa_sink_input_new_data *data); +void pa_sink_input_new_data_set_volume(pa_sink_input_new_data *data, const pa_cvolume *volume); +void pa_sink_input_new_data_add_volume_factor(pa_sink_input_new_data *data, const char *key, const pa_cvolume *volume_factor); +void pa_sink_input_new_data_add_volume_factor_sink(pa_sink_input_new_data *data, const char *key, const pa_cvolume *volume_factor); +void pa_sink_input_new_data_set_muted(pa_sink_input_new_data *data, bool mute); +bool pa_sink_input_new_data_set_sink(pa_sink_input_new_data *data, pa_sink *s, bool save, bool requested_by_application); +bool pa_sink_input_new_data_set_formats(pa_sink_input_new_data *data, pa_idxset *formats); +void pa_sink_input_new_data_done(pa_sink_input_new_data *data); + +/* To be called by the implementing module only */ + +int pa_sink_input_new( + pa_sink_input **i, + pa_core *core, + pa_sink_input_new_data *data); + +void pa_sink_input_put(pa_sink_input *i); +void pa_sink_input_unlink(pa_sink_input* i); + +pa_usec_t pa_sink_input_set_requested_latency(pa_sink_input *i, pa_usec_t usec); + +/* Request that the specified number of bytes already written out to +the hw device is rewritten, if possible. Please note that this is +only a kind request. The sink driver may not be able to fulfill it +fully -- or at all. If the request for a rewrite was successful, the +sink driver will call ->rewind() and pass the number of bytes that +could be rewound in the HW device. This functionality is required for +implementing the "zero latency" write-through functionality. */ +void pa_sink_input_request_rewind(pa_sink_input *i, size_t nbytes, bool rewrite, bool flush, bool dont_rewind_render); + +void pa_sink_input_cork(pa_sink_input *i, bool b); + +int pa_sink_input_set_rate(pa_sink_input *i, uint32_t rate); +int pa_sink_input_update_resampler(pa_sink_input *i); + +/* This returns the sink's fields converted into out sample type */ +size_t pa_sink_input_get_max_rewind(pa_sink_input *i); +size_t pa_sink_input_get_max_request(pa_sink_input *i); + +/* Callable by everyone from main thread*/ + +/* External code may request disconnection with this function */ +void pa_sink_input_kill(pa_sink_input*i); + +pa_usec_t pa_sink_input_get_latency(pa_sink_input *i, pa_usec_t *sink_latency); + +bool pa_sink_input_is_passthrough(pa_sink_input *i); +bool pa_sink_input_is_volume_readable(pa_sink_input *i); +void pa_sink_input_set_volume(pa_sink_input *i, const pa_cvolume *volume, bool save, bool absolute); +void pa_sink_input_add_volume_factor(pa_sink_input *i, const char *key, const pa_cvolume *volume_factor); +int pa_sink_input_remove_volume_factor(pa_sink_input *i, const char *key); +pa_cvolume *pa_sink_input_get_volume(pa_sink_input *i, pa_cvolume *volume, bool absolute); + +void pa_sink_input_set_mute(pa_sink_input *i, bool mute, bool save); + +void pa_sink_input_set_property(pa_sink_input *i, const char *key, const char *value); +void pa_sink_input_set_property_arbitrary(pa_sink_input *i, const char *key, const uint8_t *value, size_t nbytes); +void pa_sink_input_update_proplist(pa_sink_input *i, pa_update_mode_t mode, pa_proplist *p); + +pa_resample_method_t pa_sink_input_get_resample_method(pa_sink_input *i); + +void pa_sink_input_send_event(pa_sink_input *i, const char *name, pa_proplist *data); + +int pa_sink_input_move_to(pa_sink_input *i, pa_sink *dest, bool save); +bool pa_sink_input_may_move(pa_sink_input *i); /* may this sink input move at all? */ +bool pa_sink_input_may_move_to(pa_sink_input *i, pa_sink *dest); /* may this sink input move to this sink? */ + +/* The same as pa_sink_input_move_to() but in two separate steps, + * first the detaching from the old sink, then the attaching to the + * new sink */ +int pa_sink_input_start_move(pa_sink_input *i); +int pa_sink_input_finish_move(pa_sink_input *i, pa_sink *dest, bool save); +void pa_sink_input_fail_move(pa_sink_input *i); + +pa_usec_t pa_sink_input_get_requested_latency(pa_sink_input *i); + +/* To be used exclusively by the sink driver IO thread */ + +void pa_sink_input_peek(pa_sink_input *i, size_t length, pa_memchunk *chunk, pa_cvolume *volume); +void pa_sink_input_drop(pa_sink_input *i, size_t length); +void pa_sink_input_process_rewind(pa_sink_input *i, size_t nbytes /* in the sink's sample spec */); +void pa_sink_input_update_max_rewind(pa_sink_input *i, size_t nbytes /* in the sink's sample spec */); +void pa_sink_input_update_max_request(pa_sink_input *i, size_t nbytes /* in the sink's sample spec */); + +void pa_sink_input_set_state_within_thread(pa_sink_input *i, pa_sink_input_state_t state); + +int pa_sink_input_process_msg(pa_msgobject *o, int code, void *userdata, int64_t offset, pa_memchunk *chunk); + +pa_usec_t pa_sink_input_set_requested_latency_within_thread(pa_sink_input *i, pa_usec_t usec); + +bool pa_sink_input_safe_to_remove(pa_sink_input *i); +bool pa_sink_input_process_underrun(pa_sink_input *i); + +pa_memchunk* pa_sink_input_get_silence(pa_sink_input *i, pa_memchunk *ret); + +/* Calls the attach() callback if it's set. The input must be in detached + * state. */ +void pa_sink_input_attach(pa_sink_input *i); + +/* Calls the detach() callback if it's set and the input is attached. The input + * is allowed to be already detached, in which case this does nothing. + * + * The reason why this can be called for already-detached inputs is that when + * a filter sink's input is detached, it has to detach also all inputs + * connected to the filter sink. In case the filter sink's input was detached + * because the filter sink is being removed, those other inputs will be moved + * to another sink or removed, and moving and removing involve detaching the + * inputs, but the inputs at that point are already detached. + * + * XXX: Moving or removing an input also involves sending messages to the + * input's sink. If the input's sink is a detached filter sink, shouldn't + * sending messages to it be prohibited? The messages are processed in the + * root sink's IO thread, and when the filter sink is detached, it would seem + * logical to prohibit any interaction with the IO thread that isn't any more + * associated with the filter sink. Currently sending messages to detached + * filter sinks mostly works, because the filter sinks don't update their + * asyncmsgq pointer when detaching, so messages still find their way to the + * old IO thread. */ +void pa_sink_input_detach(pa_sink_input *i); + +/* Called from the main thread, from sink.c only. The normal way to set the + * sink input volume is to call pa_sink_input_set_volume(), but the flat volume + * logic in sink.c needs also a function that doesn't do all the extra stuff + * that pa_sink_input_set_volume() does. This function simply sets i->volume + * and fires change notifications. */ +void pa_sink_input_set_volume_direct(pa_sink_input *i, const pa_cvolume *volume); + +/* Called from the main thread, from sink.c only. This shouldn't be a public + * function, but the flat volume logic in sink.c currently needs a way to + * directly set the sink input reference ratio. This function simply sets + * i->reference_ratio and logs a message if the value changes. */ +void pa_sink_input_set_reference_ratio(pa_sink_input *i, const pa_cvolume *ratio); + +void pa_sink_input_set_preferred_sink(pa_sink_input *i, pa_sink *s); + +#define pa_sink_input_assert_io_context(s) \ + pa_assert(pa_thread_mq_get() || !PA_SINK_INPUT_IS_LINKED((s)->state)) + +#endif diff --git a/pulse/pulsecore-14.0/sink.h b/pulse/pulsecore-14.0/sink.h new file mode 100644 index 00000000..c3f5fbcd --- /dev/null +++ b/pulse/pulsecore-14.0/sink.h @@ -0,0 +1,575 @@ +#ifndef foopulsesinkhfoo +#define foopulsesinkhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PA_MAX_INPUTS_PER_SINK 256 + +/* Returns true if sink is linked: registered and accessible from client side. */ +static inline bool PA_SINK_IS_LINKED(pa_sink_state_t x) { + return x == PA_SINK_RUNNING || x == PA_SINK_IDLE || x == PA_SINK_SUSPENDED; +} + +/* A generic definition for void callback functions */ +typedef void(*pa_sink_cb_t)(pa_sink *s); + +typedef int (*pa_sink_get_mute_cb_t)(pa_sink *s, bool *mute); + +struct pa_sink { + pa_msgobject parent; + + uint32_t index; + pa_core *core; + + pa_sink_state_t state; + + /* Set in the beginning of pa_sink_unlink() before setting the sink state + * to UNLINKED. The purpose is to prevent moving streams to a sink that is + * about to be removed. */ + bool unlink_requested; + + pa_sink_flags_t flags; + pa_suspend_cause_t suspend_cause; + + char *name; + char *driver; /* may be NULL */ + pa_proplist *proplist; + + pa_module *module; /* may be NULL */ + pa_card *card; /* may be NULL */ + + pa_sample_spec sample_spec; + pa_channel_map channel_map; + uint32_t default_sample_rate; + uint32_t alternate_sample_rate; + bool avoid_resampling:1; + + pa_idxset *inputs; + unsigned n_corked; + pa_source *monitor_source; + pa_sink_input *input_to_master; /* non-NULL only for filter sinks */ + + pa_volume_t base_volume; /* shall be constant */ + unsigned n_volume_steps; /* shall be constant */ + + /* Also see http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/Developer/Volumes/ */ + pa_cvolume reference_volume; /* The volume exported and taken as reference base for relative sink input volumes */ + pa_cvolume real_volume; /* The volume that the hardware is configured to */ + pa_cvolume soft_volume; /* The internal software volume we apply to all PCM data while it passes through */ + + bool muted:1; + + bool refresh_volume:1; + bool refresh_muted:1; + bool save_port:1; + bool save_volume:1; + bool save_muted:1; + + /* Saved volume state while we're in passthrough mode */ + pa_cvolume saved_volume; + bool saved_save_volume:1; + + pa_asyncmsgq *asyncmsgq; + + pa_memchunk silence; + + pa_hashmap *ports; + pa_device_port *active_port; + + /* The latency offset is inherited from the currently active port */ + int64_t port_latency_offset; + + unsigned priority; + + bool set_mute_in_progress; + + /* Callbacks for doing things when the sink state and/or suspend cause is + * changed. It's fine to set either or both of the callbacks to NULL if the + * implementation doesn't have anything to do on state or suspend cause + * changes. + * + * set_state_in_main_thread() is called first. The callback is allowed to + * report failure if and only if the sink changes its state from + * SUSPENDED to IDLE or RUNNING. (FIXME: It would make sense to allow + * failure also when changing state from INIT to IDLE or RUNNING, but + * currently that will crash pa_sink_put().) If + * set_state_in_main_thread() fails, set_state_in_io_thread() won't be + * called. + * + * If set_state_in_main_thread() is successful (or not set), then + * set_state_in_io_thread() is called. Again, failure is allowed if and + * only if the sink changes state from SUSPENDED to IDLE or RUNNING. If + * set_state_in_io_thread() fails, then set_state_in_main_thread() is + * called again, this time with the state parameter set to SUSPENDED and + * the suspend_cause parameter set to 0. + * + * pa_sink.state, pa_sink.thread_info.state and pa_sink.suspend_cause + * are updated only after all the callback calls. In case of failure, the + * state is set to SUSPENDED and the suspend cause is set to 0. */ + int (*set_state_in_main_thread)(pa_sink *s, pa_sink_state_t state, pa_suspend_cause_t suspend_cause); /* may be NULL */ + int (*set_state_in_io_thread)(pa_sink *s, pa_sink_state_t state, pa_suspend_cause_t suspend_cause); /* may be NULL */ + + /* Sink drivers that support hardware volume may set this + * callback. This is called when the current volume needs to be + * re-read from the hardware. + * + * There are two ways for drivers to implement hardware volume + * query: either set this callback or handle + * PA_SINK_MESSAGE_GET_VOLUME. The callback implementation or the + * message handler must update s->real_volume and s->soft_volume + * (using pa_sink_set_soft_volume()) to match the current hardware + * volume. + * + * If PA_SINK_DEFERRED_VOLUME is not set, then this is called from the + * main thread before sending PA_SINK_MESSAGE_GET_VOLUME, so in + * this case the driver can choose whether to read the volume from + * the hardware in the main thread or in the IO thread. + * + * If PA_SINK_DEFERRED_VOLUME is set, then this is called from the IO + * thread within the default handler for + * PA_SINK_MESSAGE_GET_VOLUME (the main thread is waiting while + * the message is being processed), so there's no choice of where + * to do the volume reading - it has to be done in the IO thread + * always. + * + * You must use the function pa_sink_set_get_volume_callback() to + * set this callback. */ + pa_sink_cb_t get_volume; /* may be NULL */ + + /* Sink drivers that support hardware volume must set this + * callback. This is called when the hardware volume needs to be + * updated. + * + * If PA_SINK_DEFERRED_VOLUME is not set, then this is called from the + * main thread. The callback implementation must set the hardware + * volume according to s->real_volume. If the driver can't set the + * hardware volume to the exact requested value, it has to update + * s->real_volume and/or s->soft_volume so that they together + * match the actual hardware volume that was set. + * + * If PA_SINK_DEFERRED_VOLUME is set, then this is called from the IO + * thread. The callback implementation must not actually set the + * hardware volume yet, but it must check how close to the + * requested volume the hardware volume can be set, and update + * s->real_volume and/or s->soft_volume so that they together + * match the actual hardware volume that will be set later in the + * write_volume callback. + * + * You must use the function pa_sink_set_set_volume_callback() to + * set this callback. */ + pa_sink_cb_t set_volume; /* may be NULL */ + + /* Sink drivers that set PA_SINK_DEFERRED_VOLUME must provide this + * callback. This callback is not used with sinks that do not set + * PA_SINK_DEFERRED_VOLUME. This is called from the IO thread when a + * pending hardware volume change has to be written to the + * hardware. The requested volume is passed to the callback + * implementation in s->thread_info.current_hw_volume. + * + * The call is done inside pa_sink_volume_change_apply(), which is + * not called automatically - it is the driver's responsibility to + * schedule that function to be called at the right times in the + * IO thread. + * + * You must use the function pa_sink_set_write_volume_callback() to + * set this callback. */ + pa_sink_cb_t write_volume; /* may be NULL */ + + /* If the sink mute can change "spontaneously" (i.e. initiated by the sink + * implementation, not by someone else calling pa_sink_set_mute()), then + * the sink implementation can notify about changed mute either by calling + * pa_sink_mute_changed() or by calling pa_sink_get_mute() with + * force_refresh=true. If the implementation chooses the latter approach, + * it should implement the get_mute callback. Otherwise get_mute can be + * NULL. + * + * This is called when pa_sink_get_mute() is called with + * force_refresh=true. This is called from the IO thread if the + * PA_SINK_DEFERRED_VOLUME flag is set, otherwise this is called from the + * main thread. On success, the implementation is expected to return 0 and + * set the mute parameter that is passed as a reference. On failure, the + * implementation is expected to return -1. + * + * You must use the function pa_sink_set_get_mute_callback() to + * set this callback. */ + pa_sink_get_mute_cb_t get_mute; + + /* Called when the mute setting shall be changed. A PA_SINK_MESSAGE_SET_MUTE + * message will also be sent. Called from IO thread if PA_SINK_DEFERRED_VOLUME + * flag is set otherwise from main loop context. + * + * You must use the function pa_sink_set_set_mute_callback() to + * set this callback. */ + pa_sink_cb_t set_mute; /* may be NULL */ + + /* Called when a rewind request is issued. Called from IO thread + * context. */ + pa_sink_cb_t request_rewind; /* may be NULL */ + + /* Called when a the requested latency is changed. Called from IO + * thread context. */ + pa_sink_cb_t update_requested_latency; /* may be NULL */ + + /* Called whenever the port shall be changed. Called from the main + * thread. */ + int (*set_port)(pa_sink *s, pa_device_port *port); /* may be NULL */ + + /* Called to get the list of formats supported by the sink, sorted + * in descending order of preference. */ + pa_idxset* (*get_formats)(pa_sink *s); /* may be NULL */ + + /* Called to set the list of formats supported by the sink. Can be + * NULL if the sink does not support this. Returns true on success, + * false otherwise (for example when an unsupportable format is + * set). Makes a copy of the formats passed in. */ + bool (*set_formats)(pa_sink *s, pa_idxset *formats); /* may be NULL */ + + /* Called whenever device parameters need to be changed. Called from + * main thread. */ + void (*reconfigure)(pa_sink *s, pa_sample_spec *spec, bool passthrough); + + /* Contains copies of the above data so that the real-time worker + * thread can work without access locking */ + struct { + pa_sink_state_t state; + pa_hashmap *inputs; + + pa_rtpoll *rtpoll; + + pa_cvolume soft_volume; + bool soft_muted:1; + + /* The requested latency is used for dynamic latency + * sinks. For fixed latency sinks it is always identical to + * the fixed_latency. See below. */ + bool requested_latency_valid:1; + pa_usec_t requested_latency; + + /* The number of bytes streams need to keep around as history to + * be able to satisfy every DMA buffer rewrite */ + size_t max_rewind; + + /* The number of bytes streams need to keep around to satisfy + * every DMA write request */ + size_t max_request; + + /* Maximum of what clients requested to rewind in this cycle */ + size_t rewind_nbytes; + bool rewind_requested; + + /* Both dynamic and fixed latencies will be clamped to this + * range. */ + pa_usec_t min_latency; /* we won't go below this latency */ + pa_usec_t max_latency; /* An upper limit for the latencies */ + + /* 'Fixed' simply means that the latency is exclusively + * decided on by the sink, and the clients have no influence + * in changing it */ + pa_usec_t fixed_latency; /* for sinks with PA_SINK_DYNAMIC_LATENCY this is 0 */ + + /* This latency offset is a direct copy from s->port_latency_offset */ + int64_t port_latency_offset; + + /* Delayed volume change events are queued here. The events + * are stored in expiration order. The one expiring next is in + * the head of the list. */ + PA_LLIST_HEAD(pa_sink_volume_change, volume_changes); + pa_sink_volume_change *volume_changes_tail; + /* This value is updated in pa_sink_volume_change_apply() and + * used only by sinks with PA_SINK_DEFERRED_VOLUME. */ + pa_cvolume current_hw_volume; + + /* The amount of usec volume up events are delayed and volume + * down events are made earlier. */ + uint32_t volume_change_safety_margin; + /* Usec delay added to all volume change events, may be negative. */ + int32_t volume_change_extra_delay; + } thread_info; + + void *userdata; +}; + +PA_DECLARE_PUBLIC_CLASS(pa_sink); +#define PA_SINK(s) (pa_sink_cast(s)) + +typedef enum pa_sink_message { + PA_SINK_MESSAGE_ADD_INPUT, + PA_SINK_MESSAGE_REMOVE_INPUT, + PA_SINK_MESSAGE_GET_VOLUME, + PA_SINK_MESSAGE_SET_SHARED_VOLUME, + PA_SINK_MESSAGE_SET_VOLUME_SYNCED, + PA_SINK_MESSAGE_SET_VOLUME, + PA_SINK_MESSAGE_SYNC_VOLUMES, + PA_SINK_MESSAGE_GET_MUTE, + PA_SINK_MESSAGE_SET_MUTE, + PA_SINK_MESSAGE_GET_LATENCY, + PA_SINK_MESSAGE_GET_REQUESTED_LATENCY, + PA_SINK_MESSAGE_SET_STATE, + PA_SINK_MESSAGE_START_MOVE, + PA_SINK_MESSAGE_FINISH_MOVE, + PA_SINK_MESSAGE_SET_LATENCY_RANGE, + PA_SINK_MESSAGE_GET_LATENCY_RANGE, + PA_SINK_MESSAGE_SET_FIXED_LATENCY, + PA_SINK_MESSAGE_GET_FIXED_LATENCY, + PA_SINK_MESSAGE_GET_MAX_REWIND, + PA_SINK_MESSAGE_GET_MAX_REQUEST, + PA_SINK_MESSAGE_SET_MAX_REWIND, + PA_SINK_MESSAGE_SET_MAX_REQUEST, + PA_SINK_MESSAGE_UPDATE_VOLUME_AND_MUTE, + PA_SINK_MESSAGE_SET_PORT_LATENCY_OFFSET, + PA_SINK_MESSAGE_MAX +} pa_sink_message_t; + +typedef struct pa_sink_new_data { + pa_suspend_cause_t suspend_cause; + + char *name; + pa_proplist *proplist; + + const char *driver; + pa_module *module; + pa_card *card; + + pa_hashmap *ports; + char *active_port; + + pa_sample_spec sample_spec; + pa_channel_map channel_map; + uint32_t alternate_sample_rate; + bool avoid_resampling:1; + pa_cvolume volume; + bool muted:1; + + bool sample_spec_is_set:1; + bool channel_map_is_set:1; + bool alternate_sample_rate_is_set:1; + bool avoid_resampling_is_set:1; + bool volume_is_set:1; + bool muted_is_set:1; + + bool namereg_fail:1; + + bool save_port:1; + bool save_volume:1; + bool save_muted:1; +} pa_sink_new_data; + +pa_sink_new_data* pa_sink_new_data_init(pa_sink_new_data *data); +void pa_sink_new_data_set_name(pa_sink_new_data *data, const char *name); +void pa_sink_new_data_set_sample_spec(pa_sink_new_data *data, const pa_sample_spec *spec); +void pa_sink_new_data_set_channel_map(pa_sink_new_data *data, const pa_channel_map *map); +void pa_sink_new_data_set_alternate_sample_rate(pa_sink_new_data *data, const uint32_t alternate_sample_rate); +void pa_sink_new_data_set_avoid_resampling(pa_sink_new_data *data, bool avoid_resampling); +void pa_sink_new_data_set_volume(pa_sink_new_data *data, const pa_cvolume *volume); +void pa_sink_new_data_set_muted(pa_sink_new_data *data, bool mute); +void pa_sink_new_data_set_port(pa_sink_new_data *data, const char *port); +void pa_sink_new_data_done(pa_sink_new_data *data); + +/*** To be called exclusively by the sink driver, from main context */ + +pa_sink* pa_sink_new( + pa_core *core, + pa_sink_new_data *data, + pa_sink_flags_t flags); + +void pa_sink_set_get_volume_callback(pa_sink *s, pa_sink_cb_t cb); +void pa_sink_set_set_volume_callback(pa_sink *s, pa_sink_cb_t cb); +void pa_sink_set_write_volume_callback(pa_sink *s, pa_sink_cb_t cb); +void pa_sink_set_get_mute_callback(pa_sink *s, pa_sink_get_mute_cb_t cb); +void pa_sink_set_set_mute_callback(pa_sink *s, pa_sink_cb_t cb); +void pa_sink_enable_decibel_volume(pa_sink *s, bool enable); + +void pa_sink_put(pa_sink *s); +void pa_sink_unlink(pa_sink* s); + +void pa_sink_set_description(pa_sink *s, const char *description); +void pa_sink_set_asyncmsgq(pa_sink *s, pa_asyncmsgq *q); +void pa_sink_set_rtpoll(pa_sink *s, pa_rtpoll *p); + +void pa_sink_set_max_rewind(pa_sink *s, size_t max_rewind); +void pa_sink_set_max_request(pa_sink *s, size_t max_request); +void pa_sink_set_latency_range(pa_sink *s, pa_usec_t min_latency, pa_usec_t max_latency); +void pa_sink_set_fixed_latency(pa_sink *s, pa_usec_t latency); + +void pa_sink_set_soft_volume(pa_sink *s, const pa_cvolume *volume); +void pa_sink_volume_changed(pa_sink *s, const pa_cvolume *new_volume); +void pa_sink_mute_changed(pa_sink *s, bool new_muted); + +void pa_sink_update_flags(pa_sink *s, pa_sink_flags_t mask, pa_sink_flags_t value); + +bool pa_device_init_description(pa_proplist *p, pa_card *card); +bool pa_device_init_icon(pa_proplist *p, bool is_sink); +bool pa_device_init_intended_roles(pa_proplist *p); +unsigned pa_device_init_priority(pa_proplist *p); + +/**** May be called by everyone, from main context */ + +void pa_sink_reconfigure(pa_sink *s, pa_sample_spec *spec, bool passthrough); +void pa_sink_set_port_latency_offset(pa_sink *s, int64_t offset); + +/* The returned value is supposed to be in the time domain of the sound card! */ +pa_usec_t pa_sink_get_latency(pa_sink *s); +pa_usec_t pa_sink_get_requested_latency(pa_sink *s); +void pa_sink_get_latency_range(pa_sink *s, pa_usec_t *min_latency, pa_usec_t *max_latency); +pa_usec_t pa_sink_get_fixed_latency(pa_sink *s); + +size_t pa_sink_get_max_rewind(pa_sink *s); +size_t pa_sink_get_max_request(pa_sink *s); + +int pa_sink_update_status(pa_sink*s); +int pa_sink_suspend(pa_sink *s, bool suspend, pa_suspend_cause_t cause); +int pa_sink_suspend_all(pa_core *c, bool suspend, pa_suspend_cause_t cause); + +/* Use this instead of checking s->flags & PA_SINK_FLAT_VOLUME directly. */ +bool pa_sink_flat_volume_enabled(pa_sink *s); + +/* Get the master sink when sharing volumes */ +pa_sink *pa_sink_get_master(pa_sink *s); + +bool pa_sink_is_filter(pa_sink *s); + +/* Is the sink in passthrough mode? (that is, is there a passthrough sink input + * connected to this sink? */ +bool pa_sink_is_passthrough(pa_sink *s); +/* These should be called when a sink enters/leaves passthrough mode */ +void pa_sink_enter_passthrough(pa_sink *s); +void pa_sink_leave_passthrough(pa_sink *s); + +void pa_sink_set_volume(pa_sink *sink, const pa_cvolume *volume, bool sendmsg, bool save); +const pa_cvolume *pa_sink_get_volume(pa_sink *sink, bool force_refresh); + +void pa_sink_set_mute(pa_sink *sink, bool mute, bool save); +bool pa_sink_get_mute(pa_sink *sink, bool force_refresh); + +bool pa_sink_update_proplist(pa_sink *s, pa_update_mode_t mode, pa_proplist *p); + +int pa_sink_set_port(pa_sink *s, const char *name, bool save); + +unsigned pa_sink_linked_by(pa_sink *s); /* Number of connected streams */ +unsigned pa_sink_used_by(pa_sink *s); /* Number of connected streams which are not corked */ + +/* Returns how many streams are active that don't allow suspensions. If + * "ignore_input" or "ignore_output" is non-NULL, that stream is not included + * in the count (the returned count includes the value from + * pa_source_check_suspend(), which is called for the monitor source, so that's + * why "ignore_output" may be relevant). */ +unsigned pa_sink_check_suspend(pa_sink *s, pa_sink_input *ignore_input, pa_source_output *ignore_output); + +const char *pa_sink_state_to_string(pa_sink_state_t state); + +/* Moves all inputs away, and stores them in pa_queue */ +pa_queue *pa_sink_move_all_start(pa_sink *s, pa_queue *q); +void pa_sink_move_all_finish(pa_sink *s, pa_queue *q, bool save); +void pa_sink_move_all_fail(pa_queue *q); + +/* Returns a copy of the sink formats. TODO: Get rid of this function (or at + * least get rid of the copying). There's no good reason to copy the formats + * every time someone wants to know what formats the sink supports. The formats + * idxset could be stored directly in the pa_sink struct. + * https://bugs.freedesktop.org/show_bug.cgi?id=71924 */ +pa_idxset* pa_sink_get_formats(pa_sink *s); + +bool pa_sink_set_formats(pa_sink *s, pa_idxset *formats); +bool pa_sink_check_format(pa_sink *s, pa_format_info *f); +pa_idxset* pa_sink_check_formats(pa_sink *s, pa_idxset *in_formats); + +void pa_sink_set_sample_format(pa_sink *s, pa_sample_format_t format); +void pa_sink_set_sample_rate(pa_sink *s, uint32_t rate); + +/*** To be called exclusively by the sink driver, from IO context */ + +void pa_sink_render(pa_sink*s, size_t length, pa_memchunk *result); +void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result); +void pa_sink_render_into(pa_sink*s, pa_memchunk *target); +void pa_sink_render_into_full(pa_sink *s, pa_memchunk *target); + +void pa_sink_process_rewind(pa_sink *s, size_t nbytes); + +int pa_sink_process_msg(pa_msgobject *o, int code, void *userdata, int64_t offset, pa_memchunk *chunk); + +void pa_sink_attach_within_thread(pa_sink *s); +void pa_sink_detach_within_thread(pa_sink *s); + +pa_usec_t pa_sink_get_requested_latency_within_thread(pa_sink *s); + +void pa_sink_set_max_rewind_within_thread(pa_sink *s, size_t max_rewind); +void pa_sink_set_max_request_within_thread(pa_sink *s, size_t max_request); + +void pa_sink_set_latency_range_within_thread(pa_sink *s, pa_usec_t min_latency, pa_usec_t max_latency); +void pa_sink_set_fixed_latency_within_thread(pa_sink *s, pa_usec_t latency); + +void pa_sink_update_volume_and_mute(pa_sink *s); + +bool pa_sink_volume_change_apply(pa_sink *s, pa_usec_t *usec_to_next); + +size_t pa_sink_process_input_underruns(pa_sink *s, size_t left_to_play); + +/*** To be called exclusively by sink input drivers, from IO context */ + +void pa_sink_request_rewind(pa_sink*s, size_t nbytes); + +void pa_sink_invalidate_requested_latency(pa_sink *s, bool dynamic); + +int64_t pa_sink_get_latency_within_thread(pa_sink *s, bool allow_negative); + +/* Called from the main thread, from sink-input.c only. The normal way to set + * the sink reference volume is to call pa_sink_set_volume(), but the flat + * volume logic in sink-input.c needs also a function that doesn't do all the + * extra stuff that pa_sink_set_volume() does. This function simply sets + * s->reference_volume and fires change notifications. */ +void pa_sink_set_reference_volume_direct(pa_sink *s, const pa_cvolume *volume); + +/* When the default_sink is changed or the active_port of a sink is changed to + * PA_AVAILABLE_NO, this function is called to move the streams of the old + * default_sink or the sink with active_port equals PA_AVAILABLE_NO to the + * current default_sink conditionally*/ +void pa_sink_move_streams_to_default_sink(pa_core *core, pa_sink *old_sink, bool default_sink_changed); + +/* Verify that we called in IO context (aka 'thread context), or that + * the sink is not yet set up, i.e. the thread not set up yet. See + * pa_assert_io_context() in thread-mq.h for more information. */ +#define pa_sink_assert_io_context(s) \ + pa_assert(pa_thread_mq_get() || !PA_SINK_IS_LINKED((s)->state)) + +#endif diff --git a/pulse/pulsecore-14.0/sioman.h b/pulse/pulsecore-14.0/sioman.h new file mode 100644 index 00000000..10ad382a --- /dev/null +++ b/pulse/pulsecore-14.0/sioman.h @@ -0,0 +1,26 @@ +#ifndef foosiomanhfoo +#define foosiomanhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +int pa_stdio_acquire(void); +void pa_stdio_release(void); + +#endif diff --git a/pulse/pulsecore-14.0/sndfile-util.h b/pulse/pulsecore-14.0/sndfile-util.h new file mode 100644 index 00000000..1f67ac3e --- /dev/null +++ b/pulse/pulsecore-14.0/sndfile-util.h @@ -0,0 +1,50 @@ +#ifndef foopulsecoresndfileutilhfoo +#define foopulsecoresndfileutilhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2009 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +#include +#include +#include + +int pa_sndfile_read_sample_spec(SNDFILE *sf, pa_sample_spec *ss); +int pa_sndfile_read_channel_map(SNDFILE *sf, pa_channel_map *cm); + +int pa_sndfile_write_sample_spec(SF_INFO *sfi, pa_sample_spec *ss); +int pa_sndfile_write_channel_map(SNDFILE *sf, pa_channel_map *cm); + +void pa_sndfile_init_proplist(SNDFILE *sf, pa_proplist *p); + +typedef sf_count_t (*pa_sndfile_readf_t)(SNDFILE *sndfile, void *ptr, sf_count_t frames); +typedef sf_count_t (*pa_sndfile_writef_t)(SNDFILE *sndfile, const void *ptr, sf_count_t frames); + +/* Returns NULL if sf_read_raw() shall be used */ +pa_sndfile_readf_t pa_sndfile_readf_function(const pa_sample_spec *ss); + +/* Returns NULL if sf_write_raw() shall be used */ +pa_sndfile_writef_t pa_sndfile_writef_function(const pa_sample_spec *ss); + +int pa_sndfile_format_from_string(const char *extension); + +void pa_sndfile_dump_formats(void); + +#endif diff --git a/pulse/pulsecore-14.0/socket-client.h b/pulse/pulsecore-14.0/socket-client.h new file mode 100644 index 00000000..9d22072a --- /dev/null +++ b/pulse/pulsecore-14.0/socket-client.h @@ -0,0 +1,48 @@ +#ifndef foosocketclienthfoo +#define foosocketclienthfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include + +#include +#include + +struct sockaddr; + +typedef struct pa_socket_client pa_socket_client; + +typedef void (*pa_socket_client_cb_t)(pa_socket_client *c, pa_iochannel*io, void *userdata); + +pa_socket_client* pa_socket_client_new_ipv4(pa_mainloop_api *m, uint32_t address, uint16_t port); +pa_socket_client* pa_socket_client_new_ipv6(pa_mainloop_api *m, uint8_t address[16], uint16_t port); +pa_socket_client* pa_socket_client_new_unix(pa_mainloop_api *m, const char *filename); +pa_socket_client* pa_socket_client_new_sockaddr(pa_mainloop_api *m, const struct sockaddr *sa, size_t salen); +pa_socket_client* pa_socket_client_new_string(pa_mainloop_api *m, bool use_rtclock, const char *a, uint16_t default_port); + +pa_socket_client* pa_socket_client_ref(pa_socket_client *c); +void pa_socket_client_unref(pa_socket_client *c); + +void pa_socket_client_set_callback(pa_socket_client *c, pa_socket_client_cb_t on_connection, void *userdata); + +bool pa_socket_client_is_local(pa_socket_client *c); + +#endif diff --git a/pulse/pulsecore-14.0/socket-server.h b/pulse/pulsecore-14.0/socket-server.h new file mode 100644 index 00000000..0793baf4 --- /dev/null +++ b/pulse/pulsecore-14.0/socket-server.h @@ -0,0 +1,53 @@ +#ifndef foosocketserverhfoo +#define foosocketserverhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include +#include + +/* It is safe to destroy the calling socket_server object from the callback */ + +typedef struct pa_socket_server pa_socket_server; + +pa_socket_server* pa_socket_server_new_unix(pa_mainloop_api *m, const char *filename); +pa_socket_server* pa_socket_server_new_ipv4(pa_mainloop_api *m, uint32_t address, uint16_t port, bool fallback, const char *tcpwrap_service); +pa_socket_server* pa_socket_server_new_ipv4_loopback(pa_mainloop_api *m, uint16_t port, bool fallback, const char *tcpwrap_service); +pa_socket_server* pa_socket_server_new_ipv4_any(pa_mainloop_api *m, uint16_t port, bool fallback, const char *tcpwrap_service); +pa_socket_server* pa_socket_server_new_ipv4_string(pa_mainloop_api *m, const char *name, uint16_t port, bool fallback, const char *tcpwrap_service); +#ifdef HAVE_IPV6 +pa_socket_server* pa_socket_server_new_ipv6(pa_mainloop_api *m, const uint8_t address[16], uint16_t port, bool fallback, const char *tcpwrap_service); +pa_socket_server* pa_socket_server_new_ipv6_loopback(pa_mainloop_api *m, uint16_t port, bool fallback, const char *tcpwrap_service); +pa_socket_server* pa_socket_server_new_ipv6_any(pa_mainloop_api *m, uint16_t port, bool fallback, const char *tcpwrap_service); +pa_socket_server* pa_socket_server_new_ipv6_string(pa_mainloop_api *m, const char *name, uint16_t port, bool fallback, const char *tcpwrap_service); +#endif + +void pa_socket_server_unref(pa_socket_server*s); +pa_socket_server* pa_socket_server_ref(pa_socket_server *s); + +typedef void (*pa_socket_server_on_connection_cb_t)(pa_socket_server*s, pa_iochannel *io, void *userdata); + +void pa_socket_server_set_callback(pa_socket_server*s, pa_socket_server_on_connection_cb_t connection_cb, void *userdata); + +char *pa_socket_server_get_address(pa_socket_server *s, char *c, size_t l); + +#endif diff --git a/pulse/pulsecore-14.0/socket-util.h b/pulse/pulsecore-14.0/socket-util.h new file mode 100644 index 00000000..f1207693 --- /dev/null +++ b/pulse/pulsecore-14.0/socket-util.h @@ -0,0 +1,44 @@ +#ifndef foosocketutilhfoo +#define foosocketutilhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +#include +#include + +void pa_socket_peer_to_string(int fd, char *c, size_t l); + +void pa_make_socket_low_delay(int fd); +void pa_make_tcp_socket_low_delay(int fd); +void pa_make_udp_socket_low_delay(int fd); + +int pa_socket_set_sndbuf(int fd, size_t l); +int pa_socket_set_rcvbuf(int fd, size_t l); + +int pa_unix_socket_is_stale(const char *fn); +int pa_unix_socket_remove_stale(const char *fn); + +bool pa_socket_address_is_local(const struct sockaddr *sa); +bool pa_socket_is_local(int fd); + +#endif diff --git a/pulse/pulsecore-14.0/socket.h b/pulse/pulsecore-14.0/socket.h new file mode 100644 index 00000000..72f22281 --- /dev/null +++ b/pulse/pulsecore-14.0/socket.h @@ -0,0 +1,20 @@ +#ifndef foopulsecoresockethfoo +#define foopulsecoresockethfoo + +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + +#ifdef HAVE_WINSOCK2_H +#include +#include "winerrno.h" + +typedef long suseconds_t; + +#endif + +#ifdef HAVE_WS2TCPIP_H +#include +#endif + +#endif diff --git a/pulse/pulsecore-14.0/sound-file-stream.h b/pulse/pulsecore-14.0/sound-file-stream.h new file mode 100644 index 00000000..de55c6d0 --- /dev/null +++ b/pulse/pulsecore-14.0/sound-file-stream.h @@ -0,0 +1,27 @@ +#ifndef foosoundfilestreamhfoo +#define foosoundfilestreamhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +int pa_play_file(pa_sink *sink, const char *fname, const pa_cvolume *volume); + +#endif diff --git a/pulse/pulsecore-14.0/sound-file.h b/pulse/pulsecore-14.0/sound-file.h new file mode 100644 index 00000000..01afa4e5 --- /dev/null +++ b/pulse/pulsecore-14.0/sound-file.h @@ -0,0 +1,31 @@ +#ifndef soundfilehfoo +#define soundfilehfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include +#include + +int pa_sound_file_load(pa_mempool *pool, const char *fname, pa_sample_spec *ss, pa_channel_map *map, pa_memchunk *chunk, pa_proplist *p); + +int pa_sound_file_too_big_to_cache(const char *fname); + +#endif diff --git a/pulse/pulsecore-14.0/source-output.h b/pulse/pulsecore-14.0/source-output.h new file mode 100644 index 00000000..2bf56820 --- /dev/null +++ b/pulse/pulsecore-14.0/source-output.h @@ -0,0 +1,410 @@ +#ifndef foopulsesourceoutputhfoo +#define foopulsesourceoutputhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef enum pa_source_output_state { + PA_SOURCE_OUTPUT_INIT, + PA_SOURCE_OUTPUT_RUNNING, + PA_SOURCE_OUTPUT_CORKED, + PA_SOURCE_OUTPUT_UNLINKED +} pa_source_output_state_t; + +static inline bool PA_SOURCE_OUTPUT_IS_LINKED(pa_source_output_state_t x) { + return x == PA_SOURCE_OUTPUT_RUNNING || x == PA_SOURCE_OUTPUT_CORKED; +} + +typedef enum pa_source_output_flags { + PA_SOURCE_OUTPUT_VARIABLE_RATE = 1, + PA_SOURCE_OUTPUT_DONT_MOVE = 2, + PA_SOURCE_OUTPUT_START_CORKED = 4, + PA_SOURCE_OUTPUT_NO_REMAP = 8, + PA_SOURCE_OUTPUT_NO_REMIX = 16, + PA_SOURCE_OUTPUT_FIX_FORMAT = 32, + PA_SOURCE_OUTPUT_FIX_RATE = 64, + PA_SOURCE_OUTPUT_FIX_CHANNELS = 128, + PA_SOURCE_OUTPUT_DONT_INHIBIT_AUTO_SUSPEND = 256, + PA_SOURCE_OUTPUT_NO_CREATE_ON_SUSPEND = 512, + PA_SOURCE_OUTPUT_KILL_ON_SUSPEND = 1024, + PA_SOURCE_OUTPUT_PASSTHROUGH = 2048 +} pa_source_output_flags_t; + +struct pa_source_output { + pa_msgobject parent; + + uint32_t index; + pa_core *core; + + pa_source_output_state_t state; + pa_source_output_flags_t flags; + + char *driver; /* may be NULL */ + pa_proplist *proplist; + + pa_module *module; /* may be NULL */ + pa_client *client; /* may be NULL */ + + pa_source *source; /* NULL while being moved */ + + /* This is set to true when creating the source output if the source was + * requested by the application that created the source output. This is + * sometimes useful for determining whether the source output should be + * moved by some automatic policy. If the source output is moved away from + * the source that the application requested, this flag is reset to + * false. */ + bool source_requested_by_application; + + pa_source *destination_source; /* only set by filter sources */ + + /* A source output can monitor just a single input of a sink, in which case we find it here */ + pa_sink_input *direct_on_input; /* may be NULL */ + + pa_sample_spec sample_spec; + pa_channel_map channel_map; + pa_format_info *format; + + /* Also see http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/Developer/Volumes/ */ + pa_cvolume volume; /* The volume clients are informed about */ + pa_cvolume reference_ratio; /* The ratio of the stream's volume to the source's reference volume */ + pa_cvolume real_ratio; /* The ratio of the stream's volume to the source's real volume */ + pa_cvolume volume_factor; /* An internally used volume factor that can be used by modules to apply effects and suchlike without having that visible to the outside */ + pa_cvolume soft_volume; /* The internal software volume we apply to all PCM data while it passes through. Usually calculated as real_ratio * volume_factor */ + + pa_cvolume volume_factor_source; /* A second volume factor in format of the source this stream is connected to */ + + bool volume_writable:1; + + bool muted:1; + + /* if true then the volume and the mute state of this source-output + * are worth remembering, module-stream-restore looks for this. */ + bool save_volume:1, save_muted:1; + + /* if users move the source-output to a source, and the source is not + * default_source, the source->name will be saved in preferred_source. And + * later if source-output is moved to other sources for some reason, it + * still can be restored to the preferred_source at an appropriate time */ + char *preferred_source; + + pa_resample_method_t requested_resample_method, actual_resample_method; + + /* Pushes a new memchunk into the output. Called from IO thread + * context. */ + void (*push)(pa_source_output *o, const pa_memchunk *chunk); /* may NOT be NULL */ + + /* Only relevant for monitor sources right now: called when the + * recorded stream is rewound. Called from IO context */ + void (*process_rewind)(pa_source_output *o, size_t nbytes); /* may be NULL */ + + /* Called whenever the maximum rewindable size of the source + * changes. Called from IO thread context. */ + void (*update_max_rewind) (pa_source_output *o, size_t nbytes); /* may be NULL */ + + /* Called whenever the configured latency of the source + * changes. Called from IO context. */ + void (*update_source_requested_latency) (pa_source_output *o); /* may be NULL */ + + /* Called whenever the latency range of the source changes. Called + * from IO context. */ + void (*update_source_latency_range) (pa_source_output *o); /* may be NULL */ + + /* Called whenever the fixed latency of the source changes, if there + * is one. Called from IO context. */ + void (*update_source_fixed_latency) (pa_source_output *i); /* may be NULL */ + + /* If non-NULL this function is called when the output is first + * connected to a source or when the rtpoll/asyncmsgq fields + * change. You usually don't need to implement this function + * unless you rewrite a source that is piggy-backed onto + * another. Called from IO thread context */ + void (*attach) (pa_source_output *o); /* may be NULL */ + + /* If non-NULL this function is called when the output is + * disconnected from its source. Called from IO thread context */ + void (*detach) (pa_source_output *o); /* may be NULL */ + + /* If non-NULL called whenever the source this output is attached + * to suspends or resumes or if the suspend cause changes. + * Called from main context */ + void (*suspend) (pa_source_output *o, pa_source_state_t old_state, pa_suspend_cause_t old_suspend_cause); /* may be NULL */ + + /* If non-NULL called whenever the source this output is attached + * to suspends or resumes. Called from IO context */ + void (*suspend_within_thread) (pa_source_output *o, bool b); /* may be NULL */ + + /* If non-NULL called whenever the source output is moved to a new + * source. Called from main context after the source output has been + * detached from the old source and before it has been attached to + * the new source. If dest is NULL the move was executed in two + * phases and the second one failed; the stream will be destroyed + * after this call. */ + void (*moving) (pa_source_output *o, pa_source *dest); /* may be NULL */ + + /* Supposed to unlink and destroy this stream. Called from main + * context. */ + void (*kill)(pa_source_output* o); /* may NOT be NULL */ + + /* Return the current latency (i.e. length of buffered audio) of + this stream. Called from main context. This is added to what the + PA_SOURCE_OUTPUT_MESSAGE_GET_LATENCY message sent to the IO thread + returns */ + pa_usec_t (*get_latency) (pa_source_output *o); /* may be NULL */ + + /* If non-NULL this function is called from thread context if the + * state changes. The old state is found in thread_info.state. */ + void (*state_change) (pa_source_output *o, pa_source_output_state_t state); /* may be NULL */ + + /* If non-NULL this function is called before this source output + * is moved to a source and if it returns false the move + * will not be allowed */ + bool (*may_move_to) (pa_source_output *o, pa_source *s); /* may be NULL */ + + /* If non-NULL this function is used to dispatch asynchronous + * control events. */ + void (*send_event)(pa_source_output *o, const char *event, pa_proplist* data); + + /* If non-NULL this function is called whenever the source output + * volume changes. Called from main context */ + void (*volume_changed)(pa_source_output *o); /* may be NULL */ + + /* If non-NULL this function is called whenever the source output + * mute status changes. Called from main context */ + void (*mute_changed)(pa_source_output *o); /* may be NULL */ + + struct { + pa_source_output_state_t state; + + pa_cvolume soft_volume; + bool muted:1; + + bool attached:1; /* True only between ->attach() and ->detach() calls */ + + pa_sample_spec sample_spec; + + pa_resampler* resampler; /* may be NULL */ + + /* We maintain a delay memblockq here for source outputs that + * don't implement rewind() */ + pa_memblockq *delay_memblockq; + + /* The requested latency for the source */ + pa_usec_t requested_source_latency; + + pa_sink_input *direct_on_input; /* may be NULL */ + } thread_info; + + void *userdata; +}; + +PA_DECLARE_PUBLIC_CLASS(pa_source_output); +#define PA_SOURCE_OUTPUT(o) pa_source_output_cast(o) + +enum { + PA_SOURCE_OUTPUT_MESSAGE_GET_LATENCY, + PA_SOURCE_OUTPUT_MESSAGE_SET_RATE, + PA_SOURCE_OUTPUT_MESSAGE_SET_STATE, + PA_SOURCE_OUTPUT_MESSAGE_SET_REQUESTED_LATENCY, + PA_SOURCE_OUTPUT_MESSAGE_GET_REQUESTED_LATENCY, + PA_SOURCE_OUTPUT_MESSAGE_SET_SOFT_VOLUME, + PA_SOURCE_OUTPUT_MESSAGE_SET_SOFT_MUTE, + PA_SOURCE_OUTPUT_MESSAGE_MAX +}; + +typedef struct pa_source_output_send_event_hook_data { + pa_source_output *source_output; + const char *event; + pa_proplist *data; +} pa_source_output_send_event_hook_data; + +typedef struct pa_source_output_new_data { + pa_source_output_flags_t flags; + + pa_proplist *proplist; + pa_sink_input *direct_on_input; + + const char *driver; + pa_module *module; + pa_client *client; + + pa_source *source; + bool source_requested_by_application; + pa_source *destination_source; + + pa_resample_method_t resample_method; + + pa_sample_spec sample_spec; + pa_channel_map channel_map; + pa_format_info *format; + pa_idxset *req_formats; + pa_idxset *nego_formats; + + pa_cvolume volume, volume_factor, volume_factor_source; + bool muted:1; + + bool sample_spec_is_set:1; + bool channel_map_is_set:1; + + bool volume_is_set:1, volume_factor_is_set:1, volume_factor_source_is_set:1; + bool muted_is_set:1; + + bool volume_is_absolute:1; + + bool volume_writable:1; + + bool save_volume:1, save_muted:1; + char *preferred_source; +} pa_source_output_new_data; + +pa_source_output_new_data* pa_source_output_new_data_init(pa_source_output_new_data *data); +void pa_source_output_new_data_set_sample_spec(pa_source_output_new_data *data, const pa_sample_spec *spec); +void pa_source_output_new_data_set_channel_map(pa_source_output_new_data *data, const pa_channel_map *map); +bool pa_source_output_new_data_is_passthrough(pa_source_output_new_data *data); +void pa_source_output_new_data_set_volume(pa_source_output_new_data *data, const pa_cvolume *volume); +void pa_source_output_new_data_apply_volume_factor(pa_source_output_new_data *data, const pa_cvolume *volume_factor); +void pa_source_output_new_data_apply_volume_factor_source(pa_source_output_new_data *data, const pa_cvolume *volume_factor); +void pa_source_output_new_data_set_muted(pa_source_output_new_data *data, bool mute); +bool pa_source_output_new_data_set_source(pa_source_output_new_data *data, pa_source *s, bool save, + bool requested_by_application); +bool pa_source_output_new_data_set_formats(pa_source_output_new_data *data, pa_idxset *formats); +void pa_source_output_new_data_done(pa_source_output_new_data *data); + +/* To be called by the implementing module only */ + +int pa_source_output_new( + pa_source_output**o, + pa_core *core, + pa_source_output_new_data *data); + +void pa_source_output_put(pa_source_output *o); +void pa_source_output_unlink(pa_source_output*o); + +pa_usec_t pa_source_output_set_requested_latency(pa_source_output *o, pa_usec_t usec); + +void pa_source_output_cork(pa_source_output *o, bool b); + +int pa_source_output_set_rate(pa_source_output *o, uint32_t rate); +int pa_source_output_update_resampler(pa_source_output *o); + +size_t pa_source_output_get_max_rewind(pa_source_output *o); + +/* Callable by everyone */ + +/* External code may request disconnection with this function */ +void pa_source_output_kill(pa_source_output*o); + +pa_usec_t pa_source_output_get_latency(pa_source_output *o, pa_usec_t *source_latency); + +bool pa_source_output_is_volume_readable(pa_source_output *o); +bool pa_source_output_is_passthrough(pa_source_output *o); +void pa_source_output_set_volume(pa_source_output *o, const pa_cvolume *volume, bool save, bool absolute); +pa_cvolume *pa_source_output_get_volume(pa_source_output *o, pa_cvolume *volume, bool absolute); + +void pa_source_output_set_mute(pa_source_output *o, bool mute, bool save); + +void pa_source_output_set_property(pa_source_output *o, const char *key, const char *value); +void pa_source_output_set_property_arbitrary(pa_source_output *o, const char *key, const uint8_t *value, size_t nbytes); +void pa_source_output_update_proplist(pa_source_output *o, pa_update_mode_t mode, pa_proplist *p); + +pa_resample_method_t pa_source_output_get_resample_method(pa_source_output *o); + +void pa_source_output_send_event(pa_source_output *o, const char *name, pa_proplist *data); + +bool pa_source_output_may_move(pa_source_output *o); +bool pa_source_output_may_move_to(pa_source_output *o, pa_source *dest); +int pa_source_output_move_to(pa_source_output *o, pa_source *dest, bool save); + +/* The same as pa_source_output_move_to() but in two separate steps, + * first the detaching from the old source, then the attaching to the + * new source */ +int pa_source_output_start_move(pa_source_output *o); +int pa_source_output_finish_move(pa_source_output *o, pa_source *dest, bool save); +void pa_source_output_fail_move(pa_source_output *o); + +pa_usec_t pa_source_output_get_requested_latency(pa_source_output *o); + +/* To be used exclusively by the source driver thread */ + +void pa_source_output_push(pa_source_output *o, const pa_memchunk *chunk); +void pa_source_output_process_rewind(pa_source_output *o, size_t nbytes); +void pa_source_output_update_max_rewind(pa_source_output *o, size_t nbytes); + +void pa_source_output_set_state_within_thread(pa_source_output *o, pa_source_output_state_t state); + +int pa_source_output_process_msg(pa_msgobject *mo, int code, void *userdata, int64_t offset, pa_memchunk *chunk); + +pa_usec_t pa_source_output_set_requested_latency_within_thread(pa_source_output *o, pa_usec_t usec); + +/* Calls the attach() callback if it's set. The output must be in detached + * state. */ +void pa_source_output_attach(pa_source_output *o); + +/* Calls the detach() callback if it's set and the output is attached. The + * output is allowed to be already detached, in which case this does nothing. + * + * The reason why this can be called for already-detached outputs is that when + * a filter source's output is detached, it has to detach also all outputs + * connected to the filter source. In case the filter source's output was + * detached because the filter source is being removed, those other outputs + * will be moved to another source or removed, and moving and removing involve + * detaching the outputs, but the outputs at that point are already detached. + * + * XXX: Moving or removing an output also involves sending messages to the + * output's source. If the output's source is a detached filter source, + * shouldn't sending messages to it be prohibited? The messages are processed + * in the root source's IO thread, and when the filter source is detached, it + * would seem logical to prohibit any interaction with the IO thread that isn't + * any more associated with the filter source. Currently sending messages to + * detached filter sources mostly works, because the filter sources don't + * update their asyncmsgq pointer when detaching, so messages still find their + * way to the old IO thread. */ +void pa_source_output_detach(pa_source_output *o); + +/* Called from the main thread, from source.c only. The normal way to set the + * source output volume is to call pa_source_output_set_volume(), but the flat + * volume logic in source.c needs also a function that doesn't do all the extra + * stuff that pa_source_output_set_volume() does. This function simply sets + * o->volume and fires change notifications. */ +void pa_source_output_set_volume_direct(pa_source_output *o, const pa_cvolume *volume); + +/* Called from the main thread, from source.c only. This shouldn't be a public + * function, but the flat volume logic in source.c currently needs a way to + * directly set the source output reference ratio. This function simply sets + * o->reference_ratio and logs a message if the value changes. */ +void pa_source_output_set_reference_ratio(pa_source_output *o, const pa_cvolume *ratio); + +void pa_source_output_set_preferred_source(pa_source_output *o, pa_source *s); + +#define pa_source_output_assert_io_context(s) \ + pa_assert(pa_thread_mq_get() || !PA_SOURCE_OUTPUT_IS_LINKED((s)->state)) + +#endif diff --git a/pulse/pulsecore-14.0/source.h b/pulse/pulsecore-14.0/source.h new file mode 100644 index 00000000..aa45e6dd --- /dev/null +++ b/pulse/pulsecore-14.0/source.h @@ -0,0 +1,493 @@ +#ifndef foopulsesourcehfoo +#define foopulsesourcehfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PA_MAX_OUTPUTS_PER_SOURCE 256 + +/* Returns true if source is linked: registered and accessible from client side. */ +static inline bool PA_SOURCE_IS_LINKED(pa_source_state_t x) { + return x == PA_SOURCE_RUNNING || x == PA_SOURCE_IDLE || x == PA_SOURCE_SUSPENDED; +} + +/* A generic definition for void callback functions */ +typedef void(*pa_source_cb_t)(pa_source *s); + +typedef int (*pa_source_get_mute_cb_t)(pa_source *s, bool *mute); + +struct pa_source { + pa_msgobject parent; + + uint32_t index; + pa_core *core; + + pa_source_state_t state; + + /* Set in the beginning of pa_source_unlink() before setting the source + * state to UNLINKED. The purpose is to prevent moving streams to a source + * that is about to be removed. */ + bool unlink_requested; + + pa_source_flags_t flags; + pa_suspend_cause_t suspend_cause; + + char *name; + char *driver; /* may be NULL */ + pa_proplist *proplist; + + pa_module *module; /* may be NULL */ + pa_card *card; /* may be NULL */ + + pa_sample_spec sample_spec; + pa_channel_map channel_map; + uint32_t default_sample_rate; + uint32_t alternate_sample_rate; + bool avoid_resampling:1; + + pa_idxset *outputs; + unsigned n_corked; + pa_sink *monitor_of; /* may be NULL */ + pa_source_output *output_from_master; /* non-NULL only for filter sources */ + + pa_volume_t base_volume; /* shall be constant */ + unsigned n_volume_steps; /* shall be constant */ + + /* Also see http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/Developer/Volumes/ */ + pa_cvolume reference_volume; /* The volume exported and taken as reference base for relative source output volumes */ + pa_cvolume real_volume; /* The volume that the hardware is configured to */ + pa_cvolume soft_volume; /* The internal software volume we apply to all PCM data while it passes through */ + + bool muted:1; + + bool refresh_volume:1; + bool refresh_muted:1; + bool save_port:1; + bool save_volume:1; + bool save_muted:1; + + /* Saved volume state while we're in passthrough mode */ + pa_cvolume saved_volume; + bool saved_save_volume:1; + + pa_asyncmsgq *asyncmsgq; + + pa_memchunk silence; + + pa_hashmap *ports; + pa_device_port *active_port; + + /* The latency offset is inherited from the currently active port */ + int64_t port_latency_offset; + + unsigned priority; + + bool set_mute_in_progress; + + /* Callbacks for doing things when the source state and/or suspend cause is + * changed. It's fine to set either or both of the callbacks to NULL if the + * implementation doesn't have anything to do on state or suspend cause + * changes. + * + * set_state_in_main_thread() is called first. The callback is allowed to + * report failure if and only if the source changes its state from + * SUSPENDED to IDLE or RUNNING. (FIXME: It would make sense to allow + * failure also when changing state from INIT to IDLE or RUNNING, but + * currently that will crash pa_source_put().) If + * set_state_in_main_thread() fails, set_state_in_io_thread() won't be + * called. + * + * If set_state_in_main_thread() is successful (or not set), then + * set_state_in_io_thread() is called. Again, failure is allowed if and + * only if the source changes state from SUSPENDED to IDLE or RUNNING. If + * set_state_in_io_thread() fails, then set_state_in_main_thread() is + * called again, this time with the state parameter set to SUSPENDED and + * the suspend_cause parameter set to 0. + * + * pa_source.state, pa_source.thread_info.state and pa_source.suspend_cause + * are updated only after all the callback calls. In case of failure, the + * state is set to SUSPENDED and the suspend cause is set to 0. */ + int (*set_state_in_main_thread)(pa_source *s, pa_source_state_t state, pa_suspend_cause_t suspend_cause); /* may be NULL */ + int (*set_state_in_io_thread)(pa_source *s, pa_source_state_t state, pa_suspend_cause_t suspend_cause); /* may be NULL */ + + /* Called when the volume is queried. Called from main loop + * context. If this is NULL a PA_SOURCE_MESSAGE_GET_VOLUME message + * will be sent to the IO thread instead. If refresh_volume is + * false neither this function is called nor a message is sent. + * + * You must use the function pa_source_set_get_volume_callback() to + * set this callback. */ + pa_source_cb_t get_volume; /* may be NULL */ + + /* Called when the volume shall be changed. Called from main loop + * context. If this is NULL a PA_SOURCE_MESSAGE_SET_VOLUME message + * will be sent to the IO thread instead. + * + * You must use the function pa_source_set_set_volume_callback() to + * set this callback. */ + pa_source_cb_t set_volume; /* may be NULL */ + + /* Source drivers that set PA_SOURCE_DEFERRED_VOLUME must provide this + * callback. This callback is not used with source that do not set + * PA_SOURCE_DEFERRED_VOLUME. This is called from the IO thread when a + * pending hardware volume change has to be written to the + * hardware. The requested volume is passed to the callback + * implementation in s->thread_info.current_hw_volume. + * + * The call is done inside pa_source_volume_change_apply(), which is + * not called automatically - it is the driver's responsibility to + * schedule that function to be called at the right times in the + * IO thread. + * + * You must use the function pa_source_set_write_volume_callback() to + * set this callback. */ + pa_source_cb_t write_volume; /* may be NULL */ + + /* If the source mute can change "spontaneously" (i.e. initiated by the + * source implementation, not by someone else calling + * pa_source_set_mute()), then the source implementation can notify about + * changed mute either by calling pa_source_mute_changed() or by calling + * pa_source_get_mute() with force_refresh=true. If the implementation + * chooses the latter approach, it should implement the get_mute callback. + * Otherwise get_mute can be NULL. + * + * This is called when pa_source_get_mute() is called with + * force_refresh=true. This is called from the IO thread if the + * PA_SINK_DEFERRED_VOLUME flag is set, otherwise this is called from the + * main thread. On success, the implementation is expected to return 0 and + * set the mute parameter that is passed as a reference. On failure, the + * implementation is expected to return -1. + * + * You must use the function pa_source_set_get_mute_callback() to + * set this callback. */ + pa_source_get_mute_cb_t get_mute; + + /* Called when the mute setting shall be changed. Called from main + * loop context. If this is NULL a PA_SOURCE_MESSAGE_SET_MUTE + * message will be sent to the IO thread instead. + * + * You must use the function pa_source_set_set_mute_callback() to + * set this callback. */ + pa_source_cb_t set_mute; /* may be NULL */ + + /* Called when a the requested latency is changed. Called from IO + * thread context. */ + pa_source_cb_t update_requested_latency; /* may be NULL */ + + /* Called whenever the port shall be changed. Called from the main + * thread. */ + int (*set_port)(pa_source *s, pa_device_port *port); /*ditto */ + + /* Called to get the list of formats supported by the source, sorted + * in descending order of preference. */ + pa_idxset* (*get_formats)(pa_source *s); /* ditto */ + + /* Called whenever device parameters need to be changed. Called from + * main thread. */ + void (*reconfigure)(pa_source *s, pa_sample_spec *spec, bool passthrough); + + /* Contains copies of the above data so that the real-time worker + * thread can work without access locking */ + struct { + pa_source_state_t state; + pa_hashmap *outputs; + + pa_rtpoll *rtpoll; + + pa_cvolume soft_volume; + bool soft_muted:1; + + bool requested_latency_valid:1; + pa_usec_t requested_latency; + + /* Then number of bytes this source will be rewound for at + * max. (Only used on monitor sources) */ + size_t max_rewind; + + pa_usec_t min_latency; /* we won't go below this latency */ + pa_usec_t max_latency; /* An upper limit for the latencies */ + + pa_usec_t fixed_latency; /* for sources with PA_SOURCE_DYNAMIC_LATENCY this is 0 */ + + /* This latency offset is a direct copy from s->port_latency_offset */ + int64_t port_latency_offset; + + /* Delayed volume change events are queued here. The events + * are stored in expiration order. The one expiring next is in + * the head of the list. */ + PA_LLIST_HEAD(pa_source_volume_change, volume_changes); + pa_source_volume_change *volume_changes_tail; + /* This value is updated in pa_source_volume_change_apply() and + * used only by sources with PA_SOURCE_DEFERRED_VOLUME. */ + pa_cvolume current_hw_volume; + + /* The amount of usec volume up events are delayed and volume + * down events are made earlier. */ + uint32_t volume_change_safety_margin; + /* Usec delay added to all volume change events, may be negative. */ + int32_t volume_change_extra_delay; + } thread_info; + + void *userdata; +}; + +PA_DECLARE_PUBLIC_CLASS(pa_source); +#define PA_SOURCE(s) pa_source_cast(s) + +typedef enum pa_source_message { + PA_SOURCE_MESSAGE_ADD_OUTPUT, + PA_SOURCE_MESSAGE_REMOVE_OUTPUT, + PA_SOURCE_MESSAGE_GET_VOLUME, + PA_SOURCE_MESSAGE_SET_SHARED_VOLUME, + PA_SOURCE_MESSAGE_SET_VOLUME_SYNCED, + PA_SOURCE_MESSAGE_SET_VOLUME, + PA_SOURCE_MESSAGE_SYNC_VOLUMES, + PA_SOURCE_MESSAGE_GET_MUTE, + PA_SOURCE_MESSAGE_SET_MUTE, + PA_SOURCE_MESSAGE_GET_LATENCY, + PA_SOURCE_MESSAGE_GET_REQUESTED_LATENCY, + PA_SOURCE_MESSAGE_SET_STATE, + PA_SOURCE_MESSAGE_SET_LATENCY_RANGE, + PA_SOURCE_MESSAGE_GET_LATENCY_RANGE, + PA_SOURCE_MESSAGE_SET_FIXED_LATENCY, + PA_SOURCE_MESSAGE_GET_FIXED_LATENCY, + PA_SOURCE_MESSAGE_GET_MAX_REWIND, + PA_SOURCE_MESSAGE_SET_MAX_REWIND, + PA_SOURCE_MESSAGE_UPDATE_VOLUME_AND_MUTE, + PA_SOURCE_MESSAGE_SET_PORT_LATENCY_OFFSET, + PA_SOURCE_MESSAGE_MAX +} pa_source_message_t; + +typedef struct pa_source_new_data { + pa_suspend_cause_t suspend_cause; + + char *name; + pa_proplist *proplist; + + const char *driver; + pa_module *module; + pa_card *card; + + pa_hashmap *ports; + char *active_port; + + pa_sample_spec sample_spec; + pa_channel_map channel_map; + uint32_t alternate_sample_rate; + bool avoid_resampling:1; + pa_cvolume volume; + bool muted:1; + + bool volume_is_set:1; + bool muted_is_set:1; + bool sample_spec_is_set:1; + bool channel_map_is_set:1; + bool alternate_sample_rate_is_set:1; + bool avoid_resampling_is_set:1; + + bool namereg_fail:1; + + bool save_port:1; + bool save_volume:1; + bool save_muted:1; +} pa_source_new_data; + +pa_source_new_data* pa_source_new_data_init(pa_source_new_data *data); +void pa_source_new_data_set_name(pa_source_new_data *data, const char *name); +void pa_source_new_data_set_sample_spec(pa_source_new_data *data, const pa_sample_spec *spec); +void pa_source_new_data_set_channel_map(pa_source_new_data *data, const pa_channel_map *map); +void pa_source_new_data_set_alternate_sample_rate(pa_source_new_data *data, const uint32_t alternate_sample_rate); +void pa_source_new_data_set_avoid_resampling(pa_source_new_data *data, bool avoid_resampling); +void pa_source_new_data_set_volume(pa_source_new_data *data, const pa_cvolume *volume); +void pa_source_new_data_set_muted(pa_source_new_data *data, bool mute); +void pa_source_new_data_set_port(pa_source_new_data *data, const char *port); +void pa_source_new_data_done(pa_source_new_data *data); + +/*** To be called exclusively by the source driver, from main context */ + +pa_source* pa_source_new( + pa_core *core, + pa_source_new_data *data, + pa_source_flags_t flags); + +void pa_source_set_get_volume_callback(pa_source *s, pa_source_cb_t cb); +void pa_source_set_set_volume_callback(pa_source *s, pa_source_cb_t cb); +void pa_source_set_write_volume_callback(pa_source *s, pa_source_cb_t cb); +void pa_source_set_get_mute_callback(pa_source *s, pa_source_get_mute_cb_t cb); +void pa_source_set_set_mute_callback(pa_source *s, pa_source_cb_t cb); +void pa_source_enable_decibel_volume(pa_source *s, bool enable); + +void pa_source_put(pa_source *s); +void pa_source_unlink(pa_source *s); + +void pa_source_set_description(pa_source *s, const char *description); +void pa_source_set_asyncmsgq(pa_source *s, pa_asyncmsgq *q); +void pa_source_set_rtpoll(pa_source *s, pa_rtpoll *p); + +void pa_source_set_max_rewind(pa_source *s, size_t max_rewind); +void pa_source_set_latency_range(pa_source *s, pa_usec_t min_latency, pa_usec_t max_latency); +void pa_source_set_fixed_latency(pa_source *s, pa_usec_t latency); + +void pa_source_set_soft_volume(pa_source *s, const pa_cvolume *volume); +void pa_source_volume_changed(pa_source *s, const pa_cvolume *new_volume); +void pa_source_mute_changed(pa_source *s, bool new_muted); + +int pa_source_sync_suspend(pa_source *s); + +void pa_source_update_flags(pa_source *s, pa_source_flags_t mask, pa_source_flags_t value); + +/*** May be called by everyone, from main context */ + +void pa_source_set_port_latency_offset(pa_source *s, int64_t offset); + +/* The returned value is supposed to be in the time domain of the sound card! */ +pa_usec_t pa_source_get_latency(pa_source *s); +pa_usec_t pa_source_get_requested_latency(pa_source *s); +void pa_source_get_latency_range(pa_source *s, pa_usec_t *min_latency, pa_usec_t *max_latency); +pa_usec_t pa_source_get_fixed_latency(pa_source *s); + +size_t pa_source_get_max_rewind(pa_source *s); + +int pa_source_update_status(pa_source*s); +int pa_source_suspend(pa_source *s, bool suspend, pa_suspend_cause_t cause); +int pa_source_suspend_all(pa_core *c, bool suspend, pa_suspend_cause_t cause); + +/* Use this instead of checking s->flags & PA_SOURCE_FLAT_VOLUME directly. */ +bool pa_source_flat_volume_enabled(pa_source *s); + +/* Get the master source when sharing volumes */ +pa_source *pa_source_get_master(pa_source *s); + +bool pa_source_is_filter(pa_source *s); + +/* Is the source in passthrough mode? (that is, is this a monitor source for a sink + * that has a passthrough sink input connected to it. */ +bool pa_source_is_passthrough(pa_source *s); +/* These should be called when a source enters/leaves passthrough mode */ +void pa_source_enter_passthrough(pa_source *s); +void pa_source_leave_passthrough(pa_source *s); + +void pa_source_set_volume(pa_source *source, const pa_cvolume *volume, bool sendmsg, bool save); +const pa_cvolume *pa_source_get_volume(pa_source *source, bool force_refresh); + +void pa_source_set_mute(pa_source *source, bool mute, bool save); +bool pa_source_get_mute(pa_source *source, bool force_refresh); + +bool pa_source_update_proplist(pa_source *s, pa_update_mode_t mode, pa_proplist *p); + +int pa_source_set_port(pa_source *s, const char *name, bool save); + +void pa_source_reconfigure(pa_source *s, pa_sample_spec *spec, bool passthrough); + +unsigned pa_source_linked_by(pa_source *s); /* Number of connected streams */ +unsigned pa_source_used_by(pa_source *s); /* Number of connected streams that are not corked */ + +/* Returns how many streams are active that don't allow suspensions. If + * "ignore" is non-NULL, that stream is not included in the count. */ +unsigned pa_source_check_suspend(pa_source *s, pa_source_output *ignore); + +const char *pa_source_state_to_string(pa_source_state_t state); + +/* Moves all inputs away, and stores them in pa_queue */ +pa_queue *pa_source_move_all_start(pa_source *s, pa_queue *q); +void pa_source_move_all_finish(pa_source *s, pa_queue *q, bool save); +void pa_source_move_all_fail(pa_queue *q); + +/* Returns a copy of the source formats. TODO: Get rid of this function (or at + * least get rid of the copying). There's no good reason to copy the formats + * every time someone wants to know what formats the source supports. The + * formats idxset could be stored directly in the pa_source struct. + * https://bugs.freedesktop.org/show_bug.cgi?id=71924 */ +pa_idxset* pa_source_get_formats(pa_source *s); + +bool pa_source_check_format(pa_source *s, pa_format_info *f); +pa_idxset* pa_source_check_formats(pa_source *s, pa_idxset *in_formats); + +void pa_source_set_sample_format(pa_source *s, pa_sample_format_t format); +void pa_source_set_sample_rate(pa_source *s, uint32_t rate); + +/*** To be called exclusively by the source driver, from IO context */ + +void pa_source_post(pa_source*s, const pa_memchunk *chunk); +void pa_source_post_direct(pa_source*s, pa_source_output *o, const pa_memchunk *chunk); +void pa_source_process_rewind(pa_source *s, size_t nbytes); + +int pa_source_process_msg(pa_msgobject *o, int code, void *userdata, int64_t, pa_memchunk *chunk); + +void pa_source_attach_within_thread(pa_source *s); +void pa_source_detach_within_thread(pa_source *s); + +pa_usec_t pa_source_get_requested_latency_within_thread(pa_source *s); + +void pa_source_set_max_rewind_within_thread(pa_source *s, size_t max_rewind); + +void pa_source_set_latency_range_within_thread(pa_source *s, pa_usec_t min_latency, pa_usec_t max_latency); +void pa_source_set_fixed_latency_within_thread(pa_source *s, pa_usec_t latency); + +void pa_source_update_volume_and_mute(pa_source *s); + +bool pa_source_volume_change_apply(pa_source *s, pa_usec_t *usec_to_next); + +/*** To be called exclusively by source output drivers, from IO context */ + +void pa_source_invalidate_requested_latency(pa_source *s, bool dynamic); +int64_t pa_source_get_latency_within_thread(pa_source *s, bool allow_negative); + +/* Called from the main thread, from source-output.c only. The normal way to + * set the source reference volume is to call pa_source_set_volume(), but the + * flat volume logic in source-output.c needs also a function that doesn't do + * all the extra stuff that pa_source_set_volume() does. This function simply + * sets s->reference_volume and fires change notifications. */ +void pa_source_set_reference_volume_direct(pa_source *s, const pa_cvolume *volume); + +/* When the default_source is changed or the active_port of a source is changed to + * PA_AVAILABLE_NO, this function is called to move the streams of the old + * default_source or the source with active_port equals PA_AVAILABLE_NO to the + * current default_source conditionally*/ +void pa_source_move_streams_to_default_source(pa_core *core, pa_source *old_source, bool default_source_changed); + +#define pa_source_assert_io_context(s) \ + pa_assert(pa_thread_mq_get() || !PA_SOURCE_IS_LINKED((s)->state)) + +#endif diff --git a/pulse/pulsecore-14.0/srbchannel.h b/pulse/pulsecore-14.0/srbchannel.h new file mode 100644 index 00000000..09193e0f --- /dev/null +++ b/pulse/pulsecore-14.0/srbchannel.h @@ -0,0 +1,57 @@ +#ifndef foopulsesrbchannelhfoo +#define foopulsesrbchannelhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2014 David Henningsson, Canonical Ltd. + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include +#include +#include + +/* An shm ringbuffer that is used for low overhead server-client communication. + * Signaling is done through eventfd semaphores (pa_fdsem). */ + +typedef struct pa_srbchannel pa_srbchannel; + +typedef struct pa_srbchannel_template { + int readfd, writefd; + pa_memblock *memblock; +} pa_srbchannel_template; + +pa_srbchannel* pa_srbchannel_new(pa_mainloop_api *m, pa_mempool *p); +/* Note: this creates a srbchannel with swapped read and write. */ +pa_srbchannel* pa_srbchannel_new_from_template(pa_mainloop_api *m, pa_srbchannel_template *t); + +void pa_srbchannel_free(pa_srbchannel *sr); + +void pa_srbchannel_export(pa_srbchannel *sr, pa_srbchannel_template *t); + +size_t pa_srbchannel_write(pa_srbchannel *sr, const void *data, size_t l); +size_t pa_srbchannel_read(pa_srbchannel *sr, void *data, size_t l); + +/* Set the callback function that is called whenever data becomes available for reading. + * It can also be called if the output buffer was full and can now be written to. + * + * Return false to abort all processing (e g if the srbchannel has been freed during the callback). + * Otherwise return true. +*/ +typedef bool (*pa_srbchannel_cb_t)(pa_srbchannel *sr, void *userdata); +void pa_srbchannel_set_callback(pa_srbchannel *sr, pa_srbchannel_cb_t callback, void *userdata); + +#endif diff --git a/pulse/pulsecore-14.0/start-child.h b/pulse/pulsecore-14.0/start-child.h new file mode 100644 index 00000000..6222f456 --- /dev/null +++ b/pulse/pulsecore-14.0/start-child.h @@ -0,0 +1,28 @@ +#ifndef foopulsestartchildhfoo +#define foopulsestartchildhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2007 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include +#include + +int pa_start_child_for_read(const char *name, const char *argv1, pid_t *pid); + +#endif diff --git a/pulse/pulsecore-14.0/strbuf.h b/pulse/pulsecore-14.0/strbuf.h new file mode 100644 index 00000000..469f6f78 --- /dev/null +++ b/pulse/pulsecore-14.0/strbuf.h @@ -0,0 +1,40 @@ +#ifndef foostrbufhfoo +#define foostrbufhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include + +typedef struct pa_strbuf pa_strbuf; + +pa_strbuf *pa_strbuf_new(void); +void pa_strbuf_free(pa_strbuf *sb); +char *pa_strbuf_to_string(pa_strbuf *sb); +char *pa_strbuf_to_string_free(pa_strbuf *sb); + +size_t pa_strbuf_printf(pa_strbuf *sb, const char *format, ...) PA_GCC_PRINTF_ATTR(2,3); +void pa_strbuf_puts(pa_strbuf *sb, const char *t); +void pa_strbuf_putsn(pa_strbuf *sb, const char *t, size_t m); +void pa_strbuf_putc(pa_strbuf *sb, char c); + +bool pa_strbuf_isempty(pa_strbuf *sb); + +#endif diff --git a/pulse/pulsecore-14.0/stream-util.h b/pulse/pulsecore-14.0/stream-util.h new file mode 100644 index 00000000..b2e47fe4 --- /dev/null +++ b/pulse/pulsecore-14.0/stream-util.h @@ -0,0 +1,48 @@ +#ifndef foostreamutilhfoo +#define foostreamutilhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2013 Intel Corporation + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include + +/* This is a helper function that is called from pa_sink_input_new() and + * pa_source_output_new(). The job of this function is to figure out what + * channel map should be used for interpreting the volume that was set for the + * stream. The channel map that the client intended for the volume may be + * different than the final stream channel map, because the client may want the + * server to decide the stream channel map. + * + * volume is the volume for which the channel map should be figured out. + * + * original_map is the channel map that is set in the new data struct's + * channel_map field. If the channel map hasn't been set in the new data, then + * original_map should be NULL. + * + * format is the negotiated format for the stream. It's used as a fallback if + * original_map is not available. + * + * On success, the result is saved in volume_map. It's possible that this + * function fails to figure out the right channel map for the volume, in which + * case a negative error code is returned. */ +int pa_stream_get_volume_channel_map(const pa_cvolume *volume, const pa_channel_map *original_map, const pa_format_info *format, + pa_channel_map *volume_map); + +#endif diff --git a/pulse/pulsecore-14.0/strlist.h b/pulse/pulsecore-14.0/strlist.h new file mode 100644 index 00000000..3cc71e80 --- /dev/null +++ b/pulse/pulsecore-14.0/strlist.h @@ -0,0 +1,54 @@ +#ifndef foostrlisthfoo +#define foostrlisthfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +typedef struct pa_strlist pa_strlist; + +/* Add the specified server string to the list, return the new linked list head */ +pa_strlist* pa_strlist_prepend(pa_strlist *l, const char *s); + +/* Remove the specified string from the list, return the new linked list head */ +pa_strlist* pa_strlist_remove(pa_strlist *l, const char *s); + +/* Make a whitespace separated string of all server strings. Returned memory has to be freed with pa_xfree() */ +char *pa_strlist_to_string(pa_strlist *l); + +/* Free the entire list */ +void pa_strlist_free(pa_strlist *l); + +/* Return the next entry in the list in *string and remove it from + * the list. Returns the new list head. The memory *string points to + * has to be freed with pa_xfree() */ +pa_strlist* pa_strlist_pop(pa_strlist *l, char **s); + +/* Parse a whitespace separated server list */ +pa_strlist* pa_strlist_parse(const char *s); + +/* Reverse string list */ +pa_strlist *pa_strlist_reverse(pa_strlist *l); + +/* Return the next item in the list */ +pa_strlist *pa_strlist_next(pa_strlist *s); + +/* Return the string associated to the current item */ +const char *pa_strlist_data(pa_strlist *s); + +#endif diff --git a/pulse/pulsecore-14.0/tagstruct.h b/pulse/pulsecore-14.0/tagstruct.h new file mode 100644 index 00000000..dcb51cbf --- /dev/null +++ b/pulse/pulsecore-14.0/tagstruct.h @@ -0,0 +1,106 @@ +#ifndef footagstructhfoo +#define footagstructhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +typedef struct pa_tagstruct pa_tagstruct; + +/* Due to a stupid design flaw, proplists may only be at the END of a + * packet or not before a STRING! Don't forget that! We can't really + * fix this without breaking compat. */ + +enum { + PA_TAG_INVALID = 0, + PA_TAG_STRING = 't', + PA_TAG_STRING_NULL = 'N', + PA_TAG_U32 = 'L', + PA_TAG_U8 = 'B', + PA_TAG_U64 = 'R', + PA_TAG_S64 = 'r', + PA_TAG_SAMPLE_SPEC = 'a', + PA_TAG_ARBITRARY = 'x', + PA_TAG_BOOLEAN_TRUE = '1', + PA_TAG_BOOLEAN_FALSE = '0', + PA_TAG_BOOLEAN = PA_TAG_BOOLEAN_TRUE, + PA_TAG_TIMEVAL = 'T', + PA_TAG_USEC = 'U' /* 64bit unsigned */, + PA_TAG_CHANNEL_MAP = 'm', + PA_TAG_CVOLUME = 'v', + PA_TAG_PROPLIST = 'P', + PA_TAG_VOLUME = 'V', + PA_TAG_FORMAT_INFO = 'f', +}; + +pa_tagstruct *pa_tagstruct_new(void); +pa_tagstruct *pa_tagstruct_new_fixed(const uint8_t* data, size_t length); +void pa_tagstruct_free(pa_tagstruct*t); + +int pa_tagstruct_eof(pa_tagstruct*t); +const uint8_t* pa_tagstruct_data(pa_tagstruct*t, size_t *l); + +void pa_tagstruct_put(pa_tagstruct *t, ...); + +void pa_tagstruct_puts(pa_tagstruct*t, const char *s); +void pa_tagstruct_putu8(pa_tagstruct*t, uint8_t c); +void pa_tagstruct_putu32(pa_tagstruct*t, uint32_t i); +void pa_tagstruct_putu64(pa_tagstruct*t, uint64_t i); +void pa_tagstruct_puts64(pa_tagstruct*t, int64_t i); +void pa_tagstruct_put_sample_spec(pa_tagstruct *t, const pa_sample_spec *ss); +void pa_tagstruct_put_arbitrary(pa_tagstruct*t, const void *p, size_t length); +void pa_tagstruct_put_boolean(pa_tagstruct*t, bool b); +void pa_tagstruct_put_timeval(pa_tagstruct*t, const struct timeval *tv); +void pa_tagstruct_put_usec(pa_tagstruct*t, pa_usec_t u); +void pa_tagstruct_put_channel_map(pa_tagstruct *t, const pa_channel_map *map); +void pa_tagstruct_put_cvolume(pa_tagstruct *t, const pa_cvolume *cvolume); +void pa_tagstruct_put_proplist(pa_tagstruct *t, const pa_proplist *p); +void pa_tagstruct_put_volume(pa_tagstruct *t, pa_volume_t volume); +void pa_tagstruct_put_format_info(pa_tagstruct *t, const pa_format_info *f); + +int pa_tagstruct_get(pa_tagstruct *t, ...); + +int pa_tagstruct_gets(pa_tagstruct*t, const char **s); +int pa_tagstruct_getu8(pa_tagstruct*t, uint8_t *c); +int pa_tagstruct_getu32(pa_tagstruct*t, uint32_t *i); +int pa_tagstruct_getu64(pa_tagstruct*t, uint64_t *i); +int pa_tagstruct_gets64(pa_tagstruct*t, int64_t *i); +int pa_tagstruct_get_sample_spec(pa_tagstruct *t, pa_sample_spec *ss); +int pa_tagstruct_get_arbitrary(pa_tagstruct *t, const void **p, size_t length); +int pa_tagstruct_get_boolean(pa_tagstruct *t, bool *b); +int pa_tagstruct_get_timeval(pa_tagstruct*t, struct timeval *tv); +int pa_tagstruct_get_usec(pa_tagstruct*t, pa_usec_t *u); +int pa_tagstruct_get_channel_map(pa_tagstruct *t, pa_channel_map *map); +int pa_tagstruct_get_cvolume(pa_tagstruct *t, pa_cvolume *v); +int pa_tagstruct_get_proplist(pa_tagstruct *t, pa_proplist *p); +int pa_tagstruct_get_volume(pa_tagstruct *t, pa_volume_t *v); +int pa_tagstruct_get_format_info(pa_tagstruct *t, pa_format_info *f); + +#endif diff --git a/pulse/pulsecore-14.0/thread-mq.h b/pulse/pulsecore-14.0/thread-mq.h new file mode 100644 index 00000000..f6daa7fe --- /dev/null +++ b/pulse/pulsecore-14.0/thread-mq.h @@ -0,0 +1,57 @@ +#ifndef foopulsethreadmqhfoo +#define foopulsethreadmqhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include +#include +#include + +/* Two way communication between a thread and a mainloop. Before the + * thread is started a pa_thread_mq should be initialized and than + * attached to the thread using pa_thread_mq_install(). */ + +typedef struct pa_thread_mq { + pa_mainloop_api *main_mainloop; + pa_mainloop_api *thread_mainloop; + pa_asyncmsgq *inq, *outq; + pa_io_event *read_main_event, *write_main_event; + pa_io_event *read_thread_event, *write_thread_event; +} pa_thread_mq; + +int pa_thread_mq_init(pa_thread_mq *q, pa_mainloop_api *mainloop, pa_rtpoll *rtpoll); +int pa_thread_mq_init_thread_mainloop(pa_thread_mq *q, pa_mainloop_api *main_mainloop, pa_mainloop_api *thread_mainloop); +void pa_thread_mq_done(pa_thread_mq *q); + +/* Install the specified pa_thread_mq object for the current thread */ +void pa_thread_mq_install(pa_thread_mq *q); + +/* Return the pa_thread_mq object that is set for the current thread */ +pa_thread_mq *pa_thread_mq_get(void); + +/* Verify that we are in control context (aka 'main context'). */ +#define pa_assert_ctl_context(s) \ + pa_assert(!pa_thread_mq_get()) + +/* Verify that we are in IO context (aka 'thread context'). */ +#define pa_assert_io_context(s) \ + pa_assert(pa_thread_mq_get()) + +#endif diff --git a/pulse/pulsecore-14.0/thread.h b/pulse/pulsecore-14.0/thread.h new file mode 100644 index 00000000..8a145582 --- /dev/null +++ b/pulse/pulsecore-14.0/thread.h @@ -0,0 +1,117 @@ +#ifndef foopulsethreadhfoo +#define foopulsethreadhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include +#include + +#include +#include + +#ifndef PACKAGE +#error "Please include config.h before including this file!" +#endif + +typedef struct pa_thread pa_thread; + +typedef void (*pa_thread_func_t) (void *userdata); + +pa_thread* pa_thread_new(const char *name, pa_thread_func_t thread_func, void *userdata); +void pa_thread_free(pa_thread *t); +void pa_thread_free_nojoin(pa_thread *t); +int pa_thread_join(pa_thread *t); +int pa_thread_is_running(pa_thread *t); +pa_thread *pa_thread_self(void); +void pa_thread_yield(void); + +void* pa_thread_get_data(pa_thread *t); +void pa_thread_set_data(pa_thread *t, void *userdata); + +const char *pa_thread_get_name(pa_thread *t); +void pa_thread_set_name(pa_thread *t, const char *name); + +typedef struct pa_tls pa_tls; + +pa_tls* pa_tls_new(pa_free_cb_t free_cb); +void pa_tls_free(pa_tls *t); +void * pa_tls_get(pa_tls *t); +void *pa_tls_set(pa_tls *t, void *userdata); + +#define PA_STATIC_TLS_DECLARE(name, free_cb) \ + static struct { \ + pa_once once; \ + pa_tls *volatile tls; \ + } name##_tls = { \ + .once = PA_ONCE_INIT, \ + .tls = NULL \ + }; \ + static void name##_tls_init(void) { \ + name##_tls.tls = pa_tls_new(free_cb); \ + } \ + static inline pa_tls* name##_tls_obj(void) { \ + pa_run_once(&name##_tls.once, name##_tls_init); \ + return name##_tls.tls; \ + } \ + static void name##_tls_destructor(void) PA_GCC_DESTRUCTOR; \ + static void name##_tls_destructor(void) { \ + static void (*_free_cb)(void*) = free_cb; \ + if (!pa_in_valgrind()) \ + return; \ + if (!name##_tls.tls) \ + return; \ + if (_free_cb) { \ + void *p; \ + if ((p = pa_tls_get(name##_tls.tls))) \ + _free_cb(p); \ + } \ + pa_tls_free(name##_tls.tls); \ + } \ + static inline void* name##_tls_get(void) { \ + return pa_tls_get(name##_tls_obj()); \ + } \ + static inline void* name##_tls_set(void *p) { \ + return pa_tls_set(name##_tls_obj(), p); \ + } \ + struct __stupid_useless_struct_to_allow_trailing_semicolon + +#if defined(SUPPORT_TLS___THREAD) && !defined(OS_IS_WIN32) +/* An optimized version of the above that requires no dynamic + * allocation if the compiler supports __thread */ +#define PA_STATIC_TLS_DECLARE_NO_FREE(name) \ + static __thread void *name##_tls = NULL; \ + static inline void* name##_tls_get(void) { \ + return name##_tls; \ + } \ + static inline void* name##_tls_set(void *p) { \ + void *r = name##_tls; \ + name##_tls = p; \ + return r; \ + } \ + struct __stupid_useless_struct_to_allow_trailing_semicolon +#else +#define PA_STATIC_TLS_DECLARE_NO_FREE(name) PA_STATIC_TLS_DECLARE(name, NULL) +#endif + +#define PA_STATIC_TLS_GET(name) (name##_tls_get()) +#define PA_STATIC_TLS_SET(name, p) (name##_tls_set(p)) + +#endif diff --git a/pulse/pulsecore-14.0/time-smoother.h b/pulse/pulsecore-14.0/time-smoother.h new file mode 100644 index 00000000..49ae08c9 --- /dev/null +++ b/pulse/pulsecore-14.0/time-smoother.h @@ -0,0 +1,57 @@ +#ifndef foopulsetimesmootherhfoo +#define foopulsetimesmootherhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2007 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include +#include + +typedef struct pa_smoother pa_smoother; + +pa_smoother* pa_smoother_new( + pa_usec_t x_adjust_time, + pa_usec_t x_history_time, + bool monotonic, + bool smoothing, + unsigned min_history, + pa_usec_t x_offset, + bool paused); + +void pa_smoother_free(pa_smoother* s); + +/* Adds a new value to our dataset. x = local/system time, y = remote time */ +void pa_smoother_put(pa_smoother *s, pa_usec_t x, pa_usec_t y); + +/* Returns an interpolated value based on the dataset. x = local/system time, return value = remote time */ +pa_usec_t pa_smoother_get(pa_smoother *s, pa_usec_t x); + +/* Translates a time span from the remote time domain to the local one. x = local/system time when to estimate, y_delay = remote time span */ +pa_usec_t pa_smoother_translate(pa_smoother *s, pa_usec_t x, pa_usec_t y_delay); + +void pa_smoother_set_time_offset(pa_smoother *s, pa_usec_t x_offset); + +void pa_smoother_pause(pa_smoother *s, pa_usec_t x); +void pa_smoother_resume(pa_smoother *s, pa_usec_t x, bool abrupt); + +void pa_smoother_reset(pa_smoother *s, pa_usec_t time_offset, bool paused); + +void pa_smoother_fix_now(pa_smoother *s); + +#endif diff --git a/pulse/pulsecore-14.0/tokenizer.h b/pulse/pulsecore-14.0/tokenizer.h new file mode 100644 index 00000000..806d40cb --- /dev/null +++ b/pulse/pulsecore-14.0/tokenizer.h @@ -0,0 +1,30 @@ +#ifndef footokenizerhfoo +#define footokenizerhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +typedef struct pa_tokenizer pa_tokenizer; + +pa_tokenizer* pa_tokenizer_new(const char *s, unsigned args); +void pa_tokenizer_free(pa_tokenizer *t); + +const char *pa_tokenizer_get(pa_tokenizer *t, unsigned i); + +#endif diff --git a/pulse/pulsecore-14.0/typedefs.h b/pulse/pulsecore-14.0/typedefs.h new file mode 100644 index 00000000..3652f8f7 --- /dev/null +++ b/pulse/pulsecore-14.0/typedefs.h @@ -0,0 +1,37 @@ +#ifndef footypedefshfoo +#define footypedefshfoo + +/*** + This file is part of PulseAudio. + + Copyright 2015 Canonical Ltd. + Written by David Henningsson + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +typedef struct pa_card pa_card; +typedef struct pa_card_profile pa_card_profile; +typedef struct pa_client pa_client; +typedef struct pa_core pa_core; +typedef struct pa_device_port pa_device_port; +typedef struct pa_sink pa_sink; +typedef struct pa_sink_volume_change pa_sink_volume_change; +typedef struct pa_sink_input pa_sink_input; +typedef struct pa_source pa_source; +typedef struct pa_source_volume_change pa_source_volume_change; +typedef struct pa_source_output pa_source_output; + + +#endif diff --git a/pulse/pulsecore-14.0/usergroup.h b/pulse/pulsecore-14.0/usergroup.h new file mode 100644 index 00000000..09450593 --- /dev/null +++ b/pulse/pulsecore-14.0/usergroup.h @@ -0,0 +1,49 @@ +#ifndef foousergrouphfoo +#define foousergrouphfoo + +/*** + This file is part of PulseAudio. + + Copyright 2009 Ted Percival + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, see . +***/ + +#include + +#ifndef PACKAGE +#error "Please include config.h before including this file!" +#endif + +#ifdef HAVE_GRP_H + +struct group *pa_getgrgid_malloc(gid_t gid); +void pa_getgrgid_free(struct group *grp); + +struct group *pa_getgrnam_malloc(const char *name); +void pa_getgrnam_free(struct group *group); + +#endif /* HAVE_GRP_H */ + +#ifdef HAVE_PWD_H + +struct passwd *pa_getpwuid_malloc(uid_t uid); +void pa_getpwuid_free(struct passwd *passwd); + +struct passwd *pa_getpwnam_malloc(const char *name); +void pa_getpwnam_free(struct passwd *passwd); + +#endif /* HAVE_PWD_H */ + +#endif /* foousergrouphfoo */ diff --git a/pulse/pulsecore-14.0/winerrno.h b/pulse/pulsecore-14.0/winerrno.h new file mode 100644 index 00000000..052d4de2 --- /dev/null +++ b/pulse/pulsecore-14.0/winerrno.h @@ -0,0 +1,89 @@ + +/* Generated with: +cat /usr/i686-pc-mingw32/sys-root/mingw/include/winerror.h \ + | awk '/#define WSAE.*WSABASE/{gsub("WSA", ""); print "#undef " $2 "\n#define " $2 " WSA" $2}' \ + | egrep -v 'EINTR|EBADF|EACCES|EFAULT|EINVAL|EMFILE|_QOS|PROVIDER|PROCTABLE' +*/ + +#undef EWOULDBLOCK +#define EWOULDBLOCK WSAEWOULDBLOCK +#undef EINPROGRESS +#define EINPROGRESS WSAEINPROGRESS +#undef EALREADY +#define EALREADY WSAEALREADY +#undef ENOTSOCK +#define ENOTSOCK WSAENOTSOCK +#undef EDESTADDRREQ +#define EDESTADDRREQ WSAEDESTADDRREQ +#undef EMSGSIZE +#define EMSGSIZE WSAEMSGSIZE +#undef EPROTOTYPE +#define EPROTOTYPE WSAEPROTOTYPE +#undef ENOPROTOOPT +#define ENOPROTOOPT WSAENOPROTOOPT +#undef EPROTONOSUPPORT +#define EPROTONOSUPPORT WSAEPROTONOSUPPORT +#undef ESOCKTNOSUPPORT +#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT +#undef EOPNOTSUPP +#define EOPNOTSUPP WSAEOPNOTSUPP +#undef EPFNOSUPPORT +#define EPFNOSUPPORT WSAEPFNOSUPPORT +#undef EAFNOSUPPORT +#define EAFNOSUPPORT WSAEAFNOSUPPORT +#undef EADDRINUSE +#define EADDRINUSE WSAEADDRINUSE +#undef EADDRNOTAVAIL +#define EADDRNOTAVAIL WSAEADDRNOTAVAIL +#undef ENETDOWN +#define ENETDOWN WSAENETDOWN +#undef ENETUNREACH +#define ENETUNREACH WSAENETUNREACH +#undef ENETRESET +#define ENETRESET WSAENETRESET +#undef ECONNABORTED +#define ECONNABORTED WSAECONNABORTED +#undef ECONNRESET +#define ECONNRESET WSAECONNRESET +#undef ENOBUFS +#define ENOBUFS WSAENOBUFS +#undef EISCONN +#define EISCONN WSAEISCONN +#undef ENOTCONN +#define ENOTCONN WSAENOTCONN +#undef ESHUTDOWN +#define ESHUTDOWN WSAESHUTDOWN +#undef ETOOMANYREFS +#define ETOOMANYREFS WSAETOOMANYREFS +#undef ETIMEDOUT +#define ETIMEDOUT WSAETIMEDOUT +#undef ECONNREFUSED +#define ECONNREFUSED WSAECONNREFUSED +#undef ELOOP +#define ELOOP WSAELOOP +#undef ENAMETOOLONG +#define ENAMETOOLONG WSAENAMETOOLONG +#undef EHOSTDOWN +#define EHOSTDOWN WSAEHOSTDOWN +#undef EHOSTUNREACH +#define EHOSTUNREACH WSAEHOSTUNREACH +#undef ENOTEMPTY +#define ENOTEMPTY WSAENOTEMPTY +#undef EPROCLIM +#define EPROCLIM WSAEPROCLIM +#undef EUSERS +#define EUSERS WSAEUSERS +#undef EDQUOT +#define EDQUOT WSAEDQUOT +#undef ESTALE +#define ESTALE WSAESTALE +#undef EREMOTE +#define EREMOTE WSAEREMOTE +#undef EDISCON +#define EDISCON WSAEDISCON +#undef ENOMORE +#define ENOMORE WSAENOMORE +#undef ECANCELLED +#define ECANCELLED WSAECANCELLED +#undef EREFUSED +#define EREFUSED WSAEREFUSED diff --git a/pulse/pulsecore-14.0/x11prop.h b/pulse/pulsecore-14.0/x11prop.h new file mode 100644 index 00000000..2b9d3f12 --- /dev/null +++ b/pulse/pulsecore-14.0/x11prop.h @@ -0,0 +1,32 @@ +#ifndef foox11prophfoo +#define foox11prophfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + Copyright 2010 Colin Guthrie + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include + +#include + +void pa_x11_set_prop(xcb_connection_t *xcb, int screen, const char *name, const char *data); +void pa_x11_del_prop(xcb_connection_t *xcb, int screen, const char *name); +char* pa_x11_get_prop(xcb_connection_t *xcb, int screen, const char *name, char *p, size_t l); + +#endif diff --git a/pulse/pulsecore-14.0/x11wrap.h b/pulse/pulsecore-14.0/x11wrap.h new file mode 100644 index 00000000..0539303c --- /dev/null +++ b/pulse/pulsecore-14.0/x11wrap.h @@ -0,0 +1,60 @@ +#ifndef foox11wraphfoo +#define foox11wraphfoo + +/*** + This file is part of PulseAudio. + + Copyright 2004-2006 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see . +***/ + +#include +#include + +#include + +typedef struct pa_x11_wrapper pa_x11_wrapper; + +typedef struct pa_x11_client pa_x11_client; + +typedef int (*pa_x11_event_cb_t)(pa_x11_wrapper *w, XEvent *e, void *userdata); +typedef void (*pa_x11_kill_cb_t)(pa_x11_wrapper *w, void *userdata); + +/* Return the X11 wrapper for this core. In case no wrapper was + existent before, allocate a new one */ +pa_x11_wrapper* pa_x11_wrapper_get(pa_core *c, const char *name); + +/* Increase the wrapper's reference count by one */ +pa_x11_wrapper* pa_x11_wrapper_ref(pa_x11_wrapper *w); + +/* Decrease the reference counter of an X11 wrapper object */ +void pa_x11_wrapper_unref(pa_x11_wrapper* w); + +/* Return the X11 display object for this connection */ +Display *pa_x11_wrapper_get_display(pa_x11_wrapper *w); + +/* Return the XCB connection object for this connection */ +xcb_connection_t *pa_x11_wrapper_get_xcb_connection(pa_x11_wrapper *w); + +/* Kill the connection to the X11 display */ +void pa_x11_wrapper_kill(pa_x11_wrapper *w); + +/* Register an X11 client, that is called for each X11 event */ +pa_x11_client* pa_x11_client_new(pa_x11_wrapper *w, pa_x11_event_cb_t event_cb, pa_x11_kill_cb_t kill_cb, void *userdata); + +/* Free an X11 client object */ +void pa_x11_client_free(pa_x11_client *c); + +#endif diff --git a/rpm_spec/gui-agent.spec.in b/rpm_spec/gui-agent.spec.in index 231a280a..6d550882 100644 --- a/rpm_spec/gui-agent.spec.in +++ b/rpm_spec/gui-agent.spec.in @@ -46,7 +46,7 @@ BuildRequires: libXdamage-devel BuildRequires: libXfixes-devel BuildRequires: libXt-devel BuildRequires: libtool-ltdl-devel -BuildRequires: pulseaudio-libs-devel >= 0.9.21, pulseaudio-libs-devel <= 13.99.2 +BuildRequires: pulseaudio-libs-devel >= 0.9.21, pulseaudio-libs-devel <= 14.0 BuildRequires: xorg-x11-server-devel BuildRequires: pam-devel BuildRequires: qubes-libvchan-devel