├── .gitignore ├── .mailmap ├── GPL ├── LGPL ├── LICENSE ├── README.md ├── bindings.zig ├── build.zig ├── build.zig.zon ├── example └── sine.zig └── src ├── pulse ├── cdecl.h ├── channelmap.c ├── channelmap.h ├── client-conf-x11.c ├── client-conf-x11.h ├── client-conf.c ├── client-conf.h ├── client.conf.in ├── context.c ├── context.h ├── def.h ├── direction.c ├── direction.h ├── error.c ├── error.h ├── ext-device-manager.c ├── ext-device-manager.h ├── ext-device-restore.c ├── ext-device-restore.h ├── ext-stream-restore.c ├── ext-stream-restore.h ├── fork-detect.c ├── fork-detect.h ├── format.c ├── format.h ├── gccmacro.h ├── glib-mainloop.c ├── glib-mainloop.h ├── internal.h ├── introspect.c ├── introspect.h ├── mainloop-api.c ├── mainloop-api.h ├── mainloop-signal.c ├── mainloop-signal.h ├── mainloop.c ├── mainloop.h ├── map-file ├── operation.c ├── operation.h ├── proplist.c ├── proplist.h ├── pulseaudio.h ├── rtclock.c ├── rtclock.h ├── sample.c ├── sample.h ├── scache.c ├── scache.h ├── simple.c ├── simple.h ├── stream.c ├── stream.h ├── subscribe.c ├── subscribe.h ├── thread-mainloop.c ├── thread-mainloop.h ├── timeval.c ├── timeval.h ├── utf8.c ├── utf8.h ├── util.c ├── util.h ├── version.h.in ├── volume.c ├── volume.h ├── xmalloc.c └── xmalloc.h └── pulsecore ├── arpa-inet.c ├── arpa-inet.h ├── asyncmsgq.c ├── asyncmsgq.h ├── asyncq.c ├── asyncq.h ├── atomic.h ├── aupdate.c ├── aupdate.h ├── auth-cookie.c ├── auth-cookie.h ├── authkey.c ├── authkey.h ├── avahi-wrap.c ├── avahi-wrap.h ├── bitset.c ├── bitset.h ├── card.c ├── card.h ├── cli-command.c ├── cli-command.h ├── cli-text.c ├── cli-text.h ├── cli.c ├── cli.h ├── client.c ├── client.h ├── conf-parser.c ├── conf-parser.h ├── core-error.c ├── core-error.h ├── core-format.c ├── core-format.h ├── core-rtclock.c ├── core-rtclock.h ├── core-scache.c ├── core-scache.h ├── core-subscribe.c ├── core-subscribe.h ├── core-util.c ├── core-util.h ├── core.c ├── core.h ├── cpu-arm.c ├── cpu-arm.h ├── cpu-orc.c ├── cpu-orc.h ├── cpu-x86.c ├── cpu-x86.h ├── cpu.c ├── cpu.h ├── creds.h ├── database-gdbm.c ├── database-simple.c ├── database-tdb.c ├── database.c ├── database.h ├── dbus-shared.c ├── dbus-shared.h ├── dbus-util.c ├── dbus-util.h ├── device-port.c ├── device-port.h ├── dynarray.c ├── dynarray.h ├── endianmacros.h ├── esound.h ├── fdsem.c ├── fdsem.h ├── ffmpeg ├── avcodec.h ├── dsputil.h └── resample2.c ├── filter ├── LICENSE.WEBKIT ├── biquad.c ├── biquad.h ├── crossover.c ├── crossover.h ├── lfe-filter.c └── lfe-filter.h ├── flist.c ├── flist.h ├── g711.c ├── g711.h ├── hashmap.c ├── hashmap.h ├── hook-list.c ├── hook-list.h ├── i18n.c ├── i18n.h ├── idxset.c ├── idxset.h ├── iochannel.c ├── iochannel.h ├── ioline.c ├── ioline.h ├── ipacl.c ├── ipacl.h ├── json.c ├── json.h ├── llist.h ├── lock-autospawn.c ├── lock-autospawn.h ├── log.c ├── log.h ├── ltdl-helper.c ├── ltdl-helper.h ├── macro.h ├── mcalign.c ├── mcalign.h ├── mem.h ├── memblock.c ├── memblock.h ├── memblockq.c ├── memblockq.h ├── memchunk.c ├── memchunk.h ├── memfd-wrappers.h ├── memtrap.c ├── memtrap.h ├── message-handler.c ├── message-handler.h ├── mime-type.c ├── mime-type.h ├── mix.c ├── mix.h ├── mix_neon.c ├── modargs.c ├── modargs.h ├── modinfo.c ├── modinfo.h ├── module.c ├── module.h ├── msgobject.c ├── msgobject.h ├── mutex-posix.c ├── mutex-win32.c ├── mutex.h ├── namereg.c ├── namereg.h ├── native-common.c ├── native-common.h ├── object.c ├── object.h ├── once.c ├── once.h ├── packet.c ├── packet.h ├── parseaddr.c ├── parseaddr.h ├── pdispatch.c ├── pdispatch.h ├── pid.c ├── pid.h ├── pipe.c ├── pipe.h ├── play-memblockq.c ├── play-memblockq.h ├── play-memchunk.c ├── play-memchunk.h ├── poll-posix.c ├── poll-win32.c ├── poll.h ├── proplist-util.c ├── proplist-util.h ├── protocol-cli.c ├── protocol-cli.h ├── protocol-dbus.c ├── protocol-dbus.h ├── protocol-esound.c ├── protocol-esound.h ├── protocol-http.c ├── protocol-http.h ├── protocol-native.c ├── protocol-native.h ├── protocol-simple.c ├── protocol-simple.h ├── pstream-util.c ├── pstream-util.h ├── pstream.c ├── pstream.h ├── queue.c ├── queue.h ├── random.c ├── random.h ├── ratelimit.c ├── ratelimit.h ├── refcnt.h ├── remap.c ├── remap.h ├── remap_mmx.c ├── remap_neon.c ├── remap_sse.c ├── resampler.c ├── resampler.h ├── resampler ├── ffmpeg.c ├── libsamplerate.c ├── peaks.c ├── soxr.c ├── speex.c └── trivial.c ├── rtkit.c ├── rtkit.h ├── rtpoll.c ├── rtpoll.h ├── sample-util.c ├── sample-util.h ├── sconv-s16be.c ├── sconv-s16be.h ├── sconv-s16le.c ├── sconv-s16le.h ├── sconv.c ├── sconv.h ├── sconv_neon.c ├── sconv_sse.c ├── semaphore-osx.c ├── semaphore-posix.c ├── semaphore-win32.c ├── semaphore.h ├── shared.c ├── shared.h ├── shm.c ├── shm.h ├── shmasyncq.c ├── shmasyncq.h ├── sink-input.c ├── sink-input.h ├── sink.c ├── sink.h ├── sioman.c ├── sioman.h ├── sndfile-util.c ├── sndfile-util.h ├── socket-client.c ├── socket-client.h ├── socket-server.c ├── socket-server.h ├── socket-util.c ├── socket-util.h ├── socket.h ├── sound-file-stream.c ├── sound-file-stream.h ├── sound-file.c ├── sound-file.h ├── source-output.c ├── source-output.h ├── source.c ├── source.h ├── srbchannel.c ├── srbchannel.h ├── start-child.c ├── start-child.h ├── strbuf.c ├── strbuf.h ├── stream-util.c ├── stream-util.h ├── strlist.c ├── strlist.h ├── svolume.orc ├── svolume_arm.c ├── svolume_c.c ├── svolume_mmx.c ├── svolume_orc.c ├── svolume_sse.c ├── tagstruct.c ├── tagstruct.h ├── thread-mq.c ├── thread-mq.h ├── thread-posix.c ├── thread-win32.c ├── thread.h ├── time-smoother.c ├── time-smoother.h ├── time-smoother_2.c ├── time-smoother_2.h ├── tokenizer.c ├── tokenizer.h ├── typedefs.h ├── usergroup.c ├── usergroup.h ├── winerrno.h ├── x11prop.c ├── x11prop.h ├── x11wrap.c └── x11wrap.h /.gitignore: -------------------------------------------------------------------------------- 1 | /.zig-cache/ 2 | /zig-out/ 3 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | Diego Elio Pettenò 2 | Lennart Poettering 3 | Lennart Poettering 4 | Russ Dill 5 | Russ Dill 6 | Sjoerd Simons 7 | Sjoerd Simons 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | All PulseAudio source files, except as noted below, are licensed under the GNU 2 | Lesser General Public License. (see file LGPL for details) 3 | 4 | However, the server side has optional GPL dependencies. These include the 5 | libsamplerate and gdbm (core libraries), LIRC (lirc module) and FFTW (equalizer 6 | module), although others may also be included in the future. If PulseAudio is 7 | compiled with these optional components, this effectively downgrades the 8 | license of the server part to GPL (see the file GPL for details), exercising 9 | section 3 of the LGPL. In such circumstances, you should treat the client 10 | library (libpulse) of PulseAudio as being LGPL licensed and the server part 11 | (libpulsecore) as being GPL licensed. Since the PulseAudio daemon, tests, 12 | various utilities/helpers and the modules link to libpulsecore and/or the afore 13 | mentioned optional GPL dependencies they are of course also GPL licensed also 14 | in this scenario. 15 | 16 | In addition to this, if D-Bus support is enabled, the PulseAudio client library 17 | (libpulse) MAY need to be licensed under the GPL, depending on the license 18 | adopted for libdbus. libdbus is licensed under either of the Academic Free 19 | License 2.1 or GPL 2.0 or above. Which of these applies is your choice, and the 20 | result affects the licensing of libpulse and thus, potentially, all programs 21 | that link to libpulse. 22 | 23 | Andre Adrian's echo cancellation implementation is licensed under a less 24 | restrictive license - see src/modules/echo-cancel/adrian-license.txt for 25 | details. 26 | 27 | Some other files pulled into PA source (i.e. reference implementations that are 28 | considered too small and stable to be considered as an external library) use the 29 | more permissive MIT license. These include the device reservation DBus protocol 30 | and realtime kit implementations. 31 | 32 | A more permissive BSD-style license is used for LFE filters, see 33 | src/pulsecore/filter/LICENSE.WEBKIT for details. 34 | 35 | Additionally, a more permissive Sun license is used for code that performs 36 | u-law, A-law and linear PCM conversions. 37 | 38 | While we attempt to provide a summary here, it is the ultimate responsibility of 39 | the packager to ensure the components they use in their build of PulseAudio 40 | meets their license requirements. 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PulseAudio Zig Package 2 | 3 | This is a fork of 4 | [PulseAudio](https://www.freedesktop.org/wiki/Software/PulseAudio/), packaged 5 | for Zig. Unnecessary files have been deleted, and the build system has been 6 | replaced with `build.zig`. 7 | 8 | ## License 9 | 10 | Original LICENSE file is unchanged. The Zig files that have been added to this 11 | repository are MIT (Expat) licensed. 12 | 13 | The MIT License (Expat) 14 | 15 | Copyright (c) contributors 16 | 17 | Permission is hereby granted, free of charge, to any person obtaining a copy 18 | of this software and associated documentation files (the "Software"), to deal 19 | in the Software without restriction, including without limitation the rights 20 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 21 | copies of the Software, and to permit persons to whom the Software is 22 | furnished to do so, subject to the following conditions: 23 | 24 | The above copyright notice and this permission notice shall be included in 25 | all copies or substantial portions of the Software. 26 | 27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 28 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 29 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 30 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 31 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 32 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 33 | THE SOFTWARE. 34 | -------------------------------------------------------------------------------- /build.zig.zon: -------------------------------------------------------------------------------- 1 | .{ 2 | .name = .pulseaudio, 3 | .version = "16.1.1-6", 4 | .fingerprint = 0x73554b57d8fa4f9a, 5 | .minimum_zig_version = "0.14.0", 6 | .dependencies = .{}, 7 | .paths = .{ 8 | "GPL", 9 | "LGPL", 10 | "LICENSE", 11 | "README.md", 12 | "bindings.zig", 13 | "build.zig", 14 | "build.zig.zon", 15 | "src", 16 | }, 17 | } 18 | -------------------------------------------------------------------------------- /src/pulse/cdecl.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsecdeclhfoo 2 | #define foopulsecdeclhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | /** \file 24 | * C++ compatibility support */ 25 | 26 | #ifdef __cplusplus 27 | /** If using C++ this macro enables C mode, otherwise does nothing */ 28 | #define PA_C_DECL_BEGIN extern "C" { 29 | /** If using C++ this macros switches back to C++ mode, otherwise does nothing */ 30 | #define PA_C_DECL_END } 31 | 32 | #else 33 | /** If using C++ this macro enables C mode, otherwise does nothing */ 34 | #define PA_C_DECL_BEGIN 35 | /** If using C++ this macros switches back to C++ mode, otherwise does nothing */ 36 | #define PA_C_DECL_END 37 | 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/pulse/client-conf-x11.h: -------------------------------------------------------------------------------- 1 | #ifndef fooclientconfx11hfoo 2 | #define fooclientconfx11hfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include "client-conf.h" 24 | 25 | /* Load client configuration data from X11, overwriting the current settings in 26 | * *c. */ 27 | int pa_client_conf_from_x11(pa_client_conf *c); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/pulse/client-conf.h: -------------------------------------------------------------------------------- 1 | #ifndef fooclientconfhfoo 2 | #define fooclientconfhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | 26 | /* A structure containing configuration data for PulseAudio clients. */ 27 | 28 | typedef struct pa_client_conf { 29 | char *daemon_binary; 30 | char *extra_arguments; 31 | char *default_sink; 32 | char *default_source; 33 | char *default_server; 34 | char *default_dbus_server; 35 | char *cookie_file_from_env; 36 | uint8_t cookie_from_x11[PA_NATIVE_COOKIE_LENGTH]; 37 | bool cookie_from_x11_valid; 38 | char *cookie_file_from_application; 39 | char *cookie_file_from_client_conf; 40 | bool autospawn, disable_shm, disable_memfd, auto_connect_localhost, auto_connect_display; 41 | size_t shm_size; 42 | } pa_client_conf; 43 | 44 | /* Create a new configuration data object and reset it to defaults */ 45 | pa_client_conf *pa_client_conf_new(void); 46 | void pa_client_conf_free(pa_client_conf *c); 47 | 48 | /* Load the configuration data from the client configuration file and 49 | * optionally from X11 and/or environment variables, overwriting the current 50 | * settings in *c. */ 51 | void pa_client_conf_load(pa_client_conf *c, bool load_from_x11, bool load_from_env); 52 | 53 | /* Load the cookie from the cookie sources specified in the configuration, or 54 | * if nothing is specified or none of the sources work, load the cookie from 55 | * the default source. If the default source doesn't work either, this function 56 | * returns a negative value and initializes the cookie to all-zeroes. */ 57 | int pa_client_conf_load_cookie(pa_client_conf *c, uint8_t *cookie, size_t cookie_length); 58 | 59 | void pa_client_conf_set_cookie_file_from_application(pa_client_conf *c, const char *cookie_file); 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/pulse/client.conf.in: -------------------------------------------------------------------------------- 1 | # This file is part of PulseAudio. 2 | # 3 | # PulseAudio is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU Lesser General Public License as published by 5 | # the Free Software Foundation; either version 2 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # PulseAudio is distributed in the hope that it will be useful, but 9 | # WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with PulseAudio; if not, see . 15 | 16 | ## Configuration file for PulseAudio clients. See pulse-client.conf(5) for 17 | ## more information. Default values are commented out. Use either ; or # for 18 | ## commenting. 19 | 20 | ; default-sink = 21 | ; default-source = 22 | ; default-server = 23 | ; default-dbus-server = 24 | 25 | ; autospawn = yes 26 | ; daemon-binary = @PA_BINARY@ 27 | ; extra-arguments = --log-target=syslog 28 | 29 | ; cookie-file = 30 | 31 | ; enable-shm = yes 32 | ; shm-size-bytes = 0 # setting this 0 will use the system-default, usually 64 MiB 33 | 34 | ; auto-connect-localhost = no 35 | ; auto-connect-display = no 36 | -------------------------------------------------------------------------------- /src/pulse/direction.c: -------------------------------------------------------------------------------- 1 | /*** 2 | This file is part of PulseAudio. 3 | 4 | Copyright 2014 Intel Corporation 5 | 6 | PulseAudio is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published 8 | by the Free Software Foundation; either version 2.1 of the License, 9 | or (at your option) any later version. 10 | 11 | PulseAudio is distributed in the hope that it will be useful, but 12 | WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with PulseAudio; if not, see . 18 | ***/ 19 | 20 | #include "direction.h" 21 | 22 | #include 23 | 24 | int pa_direction_valid(pa_direction_t direction) { 25 | if (direction != PA_DIRECTION_INPUT 26 | && direction != PA_DIRECTION_OUTPUT 27 | && direction != (PA_DIRECTION_INPUT | PA_DIRECTION_OUTPUT)) 28 | return 0; 29 | 30 | return 1; 31 | } 32 | 33 | const char *pa_direction_to_string(pa_direction_t direction) { 34 | pa_init_i18n(); 35 | 36 | if (direction == PA_DIRECTION_INPUT) 37 | return _("input"); 38 | if (direction == PA_DIRECTION_OUTPUT) 39 | return _("output"); 40 | if (direction == (PA_DIRECTION_INPUT | PA_DIRECTION_OUTPUT)) 41 | return _("bidirectional"); 42 | 43 | return _("invalid"); 44 | } 45 | -------------------------------------------------------------------------------- /src/pulse/direction.h: -------------------------------------------------------------------------------- 1 | #ifndef foodirectionhfoo 2 | #define foodirectionhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2014 Intel Corporation 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | 25 | /** \file 26 | * Utility functions for \ref pa_direction_t. */ 27 | 28 | /** Return non-zero if the given value is a valid direction (either input, 29 | * output or bidirectional). \since 6.0 */ 30 | int pa_direction_valid(pa_direction_t direction) PA_GCC_CONST; 31 | 32 | /** Return a textual representation of the direction. \since 6.0 */ 33 | const char *pa_direction_to_string(pa_direction_t direction); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src/pulse/error.h: -------------------------------------------------------------------------------- 1 | #ifndef fooerrorhfoo 2 | #define fooerrorhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | Copyright 2006 Pierre Ossman for Cendio AB 9 | 10 | PulseAudio is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU Lesser General Public License as published 12 | by the Free Software Foundation; either version 2.1 of the License, 13 | or (at your option) any later version. 14 | 15 | PulseAudio is distributed in the hope that it will be useful, but 16 | WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License 21 | along with PulseAudio; if not, see . 22 | ***/ 23 | 24 | #include 25 | #include 26 | 27 | /** \file 28 | * Error management */ 29 | 30 | PA_C_DECL_BEGIN 31 | 32 | /** Return a human readable error message for the specified numeric error code */ 33 | const char* pa_strerror(int error); 34 | 35 | PA_C_DECL_END 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/pulse/fork-detect.c: -------------------------------------------------------------------------------- 1 | /*** 2 | This file is part of PulseAudio. 3 | 4 | Copyright 2009 Lennart Poettering 5 | 6 | PulseAudio is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published 8 | by the Free Software Foundation; either version 2.1 of the License, 9 | or (at your option) any later version. 10 | 11 | PulseAudio is distributed in the hope that it will be useful, but 12 | WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with PulseAudio; if not, see . 18 | ***/ 19 | 20 | #ifdef HAVE_CONFIG_H 21 | #include 22 | #endif 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | #include "fork-detect.h" 30 | 31 | int pa_detect_fork(void) { 32 | static pa_atomic_t pid = PA_ATOMIC_INIT((int) -1); 33 | 34 | /* Some really stupid applications (Hey, vim, that means you!) 35 | * love to fork after initializing 36 | * gtk/libcanberra/pulseaudio. This is really bad style. We 37 | * however have to deal with this cleanly, so we try to detect the 38 | * forks making sure all our calls fail cleanly after the fork. */ 39 | 40 | pa_assert_cc(sizeof(pa_atomic_t) >= sizeof(pid_t)); 41 | 42 | for (;;) { 43 | pid_t stored_pid = (pid_t) pa_atomic_load(&pid); 44 | 45 | /* First let's check whether the current pid matches the stored one */ 46 | if (stored_pid == getpid()) 47 | return false; 48 | 49 | /* Does it contain a different PID than ours? Then the process got forked. */ 50 | if ((int) stored_pid != (int) -1) 51 | return true; 52 | 53 | /* Ok, it still contains no PID, then store it */ 54 | if (pa_atomic_cmpxchg(&pid, (int) -1, (int) getpid())) 55 | return false; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/pulse/fork-detect.h: -------------------------------------------------------------------------------- 1 | #ifndef fooforkdetecthfoo 2 | #define fooforkdetecthfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2009 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | int pa_detect_fork(void); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/pulse/glib-mainloop.h: -------------------------------------------------------------------------------- 1 | #ifndef fooglibmainloophfoo 2 | #define fooglibmainloophfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | Copyright 2006 Pierre Ossman for Cendio AB 9 | 10 | PulseAudio is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU Lesser General Public License as published 12 | by the Free Software Foundation; either version 2.1 of the License, 13 | or (at your option) any later version. 14 | 15 | PulseAudio is distributed in the hope that it will be useful, but 16 | WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License 21 | along with PulseAudio; if not, see . 22 | ***/ 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | /** \page glib-mainloop GLIB Main Loop Bindings 31 | * 32 | * \section overv_sec Overview 33 | * 34 | * The GLIB main loop bindings are extremely easy to use. All that is 35 | * required is to create a pa_glib_mainloop object using 36 | * pa_glib_mainloop_new(). When the main loop abstraction is needed, it is 37 | * provided by pa_glib_mainloop_get_api(). 38 | * 39 | */ 40 | 41 | /** \file 42 | * GLIB main loop support 43 | * 44 | * See also \subpage glib-mainloop 45 | */ 46 | 47 | PA_C_DECL_BEGIN 48 | 49 | /** An opaque GLIB main loop object */ 50 | typedef struct pa_glib_mainloop pa_glib_mainloop; 51 | 52 | /** Create a new GLIB main loop object for the specified GLIB main 53 | * loop context. Takes an argument c for the 54 | * GMainContext to use. If c is NULL the default context is used. */ 55 | pa_glib_mainloop *pa_glib_mainloop_new(GMainContext *c); 56 | 57 | /** Free the GLIB main loop object */ 58 | void pa_glib_mainloop_free(pa_glib_mainloop* g); 59 | 60 | /** Return the abstract main loop API vtable for the GLIB main loop 61 | object. No need to free the API as it is owned by the loop 62 | and is destroyed when the loop is freed. */ 63 | pa_mainloop_api* pa_glib_mainloop_get_api(pa_glib_mainloop *g); 64 | 65 | PA_C_DECL_END 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /src/pulse/mainloop-api.c: -------------------------------------------------------------------------------- 1 | /*** 2 | This file is part of PulseAudio. 3 | 4 | Copyright 2004-2006 Lennart Poettering 5 | 6 | PulseAudio is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as 8 | published by the Free Software Foundation; either version 2.1 of the 9 | License, or (at your option) any later version. 10 | 11 | PulseAudio is distributed in the hope that it will be useful, but 12 | WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with PulseAudio; if not, see . 18 | ***/ 19 | 20 | #ifdef HAVE_CONFIG_H 21 | #include 22 | #endif 23 | 24 | #include 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | #include "mainloop-api.h" 32 | 33 | struct once_info { 34 | void (*callback)(pa_mainloop_api*m, void *userdata); 35 | void *userdata; 36 | }; 37 | 38 | static void once_callback(pa_mainloop_api *m, pa_defer_event *e, void *userdata) { 39 | struct once_info *i = userdata; 40 | 41 | pa_assert(m); 42 | pa_assert(i); 43 | 44 | pa_assert(i->callback); 45 | i->callback(m, i->userdata); 46 | 47 | pa_assert(m->defer_free); 48 | m->defer_free(e); 49 | } 50 | 51 | static void free_callback(pa_mainloop_api *m, pa_defer_event *e, void *userdata) { 52 | struct once_info *i = userdata; 53 | 54 | pa_assert(m); 55 | pa_assert(i); 56 | pa_xfree(i); 57 | } 58 | 59 | void pa_mainloop_api_once(pa_mainloop_api* m, void (*callback)(pa_mainloop_api *m, void *userdata), void *userdata) { 60 | struct once_info *i; 61 | pa_defer_event *e; 62 | 63 | pa_assert(m); 64 | pa_assert(callback); 65 | 66 | pa_init_i18n(); 67 | 68 | i = pa_xnew(struct once_info, 1); 69 | i->callback = callback; 70 | i->userdata = userdata; 71 | 72 | pa_assert(m->defer_new); 73 | pa_assert_se(e = m->defer_new(m, once_callback, i)); 74 | m->defer_set_destroy(e, free_callback); 75 | } 76 | -------------------------------------------------------------------------------- /src/pulse/mainloop-signal.h: -------------------------------------------------------------------------------- 1 | #ifndef foomainloopsignalhfoo 2 | #define foomainloopsignalhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2008 Lennart Poettering 8 | Copyright 2006 Pierre Ossman for Cendio AB 9 | 10 | PulseAudio is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU Lesser General Public License as published 12 | by the Free Software Foundation; either version 2.1 of the License, 13 | or (at your option) any later version. 14 | 15 | PulseAudio is distributed in the hope that it will be useful, but 16 | WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License 21 | along with PulseAudio; if not, see . 22 | ***/ 23 | 24 | #include 25 | #include 26 | 27 | PA_C_DECL_BEGIN 28 | 29 | /** \file 30 | * UNIX signal support for main loops. In contrast to other 31 | * main loop event sources such as timer and IO events, UNIX signal 32 | * support requires modification of the global process 33 | * environment. Due to this the generic main loop abstraction layer as 34 | * defined in \ref mainloop-api.h doesn't have direct support for UNIX 35 | * signals. However, you may hook signal support into an abstract main loop via the routines defined herein. 36 | */ 37 | 38 | /** An opaque UNIX signal event source object */ 39 | typedef struct pa_signal_event pa_signal_event; 40 | 41 | /** Callback prototype for signal events */ 42 | typedef void (*pa_signal_cb_t) (pa_mainloop_api *api, pa_signal_event*e, int sig, void *userdata); 43 | 44 | /** Destroy callback prototype for signal events */ 45 | typedef void (*pa_signal_destroy_cb_t) (pa_mainloop_api *api, pa_signal_event*e, void *userdata); 46 | 47 | /** Initialize the UNIX signal subsystem and bind it to the specified main loop */ 48 | int pa_signal_init(pa_mainloop_api *api); 49 | 50 | /** Cleanup the signal subsystem */ 51 | void pa_signal_done(void); 52 | 53 | /** Create a new UNIX signal event source object */ 54 | pa_signal_event* pa_signal_new(int sig, pa_signal_cb_t callback, void *userdata); 55 | 56 | /** Free a UNIX signal event source object */ 57 | void pa_signal_free(pa_signal_event *e); 58 | 59 | /** Set a function that is called when the signal event source is destroyed. Use this to free the userdata argument if required */ 60 | void pa_signal_set_destroy(pa_signal_event *e, pa_signal_destroy_cb_t callback); 61 | 62 | PA_C_DECL_END 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/pulse/operation.h: -------------------------------------------------------------------------------- 1 | #ifndef foooperationhfoo 2 | #define foooperationhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | /** \file 28 | * Asynchronous operations */ 29 | 30 | PA_C_DECL_BEGIN 31 | 32 | /** An asynchronous operation object */ 33 | typedef struct pa_operation pa_operation; 34 | 35 | /** A callback for operation state changes */ 36 | typedef void (*pa_operation_notify_cb_t) (pa_operation *o, void *userdata); 37 | 38 | /** Increase the reference count by one */ 39 | pa_operation *pa_operation_ref(pa_operation *o); 40 | 41 | /** Decrease the reference count by one */ 42 | void pa_operation_unref(pa_operation *o); 43 | 44 | /** Cancel the operation. Beware! This will not necessarily cancel the 45 | * execution of the operation on the server side. However it will make 46 | * sure that the callback associated with this operation will not be 47 | * called anymore, effectively disabling the operation from the client 48 | * side's view. */ 49 | void pa_operation_cancel(pa_operation *o); 50 | 51 | /** Return the current status of the operation */ 52 | pa_operation_state_t pa_operation_get_state(const pa_operation *o); 53 | 54 | /** Set the callback function that is called when the operation state 55 | * changes. Usually this is not necessary, since the functions that 56 | * create pa_operation objects already take a callback that is called 57 | * when the operation finishes. Registering a state change callback is 58 | * mainly useful, if you want to get called back also if the operation 59 | * gets cancelled. \since 4.0 */ 60 | void pa_operation_set_state_callback(pa_operation *o, pa_operation_notify_cb_t cb, void *userdata); 61 | 62 | PA_C_DECL_END 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/pulse/rtclock.c: -------------------------------------------------------------------------------- 1 | /*** 2 | This file is part of PulseAudio. 3 | 4 | Copyright 2004-2006 Lennart Poettering 5 | 6 | PulseAudio is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as 8 | published by the Free Software Foundation; either version 2.1 of the 9 | License, or (at your option) any later version. 10 | 11 | PulseAudio is distributed in the hope that it will be useful, but 12 | WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with PulseAudio; if not, see . 18 | ***/ 19 | 20 | #ifdef HAVE_CONFIG_H 21 | #include 22 | #endif 23 | 24 | #include 25 | 26 | #include 27 | 28 | #include 29 | 30 | #include "rtclock.h" 31 | 32 | pa_usec_t pa_rtclock_now(void) { 33 | struct timeval tv; 34 | 35 | return pa_timeval_load(pa_rtclock_get(&tv)); 36 | } 37 | -------------------------------------------------------------------------------- /src/pulse/rtclock.h: -------------------------------------------------------------------------------- 1 | #ifndef foortclockfoo 2 | #define foortclockfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2009 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | 26 | /** \file 27 | * Monotonic clock utilities. */ 28 | 29 | PA_C_DECL_BEGIN 30 | 31 | /** Return the current monotonic system time in usec, if such a clock 32 | * is available. If it is not available this will return the 33 | * wallclock time instead. \since 0.9.16 */ 34 | pa_usec_t pa_rtclock_now(void); 35 | 36 | PA_C_DECL_END 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/pulse/utf8.h: -------------------------------------------------------------------------------- 1 | #ifndef fooutf8hfoo 2 | #define fooutf8hfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2006 Lennart Poettering 8 | Copyright 2006 Pierre Ossman for Cendio AB 9 | 10 | PulseAudio is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU Lesser General Public License as 12 | published by the Free Software Foundation; either version 2.1 of the 13 | License, or (at your option) any later version. 14 | 15 | PulseAudio is distributed in the hope that it will be useful, but 16 | WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with PulseAudio; if not, see . 22 | ***/ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | /** \file 29 | * UTF-8 validation functions 30 | */ 31 | 32 | PA_C_DECL_BEGIN 33 | 34 | /** Test if the specified strings qualifies as valid UTF8. Return the string if so, otherwise NULL */ 35 | char *pa_utf8_valid(const char *str) PA_GCC_PURE; 36 | 37 | /** Test if the specified strings qualifies as valid 7-bit ASCII. Return the string if so, otherwise NULL. \since 0.9.15 */ 38 | char *pa_ascii_valid(const char *str) PA_GCC_PURE; 39 | 40 | /** Filter all invalid UTF8 characters from the specified string, returning a new fully UTF8 valid string. Don't forget to free the returned string with pa_xfree() */ 41 | char *pa_utf8_filter(const char *str); 42 | 43 | /** Filter all invalid ASCII characters from the specified string, returning a new fully ASCII valid string. Don't forget to free the returned string with pa_xfree(). \since 0.9.15 */ 44 | char *pa_ascii_filter(const char *str); 45 | 46 | /** Convert a UTF-8 string to the current locale. Free the string using pa_xfree(). */ 47 | char* pa_utf8_to_locale (const char *str); 48 | 49 | /** Convert a string in the current locale to UTF-8. Free the string using pa_xfree(). */ 50 | char* pa_locale_to_utf8 (const char *str); 51 | 52 | PA_C_DECL_END 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/pulse/util.h: -------------------------------------------------------------------------------- 1 | #ifndef fooutilhfoo 2 | #define fooutilhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | Copyright 2006 Pierre Ossman for Cendio AB 9 | 10 | PulseAudio is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU Lesser General Public License as 12 | published by the Free Software Foundation; either version 2.1 of the 13 | License, or (at your option) any later version. 14 | 15 | PulseAudio is distributed in the hope that it will be useful, but 16 | WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with PulseAudio; if not, see . 22 | ***/ 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | /** \file 30 | * Assorted utility functions */ 31 | 32 | PA_C_DECL_BEGIN 33 | 34 | /** Return the current username in the specified string buffer. */ 35 | char *pa_get_user_name(char *s, size_t l); 36 | 37 | /** Return the current hostname in the specified buffer. */ 38 | char *pa_get_host_name(char *s, size_t l); 39 | 40 | /** Return the fully qualified domain name in s */ 41 | char *pa_get_fqdn(char *s, size_t l); 42 | 43 | /** Return the home directory of the current user */ 44 | char *pa_get_home_dir(char *s, size_t l); 45 | 46 | /** Return the binary file name of the current process. This is not 47 | * supported on all architectures, in which case NULL is returned. */ 48 | char *pa_get_binary_name(char *s, size_t l); 49 | 50 | /** Return a pointer to the filename inside a path (which is the last 51 | * component). If passed NULL will return NULL. */ 52 | char *pa_path_get_filename(const char *p); 53 | 54 | /** Wait t milliseconds */ 55 | int pa_msleep(unsigned long t); 56 | 57 | /** Make the calling thread realtime if we can. On Linux, this uses RealTimeKit 58 | * if available and POSIX APIs otherwise (the latter applies to other UNIX 59 | * variants as well). This is also implemented for macOS and Windows. 60 | * \since 13.0 */ 61 | int pa_thread_make_realtime(int rtprio); 62 | 63 | PA_C_DECL_END 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/pulsecore/arpa-inet.h: -------------------------------------------------------------------------------- 1 | #ifndef fooarpa_inethfoo 2 | #define fooarpa_inethfoo 3 | 4 | #if defined(HAVE_ARPA_INET_H) 5 | 6 | #include 7 | 8 | #elif defined(OS_IS_WIN32) 9 | 10 | /* On Windows winsock2.h (here included via pulsecore/socket.h) provides most of the functionality of arpa/inet.h, except for 11 | * the inet_ntop and inet_pton functions, which are implemented here on versions earlier than Vista. */ 12 | 13 | #include 14 | 15 | #if (_WIN32_WINNT < 0x0600) 16 | 17 | const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt); 18 | 19 | int inet_pton(int af, const char *src, void *dst); 20 | 21 | #endif 22 | 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/pulsecore/auth-cookie.h: -------------------------------------------------------------------------------- 1 | #ifndef fooauthcookiehfoo 2 | #define fooauthcookiehfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2008 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | 25 | typedef struct pa_auth_cookie pa_auth_cookie; 26 | 27 | pa_auth_cookie* pa_auth_cookie_get(pa_core *c, const char *cn, bool create, size_t size); 28 | pa_auth_cookie* pa_auth_cookie_create(pa_core *c, const void *data, size_t size); 29 | pa_auth_cookie* pa_auth_cookie_ref(pa_auth_cookie *c); 30 | void pa_auth_cookie_unref(pa_auth_cookie *c); 31 | 32 | const uint8_t* pa_auth_cookie_read(pa_auth_cookie *, size_t size); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/pulsecore/authkey.h: -------------------------------------------------------------------------------- 1 | #ifndef fooauthkeyhfoo 2 | #define fooauthkeyhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | 25 | int pa_authkey_load(const char *fn, bool create, void *data, size_t length); 26 | 27 | int pa_authkey_save(const char *path, const void *data, size_t length); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/pulsecore/avahi-wrap.h: -------------------------------------------------------------------------------- 1 | #ifndef fooavahiwrapperhfoo 2 | #define fooavahiwrapperhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | 25 | #include 26 | 27 | AvahiPoll* pa_avahi_poll_new(pa_mainloop_api *api); 28 | void pa_avahi_poll_free(AvahiPoll *p); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/pulsecore/bitset.c: -------------------------------------------------------------------------------- 1 | /*** 2 | This file is part of PulseAudio. 3 | 4 | Copyright 2009 Lennart Poettering 5 | 6 | PulseAudio is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published 8 | by the Free Software Foundation; either version 2.1 of the License, 9 | or (at your option) any later version. 10 | 11 | PulseAudio is distributed in the hope that it will be useful, but 12 | WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with PulseAudio; if not, see . 18 | ***/ 19 | 20 | #ifdef HAVE_CONFIG_H 21 | #include 22 | #endif 23 | 24 | #include 25 | 26 | #include 27 | 28 | #include "bitset.h" 29 | 30 | void pa_bitset_set(pa_bitset_t *b, unsigned k, bool v) { 31 | pa_assert(b); 32 | 33 | if (v) 34 | b[k >> 5] |= 1 << (k & 31); 35 | else 36 | b[k >> 5] &= ~((uint32_t) (1 << (k & 31))); 37 | } 38 | 39 | bool pa_bitset_get(const pa_bitset_t *b, unsigned k) { 40 | return !!(b[k >> 5] & (1 << (k & 31))); 41 | } 42 | 43 | bool pa_bitset_equals(const pa_bitset_t *b, unsigned n, ...) { 44 | va_list ap; 45 | pa_bitset_t *a; 46 | bool equal; 47 | 48 | a = pa_xnew0(pa_bitset_t, PA_BITSET_ELEMENTS(n)); 49 | 50 | va_start(ap, n); 51 | for (;;) { 52 | int j = va_arg(ap, int); 53 | 54 | if (j < 0) 55 | break; 56 | 57 | pa_bitset_set(a, j, true); 58 | } 59 | va_end(ap); 60 | 61 | equal = memcmp(a, b, PA_BITSET_SIZE(n)) == 0; 62 | pa_xfree(a); 63 | 64 | return equal; 65 | } 66 | -------------------------------------------------------------------------------- /src/pulsecore/bitset.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsecorebitsethfoo 2 | #define foopulsecorebitsethfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2009 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | 26 | #define PA_BITSET_ELEMENTS(n) (((n)+31)/32) 27 | #define PA_BITSET_SIZE(n) (PA_BITSET_ELEMENTS(n)*4) 28 | 29 | typedef uint32_t pa_bitset_t; 30 | 31 | void pa_bitset_set(pa_bitset_t *b, unsigned k, bool v); 32 | bool pa_bitset_get(const pa_bitset_t *b, unsigned k); 33 | bool pa_bitset_equals(const pa_bitset_t *b, unsigned n, ...); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src/pulsecore/cli-command.h: -------------------------------------------------------------------------------- 1 | #ifndef fooclicommandhfoo 2 | #define fooclicommandhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | 26 | /* Execute a single CLI command. Write the results to the string 27 | * buffer *buf. If *fail is non-zero the function will return -1 when 28 | * one or more of the executed commands failed. *fail 29 | * may be modified by the function call. */ 30 | int pa_cli_command_execute_line(pa_core *c, const char *s, pa_strbuf *buf, bool *fail); 31 | 32 | /* Execute a whole file of CLI commands */ 33 | int pa_cli_command_execute_file(pa_core *c, const char *fn, pa_strbuf *buf, bool *fail); 34 | 35 | /* Execute a whole file of CLI commands */ 36 | int pa_cli_command_execute_file_stream(pa_core *c, FILE *f, pa_strbuf *buf, bool *fail); 37 | 38 | /* Split the specified string into lines and run pa_cli_command_execute_line() for each. */ 39 | int pa_cli_command_execute(pa_core *c, const char *s, pa_strbuf *buf, bool *fail); 40 | 41 | /* Same as pa_cli_command_execute_line() but also take ifstate var. */ 42 | int pa_cli_command_execute_line_stateful(pa_core *c, const char *s, pa_strbuf *buf, bool *fail, int *ifstate); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/pulsecore/cli-text.h: -------------------------------------------------------------------------------- 1 | #ifndef fooclitexthfoo 2 | #define fooclitexthfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | 25 | /* Some functions to generate pretty formatted listings of 26 | * entities. The returned strings have to be freed manually. */ 27 | 28 | char *pa_sink_input_list_to_string(pa_core *c); 29 | char *pa_source_output_list_to_string(pa_core *c); 30 | char *pa_sink_list_to_string(pa_core *core); 31 | char *pa_source_list_to_string(pa_core *c); 32 | char *pa_card_list_to_string(pa_core *c); 33 | char *pa_client_list_to_string(pa_core *c); 34 | char *pa_module_list_to_string(pa_core *c); 35 | char *pa_scache_list_to_string(pa_core *c); 36 | 37 | char *pa_full_status_string(pa_core *c); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/pulsecore/cli.h: -------------------------------------------------------------------------------- 1 | #ifndef fooclihfoo 2 | #define fooclihfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | typedef struct pa_cli pa_cli; 28 | 29 | typedef void (*pa_cli_eof_cb_t)(pa_cli *c, void *userdata); 30 | 31 | /* Create a new command line session on the specified io channel owned by the specified module */ 32 | pa_cli* pa_cli_new(pa_core *core, pa_iochannel *io, pa_module *m); 33 | void pa_cli_free(pa_cli *cli); 34 | 35 | /* Set a callback function that is called whenever the command line session is terminated */ 36 | void pa_cli_set_eof_callback(pa_cli *cli, pa_cli_eof_cb_t cb, void *userdata); 37 | 38 | pa_module *pa_cli_get_module(pa_cli *c); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/pulsecore/core-error.c: -------------------------------------------------------------------------------- 1 | /*** 2 | This file is part of PulseAudio. 3 | 4 | Copyright 2004-2006 Lennart Poettering 5 | Copyright 2006 Pierre Ossman for Cendio AB 6 | 7 | PulseAudio is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published 9 | by the Free Software Foundation; either version 2.1 of the License, 10 | or (at your option) any later version. 11 | 12 | PulseAudio is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with PulseAudio; if not, see . 19 | ***/ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include 23 | #endif 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | #include "core-error.h" 38 | 39 | PA_STATIC_TLS_DECLARE(cstrerror, pa_xfree); 40 | 41 | const char* pa_cstrerror(int errnum) { 42 | const char *original = NULL; 43 | char *translated, *t; 44 | char errbuf[128]; 45 | 46 | if (errnum < 0) 47 | errnum = -errnum; 48 | 49 | if ((t = PA_STATIC_TLS_GET(cstrerror))) 50 | pa_xfree(t); 51 | 52 | #if defined(HAVE_STRERROR_R) && defined(__GLIBC__) 53 | original = strerror_r(errnum, errbuf, sizeof(errbuf)); 54 | #elif defined(HAVE_STRERROR_R) 55 | if (strerror_r(errnum, errbuf, sizeof(errbuf)) == 0) { 56 | errbuf[sizeof(errbuf) - 1] = 0; 57 | original = errbuf; 58 | } 59 | #else 60 | /* This might not be thread safe, but we hope for the best */ 61 | original = strerror(errnum); 62 | #endif 63 | 64 | /* The second condition is a Windows-ism */ 65 | if (!original || !strcasecmp(original, "Unknown error")) { 66 | pa_snprintf(errbuf, sizeof(errbuf), "Unknown error %d", errnum); 67 | original = errbuf; 68 | } 69 | 70 | if (!(translated = pa_locale_to_utf8(original))) { 71 | pa_log_warn("Unable to convert error string to locale, filtering."); 72 | translated = pa_utf8_filter(original); 73 | } 74 | 75 | PA_STATIC_TLS_SET(cstrerror, translated); 76 | 77 | return translated; 78 | } 79 | -------------------------------------------------------------------------------- /src/pulsecore/core-error.h: -------------------------------------------------------------------------------- 1 | #ifndef foocoreerrorhfoo 2 | #define foocoreerrorhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | Copyright 2006 Pierre Ossman for Cendio AB 9 | 10 | PulseAudio is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU Lesser General Public License as published 12 | by the Free Software Foundation; either version 2.1 of the License, 13 | or (at your option) any later version. 14 | 15 | PulseAudio is distributed in the hope that it will be useful, but 16 | WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License 21 | along with PulseAudio; if not, see . 22 | ***/ 23 | 24 | #include 25 | 26 | /** \file 27 | * Error management */ 28 | 29 | PA_C_DECL_BEGIN 30 | 31 | /** A wrapper around the standard strerror() function that converts the 32 | * string to UTF-8. The function is thread safe but the returned string is 33 | * only guaranteed to exist until the thread exits or pa_cstrerror() is 34 | * called again from the same thread. */ 35 | const char* pa_cstrerror(int errnum); 36 | 37 | PA_C_DECL_END 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/pulsecore/core-rtclock.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsertclockhfoo 2 | #define foopulsertclockhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | 26 | struct timeval; 27 | 28 | /* Something like pulse/timeval.h but based on CLOCK_MONOTONIC */ 29 | 30 | struct timeval *pa_rtclock_get(struct timeval *ts); 31 | 32 | pa_usec_t pa_rtclock_age(const struct timeval *tv); 33 | bool pa_rtclock_hrtimer(void); 34 | void pa_rtclock_hrtimer_enable(void); 35 | 36 | /* timer with a resolution better than this are considered high-resolution */ 37 | #define PA_HRTIMER_THRESHOLD_USEC 10 38 | 39 | /* bit to set in tv.tv_usec to mark that the timeval is in monotonic time */ 40 | #define PA_TIMEVAL_RTCLOCK ((time_t) (1LU << 30)) 41 | 42 | struct timeval* pa_rtclock_from_wallclock(struct timeval *tv); 43 | 44 | #ifdef HAVE_CLOCK_GETTIME 45 | struct timespec; 46 | 47 | pa_usec_t pa_timespec_load(const struct timespec *ts); 48 | struct timespec* pa_timespec_store(struct timespec *ts, pa_usec_t v); 49 | #endif 50 | 51 | struct timeval* pa_timeval_rtstore(struct timeval *tv, pa_usec_t v, bool rtclock); 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/pulsecore/core-scache.h: -------------------------------------------------------------------------------- 1 | #ifndef foocorescachehfoo 2 | #define foocorescachehfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | Copyright 2006 Pierre Ossman for Cendio AB 9 | 10 | PulseAudio is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU Lesser General Public License as published 12 | by the Free Software Foundation; either version 2.1 of the License, 13 | or (at your option) any later version. 14 | 15 | PulseAudio is distributed in the hope that it will be useful, but 16 | WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License 21 | along with PulseAudio; if not, see . 22 | ***/ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #define PA_SCACHE_ENTRY_SIZE_MAX (1024*1024*16) 29 | 30 | typedef struct pa_scache_entry { 31 | uint32_t index; 32 | pa_core *core; 33 | 34 | char *name; 35 | 36 | pa_cvolume volume; 37 | bool volume_is_set; 38 | pa_sample_spec sample_spec; 39 | pa_channel_map channel_map; 40 | pa_memchunk memchunk; 41 | 42 | char *filename; 43 | 44 | bool lazy; 45 | time_t last_used_time; 46 | 47 | pa_proplist *proplist; 48 | } pa_scache_entry; 49 | 50 | 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); 51 | int pa_scache_add_file(pa_core *c, const char *name, const char *filename, uint32_t *idx); 52 | int pa_scache_add_file_lazy(pa_core *c, const char *name, const char *filename, uint32_t *idx); 53 | 54 | int pa_scache_add_directory_lazy(pa_core *c, const char *pathname); 55 | 56 | int pa_scache_remove_item(pa_core *c, const char *name); 57 | 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); 58 | 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); 59 | void pa_scache_free_all(pa_core *c); 60 | 61 | const char *pa_scache_get_name_by_id(pa_core *c, uint32_t id); 62 | uint32_t pa_scache_get_id_by_name(pa_core *c, const char *name); 63 | 64 | size_t pa_scache_total_size(pa_core *c); 65 | 66 | void pa_scache_unload_unused(pa_core *c); 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /src/pulsecore/core-subscribe.h: -------------------------------------------------------------------------------- 1 | #ifndef foocoresubscribehfoo 2 | #define foocoresubscribehfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | typedef struct pa_subscription pa_subscription; 24 | typedef struct pa_subscription_event pa_subscription_event; 25 | 26 | #include 27 | #include 28 | 29 | typedef void (*pa_subscription_cb_t)(pa_core *c, pa_subscription_event_type_t t, uint32_t idx, void *userdata); 30 | 31 | pa_subscription* pa_subscription_new(pa_core *c, pa_subscription_mask_t m, pa_subscription_cb_t cb, void *userdata); 32 | void pa_subscription_free(pa_subscription*s); 33 | void pa_subscription_free_all(pa_core *c); 34 | 35 | void pa_subscription_post(pa_core *c, pa_subscription_event_type_t t, uint32_t idx); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/pulsecore/cpu-arm.h: -------------------------------------------------------------------------------- 1 | #ifndef foocpuarmhfoo 2 | #define foocpuarmhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | Copyright 2009 Wim Taymans 9 | 10 | PulseAudio is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU Lesser General Public License as published 12 | by the Free Software Foundation; either version 2.1 of the License, 13 | or (at your option) any later version. 14 | 15 | PulseAudio is distributed in the hope that it will be useful, but 16 | WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License 21 | along with PulseAudio; if not, see . 22 | ***/ 23 | 24 | #include 25 | #include 26 | 27 | #ifndef PACKAGE 28 | #error "Please include config.h before including this file!" 29 | #endif 30 | 31 | typedef enum pa_cpu_arm_flag { 32 | PA_CPU_ARM_V6 = (1 << 0), 33 | PA_CPU_ARM_V7 = (1 << 1), 34 | PA_CPU_ARM_VFP = (1 << 2), 35 | PA_CPU_ARM_EDSP = (1 << 3), 36 | PA_CPU_ARM_NEON = (1 << 4), 37 | PA_CPU_ARM_VFPV3 = (1 << 5), 38 | PA_CPU_ARM_CORTEX_A8 = (1 << 6), 39 | } pa_cpu_arm_flag_t; 40 | 41 | void pa_cpu_get_arm_flags(pa_cpu_arm_flag_t *flags); 42 | bool pa_cpu_init_arm(pa_cpu_arm_flag_t *flags); 43 | 44 | /* some optimized functions */ 45 | void pa_volume_func_init_arm(pa_cpu_arm_flag_t flags); 46 | 47 | #ifdef HAVE_NEON 48 | void pa_convert_func_init_neon(pa_cpu_arm_flag_t flags); 49 | void pa_mix_func_init_neon(pa_cpu_arm_flag_t flags); 50 | void pa_remap_func_init_neon(pa_cpu_arm_flag_t flags); 51 | #endif 52 | 53 | #endif /* foocpuarmhfoo */ 54 | -------------------------------------------------------------------------------- /src/pulsecore/cpu-orc.c: -------------------------------------------------------------------------------- 1 | /*** 2 | This file is part of PulseAudio. 3 | 4 | Copyright 2010 Arun Raghavan 5 | 6 | PulseAudio is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published 8 | by the Free Software Foundation; either version 2.1 of the License, 9 | or (at your option) any later version. 10 | 11 | PulseAudio is distributed in the hope that it will be useful, but 12 | WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with PulseAudio; if not, see . 18 | ***/ 19 | 20 | #ifdef HAVE_CONFIG_H 21 | #include 22 | #endif 23 | 24 | #include "cpu-orc.h" 25 | 26 | bool pa_cpu_init_orc(pa_cpu_info cpu_info) { 27 | #ifndef DISABLE_ORC 28 | /* Update these as we test on more architectures */ 29 | pa_cpu_x86_flag_t x86_want_flags = PA_CPU_X86_MMX | PA_CPU_X86_SSE | PA_CPU_X86_SSE2 | PA_CPU_X86_SSE3 | PA_CPU_X86_SSSE3 | PA_CPU_X86_SSE4_1 | PA_CPU_X86_SSE4_2; 30 | 31 | /* Enable Orc svolume optimizations */ 32 | if ((cpu_info.cpu_type == PA_CPU_X86) && (cpu_info.flags.x86 & x86_want_flags)) { 33 | pa_volume_func_init_orc(); 34 | return true; 35 | } 36 | #endif 37 | 38 | return false; 39 | } 40 | -------------------------------------------------------------------------------- /src/pulsecore/cpu-orc.h: -------------------------------------------------------------------------------- 1 | #ifndef foocpuorchfoo 2 | #define foocpuorchfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2010 Arun Raghavan 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | 25 | /* Orc-optimised bits */ 26 | 27 | bool pa_cpu_init_orc(pa_cpu_info cpu_info); 28 | 29 | void pa_volume_func_init_orc(void); 30 | 31 | #endif /* foocpuorchfoo */ 32 | -------------------------------------------------------------------------------- /src/pulsecore/cpu-x86.h: -------------------------------------------------------------------------------- 1 | #ifndef foocpux86hfoo 2 | #define foocpux86hfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | Copyright 2009 Wim Taymans 9 | 10 | PulseAudio is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU Lesser General Public License as published 12 | by the Free Software Foundation; either version 2.1 of the License, 13 | or (at your option) any later version. 14 | 15 | PulseAudio is distributed in the hope that it will be useful, but 16 | WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License 21 | along with PulseAudio; if not, see . 22 | ***/ 23 | 24 | #include 25 | #include 26 | 27 | typedef enum pa_cpu_x86_flag { 28 | PA_CPU_X86_MMX = (1 << 0), 29 | PA_CPU_X86_MMXEXT = (1 << 1), 30 | PA_CPU_X86_SSE = (1 << 2), 31 | PA_CPU_X86_SSE2 = (1 << 3), 32 | PA_CPU_X86_SSE3 = (1 << 4), 33 | PA_CPU_X86_SSSE3 = (1 << 5), 34 | PA_CPU_X86_SSE4_1 = (1 << 6), 35 | PA_CPU_X86_SSE4_2 = (1 << 7), 36 | PA_CPU_X86_3DNOW = (1 << 8), 37 | PA_CPU_X86_3DNOWEXT = (1 << 9), 38 | PA_CPU_X86_CMOV = (1 << 10) 39 | } pa_cpu_x86_flag_t; 40 | 41 | void pa_cpu_get_x86_flags(pa_cpu_x86_flag_t *flags); 42 | bool pa_cpu_init_x86 (pa_cpu_x86_flag_t *flags); 43 | 44 | #if defined (__i386__) 45 | typedef int32_t pa_reg_x86; 46 | #elif defined (__amd64__) 47 | typedef int64_t pa_reg_x86; 48 | #endif 49 | 50 | /* some optimized functions */ 51 | void pa_volume_func_init_mmx(pa_cpu_x86_flag_t flags); 52 | void pa_volume_func_init_sse(pa_cpu_x86_flag_t flags); 53 | 54 | void pa_remap_func_init_mmx(pa_cpu_x86_flag_t flags); 55 | void pa_remap_func_init_sse(pa_cpu_x86_flag_t flags); 56 | 57 | void pa_convert_func_init_sse (pa_cpu_x86_flag_t flags); 58 | 59 | #endif /* foocpux86hfoo */ 60 | -------------------------------------------------------------------------------- /src/pulsecore/cpu.c: -------------------------------------------------------------------------------- 1 | /*** 2 | This file is part of PulseAudio. 3 | 4 | Copyright 2014 Peter Meerwald 5 | 6 | PulseAudio is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published 8 | by the Free Software Foundation; either version 2.1 of the License, 9 | or (at your option) any later version. 10 | 11 | PulseAudio is distributed in the hope that it will be useful, but 12 | WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | General Public License for more details. 15 | ***/ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include 19 | #endif 20 | 21 | #include "cpu.h" 22 | #include "cpu-orc.h" 23 | 24 | void pa_cpu_init(pa_cpu_info *cpu_info) { 25 | cpu_info->cpu_type = PA_CPU_UNDEFINED; 26 | /* don't force generic code, used for testing only */ 27 | cpu_info->force_generic_code = false; 28 | if (!getenv("PULSE_NO_SIMD")) { 29 | if (pa_cpu_init_x86(&cpu_info->flags.x86)) 30 | cpu_info->cpu_type = PA_CPU_X86; 31 | else if (pa_cpu_init_arm(&cpu_info->flags.arm)) 32 | cpu_info->cpu_type = PA_CPU_ARM; 33 | pa_cpu_init_orc(*cpu_info); 34 | } 35 | 36 | pa_remap_func_init(cpu_info); 37 | pa_mix_func_init(cpu_info); 38 | } 39 | -------------------------------------------------------------------------------- /src/pulsecore/cpu.h: -------------------------------------------------------------------------------- 1 | #ifndef foocpuhfoo 2 | #define foocpuhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2010 Arun Raghavan 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | 26 | typedef enum { 27 | PA_CPU_UNDEFINED = 0, 28 | PA_CPU_X86, 29 | PA_CPU_ARM, 30 | } pa_cpu_type_t; 31 | 32 | typedef struct pa_cpu_info pa_cpu_info; 33 | 34 | struct pa_cpu_info { 35 | pa_cpu_type_t cpu_type; 36 | 37 | union { 38 | pa_cpu_x86_flag_t x86; 39 | pa_cpu_arm_flag_t arm; 40 | } flags; 41 | bool force_generic_code; 42 | }; 43 | 44 | void pa_cpu_init(pa_cpu_info *cpu_info); 45 | 46 | void pa_remap_func_init(const pa_cpu_info *cpu_info); 47 | void pa_mix_func_init(const pa_cpu_info *cpu_info); 48 | 49 | #endif /* foocpuhfoo */ 50 | -------------------------------------------------------------------------------- /src/pulsecore/creds.h: -------------------------------------------------------------------------------- 1 | #ifndef foocredshfoo 2 | #define foocredshfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | 25 | #ifndef PACKAGE 26 | #error "Please include config.h before including this file!" 27 | #endif 28 | 29 | #include 30 | #include 31 | 32 | #define MAX_ANCIL_DATA_FDS 2 33 | 34 | typedef struct pa_creds pa_creds; 35 | typedef struct pa_cmsg_ancil_data pa_cmsg_ancil_data; 36 | 37 | #if defined(SCM_CREDENTIALS) || defined(SCM_CREDS) 38 | 39 | #define HAVE_CREDS 1 40 | 41 | struct pa_creds { 42 | gid_t gid; 43 | uid_t uid; 44 | }; 45 | 46 | /* Struct for handling ancillary data, i e, extra data that can be sent together with a message 47 | * over unix pipes. Supports sending and receiving credentials and file descriptors. */ 48 | struct pa_cmsg_ancil_data { 49 | pa_creds creds; 50 | bool creds_valid; 51 | int nfd; 52 | 53 | /* Don't close these fds by your own. Check pa_cmsg_ancil_data_close_fds() */ 54 | int fds[MAX_ANCIL_DATA_FDS]; 55 | bool close_fds_on_cleanup; 56 | }; 57 | 58 | void pa_cmsg_ancil_data_close_fds(struct pa_cmsg_ancil_data *ancil); 59 | 60 | #else 61 | #undef HAVE_CREDS 62 | #endif 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/pulsecore/dbus-shared.h: -------------------------------------------------------------------------------- 1 | #ifndef foodbussharedhfoo 2 | #define foodbussharedhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006, 2009 Lennart Poettering 8 | Copyright 2006 Shams E. King 9 | 10 | PulseAudio is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU Lesser General Public License as published 12 | by the Free Software Foundation; either version 2.1 of the License, 13 | or (at your option) any later version. 14 | 15 | PulseAudio is distributed in the hope that it will be useful, but 16 | WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License 21 | along with PulseAudio; if not, see . 22 | ***/ 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | typedef struct pa_dbus_connection pa_dbus_connection; 30 | 31 | /* return a pa_dbus_connection of the specified type for the given core, 32 | * like dbus_bus_get(), but integrates the connection with the pa_core */ 33 | pa_dbus_connection* pa_dbus_bus_get(pa_core *c, DBusBusType type, DBusError *error); 34 | 35 | DBusConnection* pa_dbus_connection_get(pa_dbus_connection *conn); 36 | 37 | pa_dbus_connection* pa_dbus_connection_ref(pa_dbus_connection *conn); 38 | void pa_dbus_connection_unref(pa_dbus_connection *conn); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/pulsecore/fdsem.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsefdsemhfoo 2 | #define foopulsefdsemhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | 25 | /* A simple, asynchronous semaphore which uses fds for sleeping. In 26 | * the best case all functions are lock-free unless sleeping is 27 | * required. */ 28 | 29 | #include 30 | 31 | typedef struct pa_fdsem pa_fdsem; 32 | 33 | typedef struct pa_fdsem_data { 34 | pa_atomic_t waiting; 35 | pa_atomic_t signalled; 36 | pa_atomic_t in_pipe; 37 | } pa_fdsem_data; 38 | 39 | pa_fdsem *pa_fdsem_new(void); 40 | pa_fdsem *pa_fdsem_open_shm(pa_fdsem_data *data, int event_fd); 41 | pa_fdsem *pa_fdsem_new_shm(pa_fdsem_data *data); 42 | void pa_fdsem_free(pa_fdsem *f); 43 | 44 | void pa_fdsem_post(pa_fdsem *f); 45 | void pa_fdsem_wait(pa_fdsem *f); 46 | int pa_fdsem_try(pa_fdsem *f); 47 | 48 | int pa_fdsem_get(pa_fdsem *f); 49 | 50 | int pa_fdsem_before_poll(pa_fdsem *f); 51 | int pa_fdsem_after_poll(pa_fdsem *f); 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/pulsecore/ffmpeg/dsputil.h: -------------------------------------------------------------------------------- 1 | /* empty file, just here to allow us to compile an unmodified resampler2.c */ 2 | -------------------------------------------------------------------------------- /src/pulsecore/filter/LICENSE.WEBKIT: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Google Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 14 | * its contributors may be used to endorse or promote products derived 15 | * from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 18 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | -------------------------------------------------------------------------------- /src/pulsecore/filter/biquad.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 2 | * Use of this source code is governed by a BSD-style license that can be 3 | * found in the LICENSE file. 4 | */ 5 | 6 | #ifndef BIQUAD_H_ 7 | #define BIQUAD_H_ 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /* The biquad filter parameters. The transfer function H(z) is (b0 + b1 * z^(-1) 14 | * + b2 * z^(-2)) / (1 + a1 * z^(-1) + a2 * z^(-2)). The previous two inputs 15 | * are stored in x1 and x2, and the previous two outputs are stored in y1 and 16 | * y2. 17 | * 18 | * We use double during the coefficients calculation for better accurary, but 19 | * float is used during the actual filtering for faster computation. 20 | */ 21 | struct biquad { 22 | float b0, b1, b2; 23 | float a1, a2; 24 | }; 25 | 26 | /* The type of the biquad filters */ 27 | enum biquad_type { 28 | BQ_LOWPASS, 29 | BQ_HIGHPASS, 30 | }; 31 | 32 | /* Initialize a biquad filter parameters from its type and parameters. 33 | * Args: 34 | * bq - The biquad filter we want to set. 35 | * type - The type of the biquad filter. 36 | * frequency - The value should be in the range [0, 1]. It is relative to 37 | * half of the sampling rate. 38 | */ 39 | void biquad_set(struct biquad *bq, enum biquad_type type, double freq); 40 | 41 | #ifdef __cplusplus 42 | } /* extern "C" */ 43 | #endif 44 | 45 | #endif /* BIQUAD_H_ */ 46 | -------------------------------------------------------------------------------- /src/pulsecore/filter/crossover.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 2 | * Use of this source code is governed by a BSD-style license that can be 3 | * found in the LICENSE file. 4 | */ 5 | 6 | #ifdef HAVE_CONFIG_H 7 | #include 8 | #endif 9 | 10 | #include 11 | 12 | #include "crossover.h" 13 | 14 | void lr4_set(struct lr4 *lr4, enum biquad_type type, float freq) 15 | { 16 | biquad_set(&lr4->bq, type, freq); 17 | lr4->x1 = 0; 18 | lr4->x2 = 0; 19 | lr4->y1 = 0; 20 | lr4->y2 = 0; 21 | lr4->z1 = 0; 22 | lr4->z2 = 0; 23 | } 24 | 25 | void lr4_process_float32(struct lr4 *lr4, int samples, int channels, float *src, float *dest) 26 | { 27 | float lx1 = lr4->x1; 28 | float lx2 = lr4->x2; 29 | float ly1 = lr4->y1; 30 | float ly2 = lr4->y2; 31 | float lz1 = lr4->z1; 32 | float lz2 = lr4->z2; 33 | float lb0 = lr4->bq.b0; 34 | float lb1 = lr4->bq.b1; 35 | float lb2 = lr4->bq.b2; 36 | float la1 = lr4->bq.a1; 37 | float la2 = lr4->bq.a2; 38 | 39 | int i; 40 | for (i = 0; i < samples * channels; i += channels) { 41 | float x, y, z; 42 | x = src[i]; 43 | y = lb0*x + lb1*lx1 + lb2*lx2 - la1*ly1 - la2*ly2; 44 | z = lb0*y + lb1*ly1 + lb2*ly2 - la1*lz1 - la2*lz2; 45 | lx2 = lx1; 46 | lx1 = x; 47 | ly2 = ly1; 48 | ly1 = y; 49 | lz2 = lz1; 50 | lz1 = z; 51 | dest[i] = z; 52 | } 53 | 54 | lr4->x1 = lx1; 55 | lr4->x2 = lx2; 56 | lr4->y1 = ly1; 57 | lr4->y2 = ly2; 58 | lr4->z1 = lz1; 59 | lr4->z2 = lz2; 60 | } 61 | 62 | void lr4_process_s16(struct lr4 *lr4, int samples, int channels, short *src, short *dest) 63 | { 64 | float lx1 = lr4->x1; 65 | float lx2 = lr4->x2; 66 | float ly1 = lr4->y1; 67 | float ly2 = lr4->y2; 68 | float lz1 = lr4->z1; 69 | float lz2 = lr4->z2; 70 | float lb0 = lr4->bq.b0; 71 | float lb1 = lr4->bq.b1; 72 | float lb2 = lr4->bq.b2; 73 | float la1 = lr4->bq.a1; 74 | float la2 = lr4->bq.a2; 75 | 76 | int i; 77 | for (i = 0; i < samples * channels; i += channels) { 78 | float x, y, z; 79 | x = src[i]; 80 | y = lb0*x + lb1*lx1 + lb2*lx2 - la1*ly1 - la2*ly2; 81 | z = lb0*y + lb1*ly1 + lb2*ly2 - la1*lz1 - la2*lz2; 82 | lx2 = lx1; 83 | lx1 = x; 84 | ly2 = ly1; 85 | ly1 = y; 86 | lz2 = lz1; 87 | lz1 = z; 88 | dest[i] = PA_CLAMP_UNLIKELY((int) z, -0x8000, 0x7fff); 89 | } 90 | 91 | lr4->x1 = lx1; 92 | lr4->x2 = lx2; 93 | lr4->y1 = ly1; 94 | lr4->y2 = ly2; 95 | lr4->z1 = lz1; 96 | lr4->z2 = lz2; 97 | } 98 | -------------------------------------------------------------------------------- /src/pulsecore/filter/crossover.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 2 | * Use of this source code is governed by a BSD-style license that can be 3 | * found in the LICENSE file. 4 | */ 5 | 6 | #ifndef CROSSOVER_H_ 7 | #define CROSSOVER_H_ 8 | 9 | #include "biquad.h" 10 | /* An LR4 filter is two biquads with the same parameters connected in series: 11 | * 12 | * x -- [BIQUAD] -- y -- [BIQUAD] -- z 13 | * 14 | * Both biquad filter has the same parameter b[012] and a[12], 15 | * The variable [xyz][12] keep the history values. 16 | */ 17 | struct lr4 { 18 | struct biquad bq; 19 | float x1, x2; 20 | float y1, y2; 21 | float z1, z2; 22 | }; 23 | 24 | void lr4_set(struct lr4 *lr4, enum biquad_type type, float freq); 25 | 26 | void lr4_process_float32(struct lr4 *lr4, int samples, int channels, float *src, float *dest); 27 | void lr4_process_s16(struct lr4 *lr4, int samples, int channels, short *src, short *dest); 28 | 29 | #endif /* CROSSOVER_H_ */ 30 | -------------------------------------------------------------------------------- /src/pulsecore/filter/lfe-filter.h: -------------------------------------------------------------------------------- 1 | #ifndef foolfefilterhfoo 2 | #define foolfefilterhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2014 David Henningsson, Canonical Ltd. 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 22 | USA. 23 | ***/ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | typedef struct pa_lfe_filter pa_lfe_filter_t; 31 | 32 | pa_lfe_filter_t * pa_lfe_filter_new(const pa_sample_spec* ss, const pa_channel_map* cm, float crossover_freq, size_t maxrewind); 33 | void pa_lfe_filter_free(pa_lfe_filter_t *); 34 | void pa_lfe_filter_reset(pa_lfe_filter_t *); 35 | void pa_lfe_filter_rewind(pa_lfe_filter_t *, size_t amount); 36 | pa_memchunk * pa_lfe_filter_process(pa_lfe_filter_t *filter, pa_memchunk *buf); 37 | void pa_lfe_filter_update_rate(pa_lfe_filter_t *, uint32_t new_rate); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/pulsecore/g711.h: -------------------------------------------------------------------------------- 1 | #ifndef foog711hfoo 2 | #define foog711hfoo 3 | 4 | /* g711.h - include for G711 u-law and a-law conversion routines 5 | ** 6 | ** Copyright (C) 2001 Chris Bagwell 7 | ** 8 | ** Permission to use, copy, modify, and distribute this software and its 9 | ** documentation for any purpose and without fee is hereby granted, provided 10 | ** that the above copyright notice appear in all copies and that both that 11 | ** copyright notice and this permission notice appear in supporting 12 | ** documentation. This software is provided "as is" without express or 13 | ** implied warranty. 14 | */ 15 | 16 | /** Copied from sox -- Lennart Poettering */ 17 | 18 | #include 19 | 20 | #ifdef FAST_ALAW_CONVERSION 21 | extern uint8_t _st_13linear2alaw[0x2000]; 22 | extern int16_t _st_alaw2linear16[256]; 23 | #define st_13linear2alaw(sw) (_st_13linear2alaw[(sw + 0x1000)]) 24 | #define st_alaw2linear16(uc) (_st_alaw2linear16[uc]) 25 | #else 26 | unsigned char st_13linear2alaw(int16_t pcm_val); 27 | int16_t st_alaw2linear16(unsigned char); 28 | #endif 29 | 30 | #ifdef FAST_ULAW_CONVERSION 31 | extern uint8_t _st_14linear2ulaw[0x4000]; 32 | extern int16_t _st_ulaw2linear16[256]; 33 | #define st_14linear2ulaw(sw) (_st_14linear2ulaw[(sw + 0x2000)]) 34 | #define st_ulaw2linear16(uc) (_st_ulaw2linear16[uc]) 35 | #else 36 | unsigned char st_14linear2ulaw(int16_t pcm_val); 37 | int16_t st_ulaw2linear16(unsigned char); 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/pulsecore/hook-list.h: -------------------------------------------------------------------------------- 1 | #ifndef foohooklistfoo 2 | #define foohooklistfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | 25 | typedef struct pa_hook_slot pa_hook_slot; 26 | typedef struct pa_hook pa_hook; 27 | 28 | typedef enum pa_hook_result { 29 | PA_HOOK_OK = 0, 30 | PA_HOOK_STOP = 1, 31 | PA_HOOK_CANCEL = -1 32 | } pa_hook_result_t; 33 | 34 | typedef enum pa_hook_priority { 35 | PA_HOOK_EARLY = -100, 36 | PA_HOOK_NORMAL = 0, 37 | PA_HOOK_LATE = 100 38 | } pa_hook_priority_t; 39 | 40 | typedef pa_hook_result_t (*pa_hook_cb_t)( 41 | void *hook_data, 42 | void *call_data, 43 | void *slot_data); 44 | 45 | struct pa_hook_slot { 46 | bool dead; 47 | pa_hook *hook; 48 | pa_hook_priority_t priority; 49 | pa_hook_cb_t callback; 50 | void *data; 51 | PA_LLIST_FIELDS(pa_hook_slot); 52 | }; 53 | 54 | struct pa_hook { 55 | PA_LLIST_HEAD(pa_hook_slot, slots); 56 | int n_firing, n_dead; 57 | 58 | void *data; 59 | }; 60 | 61 | void pa_hook_init(pa_hook *hook, void *data); 62 | void pa_hook_done(pa_hook *hook); 63 | 64 | pa_hook_slot* pa_hook_connect(pa_hook *hook, pa_hook_priority_t prio, pa_hook_cb_t cb, void *data); 65 | void pa_hook_slot_free(pa_hook_slot *slot); 66 | 67 | pa_hook_result_t pa_hook_fire(pa_hook *hook, void *data); 68 | 69 | bool pa_hook_is_firing(pa_hook *hook); 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /src/pulsecore/i18n.c: -------------------------------------------------------------------------------- 1 | /*** 2 | This file is part of PulseAudio. 3 | 4 | Copyright 2008 Lennart Poettering 5 | 6 | PulseAudio is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as 8 | published by the Free Software Foundation; either version 2.1 of the 9 | License, or (at your option) any later version. 10 | 11 | PulseAudio is distributed in the hope that it will be useful, but 12 | WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with PulseAudio; if not, see . 18 | ***/ 19 | 20 | #ifdef HAVE_CONFIG_H 21 | #include 22 | #endif 23 | 24 | #include 25 | 26 | #include "i18n.h" 27 | 28 | void pa_init_i18n(void) { 29 | #ifdef ENABLE_NLS 30 | PA_ONCE_BEGIN { 31 | 32 | bindtextdomain(GETTEXT_PACKAGE, PULSE_LOCALEDIR); 33 | bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); 34 | 35 | } PA_ONCE_END; 36 | #endif 37 | } 38 | -------------------------------------------------------------------------------- /src/pulsecore/i18n.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsei18nhfoo 2 | #define foopulsei18nhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2008 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | 25 | PA_C_DECL_BEGIN 26 | 27 | #ifdef ENABLE_NLS 28 | 29 | #if !defined(GETTEXT_PACKAGE) 30 | #error "Something is very wrong here, config.h needs to be included first" 31 | #endif 32 | 33 | #include 34 | 35 | #define _(String) dgettext(GETTEXT_PACKAGE, String) 36 | #ifdef gettext_noop 37 | #define N_(String) gettext_noop(String) 38 | #else 39 | #define N_(String) (String) 40 | #endif 41 | 42 | #else /* NLS is disabled */ 43 | 44 | #define _(String) (String) 45 | #define N_(String) (String) 46 | #define textdomain(String) (String) 47 | #define gettext(String) (String) 48 | #define dgettext(Domain,String) (String) 49 | #define dcgettext(Domain,String,Type) (String) 50 | #define ngettext(SingularString,PluralString,N) (PluralString) 51 | #define dngettext(Domain,SingularString,PluralString,N) (PluralString) 52 | #define dcngettext(Domain,SingularString,PluralString,N,Type) (PluralString) 53 | #define bindtextdomain(Domain,Directory) (Domain) 54 | #define bind_textdomain_codeset(Domain,Codeset) (Codeset) 55 | 56 | #endif /* ENABLE_NLS */ 57 | 58 | void pa_init_i18n(void); 59 | 60 | PA_C_DECL_END 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/pulsecore/ioline.h: -------------------------------------------------------------------------------- 1 | #ifndef fooiolinehfoo 2 | #define fooiolinehfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | 25 | #include 26 | 27 | /* An ioline wraps an iochannel for line based communication. A 28 | * callback function is called whenever a new line has been received 29 | * from the client */ 30 | 31 | typedef struct pa_ioline pa_ioline; 32 | 33 | typedef void (*pa_ioline_cb_t)(pa_ioline*io, const char *s, void *userdata); 34 | typedef void (*pa_ioline_drain_cb_t)(pa_ioline *io, void *userdata); 35 | 36 | pa_ioline* pa_ioline_new(pa_iochannel *io); 37 | void pa_ioline_unref(pa_ioline *l); 38 | pa_ioline* pa_ioline_ref(pa_ioline *l); 39 | void pa_ioline_close(pa_ioline *l); 40 | 41 | /* Write a string to the channel */ 42 | void pa_ioline_puts(pa_ioline *s, const char *c); 43 | 44 | /* Write a string to the channel */ 45 | void pa_ioline_printf(pa_ioline *s, const char *format, ...) PA_GCC_PRINTF_ATTR(2,3); 46 | 47 | /* Set the callback function that is called for every received line */ 48 | void pa_ioline_set_callback(pa_ioline*io, pa_ioline_cb_t callback, void *userdata); 49 | 50 | /* Set the callback function that is called when everything has been written */ 51 | void pa_ioline_set_drain_callback(pa_ioline*io, pa_ioline_drain_cb_t callback, void *userdata); 52 | 53 | /* Make sure to close the ioline object as soon as the send buffer is emptied */ 54 | void pa_ioline_defer_close(pa_ioline *io); 55 | 56 | /* Returns true when everything was written */ 57 | bool pa_ioline_is_drained(pa_ioline *io); 58 | 59 | /* Detaches from the iochannel and returns it. Data that has already 60 | * been read will not be available in the detached iochannel */ 61 | pa_iochannel* pa_ioline_detach_iochannel(pa_ioline *l); 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/pulsecore/ipacl.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsecoreipaclhfoo 2 | #define foopulsecoreipaclhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | Copyright 2006 Pierre Ossman for Cendio AB 9 | 10 | PulseAudio is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU Lesser General Public License as 12 | published by the Free Software Foundation; either version 2.1 of the 13 | License, or (at your option) any later version. 14 | 15 | PulseAudio is distributed in the hope that it will be useful, but 16 | WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with PulseAudio; if not, see . 22 | ***/ 23 | 24 | typedef struct pa_ip_acl pa_ip_acl; 25 | 26 | pa_ip_acl* pa_ip_acl_new(const char *s); 27 | void pa_ip_acl_free(pa_ip_acl *acl); 28 | int pa_ip_acl_check(pa_ip_acl *acl, int fd); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/pulsecore/lock-autospawn.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulselockautospawnhfoo 2 | #define foopulselockautospawnhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2008 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | 25 | int pa_autospawn_lock_init(void); 26 | int pa_autospawn_lock_acquire(bool block); 27 | void pa_autospawn_lock_release(void); 28 | void pa_autospawn_lock_done(bool after_fork); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/pulsecore/ltdl-helper.c: -------------------------------------------------------------------------------- 1 | /*** 2 | This file is part of PulseAudio. 3 | 4 | Copyright 2004-2006 Lennart Poettering 5 | Copyright 2006 Pierre Ossman for Cendio AB 6 | 7 | PulseAudio is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published 9 | by the Free Software Foundation; either version 2.1 of the License, 10 | or (at your option) any later version. 11 | 12 | PulseAudio is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with PulseAudio; if not, see . 19 | ***/ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include 23 | #endif 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | #include 31 | #include 32 | 33 | #include "ltdl-helper.h" 34 | 35 | pa_void_func_t pa_load_sym(lt_dlhandle handle, const char *module, const char *symbol) { 36 | char *sn, *c; 37 | pa_void_func_t f; 38 | 39 | pa_assert(handle); 40 | pa_assert(symbol); 41 | 42 | f = (pa_void_func_t) lt_dlsym(handle, symbol); 43 | 44 | if (f) 45 | return f; 46 | 47 | if (!module) 48 | return NULL; 49 | 50 | /* As the .la files might have been cleansed from the system, we should 51 | * try with the ltdl prefix as well. */ 52 | 53 | sn = pa_sprintf_malloc("%s_LTX_%s", module, symbol); 54 | 55 | for (c = sn; *c; c++) 56 | if (!isalnum((unsigned char)*c)) 57 | *c = '_'; 58 | 59 | f = (pa_void_func_t) lt_dlsym(handle, sn); 60 | pa_xfree(sn); 61 | 62 | return f; 63 | } 64 | -------------------------------------------------------------------------------- /src/pulsecore/ltdl-helper.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsecoreltdlhelperhfoo 2 | #define foopulsecoreltdlhelperhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | 25 | typedef void (*pa_void_func_t)(void); 26 | 27 | pa_void_func_t pa_load_sym(lt_dlhandle handle, const char*module, const char *symbol); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/pulsecore/mem.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsememhfoo 2 | #define foopulsememhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2016 Ahmed S. Darwish 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | typedef enum pa_mem_type { 29 | PA_MEM_TYPE_SHARED_POSIX, /* Data is shared and created using POSIX shm_open() */ 30 | PA_MEM_TYPE_SHARED_MEMFD, /* Data is shared and created using Linux memfd_create() */ 31 | PA_MEM_TYPE_PRIVATE, /* Data is private and created using classic memory allocation 32 | (posix_memalign(), malloc() or anonymous mmap()) */ 33 | } pa_mem_type_t; 34 | 35 | static inline const char *pa_mem_type_to_string(pa_mem_type_t type) { 36 | switch (type) { 37 | case PA_MEM_TYPE_SHARED_POSIX: 38 | return "shared posix-shm"; 39 | case PA_MEM_TYPE_SHARED_MEMFD: 40 | return "shared memfd"; 41 | case PA_MEM_TYPE_PRIVATE: 42 | return "private"; 43 | } 44 | 45 | pa_assert_not_reached(); 46 | } 47 | 48 | static inline bool pa_mem_type_is_shared(pa_mem_type_t t) { 49 | return (t == PA_MEM_TYPE_SHARED_POSIX) || (t == PA_MEM_TYPE_SHARED_MEMFD); 50 | } 51 | 52 | static inline bool pa_memfd_is_locally_supported(void) { 53 | #if defined(HAVE_CREDS) && defined(HAVE_MEMFD) 54 | return true; 55 | #else 56 | return false; 57 | #endif 58 | } 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /src/pulsecore/memchunk.h: -------------------------------------------------------------------------------- 1 | #ifndef foomemchunkhfoo 2 | #define foomemchunkhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | typedef struct pa_memchunk pa_memchunk; 24 | 25 | #include 26 | 27 | /* A memchunk describes a part of a memblock. In contrast to the memblock, a 28 | * memchunk is not allocated dynamically or reference counted, instead 29 | * it is usually stored on the stack and copied around */ 30 | 31 | struct pa_memchunk { 32 | pa_memblock *memblock; 33 | size_t index, length; 34 | }; 35 | 36 | /* Make a memchunk writable, i.e. make sure that the caller may have 37 | * exclusive access to the memblock and it is not read-only. If needed 38 | * the memblock in the structure is replaced by a copy. If min is not 39 | * 0 it is made sure that the returned memblock is at least of the 40 | * specified size, i.e. is enlarged if necessary. */ 41 | pa_memchunk* pa_memchunk_make_writable(pa_memchunk *c, size_t min); 42 | 43 | /* Invalidate a memchunk. This does not free the containing memblock, 44 | * but sets all members to zero. */ 45 | pa_memchunk* pa_memchunk_reset(pa_memchunk *c); 46 | 47 | /* Map a memory chunk back into memory if it was swapped out */ 48 | pa_memchunk *pa_memchunk_will_need(const pa_memchunk *c); 49 | 50 | /* Copy the data in the src memchunk to the dst memchunk */ 51 | pa_memchunk* pa_memchunk_memcpy(pa_memchunk *dst, pa_memchunk *src); 52 | 53 | /* Return true if any field is set != 0 */ 54 | bool pa_memchunk_isset(pa_memchunk *c); 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /src/pulsecore/memfd-wrappers.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsememfdwrappershfoo 2 | #define foopulsememfdwrappershfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2016 Ahmed S. Darwish 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #if defined(HAVE_MEMFD) && !defined(HAVE_MEMFD_CREATE) 24 | 25 | #include 26 | #include 27 | 28 | /* 29 | * Before glibc version 2.27 there was no wrapper for memfd_create(2), 30 | * so we have to provide our own. 31 | * 32 | * Also define memfd fcntl sealing macros. While they are already 33 | * defined in the kernel header file , that file as 34 | * a whole conflicts with the original glibc header . 35 | */ 36 | 37 | static inline int memfd_create(const char *name, unsigned int flags) { 38 | return syscall(SYS_memfd_create, name, flags); 39 | } 40 | 41 | /* memfd_create(2) flags */ 42 | 43 | #ifndef MFD_CLOEXEC 44 | #define MFD_CLOEXEC 0x0001U 45 | #endif 46 | 47 | #ifndef MFD_ALLOW_SEALING 48 | #define MFD_ALLOW_SEALING 0x0002U 49 | #endif 50 | 51 | /* fcntl() seals-related flags */ 52 | 53 | #ifndef F_LINUX_SPECIFIC_BASE 54 | #define F_LINUX_SPECIFIC_BASE 1024 55 | #endif 56 | 57 | #ifndef F_ADD_SEALS 58 | #define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9) 59 | #define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10) 60 | 61 | #define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */ 62 | #define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */ 63 | #define F_SEAL_GROW 0x0004 /* prevent file from growing */ 64 | #define F_SEAL_WRITE 0x0008 /* prevent writes */ 65 | #endif 66 | 67 | #endif /* HAVE_MEMFD && !HAVE_MEMFD_CREATE */ 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /src/pulsecore/memtrap.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsecorememtraphfoo 2 | #define foopulsecorememtraphfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2009 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | 25 | #include 26 | 27 | /* This subsystem will trap SIGBUS on specific memory regions. The 28 | * regions will be remapped to anonymous memory (i.e. writable NUL 29 | * bytes) on SIGBUS, so that execution of the main program can 30 | * continue though with memory having changed beneath its hands. With 31 | * pa_memtrap_is_good() it is possible to query if a memory region is 32 | * still 'good' i.e. no SIGBUS has happened yet for it. 33 | * 34 | * Intended usage is to handle memory mapped in which is controlled by 35 | * other processes that might execute ftruncate() or when mapping inb 36 | * hardware resources that might get invalidated when unplugged. */ 37 | 38 | typedef struct pa_memtrap pa_memtrap; 39 | 40 | pa_memtrap* pa_memtrap_add(const void *start, size_t size); 41 | pa_memtrap *pa_memtrap_update(pa_memtrap *m, const void *start, size_t size); 42 | 43 | void pa_memtrap_remove(pa_memtrap *m); 44 | 45 | bool pa_memtrap_is_good(pa_memtrap *m); 46 | 47 | void pa_memtrap_install(void); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/pulsecore/message-handler.h: -------------------------------------------------------------------------------- 1 | #ifndef foocoremessageshfoo 2 | #define foocoremessageshfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | PulseAudio is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published 9 | by the Free Software Foundation; either version 2.1 of the License, 10 | or (at your option) any later version. 11 | 12 | PulseAudio is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with PulseAudio; if not, see . 19 | ***/ 20 | 21 | #include 22 | #include 23 | 24 | /* Message handler types and functions */ 25 | 26 | /* Prototype for message callback */ 27 | typedef int (*pa_message_handler_cb_t)( 28 | const char *object_path, 29 | const char *message, 30 | const pa_json_object *parameters, 31 | char **response, 32 | void *userdata); 33 | 34 | /* Message handler object */ 35 | struct pa_message_handler { 36 | char *object_path; 37 | char *description; 38 | pa_message_handler_cb_t callback; 39 | void *userdata; 40 | }; 41 | 42 | /* Handler registration */ 43 | void pa_message_handler_register(pa_core *c, const char *object_path, const char *description, pa_message_handler_cb_t cb, void *userdata); 44 | void pa_message_handler_unregister(pa_core *c, const char *object_path); 45 | 46 | /* Send message to the specified object path */ 47 | int pa_message_handler_send_message(pa_core *c, const char *object_path, const char *message, const char *message_parameters, char **response); 48 | 49 | /* Set handler description */ 50 | int pa_message_handler_set_description(pa_core *c, const char *object_path, const char *description); 51 | #endif 52 | -------------------------------------------------------------------------------- /src/pulsecore/mime-type.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsecoremimetypehfoo 2 | #define foopulsecoremimetypehfoo 3 | /*** 4 | This file is part of PulseAudio. 5 | 6 | Copyright 2009 Lennart Poettering 7 | 8 | PulseAudio is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published 10 | by the Free Software Foundation; either version 2.1 of the License, 11 | or (at your option) any later version. 12 | 13 | PulseAudio is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with PulseAudio; if not, see . 20 | ***/ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | bool pa_sample_spec_is_mime(const pa_sample_spec *ss, const pa_channel_map *cm); 27 | void pa_sample_spec_mimefy(pa_sample_spec *ss, pa_channel_map *cm); 28 | char *pa_sample_spec_to_mime_type(const pa_sample_spec *ss, const pa_channel_map *cm); 29 | char *pa_sample_spec_to_mime_type_mimefy(const pa_sample_spec *_ss, const pa_channel_map *_cm); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/pulsecore/mix.h: -------------------------------------------------------------------------------- 1 | #ifndef foomixhfoo 2 | #define foomixhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | Copyright 2006 Pierre Ossman for Cendio AB 9 | Copyright 2013 Peter Meerwald 10 | 11 | PulseAudio is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU Lesser General Public License as published 13 | by the Free Software Foundation; either version 2.1 of the License, 14 | or (at your option) any later version. 15 | 16 | PulseAudio is distributed in the hope that it will be useful, but 17 | WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | General Public License for more details. 20 | 21 | You should have received a copy of the GNU Lesser General Public License 22 | along with PulseAudio; if not, see . 23 | ***/ 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | typedef struct pa_mix_info { 30 | pa_memchunk chunk; 31 | pa_cvolume volume; 32 | void *userdata; 33 | 34 | /* The following fields are used internally by pa_mix(), should 35 | * not be initialised by the caller of pa_mix(). */ 36 | void *ptr; 37 | union { 38 | int32_t i; 39 | float f; 40 | } linear[PA_CHANNELS_MAX]; 41 | } pa_mix_info; 42 | 43 | size_t pa_mix( 44 | pa_mix_info channels[], 45 | unsigned nchannels, 46 | void *data, 47 | size_t length, 48 | const pa_sample_spec *spec, 49 | const pa_cvolume *volume, 50 | bool mute); 51 | 52 | typedef void (*pa_do_mix_func_t) (pa_mix_info streams[], unsigned nstreams, unsigned channels, void *data, unsigned length); 53 | 54 | pa_do_mix_func_t pa_get_mix_func(pa_sample_format_t f); 55 | void pa_set_mix_func(pa_sample_format_t f, pa_do_mix_func_t func); 56 | 57 | void pa_volume_memchunk( 58 | pa_memchunk*c, 59 | const pa_sample_spec *spec, 60 | const pa_cvolume *volume); 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/pulsecore/modinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef foomodinfohfoo 2 | #define foomodinfohfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | /* Some functions for reading module meta data from PulseAudio modules */ 24 | #include 25 | 26 | typedef struct pa_modinfo { 27 | char *author; 28 | char *description; 29 | char *usage; 30 | char *version; 31 | char *deprecated; 32 | bool load_once; 33 | } pa_modinfo; 34 | 35 | /* Read meta data from an libtool handle */ 36 | pa_modinfo *pa_modinfo_get_by_handle(lt_dlhandle dl, const char *module_name); 37 | 38 | /* Read meta data from a module file */ 39 | pa_modinfo *pa_modinfo_get_by_name(const char *name); 40 | 41 | /* Free meta data */ 42 | void pa_modinfo_free(pa_modinfo *i); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/pulsecore/msgobject.c: -------------------------------------------------------------------------------- 1 | /*** 2 | This file is part of PulseAudio. 3 | 4 | Copyright 2004-2006 Lennart Poettering 5 | Copyright 2006 Pierre Ossman for Cendio AB 6 | 7 | PulseAudio is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published 9 | by the Free Software Foundation; either version 2.1 of the License, 10 | or (at your option) any later version. 11 | 12 | PulseAudio is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with PulseAudio; if not, see . 19 | ***/ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include 23 | #endif 24 | 25 | #include "msgobject.h" 26 | 27 | PA_DEFINE_PUBLIC_CLASS(pa_msgobject, pa_object); 28 | 29 | pa_msgobject *pa_msgobject_new_internal(size_t size, const char *type_id, bool (*check_type)(const char *type_name)) { 30 | pa_msgobject *o; 31 | 32 | pa_assert(size >= sizeof(pa_msgobject)); 33 | pa_assert(type_id); 34 | 35 | if (!check_type) 36 | check_type = pa_msgobject_check_type; 37 | 38 | pa_assert(check_type(type_id)); 39 | pa_assert(check_type(pa_object_type_id)); 40 | pa_assert(check_type(pa_msgobject_type_id)); 41 | 42 | o = PA_MSGOBJECT(pa_object_new_internal(size, type_id, check_type)); 43 | o->process_msg = NULL; 44 | return o; 45 | } 46 | -------------------------------------------------------------------------------- /src/pulsecore/msgobject.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsemsgobjecthfoo 2 | #define foopulsemsgobjecthfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | Copyright 2006 Pierre Ossman for Cendio AB 9 | 10 | PulseAudio is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU Lesser General Public License as published 12 | by the Free Software Foundation; either version 2.1 of the License, 13 | or (at your option) any later version. 14 | 15 | PulseAudio is distributed in the hope that it will be useful, but 16 | WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License 21 | along with PulseAudio; if not, see . 22 | ***/ 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | typedef struct pa_msgobject pa_msgobject; 31 | 32 | struct pa_msgobject { 33 | pa_object parent; 34 | int (*process_msg)(pa_msgobject *o, int code, void *userdata, int64_t offset, pa_memchunk *chunk); 35 | }; 36 | 37 | pa_msgobject *pa_msgobject_new_internal(size_t size, const char *type_id, bool (*check_type)(const char *type_name)); 38 | 39 | #define pa_msgobject_new(type) ((type*) pa_msgobject_new_internal(sizeof(type), type##_type_id, type##_check_type)) 40 | #define pa_msgobject_free ((void (*) (pa_msgobject* o)) pa_object_free) 41 | 42 | #define PA_MSGOBJECT(o) pa_msgobject_cast(o) 43 | 44 | PA_DECLARE_PUBLIC_CLASS(pa_msgobject); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/pulsecore/mutex.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsemutexhfoo 2 | #define foopulsemutexhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | 26 | typedef struct pa_mutex pa_mutex; 27 | 28 | /* Please think twice before enabling priority inheritance. This is no 29 | * magic wand! Use it only when the potentially prioritized threads are 30 | * good candidates for it. Don't use this blindly! Also, note that 31 | * only very few operating systems actually implement this, hence this 32 | * is merely a hint. */ 33 | pa_mutex* pa_mutex_new(bool recursive, bool inherit_priority); 34 | 35 | void pa_mutex_free(pa_mutex *m); 36 | void pa_mutex_lock(pa_mutex *m); 37 | bool pa_mutex_try_lock(pa_mutex *m); 38 | void pa_mutex_unlock(pa_mutex *m); 39 | 40 | typedef struct pa_cond pa_cond; 41 | 42 | pa_cond *pa_cond_new(void); 43 | void pa_cond_free(pa_cond *c); 44 | void pa_cond_signal(pa_cond *c, int broadcast); 45 | int pa_cond_wait(pa_cond *c, pa_mutex *m); 46 | 47 | /* Static mutexes are basically just atomically updated pointers to pa_mutex objects */ 48 | 49 | typedef struct pa_static_mutex { 50 | pa_atomic_ptr_t ptr; 51 | } pa_static_mutex; 52 | 53 | #define PA_STATIC_MUTEX_INIT { PA_ATOMIC_PTR_INIT(NULL) } 54 | 55 | pa_mutex* pa_static_mutex_get(pa_static_mutex *m, bool recursive, bool inherit_priority); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/pulsecore/namereg.h: -------------------------------------------------------------------------------- 1 | #ifndef foonamereghfoo 2 | #define foonamereghfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | 26 | #define PA_NAME_MAX 128 27 | 28 | typedef enum pa_namereg_type { 29 | PA_NAMEREG_SINK, 30 | PA_NAMEREG_SOURCE, 31 | PA_NAMEREG_SAMPLE, 32 | PA_NAMEREG_CARD 33 | } pa_namereg_type_t; 34 | 35 | const char *pa_namereg_register(pa_core *c, const char *name, pa_namereg_type_t type, void *data, bool fail); 36 | void pa_namereg_unregister(pa_core *c, const char *name); 37 | void* pa_namereg_get(pa_core *c, const char *name, pa_namereg_type_t type); 38 | 39 | bool pa_namereg_is_valid_name(const char *name); 40 | bool pa_namereg_is_valid_name_or_wildcard(const char *name, pa_namereg_type_t type); 41 | char* pa_namereg_make_valid_name(const char *name); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/pulsecore/native-common.c: -------------------------------------------------------------------------------- 1 | /*** 2 | This file is part of PulseAudio. 3 | 4 | Copyright 2016 Ahmed S. Darwish 5 | 6 | PulseAudio is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as 8 | published by the Free Software Foundation; either version 2.1 of the 9 | License, or (at your option) any later version. 10 | 11 | PulseAudio is distributed in the hope that it will be useful, but 12 | WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with PulseAudio; if not, see . 18 | ***/ 19 | 20 | #ifdef HAVE_CONFIG_H 21 | #include 22 | #endif 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "native-common.h" 32 | 33 | /* 34 | * Command handlers shared between client and server 35 | */ 36 | 37 | /* Check pa_pstream_register_memfd_mempool() for further details */ 38 | int pa_common_command_register_memfd_shmid(pa_pstream *p, pa_pdispatch *pd, uint32_t version, 39 | uint32_t command, pa_tagstruct *t) { 40 | #if defined(HAVE_CREDS) && defined(HAVE_MEMFD) 41 | pa_cmsg_ancil_data *ancil = NULL; 42 | unsigned shm_id; 43 | int ret = -1; 44 | 45 | pa_assert(pd); 46 | pa_assert(command == PA_COMMAND_REGISTER_MEMFD_SHMID); 47 | pa_assert(t); 48 | 49 | ancil = pa_pdispatch_take_ancil_data(pd); 50 | if (!ancil) 51 | goto finish; 52 | 53 | /* Upon fd leaks and reaching our open fd limit, recvmsg(2) 54 | * just strips all passed fds from the ancillary data */ 55 | if (ancil->nfd == 0) { 56 | pa_log("Expected 1 memfd fd to be received over pipe; got 0"); 57 | pa_log("Did we reach our open file descriptors limit?"); 58 | goto finish; 59 | } 60 | 61 | if (ancil->nfd != 1 || ancil->fds[0] == -1) 62 | goto finish; 63 | 64 | if (version < 31 || pa_tagstruct_getu32(t, &shm_id) < 0 || !pa_tagstruct_eof(t)) 65 | goto finish; 66 | 67 | pa_pstream_attach_memfd_shmid(p, shm_id, ancil->fds[0]); 68 | 69 | ret = 0; 70 | finish: 71 | if (ancil) 72 | pa_cmsg_ancil_data_close_fds(ancil); 73 | 74 | return ret; 75 | #else 76 | return -1; 77 | #endif 78 | } 79 | -------------------------------------------------------------------------------- /src/pulsecore/object.c: -------------------------------------------------------------------------------- 1 | /*** 2 | This file is part of PulseAudio. 3 | 4 | Copyright 2004-2006 Lennart Poettering 5 | Copyright 2006 Pierre Ossman for Cendio AB 6 | 7 | PulseAudio is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published 9 | by the Free Software Foundation; either version 2.1 of the License, 10 | or (at your option) any later version. 11 | 12 | PulseAudio is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with PulseAudio; if not, see . 19 | ***/ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include 23 | #endif 24 | 25 | #include "object.h" 26 | 27 | const char pa_object_type_id[] = "pa_object"; 28 | 29 | pa_object *pa_object_new_internal(size_t size, const char *type_id, bool (*check_type)(const char *type_id)) { 30 | pa_object *o; 31 | 32 | pa_assert(size > sizeof(pa_object)); 33 | pa_assert(type_id); 34 | 35 | if (!check_type) 36 | check_type = pa_object_check_type; 37 | 38 | pa_assert(check_type(type_id)); 39 | pa_assert(check_type(pa_object_type_id)); 40 | 41 | o = pa_xmalloc0(size); 42 | PA_REFCNT_INIT(o); 43 | o->type_id = type_id; 44 | o->free = pa_object_free; 45 | o->check_type = check_type; 46 | 47 | return o; 48 | } 49 | 50 | pa_object *pa_object_ref(pa_object *o) { 51 | pa_object_assert_ref(o); 52 | 53 | PA_REFCNT_INC(o); 54 | return o; 55 | } 56 | 57 | void pa_object_unref(pa_object *o) { 58 | pa_object_assert_ref(o); 59 | 60 | if (PA_REFCNT_DEC(o) <= 0) { 61 | pa_assert(o->free); 62 | o->free(o); 63 | } 64 | } 65 | 66 | bool pa_object_check_type(const char *type_id) { 67 | pa_assert(type_id); 68 | 69 | return type_id == pa_object_type_id; 70 | } 71 | -------------------------------------------------------------------------------- /src/pulsecore/once.c: -------------------------------------------------------------------------------- 1 | /*** 2 | This file is part of PulseAudio. 3 | 4 | Copyright 2006 Lennart Poettering 5 | 6 | PulseAudio is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published 8 | by the Free Software Foundation; either version 2.1 of the License, 9 | or (at your option) any later version. 10 | 11 | PulseAudio is distributed in the hope that it will be useful, but 12 | WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with PulseAudio; if not, see . 18 | ***/ 19 | 20 | #ifdef HAVE_CONFIG_H 21 | #include 22 | #endif 23 | 24 | #include 25 | 26 | #include "once.h" 27 | 28 | /* See http://www.hpl.hp.com/research/linux/atomic_ops/example.php4 for the 29 | * reference algorithm used here. */ 30 | 31 | bool pa_once_begin(pa_once *control) { 32 | pa_mutex *m; 33 | 34 | pa_assert(control); 35 | 36 | if (pa_atomic_load(&control->done)) 37 | return false; 38 | 39 | /* Caveat: We have to make sure that the once func has completed 40 | * before returning, even if the once func is not actually 41 | * executed by us. Hence the awkward locking. */ 42 | 43 | m = pa_static_mutex_get(&control->mutex, false, false); 44 | pa_mutex_lock(m); 45 | 46 | if (pa_atomic_load(&control->done)) { 47 | pa_mutex_unlock(m); 48 | return false; 49 | } 50 | 51 | return true; 52 | } 53 | 54 | void pa_once_end(pa_once *control) { 55 | pa_mutex *m; 56 | 57 | pa_assert(control); 58 | 59 | pa_assert(!pa_atomic_load(&control->done)); 60 | pa_atomic_store(&control->done, 1); 61 | 62 | m = pa_static_mutex_get(&control->mutex, false, false); 63 | pa_mutex_unlock(m); 64 | } 65 | 66 | /* Not reentrant -- how could it be? */ 67 | void pa_run_once(pa_once *control, pa_once_func_t func) { 68 | pa_assert(control); 69 | pa_assert(func); 70 | 71 | if (pa_once_begin(control)) { 72 | func(); 73 | pa_once_end(control); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/pulsecore/once.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulseoncehfoo 2 | #define foopulseoncehfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | 26 | typedef struct pa_once { 27 | pa_static_mutex mutex; 28 | pa_atomic_t done; 29 | } pa_once; 30 | 31 | #define PA_ONCE_INIT \ 32 | { \ 33 | .mutex = PA_STATIC_MUTEX_INIT, \ 34 | .done = PA_ATOMIC_INIT(0) \ 35 | } 36 | 37 | /* Not to be called directly, use the macros defined below instead */ 38 | bool pa_once_begin(pa_once *o); 39 | void pa_once_end(pa_once *o); 40 | 41 | #define PA_ONCE_BEGIN \ 42 | do { \ 43 | static pa_once _once = PA_ONCE_INIT; \ 44 | if (pa_once_begin(&_once)) {{ 45 | 46 | #define PA_ONCE_END \ 47 | } \ 48 | pa_once_end(&_once); \ 49 | } \ 50 | } while(0) 51 | 52 | /* 53 | 54 | Usage of these macros is like this: 55 | 56 | void foo() { 57 | 58 | PA_ONCE_BEGIN { 59 | 60 | ... stuff to be called just once ... 61 | 62 | } PA_ONCE_END; 63 | } 64 | 65 | */ 66 | 67 | /* Same API but calls a function */ 68 | typedef void (*pa_once_func_t) (void); 69 | void pa_run_once(pa_once *o, pa_once_func_t f); 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /src/pulsecore/packet.h: -------------------------------------------------------------------------------- 1 | #ifndef foopackethfoo 2 | #define foopackethfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | 26 | typedef struct pa_packet pa_packet; 27 | 28 | /* create empty packet (either of type appended or dynamic depending 29 | * on length) */ 30 | pa_packet* pa_packet_new(size_t length); 31 | 32 | /* create packet (either of type appended or dynamic depending on length) 33 | * and copy data */ 34 | pa_packet* pa_packet_new_data(const void* data, size_t length); 35 | 36 | /* data must have been malloc()ed; the packet takes ownership of the memory, 37 | * i.e. memory is free()d with the packet */ 38 | pa_packet* pa_packet_new_dynamic(void* data, size_t length); 39 | 40 | const void* pa_packet_data(pa_packet *p, size_t *l); 41 | 42 | pa_packet* pa_packet_ref(pa_packet *p); 43 | void pa_packet_unref(pa_packet *p); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/pulsecore/parseaddr.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsecoreparseaddrhfoo 2 | #define foopulsecoreparseaddrhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | 25 | #include 26 | 27 | typedef enum pa_parsed_address_type { 28 | PA_PARSED_ADDRESS_UNIX, 29 | PA_PARSED_ADDRESS_TCP4, 30 | PA_PARSED_ADDRESS_TCP6, 31 | PA_PARSED_ADDRESS_TCP_AUTO 32 | } pa_parsed_address_type_t; 33 | 34 | typedef struct pa_parsed_address { 35 | pa_parsed_address_type_t type; 36 | char *path_or_host; 37 | uint16_t port; 38 | } pa_parsed_address; 39 | 40 | int pa_parse_address(const char *a, pa_parsed_address *ret_p); 41 | 42 | bool pa_is_ip_address(const char *a); 43 | 44 | bool pa_is_ip6_address(const char *a); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/pulsecore/pdispatch.h: -------------------------------------------------------------------------------- 1 | #ifndef foopdispatchhfoo 2 | #define foopdispatchhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | Copyright 2006 Pierre Ossman for Cendio AB 9 | 10 | PulseAudio is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU Lesser General Public License as 12 | published by the Free Software Foundation; either version 2.1 of the 13 | License, or (at your option) any later version. 14 | 15 | PulseAudio is distributed in the hope that it will be useful, but 16 | WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with PulseAudio; if not, see . 22 | ***/ 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | typedef struct pa_pdispatch pa_pdispatch; 34 | 35 | typedef void (*pa_pdispatch_cb_t)(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata); 36 | typedef void (*pa_pdispatch_drain_cb_t)(pa_pdispatch *pd, void *userdata); 37 | 38 | pa_pdispatch* pa_pdispatch_new(pa_mainloop_api *m, bool use_rtclock, const pa_pdispatch_cb_t *table, unsigned entries); 39 | void pa_pdispatch_unref(pa_pdispatch *pd); 40 | pa_pdispatch* pa_pdispatch_ref(pa_pdispatch *pd); 41 | 42 | int pa_pdispatch_run(pa_pdispatch *pd, pa_packet *p, pa_cmsg_ancil_data *ancil_data, void *userdata); 43 | 44 | 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); 45 | 46 | int pa_pdispatch_is_pending(pa_pdispatch *pd); 47 | 48 | void pa_pdispatch_set_drain_callback(pa_pdispatch *pd, pa_pdispatch_drain_cb_t callback, void *userdata); 49 | 50 | /* Remove all reply slots with the give userdata parameter */ 51 | void pa_pdispatch_unregister_reply(pa_pdispatch *pd, void *userdata); 52 | 53 | const pa_creds * pa_pdispatch_creds(pa_pdispatch *pd); 54 | pa_cmsg_ancil_data *pa_pdispatch_take_ancil_data(pa_pdispatch *pd); 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /src/pulsecore/pid.h: -------------------------------------------------------------------------------- 1 | #ifndef foopidhfoo 2 | #define foopidhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | int pa_pid_file_create(const char *procname); 24 | int pa_pid_file_remove(void); 25 | int pa_pid_file_check_running(pid_t *pid, const char *procname); 26 | int pa_pid_file_kill(int sig, pid_t *pid, const char *procname); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/pulsecore/pipe.h: -------------------------------------------------------------------------------- 1 | #ifndef foopipehfoo 2 | #define foopipehfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2006 Pierre Ossman for Cendio AB 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #ifndef HAVE_PIPE 24 | 25 | int pipe(int filedes[2]); 26 | 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/pulsecore/play-memblockq.h: -------------------------------------------------------------------------------- 1 | #ifndef fooplaymemblockqhfoo 2 | #define fooplaymemblockqhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | 26 | pa_sink_input* pa_memblockq_sink_input_new( 27 | pa_sink *sink, 28 | const pa_sample_spec *ss, 29 | const pa_channel_map *map, 30 | pa_memblockq *q, 31 | pa_cvolume *volume, 32 | pa_proplist *p, 33 | pa_sink_input_flags_t flags); 34 | 35 | void pa_memblockq_sink_input_set_queue(pa_sink_input *i, pa_memblockq *q); 36 | 37 | int pa_play_memblockq( 38 | pa_sink *sink, 39 | const pa_sample_spec *ss, 40 | const pa_channel_map *map, 41 | pa_memblockq *q, 42 | pa_cvolume *cvolume, 43 | pa_proplist *p, 44 | pa_sink_input_flags_t flags, 45 | uint32_t *sink_input_index); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/pulsecore/play-memchunk.c: -------------------------------------------------------------------------------- 1 | /*** 2 | This file is part of PulseAudio. 3 | 4 | Copyright 2004-2008 Lennart Poettering 5 | 6 | PulseAudio is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published 8 | by the Free Software Foundation; either version 2.1 of the License, 9 | or (at your option) any later version. 10 | 11 | PulseAudio is distributed in the hope that it will be useful, but 12 | WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with PulseAudio; if not, see . 18 | ***/ 19 | 20 | #ifdef HAVE_CONFIG_H 21 | #include 22 | #endif 23 | 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | #include "play-memchunk.h" 31 | 32 | int pa_play_memchunk( 33 | pa_sink *sink, 34 | const pa_sample_spec *ss, 35 | const pa_channel_map *map, 36 | const pa_memchunk *chunk, 37 | pa_cvolume *volume, 38 | pa_proplist *p, 39 | pa_sink_input_flags_t flags, 40 | uint32_t *sink_input_index) { 41 | 42 | pa_memblockq *q; 43 | int r; 44 | pa_memchunk silence; 45 | 46 | pa_assert(sink); 47 | pa_assert(ss); 48 | pa_assert(chunk); 49 | 50 | pa_silence_memchunk_get(&sink->core->silence_cache, sink->core->mempool, &silence, ss, 0); 51 | q = pa_memblockq_new("pa_play_memchunk() q", 0, chunk->length, 0, ss, 1, 1, 0, &silence); 52 | pa_memblock_unref(silence.memblock); 53 | 54 | pa_assert_se(pa_memblockq_push(q, chunk) >= 0); 55 | 56 | if ((r = pa_play_memblockq(sink, ss, map, q, volume, p, flags, sink_input_index)) < 0) { 57 | pa_memblockq_free(q); 58 | return r; 59 | } 60 | 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /src/pulsecore/play-memchunk.h: -------------------------------------------------------------------------------- 1 | #ifndef fooplaychunkhfoo 2 | #define fooplaychunkhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | 26 | int pa_play_memchunk( 27 | pa_sink *sink, 28 | const pa_sample_spec *ss, 29 | const pa_channel_map *map, 30 | const pa_memchunk *chunk, 31 | pa_cvolume *cvolume, 32 | pa_proplist *p, 33 | pa_sink_input_flags_t flags, 34 | uint32_t *sink_input_index); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/pulsecore/proplist-util.h: -------------------------------------------------------------------------------- 1 | #ifndef fooproplistutilutilhfoo 2 | #define fooproplistutilutilhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2008 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | 25 | void pa_init_proplist(pa_proplist *p); 26 | char *pa_proplist_get_stream_group(pa_proplist *pl, const char *prefix, const char *cache); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/pulsecore/protocol-cli.h: -------------------------------------------------------------------------------- 1 | #ifndef fooprotocolclihfoo 2 | #define fooprotocolclihfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | typedef struct pa_cli_protocol pa_cli_protocol; 29 | 30 | pa_cli_protocol* pa_cli_protocol_get(pa_core *core); 31 | pa_cli_protocol* pa_cli_protocol_ref(pa_cli_protocol *p); 32 | void pa_cli_protocol_unref(pa_cli_protocol *p); 33 | void pa_cli_protocol_connect(pa_cli_protocol *p, pa_iochannel *io, pa_module *m); 34 | void pa_cli_protocol_disconnect(pa_cli_protocol *o, pa_module *m); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/pulsecore/protocol-esound.h: -------------------------------------------------------------------------------- 1 | #ifndef fooprotocolesoundhfoo 2 | #define fooprotocolesoundhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | Copyright 2006 Pierre Ossman for Cendio AB 9 | 10 | PulseAudio is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU Lesser General Public License as published 12 | by the Free Software Foundation; either version 2.1 of the License, 13 | or (at your option) any later version. 14 | 15 | PulseAudio is distributed in the hope that it will be useful, but 16 | WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License 21 | along with PulseAudio; if not, see . 22 | ***/ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | typedef struct pa_esound_protocol pa_esound_protocol; 32 | 33 | typedef struct pa_esound_options { 34 | PA_REFCNT_DECLARE; 35 | 36 | pa_module *module; 37 | 38 | bool auth_anonymous; 39 | pa_ip_acl *auth_ip_acl; 40 | pa_auth_cookie *auth_cookie; 41 | 42 | char *default_sink, *default_source; 43 | } pa_esound_options; 44 | 45 | pa_esound_protocol* pa_esound_protocol_get(pa_core*core); 46 | pa_esound_protocol* pa_esound_protocol_ref(pa_esound_protocol *p); 47 | void pa_esound_protocol_unref(pa_esound_protocol *p); 48 | void pa_esound_protocol_connect(pa_esound_protocol *p, pa_iochannel *io, pa_esound_options *o); 49 | void pa_esound_protocol_disconnect(pa_esound_protocol *p, pa_module *m); 50 | 51 | pa_esound_options* pa_esound_options_new(void); 52 | pa_esound_options* pa_esound_options_ref(pa_esound_options *o); 53 | void pa_esound_options_unref(pa_esound_options *o); 54 | int pa_esound_options_parse(pa_esound_options *o, pa_core *c, pa_modargs *ma); 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /src/pulsecore/protocol-http.h: -------------------------------------------------------------------------------- 1 | #ifndef fooprotocolhttphfoo 2 | #define fooprotocolhttphfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2005-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | typedef struct pa_http_protocol pa_http_protocol; 30 | 31 | pa_http_protocol* pa_http_protocol_get(pa_core *core); 32 | pa_http_protocol* pa_http_protocol_ref(pa_http_protocol *p); 33 | void pa_http_protocol_unref(pa_http_protocol *p); 34 | void pa_http_protocol_connect(pa_http_protocol *p, pa_iochannel *io, pa_module *m); 35 | void pa_http_protocol_disconnect(pa_http_protocol *p, pa_module *m); 36 | 37 | void pa_http_protocol_add_server_string(pa_http_protocol *p, const char *name); 38 | void pa_http_protocol_remove_server_string(pa_http_protocol *p, const char *name); 39 | pa_strlist *pa_http_protocol_servers(pa_http_protocol *p); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/pulsecore/protocol-simple.h: -------------------------------------------------------------------------------- 1 | #ifndef fooprotocolsimplehfoo 2 | #define fooprotocolsimplehfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | typedef struct pa_simple_protocol pa_simple_protocol; 29 | 30 | typedef struct pa_simple_options { 31 | PA_REFCNT_DECLARE; 32 | 33 | pa_module *module; 34 | 35 | char *default_sink, *default_source; 36 | 37 | pa_sample_spec sample_spec; 38 | pa_channel_map channel_map; 39 | 40 | bool record:1; 41 | bool playback:1; 42 | } pa_simple_options; 43 | 44 | pa_simple_protocol* pa_simple_protocol_get(pa_core*core); 45 | pa_simple_protocol* pa_simple_protocol_ref(pa_simple_protocol *p); 46 | void pa_simple_protocol_unref(pa_simple_protocol *p); 47 | void pa_simple_protocol_connect(pa_simple_protocol *p, pa_iochannel *io, pa_simple_options *o); 48 | void pa_simple_protocol_disconnect(pa_simple_protocol *p, pa_module *m); 49 | 50 | pa_simple_options* pa_simple_options_new(void); 51 | pa_simple_options* pa_simple_options_ref(pa_simple_options *o); 52 | void pa_simple_options_unref(pa_simple_options *o); 53 | int pa_simple_options_parse(pa_simple_options *o, pa_core *c, pa_modargs *ma); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/pulsecore/pstream-util.h: -------------------------------------------------------------------------------- 1 | #ifndef foopstreamutilhfoo 2 | #define foopstreamutilhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | /* The tagstruct is freed!*/ 29 | void pa_pstream_send_tagstruct_with_creds(pa_pstream *p, pa_tagstruct *t, const pa_creds *creds); 30 | void pa_pstream_send_tagstruct_with_fds(pa_pstream *p, pa_tagstruct *t, int nfd, const int *fds, bool close_fds); 31 | 32 | #define pa_pstream_send_tagstruct(p, t) pa_pstream_send_tagstruct_with_creds((p), (t), NULL) 33 | 34 | void pa_pstream_send_error(pa_pstream *p, uint32_t tag, uint32_t error); 35 | void pa_pstream_send_simple_ack(pa_pstream *p, uint32_t tag); 36 | 37 | int pa_pstream_register_memfd_mempool(pa_pstream *p, pa_mempool *pool, const char **fail_reason); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/pulsecore/queue.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsecorequeuehfoo 2 | #define foopulsecorequeuehfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2008 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | 25 | typedef struct pa_queue pa_queue; 26 | 27 | /* A simple implementation of the abstract data type queue. Stores 28 | * pointers as members. The memory has to be managed by the caller. */ 29 | 30 | pa_queue* pa_queue_new(void); 31 | 32 | /* Free the queue and run the specified callback function for every 33 | * remaining entry. The callback function may be NULL. */ 34 | void pa_queue_free(pa_queue *q, pa_free_cb_t free_func); 35 | 36 | void pa_queue_push(pa_queue *q, void *p); 37 | void* pa_queue_pop(pa_queue *q); 38 | 39 | int pa_queue_isempty(pa_queue *q); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/pulsecore/random.h: -------------------------------------------------------------------------------- 1 | #ifndef foorandomhfoo 2 | #define foorandomhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | Copyright 2006 Pierre Ossman for Cendio AB 9 | 10 | PulseAudio is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU Lesser General Public License as 12 | published by the Free Software Foundation; either version 2.1 of the 13 | License, or (at your option) any later version. 14 | 15 | PulseAudio is distributed in the hope that it will be useful, but 16 | WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with PulseAudio; if not, see . 22 | ***/ 23 | 24 | #include 25 | 26 | void pa_random_seed(void); 27 | void pa_random(void *ret_data, size_t length); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/pulsecore/ratelimit.c: -------------------------------------------------------------------------------- 1 | /*** 2 | This file is part of PulseAudio. 3 | 4 | Copyright 2009 Lennart Poettering 5 | 6 | PulseAudio is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as 8 | published by the Free Software Foundation; either version 2.1 of the 9 | License, or (at your option) any later version. 10 | 11 | PulseAudio is distributed in the hope that it will be useful, but 12 | WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with PulseAudio; if not, see . 18 | ***/ 19 | 20 | #ifdef HAVE_CONFIG_H 21 | #include 22 | #endif 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | #include "ratelimit.h" 30 | 31 | static pa_static_mutex mutex = PA_STATIC_MUTEX_INIT; 32 | 33 | /* Modelled after Linux' lib/ratelimit.c by Dave Young 34 | * , which is licensed GPLv2. */ 35 | 36 | bool pa_ratelimit_test(pa_ratelimit *r, pa_log_level_t t) { 37 | pa_usec_t now; 38 | pa_mutex *m; 39 | 40 | now = pa_rtclock_now(); 41 | 42 | m = pa_static_mutex_get(&mutex, false, false); 43 | pa_mutex_lock(m); 44 | 45 | pa_assert(r); 46 | pa_assert(r->interval > 0); 47 | pa_assert(r->burst > 0); 48 | 49 | if (r->begin <= 0 || 50 | r->begin + r->interval < now) { 51 | 52 | if (r->n_missed > 0) 53 | pa_logl(t, "%u events suppressed", r->n_missed); 54 | 55 | r->begin = now; 56 | 57 | /* Reset counters */ 58 | r->n_printed = 0; 59 | r->n_missed = 0; 60 | goto good; 61 | } 62 | 63 | if (r->n_printed <= r->burst) 64 | goto good; 65 | 66 | r->n_missed++; 67 | pa_mutex_unlock(m); 68 | return false; 69 | 70 | good: 71 | r->n_printed++; 72 | pa_mutex_unlock(m); 73 | return true; 74 | } 75 | -------------------------------------------------------------------------------- /src/pulsecore/ratelimit.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsecoreratelimithfoo 2 | #define foopulsecoreratelimithfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2009 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | typedef struct pa_ratelimit { 28 | pa_usec_t interval; 29 | unsigned burst; 30 | unsigned n_printed, n_missed; 31 | pa_usec_t begin; 32 | } pa_ratelimit; 33 | 34 | #define PA_DEFINE_RATELIMIT(_name, _interval, _burst) \ 35 | pa_ratelimit _name = { \ 36 | .interval = (_interval), \ 37 | .burst = (_burst), \ 38 | .n_printed = 0, \ 39 | .n_missed = 0, \ 40 | .begin = 0 \ 41 | } 42 | 43 | #define PA_INIT_RATELIMIT(v, _interval, _burst) \ 44 | do { \ 45 | pa_ratelimit *r = &(v); \ 46 | r->interval = (_interval); \ 47 | r->burst = (_burst); \ 48 | r->n_printed = 0; \ 49 | r->n_missed = 0; \ 50 | r->begin = 0; \ 51 | } while (false); 52 | 53 | bool pa_ratelimit_test(pa_ratelimit *r, pa_log_level_t t); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/pulsecore/refcnt.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulserefcnthfoo 2 | #define foopulserefcnthfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | /* #define DEBUG_REF */ 28 | 29 | #define PA_REFCNT_DECLARE \ 30 | pa_atomic_t _ref 31 | 32 | #define PA_REFCNT_VALUE(p) \ 33 | pa_atomic_load(&(p)->_ref) 34 | 35 | #define PA_REFCNT_INIT_ZERO(p) \ 36 | pa_atomic_store(&(p)->_ref, 0) 37 | 38 | #ifndef DEBUG_REF 39 | 40 | #define PA_REFCNT_INIT(p) \ 41 | pa_atomic_store(&(p)->_ref, 1) 42 | 43 | #define PA_REFCNT_INC(p) \ 44 | pa_atomic_inc(&(p)->_ref) 45 | 46 | #define PA_REFCNT_DEC(p) \ 47 | (pa_atomic_dec(&(p)->_ref)-1) 48 | 49 | #else 50 | 51 | /* If you need to debug ref counting problems define DEBUG_REF and 52 | * set $PULSE_LOG_BACKTRACE=5 or suchlike in the shell when running 53 | * PA */ 54 | 55 | #define PA_REFCNT_INIT(p) \ 56 | do { \ 57 | pa_atomic_store(&(p)->_ref, 1); \ 58 | pa_log("REF: Init %p", p); \ 59 | } while (false) 60 | 61 | #define PA_REFCNT_INC(p) \ 62 | do { \ 63 | pa_atomic_inc(&(p)->_ref); \ 64 | pa_log("REF: Inc %p", p); \ 65 | } while (false) \ 66 | 67 | #define PA_REFCNT_DEC(p) \ 68 | ({ \ 69 | int _j = (pa_atomic_dec(&(p)->_ref)-1); \ 70 | if (_j <= 0) \ 71 | pa_log("REF: Done %p", p); \ 72 | else \ 73 | pa_log("REF: Dec %p", p); \ 74 | _j; \ 75 | }) 76 | 77 | #endif 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /src/pulsecore/remap.h: -------------------------------------------------------------------------------- 1 | #ifndef fooremapfoo 2 | #define fooremapfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | Copyright 2009 Wim Taymans 9 | 10 | PulseAudio is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU Lesser General Public License as published 12 | by the Free Software Foundation; either version 2.1 of the License, 13 | or (at your option) any later version. 14 | 15 | PulseAudio is distributed in the hope that it will be useful, but 16 | WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License 21 | along with PulseAudio; if not, see . 22 | ***/ 23 | 24 | #include 25 | 26 | typedef struct pa_remap pa_remap_t; 27 | 28 | typedef void (*pa_do_remap_func_t) (pa_remap_t *m, void *d, const void *s, unsigned n); 29 | 30 | struct pa_remap { 31 | pa_sample_format_t format; 32 | pa_sample_spec i_ss, o_ss; 33 | float map_table_f[PA_CHANNELS_MAX][PA_CHANNELS_MAX]; 34 | int32_t map_table_i[PA_CHANNELS_MAX][PA_CHANNELS_MAX]; 35 | pa_do_remap_func_t do_remap; 36 | void *state; /* optional state information for the remap function */ 37 | }; 38 | 39 | void pa_init_remap_func(pa_remap_t *m); 40 | 41 | /* custom installation of init functions */ 42 | typedef void (*pa_init_remap_func_t) (pa_remap_t *m); 43 | 44 | pa_init_remap_func_t pa_get_init_remap_func(void); 45 | void pa_set_init_remap_func(pa_init_remap_func_t func); 46 | 47 | /* Check if remapping can be performed by just copying some or all input 48 | * channels' data to output channels. Returns true and a table of input 49 | * channel indices, or false otherwise. 50 | * 51 | * The table contains an entry for each output channels. Each table entry given 52 | * either the input channel index to be copied, or -1 indicating that the 53 | * output channel is not used and hence zero. 54 | */ 55 | bool pa_setup_remap_arrange(const pa_remap_t *m, int8_t arrange[PA_CHANNELS_MAX]); 56 | 57 | void pa_set_remap_func(pa_remap_t *m, pa_do_remap_func_t func_s16, 58 | pa_do_remap_func_t func_s32, pa_do_remap_func_t func_float); 59 | 60 | #endif /* fooremapfoo */ 61 | -------------------------------------------------------------------------------- /src/pulsecore/sconv.h: -------------------------------------------------------------------------------- 1 | #ifndef foosconvhfoo 2 | #define foosconvhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | Copyright 2006 Pierre Ossman for Cendio AB 9 | 10 | PulseAudio is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU Lesser General Public License as published 12 | by the Free Software Foundation; either version 2.1 of the License, 13 | or (at your option) any later version. 14 | 15 | PulseAudio is distributed in the hope that it will be useful, but 16 | WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License 21 | along with PulseAudio; if not, see . 22 | ***/ 23 | 24 | #include 25 | #include 26 | 27 | typedef void (*pa_convert_func_t)(unsigned n, const void *a, void *b); 28 | 29 | pa_convert_func_t pa_get_convert_to_float32ne_function(pa_sample_format_t f) PA_GCC_PURE; 30 | pa_convert_func_t pa_get_convert_from_float32ne_function(pa_sample_format_t f) PA_GCC_PURE; 31 | 32 | pa_convert_func_t pa_get_convert_to_s16ne_function(pa_sample_format_t f) PA_GCC_PURE; 33 | pa_convert_func_t pa_get_convert_from_s16ne_function(pa_sample_format_t f) PA_GCC_PURE; 34 | 35 | void pa_set_convert_to_float32ne_function(pa_sample_format_t f, pa_convert_func_t func); 36 | void pa_set_convert_from_float32ne_function(pa_sample_format_t f, pa_convert_func_t func); 37 | 38 | void pa_set_convert_to_s16ne_function(pa_sample_format_t f, pa_convert_func_t func); 39 | void pa_set_convert_from_s16ne_function(pa_sample_format_t f, pa_convert_func_t func); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/pulsecore/semaphore-posix.c: -------------------------------------------------------------------------------- 1 | /*** 2 | This file is part of PulseAudio. 3 | 4 | Copyright 2006 Lennart Poettering 5 | 6 | PulseAudio is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published 8 | by the Free Software Foundation; either version 2.1 of the License, 9 | or (at your option) any later version. 10 | 11 | PulseAudio is distributed in the hope that it will be useful, but 12 | WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with PulseAudio; if not, see . 18 | ***/ 19 | 20 | #ifdef HAVE_CONFIG_H 21 | #include 22 | #endif 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | #include "semaphore.h" 32 | 33 | struct pa_semaphore { 34 | sem_t sem; 35 | }; 36 | 37 | pa_semaphore* pa_semaphore_new(unsigned value) { 38 | pa_semaphore *s; 39 | 40 | s = pa_xnew(pa_semaphore, 1); 41 | pa_assert_se(sem_init(&s->sem, 0, value) == 0); 42 | return s; 43 | } 44 | 45 | void pa_semaphore_free(pa_semaphore *s) { 46 | pa_assert(s); 47 | pa_assert_se(sem_destroy(&s->sem) == 0); 48 | pa_xfree(s); 49 | } 50 | 51 | void pa_semaphore_post(pa_semaphore *s) { 52 | pa_assert(s); 53 | pa_assert_se(sem_post(&s->sem) == 0); 54 | } 55 | 56 | void pa_semaphore_wait(pa_semaphore *s) { 57 | int ret; 58 | pa_assert(s); 59 | 60 | do { 61 | ret = sem_wait(&s->sem); 62 | } while (ret < 0 && errno == EINTR); 63 | 64 | pa_assert(ret == 0); 65 | } 66 | 67 | pa_semaphore* pa_static_semaphore_get(pa_static_semaphore *s, unsigned value) { 68 | pa_semaphore *m; 69 | 70 | pa_assert(s); 71 | 72 | /* First, check if already initialized and short cut */ 73 | if ((m = pa_atomic_ptr_load(&s->ptr))) 74 | return m; 75 | 76 | /* OK, not initialized, so let's allocate, and fill in */ 77 | m = pa_semaphore_new(value); 78 | if ((pa_atomic_ptr_cmpxchg(&s->ptr, NULL, m))) 79 | return m; 80 | 81 | pa_semaphore_free(m); 82 | 83 | /* Him, filling in failed, so someone else must have filled in 84 | * already */ 85 | pa_assert_se(m = pa_atomic_ptr_load(&s->ptr)); 86 | return m; 87 | } 88 | -------------------------------------------------------------------------------- /src/pulsecore/semaphore-win32.c: -------------------------------------------------------------------------------- 1 | /*** 2 | This file is part of PulseAudio. 3 | 4 | Copyright 2006 Pierre Ossman for Cendio AB 5 | 6 | PulseAudio is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published 8 | by the Free Software Foundation; either version 2.1 of the License, 9 | or (at your option) any later version. 10 | 11 | PulseAudio is distributed in the hope that it will be useful, but 12 | WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with PulseAudio; if not, see . 18 | ***/ 19 | 20 | #ifdef HAVE_CONFIG_H 21 | #include 22 | #endif 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | #include "semaphore.h" 30 | 31 | struct pa_semaphore { 32 | HANDLE sema; 33 | }; 34 | 35 | pa_semaphore* pa_semaphore_new(unsigned value) { 36 | pa_semaphore *s; 37 | 38 | s = pa_xnew(pa_semaphore, 1); 39 | 40 | s->sema = CreateSemaphore(NULL, value, 32767, NULL); 41 | pa_assert(s->sema != NULL); 42 | 43 | return s; 44 | } 45 | 46 | void pa_semaphore_free(pa_semaphore *s) { 47 | pa_assert(s); 48 | CloseHandle(s->sema); 49 | pa_xfree(s); 50 | } 51 | 52 | void pa_semaphore_post(pa_semaphore *s) { 53 | pa_assert(s); 54 | ReleaseSemaphore(s->sema, 1, NULL); 55 | } 56 | 57 | void pa_semaphore_wait(pa_semaphore *s) { 58 | pa_assert(s); 59 | WaitForSingleObject(s->sema, INFINITE); 60 | } 61 | -------------------------------------------------------------------------------- /src/pulsecore/semaphore.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsesemaphorehfoo 2 | #define foopulsesemaphorehfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | 26 | typedef struct pa_semaphore pa_semaphore; 27 | 28 | pa_semaphore* pa_semaphore_new(unsigned value); 29 | void pa_semaphore_free(pa_semaphore *m); 30 | 31 | void pa_semaphore_post(pa_semaphore *m); 32 | void pa_semaphore_wait(pa_semaphore *m); 33 | 34 | /* Static semaphores are basically just atomically updated pointers to 35 | * pa_semaphore objects */ 36 | 37 | typedef struct pa_static_semaphore { 38 | pa_atomic_ptr_t ptr; 39 | } pa_static_semaphore; 40 | 41 | #define PA_STATIC_SEMAPHORE_INIT { PA_ATOMIC_PTR_INIT(NULL) } 42 | 43 | /* When you call this make sure to pass always the same value parameter! */ 44 | pa_semaphore* pa_static_semaphore_get(pa_static_semaphore *m, unsigned value); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/pulsecore/shared.h: -------------------------------------------------------------------------------- 1 | #ifndef foosharedshfoo 2 | #define foosharedshfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | 26 | /* The shared property subsystem is to be used to share data between 27 | * modules. Consider them to be kind of "global" variables for a 28 | * core. Why not use the hashmap functions directly? The hashmap 29 | * functions copy neither the key nor value, while this property 30 | * system copies the key. Users of this system have to think about 31 | * reference counting themselves. */ 32 | 33 | /* Note: please don't confuse this with the proplist framework in 34 | * pulse/proplist.[ch]! */ 35 | 36 | /* Return a pointer to the value of the specified shared property. */ 37 | void* pa_shared_get(pa_core *c, const char *name); 38 | 39 | /* Set the shared property 'name' to 'data'. This function fails in 40 | * case a property by this name already exists. The property data is 41 | * not copied or reference counted. This is the caller's job. */ 42 | int pa_shared_set(pa_core *c, const char *name, void *data); 43 | 44 | /* Remove the specified shared property. Return non-zero on failure */ 45 | int pa_shared_remove(pa_core *c, const char *name); 46 | 47 | /* A combination of pa_shared_remove() and pa_shared_set(); this function 48 | * first tries to remove the property by this name and then sets the 49 | * property. Return non-zero on failure. */ 50 | int pa_shared_replace(pa_core *c, const char *name, void *data); 51 | 52 | /* Dump the current set of shared properties */ 53 | void pa_shared_dump(pa_core *c, pa_strbuf *s); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/pulsecore/shm.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulseshmhfoo 2 | #define foopulseshmhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | typedef struct pa_shm { 29 | pa_mem_type_t type; 30 | unsigned id; 31 | void *ptr; 32 | size_t size; 33 | 34 | /* Only for type = PA_MEM_TYPE_SHARED_POSIX */ 35 | bool do_unlink:1; 36 | 37 | /* Only for type = PA_MEM_TYPE_SHARED_MEMFD 38 | * 39 | * To avoid fd leaks, we keep this fd open only until we pass it 40 | * to the other PA endpoint over unix domain socket. 41 | * 42 | * When we don't have ownership for the memfd fd in question (e.g. 43 | * pa_shm_attach()), or the file descriptor has now been closed, 44 | * this is set to -1. 45 | * 46 | * For the special case of a global mempool, we keep this fd 47 | * always open. Check comments on top of pa_mempool_new() for 48 | * rationale. */ 49 | int fd; 50 | } pa_shm; 51 | 52 | int pa_shm_create_rw(pa_shm *m, pa_mem_type_t type, size_t size, mode_t mode); 53 | int pa_shm_attach(pa_shm *m, pa_mem_type_t type, unsigned id, int memfd_fd, bool writable); 54 | 55 | void pa_shm_punch(pa_shm *m, size_t offset, size_t size); 56 | 57 | void pa_shm_free(pa_shm *m); 58 | 59 | int pa_shm_cleanup(void); 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/pulsecore/shmasyncq.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulseshmasyncqhfoo 2 | #define foopulseshmasyncqhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | 25 | #include 26 | 27 | /* Similar to pa_asyncq, but stores data in a shared memory segment */ 28 | 29 | struct pa_shmasyncq_data { 30 | unsigned n_elements; 31 | size_t element_size; 32 | unsigned read_idx; 33 | unsigned write_idx; 34 | pa_fdsem_data read_fdsem_data, write_fdsem_data; 35 | }; 36 | 37 | #define PA_SHMASYNCQ_DEFAULT_N_ELEMENTS 128 38 | #define PA_SHMASYNCQ_SIZE(n_elements, element_size) (PA_ALIGN(sizeof(pa_shmasyncq_data)) + (((n_elements) * (PA_ALIGN(sizeof(pa_atomic_t)) + PA_ALIGN(element_size))))) 39 | #define PA_SHMASYNCQ_DEFAULT_SIZE(element_size) PA_SHMASYNCQ_SIZE(PA_SHMASYNCQ_DEFAULT_N_ELEMENTS, element_size) 40 | 41 | typedef struct pa_shmasyncq pa_shmasyncq; 42 | 43 | pa_shmasyncq *pa_shmasyncq_new(unsigned n_elements, size_t element_size, void *data, int fd[2]); 44 | void pa_shmasyncq_free(pa_shmasyncq* q, pa_free_cb_t free_cb); 45 | 46 | void* pa_shmasyncq_pop_begin(pa_shmasyncq *q, bool wait); 47 | void pa_shmasyncq_pop_commit(pa_shmasyncq *q); 48 | 49 | int* pa_shmasyncq_push_begin(pa_shmasyncq *q, bool wait); 50 | void pa_shmasyncq_push_commit(pa_shmasyncq *q); 51 | 52 | int pa_shmasyncq_get_fd(pa_shmasyncq *q); 53 | int pa_shmasyncq_before_poll(pa_shmasyncq *a); 54 | void pa_shmasyncq_after_poll(pa_shmasyncq *a); 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /src/pulsecore/sioman.c: -------------------------------------------------------------------------------- 1 | /*** 2 | This file is part of PulseAudio. 3 | 4 | Copyright 2004-2006 Lennart Poettering 5 | 6 | PulseAudio is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published 8 | by the Free Software Foundation; either version 2.1 of the License, 9 | or (at your option) any later version. 10 | 11 | PulseAudio is distributed in the hope that it will be useful, but 12 | WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with PulseAudio; if not, see . 18 | ***/ 19 | 20 | #ifdef HAVE_CONFIG_H 21 | #include 22 | #endif 23 | 24 | #include 25 | #include 26 | 27 | #include "sioman.h" 28 | 29 | static pa_atomic_t stdio_inuse = PA_ATOMIC_INIT(0); 30 | 31 | int pa_stdio_acquire(void) { 32 | return pa_atomic_cmpxchg(&stdio_inuse, 0, 1) ? 0 : -1; 33 | } 34 | 35 | void pa_stdio_release(void) { 36 | pa_assert_se(pa_atomic_cmpxchg(&stdio_inuse, 1, 0)); 37 | } 38 | -------------------------------------------------------------------------------- /src/pulsecore/sioman.h: -------------------------------------------------------------------------------- 1 | #ifndef foosiomanhfoo 2 | #define foosiomanhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | int pa_stdio_acquire(void); 24 | void pa_stdio_release(void); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/pulsecore/sndfile-util.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsecoresndfileutilhfoo 2 | #define foopulsecoresndfileutilhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2009 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | int pa_sndfile_read_sample_spec(SNDFILE *sf, pa_sample_spec *ss); 30 | int pa_sndfile_read_channel_map(SNDFILE *sf, pa_channel_map *cm); 31 | 32 | int pa_sndfile_write_sample_spec(SF_INFO *sfi, pa_sample_spec *ss); 33 | int pa_sndfile_write_channel_map(SNDFILE *sf, pa_channel_map *cm); 34 | 35 | void pa_sndfile_init_proplist(SNDFILE *sf, pa_proplist *p); 36 | 37 | typedef sf_count_t (*pa_sndfile_readf_t)(SNDFILE *sndfile, void *ptr, sf_count_t frames); 38 | typedef sf_count_t (*pa_sndfile_writef_t)(SNDFILE *sndfile, const void *ptr, sf_count_t frames); 39 | 40 | /* Returns NULL if sf_read_raw() shall be used */ 41 | pa_sndfile_readf_t pa_sndfile_readf_function(const pa_sample_spec *ss); 42 | 43 | /* Returns NULL if sf_write_raw() shall be used */ 44 | pa_sndfile_writef_t pa_sndfile_writef_function(const pa_sample_spec *ss); 45 | 46 | int pa_sndfile_format_from_string(const char *extension); 47 | 48 | void pa_sndfile_dump_formats(void); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/pulsecore/socket-client.h: -------------------------------------------------------------------------------- 1 | #ifndef foosocketclienthfoo 2 | #define foosocketclienthfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | Copyright 2006 Pierre Ossman for Cendio AB 9 | 10 | PulseAudio is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU Lesser General Public License as 12 | published by the Free Software Foundation; either version 2.1 of the 13 | License, or (at your option) any later version. 14 | 15 | PulseAudio is distributed in the hope that it will be useful, but 16 | WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with PulseAudio; if not, see . 22 | ***/ 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | struct sockaddr; 30 | 31 | typedef struct pa_socket_client pa_socket_client; 32 | 33 | typedef void (*pa_socket_client_cb_t)(pa_socket_client *c, pa_iochannel*io, void *userdata); 34 | 35 | pa_socket_client* pa_socket_client_new_ipv4(pa_mainloop_api *m, uint32_t address, uint16_t port); 36 | pa_socket_client* pa_socket_client_new_ipv6(pa_mainloop_api *m, uint8_t address[16], uint16_t port); 37 | pa_socket_client* pa_socket_client_new_unix(pa_mainloop_api *m, const char *filename); 38 | pa_socket_client* pa_socket_client_new_sockaddr(pa_mainloop_api *m, const struct sockaddr *sa, size_t salen); 39 | pa_socket_client* pa_socket_client_new_string(pa_mainloop_api *m, bool use_rtclock, const char *a, uint16_t default_port); 40 | 41 | pa_socket_client* pa_socket_client_ref(pa_socket_client *c); 42 | void pa_socket_client_unref(pa_socket_client *c); 43 | 44 | void pa_socket_client_set_callback(pa_socket_client *c, pa_socket_client_cb_t on_connection, void *userdata); 45 | 46 | bool pa_socket_client_is_local(pa_socket_client *c); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/pulsecore/socket-util.h: -------------------------------------------------------------------------------- 1 | #ifndef foosocketutilhfoo 2 | #define foosocketutilhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | Copyright 2006 Pierre Ossman for Cendio AB 9 | 10 | PulseAudio is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU Lesser General Public License as published 12 | by the Free Software Foundation; either version 2.1 of the License, 13 | or (at your option) any later version. 14 | 15 | PulseAudio is distributed in the hope that it will be useful, but 16 | WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License 21 | along with PulseAudio; if not, see . 22 | ***/ 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | void pa_socket_peer_to_string(int fd, char *c, size_t l); 30 | 31 | void pa_make_socket_low_delay(int fd); 32 | void pa_make_tcp_socket_low_delay(int fd); 33 | void pa_make_udp_socket_low_delay(int fd); 34 | 35 | int pa_socket_set_sndbuf(int fd, size_t l); 36 | int pa_socket_set_rcvbuf(int fd, size_t l); 37 | 38 | bool pa_socket_address_is_local(const struct sockaddr *sa); 39 | bool pa_socket_is_local(int fd); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/pulsecore/socket.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsecoresockethfoo 2 | #define foopulsecoresockethfoo 3 | 4 | #ifdef HAVE_SYS_SOCKET_H 5 | #include 6 | #endif 7 | 8 | #ifdef HAVE_WINSOCK2_H 9 | #include 10 | #include "winerrno.h" 11 | 12 | typedef long suseconds_t; 13 | 14 | /** Windows 10 supports AF_UNIX as of build 17603, with 15 | support provided in the header file . However, 16 | only the latest Windows SDK provides this file; older SDKs and 17 | MinGW do not. 18 | 19 | Hence we define SOCKADDR_UN here. We do not expect this definition to change 20 | as Windows has some pretty good binary backwards-compatibility guarantees. 21 | 22 | This shouldn't pose a problem for older versions of Windows; we expect them to 23 | fail with an error whenever we try to make a socket of type AF_UNIX. */ 24 | #define UNIX_PATH_MAX 108 25 | 26 | typedef struct sockaddr_un 27 | { 28 | ADDRESS_FAMILY sun_family; /* AF_UNIX */ 29 | char sun_path[UNIX_PATH_MAX]; /* pathname */ 30 | } SOCKADDR_UN, *PSOCKADDR_UN; 31 | 32 | #ifndef SUN_LEN 33 | #define SUN_LEN(ptr) \ 34 | ((size_t)(((struct sockaddr_un *) 0)->sun_path) + strlen((ptr)->sun_path)) 35 | #endif 36 | 37 | #define HAVE_SYS_UN_H 38 | 39 | #endif 40 | 41 | #ifdef HAVE_WS2TCPIP_H 42 | #include 43 | #endif 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/pulsecore/sound-file-stream.h: -------------------------------------------------------------------------------- 1 | #ifndef foosoundfilestreamhfoo 2 | #define foosoundfilestreamhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | 25 | int pa_play_file(pa_sink *sink, const char *fname, const pa_cvolume *volume); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/pulsecore/sound-file.h: -------------------------------------------------------------------------------- 1 | #ifndef soundfilehfoo 2 | #define soundfilehfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | 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); 28 | 29 | int pa_sound_file_too_big_to_cache(const char *fname); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/pulsecore/srbchannel.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsesrbchannelhfoo 2 | #define foopulsesrbchannelhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2014 David Henningsson, Canonical Ltd. 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | /* An shm ringbuffer that is used for low overhead server-client communication. 28 | * Signaling is done through eventfd semaphores (pa_fdsem). */ 29 | 30 | typedef struct pa_srbchannel pa_srbchannel; 31 | 32 | typedef struct pa_srbchannel_template { 33 | int readfd, writefd; 34 | pa_memblock *memblock; 35 | } pa_srbchannel_template; 36 | 37 | pa_srbchannel* pa_srbchannel_new(pa_mainloop_api *m, pa_mempool *p); 38 | /* Note: this creates a srbchannel with swapped read and write. */ 39 | pa_srbchannel* pa_srbchannel_new_from_template(pa_mainloop_api *m, pa_srbchannel_template *t); 40 | 41 | void pa_srbchannel_free(pa_srbchannel *sr); 42 | 43 | void pa_srbchannel_export(pa_srbchannel *sr, pa_srbchannel_template *t); 44 | 45 | size_t pa_srbchannel_write(pa_srbchannel *sr, const void *data, size_t l); 46 | size_t pa_srbchannel_read(pa_srbchannel *sr, void *data, size_t l); 47 | 48 | /* Set the callback function that is called whenever data becomes available for reading. 49 | * It can also be called if the output buffer was full and can now be written to. 50 | * 51 | * Return false to abort all processing (e g if the srbchannel has been freed during the callback). 52 | * Otherwise return true. 53 | */ 54 | typedef bool (*pa_srbchannel_cb_t)(pa_srbchannel *sr, void *userdata); 55 | void pa_srbchannel_set_callback(pa_srbchannel *sr, pa_srbchannel_cb_t callback, void *userdata); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/pulsecore/start-child.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsestartchildhfoo 2 | #define foopulsestartchildhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2007 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | 26 | int pa_start_child_for_read(const char *name, const char *argv1, pid_t *pid); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/pulsecore/strbuf.h: -------------------------------------------------------------------------------- 1 | #ifndef foostrbufhfoo 2 | #define foostrbufhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | 26 | typedef struct pa_strbuf pa_strbuf; 27 | 28 | pa_strbuf *pa_strbuf_new(void); 29 | void pa_strbuf_free(pa_strbuf *sb); 30 | char *pa_strbuf_to_string(pa_strbuf *sb); 31 | char *pa_strbuf_to_string_free(pa_strbuf *sb); 32 | 33 | size_t pa_strbuf_printf(pa_strbuf *sb, const char *format, ...) PA_GCC_PRINTF_ATTR(2,3); 34 | void pa_strbuf_puts(pa_strbuf *sb, const char *t); 35 | void pa_strbuf_putsn(pa_strbuf *sb, const char *t, size_t m); 36 | void pa_strbuf_putc(pa_strbuf *sb, char c); 37 | 38 | bool pa_strbuf_isempty(pa_strbuf *sb); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/pulsecore/stream-util.h: -------------------------------------------------------------------------------- 1 | #ifndef foostreamutilhfoo 2 | #define foostreamutilhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2013 Intel Corporation 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | 26 | /* This is a helper function that is called from pa_sink_input_new() and 27 | * pa_source_output_new(). The job of this function is to figure out what 28 | * channel map should be used for interpreting the volume that was set for the 29 | * stream. The channel map that the client intended for the volume may be 30 | * different than the final stream channel map, because the client may want the 31 | * server to decide the stream channel map. 32 | * 33 | * volume is the volume for which the channel map should be figured out. 34 | * 35 | * original_map is the channel map that is set in the new data struct's 36 | * channel_map field. If the channel map hasn't been set in the new data, then 37 | * original_map should be NULL. 38 | * 39 | * format is the negotiated format for the stream. It's used as a fallback if 40 | * original_map is not available. 41 | * 42 | * On success, the result is saved in volume_map. It's possible that this 43 | * function fails to figure out the right channel map for the volume, in which 44 | * case a negative error code is returned. */ 45 | int pa_stream_get_volume_channel_map(const pa_cvolume *volume, const pa_channel_map *original_map, const pa_format_info *format, 46 | pa_channel_map *volume_map); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/pulsecore/strlist.h: -------------------------------------------------------------------------------- 1 | #ifndef foostrlisthfoo 2 | #define foostrlisthfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | typedef struct pa_strlist pa_strlist; 24 | 25 | /* Add the specified server string to the list, return the new linked list head */ 26 | pa_strlist* pa_strlist_prepend(pa_strlist *l, const char *s); 27 | 28 | /* Remove the specified string from the list, return the new linked list head */ 29 | pa_strlist* pa_strlist_remove(pa_strlist *l, const char *s); 30 | 31 | /* Make a whitespace separated string of all server strings. Returned memory has to be freed with pa_xfree() */ 32 | char *pa_strlist_to_string(pa_strlist *l); 33 | 34 | /* Free the entire list */ 35 | void pa_strlist_free(pa_strlist *l); 36 | 37 | /* Return the next entry in the list in *string and remove it from 38 | * the list. Returns the new list head. The memory *string points to 39 | * has to be freed with pa_xfree() */ 40 | pa_strlist* pa_strlist_pop(pa_strlist *l, char **s); 41 | 42 | /* Parse a whitespace separated server list */ 43 | pa_strlist* pa_strlist_parse(const char *s); 44 | 45 | /* Reverse string list */ 46 | pa_strlist *pa_strlist_reverse(pa_strlist *l); 47 | 48 | /* Return the next item in the list */ 49 | pa_strlist *pa_strlist_next(pa_strlist *s); 50 | 51 | /* Return the string associated to the current item */ 52 | const char *pa_strlist_data(pa_strlist *s); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/pulsecore/svolume_orc.c: -------------------------------------------------------------------------------- 1 | /*** 2 | This file is part of PulseAudio. 3 | 4 | Copyright 2004-2006 Lennart Poettering 5 | Copyright 2009 Wim Taymans 6 | Copyright 2010 Arun Raghavan 7 | 8 | PulseAudio is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published 10 | by the Free Software Foundation; either version 2.1 of the License, 11 | or (at your option) any later version. 12 | 13 | PulseAudio is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with PulseAudio; if not, see . 20 | ***/ 21 | 22 | #ifdef HAVE_CONFIG_H 23 | #include 24 | #endif 25 | 26 | #include "cpu-orc.h" 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | pa_do_volume_func_t fallback; 33 | 34 | static void 35 | pa_volume_s16ne_orc(int16_t *samples, const int32_t *volumes, unsigned channels, unsigned length) { 36 | if (channels == 2) { 37 | int64_t v = (int64_t)volumes[1] << 32 | volumes[0]; 38 | pa_volume_s16ne_orc_2ch (samples, v, ((length / (sizeof(int16_t))) / 2)); 39 | } else if (channels == 1) 40 | pa_volume_s16ne_orc_1ch (samples, volumes[0], length / (sizeof(int16_t))); 41 | else 42 | fallback(samples, volumes, channels, length); 43 | } 44 | 45 | void pa_volume_func_init_orc(void) { 46 | pa_log_info("Initialising ORC optimized volume functions."); 47 | 48 | fallback = pa_get_volume_func(PA_SAMPLE_S16NE); 49 | pa_set_volume_func(PA_SAMPLE_S16NE, (pa_do_volume_func_t) pa_volume_s16ne_orc); 50 | } 51 | -------------------------------------------------------------------------------- /src/pulsecore/thread-mq.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsethreadmqhfoo 2 | #define foopulsethreadmqhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | /* Two way communication between a thread and a mainloop. Before the 28 | * thread is started a pa_thread_mq should be initialized and than 29 | * attached to the thread using pa_thread_mq_install(). */ 30 | 31 | typedef struct pa_thread_mq { 32 | pa_mainloop_api *main_mainloop; 33 | pa_mainloop_api *thread_mainloop; 34 | pa_asyncmsgq *inq, *outq; 35 | pa_io_event *read_main_event, *write_main_event; 36 | pa_io_event *read_thread_event, *write_thread_event; 37 | } pa_thread_mq; 38 | 39 | int pa_thread_mq_init(pa_thread_mq *q, pa_mainloop_api *mainloop, pa_rtpoll *rtpoll); 40 | int pa_thread_mq_init_thread_mainloop(pa_thread_mq *q, pa_mainloop_api *main_mainloop, pa_mainloop_api *thread_mainloop); 41 | void pa_thread_mq_done(pa_thread_mq *q); 42 | 43 | /* Install the specified pa_thread_mq object for the current thread */ 44 | void pa_thread_mq_install(pa_thread_mq *q); 45 | 46 | /* Return the pa_thread_mq object that is set for the current thread */ 47 | pa_thread_mq *pa_thread_mq_get(void); 48 | 49 | /* Verify that we are in control context (aka 'main context'). */ 50 | #define pa_assert_ctl_context(s) \ 51 | pa_assert(!pa_thread_mq_get()) 52 | 53 | /* Verify that we are in IO context (aka 'thread context'). */ 54 | #define pa_assert_io_context(s) \ 55 | pa_assert(pa_thread_mq_get()) 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/pulsecore/time-smoother.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsetimesmootherhfoo 2 | #define foopulsetimesmootherhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2007 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | 26 | typedef struct pa_smoother pa_smoother; 27 | 28 | pa_smoother* pa_smoother_new( 29 | pa_usec_t x_adjust_time, 30 | pa_usec_t x_history_time, 31 | bool monotonic, 32 | bool smoothing, 33 | unsigned min_history, 34 | pa_usec_t x_offset, 35 | bool paused); 36 | 37 | void pa_smoother_free(pa_smoother* s); 38 | 39 | /* Adds a new value to our dataset. x = local/system time, y = remote time */ 40 | void pa_smoother_put(pa_smoother *s, pa_usec_t x, pa_usec_t y); 41 | 42 | /* Returns an interpolated value based on the dataset. x = local/system time, return value = remote time */ 43 | pa_usec_t pa_smoother_get(pa_smoother *s, pa_usec_t x); 44 | 45 | /* 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 */ 46 | pa_usec_t pa_smoother_translate(pa_smoother *s, pa_usec_t x, pa_usec_t y_delay); 47 | 48 | void pa_smoother_set_time_offset(pa_smoother *s, pa_usec_t x_offset); 49 | 50 | void pa_smoother_pause(pa_smoother *s, pa_usec_t x); 51 | void pa_smoother_resume(pa_smoother *s, pa_usec_t x, bool abrupt); 52 | 53 | void pa_smoother_reset(pa_smoother *s, pa_usec_t time_offset, bool paused); 54 | 55 | void pa_smoother_fix_now(pa_smoother *s); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/pulsecore/time-smoother_2.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsetimesmoother2hfoo 2 | #define foopulsetimesmoother2hfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | PulseAudio is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as 9 | published by the Free Software Foundation; either version 2.1 of the 10 | License, or (at your option) any later version. 11 | 12 | PulseAudio is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with PulseAudio; if not, see . 19 | ***/ 20 | 21 | #include 22 | 23 | typedef struct pa_smoother_2 pa_smoother_2; 24 | 25 | /* Create new smoother */ 26 | pa_smoother_2* pa_smoother_2_new(pa_usec_t window, pa_usec_t time_stamp, uint32_t frame_size, uint32_t rate); 27 | /* Free the smoother */ 28 | void pa_smoother_2_free(pa_smoother_2* s); 29 | /* Reset the smoother */ 30 | void pa_smoother_2_reset(pa_smoother_2 *s, pa_usec_t time_stamp); 31 | /* Pause the smoother */ 32 | void pa_smoother_2_pause(pa_smoother_2 *s, pa_usec_t time_stamp); 33 | /* Resume the smoother */ 34 | void pa_smoother_2_resume(pa_smoother_2 *s, pa_usec_t time_stamp); 35 | 36 | /* Add a new data point and re-calculate time conversion factor */ 37 | void pa_smoother_2_put(pa_smoother_2 *s, pa_usec_t time_stamp, int64_t byte_count); 38 | 39 | /* Calculate the current latency. For a source, the sign of the result must be inverted */ 40 | int64_t pa_smoother_2_get_delay(pa_smoother_2 *s, pa_usec_t time_stamp, uint64_t byte_count); 41 | /* Convert system time since start to sound card time */ 42 | pa_usec_t pa_smoother_2_get(pa_smoother_2 *s, pa_usec_t time_stamp); 43 | /* Convert a time interval from sound card time to system time */ 44 | pa_usec_t pa_smoother_2_translate(pa_smoother_2 *s, pa_usec_t time_difference); 45 | 46 | /* Enable USB hack, only used for alsa sinks */ 47 | void pa_smoother_2_usb_hack_enable(pa_smoother_2 *s, bool enable, pa_usec_t offset); 48 | /* Set sample rate */ 49 | void pa_smoother_2_set_rate(pa_smoother_2 *s, pa_usec_t time_stamp, uint32_t rate); 50 | /* Set rate and frame size */ 51 | void pa_smoother_2_set_sample_spec(pa_smoother_2 *s, pa_usec_t time_stamp, pa_sample_spec *spec); 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/pulsecore/tokenizer.c: -------------------------------------------------------------------------------- 1 | /*** 2 | This file is part of PulseAudio. 3 | 4 | Copyright 2004-2006 Lennart Poettering 5 | 6 | PulseAudio is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published 8 | by the Free Software Foundation; either version 2.1 of the License, 9 | or (at your option) any later version. 10 | 11 | PulseAudio is distributed in the hope that it will be useful, but 12 | WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with PulseAudio; if not, see . 18 | ***/ 19 | 20 | #ifdef HAVE_CONFIG_H 21 | #include 22 | #endif 23 | 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | #include "tokenizer.h" 33 | 34 | static void parse(pa_dynarray*a, const char *s, unsigned args) { 35 | int infty = 0; 36 | const char delimiter[] = " \t\n\r"; 37 | const char *p; 38 | 39 | pa_assert(a); 40 | pa_assert(s); 41 | 42 | if (args == 0) 43 | infty = 1; 44 | 45 | p = s+strspn(s, delimiter); 46 | while (*p && (infty || args >= 2)) { 47 | size_t l = strcspn(p, delimiter); 48 | char *n = pa_xstrndup(p, l); 49 | pa_dynarray_append(a, n); 50 | p += l; 51 | p += strspn(p, delimiter); 52 | args--; 53 | } 54 | 55 | if (args && *p) { 56 | char *n = pa_xstrdup(p); 57 | pa_dynarray_append(a, n); 58 | } 59 | } 60 | 61 | pa_tokenizer* pa_tokenizer_new(const char *s, unsigned args) { 62 | pa_dynarray *a; 63 | 64 | a = pa_dynarray_new(pa_xfree); 65 | parse(a, s, args); 66 | return (pa_tokenizer*) a; 67 | } 68 | 69 | void pa_tokenizer_free(pa_tokenizer *t) { 70 | pa_dynarray *a = (pa_dynarray*) t; 71 | 72 | pa_assert(a); 73 | pa_dynarray_free(a); 74 | } 75 | 76 | const char *pa_tokenizer_get(pa_tokenizer *t, unsigned i) { 77 | pa_dynarray *a = (pa_dynarray*) t; 78 | 79 | pa_assert(a); 80 | 81 | return pa_dynarray_get(a, i); 82 | } 83 | -------------------------------------------------------------------------------- /src/pulsecore/tokenizer.h: -------------------------------------------------------------------------------- 1 | #ifndef footokenizerhfoo 2 | #define footokenizerhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | typedef struct pa_tokenizer pa_tokenizer; 24 | 25 | pa_tokenizer* pa_tokenizer_new(const char *s, unsigned args); 26 | void pa_tokenizer_free(pa_tokenizer *t); 27 | 28 | const char *pa_tokenizer_get(pa_tokenizer *t, unsigned i); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/pulsecore/typedefs.h: -------------------------------------------------------------------------------- 1 | #ifndef footypedefshfoo 2 | #define footypedefshfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2015 Canonical Ltd. 8 | Written by David Henningsson 9 | 10 | PulseAudio is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU Lesser General Public License as published 12 | by the Free Software Foundation; either version 2.1 of the License, 13 | or (at your option) any later version. 14 | 15 | PulseAudio is distributed in the hope that it will be useful, but 16 | WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License 21 | along with PulseAudio; if not, see . 22 | ***/ 23 | 24 | typedef struct pa_card pa_card; 25 | typedef struct pa_card_profile pa_card_profile; 26 | typedef struct pa_client pa_client; 27 | typedef struct pa_core pa_core; 28 | typedef struct pa_device_port pa_device_port; 29 | typedef struct pa_sink pa_sink; 30 | typedef struct pa_sink_volume_change pa_sink_volume_change; 31 | typedef struct pa_sink_input pa_sink_input; 32 | typedef struct pa_source pa_source; 33 | typedef struct pa_source_volume_change pa_source_volume_change; 34 | typedef struct pa_source_output pa_source_output; 35 | 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/pulsecore/usergroup.h: -------------------------------------------------------------------------------- 1 | #ifndef foousergrouphfoo 2 | #define foousergrouphfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2009 Ted Percival 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of the 12 | License, or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | 25 | #ifndef PACKAGE 26 | #error "Please include config.h before including this file!" 27 | #endif 28 | 29 | #ifdef HAVE_GRP_H 30 | 31 | struct group *pa_getgrgid_malloc(gid_t gid); 32 | void pa_getgrgid_free(struct group *grp); 33 | 34 | struct group *pa_getgrnam_malloc(const char *name); 35 | void pa_getgrnam_free(struct group *group); 36 | 37 | #endif /* HAVE_GRP_H */ 38 | 39 | #ifdef HAVE_PWD_H 40 | 41 | struct passwd *pa_getpwuid_malloc(uid_t uid); 42 | void pa_getpwuid_free(struct passwd *passwd); 43 | 44 | struct passwd *pa_getpwnam_malloc(const char *name); 45 | void pa_getpwnam_free(struct passwd *passwd); 46 | 47 | #endif /* HAVE_PWD_H */ 48 | 49 | #endif /* foousergrouphfoo */ 50 | -------------------------------------------------------------------------------- /src/pulsecore/winerrno.h: -------------------------------------------------------------------------------- 1 | 2 | /* Generated with: 3 | cat /usr/i686-pc-mingw32/sys-root/mingw/include/winerror.h \ 4 | | awk '/#define WSAE.*WSABASE/{gsub("WSA", ""); print "#undef " $2 "\n#define " $2 " WSA" $2}' \ 5 | | egrep -v 'EINTR|EBADF|EACCES|EFAULT|EINVAL|EMFILE|_QOS|PROVIDER|PROCTABLE' 6 | */ 7 | 8 | #undef EWOULDBLOCK 9 | #define EWOULDBLOCK WSAEWOULDBLOCK 10 | #undef EINPROGRESS 11 | #define EINPROGRESS WSAEINPROGRESS 12 | #undef EALREADY 13 | #define EALREADY WSAEALREADY 14 | #undef ENOTSOCK 15 | #define ENOTSOCK WSAENOTSOCK 16 | #undef EDESTADDRREQ 17 | #define EDESTADDRREQ WSAEDESTADDRREQ 18 | #undef EMSGSIZE 19 | #define EMSGSIZE WSAEMSGSIZE 20 | #undef EPROTOTYPE 21 | #define EPROTOTYPE WSAEPROTOTYPE 22 | #undef ENOPROTOOPT 23 | #define ENOPROTOOPT WSAENOPROTOOPT 24 | #undef EPROTONOSUPPORT 25 | #define EPROTONOSUPPORT WSAEPROTONOSUPPORT 26 | #undef ESOCKTNOSUPPORT 27 | #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT 28 | #undef EOPNOTSUPP 29 | #define EOPNOTSUPP WSAEOPNOTSUPP 30 | #undef EPFNOSUPPORT 31 | #define EPFNOSUPPORT WSAEPFNOSUPPORT 32 | #undef EAFNOSUPPORT 33 | #define EAFNOSUPPORT WSAEAFNOSUPPORT 34 | #undef EADDRINUSE 35 | #define EADDRINUSE WSAEADDRINUSE 36 | #undef EADDRNOTAVAIL 37 | #define EADDRNOTAVAIL WSAEADDRNOTAVAIL 38 | #undef ENETDOWN 39 | #define ENETDOWN WSAENETDOWN 40 | #undef ENETUNREACH 41 | #define ENETUNREACH WSAENETUNREACH 42 | #undef ENETRESET 43 | #define ENETRESET WSAENETRESET 44 | #undef ECONNABORTED 45 | #define ECONNABORTED WSAECONNABORTED 46 | #undef ECONNRESET 47 | #define ECONNRESET WSAECONNRESET 48 | #undef ENOBUFS 49 | #define ENOBUFS WSAENOBUFS 50 | #undef EISCONN 51 | #define EISCONN WSAEISCONN 52 | #undef ENOTCONN 53 | #define ENOTCONN WSAENOTCONN 54 | #undef ESHUTDOWN 55 | #define ESHUTDOWN WSAESHUTDOWN 56 | #undef ETOOMANYREFS 57 | #define ETOOMANYREFS WSAETOOMANYREFS 58 | #undef ETIMEDOUT 59 | #define ETIMEDOUT WSAETIMEDOUT 60 | #undef ECONNREFUSED 61 | #define ECONNREFUSED WSAECONNREFUSED 62 | #undef ELOOP 63 | #define ELOOP WSAELOOP 64 | #undef ENAMETOOLONG 65 | #define ENAMETOOLONG WSAENAMETOOLONG 66 | #undef EHOSTDOWN 67 | #define EHOSTDOWN WSAEHOSTDOWN 68 | #undef EHOSTUNREACH 69 | #define EHOSTUNREACH WSAEHOSTUNREACH 70 | #undef ENOTEMPTY 71 | #define ENOTEMPTY WSAENOTEMPTY 72 | #undef EPROCLIM 73 | #define EPROCLIM WSAEPROCLIM 74 | #undef EUSERS 75 | #define EUSERS WSAEUSERS 76 | #undef EDQUOT 77 | #define EDQUOT WSAEDQUOT 78 | #undef ESTALE 79 | #define ESTALE WSAESTALE 80 | #undef EREMOTE 81 | #define EREMOTE WSAEREMOTE 82 | #undef EDISCON 83 | #define EDISCON WSAEDISCON 84 | #undef ENOMORE 85 | #define ENOMORE WSAENOMORE 86 | #undef ECANCELLED 87 | #define ECANCELLED WSAECANCELLED 88 | #undef EREFUSED 89 | #define EREFUSED WSAEREFUSED 90 | -------------------------------------------------------------------------------- /src/pulsecore/x11prop.h: -------------------------------------------------------------------------------- 1 | #ifndef foox11prophfoo 2 | #define foox11prophfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | Copyright 2010 Colin Guthrie 9 | 10 | PulseAudio is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU Lesser General Public License as published 12 | by the Free Software Foundation; either version 2.1 of the License, 13 | or (at your option) any later version. 14 | 15 | PulseAudio is distributed in the hope that it will be useful, but 16 | WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License 21 | along with PulseAudio; if not, see . 22 | ***/ 23 | 24 | #include 25 | 26 | #include 27 | 28 | void pa_x11_set_prop(xcb_connection_t *xcb, int screen, const char *name, const char *data); 29 | void pa_x11_del_prop(xcb_connection_t *xcb, int screen, const char *name); 30 | char* pa_x11_get_prop(xcb_connection_t *xcb, int screen, const char *name, char *p, size_t l); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/pulsecore/x11wrap.h: -------------------------------------------------------------------------------- 1 | #ifndef foox11wraphfoo 2 | #define foox11wraphfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2004-2006 Lennart Poettering 8 | 9 | PulseAudio is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published 11 | by the Free Software Foundation; either version 2.1 of the License, 12 | or (at your option) any later version. 13 | 14 | PulseAudio is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with PulseAudio; if not, see . 21 | ***/ 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | typedef struct pa_x11_wrapper pa_x11_wrapper; 29 | 30 | typedef struct pa_x11_client pa_x11_client; 31 | 32 | typedef int (*pa_x11_event_cb_t)(pa_x11_wrapper *w, XEvent *e, void *userdata); 33 | typedef void (*pa_x11_kill_cb_t)(pa_x11_wrapper *w, void *userdata); 34 | 35 | /* Return the X11 wrapper for this core. In case no wrapper was 36 | existent before, allocate a new one */ 37 | pa_x11_wrapper* pa_x11_wrapper_get(pa_core *c, const char *name); 38 | 39 | /* Increase the wrapper's reference count by one */ 40 | pa_x11_wrapper* pa_x11_wrapper_ref(pa_x11_wrapper *w); 41 | 42 | /* Decrease the reference counter of an X11 wrapper object */ 43 | void pa_x11_wrapper_unref(pa_x11_wrapper* w); 44 | 45 | /* Return the X11 display object for this connection */ 46 | Display *pa_x11_wrapper_get_display(pa_x11_wrapper *w); 47 | 48 | /* Return the XCB connection object for this connection */ 49 | xcb_connection_t *pa_x11_wrapper_get_xcb_connection(pa_x11_wrapper *w); 50 | 51 | /* Initiate X11 connection teardown. */ 52 | void pa_x11_wrapper_kill_deferred(pa_x11_wrapper *w); 53 | 54 | /* Register an X11 client, that is called for each X11 event */ 55 | 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); 56 | 57 | /* Free an X11 client object */ 58 | void pa_x11_client_free(pa_x11_client *c); 59 | 60 | #endif 61 | --------------------------------------------------------------------------------