├── .gitignore ├── binding.gyp ├── index.js ├── package.json ├── readme.md ├── src ├── darwin.cc └── pulse.cc └── vendor └── pulse ├── cdecl.h ├── channelmap.h ├── context.h ├── def.h ├── direction.h ├── error.h ├── ext-device-manager.h ├── ext-device-restore.h ├── ext-stream-restore.h ├── format.h ├── gccmacro.h ├── glib-mainloop.h ├── introspect.h ├── mainloop-api.h ├── mainloop-signal.h ├── mainloop.h ├── operation.h ├── proplist.h ├── pulseaudio.h ├── rtclock.h ├── sample.h ├── scache.h ├── simple.h ├── stream.h ├── subscribe.h ├── thread-mainloop.h ├── timeval.h ├── utf8.h ├── util.h ├── version.h ├── volume.h └── xmalloc.h /.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /node_modules/ 3 | -------------------------------------------------------------------------------- /binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | "targets": [ 3 | { 4 | "target_name": "line-in", 5 | "include_dirs" : [ 6 | " 2 | #include 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | static const int kNumberBuffers = 3; 10 | static const int kBufferByteSize = 8192; 11 | 12 | class LineIn : public Nan::ObjectWrap { 13 | public: 14 | LineIn(); 15 | ~LineIn(); 16 | 17 | void enqueueBuffer(AudioQueueBufferRef bufferRef); 18 | static NAN_MODULE_INIT(Init); 19 | 20 | private: 21 | static NAN_METHOD(New); 22 | static NAN_METHOD(Read); 23 | 24 | void emitQueue(); 25 | static void _emitQueue(uv_async_t* handle); 26 | 27 | AudioStreamBasicDescription desc; 28 | AudioQueueRef audioQueue; 29 | 30 | bool hasEnded; 31 | std::vector *bufferQueue; 32 | 33 | uv_async_t async; 34 | uv_mutex_t async_lock; 35 | }; 36 | 37 | void callback (void *userData, AudioQueueRef audioQueue, AudioQueueBufferRef bufferRef, const AudioTimeStamp *startTime, UInt32 inumberPacketDescriptions, const AudioStreamPacketDescription *packetDescs) { 38 | static_cast(userData)->enqueueBuffer(bufferRef); 39 | } 40 | 41 | LineIn::LineIn() { 42 | uv_async_init(uv_default_loop(), &async, _emitQueue); 43 | uv_mutex_init(&async_lock); 44 | 45 | hasEnded = false; 46 | async.data = static_cast(this); 47 | bufferQueue = new std::vector(); 48 | } 49 | 50 | LineIn::~LineIn() { 51 | hasEnded = true; 52 | 53 | AudioQueueStop(audioQueue, true); 54 | uv_mutex_destroy(&async_lock); 55 | 56 | delete bufferQueue; 57 | } 58 | 59 | void LineIn::enqueueBuffer(AudioQueueBufferRef bufferRef) { 60 | if (hasEnded == true) { 61 | AudioQueueFreeBuffer(audioQueue, bufferRef); 62 | return; 63 | } 64 | 65 | // Add buffer to queue 66 | uv_mutex_lock(&async_lock); 67 | bufferQueue->push_back(bufferRef); 68 | uv_mutex_unlock(&async_lock); 69 | 70 | // Schedule emitting to JS land 71 | uv_async_send(&async); 72 | } 73 | 74 | void LineIn::emitQueue() { 75 | Nan::HandleScope scope; 76 | 77 | // Fetch and reset current queue 78 | uv_mutex_lock(&async_lock); 79 | const auto processingQueue = bufferQueue; 80 | bufferQueue = new std::vector(); 81 | uv_mutex_unlock(&async_lock); 82 | 83 | // Get a handle to the `push` function in JS land 84 | auto push = Nan::Get(handle(), Nan::New("push").ToLocalChecked()).ToLocalChecked().As(); 85 | 86 | for (auto const &bufferRef : *processingQueue) { 87 | // Make a copy of the buffer 88 | auto buffer = Nan::CopyBuffer(static_cast(bufferRef->mAudioData), bufferRef->mAudioDataByteSize).ToLocalChecked(); 89 | 90 | // Return the buffer back to the audio queue 91 | AudioQueueEnqueueBuffer(audioQueue, bufferRef, 0, nullptr); 92 | 93 | // Push the copied buffer to JS land 94 | Nan::TryCatch tc; 95 | v8::Local argv[] = { buffer }; 96 | push->Call(Nan::GetCurrentContext()->Global(), 1, argv); 97 | 98 | // Propagate errors from `push` 99 | if (tc.HasCaught()) { 100 | // TODO: emit error event 101 | Nan::FatalException(tc); 102 | } 103 | } 104 | 105 | // Free the old queue 106 | delete processingQueue; 107 | } 108 | 109 | void LineIn::_emitQueue(uv_async_t* handle) { 110 | static_cast(handle->data)->emitQueue(); 111 | } 112 | 113 | NAN_MODULE_INIT(LineIn::Init) { 114 | auto cname = Nan::New("LineIn").ToLocalChecked(); 115 | auto ctor = Nan::New(New); 116 | auto ctorInst = ctor->InstanceTemplate(); 117 | 118 | ctor->SetClassName(cname); 119 | ctorInst->SetInternalFieldCount(1); 120 | 121 | Nan::SetPrototypeMethod(ctor, "_read", Read); 122 | 123 | Nan::Set(target, cname, Nan::GetFunction(ctor).ToLocalChecked()); 124 | } 125 | 126 | NAN_METHOD(LineIn::New) { 127 | OSStatus status; 128 | 129 | if (!info.IsConstructCall()) { 130 | return Nan::ThrowTypeError("Cannot call a class constructor"); 131 | } 132 | 133 | auto instance = new LineIn(); 134 | instance->Wrap(info.This()); 135 | 136 | instance->desc.mSampleRate = 44100; 137 | instance->desc.mFormatID = kAudioFormatLinearPCM; 138 | instance->desc.mFormatFlags = kAudioFormatFlagIsSignedInteger; 139 | instance->desc.mBytesPerPacket = 0; 140 | instance->desc.mFramesPerPacket = 1; 141 | instance->desc.mBytesPerFrame = 0; 142 | instance->desc.mChannelsPerFrame = 2; 143 | instance->desc.mBitsPerChannel = 16; 144 | instance->desc.mReserved = 0; 145 | 146 | status = AudioQueueNewInput(&instance->desc, callback, instance, nullptr, nullptr, 0, &instance->audioQueue); 147 | if (status != 0) exit(1); 148 | 149 | for (int i = 0; i < kNumberBuffers; ++i) { 150 | AudioQueueBufferRef buffer; 151 | 152 | status = AudioQueueAllocateBuffer(instance->audioQueue, kBufferByteSize, &buffer); 153 | if (status != 0) exit(3); 154 | 155 | status = AudioQueueEnqueueBuffer(instance->audioQueue, buffer, 0, nullptr); 156 | if (status != 0) exit(4); 157 | } 158 | } 159 | 160 | NAN_METHOD(LineIn::Read) { 161 | OSStatus status; 162 | 163 | auto instance = LineIn::Unwrap(info.Holder()); 164 | 165 | status = AudioQueueStart(instance->audioQueue, nullptr); 166 | if (status != 0) exit(2); 167 | } 168 | 169 | NAN_MODULE_INIT(Initialize) { 170 | LineIn::Init(target); 171 | } 172 | 173 | NODE_MODULE(line_in, Initialize) 174 | -------------------------------------------------------------------------------- /src/pulse.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | static const size_t kBufferByteSize = 8192; 8 | 9 | class LineIn : public Nan::ObjectWrap { 10 | public: 11 | LineIn(); 12 | ~LineIn(); 13 | 14 | static void _emitBuffer(uv_work_t *work, int status); 15 | static NAN_MODULE_INIT(Init); 16 | 17 | private: 18 | static NAN_METHOD(New); 19 | static NAN_METHOD(Read); 20 | 21 | void emitBuffer(void *data); 22 | void scheduleRead(); 23 | 24 | bool reading; 25 | uv_work_t work; 26 | 27 | pa_sample_spec spec; 28 | pa_simple *pulseHandle; 29 | }; 30 | 31 | struct WorkInfo { 32 | pa_simple *pulseHandle; 33 | void *audioBuffer; 34 | LineIn *instance; 35 | }; 36 | 37 | void callback(uv_work_t *work) { 38 | auto workInfo = static_cast(work->data); 39 | 40 | workInfo->audioBuffer = malloc(kBufferByteSize); 41 | 42 | int error; 43 | auto status = pa_simple_read(workInfo->pulseHandle, workInfo->audioBuffer, kBufferByteSize, &error); 44 | 45 | if (status < 0) exit(2); 46 | } 47 | 48 | LineIn::LineIn() { 49 | reading = false; 50 | } 51 | 52 | LineIn::~LineIn() { 53 | pa_simple_free(pulseHandle); 54 | } 55 | 56 | void LineIn::_emitBuffer(uv_work_t *work, int status) { 57 | auto workInfo = static_cast(work->data); 58 | workInfo->instance->emitBuffer(workInfo->audioBuffer); 59 | delete workInfo; 60 | } 61 | 62 | void LineIn::emitBuffer(void *audioBuffer) { 63 | Nan::HandleScope scope; 64 | 65 | // Get a handle to the `push` function in JS land 66 | auto push = Nan::Get(handle(), Nan::New("push").ToLocalChecked()).ToLocalChecked().As(); 67 | 68 | // Create a Node.js buffer 69 | auto buffer = Nan::NewBuffer(static_cast(audioBuffer), kBufferByteSize).ToLocalChecked(); 70 | 71 | // Push the copied buffer to JS land 72 | Nan::TryCatch tc; 73 | v8::Local argv[] = { buffer }; 74 | auto readMore = push->Call(Nan::GetCurrentContext()->Global(), 1, argv); 75 | 76 | // Propagate errors from `push` 77 | if (tc.HasCaught()) { 78 | // TODO: emit error event 79 | Nan::FatalException(tc); 80 | } 81 | 82 | reading = false; 83 | 84 | if (readMore->IsTrue()) { 85 | scheduleRead(); 86 | } 87 | } 88 | 89 | void LineIn::scheduleRead() { 90 | if (reading) return; 91 | 92 | reading = true; 93 | 94 | auto workInfo = new WorkInfo; 95 | 96 | workInfo->instance = this; 97 | workInfo->pulseHandle = pulseHandle; 98 | 99 | work.data = static_cast(workInfo); 100 | 101 | uv_queue_work(uv_default_loop(), &work, callback, _emitBuffer); 102 | } 103 | 104 | NAN_MODULE_INIT(LineIn::Init) { 105 | auto cname = Nan::New("LineIn").ToLocalChecked(); 106 | auto ctor = Nan::New(New); 107 | auto ctorInst = ctor->InstanceTemplate(); 108 | 109 | ctor->SetClassName(cname); 110 | ctorInst->SetInternalFieldCount(1); 111 | 112 | Nan::SetPrototypeMethod(ctor, "_read", Read); 113 | 114 | Nan::Set(target, cname, Nan::GetFunction(ctor).ToLocalChecked()); 115 | } 116 | 117 | NAN_METHOD(LineIn::New) { 118 | if (!info.IsConstructCall()) { 119 | return Nan::ThrowTypeError("Cannot call a class constructor"); 120 | } 121 | 122 | auto instance = new LineIn(); 123 | instance->Wrap(info.This()); 124 | 125 | instance->spec.format = PA_SAMPLE_S16LE; 126 | instance->spec.channels = 2; 127 | instance->spec.rate = 44100; 128 | 129 | int error; 130 | instance->pulseHandle = pa_simple_new(nullptr, "Node.js", PA_STREAM_RECORD, nullptr, "Line In", &instance->spec, nullptr, nullptr, &error); 131 | if (instance->pulseHandle == nullptr) { 132 | Nan::ThrowError(pa_strerror(error)); 133 | } 134 | } 135 | 136 | NAN_METHOD(LineIn::Read) { 137 | LineIn::Unwrap(info.Holder())->scheduleRead(); 138 | } 139 | 140 | NAN_MODULE_INIT(Initialize) { 141 | LineIn::Init(target); 142 | } 143 | 144 | NODE_MODULE(line_in, Initialize) 145 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/pulse/channelmap.h: -------------------------------------------------------------------------------- 1 | #ifndef foochannelmaphfoo 2 | #define foochannelmaphfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2005-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 | 29 | /** \page channelmap Channel Maps 30 | * 31 | * \section overv_sec Overview 32 | * 33 | * Channel maps provide a way to associate channels in a stream with a 34 | * specific speaker position. This relieves applications of having to 35 | * make sure their channel order is identical to the final output. 36 | * 37 | * \section init_sec Initialisation 38 | * 39 | * A channel map consists of an array of \ref pa_channel_position values, 40 | * one for each channel. This array is stored together with a channel count 41 | * in a pa_channel_map structure. 42 | * 43 | * Before filling the structure, the application must initialise it using 44 | * pa_channel_map_init(). There are also a number of convenience functions 45 | * for standard channel mappings: 46 | * 47 | * \li pa_channel_map_init_mono() - Create a channel map with only mono audio. 48 | * \li pa_channel_map_init_stereo() - Create a standard stereo mapping. 49 | * \li pa_channel_map_init_auto() - Create a standard channel map for a specific number of channels 50 | * \li pa_channel_map_init_extend() - Similar to 51 | * pa_channel_map_init_auto() but synthesize a channel map if no 52 | * predefined one is known for the specified number of channels. 53 | * 54 | * \section conv_sec Convenience Functions 55 | * 56 | * The library contains a number of convenience functions for dealing with 57 | * channel maps: 58 | * 59 | * \li pa_channel_map_valid() - Tests if a channel map is valid. 60 | * \li pa_channel_map_equal() - Tests if two channel maps are identical. 61 | * \li pa_channel_map_snprint() - Creates a textual description of a channel 62 | * map. 63 | */ 64 | 65 | /** \file 66 | * Constants and routines for channel mapping handling 67 | * 68 | * See also \subpage channelmap 69 | */ 70 | 71 | PA_C_DECL_BEGIN 72 | 73 | /** A list of channel labels */ 74 | typedef enum pa_channel_position { 75 | PA_CHANNEL_POSITION_INVALID = -1, 76 | PA_CHANNEL_POSITION_MONO = 0, 77 | 78 | PA_CHANNEL_POSITION_FRONT_LEFT, /**< Apple, Dolby call this 'Left' */ 79 | PA_CHANNEL_POSITION_FRONT_RIGHT, /**< Apple, Dolby call this 'Right' */ 80 | PA_CHANNEL_POSITION_FRONT_CENTER, /**< Apple, Dolby call this 'Center' */ 81 | 82 | /** \cond fulldocs */ 83 | PA_CHANNEL_POSITION_LEFT = PA_CHANNEL_POSITION_FRONT_LEFT, 84 | PA_CHANNEL_POSITION_RIGHT = PA_CHANNEL_POSITION_FRONT_RIGHT, 85 | PA_CHANNEL_POSITION_CENTER = PA_CHANNEL_POSITION_FRONT_CENTER, 86 | /** \endcond */ 87 | 88 | PA_CHANNEL_POSITION_REAR_CENTER, /**< Microsoft calls this 'Back Center', Apple calls this 'Center Surround', Dolby calls this 'Surround Rear Center' */ 89 | PA_CHANNEL_POSITION_REAR_LEFT, /**< Microsoft calls this 'Back Left', Apple calls this 'Left Surround' (!), Dolby calls this 'Surround Rear Left' */ 90 | PA_CHANNEL_POSITION_REAR_RIGHT, /**< Microsoft calls this 'Back Right', Apple calls this 'Right Surround' (!), Dolby calls this 'Surround Rear Right' */ 91 | 92 | PA_CHANNEL_POSITION_LFE, /**< Microsoft calls this 'Low Frequency', Apple calls this 'LFEScreen' */ 93 | /** \cond fulldocs */ 94 | PA_CHANNEL_POSITION_SUBWOOFER = PA_CHANNEL_POSITION_LFE, 95 | /** \endcond */ 96 | 97 | PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER, /**< Apple, Dolby call this 'Left Center' */ 98 | PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER, /**< Apple, Dolby call this 'Right Center */ 99 | 100 | PA_CHANNEL_POSITION_SIDE_LEFT, /**< Apple calls this 'Left Surround Direct', Dolby calls this 'Surround Left' (!) */ 101 | PA_CHANNEL_POSITION_SIDE_RIGHT, /**< Apple calls this 'Right Surround Direct', Dolby calls this 'Surround Right' (!) */ 102 | 103 | PA_CHANNEL_POSITION_AUX0, 104 | PA_CHANNEL_POSITION_AUX1, 105 | PA_CHANNEL_POSITION_AUX2, 106 | PA_CHANNEL_POSITION_AUX3, 107 | PA_CHANNEL_POSITION_AUX4, 108 | PA_CHANNEL_POSITION_AUX5, 109 | PA_CHANNEL_POSITION_AUX6, 110 | PA_CHANNEL_POSITION_AUX7, 111 | PA_CHANNEL_POSITION_AUX8, 112 | PA_CHANNEL_POSITION_AUX9, 113 | PA_CHANNEL_POSITION_AUX10, 114 | PA_CHANNEL_POSITION_AUX11, 115 | PA_CHANNEL_POSITION_AUX12, 116 | PA_CHANNEL_POSITION_AUX13, 117 | PA_CHANNEL_POSITION_AUX14, 118 | PA_CHANNEL_POSITION_AUX15, 119 | PA_CHANNEL_POSITION_AUX16, 120 | PA_CHANNEL_POSITION_AUX17, 121 | PA_CHANNEL_POSITION_AUX18, 122 | PA_CHANNEL_POSITION_AUX19, 123 | PA_CHANNEL_POSITION_AUX20, 124 | PA_CHANNEL_POSITION_AUX21, 125 | PA_CHANNEL_POSITION_AUX22, 126 | PA_CHANNEL_POSITION_AUX23, 127 | PA_CHANNEL_POSITION_AUX24, 128 | PA_CHANNEL_POSITION_AUX25, 129 | PA_CHANNEL_POSITION_AUX26, 130 | PA_CHANNEL_POSITION_AUX27, 131 | PA_CHANNEL_POSITION_AUX28, 132 | PA_CHANNEL_POSITION_AUX29, 133 | PA_CHANNEL_POSITION_AUX30, 134 | PA_CHANNEL_POSITION_AUX31, 135 | 136 | PA_CHANNEL_POSITION_TOP_CENTER, /**< Apple calls this 'Top Center Surround' */ 137 | 138 | PA_CHANNEL_POSITION_TOP_FRONT_LEFT, /**< Apple calls this 'Vertical Height Left' */ 139 | PA_CHANNEL_POSITION_TOP_FRONT_RIGHT, /**< Apple calls this 'Vertical Height Right' */ 140 | PA_CHANNEL_POSITION_TOP_FRONT_CENTER, /**< Apple calls this 'Vertical Height Center' */ 141 | 142 | PA_CHANNEL_POSITION_TOP_REAR_LEFT, /**< Microsoft and Apple call this 'Top Back Left' */ 143 | PA_CHANNEL_POSITION_TOP_REAR_RIGHT, /**< Microsoft and Apple call this 'Top Back Right' */ 144 | PA_CHANNEL_POSITION_TOP_REAR_CENTER, /**< Microsoft and Apple call this 'Top Back Center' */ 145 | 146 | PA_CHANNEL_POSITION_MAX 147 | } pa_channel_position_t; 148 | 149 | /** \cond fulldocs */ 150 | #define PA_CHANNEL_POSITION_INVALID PA_CHANNEL_POSITION_INVALID 151 | #define PA_CHANNEL_POSITION_MONO PA_CHANNEL_POSITION_MONO 152 | #define PA_CHANNEL_POSITION_LEFT PA_CHANNEL_POSITION_LEFT 153 | #define PA_CHANNEL_POSITION_RIGHT PA_CHANNEL_POSITION_RIGHT 154 | #define PA_CHANNEL_POSITION_CENTER PA_CHANNEL_POSITION_CENTER 155 | #define PA_CHANNEL_POSITION_FRONT_LEFT PA_CHANNEL_POSITION_FRONT_LEFT 156 | #define PA_CHANNEL_POSITION_FRONT_RIGHT PA_CHANNEL_POSITION_FRONT_RIGHT 157 | #define PA_CHANNEL_POSITION_FRONT_CENTER PA_CHANNEL_POSITION_FRONT_CENTER 158 | #define PA_CHANNEL_POSITION_REAR_CENTER PA_CHANNEL_POSITION_REAR_CENTER 159 | #define PA_CHANNEL_POSITION_REAR_LEFT PA_CHANNEL_POSITION_REAR_LEFT 160 | #define PA_CHANNEL_POSITION_REAR_RIGHT PA_CHANNEL_POSITION_REAR_RIGHT 161 | #define PA_CHANNEL_POSITION_LFE PA_CHANNEL_POSITION_LFE 162 | #define PA_CHANNEL_POSITION_SUBWOOFER PA_CHANNEL_POSITION_SUBWOOFER 163 | #define PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER 164 | #define PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER 165 | #define PA_CHANNEL_POSITION_SIDE_LEFT PA_CHANNEL_POSITION_SIDE_LEFT 166 | #define PA_CHANNEL_POSITION_SIDE_RIGHT PA_CHANNEL_POSITION_SIDE_RIGHT 167 | #define PA_CHANNEL_POSITION_AUX0 PA_CHANNEL_POSITION_AUX0 168 | #define PA_CHANNEL_POSITION_AUX1 PA_CHANNEL_POSITION_AUX1 169 | #define PA_CHANNEL_POSITION_AUX2 PA_CHANNEL_POSITION_AUX2 170 | #define PA_CHANNEL_POSITION_AUX3 PA_CHANNEL_POSITION_AUX3 171 | #define PA_CHANNEL_POSITION_AUX4 PA_CHANNEL_POSITION_AUX4 172 | #define PA_CHANNEL_POSITION_AUX5 PA_CHANNEL_POSITION_AUX5 173 | #define PA_CHANNEL_POSITION_AUX6 PA_CHANNEL_POSITION_AUX6 174 | #define PA_CHANNEL_POSITION_AUX7 PA_CHANNEL_POSITION_AUX7 175 | #define PA_CHANNEL_POSITION_AUX8 PA_CHANNEL_POSITION_AUX8 176 | #define PA_CHANNEL_POSITION_AUX9 PA_CHANNEL_POSITION_AUX9 177 | #define PA_CHANNEL_POSITION_AUX10 PA_CHANNEL_POSITION_AUX10 178 | #define PA_CHANNEL_POSITION_AUX11 PA_CHANNEL_POSITION_AUX11 179 | #define PA_CHANNEL_POSITION_AUX12 PA_CHANNEL_POSITION_AUX12 180 | #define PA_CHANNEL_POSITION_AUX13 PA_CHANNEL_POSITION_AUX13 181 | #define PA_CHANNEL_POSITION_AUX14 PA_CHANNEL_POSITION_AUX14 182 | #define PA_CHANNEL_POSITION_AUX15 PA_CHANNEL_POSITION_AUX15 183 | #define PA_CHANNEL_POSITION_AUX16 PA_CHANNEL_POSITION_AUX16 184 | #define PA_CHANNEL_POSITION_AUX17 PA_CHANNEL_POSITION_AUX17 185 | #define PA_CHANNEL_POSITION_AUX18 PA_CHANNEL_POSITION_AUX18 186 | #define PA_CHANNEL_POSITION_AUX19 PA_CHANNEL_POSITION_AUX19 187 | #define PA_CHANNEL_POSITION_AUX20 PA_CHANNEL_POSITION_AUX20 188 | #define PA_CHANNEL_POSITION_AUX21 PA_CHANNEL_POSITION_AUX21 189 | #define PA_CHANNEL_POSITION_AUX22 PA_CHANNEL_POSITION_AUX22 190 | #define PA_CHANNEL_POSITION_AUX23 PA_CHANNEL_POSITION_AUX23 191 | #define PA_CHANNEL_POSITION_AUX24 PA_CHANNEL_POSITION_AUX24 192 | #define PA_CHANNEL_POSITION_AUX25 PA_CHANNEL_POSITION_AUX25 193 | #define PA_CHANNEL_POSITION_AUX26 PA_CHANNEL_POSITION_AUX26 194 | #define PA_CHANNEL_POSITION_AUX27 PA_CHANNEL_POSITION_AUX27 195 | #define PA_CHANNEL_POSITION_AUX28 PA_CHANNEL_POSITION_AUX28 196 | #define PA_CHANNEL_POSITION_AUX29 PA_CHANNEL_POSITION_AUX29 197 | #define PA_CHANNEL_POSITION_AUX30 PA_CHANNEL_POSITION_AUX30 198 | #define PA_CHANNEL_POSITION_AUX31 PA_CHANNEL_POSITION_AUX31 199 | #define PA_CHANNEL_POSITION_TOP_CENTER PA_CHANNEL_POSITION_TOP_CENTER 200 | #define PA_CHANNEL_POSITION_TOP_FRONT_LEFT PA_CHANNEL_POSITION_TOP_FRONT_LEFT 201 | #define PA_CHANNEL_POSITION_TOP_FRONT_RIGHT PA_CHANNEL_POSITION_TOP_FRONT_RIGHT 202 | #define PA_CHANNEL_POSITION_TOP_FRONT_CENTER PA_CHANNEL_POSITION_TOP_FRONT_CENTER 203 | #define PA_CHANNEL_POSITION_TOP_REAR_LEFT PA_CHANNEL_POSITION_TOP_REAR_LEFT 204 | #define PA_CHANNEL_POSITION_TOP_REAR_RIGHT PA_CHANNEL_POSITION_TOP_REAR_RIGHT 205 | #define PA_CHANNEL_POSITION_TOP_REAR_CENTER PA_CHANNEL_POSITION_TOP_REAR_CENTER 206 | #define PA_CHANNEL_POSITION_MAX PA_CHANNEL_POSITION_MAX 207 | /** \endcond */ 208 | 209 | /** A mask of channel positions. \since 0.9.16 */ 210 | typedef uint64_t pa_channel_position_mask_t; 211 | 212 | /** Makes a bit mask from a channel position. \since 0.9.16 */ 213 | #define PA_CHANNEL_POSITION_MASK(f) ((pa_channel_position_mask_t) (1ULL << (f))) 214 | 215 | /** A list of channel mapping definitions for pa_channel_map_init_auto() */ 216 | typedef enum pa_channel_map_def { 217 | PA_CHANNEL_MAP_AIFF, 218 | /**< The mapping from RFC3551, which is based on AIFF-C */ 219 | 220 | /** \cond fulldocs */ 221 | PA_CHANNEL_MAP_ALSA, 222 | /**< The default mapping used by ALSA. This mapping is probably 223 | * not too useful since ALSA's default channel mapping depends on 224 | * the device string used. */ 225 | /** \endcond */ 226 | 227 | PA_CHANNEL_MAP_AUX, 228 | /**< Only aux channels */ 229 | 230 | PA_CHANNEL_MAP_WAVEEX, 231 | /**< Microsoft's WAVEFORMATEXTENSIBLE mapping. This mapping works 232 | * as if all LSBs of dwChannelMask are set. */ 233 | 234 | /** \cond fulldocs */ 235 | PA_CHANNEL_MAP_OSS, 236 | /**< The default channel mapping used by OSS as defined in the OSS 237 | * 4.0 API specs. This mapping is probably not too useful since 238 | * the OSS API has changed in this respect and no longer knows a 239 | * default channel mapping based on the number of channels. */ 240 | /** \endcond */ 241 | 242 | /**< Upper limit of valid channel mapping definitions */ 243 | PA_CHANNEL_MAP_DEF_MAX, 244 | 245 | PA_CHANNEL_MAP_DEFAULT = PA_CHANNEL_MAP_AIFF 246 | /**< The default channel map */ 247 | } pa_channel_map_def_t; 248 | 249 | /** \cond fulldocs */ 250 | #define PA_CHANNEL_MAP_AIFF PA_CHANNEL_MAP_AIFF 251 | #define PA_CHANNEL_MAP_ALSA PA_CHANNEL_MAP_ALSA 252 | #define PA_CHANNEL_MAP_AUX PA_CHANNEL_MAP_AUX 253 | #define PA_CHANNEL_MAP_WAVEEX PA_CHANNEL_MAP_WAVEEX 254 | #define PA_CHANNEL_MAP_OSS PA_CHANNEL_MAP_OSS 255 | #define PA_CHANNEL_MAP_DEF_MAX PA_CHANNEL_MAP_DEF_MAX 256 | #define PA_CHANNEL_MAP_DEFAULT PA_CHANNEL_MAP_DEFAULT 257 | /** \endcond */ 258 | 259 | /** A channel map which can be used to attach labels to specific 260 | * channels of a stream. These values are relevant for conversion and 261 | * mixing of streams */ 262 | typedef struct pa_channel_map { 263 | uint8_t channels; 264 | /**< Number of channels */ 265 | 266 | pa_channel_position_t map[PA_CHANNELS_MAX]; 267 | /**< Channel labels */ 268 | } pa_channel_map; 269 | 270 | /** Initialize the specified channel map and return a pointer to 271 | * it. The channel map will have a defined state but 272 | * pa_channel_map_valid() will fail for it. */ 273 | pa_channel_map* pa_channel_map_init(pa_channel_map *m); 274 | 275 | /** Initialize the specified channel map for monaural audio and return a pointer to it */ 276 | pa_channel_map* pa_channel_map_init_mono(pa_channel_map *m); 277 | 278 | /** Initialize the specified channel map for stereophonic audio and return a pointer to it */ 279 | pa_channel_map* pa_channel_map_init_stereo(pa_channel_map *m); 280 | 281 | /** Initialize the specified channel map for the specified number of 282 | * channels using default labels and return a pointer to it. This call 283 | * will fail (return NULL) if there is no default channel map known for this 284 | * specific number of channels and mapping. */ 285 | pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, pa_channel_map_def_t def); 286 | 287 | /** Similar to pa_channel_map_init_auto() but instead of failing if no 288 | * default mapping is known with the specified parameters it will 289 | * synthesize a mapping based on a known mapping with fewer channels 290 | * and fill up the rest with AUX0...AUX31 channels \since 0.9.11 */ 291 | pa_channel_map* pa_channel_map_init_extend(pa_channel_map *m, unsigned channels, pa_channel_map_def_t def); 292 | 293 | /** Return a text label for the specified channel position */ 294 | const char* pa_channel_position_to_string(pa_channel_position_t pos) PA_GCC_PURE; 295 | 296 | /** The inverse of pa_channel_position_to_string(). \since 0.9.16 */ 297 | pa_channel_position_t pa_channel_position_from_string(const char *s) PA_GCC_PURE; 298 | 299 | /** Return a human readable text label for the specified channel position. \since 0.9.7 */ 300 | const char* pa_channel_position_to_pretty_string(pa_channel_position_t pos); 301 | 302 | /** The maximum length of strings returned by 303 | * pa_channel_map_snprint(). Please note that this value can change 304 | * with any release without warning and without being considered API 305 | * or ABI breakage. You should not use this definition anywhere where 306 | * it might become part of an ABI. */ 307 | #define PA_CHANNEL_MAP_SNPRINT_MAX 336 308 | 309 | /** Make a human readable string from the specified channel map */ 310 | char* pa_channel_map_snprint(char *s, size_t l, const pa_channel_map *map); 311 | 312 | /** Parse a channel position list or well-known mapping name into a 313 | * channel map structure. This turns the output of 314 | * pa_channel_map_snprint() and pa_channel_map_to_name() back into a 315 | * pa_channel_map */ 316 | pa_channel_map *pa_channel_map_parse(pa_channel_map *map, const char *s); 317 | 318 | /** Compare two channel maps. Return 1 if both match. */ 319 | int pa_channel_map_equal(const pa_channel_map *a, const pa_channel_map *b) PA_GCC_PURE; 320 | 321 | /** Return non-zero if the specified channel map is considered valid */ 322 | int pa_channel_map_valid(const pa_channel_map *map) PA_GCC_PURE; 323 | 324 | /** Return non-zero if the specified channel map is compatible with 325 | * the specified sample spec. \since 0.9.12 */ 326 | int pa_channel_map_compatible(const pa_channel_map *map, const pa_sample_spec *ss) PA_GCC_PURE; 327 | 328 | /** Returns non-zero if every channel defined in b is also defined in a. \since 0.9.15 */ 329 | int pa_channel_map_superset(const pa_channel_map *a, const pa_channel_map *b) PA_GCC_PURE; 330 | 331 | /** Returns non-zero if it makes sense to apply a volume 'balance' 332 | * with this mapping, i.e.\ if there are left/right channels 333 | * available. \since 0.9.15 */ 334 | int pa_channel_map_can_balance(const pa_channel_map *map) PA_GCC_PURE; 335 | 336 | /** Returns non-zero if it makes sense to apply a volume 'fade' 337 | * (i.e.\ 'balance' between front and rear) with this mapping, i.e.\ if 338 | * there are front/rear channels available. \since 0.9.15 */ 339 | int pa_channel_map_can_fade(const pa_channel_map *map) PA_GCC_PURE; 340 | 341 | /** Tries to find a well-known channel mapping name for this channel 342 | * mapping, i.e.\ "stereo", "surround-71" and so on. If the channel 343 | * mapping is unknown NULL will be returned. This name can be parsed 344 | * with pa_channel_map_parse() \since 0.9.15 */ 345 | const char* pa_channel_map_to_name(const pa_channel_map *map) PA_GCC_PURE; 346 | 347 | /** Tries to find a human readable text label for this channel 348 | mapping, i.e.\ "Stereo", "Surround 7.1" and so on. If the channel 349 | mapping is unknown NULL will be returned. \since 0.9.15 */ 350 | const char* pa_channel_map_to_pretty_name(const pa_channel_map *map) PA_GCC_PURE; 351 | 352 | /** Returns non-zero if the specified channel position is available at 353 | * least once in the channel map. \since 0.9.16 */ 354 | int pa_channel_map_has_position(const pa_channel_map *map, pa_channel_position_t p) PA_GCC_PURE; 355 | 356 | /** Generates a bit mask from a channel map. \since 0.9.16 */ 357 | pa_channel_position_mask_t pa_channel_map_mask(const pa_channel_map *map) PA_GCC_PURE; 358 | 359 | PA_C_DECL_END 360 | 361 | #endif 362 | -------------------------------------------------------------------------------- /vendor/pulse/context.h: -------------------------------------------------------------------------------- 1 | #ifndef foocontexthfoo 2 | #define foocontexthfoo 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 | #include 31 | 32 | /** \page async Asynchronous API 33 | * 34 | * \section overv_sec Overview 35 | * 36 | * The asynchronous API is the native interface to the PulseAudio library. 37 | * It allows full access to all available functionality. This however means that 38 | * it is rather complex and can take some time to fully master. 39 | * 40 | * \section mainloop_sec Main Loop Abstraction 41 | * 42 | * The API is based around an asynchronous event loop, or main loop, 43 | * abstraction. This abstraction contains three basic elements: 44 | * 45 | * \li Deferred events - Events that will trigger as soon as possible. Note 46 | * that some implementations may block all other events 47 | * when a deferred event is active. 48 | * \li I/O events - Events that trigger on file descriptor activities. 49 | * \li Times events - Events that trigger after a fixed amount of time. 50 | * 51 | * The abstraction is represented as a number of function pointers in the 52 | * pa_mainloop_api structure. 53 | * 54 | * To actually be able to use these functions, an implementation needs to 55 | * be coupled to the abstraction. There are three of these shipped with 56 | * PulseAudio, but any other can be used with a minimal amount of work, 57 | * provided it supports the three basic events listed above. 58 | * 59 | * The implementations shipped with PulseAudio are: 60 | * 61 | * \li \subpage mainloop - A minimal but fast implementation based on poll(). 62 | * \li \subpage threaded_mainloop - A special version of the previous 63 | * implementation where all of PulseAudio's 64 | * internal handling runs in a separate 65 | * thread. 66 | * \li \subpage glib-mainloop - A wrapper around GLib's main loop. 67 | * 68 | * UNIX signals may be hooked to a main loop using the functions from 69 | * \ref mainloop-signal.h. These rely only on the main loop abstraction 70 | * and can therefore be used with any of the implementations. 71 | * 72 | * \section refcnt_sec Reference Counting 73 | * 74 | * Almost all objects in PulseAudio are reference counted. What that means 75 | * is that you rarely malloc() or free() any objects. Instead you increase 76 | * and decrease their reference counts. Whenever an object's reference 77 | * count reaches zero, that object gets destroy and any resources it uses 78 | * get freed. 79 | * 80 | * The benefit of this design is that an application need not worry about 81 | * whether or not it needs to keep an object around in case the library is 82 | * using it internally. If it is, then it has made sure it has its own 83 | * reference to it. 84 | * 85 | * Whenever the library creates an object, it will have an initial 86 | * reference count of one. Most of the time, this single reference will be 87 | * sufficient for the application, so all required reference count 88 | * interaction will be a single call to the object's unref function. 89 | * 90 | * \section context_sec Context 91 | * 92 | * A context is the basic object for a connection to a PulseAudio server. 93 | * It multiplexes commands, data streams and events through a single 94 | * channel. 95 | * 96 | * There is no need for more than one context per application, unless 97 | * connections to multiple servers are needed. 98 | * 99 | * \subsection ops_subsec Operations 100 | * 101 | * All operations on the context are performed asynchronously. I.e. the 102 | * client will not wait for the server to complete the request. To keep 103 | * track of all these in-flight operations, the application is given a 104 | * pa_operation object for each asynchronous operation. 105 | * 106 | * There are only two actions (besides reference counting) that can be 107 | * performed on a pa_operation: querying its state with 108 | * pa_operation_get_state() and aborting it with pa_operation_cancel(). 109 | * 110 | * A pa_operation object is reference counted, so an application must 111 | * make sure to unreference it, even if it has no intention of using it. 112 | * 113 | * \subsection conn_subsec Connecting 114 | * 115 | * A context must be connected to a server before any operation can be 116 | * issued. Calling pa_context_connect() will initiate the connection 117 | * procedure. Unlike most asynchronous operations, connecting does not 118 | * result in a pa_operation object. Instead, the application should 119 | * register a callback using pa_context_set_state_callback(). 120 | * 121 | * \subsection disc_subsec Disconnecting 122 | * 123 | * When the sound support is no longer needed, the connection needs to be 124 | * closed using pa_context_disconnect(). This is an immediate function that 125 | * works synchronously. 126 | * 127 | * Since the context object has references to other objects it must be 128 | * disconnected after use or there is a high risk of memory leaks. If the 129 | * connection has terminated by itself, then there is no need to explicitly 130 | * disconnect the context using pa_context_disconnect(). 131 | * 132 | * \section Functions 133 | * 134 | * The sound server's functionality can be divided into a number of 135 | * subsections: 136 | * 137 | * \li \subpage streams 138 | * \li \subpage scache 139 | * \li \subpage introspect 140 | * \li \subpage subscribe 141 | */ 142 | 143 | /** \file 144 | * Connection contexts for asynchronous communication with a 145 | * server. A pa_context object wraps a connection to a PulseAudio 146 | * server using its native protocol. 147 | * 148 | * See also \subpage async 149 | */ 150 | 151 | PA_C_DECL_BEGIN 152 | 153 | /** An opaque connection context to a daemon */ 154 | typedef struct pa_context pa_context; 155 | 156 | /** Generic notification callback prototype */ 157 | typedef void (*pa_context_notify_cb_t)(pa_context *c, void *userdata); 158 | 159 | /** A generic callback for operation completion */ 160 | typedef void (*pa_context_success_cb_t) (pa_context *c, int success, void *userdata); 161 | 162 | /** A callback for asynchronous meta/policy event messages. The set 163 | * of defined events can be extended at any time. Also, server modules 164 | * may introduce additional message types so make sure that your 165 | * callback function ignores messages it doesn't know. \since 166 | * 0.9.15 */ 167 | typedef void (*pa_context_event_cb_t)(pa_context *c, const char *name, pa_proplist *p, void *userdata); 168 | 169 | /** Instantiate a new connection context with an abstract mainloop API 170 | * and an application name. It is recommended to use pa_context_new_with_proplist() 171 | * instead and specify some initial properties.*/ 172 | pa_context *pa_context_new(pa_mainloop_api *mainloop, const char *name); 173 | 174 | /** Instantiate a new connection context with an abstract mainloop API 175 | * and an application name, and specify the initial client property 176 | * list. \since 0.9.11 */ 177 | pa_context *pa_context_new_with_proplist(pa_mainloop_api *mainloop, const char *name, pa_proplist *proplist); 178 | 179 | /** Decrease the reference counter of the context by one */ 180 | void pa_context_unref(pa_context *c); 181 | 182 | /** Increase the reference counter of the context by one */ 183 | pa_context* pa_context_ref(pa_context *c); 184 | 185 | /** Set a callback function that is called whenever the context status changes */ 186 | void pa_context_set_state_callback(pa_context *c, pa_context_notify_cb_t cb, void *userdata); 187 | 188 | /** Set a callback function that is called whenever a meta/policy 189 | * control event is received. \since 0.9.15 */ 190 | void pa_context_set_event_callback(pa_context *p, pa_context_event_cb_t cb, void *userdata); 191 | 192 | /** Return the error number of the last failed operation */ 193 | int pa_context_errno(pa_context *c); 194 | 195 | /** Return non-zero if some data is pending to be written to the connection */ 196 | int pa_context_is_pending(pa_context *c); 197 | 198 | /** Return the current context status */ 199 | pa_context_state_t pa_context_get_state(pa_context *c); 200 | 201 | /** Connect the context to the specified server. If server is NULL, 202 | connect to the default server. This routine may but will not always 203 | return synchronously on error. Use pa_context_set_state_callback() to 204 | be notified when the connection is established. If flags doesn't have 205 | PA_CONTEXT_NOAUTOSPAWN set and no specific server is specified or 206 | accessible a new daemon is spawned. If api is non-NULL, the functions 207 | specified in the structure are used when forking a new child 208 | process. */ 209 | int pa_context_connect(pa_context *c, const char *server, pa_context_flags_t flags, const pa_spawn_api *api); 210 | 211 | /** Terminate the context connection immediately */ 212 | void pa_context_disconnect(pa_context *c); 213 | 214 | /** Drain the context. If there is nothing to drain, the function returns NULL */ 215 | pa_operation* pa_context_drain(pa_context *c, pa_context_notify_cb_t cb, void *userdata); 216 | 217 | /** Tell the daemon to exit. The returned operation is unlikely to 218 | * complete successfully, since the daemon probably died before 219 | * returning a success notification */ 220 | pa_operation* pa_context_exit_daemon(pa_context *c, pa_context_success_cb_t cb, void *userdata); 221 | 222 | /** Set the name of the default sink. */ 223 | pa_operation* pa_context_set_default_sink(pa_context *c, const char *name, pa_context_success_cb_t cb, void *userdata); 224 | 225 | /** Set the name of the default source. */ 226 | pa_operation* pa_context_set_default_source(pa_context *c, const char *name, pa_context_success_cb_t cb, void *userdata); 227 | 228 | /** Returns 1 when the connection is to a local daemon. Returns negative when no connection has been made yet. */ 229 | int pa_context_is_local(pa_context *c); 230 | 231 | /** Set a different application name for context on the server. */ 232 | pa_operation* pa_context_set_name(pa_context *c, const char *name, pa_context_success_cb_t cb, void *userdata); 233 | 234 | /** Return the server name this context is connected to. */ 235 | const char* pa_context_get_server(pa_context *c); 236 | 237 | /** Return the protocol version of the library. */ 238 | uint32_t pa_context_get_protocol_version(pa_context *c); 239 | 240 | /** Return the protocol version of the connected server. */ 241 | uint32_t pa_context_get_server_protocol_version(pa_context *c); 242 | 243 | /** Update the property list of the client, adding new entries. Please 244 | * note that it is highly recommended to set as much properties 245 | * initially via pa_context_new_with_proplist() as possible instead a 246 | * posteriori with this function, since that information may then be 247 | * used to route streams of the client to the right device. \since 0.9.11 */ 248 | pa_operation *pa_context_proplist_update(pa_context *c, pa_update_mode_t mode, pa_proplist *p, pa_context_success_cb_t cb, void *userdata); 249 | 250 | /** Update the property list of the client, remove entries. \since 0.9.11 */ 251 | pa_operation *pa_context_proplist_remove(pa_context *c, const char *const keys[], pa_context_success_cb_t cb, void *userdata); 252 | 253 | /** Return the client index this context is 254 | * identified in the server with. This is useful for usage with the 255 | * introspection functions, such as pa_context_get_client_info(). \since 0.9.11 */ 256 | uint32_t pa_context_get_index(pa_context *s); 257 | 258 | /** Create a new timer event source for the specified time (wrapper 259 | * for mainloop->time_new). \since 0.9.16 */ 260 | pa_time_event* pa_context_rttime_new(pa_context *c, pa_usec_t usec, pa_time_event_cb_t cb, void *userdata); 261 | 262 | /** Restart a running or expired timer event source (wrapper for 263 | * mainloop->time_restart). \since 0.9.16 */ 264 | void pa_context_rttime_restart(pa_context *c, pa_time_event *e, pa_usec_t usec); 265 | 266 | /** Return the optimal block size for passing around audio buffers. It 267 | * is recommended to allocate buffers of the size returned here when 268 | * writing audio data to playback streams, if the latency constraints 269 | * permit this. It is not recommended writing larger blocks than this 270 | * because usually they will then be split up internally into chunks 271 | * of this size. It is not recommended writing smaller blocks than 272 | * this (unless required due to latency demands) because this 273 | * increases CPU usage. If ss is NULL you will be returned the 274 | * byte-exact tile size. If you pass a valid ss, then the tile size 275 | * will be rounded down to multiple of the frame size. This is 276 | * supposed to be used in a construct such as 277 | * pa_context_get_tile_size(pa_stream_get_context(s), 278 | * pa_stream_get_sample_spec(ss)); \since 0.9.20 */ 279 | size_t pa_context_get_tile_size(pa_context *c, const pa_sample_spec *ss); 280 | 281 | /** Load the authentication cookie from a file. This function is primarily 282 | * meant for PulseAudio's own tunnel modules, which need to load the cookie 283 | * from a custom location. Applications don't usually need to care about the 284 | * cookie at all, but if it happens that you know what the authentication 285 | * cookie is and your application needs to load it from a non-standard 286 | * location, feel free to use this function. \since 5.0 */ 287 | int pa_context_load_cookie_from_file(pa_context *c, const char *cookie_file_path); 288 | 289 | PA_C_DECL_END 290 | 291 | #endif 292 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/pulse/ext-device-manager.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulseextdevicemanagerhfoo 2 | #define foopulseextdevicemanagerhfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2008 Lennart Poettering 8 | Copyright 2009 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 | #include 26 | #include 27 | 28 | /** \file 29 | * 30 | * Routines for controlling module-device-manager 31 | */ 32 | 33 | PA_C_DECL_BEGIN 34 | 35 | /* Don't extend this struct! It will break binary compatibility, because 36 | * pa_ext_device_manager_info.role_priorities points to an array of structs 37 | * instead of an array of pointers to structs. */ 38 | typedef struct pa_ext_device_manager_role_priority_info { 39 | const char *role; 40 | uint32_t priority; 41 | } pa_ext_device_manager_role_priority_info; 42 | 43 | /** Stores information about one device in the device database that is 44 | * maintained by module-device-manager. \since 0.9.21 */ 45 | typedef struct pa_ext_device_manager_info { 46 | const char *name; /**< Identifier string of the device. A string like "sink:" or similar followed by the name of the device. */ 47 | const char *description; /**< The description of the device when it was last seen, if applicable and saved */ 48 | const char *icon; /**< The icon given to the device */ 49 | uint32_t index; /**< The device index if it is currently available or PA_INVALID_INDEX */ 50 | uint32_t n_role_priorities; /**< How many role priorities do we have? */ 51 | pa_ext_device_manager_role_priority_info *role_priorities; /**< An array of role priority structures or NULL */ 52 | } pa_ext_device_manager_info; 53 | 54 | /** Callback prototype for pa_ext_device_manager_test(). \since 0.9.21 */ 55 | typedef void (*pa_ext_device_manager_test_cb_t)( 56 | pa_context *c, 57 | uint32_t version, 58 | void *userdata); 59 | 60 | /** Test if this extension module is available in the server. \since 0.9.21 */ 61 | pa_operation *pa_ext_device_manager_test( 62 | pa_context *c, 63 | pa_ext_device_manager_test_cb_t cb, 64 | void *userdata); 65 | 66 | /** Callback prototype for pa_ext_device_manager_read(). \since 0.9.21 */ 67 | typedef void (*pa_ext_device_manager_read_cb_t)( 68 | pa_context *c, 69 | const pa_ext_device_manager_info *info, 70 | int eol, 71 | void *userdata); 72 | 73 | /** Read all entries from the device database. \since 0.9.21 */ 74 | pa_operation *pa_ext_device_manager_read( 75 | pa_context *c, 76 | pa_ext_device_manager_read_cb_t cb, 77 | void *userdata); 78 | 79 | /** Sets the description for a device. \since 0.9.21 */ 80 | pa_operation *pa_ext_device_manager_set_device_description( 81 | pa_context *c, 82 | const char* device, 83 | const char* description, 84 | pa_context_success_cb_t cb, 85 | void *userdata); 86 | 87 | /** Delete entries from the device database. \since 0.9.21 */ 88 | pa_operation *pa_ext_device_manager_delete( 89 | pa_context *c, 90 | const char *const s[], 91 | pa_context_success_cb_t cb, 92 | void *userdata); 93 | 94 | /** Enable the role-based device-priority routing mode. \since 0.9.21 */ 95 | pa_operation *pa_ext_device_manager_enable_role_device_priority_routing( 96 | pa_context *c, 97 | int enable, 98 | pa_context_success_cb_t cb, 99 | void *userdata); 100 | 101 | /** Prefer a given device in the priority list. \since 0.9.21 */ 102 | pa_operation *pa_ext_device_manager_reorder_devices_for_role( 103 | pa_context *c, 104 | const char* role, 105 | const char** devices, 106 | pa_context_success_cb_t cb, 107 | void *userdata); 108 | 109 | /** Subscribe to changes in the device database. \since 0.9.21 */ 110 | pa_operation *pa_ext_device_manager_subscribe( 111 | pa_context *c, 112 | int enable, 113 | pa_context_success_cb_t cb, 114 | void *userdata); 115 | 116 | /** Callback prototype for pa_ext_device_manager_set_subscribe_cb(). \since 0.9.21 */ 117 | typedef void (*pa_ext_device_manager_subscribe_cb_t)( 118 | pa_context *c, 119 | void *userdata); 120 | 121 | /** Set the subscription callback that is called when 122 | * pa_ext_device_manager_subscribe() was called. \since 0.9.21 */ 123 | void pa_ext_device_manager_set_subscribe_cb( 124 | pa_context *c, 125 | pa_ext_device_manager_subscribe_cb_t cb, 126 | void *userdata); 127 | 128 | PA_C_DECL_END 129 | 130 | #endif 131 | -------------------------------------------------------------------------------- /vendor/pulse/ext-device-restore.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulseextdevicerestorehfoo 2 | #define foopulseextdevicerestorehfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2008 Lennart Poettering 8 | Copyright 2011 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 | #include 26 | #include 27 | 28 | /** \file 29 | * 30 | * Routines for controlling module-device-restore 31 | */ 32 | 33 | PA_C_DECL_BEGIN 34 | 35 | /** Stores information about one device in the device database that is 36 | * maintained by module-device-manager. \since 1.0 */ 37 | typedef struct pa_ext_device_restore_info { 38 | pa_device_type_t type; /**< Device type sink or source? */ 39 | uint32_t index; /**< The device index */ 40 | uint8_t n_formats; /**< How many formats do we have? */ 41 | pa_format_info **formats; /**< An array of formats (may be NULL if n_formats == 0) */ 42 | } pa_ext_device_restore_info; 43 | 44 | /** Callback prototype for pa_ext_device_restore_test(). \since 1.0 */ 45 | typedef void (*pa_ext_device_restore_test_cb_t)( 46 | pa_context *c, 47 | uint32_t version, 48 | void *userdata); 49 | 50 | /** Test if this extension module is available in the server. \since 1.0 */ 51 | pa_operation *pa_ext_device_restore_test( 52 | pa_context *c, 53 | pa_ext_device_restore_test_cb_t cb, 54 | void *userdata); 55 | 56 | /** Subscribe to changes in the device database. \since 1.0 */ 57 | pa_operation *pa_ext_device_restore_subscribe( 58 | pa_context *c, 59 | int enable, 60 | pa_context_success_cb_t cb, 61 | void *userdata); 62 | 63 | /** Callback prototype for pa_ext_device_restore_set_subscribe_cb(). \since 1.0 */ 64 | typedef void (*pa_ext_device_restore_subscribe_cb_t)( 65 | pa_context *c, 66 | pa_device_type_t type, 67 | uint32_t idx, 68 | void *userdata); 69 | 70 | /** Set the subscription callback that is called when 71 | * pa_ext_device_restore_subscribe() was called. \since 1.0 */ 72 | void pa_ext_device_restore_set_subscribe_cb( 73 | pa_context *c, 74 | pa_ext_device_restore_subscribe_cb_t cb, 75 | void *userdata); 76 | 77 | /** Callback prototype for pa_ext_device_restore_read_formats(). \since 1.0 */ 78 | typedef void (*pa_ext_device_restore_read_device_formats_cb_t)( 79 | pa_context *c, 80 | const pa_ext_device_restore_info *info, 81 | int eol, 82 | void *userdata); 83 | 84 | /** Read the formats for all present devices from the device database. \since 1.0 */ 85 | pa_operation *pa_ext_device_restore_read_formats_all( 86 | pa_context *c, 87 | pa_ext_device_restore_read_device_formats_cb_t cb, 88 | void *userdata); 89 | 90 | /** Read an entry from the device database. \since 1.0 */ 91 | pa_operation *pa_ext_device_restore_read_formats( 92 | pa_context *c, 93 | pa_device_type_t type, 94 | uint32_t idx, 95 | pa_ext_device_restore_read_device_formats_cb_t cb, 96 | void *userdata); 97 | 98 | /** Read an entry from the device database. \since 1.0 */ 99 | pa_operation *pa_ext_device_restore_save_formats( 100 | pa_context *c, 101 | pa_device_type_t type, 102 | uint32_t idx, 103 | uint8_t n_formats, 104 | pa_format_info **formats, 105 | pa_context_success_cb_t cb, 106 | void *userdata); 107 | 108 | PA_C_DECL_END 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /vendor/pulse/ext-stream-restore.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulseextstreamrestorehfoo 2 | #define foopulseextstreamrestorehfoo 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 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | /** \file 30 | * 31 | * Routines for controlling module-stream-restore 32 | */ 33 | 34 | PA_C_DECL_BEGIN 35 | 36 | /** Stores information about one entry in the stream database that is 37 | * maintained by module-stream-restore. \since 0.9.12 */ 38 | typedef struct pa_ext_stream_restore_info { 39 | const char *name; /**< Identifier string of the stream. A string like "sink-input-by-role:" or similar followed by some arbitrary property value. */ 40 | pa_channel_map channel_map; /**< The channel map for the volume field, if applicable */ 41 | pa_cvolume volume; /**< The volume of the stream when it was seen last, if applicable and saved */ 42 | const char *device; /**< The sink/source of the stream when it was last seen, if applicable and saved */ 43 | int mute; /**< The boolean mute state of the stream when it was last seen, if applicable and saved */ 44 | } pa_ext_stream_restore_info; 45 | 46 | /** Callback prototype for pa_ext_stream_restore_test(). \since 0.9.12 */ 47 | typedef void (*pa_ext_stream_restore_test_cb_t)( 48 | pa_context *c, 49 | uint32_t version, 50 | void *userdata); 51 | 52 | /** Test if this extension module is available in the server. \since 0.9.12 */ 53 | pa_operation *pa_ext_stream_restore_test( 54 | pa_context *c, 55 | pa_ext_stream_restore_test_cb_t cb, 56 | void *userdata); 57 | 58 | /** Callback prototype for pa_ext_stream_restore_read(). \since 0.9.12 */ 59 | typedef void (*pa_ext_stream_restore_read_cb_t)( 60 | pa_context *c, 61 | const pa_ext_stream_restore_info *info, 62 | int eol, 63 | void *userdata); 64 | 65 | /** Read all entries from the stream database. \since 0.9.12 */ 66 | pa_operation *pa_ext_stream_restore_read( 67 | pa_context *c, 68 | pa_ext_stream_restore_read_cb_t cb, 69 | void *userdata); 70 | 71 | /** Store entries in the stream database. \since 0.9.12 */ 72 | pa_operation *pa_ext_stream_restore_write( 73 | pa_context *c, 74 | pa_update_mode_t mode, 75 | const pa_ext_stream_restore_info data[], 76 | unsigned n, 77 | int apply_immediately, 78 | pa_context_success_cb_t cb, 79 | void *userdata); 80 | 81 | /** Delete entries from the stream database. \since 0.9.12 */ 82 | pa_operation *pa_ext_stream_restore_delete( 83 | pa_context *c, 84 | const char *const s[], 85 | pa_context_success_cb_t cb, 86 | void *userdata); 87 | 88 | /** Subscribe to changes in the stream database. \since 0.9.12 */ 89 | pa_operation *pa_ext_stream_restore_subscribe( 90 | pa_context *c, 91 | int enable, 92 | pa_context_success_cb_t cb, 93 | void *userdata); 94 | 95 | /** Callback prototype for pa_ext_stream_restore_set_subscribe_cb(). \since 0.9.12 */ 96 | typedef void (*pa_ext_stream_restore_subscribe_cb_t)( 97 | pa_context *c, 98 | void *userdata); 99 | 100 | /** Set the subscription callback that is called when 101 | * pa_ext_stream_restore_subscribe() was called. \since 0.9.12 */ 102 | void pa_ext_stream_restore_set_subscribe_cb( 103 | pa_context *c, 104 | pa_ext_stream_restore_subscribe_cb_t cb, 105 | void *userdata); 106 | 107 | PA_C_DECL_END 108 | 109 | #endif 110 | -------------------------------------------------------------------------------- /vendor/pulse/format.h: -------------------------------------------------------------------------------- 1 | #ifndef fooformathfoo 2 | #define fooformathfoo 3 | 4 | /*** 5 | This file is part of PulseAudio. 6 | 7 | Copyright 2011 Intel Corporation 8 | Copyright 2011 Collabora Multimedia 9 | Copyright 2011 Arun Raghavan 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 | #include 29 | #include 30 | 31 | /** \file 32 | * Utility functions for handling a stream or sink format. */ 33 | 34 | PA_C_DECL_BEGIN 35 | 36 | /** Represents the type of encoding used in a stream or accepted by a sink. \since 1.0 */ 37 | typedef enum pa_encoding { 38 | PA_ENCODING_ANY, 39 | /**< Any encoding format, PCM or compressed */ 40 | 41 | PA_ENCODING_PCM, 42 | /**< Any PCM format */ 43 | 44 | PA_ENCODING_AC3_IEC61937, 45 | /**< AC3 data encapsulated in IEC 61937 header/padding */ 46 | 47 | PA_ENCODING_EAC3_IEC61937, 48 | /**< EAC3 data encapsulated in IEC 61937 header/padding */ 49 | 50 | PA_ENCODING_MPEG_IEC61937, 51 | /**< MPEG-1 or MPEG-2 (Part 3, not AAC) data encapsulated in IEC 61937 header/padding */ 52 | 53 | PA_ENCODING_DTS_IEC61937, 54 | /**< DTS data encapsulated in IEC 61937 header/padding */ 55 | 56 | PA_ENCODING_MPEG2_AAC_IEC61937, 57 | /**< MPEG-2 AAC data encapsulated in IEC 61937 header/padding. \since 4.0 */ 58 | 59 | PA_ENCODING_MAX, 60 | /**< Valid encoding types must be less than this value */ 61 | 62 | PA_ENCODING_INVALID = -1, 63 | /**< Represents an invalid encoding */ 64 | } pa_encoding_t; 65 | 66 | /** \cond fulldocs */ 67 | #define PA_ENCODING_ANY PA_ENCODING_ANY 68 | #define PA_ENCODING_PCM PA_ENCODING_PCM 69 | #define PA_ENCODING_AC3_IEC61937 PA_ENCODING_AC3_IEC61937 70 | #define PA_ENCODING_EAC3_IEC61937 PA_ENCODING_EAC3_IEC61937 71 | #define PA_ENCODING_MPEG_IEC61937 PA_ENCODING_MPEG_IEC61937 72 | #define PA_ENCODING_DTS_IEC61937 PA_ENCODING_DTS_IEC61937 73 | #define PA_ENCODING_MPEG2_AAC_IEC61937 PA_ENCODING_MPEG2_AAC_IEC61937 74 | #define PA_ENCODING_MAX PA_ENCODING_MAX 75 | #define PA_ENCODING_INVALID PA_ENCODING_INVALID 76 | /** \endcond */ 77 | 78 | /** Returns a printable string representing the given encoding type. \since 1.0 */ 79 | const char *pa_encoding_to_string(pa_encoding_t e) PA_GCC_CONST; 80 | 81 | /** Converts a string of the form returned by \a pa_encoding_to_string() back to a \a pa_encoding_t. \since 1.0 */ 82 | pa_encoding_t pa_encoding_from_string(const char *encoding); 83 | 84 | /** Represents the format of data provided in a stream or processed by a sink. \since 1.0 */ 85 | typedef struct pa_format_info { 86 | pa_encoding_t encoding; 87 | /**< The encoding used for the format */ 88 | 89 | pa_proplist *plist; 90 | /**< Additional encoding-specific properties such as sample rate, bitrate, etc. */ 91 | } pa_format_info; 92 | 93 | /** Allocates a new \a pa_format_info structure. Clients must initialise at least the encoding field themselves. \since 1.0 */ 94 | pa_format_info* pa_format_info_new(void); 95 | 96 | /** Returns a new \a pa_format_info struct and representing the same format as \a src. \since 1.0 */ 97 | pa_format_info* pa_format_info_copy(const pa_format_info *src); 98 | 99 | /** Frees a \a pa_format_info structure. \since 1.0 */ 100 | void pa_format_info_free(pa_format_info *f); 101 | 102 | /** Returns non-zero when the format info structure is valid. \since 1.0 */ 103 | int pa_format_info_valid(const pa_format_info *f); 104 | 105 | /** Returns non-zero when the format info structure represents a PCM (i.e.\ uncompressed data) format. \since 1.0 */ 106 | int pa_format_info_is_pcm(const pa_format_info *f); 107 | 108 | /** Returns non-zero if the format represented by \a first is a subset of 109 | * the format represented by \a second. This means that \a second must 110 | * have all the fields that \a first does, but the reverse need not 111 | * be true. This is typically expected to be used to check if a 112 | * stream's format is compatible with a given sink. In such a case, 113 | * \a first would be the sink's format and \a second would be the 114 | * stream's. \since 1.0 */ 115 | int pa_format_info_is_compatible(const pa_format_info *first, const pa_format_info *second); 116 | 117 | /** Maximum required string length for 118 | * pa_format_info_snprint(). Please note that this value can change 119 | * with any release without warning and without being considered API 120 | * or ABI breakage. You should not use this definition anywhere where 121 | * it might become part of an ABI. \since 1.0 */ 122 | #define PA_FORMAT_INFO_SNPRINT_MAX 256 123 | 124 | /** Return a human-readable string representing the given format. \since 1.0 */ 125 | char *pa_format_info_snprint(char *s, size_t l, const pa_format_info *f); 126 | 127 | /** Parse a human-readable string of the form generated by 128 | * \a pa_format_info_snprint() into a pa_format_info structure. \since 1.0 */ 129 | pa_format_info* pa_format_info_from_string(const char *str); 130 | 131 | /** Utility function to take a \a pa_sample_spec and generate the corresponding 132 | * \a pa_format_info. 133 | * 134 | * Note that if you want the server to choose some of the stream parameters, 135 | * for example the sample rate, so that they match the device parameters, then 136 | * you shouldn't use this function. In order to allow the server to choose 137 | * a parameter value, that parameter must be left unspecified in the 138 | * pa_format_info object, and this function always specifies all parameters. An 139 | * exception is the channel map: if you pass NULL for the channel map, then the 140 | * channel map will be left unspecified, allowing the server to choose it. 141 | * 142 | * \since 2.0 */ 143 | pa_format_info* pa_format_info_from_sample_spec(const pa_sample_spec *ss, const pa_channel_map *map); 144 | 145 | /** Utility function to generate a \a pa_sample_spec and \a pa_channel_map corresponding to a given \a pa_format_info. The 146 | * conversion for PCM formats is straight-forward. For non-PCM formats, if there is a fixed size-time conversion (i.e. all 147 | * IEC61937-encapsulated formats), a "fake" sample spec whose size-time conversion corresponds to this format is provided and 148 | * the channel map argument is ignored. For formats with variable size-time conversion, this function will fail. Returns a 149 | * negative integer if conversion failed and 0 on success. \since 2.0 */ 150 | int pa_format_info_to_sample_spec(const pa_format_info *f, pa_sample_spec *ss, pa_channel_map *map); 151 | 152 | /** Represents the type of value type of a property on a \ref pa_format_info. \since 2.0 */ 153 | typedef enum pa_prop_type_t { 154 | PA_PROP_TYPE_INT, 155 | /**< Integer property */ 156 | 157 | PA_PROP_TYPE_INT_RANGE, 158 | /**< Integer range property */ 159 | 160 | PA_PROP_TYPE_INT_ARRAY, 161 | /**< Integer array property */ 162 | 163 | PA_PROP_TYPE_STRING, 164 | /**< String property */ 165 | 166 | PA_PROP_TYPE_STRING_ARRAY, 167 | /**< String array property */ 168 | 169 | PA_PROP_TYPE_INVALID = -1, 170 | /**< Represents an invalid type */ 171 | } pa_prop_type_t; 172 | 173 | /** \cond fulldocs */ 174 | #define PA_PROP_TYPE_INT PA_PROP_TYPE_INT 175 | #define PA_PROP_TYPE_INT_RANGE PA_PROP_TYPE_INT_RANGE 176 | #define PA_PROP_TYPE_INT_ARRAY PA_PROP_TYPE_INT_ARRAY 177 | #define PA_PROP_TYPE_STRING PA_PROP_TYPE_STRING 178 | #define PA_PROP_TYPE_STRING_ARRAY PA_PROP_TYPE_STRING_ARRAY 179 | #define PA_PROP_TYPE_INVALID PA_PROP_TYPE_INVALID 180 | /** \endcond */ 181 | 182 | /** Gets the type of property \a key in a given \ref pa_format_info. \since 2.0 */ 183 | pa_prop_type_t pa_format_info_get_prop_type(const pa_format_info *f, const char *key); 184 | 185 | /** Gets an integer property from the given format info. Returns 0 on success and a negative integer on failure. \since 2.0 */ 186 | int pa_format_info_get_prop_int(const pa_format_info *f, const char *key, int *v); 187 | /** Gets an integer range property from the given format info. Returns 0 on success and a negative integer on failure. 188 | * \since 2.0 */ 189 | int pa_format_info_get_prop_int_range(const pa_format_info *f, const char *key, int *min, int *max); 190 | /** Gets an integer array property from the given format info. \a values contains the values and \a n_values contains the 191 | * number of elements. The caller must free \a values using \ref pa_xfree. Returns 0 on success and a negative integer on 192 | * failure. \since 2.0 */ 193 | int pa_format_info_get_prop_int_array(const pa_format_info *f, const char *key, int **values, int *n_values); 194 | /** Gets a string property from the given format info. The caller must free the returned string using \ref pa_xfree. Returns 195 | * 0 on success and a negative integer on failure. \since 2.0 */ 196 | int pa_format_info_get_prop_string(const pa_format_info *f, const char *key, char **v); 197 | /** Gets a string array property from the given format info. \a values contains the values and \a n_values contains 198 | * the number of elements. The caller must free \a values using \ref pa_format_info_free_string_array. Returns 0 on success and 199 | * a negative integer on failure. \since 2.0 */ 200 | int pa_format_info_get_prop_string_array(const pa_format_info *f, const char *key, char ***values, int *n_values); 201 | 202 | /** Frees a string array returned by \ref pa_format_info_get_prop_string_array. \since 2.0 */ 203 | void pa_format_info_free_string_array(char **values, int n_values); 204 | 205 | /** Sets an integer property on the given format info. \since 1.0 */ 206 | void pa_format_info_set_prop_int(pa_format_info *f, const char *key, int value); 207 | /** Sets a property with a list of integer values on the given format info. \since 1.0 */ 208 | void pa_format_info_set_prop_int_array(pa_format_info *f, const char *key, const int *values, int n_values); 209 | /** Sets a property which can have any value in a given integer range on the given format info. \since 1.0 */ 210 | void pa_format_info_set_prop_int_range(pa_format_info *f, const char *key, int min, int max); 211 | /** Sets a string property on the given format info. \since 1.0 */ 212 | void pa_format_info_set_prop_string(pa_format_info *f, const char *key, const char *value); 213 | /** Sets a property with a list of string values on the given format info. \since 1.0 */ 214 | void pa_format_info_set_prop_string_array(pa_format_info *f, const char *key, const char **values, int n_values); 215 | 216 | /** Convenience method to set the sample format as a property on the given 217 | * format. 218 | * 219 | * Note for PCM: If the sample format is left unspecified in the pa_format_info 220 | * object, then the server will select the stream sample format. In that case 221 | * the stream sample format will most likely match the device sample format, 222 | * meaning that sample format conversion will be avoided. 223 | * 224 | * \since 1.0 */ 225 | void pa_format_info_set_sample_format(pa_format_info *f, pa_sample_format_t sf); 226 | 227 | /** Convenience method to set the sampling rate as a property on the given 228 | * format. 229 | * 230 | * Note for PCM: If the sample rate is left unspecified in the pa_format_info 231 | * object, then the server will select the stream sample rate. In that case the 232 | * stream sample rate will most likely match the device sample rate, meaning 233 | * that sample rate conversion will be avoided. 234 | * 235 | * \since 1.0 */ 236 | void pa_format_info_set_rate(pa_format_info *f, int rate); 237 | 238 | /** Convenience method to set the number of channels as a property on the given 239 | * format. 240 | * 241 | * Note for PCM: If the channel count is left unspecified in the pa_format_info 242 | * object, then the server will select the stream channel count. In that case 243 | * the stream channel count will most likely match the device channel count, 244 | * meaning that up/downmixing will be avoided. 245 | * 246 | * \since 1.0 */ 247 | void pa_format_info_set_channels(pa_format_info *f, int channels); 248 | 249 | /** Convenience method to set the channel map as a property on the given 250 | * format. 251 | * 252 | * Note for PCM: If the channel map is left unspecified in the pa_format_info 253 | * object, then the server will select the stream channel map. In that case the 254 | * stream channel map will most likely match the device channel map, meaning 255 | * that remixing will be avoided. 256 | * 257 | * \since 1.0 */ 258 | void pa_format_info_set_channel_map(pa_format_info *f, const pa_channel_map *map); 259 | 260 | PA_C_DECL_END 261 | 262 | #endif 263 | -------------------------------------------------------------------------------- /vendor/pulse/gccmacro.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulsegccmacrohfoo 2 | #define foopulsegccmacrohfoo 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 | * GCC attribute macros */ 25 | 26 | #if defined(__GNUC__) 27 | #ifdef __MINGW32__ 28 | /* libintl overrides printf with a #define. As this breaks this attribute, 29 | * it has a workaround. However the workaround isn't enabled for MINGW 30 | * builds (only cygwin) */ 31 | #define PA_GCC_PRINTF_ATTR(a,b) __attribute__ ((format (__printf__, a, b))) 32 | #else 33 | #define PA_GCC_PRINTF_ATTR(a,b) __attribute__ ((format (printf, a, b))) 34 | #endif 35 | #else 36 | /** If we're in GNU C, use some magic for detecting invalid format strings */ 37 | #define PA_GCC_PRINTF_ATTR(a,b) 38 | #endif 39 | 40 | #if defined(__GNUC__) && (__GNUC__ >= 4) 41 | #define PA_GCC_SENTINEL __attribute__ ((sentinel)) 42 | #else 43 | /** Macro for usage of GCC's sentinel compilation warnings */ 44 | #define PA_GCC_SENTINEL 45 | #endif 46 | 47 | #ifdef __GNUC__ 48 | #define PA_GCC_NORETURN __attribute__((noreturn)) 49 | #else 50 | /** Macro for no-return functions */ 51 | #define PA_GCC_NORETURN 52 | #endif 53 | 54 | #ifdef __GNUC__ 55 | #define PA_GCC_UNUSED __attribute__ ((unused)) 56 | #else 57 | /** Macro for not used function, variable or parameter */ 58 | #define PA_GCC_UNUSED 59 | #endif 60 | 61 | #ifdef __GNUC__ 62 | #define PA_GCC_DESTRUCTOR __attribute__ ((destructor)) 63 | #else 64 | /** Call this function when process terminates */ 65 | #define PA_GCC_DESTRUCTOR 66 | #endif 67 | 68 | #ifndef PA_GCC_PURE 69 | #ifdef __GNUC__ 70 | #define PA_GCC_PURE __attribute__ ((pure)) 71 | #else 72 | /** This function's return value depends only the arguments list and global state **/ 73 | #define PA_GCC_PURE 74 | #endif 75 | #endif 76 | 77 | #ifndef PA_GCC_CONST 78 | #ifdef __GNUC__ 79 | #define PA_GCC_CONST __attribute__ ((const)) 80 | #else 81 | /** This function's return value depends only the arguments list (stricter version of PA_GCC_PURE) **/ 82 | #define PA_GCC_CONST 83 | #endif 84 | #endif 85 | 86 | #ifndef PA_GCC_DEPRECATED 87 | #ifdef __GNUC__ 88 | #define PA_GCC_DEPRECATED __attribute__ ((deprecated)) 89 | #else 90 | /** This function is deprecated **/ 91 | #define PA_GCC_DEPRECATED 92 | #endif 93 | #endif 94 | 95 | #ifndef PA_GCC_PACKED 96 | #ifdef __GNUC__ 97 | #define PA_GCC_PACKED __attribute__ ((packed)) 98 | #else 99 | /** Structure shall be packed in memory **/ 100 | #define PA_GCC_PACKED 101 | #endif 102 | #endif 103 | 104 | #ifndef PA_GCC_ALLOC_SIZE 105 | #if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3) 106 | #define PA_GCC_ALLOC_SIZE(x) __attribute__ ((__alloc_size__(x))) 107 | #define PA_GCC_ALLOC_SIZE2(x,y) __attribute__ ((__alloc_size__(x,y))) 108 | #else 109 | /** Macro for usage of GCC's alloc_size attribute */ 110 | #define PA_GCC_ALLOC_SIZE(x) 111 | /** Macro for usage of GCC's alloc_size attribute */ 112 | #define PA_GCC_ALLOC_SIZE2(x,y) 113 | #endif 114 | #endif 115 | 116 | #ifndef PA_GCC_MALLOC 117 | #ifdef __GNUC__ 118 | #define PA_GCC_MALLOC __attribute__ ((malloc)) 119 | #else 120 | /** Macro for usage of GCC's malloc attribute */ 121 | #define PA_GCC_MALLOC 122 | #endif 123 | #endif 124 | 125 | #ifndef PA_GCC_WEAKREF 126 | #if defined(__GNUC__) && defined(__ELF__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ > 1)) || (__GNUC__ > 4)) 127 | /** Macro for usage of GCC's weakref attribute */ 128 | #define PA_GCC_WEAKREF(x) __attribute__((weakref(#x))) 129 | #endif 130 | #endif 131 | 132 | #endif 133 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/pulse/mainloop-api.h: -------------------------------------------------------------------------------- 1 | #ifndef foomainloopapihfoo 2 | #define foomainloopapihfoo 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 | * 31 | * Main loop abstraction layer. Both the PulseAudio core and the 32 | * PulseAudio client library use a main loop abstraction layer. Due to 33 | * this it is possible to embed PulseAudio into other 34 | * applications easily. Two main loop implementations are 35 | * currently available: 36 | * \li A minimal implementation based on the C library's poll() function (See \ref mainloop.h) 37 | * \li A wrapper around the GLIB main loop. Use this to embed PulseAudio into your GLIB/GTK+/GNOME programs (See \ref glib-mainloop.h) 38 | * 39 | * The structure pa_mainloop_api is used as vtable for the main loop abstraction. 40 | * 41 | * This mainloop abstraction layer has no direct support for UNIX signals. Generic, mainloop implementation agnostic support is available through \ref mainloop-signal.h. 42 | * */ 43 | 44 | PA_C_DECL_BEGIN 45 | 46 | /** An abstract mainloop API vtable */ 47 | typedef struct pa_mainloop_api pa_mainloop_api; 48 | 49 | /** A bitmask for IO events */ 50 | typedef enum pa_io_event_flags { 51 | PA_IO_EVENT_NULL = 0, /**< No event */ 52 | PA_IO_EVENT_INPUT = 1, /**< Input event */ 53 | PA_IO_EVENT_OUTPUT = 2, /**< Output event */ 54 | PA_IO_EVENT_HANGUP = 4, /**< Hangup event */ 55 | PA_IO_EVENT_ERROR = 8 /**< Error event */ 56 | } pa_io_event_flags_t; 57 | 58 | /** An opaque IO event source object */ 59 | typedef struct pa_io_event pa_io_event; 60 | /** An IO event callback prototype \since 0.9.3 */ 61 | typedef void (*pa_io_event_cb_t)(pa_mainloop_api*ea, pa_io_event* e, int fd, pa_io_event_flags_t events, void *userdata); 62 | /** A IO event destroy callback prototype \since 0.9.3 */ 63 | typedef void (*pa_io_event_destroy_cb_t)(pa_mainloop_api*a, pa_io_event *e, void *userdata); 64 | 65 | /** An opaque timer event source object */ 66 | typedef struct pa_time_event pa_time_event; 67 | /** A time event callback prototype \since 0.9.3 */ 68 | typedef void (*pa_time_event_cb_t)(pa_mainloop_api*a, pa_time_event* e, const struct timeval *tv, void *userdata); 69 | /** A time event destroy callback prototype \since 0.9.3 */ 70 | typedef void (*pa_time_event_destroy_cb_t)(pa_mainloop_api*a, pa_time_event *e, void *userdata); 71 | 72 | /** An opaque deferred event source object. Events of this type are triggered once in every main loop iteration */ 73 | typedef struct pa_defer_event pa_defer_event; 74 | /** A defer event callback prototype \since 0.9.3 */ 75 | typedef void (*pa_defer_event_cb_t)(pa_mainloop_api*a, pa_defer_event* e, void *userdata); 76 | /** A defer event destroy callback prototype \since 0.9.3 */ 77 | typedef void (*pa_defer_event_destroy_cb_t)(pa_mainloop_api*a, pa_defer_event *e, void *userdata); 78 | 79 | /** An abstract mainloop API vtable */ 80 | struct pa_mainloop_api { 81 | /** A pointer to some private, arbitrary data of the main loop implementation */ 82 | void *userdata; 83 | 84 | /** Create a new IO event source object */ 85 | pa_io_event* (*io_new)(pa_mainloop_api*a, int fd, pa_io_event_flags_t events, pa_io_event_cb_t cb, void *userdata); 86 | /** Enable or disable IO events on this object */ 87 | void (*io_enable)(pa_io_event* e, pa_io_event_flags_t events); 88 | /** Free a IO event source object */ 89 | void (*io_free)(pa_io_event* e); 90 | /** Set a function that is called when the IO event source is destroyed. Use this to free the userdata argument if required */ 91 | void (*io_set_destroy)(pa_io_event *e, pa_io_event_destroy_cb_t cb); 92 | 93 | /** Create a new timer event source object for the specified Unix time */ 94 | pa_time_event* (*time_new)(pa_mainloop_api*a, const struct timeval *tv, pa_time_event_cb_t cb, void *userdata); 95 | /** Restart a running or expired timer event source with a new Unix time */ 96 | void (*time_restart)(pa_time_event* e, const struct timeval *tv); 97 | /** Free a deferred timer event source object */ 98 | void (*time_free)(pa_time_event* e); 99 | /** Set a function that is called when the timer event source is destroyed. Use this to free the userdata argument if required */ 100 | void (*time_set_destroy)(pa_time_event *e, pa_time_event_destroy_cb_t cb); 101 | 102 | /** Create a new deferred event source object */ 103 | pa_defer_event* (*defer_new)(pa_mainloop_api*a, pa_defer_event_cb_t cb, void *userdata); 104 | /** Enable or disable a deferred event source temporarily */ 105 | void (*defer_enable)(pa_defer_event* e, int b); 106 | /** Free a deferred event source object */ 107 | void (*defer_free)(pa_defer_event* e); 108 | /** Set a function that is called when the deferred event source is destroyed. Use this to free the userdata argument if required */ 109 | void (*defer_set_destroy)(pa_defer_event *e, pa_defer_event_destroy_cb_t cb); 110 | 111 | /** Exit the main loop and return the specified retval*/ 112 | void (*quit)(pa_mainloop_api*a, int retval); 113 | }; 114 | 115 | /** Run the specified callback function once from the main loop using an 116 | * anonymous defer event. If the mainloop runs in a different thread, you need 117 | * to follow the mainloop implementation's rules regarding how to safely create 118 | * defer events. In particular, if you're using \ref pa_threaded_mainloop, you 119 | * must lock the mainloop before calling this function. */ 120 | void pa_mainloop_api_once(pa_mainloop_api*m, void (*callback)(pa_mainloop_api*m, void *userdata), void *userdata); 121 | 122 | PA_C_DECL_END 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/pulse/mainloop.h: -------------------------------------------------------------------------------- 1 | #ifndef foomainloophfoo 2 | #define foomainloophfoo 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 | PA_C_DECL_BEGIN 28 | 29 | struct pollfd; 30 | 31 | /** \page mainloop Main Loop 32 | * 33 | * \section overv_sec Overview 34 | * 35 | * The built-in main loop implementation is based on the poll() system call. 36 | * It supports the functions defined in the main loop abstraction and very 37 | * little else. 38 | * 39 | * The main loop is created using pa_mainloop_new() and destroyed using 40 | * pa_mainloop_free(). To get access to the main loop abstraction, 41 | * pa_mainloop_get_api() is used. 42 | * 43 | * \section iter_sec Iteration 44 | * 45 | * The main loop is designed around the concept of iterations. Each iteration 46 | * consists of three steps that repeat during the application's entire 47 | * lifetime: 48 | * 49 | * -# Prepare - Build a list of file descriptors 50 | * that need to be monitored and calculate the next timeout. 51 | * -# Poll - Execute the actual poll() system call. 52 | * -# Dispatch - Dispatch any events that have fired. 53 | * 54 | * When using the main loop, the application can either execute each 55 | * iteration, one at a time, using pa_mainloop_iterate(), or let the library 56 | * iterate automatically using pa_mainloop_run(). 57 | * 58 | * \section thread_sec Threads 59 | * 60 | * The main loop functions are designed to be thread safe, but the objects 61 | * are not. What this means is that multiple main loops can be used, but only 62 | * one object per thread. 63 | * 64 | */ 65 | 66 | /** \file 67 | * 68 | * A minimal main loop implementation based on the C library's poll() 69 | * function. Using the routines defined herein you may create a simple 70 | * main loop supporting the generic main loop abstraction layer as 71 | * defined in \ref mainloop-api.h. This implementation is thread safe 72 | * as long as you access the main loop object from a single thread only. 73 | * 74 | * See also \subpage mainloop 75 | */ 76 | 77 | /** An opaque main loop object */ 78 | typedef struct pa_mainloop pa_mainloop; 79 | 80 | /** Allocate a new main loop object */ 81 | pa_mainloop *pa_mainloop_new(void); 82 | 83 | /** Free a main loop object */ 84 | void pa_mainloop_free(pa_mainloop* m); 85 | 86 | /** Prepare for a single iteration of the main loop. Returns a negative value 87 | on error or exit request. timeout specifies a maximum timeout for the subsequent 88 | poll, or -1 for blocking behaviour. .*/ 89 | int pa_mainloop_prepare(pa_mainloop *m, int timeout); 90 | 91 | /** Execute the previously prepared poll. Returns a negative value on error.*/ 92 | int pa_mainloop_poll(pa_mainloop *m); 93 | 94 | /** Dispatch timeout, io and deferred events from the previously executed poll. Returns 95 | a negative value on error. On success returns the number of source dispatched. */ 96 | int pa_mainloop_dispatch(pa_mainloop *m); 97 | 98 | /** Return the return value as specified with the main loop's quit() routine. */ 99 | int pa_mainloop_get_retval(pa_mainloop *m); 100 | 101 | /** Run a single iteration of the main loop. This is a convenience function 102 | for pa_mainloop_prepare(), pa_mainloop_poll() and pa_mainloop_dispatch(). 103 | Returns a negative value on error or exit request. If block is nonzero, 104 | block for events if none are queued. Optionally return the return value as 105 | specified with the main loop's quit() routine in the integer variable retval points 106 | to. On success returns the number of sources dispatched in this iteration. */ 107 | int pa_mainloop_iterate(pa_mainloop *m, int block, int *retval); 108 | 109 | /** Run unlimited iterations of the main loop object until the main loop's quit() routine is called. */ 110 | int pa_mainloop_run(pa_mainloop *m, int *retval); 111 | 112 | /** Return the abstract main loop abstraction layer vtable for this 113 | main loop. No need to free the API as it is owned by the loop 114 | and is destroyed when the loop is freed. */ 115 | pa_mainloop_api* pa_mainloop_get_api(pa_mainloop*m); 116 | 117 | /** Shutdown the main loop */ 118 | void pa_mainloop_quit(pa_mainloop *m, int r); 119 | 120 | /** Interrupt a running poll (for threaded systems) */ 121 | void pa_mainloop_wakeup(pa_mainloop *m); 122 | 123 | /** Generic prototype of a poll() like function */ 124 | typedef int (*pa_poll_func)(struct pollfd *ufds, unsigned long nfds, int timeout, void*userdata); 125 | 126 | /** Change the poll() implementation */ 127 | void pa_mainloop_set_poll_func(pa_mainloop *m, pa_poll_func poll_func, void *userdata); 128 | 129 | PA_C_DECL_END 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /vendor/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(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 | -------------------------------------------------------------------------------- /vendor/pulse/proplist.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulseproplisthfoo 2 | #define foopulseproplisthfoo 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 | 25 | #include 26 | #include 27 | #include 28 | 29 | /** \file 30 | * Property list constants and functions */ 31 | 32 | PA_C_DECL_BEGIN 33 | 34 | /** For streams: localized media name, formatted as UTF-8. E.g. "Guns'N'Roses: Civil War".*/ 35 | #define PA_PROP_MEDIA_NAME "media.name" 36 | 37 | /** For streams: localized media title if applicable, formatted as UTF-8. E.g. "Civil War" */ 38 | #define PA_PROP_MEDIA_TITLE "media.title" 39 | 40 | /** For streams: localized media artist if applicable, formatted as UTF-8. E.g. "Guns'N'Roses" */ 41 | #define PA_PROP_MEDIA_ARTIST "media.artist" 42 | 43 | /** For streams: localized media copyright string if applicable, formatted as UTF-8. E.g. "Evil Record Corp." */ 44 | #define PA_PROP_MEDIA_COPYRIGHT "media.copyright" 45 | 46 | /** For streams: localized media generator software string if applicable, formatted as UTF-8. E.g. "Foocrop AudioFrobnicator" */ 47 | #define PA_PROP_MEDIA_SOFTWARE "media.software" 48 | 49 | /** For streams: media language if applicable, in standard POSIX format. E.g. "de_DE" */ 50 | #define PA_PROP_MEDIA_LANGUAGE "media.language" 51 | 52 | /** For streams: source filename if applicable, in URI format or local path. E.g. "/home/lennart/music/foobar.ogg" */ 53 | #define PA_PROP_MEDIA_FILENAME "media.filename" 54 | 55 | /** \cond fulldocs */ 56 | /** For streams: icon for the media. A binary blob containing PNG image data */ 57 | #define PA_PROP_MEDIA_ICON "media.icon" 58 | /** \endcond */ 59 | 60 | /** For streams: an XDG icon name for the media. E.g. "audio-x-mp3" */ 61 | #define PA_PROP_MEDIA_ICON_NAME "media.icon_name" 62 | 63 | /** For streams: logic role of this media. One of the strings "video", "music", "game", "event", "phone", "animation", "production", "a11y", "test" */ 64 | #define PA_PROP_MEDIA_ROLE "media.role" 65 | 66 | /** For streams: the name of a filter that is desired, e.g.\ "echo-cancel" or "equalizer-sink". PulseAudio may choose to not apply the filter if it does not make sense (for example, applying echo-cancellation on a Bluetooth headset probably does not make sense. \since 1.0 */ 67 | #define PA_PROP_FILTER_WANT "filter.want" 68 | 69 | /** For streams: the name of a filter that is desired, e.g.\ "echo-cancel" or "equalizer-sink". Differs from PA_PROP_FILTER_WANT in that it forces PulseAudio to apply the filter, regardless of whether PulseAudio thinks it makes sense to do so or not. If this is set, PA_PROP_FILTER_WANT is ignored. In other words, you almost certainly do not want to use this. \since 1.0 */ 70 | #define PA_PROP_FILTER_APPLY "filter.apply" 71 | 72 | /** For streams: the name of a filter that should specifically suppressed (i.e.\ overrides PA_PROP_FILTER_WANT). Useful for the times that PA_PROP_FILTER_WANT is automatically added (e.g. echo-cancellation for phone streams when $VOIP_APP does its own, internal AEC) \since 1.0 */ 73 | #define PA_PROP_FILTER_SUPPRESS "filter.suppress" 74 | 75 | /** For event sound streams: XDG event sound name. e.g.\ "message-new-email" (Event sound streams are those with media.role set to "event") */ 76 | #define PA_PROP_EVENT_ID "event.id" 77 | 78 | /** For event sound streams: localized human readable one-line description of the event, formatted as UTF-8. E.g. "Email from lennart@example.com received." */ 79 | #define PA_PROP_EVENT_DESCRIPTION "event.description" 80 | 81 | /** For event sound streams: absolute horizontal mouse position on the screen if the event sound was triggered by a mouse click, integer formatted as text string. E.g. "865" */ 82 | #define PA_PROP_EVENT_MOUSE_X "event.mouse.x" 83 | 84 | /** For event sound streams: absolute vertical mouse position on the screen if the event sound was triggered by a mouse click, integer formatted as text string. E.g. "432" */ 85 | #define PA_PROP_EVENT_MOUSE_Y "event.mouse.y" 86 | 87 | /** For event sound streams: relative horizontal mouse position on the screen if the event sound was triggered by a mouse click, float formatted as text string, ranging from 0.0 (left side of the screen) to 1.0 (right side of the screen). E.g. "0.65" */ 88 | #define PA_PROP_EVENT_MOUSE_HPOS "event.mouse.hpos" 89 | 90 | /** For event sound streams: relative vertical mouse position on the screen if the event sound was triggered by a mouse click, float formatted as text string, ranging from 0.0 (top of the screen) to 1.0 (bottom of the screen). E.g. "0.43" */ 91 | #define PA_PROP_EVENT_MOUSE_VPOS "event.mouse.vpos" 92 | 93 | /** For event sound streams: mouse button that triggered the event if applicable, integer formatted as string with 0=left, 1=middle, 2=right. E.g. "0" */ 94 | #define PA_PROP_EVENT_MOUSE_BUTTON "event.mouse.button" 95 | 96 | /** For streams that belong to a window on the screen: localized window title. E.g. "Totem Music Player" */ 97 | #define PA_PROP_WINDOW_NAME "window.name" 98 | 99 | /** For streams that belong to a window on the screen: a textual id for identifying a window logically. E.g. "org.gnome.Totem.MainWindow" */ 100 | #define PA_PROP_WINDOW_ID "window.id" 101 | 102 | /** \cond fulldocs */ 103 | /** For streams that belong to a window on the screen: window icon. A binary blob containing PNG image data */ 104 | #define PA_PROP_WINDOW_ICON "window.icon" 105 | /** \endcond */ 106 | 107 | /** For streams that belong to a window on the screen: an XDG icon name for the window. E.g. "totem" */ 108 | #define PA_PROP_WINDOW_ICON_NAME "window.icon_name" 109 | 110 | /** For streams that belong to a window on the screen: absolute horizontal window position on the screen, integer formatted as text string. E.g. "865". \since 0.9.17 */ 111 | #define PA_PROP_WINDOW_X "window.x" 112 | 113 | /** For streams that belong to a window on the screen: absolute vertical window position on the screen, integer formatted as text string. E.g. "343". \since 0.9.17 */ 114 | #define PA_PROP_WINDOW_Y "window.y" 115 | 116 | /** For streams that belong to a window on the screen: window width on the screen, integer formatted as text string. e.g. "365". \since 0.9.17 */ 117 | #define PA_PROP_WINDOW_WIDTH "window.width" 118 | 119 | /** For streams that belong to a window on the screen: window height on the screen, integer formatted as text string. E.g. "643". \since 0.9.17 */ 120 | #define PA_PROP_WINDOW_HEIGHT "window.height" 121 | 122 | /** For streams that belong to a window on the screen: relative position of the window center on the screen, float formatted as text string, ranging from 0.0 (left side of the screen) to 1.0 (right side of the screen). E.g. "0.65". \since 0.9.17 */ 123 | #define PA_PROP_WINDOW_HPOS "window.hpos" 124 | 125 | /** For streams that belong to a window on the screen: relative position of the window center on the screen, float formatted as text string, ranging from 0.0 (top of the screen) to 1.0 (bottom of the screen). E.g. "0.43". \since 0.9.17 */ 126 | #define PA_PROP_WINDOW_VPOS "window.vpos" 127 | 128 | /** For streams that belong to a window on the screen: if the windowing system supports multiple desktops, a comma separated list of indexes of the desktops this window is visible on. If this property is an empty string, it is visible on all desktops (i.e. 'sticky'). The first desktop is 0. E.g. "0,2,3" \since 0.9.18 */ 129 | #define PA_PROP_WINDOW_DESKTOP "window.desktop" 130 | 131 | /** For streams that belong to an X11 window on the screen: the X11 display string. E.g. ":0.0" */ 132 | #define PA_PROP_WINDOW_X11_DISPLAY "window.x11.display" 133 | 134 | /** For streams that belong to an X11 window on the screen: the X11 screen the window is on, an integer formatted as string. E.g. "0" */ 135 | #define PA_PROP_WINDOW_X11_SCREEN "window.x11.screen" 136 | 137 | /** For streams that belong to an X11 window on the screen: the X11 monitor the window is on, an integer formatted as string. E.g. "0" */ 138 | #define PA_PROP_WINDOW_X11_MONITOR "window.x11.monitor" 139 | 140 | /** For streams that belong to an X11 window on the screen: the window XID, an integer formatted as string. E.g. "25632" */ 141 | #define PA_PROP_WINDOW_X11_XID "window.x11.xid" 142 | 143 | /** For clients/streams: localized human readable application name. E.g. "Totem Music Player" */ 144 | #define PA_PROP_APPLICATION_NAME "application.name" 145 | 146 | /** For clients/streams: a textual id for identifying an application logically. E.g. "org.gnome.Totem" */ 147 | #define PA_PROP_APPLICATION_ID "application.id" 148 | 149 | /** For clients/streams: a version string, e.g.\ "0.6.88" */ 150 | #define PA_PROP_APPLICATION_VERSION "application.version" 151 | 152 | /** \cond fulldocs */ 153 | /** For clients/streams: application icon. A binary blob containing PNG image data */ 154 | #define PA_PROP_APPLICATION_ICON "application.icon" 155 | /** \endcond */ 156 | 157 | /** For clients/streams: an XDG icon name for the application. E.g. "totem" */ 158 | #define PA_PROP_APPLICATION_ICON_NAME "application.icon_name" 159 | 160 | /** For clients/streams: application language if applicable, in standard POSIX format. E.g. "de_DE" */ 161 | #define PA_PROP_APPLICATION_LANGUAGE "application.language" 162 | 163 | /** For clients/streams on UNIX: application process PID, an integer formatted as string. E.g. "4711" */ 164 | #define PA_PROP_APPLICATION_PROCESS_ID "application.process.id" 165 | 166 | /** For clients/streams: application process name. E.g. "totem" */ 167 | #define PA_PROP_APPLICATION_PROCESS_BINARY "application.process.binary" 168 | 169 | /** For clients/streams: application user name. E.g. "lennart" */ 170 | #define PA_PROP_APPLICATION_PROCESS_USER "application.process.user" 171 | 172 | /** For clients/streams: host name the application runs on. E.g. "omega" */ 173 | #define PA_PROP_APPLICATION_PROCESS_HOST "application.process.host" 174 | 175 | /** For clients/streams: the D-Bus host id the application runs on. E.g. "543679e7b01393ed3e3e650047d78f6e" */ 176 | #define PA_PROP_APPLICATION_PROCESS_MACHINE_ID "application.process.machine_id" 177 | 178 | /** For clients/streams: an id for the login session the application runs in. On Unix the value of $XDG_SESSION_ID. E.g. "5" */ 179 | #define PA_PROP_APPLICATION_PROCESS_SESSION_ID "application.process.session_id" 180 | 181 | /** For devices: device string in the underlying audio layer's format. E.g. "surround51:0" */ 182 | #define PA_PROP_DEVICE_STRING "device.string" 183 | 184 | /** For devices: API this device is access with. E.g. "alsa" */ 185 | #define PA_PROP_DEVICE_API "device.api" 186 | 187 | /** For devices: localized human readable device one-line description. E.g. "Foobar Industries USB Headset 2000+ Ultra" */ 188 | #define PA_PROP_DEVICE_DESCRIPTION "device.description" 189 | 190 | /** For devices: bus path to the device in the OS' format. E.g. "/sys/bus/pci/devices/0000:00:1f.2" */ 191 | #define PA_PROP_DEVICE_BUS_PATH "device.bus_path" 192 | 193 | /** For devices: serial number if applicable. E.g. "4711-0815-1234" */ 194 | #define PA_PROP_DEVICE_SERIAL "device.serial" 195 | 196 | /** For devices: vendor ID if applicable. E.g. 1274 */ 197 | #define PA_PROP_DEVICE_VENDOR_ID "device.vendor.id" 198 | 199 | /** For devices: vendor name if applicable. E.g. "Foocorp Heavy Industries" */ 200 | #define PA_PROP_DEVICE_VENDOR_NAME "device.vendor.name" 201 | 202 | /** For devices: product ID if applicable. E.g. 4565 */ 203 | #define PA_PROP_DEVICE_PRODUCT_ID "device.product.id" 204 | 205 | /** For devices: product name if applicable. E.g. "SuperSpeakers 2000 Pro" */ 206 | #define PA_PROP_DEVICE_PRODUCT_NAME "device.product.name" 207 | 208 | /** For devices: device class. One of "sound", "modem", "monitor", "filter" */ 209 | #define PA_PROP_DEVICE_CLASS "device.class" 210 | 211 | /** For devices: form factor if applicable. One of "internal", "speaker", "handset", "tv", "webcam", "microphone", "headset", "headphone", "hands-free", "car", "hifi", "computer", "portable" */ 212 | #define PA_PROP_DEVICE_FORM_FACTOR "device.form_factor" 213 | 214 | /** For devices: bus of the device if applicable. One of "isa", "pci", "usb", "firewire", "bluetooth" */ 215 | #define PA_PROP_DEVICE_BUS "device.bus" 216 | 217 | /** \cond fulldocs */ 218 | /** For devices: icon for the device. A binary blob containing PNG image data */ 219 | #define PA_PROP_DEVICE_ICON "device.icon" 220 | /** \endcond */ 221 | 222 | /** For devices: an XDG icon name for the device. E.g. "sound-card-speakers-usb" */ 223 | #define PA_PROP_DEVICE_ICON_NAME "device.icon_name" 224 | 225 | /** For devices: access mode of the device if applicable. One of "mmap", "mmap_rewrite", "serial" */ 226 | #define PA_PROP_DEVICE_ACCESS_MODE "device.access_mode" 227 | 228 | /** For filter devices: master device id if applicable. */ 229 | #define PA_PROP_DEVICE_MASTER_DEVICE "device.master_device" 230 | 231 | /** For devices: buffer size in bytes, integer formatted as string. */ 232 | #define PA_PROP_DEVICE_BUFFERING_BUFFER_SIZE "device.buffering.buffer_size" 233 | 234 | /** For devices: fragment size in bytes, integer formatted as string. */ 235 | #define PA_PROP_DEVICE_BUFFERING_FRAGMENT_SIZE "device.buffering.fragment_size" 236 | 237 | /** For devices: profile identifier for the profile this devices is in. E.g. "analog-stereo", "analog-surround-40", "iec958-stereo", ...*/ 238 | #define PA_PROP_DEVICE_PROFILE_NAME "device.profile.name" 239 | 240 | /** For devices: intended use. A space separated list of roles (see PA_PROP_MEDIA_ROLE) this device is particularly well suited for, due to latency, quality or form factor. \since 0.9.16 */ 241 | #define PA_PROP_DEVICE_INTENDED_ROLES "device.intended_roles" 242 | 243 | /** For devices: human readable one-line description of the profile this device is in. E.g. "Analog Stereo", ... */ 244 | #define PA_PROP_DEVICE_PROFILE_DESCRIPTION "device.profile.description" 245 | 246 | /** For modules: the author's name, formatted as UTF-8 string. E.g. "Lennart Poettering" */ 247 | #define PA_PROP_MODULE_AUTHOR "module.author" 248 | 249 | /** For modules: a human readable one-line description of the module's purpose formatted as UTF-8. E.g. "Frobnicate sounds with a flux compensator" */ 250 | #define PA_PROP_MODULE_DESCRIPTION "module.description" 251 | 252 | /** For modules: a human readable usage description of the module's arguments formatted as UTF-8. */ 253 | #define PA_PROP_MODULE_USAGE "module.usage" 254 | 255 | /** For modules: a version string for the module. E.g. "0.9.15" */ 256 | #define PA_PROP_MODULE_VERSION "module.version" 257 | 258 | /** For PCM formats: the sample format used as returned by pa_sample_format_to_string() \since 1.0 */ 259 | #define PA_PROP_FORMAT_SAMPLE_FORMAT "format.sample_format" 260 | 261 | /** For all formats: the sample rate (unsigned integer) \since 1.0 */ 262 | #define PA_PROP_FORMAT_RATE "format.rate" 263 | 264 | /** For all formats: the number of channels (unsigned integer) \since 1.0 */ 265 | #define PA_PROP_FORMAT_CHANNELS "format.channels" 266 | 267 | /** For PCM formats: the channel map of the stream as returned by pa_channel_map_snprint() \since 1.0 */ 268 | #define PA_PROP_FORMAT_CHANNEL_MAP "format.channel_map" 269 | 270 | /** A property list object. Basically a dictionary with ASCII strings 271 | * as keys and arbitrary data as values. \since 0.9.11 */ 272 | typedef struct pa_proplist pa_proplist; 273 | 274 | /** Allocate a property list. \since 0.9.11 */ 275 | pa_proplist* pa_proplist_new(void); 276 | 277 | /** Free the property list. \since 0.9.11 */ 278 | void pa_proplist_free(pa_proplist* p); 279 | 280 | /** Returns a non-zero value if the key is valid. \since 3.0 */ 281 | int pa_proplist_key_valid(const char *key); 282 | 283 | /** Append a new string entry to the property list, possibly 284 | * overwriting an already existing entry with the same key. An 285 | * internal copy of the data passed is made. Will accept only valid 286 | * UTF-8. \since 0.9.11 */ 287 | int pa_proplist_sets(pa_proplist *p, const char *key, const char *value); 288 | 289 | /** Append a new string entry to the property list, possibly 290 | * overwriting an already existing entry with the same key. An 291 | * internal copy of the data passed is made. Will accept only valid 292 | * UTF-8. The string passed in must contain a '='. Left hand side of 293 | * the '=' is used as key name, the right hand side as string 294 | * data. \since 0.9.16 */ 295 | int pa_proplist_setp(pa_proplist *p, const char *pair); 296 | 297 | /** Append a new string entry to the property list, possibly 298 | * overwriting an already existing entry with the same key. An 299 | * internal copy of the data passed is made. Will accept only valid 300 | * UTF-8. The data can be passed as printf()-style format string with 301 | * arguments. \since 0.9.11 */ 302 | int pa_proplist_setf(pa_proplist *p, const char *key, const char *format, ...) PA_GCC_PRINTF_ATTR(3,4); 303 | 304 | /** Append a new arbitrary data entry to the property list, possibly 305 | * overwriting an already existing entry with the same key. An 306 | * internal copy of the data passed is made. \since 0.9.11 */ 307 | int pa_proplist_set(pa_proplist *p, const char *key, const void *data, size_t nbytes); 308 | 309 | /** Return a string entry for the specified key. Will return NULL if 310 | * the data is not valid UTF-8. Will return a NUL-terminated string in 311 | * an internally allocated buffer. The caller should make a copy of 312 | * the data before accessing the property list again. \since 0.9.11 */ 313 | const char *pa_proplist_gets(pa_proplist *p, const char *key); 314 | 315 | /** Store the value for the specified key in \a data. Will store a 316 | * NUL-terminated string for string entries. The \a data pointer returned will 317 | * point to an internally allocated buffer. The caller should make a 318 | * copy of the data before the property list is accessed again. \since 319 | * 0.9.11 */ 320 | int pa_proplist_get(pa_proplist *p, const char *key, const void **data, size_t *nbytes); 321 | 322 | /** Update mode enum for pa_proplist_update(). \since 0.9.11 */ 323 | typedef enum pa_update_mode { 324 | PA_UPDATE_SET 325 | /**< Replace the entire property list with the new one. Don't keep 326 | * any of the old data around. */, 327 | 328 | PA_UPDATE_MERGE 329 | /**< Merge new property list into the existing one, not replacing 330 | * any old entries if they share a common key with the new 331 | * property list. */, 332 | 333 | PA_UPDATE_REPLACE 334 | /**< Merge new property list into the existing one, replacing all 335 | * old entries that share a common key with the new property 336 | * list. */ 337 | } pa_update_mode_t; 338 | 339 | /** \cond fulldocs */ 340 | #define PA_UPDATE_SET PA_UPDATE_SET 341 | #define PA_UPDATE_MERGE PA_UPDATE_MERGE 342 | #define PA_UPDATE_REPLACE PA_UPDATE_REPLACE 343 | /** \endcond */ 344 | 345 | /** Merge property list "other" into "p", adhering the merge mode as 346 | * specified in "mode". \since 0.9.11 */ 347 | void pa_proplist_update(pa_proplist *p, pa_update_mode_t mode, const pa_proplist *other); 348 | 349 | /** Removes a single entry from the property list, identified be the 350 | * specified key name. \since 0.9.11 */ 351 | int pa_proplist_unset(pa_proplist *p, const char *key); 352 | 353 | /** Similar to pa_proplist_unset() but takes an array of keys to 354 | * remove. The array should be terminated by a NULL pointer. Returns -1 355 | * on failure, otherwise the number of entries actually removed (which 356 | * might even be 0, if there were no matching entries to 357 | * remove). \since 0.9.11 */ 358 | int pa_proplist_unset_many(pa_proplist *p, const char * const keys[]); 359 | 360 | /** Iterate through the property list. The user should allocate a 361 | * state variable of type void* and initialize it with NULL. A pointer 362 | * to this variable should then be passed to pa_proplist_iterate() 363 | * which should be called in a loop until it returns NULL which 364 | * signifies EOL. The property list should not be modified during 365 | * iteration through the list -- with the exception of deleting the 366 | * current entry. On each invocation this function will return the 367 | * key string for the next entry. The keys in the property list do not 368 | * have any particular order. \since 0.9.11 */ 369 | const char *pa_proplist_iterate(pa_proplist *p, void **state); 370 | 371 | /** Format the property list nicely as a human readable string. This 372 | * works very much like pa_proplist_to_string_sep() and uses a newline 373 | * as separator and appends one final one. Call pa_xfree() on the 374 | * result. \since 0.9.11 */ 375 | char *pa_proplist_to_string(pa_proplist *p); 376 | 377 | /** Format the property list nicely as a human readable string and 378 | * choose the separator. Call pa_xfree() on the result. \since 379 | * 0.9.15 */ 380 | char *pa_proplist_to_string_sep(pa_proplist *p, const char *sep); 381 | 382 | /** Allocate a new property list and assign key/value from a human 383 | * readable string. \since 0.9.15 */ 384 | pa_proplist *pa_proplist_from_string(const char *str); 385 | 386 | /** Returns 1 if an entry for the specified key exists in the 387 | * property list. \since 0.9.11 */ 388 | int pa_proplist_contains(pa_proplist *p, const char *key); 389 | 390 | /** Remove all entries from the property list object. \since 0.9.11 */ 391 | void pa_proplist_clear(pa_proplist *p); 392 | 393 | /** Allocate a new property list and copy over every single entry from 394 | * the specified list. \since 0.9.11 */ 395 | pa_proplist* pa_proplist_copy(const pa_proplist *p); 396 | 397 | /** Return the number of entries in the property list. \since 0.9.15 */ 398 | unsigned pa_proplist_size(pa_proplist *p); 399 | 400 | /** Returns 0 when the proplist is empty, positive otherwise \since 0.9.15 */ 401 | int pa_proplist_isempty(pa_proplist *p); 402 | 403 | /** Return non-zero when a and b have the same keys and values. 404 | * \since 0.9.16 */ 405 | int pa_proplist_equal(pa_proplist *a, pa_proplist *b); 406 | 407 | PA_C_DECL_END 408 | 409 | #endif 410 | -------------------------------------------------------------------------------- /vendor/pulse/pulseaudio.h: -------------------------------------------------------------------------------- 1 | #ifndef foopulseaudiohfoo 2 | #define foopulseaudiohfoo 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 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | /** \file 50 | * Include all libpulse header files at once. The following files are 51 | * included: \ref direction.h, \ref mainloop-api.h, \ref sample.h, \ref def.h, 52 | * \ref context.h, \ref stream.h, \ref introspect.h, \ref subscribe.h, \ref 53 | * scache.h, \ref version.h, \ref error.h, \ref channelmap.h, \ref 54 | * operation.h,\ref volume.h, \ref xmalloc.h, \ref utf8.h, \ref 55 | * thread-mainloop.h, \ref mainloop.h, \ref util.h, \ref proplist.h, 56 | * \ref timeval.h, \ref rtclock.h and \ref mainloop-signal.h at 57 | * once */ 58 | 59 | /** \mainpage 60 | * 61 | * \section intro_sec Introduction 62 | * 63 | * This document describes the client API for the PulseAudio sound 64 | * server. The API comes in two flavours to accommodate different styles 65 | * of applications and different needs in complexity: 66 | * 67 | * \li The complete but somewhat complicated to use asynchronous API 68 | * \li The simplified, easy to use, but limited synchronous API 69 | * 70 | * All strings in PulseAudio are in the UTF-8 encoding, regardless of current 71 | * locale. Some functions will filter invalid sequences from the string, some 72 | * will simply fail. To ensure reliable behaviour, make sure everything you 73 | * pass to the API is already in UTF-8. 74 | 75 | * \section simple_sec Simple API 76 | * 77 | * Use this if you develop your program in synchronous style and just 78 | * need a way to play or record data on the sound server. See 79 | * \subpage simple for more details. 80 | * 81 | * \section async_sec Asynchronous API 82 | * 83 | * Use this if you develop your programs in asynchronous, event loop 84 | * based style or if you want to use the advanced features of the 85 | * PulseAudio API. A guide can be found in \subpage async. 86 | * 87 | * By using the built-in threaded main loop, it is possible to achieve a 88 | * pseudo-synchronous API, which can be useful in synchronous applications 89 | * where the simple API is insufficient. See the \ref async page for 90 | * details. 91 | * 92 | * \section thread_sec Threads 93 | * 94 | * The PulseAudio client libraries are not designed to be directly 95 | * thread-safe. They are however designed to be reentrant and 96 | * threads-aware. 97 | * 98 | * To use the libraries in a threaded environment, you must assure that 99 | * all objects are only used in one thread at a time. Normally, this means 100 | * that all objects belonging to a single context must be accessed from the 101 | * same thread. 102 | * 103 | * The included main loop implementation is also not thread safe. Take care 104 | * to make sure event objects are not manipulated when any other code is 105 | * using the main loop. 106 | * 107 | * \section error_sec Error Handling 108 | * 109 | * Every function should explicitly document how errors are reported to 110 | * the caller. Unfortunately, currently a lot of that documentation is 111 | * missing. Here is an overview of the general conventions used. 112 | * 113 | * The PulseAudio API indicates error conditions by returning a negative 114 | * integer value or a NULL pointer. On success, zero or a positive integer 115 | * value or a valid pointer is returned. 116 | * 117 | * Functions of the \ref simple generally return -1 or NULL on failure and 118 | * can optionally store an error code (see ::pa_error_code) using a pointer 119 | * argument. 120 | * 121 | * Functions of the \ref async return an negative error code or NULL on 122 | * failure (see ::pa_error_code). In the later case, pa_context_errno() 123 | * can be used to obtain the error code of the last failed operation. 124 | * 125 | * An error code can be turned into a human readable message using 126 | * pa_strerror(). 127 | * 128 | * \section pkgconfig pkg-config 129 | * 130 | * The PulseAudio libraries provide pkg-config snippets for the different 131 | * modules: 132 | * 133 | * \li libpulse - The asynchronous API and the internal main loop implementation. 134 | * \li libpulse-mainloop-glib - GLIB 2.x main loop bindings. 135 | * \li libpulse-simple - The simple PulseAudio API. 136 | */ 137 | 138 | #endif 139 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/pulse/sample.h: -------------------------------------------------------------------------------- 1 | #ifndef foosamplehfoo 2 | #define foosamplehfoo 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 | #include 29 | #include 30 | #include 31 | 32 | /** \page sample Sample Format Specifications 33 | * 34 | * \section overv_sec Overview 35 | * 36 | * PulseAudio is capable of handling a multitude of sample formats, rates 37 | * and channels, transparently converting and mixing them as needed. 38 | * 39 | * \section format_sec Sample Format 40 | * 41 | * PulseAudio supports the following sample formats: 42 | * 43 | * \li PA_SAMPLE_U8 - Unsigned 8 bit integer PCM. 44 | * \li PA_SAMPLE_S16LE - Signed 16 integer bit PCM, little endian. 45 | * \li PA_SAMPLE_S16BE - Signed 16 integer bit PCM, big endian. 46 | * \li PA_SAMPLE_FLOAT32LE - 32 bit IEEE floating point PCM, little endian. 47 | * \li PA_SAMPLE_FLOAT32BE - 32 bit IEEE floating point PCM, big endian. 48 | * \li PA_SAMPLE_ALAW - 8 bit a-Law. 49 | * \li PA_SAMPLE_ULAW - 8 bit mu-Law. 50 | * \li PA_SAMPLE_S32LE - Signed 32 bit integer PCM, little endian. 51 | * \li PA_SAMPLE_S32BE - Signed 32 bit integer PCM, big endian. 52 | * \li PA_SAMPLE_S24LE - Signed 24 bit integer PCM packed, little endian. 53 | * \li PA_SAMPLE_S24BE - Signed 24 bit integer PCM packed, big endian. 54 | * \li PA_SAMPLE_S24_32LE - Signed 24 bit integer PCM in LSB of 32 bit words, little endian. 55 | * \li PA_SAMPLE_S24_32BE - Signed 24 bit integer PCM in LSB of 32 bit words, big endian. 56 | * 57 | * The floating point sample formats have the range from -1.0 to 1.0. 58 | * 59 | * The sample formats that are sensitive to endianness have convenience 60 | * macros for native endian (NE), and reverse endian (RE). 61 | * 62 | * \section rate_sec Sample Rates 63 | * 64 | * PulseAudio supports any sample rate between 1 Hz and 192000 Hz. There is no 65 | * point trying to exceed the sample rate of the output device though as the 66 | * signal will only get downsampled, consuming CPU on the machine running the 67 | * server. 68 | * 69 | * \section chan_sec Channels 70 | * 71 | * PulseAudio supports up to 32 individual channels. The order of the 72 | * channels is up to the application, but they must be continuous. To map 73 | * channels to speakers, see \ref channelmap. 74 | * 75 | * \section calc_sec Calculations 76 | * 77 | * The PulseAudio library contains a number of convenience functions to do 78 | * calculations on sample formats: 79 | * 80 | * \li pa_bytes_per_second() - The number of bytes one second of audio will 81 | * take given a sample format. 82 | * \li pa_frame_size() - The size, in bytes, of one frame (i.e. one set of 83 | * samples, one for each channel). 84 | * \li pa_sample_size() - The size, in bytes, of one sample. 85 | * \li pa_bytes_to_usec() - Calculate the time it would take to play a buffer 86 | * of a certain size. 87 | * 88 | * \section util_sec Convenience Functions 89 | * 90 | * The library also contains a couple of other convenience functions: 91 | * 92 | * \li pa_sample_spec_valid() - Tests if a sample format specification is 93 | * valid. 94 | * \li pa_sample_spec_equal() - Tests if the sample format specifications are 95 | * identical. 96 | * \li pa_sample_format_to_string() - Return a textual description of a 97 | * sample format. 98 | * \li pa_parse_sample_format() - Parse a text string into a sample format. 99 | * \li pa_sample_spec_snprint() - Create a textual description of a complete 100 | * sample format specification. 101 | * \li pa_bytes_snprint() - Pretty print a byte value (e.g. 2.5 MiB). 102 | */ 103 | 104 | /** \file 105 | * Constants and routines for sample type handling 106 | * 107 | * See also \subpage sample 108 | */ 109 | 110 | PA_C_DECL_BEGIN 111 | 112 | #if !defined(WORDS_BIGENDIAN) 113 | 114 | #if defined(__BYTE_ORDER) 115 | #if __BYTE_ORDER == __BIG_ENDIAN 116 | #define WORDS_BIGENDIAN 117 | #endif 118 | #endif 119 | 120 | /* On Sparc, WORDS_BIGENDIAN needs to be set if _BIG_ENDIAN is defined. */ 121 | #if defined(__sparc__) && defined(_BIG_ENDIAN) 122 | #define WORDS_BIGENDIAN 123 | #endif 124 | 125 | #endif 126 | 127 | /** Maximum number of allowed channels */ 128 | #define PA_CHANNELS_MAX 32U 129 | 130 | /** Maximum allowed sample rate */ 131 | #define PA_RATE_MAX (48000U*4U) 132 | 133 | /** Sample format */ 134 | typedef enum pa_sample_format { 135 | PA_SAMPLE_U8, 136 | /**< Unsigned 8 Bit PCM */ 137 | 138 | PA_SAMPLE_ALAW, 139 | /**< 8 Bit a-Law */ 140 | 141 | PA_SAMPLE_ULAW, 142 | /**< 8 Bit mu-Law */ 143 | 144 | PA_SAMPLE_S16LE, 145 | /**< Signed 16 Bit PCM, little endian (PC) */ 146 | 147 | PA_SAMPLE_S16BE, 148 | /**< Signed 16 Bit PCM, big endian */ 149 | 150 | PA_SAMPLE_FLOAT32LE, 151 | /**< 32 Bit IEEE floating point, little endian (PC), range -1.0 to 1.0 */ 152 | 153 | PA_SAMPLE_FLOAT32BE, 154 | /**< 32 Bit IEEE floating point, big endian, range -1.0 to 1.0 */ 155 | 156 | PA_SAMPLE_S32LE, 157 | /**< Signed 32 Bit PCM, little endian (PC) */ 158 | 159 | PA_SAMPLE_S32BE, 160 | /**< Signed 32 Bit PCM, big endian */ 161 | 162 | PA_SAMPLE_S24LE, 163 | /**< Signed 24 Bit PCM packed, little endian (PC). \since 0.9.15 */ 164 | 165 | PA_SAMPLE_S24BE, 166 | /**< Signed 24 Bit PCM packed, big endian. \since 0.9.15 */ 167 | 168 | PA_SAMPLE_S24_32LE, 169 | /**< Signed 24 Bit PCM in LSB of 32 Bit words, little endian (PC). \since 0.9.15 */ 170 | 171 | PA_SAMPLE_S24_32BE, 172 | /**< Signed 24 Bit PCM in LSB of 32 Bit words, big endian. \since 0.9.15 */ 173 | 174 | PA_SAMPLE_MAX, 175 | /**< Upper limit of valid sample types */ 176 | 177 | PA_SAMPLE_INVALID = -1 178 | /**< An invalid value */ 179 | } pa_sample_format_t; 180 | 181 | #ifdef WORDS_BIGENDIAN 182 | /** Signed 16 Bit PCM, native endian */ 183 | #define PA_SAMPLE_S16NE PA_SAMPLE_S16BE 184 | /** 32 Bit IEEE floating point, native endian */ 185 | #define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32BE 186 | /** Signed 32 Bit PCM, native endian */ 187 | #define PA_SAMPLE_S32NE PA_SAMPLE_S32BE 188 | /** Signed 24 Bit PCM packed, native endian. \since 0.9.15 */ 189 | #define PA_SAMPLE_S24NE PA_SAMPLE_S24BE 190 | /** Signed 24 Bit PCM in LSB of 32 Bit words, native endian. \since 0.9.15 */ 191 | #define PA_SAMPLE_S24_32NE PA_SAMPLE_S24_32BE 192 | 193 | /** Signed 16 Bit PCM reverse endian */ 194 | #define PA_SAMPLE_S16RE PA_SAMPLE_S16LE 195 | /** 32 Bit IEEE floating point, reverse endian */ 196 | #define PA_SAMPLE_FLOAT32RE PA_SAMPLE_FLOAT32LE 197 | /** Signed 32 Bit PCM, reverse endian */ 198 | #define PA_SAMPLE_S32RE PA_SAMPLE_S32LE 199 | /** Signed 24 Bit PCM, packed reverse endian. \since 0.9.15 */ 200 | #define PA_SAMPLE_S24RE PA_SAMPLE_S24LE 201 | /** Signed 24 Bit PCM, in LSB of 32 Bit words, reverse endian. \since 0.9.15 */ 202 | #define PA_SAMPLE_S24_32RE PA_SAMPLE_S24_32LE 203 | #else 204 | /** Signed 16 Bit PCM, native endian */ 205 | #define PA_SAMPLE_S16NE PA_SAMPLE_S16LE 206 | /** 32 Bit IEEE floating point, native endian */ 207 | #define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32LE 208 | /** Signed 32 Bit PCM, native endian */ 209 | #define PA_SAMPLE_S32NE PA_SAMPLE_S32LE 210 | /** Signed 24 Bit PCM packed, native endian. \since 0.9.15 */ 211 | #define PA_SAMPLE_S24NE PA_SAMPLE_S24LE 212 | /** Signed 24 Bit PCM in LSB of 32 Bit words, native endian. \since 0.9.15 */ 213 | #define PA_SAMPLE_S24_32NE PA_SAMPLE_S24_32LE 214 | 215 | /** Signed 16 Bit PCM, reverse endian */ 216 | #define PA_SAMPLE_S16RE PA_SAMPLE_S16BE 217 | /** 32 Bit IEEE floating point, reverse endian */ 218 | #define PA_SAMPLE_FLOAT32RE PA_SAMPLE_FLOAT32BE 219 | /** Signed 32 Bit PCM, reverse endian */ 220 | #define PA_SAMPLE_S32RE PA_SAMPLE_S32BE 221 | /** Signed 24 Bit PCM, packed reverse endian. \since 0.9.15 */ 222 | #define PA_SAMPLE_S24RE PA_SAMPLE_S24BE 223 | /** Signed 24 Bit PCM, in LSB of 32 Bit words, reverse endian. \since 0.9.15 */ 224 | #define PA_SAMPLE_S24_32RE PA_SAMPLE_S24_32BE 225 | #endif 226 | 227 | /** A Shortcut for PA_SAMPLE_FLOAT32NE */ 228 | #define PA_SAMPLE_FLOAT32 PA_SAMPLE_FLOAT32NE 229 | 230 | /** \cond fulldocs */ 231 | /* Allow clients to check with #ifdef for these sample formats */ 232 | #define PA_SAMPLE_U8 PA_SAMPLE_U8 233 | #define PA_SAMPLE_ALAW PA_SAMPLE_ALAW 234 | #define PA_SAMPLE_ULAW PA_SAMPLE_ULAW 235 | #define PA_SAMPLE_S16LE PA_SAMPLE_S16LE 236 | #define PA_SAMPLE_S16BE PA_SAMPLE_S16BE 237 | #define PA_SAMPLE_FLOAT32LE PA_SAMPLE_FLOAT32LE 238 | #define PA_SAMPLE_FLOAT32BE PA_SAMPLE_FLOAT32BE 239 | #define PA_SAMPLE_S32LE PA_SAMPLE_S32LE 240 | #define PA_SAMPLE_S32BE PA_SAMPLE_S32BE 241 | #define PA_SAMPLE_S24LE PA_SAMPLE_S24LE 242 | #define PA_SAMPLE_S24BE PA_SAMPLE_S24BE 243 | #define PA_SAMPLE_S24_32LE PA_SAMPLE_S24_32LE 244 | #define PA_SAMPLE_S24_32BE PA_SAMPLE_S24_32BE 245 | /** \endcond */ 246 | 247 | /** A sample format and attribute specification */ 248 | typedef struct pa_sample_spec { 249 | pa_sample_format_t format; 250 | /**< The sample format */ 251 | 252 | uint32_t rate; 253 | /**< The sample rate. (e.g. 44100) */ 254 | 255 | uint8_t channels; 256 | /**< Audio channels. (1 for mono, 2 for stereo, ...) */ 257 | } pa_sample_spec; 258 | 259 | /** Type for usec specifications (unsigned). Always 64 bit. */ 260 | typedef uint64_t pa_usec_t; 261 | 262 | /** Return the amount of bytes playback of a second of audio with the specified sample type takes */ 263 | size_t pa_bytes_per_second(const pa_sample_spec *spec) PA_GCC_PURE; 264 | 265 | /** Return the size of a frame with the specific sample type */ 266 | size_t pa_frame_size(const pa_sample_spec *spec) PA_GCC_PURE; 267 | 268 | /** Return the size of a sample with the specific sample type */ 269 | size_t pa_sample_size(const pa_sample_spec *spec) PA_GCC_PURE; 270 | 271 | /** Similar to pa_sample_size() but take a sample format instead of a 272 | * full sample spec. \since 0.9.15 */ 273 | size_t pa_sample_size_of_format(pa_sample_format_t f) PA_GCC_PURE; 274 | 275 | /** Calculate the time the specified bytes take to play with the 276 | * specified sample type. The return value will always be rounded 277 | * down for non-integral return values. */ 278 | pa_usec_t pa_bytes_to_usec(uint64_t length, const pa_sample_spec *spec) PA_GCC_PURE; 279 | 280 | /** Calculates the number of bytes that are required for the specified 281 | * time. The return value will always be rounded down for non-integral 282 | * return values. \since 0.9 */ 283 | size_t pa_usec_to_bytes(pa_usec_t t, const pa_sample_spec *spec) PA_GCC_PURE; 284 | 285 | /** Initialize the specified sample spec and return a pointer to 286 | * it. The sample spec will have a defined state but 287 | * pa_sample_spec_valid() will fail for it. \since 0.9.13 */ 288 | pa_sample_spec* pa_sample_spec_init(pa_sample_spec *spec); 289 | 290 | /** Return non-zero if the given integer is a valid sample format. \since 5.0 */ 291 | int pa_sample_format_valid(unsigned format) PA_GCC_PURE; 292 | 293 | /** Return non-zero if the rate is within the supported range. \since 5.0 */ 294 | int pa_sample_rate_valid(uint32_t rate) PA_GCC_PURE; 295 | 296 | /** Return non-zero if the channel count is within the supported range. 297 | * \since 5.0 */ 298 | int pa_channels_valid(uint8_t channels) PA_GCC_PURE; 299 | 300 | /** Return non-zero when the sample type specification is valid */ 301 | int pa_sample_spec_valid(const pa_sample_spec *spec) PA_GCC_PURE; 302 | 303 | /** Return non-zero when the two sample type specifications match */ 304 | int pa_sample_spec_equal(const pa_sample_spec*a, const pa_sample_spec*b) PA_GCC_PURE; 305 | 306 | /** Return a descriptive string for the specified sample format. \since 0.8 */ 307 | const char *pa_sample_format_to_string(pa_sample_format_t f) PA_GCC_PURE; 308 | 309 | /** Parse a sample format text. Inverse of pa_sample_format_to_string() */ 310 | pa_sample_format_t pa_parse_sample_format(const char *format) PA_GCC_PURE; 311 | 312 | /** Maximum required string length for 313 | * pa_sample_spec_snprint(). Please note that this value can change 314 | * with any release without warning and without being considered API 315 | * or ABI breakage. You should not use this definition anywhere where 316 | * it might become part of an ABI. */ 317 | #define PA_SAMPLE_SPEC_SNPRINT_MAX 32 318 | 319 | /** Pretty print a sample type specification to a string */ 320 | char* pa_sample_spec_snprint(char *s, size_t l, const pa_sample_spec *spec); 321 | 322 | /** Maximum required string length for pa_bytes_snprint(). Please note 323 | * that this value can change with any release without warning and 324 | * without being considered API or ABI breakage. You should not use 325 | * this definition anywhere where it might become part of an 326 | * ABI. \since 0.9.16 */ 327 | #define PA_BYTES_SNPRINT_MAX 11 328 | 329 | /** Pretty print a byte size value (i.e.\ "2.5 MiB") */ 330 | char* pa_bytes_snprint(char *s, size_t l, unsigned v); 331 | 332 | /** Return 1 when the specified format is little endian, return -1 333 | * when endianness does not apply to this format. \since 0.9.16 */ 334 | int pa_sample_format_is_le(pa_sample_format_t f) PA_GCC_PURE; 335 | 336 | /** Return 1 when the specified format is big endian, return -1 when 337 | * endianness does not apply to this format. \since 0.9.16 */ 338 | int pa_sample_format_is_be(pa_sample_format_t f) PA_GCC_PURE; 339 | 340 | #ifdef WORDS_BIGENDIAN 341 | #define pa_sample_format_is_ne(f) pa_sample_format_is_be(f) 342 | #define pa_sample_format_is_re(f) pa_sample_format_is_le(f) 343 | #else 344 | /** Return 1 when the specified format is native endian, return -1 345 | * when endianness does not apply to this format. \since 0.9.16 */ 346 | #define pa_sample_format_is_ne(f) pa_sample_format_is_le(f) 347 | /** Return 1 when the specified format is reverse endian, return -1 348 | * when endianness does not apply to this format. \since 0.9.16 */ 349 | #define pa_sample_format_is_re(f) pa_sample_format_is_be(f) 350 | #endif 351 | 352 | PA_C_DECL_END 353 | 354 | #endif 355 | -------------------------------------------------------------------------------- /vendor/pulse/scache.h: -------------------------------------------------------------------------------- 1 | #ifndef fooscachehfoo 2 | #define fooscachehfoo 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 | #include 30 | 31 | /** \page scache Sample Cache 32 | * 33 | * \section overv_sec Overview 34 | * 35 | * The sample cache provides a simple way of overcoming high network latencies 36 | * and reducing bandwidth. Instead of streaming a sound precisely when it 37 | * should be played, it is stored on the server and only the command to start 38 | * playing it needs to be sent. 39 | * 40 | * \section create_sec Creation 41 | * 42 | * To create a sample, the normal stream API is used (see \ref streams). The 43 | * function pa_stream_connect_upload() will make sure the stream is stored as 44 | * a sample on the server. 45 | * 46 | * To complete the upload, pa_stream_finish_upload() is called and the sample 47 | * will receive the same name as the stream. If the upload should be aborted, 48 | * simply call pa_stream_disconnect(). 49 | * 50 | * \section play_sec Playing samples 51 | * 52 | * To play back a sample, simply call pa_context_play_sample(): 53 | * 54 | * \code 55 | * pa_operation *o; 56 | * 57 | * o = pa_context_play_sample(my_context, 58 | * "sample2", // Name of my sample 59 | * NULL, // Use default sink 60 | * PA_VOLUME_NORM, // Full volume 61 | * NULL, // Don't need a callback 62 | * NULL 63 | * ); 64 | * if (o) 65 | * pa_operation_unref(o); 66 | * \endcode 67 | * 68 | * \section rem_sec Removing samples 69 | * 70 | * When a sample is no longer needed, it should be removed on the server to 71 | * save resources. The sample is deleted using pa_context_remove_sample(). 72 | */ 73 | 74 | /** \file 75 | * All sample cache related routines 76 | * 77 | * See also \subpage scache 78 | */ 79 | 80 | PA_C_DECL_BEGIN 81 | 82 | /** Callback prototype for pa_context_play_sample_with_proplist(). The 83 | * idx value is the index of the sink input object, or 84 | * PA_INVALID_INDEX on failure. \since 0.9.11 */ 85 | typedef void (*pa_context_play_sample_cb_t)(pa_context *c, uint32_t idx, void *userdata); 86 | 87 | /** Make this stream a sample upload stream */ 88 | int pa_stream_connect_upload(pa_stream *s, size_t length); 89 | 90 | /** Finish the sample upload, the stream name will become the sample 91 | * name. You cancel a sample upload by issuing 92 | * pa_stream_disconnect() */ 93 | int pa_stream_finish_upload(pa_stream *s); 94 | 95 | /** Remove a sample from the sample cache. Returns an operation object which may be used to cancel the operation while it is running */ 96 | pa_operation* pa_context_remove_sample(pa_context *c, const char *name, pa_context_success_cb_t cb, void *userdata); 97 | 98 | /** Play a sample from the sample cache to the specified device. If 99 | * the latter is NULL use the default sink. Returns an operation 100 | * object */ 101 | pa_operation* pa_context_play_sample( 102 | pa_context *c /**< Context */, 103 | const char *name /**< Name of the sample to play */, 104 | const char *dev /**< Sink to play this sample on */, 105 | pa_volume_t volume /**< Volume to play this sample with. Starting with 0.9.15 you may pass here PA_VOLUME_INVALID which will leave the decision about the volume to the server side which is a good idea. */ , 106 | pa_context_success_cb_t cb /**< Call this function after successfully starting playback, or NULL */, 107 | void *userdata /**< Userdata to pass to the callback */); 108 | 109 | /** Play a sample from the sample cache to the specified device, 110 | * allowing specification of a property list for the playback 111 | * stream. If the latter is NULL use the default sink. Returns an 112 | * operation object. \since 0.9.11 */ 113 | pa_operation* pa_context_play_sample_with_proplist( 114 | pa_context *c /**< Context */, 115 | const char *name /**< Name of the sample to play */, 116 | const char *dev /**< Sink to play this sample on */, 117 | pa_volume_t volume /**< Volume to play this sample with. Starting with 0.9.15 you may pass here PA_VOLUME_INVALID which will leave the decision about the volume to the server side which is a good idea. */ , 118 | pa_proplist *proplist /**< Property list for this sound. The property list of the cached entry will be merged into this property list */, 119 | pa_context_play_sample_cb_t cb /**< Call this function after successfully starting playback, or NULL */, 120 | void *userdata /**< Userdata to pass to the callback */); 121 | 122 | PA_C_DECL_END 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /vendor/pulse/simple.h: -------------------------------------------------------------------------------- 1 | #ifndef foosimplehfoo 2 | #define foosimplehfoo 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 | #include 30 | #include 31 | 32 | /** \page simple Simple API 33 | * 34 | * \section overv_sec Overview 35 | * 36 | * The simple API is designed for applications with very basic sound 37 | * playback or capture needs. It can only support a single stream per 38 | * connection and has no support for handling of complex features like 39 | * events, channel mappings and volume control. It is, however, very simple 40 | * to use and quite sufficient for many programs. 41 | * 42 | * \section conn_sec Connecting 43 | * 44 | * The first step before using the sound system is to connect to the 45 | * server. This is normally done this way: 46 | * 47 | * \code 48 | * pa_simple *s; 49 | * pa_sample_spec ss; 50 | * 51 | * ss.format = PA_SAMPLE_S16NE; 52 | * ss.channels = 2; 53 | * ss.rate = 44100; 54 | * 55 | * s = pa_simple_new(NULL, // Use the default server. 56 | * "Fooapp", // Our application's name. 57 | * PA_STREAM_PLAYBACK, 58 | * NULL, // Use the default device. 59 | * "Music", // Description of our stream. 60 | * &ss, // Our sample format. 61 | * NULL, // Use default channel map 62 | * NULL, // Use default buffering attributes. 63 | * NULL, // Ignore error code. 64 | * ); 65 | * \endcode 66 | * 67 | * At this point a connected object is returned, or NULL if there was a 68 | * problem connecting. 69 | * 70 | * \section transfer_sec Transferring data 71 | * 72 | * Once the connection is established to the server, data can start flowing. 73 | * Using the connection is very similar to the normal read() and write() 74 | * system calls. The main difference is that they're called pa_simple_read() 75 | * and pa_simple_write(). Note that these operations always block. 76 | * 77 | * \section ctrl_sec Buffer control 78 | * 79 | * \li pa_simple_get_latency() - Will return the total latency of 80 | * the playback or record pipeline, respectively. 81 | * \li pa_simple_flush() - Will throw away all data currently in buffers. 82 | * 83 | * If a playback stream is used then the following operation is available: 84 | * 85 | * \li pa_simple_drain() - Will wait for all sent data to finish playing. 86 | * 87 | * \section cleanup_sec Cleanup 88 | * 89 | * Once playback or capture is complete, the connection should be closed 90 | * and resources freed. This is done through: 91 | * 92 | * \code 93 | * pa_simple_free(s); 94 | * \endcode 95 | */ 96 | 97 | /** \file 98 | * A simple but limited synchronous playback and recording 99 | * API. This is a synchronous, simplified wrapper around the standard 100 | * asynchronous API. 101 | * 102 | * See also \subpage simple 103 | */ 104 | 105 | /** \example pacat-simple.c 106 | * A simple playback tool using the simple API */ 107 | 108 | /** \example parec-simple.c 109 | * A simple recording tool using the simple API */ 110 | 111 | PA_C_DECL_BEGIN 112 | 113 | /** \struct pa_simple 114 | * An opaque simple connection object */ 115 | typedef struct pa_simple pa_simple; 116 | 117 | /** Create a new connection to the server. */ 118 | pa_simple* pa_simple_new( 119 | const char *server, /**< Server name, or NULL for default */ 120 | const char *name, /**< A descriptive name for this client (application name, ...) */ 121 | pa_stream_direction_t dir, /**< Open this stream for recording or playback? */ 122 | const char *dev, /**< Sink (resp. source) name, or NULL for default */ 123 | const char *stream_name, /**< A descriptive name for this stream (application name, song title, ...) */ 124 | const pa_sample_spec *ss, /**< The sample type to use */ 125 | const pa_channel_map *map, /**< The channel map to use, or NULL for default */ 126 | const pa_buffer_attr *attr, /**< Buffering attributes, or NULL for default */ 127 | int *error /**< A pointer where the error code is stored when the routine returns NULL. It is OK to pass NULL here. */ 128 | ); 129 | 130 | /** Close and free the connection to the server. The connection object becomes invalid when this is called. */ 131 | void pa_simple_free(pa_simple *s); 132 | 133 | /** Write some data to the server. */ 134 | int pa_simple_write(pa_simple *s, const void *data, size_t bytes, int *error); 135 | 136 | /** Wait until all data already written is played by the daemon. */ 137 | int pa_simple_drain(pa_simple *s, int *error); 138 | 139 | /** Read some data from the server. This function blocks until \a bytes amount 140 | * of data has been received from the server, or until an error occurs. 141 | * Returns a negative value on failure. */ 142 | int pa_simple_read( 143 | pa_simple *s, /**< The connection object. */ 144 | void *data, /**< A pointer to a buffer. */ 145 | size_t bytes, /**< The number of bytes to read. */ 146 | int *error 147 | /**< A pointer where the error code is stored when the function returns 148 | * a negative value. It is OK to pass NULL here. */ 149 | ); 150 | 151 | /** Return the playback or record latency. */ 152 | pa_usec_t pa_simple_get_latency(pa_simple *s, int *error); 153 | 154 | /** Flush the playback or record buffer. This discards any audio in the buffer. */ 155 | int pa_simple_flush(pa_simple *s, int *error); 156 | 157 | PA_C_DECL_END 158 | 159 | #endif 160 | -------------------------------------------------------------------------------- /vendor/pulse/subscribe.h: -------------------------------------------------------------------------------- 1 | #ifndef foosubscribehfoo 2 | #define foosubscribehfoo 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 | #include 30 | 31 | /** \page subscribe Event Subscription 32 | * 33 | * \section overv_sec Overview 34 | * 35 | * The application can be notified, asynchronously, whenever the internal 36 | * layout of the server changes. Possible notifications are described in the 37 | * \ref pa_subscription_event_type and \ref pa_subscription_mask 38 | * enumerations. 39 | * 40 | * The application sets the notification mask using pa_context_subscribe() 41 | * and the function that will be called whenever a notification occurs using 42 | * pa_context_set_subscribe_callback(). 43 | * 44 | * The callback will be called with a \ref pa_subscription_event_type_t 45 | * representing the event that caused the callback. Clients can examine what 46 | * object changed using \ref PA_SUBSCRIPTION_EVENT_FACILITY_MASK. The actual 47 | * event type can then be extracted with \ref PA_SUBSCRIPTION_EVENT_TYPE_MASK. 48 | * Please note that the masked values are integers, not flags (so you will 49 | * check the object/event type using a comparison not a binary AND). For 50 | * example, the callback might look something like: 51 | * 52 | @verbatim 53 | void my_subscription_callback(pa_context *c, pa_subscription_event_type_t t, 54 | uint32_t idx, void *userdata) { 55 | if ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SOURCE) { 56 | if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) { 57 | ... a source was added, let's do stuff! ... 58 | } 59 | } 60 | } 61 | @endverbatim 62 | */ 63 | 64 | /** \file 65 | * Daemon introspection event subscription subsystem. 66 | * 67 | * See also \subpage subscribe 68 | */ 69 | 70 | PA_C_DECL_BEGIN 71 | 72 | /** Subscription event callback prototype */ 73 | typedef void (*pa_context_subscribe_cb_t)(pa_context *c, pa_subscription_event_type_t t, uint32_t idx, void *userdata); 74 | 75 | /** Enable event notification */ 76 | pa_operation* pa_context_subscribe(pa_context *c, pa_subscription_mask_t m, pa_context_success_cb_t cb, void *userdata); 77 | 78 | /** Set the context specific call back function that is called whenever the state of the daemon changes */ 79 | void pa_context_set_subscribe_callback(pa_context *c, pa_context_subscribe_cb_t cb, void *userdata); 80 | 81 | PA_C_DECL_END 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /vendor/pulse/thread-mainloop.h: -------------------------------------------------------------------------------- 1 | #ifndef foothreadmainloophfoo 2 | #define foothreadmainloophfoo 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 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 | PA_C_DECL_BEGIN 29 | 30 | /** \page threaded_mainloop Threaded Main Loop 31 | * 32 | * \section overv_sec Overview 33 | * 34 | * The threaded main loop implementation is a special version of the primary 35 | * main loop implementation (see \ref mainloop). For the basic design, see 36 | * its documentation. 37 | * 38 | * The added feature in the threaded main loop is that it spawns a new thread 39 | * that runs the real main loop. This allows a synchronous application to use 40 | * the asynchronous API without risking to stall the PulseAudio library. 41 | * 42 | * \section creat_sec Creation 43 | * 44 | * A pa_threaded_mainloop object is created using pa_threaded_mainloop_new(). 45 | * This will only allocate the required structures though, so to use it the 46 | * thread must also be started. This is done through 47 | * pa_threaded_mainloop_start(), after which you can start using the main loop. 48 | * 49 | * \section destr_sec Destruction 50 | * 51 | * When the PulseAudio connection has been terminated, the thread must be 52 | * stopped and the resources freed. Stopping the thread is done using 53 | * pa_threaded_mainloop_stop(), which must be called without the lock (see 54 | * below) held. When that function returns, the thread is stopped and the 55 | * pa_threaded_mainloop object can be freed using pa_threaded_mainloop_free(). 56 | * 57 | * \section lock_sec Locking 58 | * 59 | * Since the PulseAudio API doesn't allow concurrent accesses to objects, 60 | * a locking scheme must be used to guarantee safe usage. The threaded main 61 | * loop API provides such a scheme through the functions 62 | * pa_threaded_mainloop_lock() and pa_threaded_mainloop_unlock(). 63 | * 64 | * The lock is recursive, so it's safe to use it multiple times from the same 65 | * thread. Just make sure you call pa_threaded_mainloop_unlock() the same 66 | * number of times you called pa_threaded_mainloop_lock(). 67 | * 68 | * The lock needs to be held whenever you call any PulseAudio function that 69 | * uses an object associated with this main loop. Make sure you do not hold 70 | * on to the lock more than necessary though, as the threaded main loop stops 71 | * while the lock is held. 72 | * 73 | * Example: 74 | * 75 | * \code 76 | * void my_check_stream_func(pa_threaded_mainloop *m, pa_stream *s) { 77 | * pa_stream_state_t state; 78 | * 79 | * pa_threaded_mainloop_lock(m); 80 | * 81 | * state = pa_stream_get_state(s); 82 | * 83 | * pa_threaded_mainloop_unlock(m); 84 | * 85 | * if (state == PA_STREAM_READY) 86 | * printf("Stream is ready!"); 87 | * else 88 | * printf("Stream is not ready!"); 89 | * } 90 | * \endcode 91 | * 92 | * \section cb_sec Callbacks 93 | * 94 | * Callbacks in PulseAudio are asynchronous, so they require extra care when 95 | * using them together with a threaded main loop. 96 | * 97 | * The easiest way to turn the callback based operations into synchronous 98 | * ones, is to simply wait for the callback to be called and continue from 99 | * there. This is the approach chosen in PulseAudio's threaded API. 100 | * 101 | * \subsection basic_subsec Basic callbacks 102 | * 103 | * For the basic case, where all that is required is to wait for the callback 104 | * to be invoked, the code should look something like this: 105 | * 106 | * Example: 107 | * 108 | * \code 109 | * static void my_drain_callback(pa_stream *s, int success, void *userdata) { 110 | * pa_threaded_mainloop *m; 111 | * 112 | * m = userdata; 113 | * assert(m); 114 | * 115 | * pa_threaded_mainloop_signal(m, 0); 116 | * } 117 | * 118 | * void my_drain_stream_func(pa_threaded_mainloop *m, pa_stream *s) { 119 | * pa_operation *o; 120 | * 121 | * pa_threaded_mainloop_lock(m); 122 | * 123 | * o = pa_stream_drain(s, my_drain_callback, m); 124 | * assert(o); 125 | * 126 | * while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) 127 | * pa_threaded_mainloop_wait(m); 128 | * 129 | * pa_operation_unref(o); 130 | * 131 | * pa_threaded_mainloop_unlock(m); 132 | * } 133 | * \endcode 134 | * 135 | * The main function, my_drain_stream_func(), will wait for the callback to 136 | * be called using pa_threaded_mainloop_wait(). 137 | * 138 | * If your application is multi-threaded, then this waiting must be 139 | * done inside a while loop. The reason for this is that multiple 140 | * threads might be using pa_threaded_mainloop_wait() at the same 141 | * time. Each thread must therefore verify that it was its callback 142 | * that was invoked. Also the underlying OS synchronization primitives 143 | * are usually not free of spurious wake-ups, so a 144 | * pa_threaded_mainloop_wait() must be called within a loop even if 145 | * you have only one thread waiting. 146 | * 147 | * The callback, my_drain_callback(), indicates to the main function that it 148 | * has been called using pa_threaded_mainloop_signal(). 149 | * 150 | * As you can see, pa_threaded_mainloop_wait() may only be called with 151 | * the lock held. The same thing is true for pa_threaded_mainloop_signal(), 152 | * but as the lock is held before the callback is invoked, you do not have to 153 | * deal with that. 154 | * 155 | * The functions will not dead lock because the wait function will release 156 | * the lock before waiting and then regrab it once it has been signalled. 157 | * For those of you familiar with threads, the behaviour is that of a 158 | * condition variable. 159 | * 160 | * \subsection data_subsec Data callbacks 161 | * 162 | * For many callbacks, simply knowing that they have been called is 163 | * insufficient. The callback also receives some data that is desired. To 164 | * access this data safely, we must extend our example a bit: 165 | * 166 | * \code 167 | * static volatile int *drain_result = NULL; 168 | * 169 | * static void my_drain_callback(pa_stream*s, int success, void *userdata) { 170 | * pa_threaded_mainloop *m; 171 | * 172 | * m = userdata; 173 | * assert(m); 174 | * 175 | * drain_result = &success; 176 | * 177 | * pa_threaded_mainloop_signal(m, 1); 178 | * } 179 | * 180 | * void my_drain_stream_func(pa_threaded_mainloop *m, pa_stream *s) { 181 | * pa_operation *o; 182 | * 183 | * pa_threaded_mainloop_lock(m); 184 | * 185 | * o = pa_stream_drain(s, my_drain_callback, m); 186 | * assert(o); 187 | * 188 | * while (drain_result == NULL) 189 | * pa_threaded_mainloop_wait(m); 190 | * 191 | * pa_operation_unref(o); 192 | * 193 | * if (*drain_result) 194 | * printf("Success!"); 195 | * else 196 | * printf("Bitter defeat..."); 197 | * 198 | * pa_threaded_mainloop_accept(m); 199 | * 200 | * pa_threaded_mainloop_unlock(m); 201 | * } 202 | * \endcode 203 | * 204 | * The example is a bit silly as it would probably have been easier to just 205 | * copy the contents of success, but for larger data structures this can be 206 | * wasteful. 207 | * 208 | * The difference here compared to the basic callback is the value 1 passed 209 | * to pa_threaded_mainloop_signal() and the call to 210 | * pa_threaded_mainloop_accept(). What will happen is that 211 | * pa_threaded_mainloop_signal() will signal the main function and then wait. 212 | * The main function is then free to use the data in the callback until 213 | * pa_threaded_mainloop_accept() is called, which will allow the callback 214 | * to continue. 215 | * 216 | * Note that pa_threaded_mainloop_accept() must be called some time between 217 | * exiting the while loop and unlocking the main loop! Failure to do so will 218 | * result in a race condition. I.e. it is not ok to release the lock and 219 | * regrab it before calling pa_threaded_mainloop_accept(). 220 | * 221 | * \subsection async_subsec Asynchronous callbacks 222 | * 223 | * PulseAudio also has callbacks that are completely asynchronous, meaning 224 | * that they can be called at any time. The threaded main loop API provides 225 | * the locking mechanism to handle concurrent accesses, but nothing else. 226 | * Applications will have to handle communication from the callback to the 227 | * main program through their own mechanisms. 228 | * 229 | * The callbacks that are completely asynchronous are: 230 | * 231 | * \li State callbacks for contexts, streams, etc. 232 | * \li Subscription notifications 233 | */ 234 | 235 | /** \file 236 | * 237 | * A thread based event loop implementation based on pa_mainloop. The 238 | * event loop is run in a helper thread in the background. A few 239 | * synchronization primitives are available to access the objects 240 | * attached to the event loop safely. 241 | * 242 | * See also \subpage threaded_mainloop 243 | */ 244 | 245 | /** An opaque threaded main loop object */ 246 | typedef struct pa_threaded_mainloop pa_threaded_mainloop; 247 | 248 | /** Allocate a new threaded main loop object. You have to call 249 | * pa_threaded_mainloop_start() before the event loop thread starts 250 | * running. */ 251 | pa_threaded_mainloop *pa_threaded_mainloop_new(void); 252 | 253 | /** Free a threaded main loop object. If the event loop thread is 254 | * still running, terminate it with pa_threaded_mainloop_stop() 255 | * first. */ 256 | void pa_threaded_mainloop_free(pa_threaded_mainloop* m); 257 | 258 | /** Start the event loop thread. */ 259 | int pa_threaded_mainloop_start(pa_threaded_mainloop *m); 260 | 261 | /** Terminate the event loop thread cleanly. Make sure to unlock the 262 | * mainloop object before calling this function. */ 263 | void pa_threaded_mainloop_stop(pa_threaded_mainloop *m); 264 | 265 | /** Lock the event loop object, effectively blocking the event loop 266 | * thread from processing events. You can use this to enforce 267 | * exclusive access to all objects attached to the event loop. This 268 | * lock is recursive. This function may not be called inside the event 269 | * loop thread. Events that are dispatched from the event loop thread 270 | * are executed with this lock held. */ 271 | void pa_threaded_mainloop_lock(pa_threaded_mainloop *m); 272 | 273 | /** Unlock the event loop object, inverse of pa_threaded_mainloop_lock(). */ 274 | void pa_threaded_mainloop_unlock(pa_threaded_mainloop *m); 275 | 276 | /** Wait for an event to be signalled by the event loop thread. You 277 | * can use this to pass data from the event loop thread to the main 278 | * thread in a synchronized fashion. This function may not be called 279 | * inside the event loop thread. Prior to this call the event loop 280 | * object needs to be locked using pa_threaded_mainloop_lock(). While 281 | * waiting the lock will be released. Immediately before returning it 282 | * will be acquired again. This function may spuriously wake up even 283 | * without pa_threaded_mainloop_signal() being called. You need to 284 | * make sure to handle that! */ 285 | void pa_threaded_mainloop_wait(pa_threaded_mainloop *m); 286 | 287 | /** Signal all threads waiting for a signalling event in 288 | * pa_threaded_mainloop_wait(). If wait_for_accept is non-zero, do 289 | * not return before the signal was accepted by a 290 | * pa_threaded_mainloop_accept() call. While waiting for that condition 291 | * the event loop object is unlocked. */ 292 | void pa_threaded_mainloop_signal(pa_threaded_mainloop *m, int wait_for_accept); 293 | 294 | /** Accept a signal from the event thread issued with 295 | * pa_threaded_mainloop_signal(). This call should only be used in 296 | * conjunction with pa_threaded_mainloop_signal() with a non-zero 297 | * wait_for_accept value. */ 298 | void pa_threaded_mainloop_accept(pa_threaded_mainloop *m); 299 | 300 | /** Return the return value as specified with the main loop's 301 | * pa_mainloop_quit() routine. */ 302 | int pa_threaded_mainloop_get_retval(pa_threaded_mainloop *m); 303 | 304 | /** Return the main loop abstraction layer vtable for this main loop. 305 | * There is no need to free this object as it is owned by the loop 306 | * and is destroyed when the loop is freed. */ 307 | pa_mainloop_api* pa_threaded_mainloop_get_api(pa_threaded_mainloop*m); 308 | 309 | /** Returns non-zero when called from within the event loop thread. \since 0.9.7 */ 310 | int pa_threaded_mainloop_in_thread(pa_threaded_mainloop *m); 311 | 312 | /** Sets the name of the thread. \since 5.0 */ 313 | void pa_threaded_mainloop_set_name(pa_threaded_mainloop *m, const char *name); 314 | 315 | PA_C_DECL_END 316 | 317 | #endif 318 | -------------------------------------------------------------------------------- /vendor/pulse/timeval.h: -------------------------------------------------------------------------------- 1 | #ifndef footimevalhfoo 2 | #define footimevalhfoo 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 | #include 26 | #include 27 | #include 28 | 29 | /** \file 30 | * Utility functions for handling timeval calculations */ 31 | 32 | PA_C_DECL_BEGIN 33 | 34 | /** The number of milliseconds in a second */ 35 | #define PA_MSEC_PER_SEC ((pa_usec_t) 1000ULL) 36 | 37 | /** The number of microseconds in a second */ 38 | #define PA_USEC_PER_SEC ((pa_usec_t) 1000000ULL) 39 | 40 | /** The number of nanoseconds in a second */ 41 | #define PA_NSEC_PER_SEC ((unsigned long long) 1000000000ULL) 42 | 43 | /** The number of microseconds in a millisecond */ 44 | #define PA_USEC_PER_MSEC ((pa_usec_t) 1000ULL) 45 | 46 | /** The number of nanoseconds in a millisecond */ 47 | #define PA_NSEC_PER_MSEC ((unsigned long long) 1000000ULL) 48 | 49 | /** The number of nanoseconds in a microsecond */ 50 | #define PA_NSEC_PER_USEC ((unsigned long long) 1000ULL) 51 | 52 | /** Invalid time in usec. \since 0.9.15 */ 53 | #define PA_USEC_INVALID ((pa_usec_t) -1) 54 | 55 | /** Biggest time in usec. \since 0.9.18 */ 56 | #define PA_USEC_MAX ((pa_usec_t) -2) 57 | 58 | struct timeval; 59 | 60 | /** Return the current wallclock timestamp, just like UNIX gettimeofday(). */ 61 | struct timeval *pa_gettimeofday(struct timeval *tv); 62 | 63 | /** Calculate the difference between the two specified timeval 64 | * structs. */ 65 | pa_usec_t pa_timeval_diff(const struct timeval *a, const struct timeval *b) PA_GCC_PURE; 66 | 67 | /** Compare the two timeval structs and return 0 when equal, negative when a < b, positive otherwise */ 68 | int pa_timeval_cmp(const struct timeval *a, const struct timeval *b) PA_GCC_PURE; 69 | 70 | /** Return the time difference between now and the specified timestamp */ 71 | pa_usec_t pa_timeval_age(const struct timeval *tv); 72 | 73 | /** Add the specified time in microseconds to the specified timeval structure */ 74 | struct timeval* pa_timeval_add(struct timeval *tv, pa_usec_t v); 75 | 76 | /** Subtract the specified time in microseconds to the specified timeval structure. \since 0.9.11 */ 77 | struct timeval* pa_timeval_sub(struct timeval *tv, pa_usec_t v); 78 | 79 | /** Store the specified usec value in the timeval struct. \since 0.9.7 */ 80 | struct timeval* pa_timeval_store(struct timeval *tv, pa_usec_t v); 81 | 82 | /** Load the specified tv value and return it in usec. \since 0.9.7 */ 83 | pa_usec_t pa_timeval_load(const struct timeval *tv); 84 | 85 | PA_C_DECL_END 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /vendor/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 | -------------------------------------------------------------------------------- /vendor/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 | PA_C_DECL_END 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /vendor/pulse/version.h: -------------------------------------------------------------------------------- 1 | #ifndef fooversionhfoo /*-*-C-*-*/ 2 | #define fooversionhfoo 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 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 | /* WARNING: Make sure to edit the real source file version.h.in! */ 25 | 26 | #include 27 | 28 | /** \file 29 | * Define header version */ 30 | 31 | PA_C_DECL_BEGIN 32 | 33 | /** Return the version of the header files. Keep in mind that this is 34 | a macro and not a function, so it is impossible to get the pointer of 35 | it. */ 36 | #define pa_get_headers_version() ("6.0.0") 37 | 38 | /** Return the version of the library the current application is 39 | * linked to. */ 40 | const char* pa_get_library_version(void); 41 | 42 | /** The current API version. Version 6 relates to Polypaudio 43 | * 0.6. Prior versions (i.e. Polypaudio 0.5.1 and older) have 44 | * PA_API_VERSION undefined. Please note that this is only ever 45 | * increased on incompatible API changes! */ 46 | #define PA_API_VERSION 12 47 | 48 | /** The current protocol version. Version 8 relates to Polypaudio 49 | * 0.8/PulseAudio 0.9. */ 50 | #define PA_PROTOCOL_VERSION 30 51 | 52 | /** The major version of PA. \since 0.9.15 */ 53 | #define PA_MAJOR 6 54 | 55 | /** The minor version of PA. \since 0.9.15 */ 56 | #define PA_MINOR 0 57 | 58 | /** The micro version of PA (will always be 0 from v1.0 onwards). \since 0.9.15 */ 59 | #define PA_MICRO 0 60 | 61 | /** Evaluates to TRUE if the PulseAudio library version is equal or 62 | * newer than the specified. \since 0.9.16 */ 63 | #define PA_CHECK_VERSION(major,minor,micro) \ 64 | ((PA_MAJOR > (major)) || \ 65 | (PA_MAJOR == (major) && PA_MINOR > (minor)) || \ 66 | (PA_MAJOR == (major) && PA_MINOR == (minor) && PA_MICRO >= (micro))) 67 | 68 | PA_C_DECL_END 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /vendor/pulse/volume.h: -------------------------------------------------------------------------------- 1 | #ifndef foovolumehfoo 2 | #define foovolumehfoo 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 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | /** \page volume Volume Control 34 | * 35 | * \section overv_sec Overview 36 | * 37 | * Sinks, sources, sink inputs and samples can all have their own volumes. 38 | * To deal with these, The PulseAudio library contains a number of functions 39 | * that ease handling. 40 | * 41 | * The basic volume type in PulseAudio is the \ref pa_volume_t type. Most of 42 | * the time, applications will use the aggregated pa_cvolume structure that 43 | * can store the volume of all channels at once. 44 | * 45 | * Volumes commonly span between muted (0%), and normal (100%). It is possible 46 | * to set volumes to higher than 100%, but clipping might occur. 47 | * 48 | * There is no single well-defined meaning attached to the 100% volume for a 49 | * sink input. In fact, it depends on the server configuration. With flat 50 | * volumes enabled (the default in most Linux distributions), it means the 51 | * maximum volume that the sound hardware is capable of, which is usually so 52 | * high that you absolutely must not set sink input volume to 100% unless the 53 | * the user explicitly requests that (note that usually you shouldn't set the 54 | * volume anyway if the user doesn't explicitly request it, instead, let 55 | * PulseAudio decide the volume for the sink input). With flat volumes disabled 56 | * (the default in Ubuntu), the sink input volume is relative to the sink 57 | * volume, so 100% sink input volume means that the sink input is played at the 58 | * current sink volume level. In this case 100% is often a good default volume 59 | * for a sink input, although you still should let PulseAudio decide the 60 | * default volume. It is possible to figure out whether flat volume mode is in 61 | * effect for a given sink by calling pa_context_get_sink_info_by_name(). 62 | * 63 | * \section calc_sec Calculations 64 | * 65 | * The volumes in PulseAudio are logarithmic in nature and applications 66 | * shouldn't perform calculations with them directly. Instead, they should 67 | * be converted to and from either dB or a linear scale: 68 | * 69 | * \li dB - pa_sw_volume_from_dB() / pa_sw_volume_to_dB() 70 | * \li Linear - pa_sw_volume_from_linear() / pa_sw_volume_to_linear() 71 | * 72 | * For simple multiplication, pa_sw_volume_multiply() and 73 | * pa_sw_cvolume_multiply() can be used. 74 | * 75 | * Calculations can only be reliably performed on software volumes 76 | * as it is commonly unknown what scale hardware volumes relate to. 77 | * 78 | * The functions described above are only valid when used with 79 | * software volumes. Hence it is usually a better idea to treat all 80 | * volume values as opaque with a range from PA_VOLUME_MUTED (0%) to 81 | * PA_VOLUME_NORM (100%) and to refrain from any calculations with 82 | * them. 83 | * 84 | * \section conv_sec Convenience Functions 85 | * 86 | * To handle the pa_cvolume structure, the PulseAudio library provides a 87 | * number of convenience functions: 88 | * 89 | * \li pa_cvolume_valid() - Tests if a pa_cvolume structure is valid. 90 | * \li pa_cvolume_equal() - Tests if two pa_cvolume structures are identical. 91 | * \li pa_cvolume_channels_equal_to() - Tests if all channels of a pa_cvolume 92 | * structure have a given volume. 93 | * \li pa_cvolume_is_muted() - Tests if all channels of a pa_cvolume 94 | * structure are muted. 95 | * \li pa_cvolume_is_norm() - Tests if all channels of a pa_cvolume structure 96 | * are at a normal volume. 97 | * \li pa_cvolume_set() - Set the first n channels of a pa_cvolume structure to 98 | * a certain volume. 99 | * \li pa_cvolume_reset() - Set the first n channels of a pa_cvolume structure 100 | * to a normal volume. 101 | * \li pa_cvolume_mute() - Set the first n channels of a pa_cvolume structure 102 | * to a muted volume. 103 | * \li pa_cvolume_avg() - Return the average volume of all channels. 104 | * \li pa_cvolume_snprint() - Pretty print a pa_cvolume structure. 105 | */ 106 | 107 | /** \file 108 | * Constants and routines for volume handling 109 | * 110 | * See also \subpage volume 111 | */ 112 | 113 | PA_C_DECL_BEGIN 114 | 115 | /** Volume specification: 116 | * PA_VOLUME_MUTED: silence; 117 | * < PA_VOLUME_NORM: decreased volume; 118 | * PA_VOLUME_NORM: normal volume; 119 | * > PA_VOLUME_NORM: increased volume */ 120 | typedef uint32_t pa_volume_t; 121 | 122 | /** Normal volume (100%, 0 dB) */ 123 | #define PA_VOLUME_NORM ((pa_volume_t) 0x10000U) 124 | 125 | /** Muted (minimal valid) volume (0%, -inf dB) */ 126 | #define PA_VOLUME_MUTED ((pa_volume_t) 0U) 127 | 128 | /** Maximum valid volume we can store. \since 0.9.15 */ 129 | #define PA_VOLUME_MAX ((pa_volume_t) UINT32_MAX/2) 130 | 131 | /** Recommended maximum volume to show in user facing UIs. 132 | * Note: UIs should deal gracefully with volumes greater than this value 133 | * and not cause feedback loops etc. - i.e. if the volume is more than 134 | * this, the UI should not limit it and push the limited value back to 135 | * the server. \since 0.9.23 */ 136 | #define PA_VOLUME_UI_MAX (pa_sw_volume_from_dB(+11.0)) 137 | 138 | /** Special 'invalid' volume. \since 0.9.16 */ 139 | #define PA_VOLUME_INVALID ((pa_volume_t) UINT32_MAX) 140 | 141 | /** Check if volume is valid. \since 1.0 */ 142 | #define PA_VOLUME_IS_VALID(v) ((v) <= PA_VOLUME_MAX) 143 | 144 | /** Clamp volume to the permitted range. \since 1.0 */ 145 | #define PA_CLAMP_VOLUME(v) (PA_CLAMP_UNLIKELY((v), PA_VOLUME_MUTED, PA_VOLUME_MAX)) 146 | 147 | /** A structure encapsulating a per-channel volume */ 148 | typedef struct pa_cvolume { 149 | uint8_t channels; /**< Number of channels */ 150 | pa_volume_t values[PA_CHANNELS_MAX]; /**< Per-channel volume */ 151 | } pa_cvolume; 152 | 153 | /** Return non-zero when *a == *b */ 154 | int pa_cvolume_equal(const pa_cvolume *a, const pa_cvolume *b) PA_GCC_PURE; 155 | 156 | /** Initialize the specified volume and return a pointer to 157 | * it. The sample spec will have a defined state but 158 | * pa_cvolume_valid() will fail for it. \since 0.9.13 */ 159 | pa_cvolume* pa_cvolume_init(pa_cvolume *a); 160 | 161 | /** Set the volume of the first n channels to PA_VOLUME_NORM */ 162 | #define pa_cvolume_reset(a, n) pa_cvolume_set((a), (n), PA_VOLUME_NORM) 163 | 164 | /** Set the volume of the first n channels to PA_VOLUME_MUTED */ 165 | #define pa_cvolume_mute(a, n) pa_cvolume_set((a), (n), PA_VOLUME_MUTED) 166 | 167 | /** Set the volume of the specified number of channels to the volume v */ 168 | pa_cvolume* pa_cvolume_set(pa_cvolume *a, unsigned channels, pa_volume_t v); 169 | 170 | /** Maximum length of the strings returned by 171 | * pa_cvolume_snprint(). Please note that this value can change with 172 | * any release without warning and without being considered API or ABI 173 | * breakage. You should not use this definition anywhere where it 174 | * might become part of an ABI.*/ 175 | #define PA_CVOLUME_SNPRINT_MAX 320 176 | 177 | /** Pretty print a volume structure */ 178 | char *pa_cvolume_snprint(char *s, size_t l, const pa_cvolume *c); 179 | 180 | /** Maximum length of the strings returned by 181 | * pa_sw_cvolume_snprint_dB(). Please note that this value can change with 182 | * any release without warning and without being considered API or ABI 183 | * breakage. You should not use this definition anywhere where it 184 | * might become part of an ABI. \since 0.9.13 */ 185 | #define PA_SW_CVOLUME_SNPRINT_DB_MAX 448 186 | 187 | /** Pretty print a volume structure but show dB values. \since 0.9.13 */ 188 | char *pa_sw_cvolume_snprint_dB(char *s, size_t l, const pa_cvolume *c); 189 | 190 | /** Maximum length of the strings returned by pa_cvolume_snprint_verbose(). 191 | * Please note that this value can change with any release without warning and 192 | * without being considered API or ABI breakage. You should not use this 193 | * definition anywhere where it might become part of an ABI. \since 5.0 */ 194 | #define PA_CVOLUME_SNPRINT_VERBOSE_MAX 1984 195 | 196 | /** Pretty print a volume structure in a verbose way. The volume for each 197 | * channel is printed in several formats: the raw pa_volume_t value, 198 | * percentage, and if print_dB is non-zero, also the dB value. If map is not 199 | * NULL, the channel names will be printed. \since 5.0 */ 200 | char *pa_cvolume_snprint_verbose(char *s, size_t l, const pa_cvolume *c, const pa_channel_map *map, int print_dB); 201 | 202 | /** Maximum length of the strings returned by 203 | * pa_volume_snprint(). Please note that this value can change with 204 | * any release without warning and without being considered API or ABI 205 | * breakage. You should not use this definition anywhere where it 206 | * might become part of an ABI. \since 0.9.15 */ 207 | #define PA_VOLUME_SNPRINT_MAX 10 208 | 209 | /** Pretty print a volume \since 0.9.15 */ 210 | char *pa_volume_snprint(char *s, size_t l, pa_volume_t v); 211 | 212 | /** Maximum length of the strings returned by 213 | * pa_sw_volume_snprint_dB(). Please note that this value can change with 214 | * any release without warning and without being considered API or ABI 215 | * breakage. You should not use this definition anywhere where it 216 | * might become part of an ABI. \since 0.9.15 */ 217 | #define PA_SW_VOLUME_SNPRINT_DB_MAX 11 218 | 219 | /** Pretty print a volume but show dB values. \since 0.9.15 */ 220 | char *pa_sw_volume_snprint_dB(char *s, size_t l, pa_volume_t v); 221 | 222 | /** Maximum length of the strings returned by pa_volume_snprint_verbose(). 223 | * Please note that this value can change with any release without warning and 224 | * withou being considered API or ABI breakage. You should not use this 225 | * definition anywhere where it might become part of an ABI. \since 5.0 */ 226 | #define PA_VOLUME_SNPRINT_VERBOSE_MAX 35 227 | 228 | /** Pretty print a volume in a verbose way. The volume is printed in several 229 | * formats: the raw pa_volume_t value, percentage, and if print_dB is non-zero, 230 | * also the dB value. \since 5.0 */ 231 | char *pa_volume_snprint_verbose(char *s, size_t l, pa_volume_t v, int print_dB); 232 | 233 | /** Return the average volume of all channels */ 234 | pa_volume_t pa_cvolume_avg(const pa_cvolume *a) PA_GCC_PURE; 235 | 236 | /** Return the average volume of all channels that are included in the 237 | * specified channel map with the specified channel position mask. If 238 | * cm is NULL this call is identical to pa_cvolume_avg(). If no 239 | * channel is selected the returned value will be 240 | * PA_VOLUME_MUTED. \since 0.9.16 */ 241 | pa_volume_t pa_cvolume_avg_mask(const pa_cvolume *a, const pa_channel_map *cm, pa_channel_position_mask_t mask) PA_GCC_PURE; 242 | 243 | /** Return the maximum volume of all channels. \since 0.9.12 */ 244 | pa_volume_t pa_cvolume_max(const pa_cvolume *a) PA_GCC_PURE; 245 | 246 | /** Return the maximum volume of all channels that are included in the 247 | * specified channel map with the specified channel position mask. If 248 | * cm is NULL this call is identical to pa_cvolume_max(). If no 249 | * channel is selected the returned value will be PA_VOLUME_MUTED. 250 | * \since 0.9.16 */ 251 | pa_volume_t pa_cvolume_max_mask(const pa_cvolume *a, const pa_channel_map *cm, pa_channel_position_mask_t mask) PA_GCC_PURE; 252 | 253 | /** Return the minimum volume of all channels. \since 0.9.16 */ 254 | pa_volume_t pa_cvolume_min(const pa_cvolume *a) PA_GCC_PURE; 255 | 256 | /** Return the minimum volume of all channels that are included in the 257 | * specified channel map with the specified channel position mask. If 258 | * cm is NULL this call is identical to pa_cvolume_min(). If no 259 | * channel is selected the returned value will be PA_VOLUME_MUTED. 260 | * \since 0.9.16 */ 261 | pa_volume_t pa_cvolume_min_mask(const pa_cvolume *a, const pa_channel_map *cm, pa_channel_position_mask_t mask) PA_GCC_PURE; 262 | 263 | /** Return non-zero when the passed cvolume structure is valid */ 264 | int pa_cvolume_valid(const pa_cvolume *v) PA_GCC_PURE; 265 | 266 | /** Return non-zero if the volume of all channels is equal to the specified value */ 267 | int pa_cvolume_channels_equal_to(const pa_cvolume *a, pa_volume_t v) PA_GCC_PURE; 268 | 269 | /** Return 1 if the specified volume has all channels muted */ 270 | #define pa_cvolume_is_muted(a) pa_cvolume_channels_equal_to((a), PA_VOLUME_MUTED) 271 | 272 | /** Return 1 if the specified volume has all channels on normal level */ 273 | #define pa_cvolume_is_norm(a) pa_cvolume_channels_equal_to((a), PA_VOLUME_NORM) 274 | 275 | /** Multiply two volume specifications, return the result. This uses 276 | * PA_VOLUME_NORM as neutral element of multiplication. This is only 277 | * valid for software volumes! */ 278 | pa_volume_t pa_sw_volume_multiply(pa_volume_t a, pa_volume_t b) PA_GCC_CONST; 279 | 280 | /** Multiply two per-channel volumes and return the result in 281 | * *dest. This is only valid for software volumes! a, b and dest may 282 | * point to the same structure. */ 283 | pa_cvolume *pa_sw_cvolume_multiply(pa_cvolume *dest, const pa_cvolume *a, const pa_cvolume *b); 284 | 285 | /** Multiply a per-channel volume with a scalar volume and return the 286 | * result in *dest. This is only valid for software volumes! a 287 | * and dest may point to the same structure. \since 288 | * 0.9.16 */ 289 | pa_cvolume *pa_sw_cvolume_multiply_scalar(pa_cvolume *dest, const pa_cvolume *a, pa_volume_t b); 290 | 291 | /** Divide two volume specifications, return the result. This uses 292 | * PA_VOLUME_NORM as neutral element of division. This is only valid 293 | * for software volumes! If a division by zero is tried the result 294 | * will be 0. \since 0.9.13 */ 295 | pa_volume_t pa_sw_volume_divide(pa_volume_t a, pa_volume_t b) PA_GCC_CONST; 296 | 297 | /** Divide two per-channel volumes and return the result in 298 | * *dest. This is only valid for software volumes! a, b 299 | * and dest may point to the same structure. \since 0.9.13 */ 300 | pa_cvolume *pa_sw_cvolume_divide(pa_cvolume *dest, const pa_cvolume *a, const pa_cvolume *b); 301 | 302 | /** Divide a per-channel volume by a scalar volume and return the 303 | * result in *dest. This is only valid for software volumes! a 304 | * and dest may point to the same structure. \since 305 | * 0.9.16 */ 306 | pa_cvolume *pa_sw_cvolume_divide_scalar(pa_cvolume *dest, const pa_cvolume *a, pa_volume_t b); 307 | 308 | /** Convert a decibel value to a volume (amplitude, not power). This is only valid for software volumes! */ 309 | pa_volume_t pa_sw_volume_from_dB(double f) PA_GCC_CONST; 310 | 311 | /** Convert a volume to a decibel value (amplitude, not power). This is only valid for software volumes! */ 312 | double pa_sw_volume_to_dB(pa_volume_t v) PA_GCC_CONST; 313 | 314 | /** Convert a linear factor to a volume. 0.0 and less is muted while 315 | * 1.0 is PA_VOLUME_NORM. This is only valid for software volumes! */ 316 | pa_volume_t pa_sw_volume_from_linear(double v) PA_GCC_CONST; 317 | 318 | /** Convert a volume to a linear factor. This is only valid for software volumes! */ 319 | double pa_sw_volume_to_linear(pa_volume_t v) PA_GCC_CONST; 320 | 321 | #ifdef INFINITY 322 | #define PA_DECIBEL_MININFTY ((double) -INFINITY) 323 | #else 324 | /** This floor value is used as minus infinity when using pa_sw_volume_to_dB() / pa_sw_volume_from_dB(). */ 325 | #define PA_DECIBEL_MININFTY ((double) -200.0) 326 | #endif 327 | 328 | /** Remap a volume from one channel mapping to a different channel mapping. \since 0.9.12 */ 329 | pa_cvolume *pa_cvolume_remap(pa_cvolume *v, const pa_channel_map *from, const pa_channel_map *to); 330 | 331 | /** Return non-zero if the specified volume is compatible with the 332 | * specified sample spec. \since 0.9.13 */ 333 | int pa_cvolume_compatible(const pa_cvolume *v, const pa_sample_spec *ss) PA_GCC_PURE; 334 | 335 | /** Return non-zero if the specified volume is compatible with the 336 | * specified sample spec. \since 0.9.15 */ 337 | int pa_cvolume_compatible_with_channel_map(const pa_cvolume *v, const pa_channel_map *cm) PA_GCC_PURE; 338 | 339 | /** Calculate a 'balance' value for the specified volume with the 340 | * specified channel map. The return value will range from -1.0f 341 | * (left) to +1.0f (right). If no balance value is applicable to this 342 | * channel map the return value will always be 0.0f. See 343 | * pa_channel_map_can_balance(). \since 0.9.15 */ 344 | float pa_cvolume_get_balance(const pa_cvolume *v, const pa_channel_map *map) PA_GCC_PURE; 345 | 346 | /** Adjust the 'balance' value for the specified volume with the 347 | * specified channel map. v will be modified in place and 348 | * returned. The balance is a value between -1.0f and +1.0f. This 349 | * operation might not be reversible! Also, after this call 350 | * pa_cvolume_get_balance() is not guaranteed to actually return the 351 | * requested balance value (e.g. when the input volume was zero anyway for 352 | * all channels). If no balance value is applicable to 353 | * this channel map the volume will not be modified. See 354 | * pa_channel_map_can_balance(). \since 0.9.15 */ 355 | pa_cvolume* pa_cvolume_set_balance(pa_cvolume *v, const pa_channel_map *map, float new_balance); 356 | 357 | /** Calculate a 'fade' value (i.e.\ 'balance' between front and rear) 358 | * for the specified volume with the specified channel map. The return 359 | * value will range from -1.0f (rear) to +1.0f (left). If no fade 360 | * value is applicable to this channel map the return value will 361 | * always be 0.0f. See pa_channel_map_can_fade(). \since 0.9.15 */ 362 | float pa_cvolume_get_fade(const pa_cvolume *v, const pa_channel_map *map) PA_GCC_PURE; 363 | 364 | /** Adjust the 'fade' value (i.e.\ 'balance' between front and rear) 365 | * for the specified volume with the specified channel map. v will be 366 | * modified in place and returned. The balance is a value between 367 | * -1.0f and +1.0f. This operation might not be reversible! Also, 368 | * after this call pa_cvolume_get_fade() is not guaranteed to actually 369 | * return the requested fade value (e.g. when the input volume was 370 | * zero anyway for all channels). If no fade value is applicable to 371 | * this channel map the volume will not be modified. See 372 | * pa_channel_map_can_fade(). \since 0.9.15 */ 373 | pa_cvolume* pa_cvolume_set_fade(pa_cvolume *v, const pa_channel_map *map, float new_fade); 374 | 375 | /** Scale the passed pa_cvolume structure so that the maximum volume 376 | * of all channels equals max. The proportions between the channel 377 | * volumes are kept. \since 0.9.15 */ 378 | pa_cvolume* pa_cvolume_scale(pa_cvolume *v, pa_volume_t max); 379 | 380 | /** Scale the passed pa_cvolume structure so that the maximum volume 381 | * of all channels selected via cm/mask equals max. This also modifies 382 | * the volume of those channels that are unmasked. The proportions 383 | * between the channel volumes are kept. \since 0.9.16 */ 384 | pa_cvolume* pa_cvolume_scale_mask(pa_cvolume *v, pa_volume_t max, pa_channel_map *cm, pa_channel_position_mask_t mask); 385 | 386 | /** Set the passed volume to all channels at the specified channel 387 | * position. Will return the updated volume struct, or NULL if there 388 | * is no channel at the position specified. You can check if a channel 389 | * map includes a specific position by calling 390 | * pa_channel_map_has_position(). \since 0.9.16 */ 391 | pa_cvolume* pa_cvolume_set_position(pa_cvolume *cv, const pa_channel_map *map, pa_channel_position_t t, pa_volume_t v); 392 | 393 | /** Get the maximum volume of all channels at the specified channel 394 | * position. Will return 0 if there is no channel at the position 395 | * specified. You can check if a channel map includes a specific 396 | * position by calling pa_channel_map_has_position(). \since 0.9.16 */ 397 | pa_volume_t pa_cvolume_get_position(pa_cvolume *cv, const pa_channel_map *map, pa_channel_position_t t) PA_GCC_PURE; 398 | 399 | /** This goes through all channels in a and b and sets the 400 | * corresponding channel in dest to the greater volume of both. a, b 401 | * and dest may point to the same structure. \since 0.9.16 */ 402 | pa_cvolume* pa_cvolume_merge(pa_cvolume *dest, const pa_cvolume *a, const pa_cvolume *b); 403 | 404 | /** Increase the volume passed in by 'inc', but not exceeding 'limit'. 405 | * The proportions between the channels are kept. \since 0.9.19 */ 406 | pa_cvolume* pa_cvolume_inc_clamp(pa_cvolume *v, pa_volume_t inc, pa_volume_t limit); 407 | 408 | /** Increase the volume passed in by 'inc'. The proportions between 409 | * the channels are kept. \since 0.9.16 */ 410 | pa_cvolume* pa_cvolume_inc(pa_cvolume *v, pa_volume_t inc); 411 | 412 | /** Decrease the volume passed in by 'dec'. The proportions between 413 | * the channels are kept. \since 0.9.16 */ 414 | pa_cvolume* pa_cvolume_dec(pa_cvolume *v, pa_volume_t dec); 415 | 416 | PA_C_DECL_END 417 | 418 | #endif 419 | -------------------------------------------------------------------------------- /vendor/pulse/xmalloc.h: -------------------------------------------------------------------------------- 1 | #ifndef foomemoryhfoo 2 | #define foomemoryhfoo 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 | #include 29 | #include 30 | #include 31 | 32 | /** \file 33 | * Memory allocation functions. 34 | */ 35 | 36 | PA_C_DECL_BEGIN 37 | 38 | /** Allocate the specified number of bytes, just like malloc() does. However, in case of OOM, terminate */ 39 | void* pa_xmalloc(size_t l) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE(1); 40 | 41 | /** Same as pa_xmalloc(), but initialize allocated memory to 0 */ 42 | void *pa_xmalloc0(size_t l) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE(1); 43 | 44 | /** The combination of pa_xmalloc() and realloc() */ 45 | void *pa_xrealloc(void *ptr, size_t size) PA_GCC_ALLOC_SIZE(2); 46 | 47 | /** Free allocated memory */ 48 | void pa_xfree(void *p); 49 | 50 | /** Duplicate the specified string, allocating memory with pa_xmalloc() */ 51 | char *pa_xstrdup(const char *s) PA_GCC_MALLOC; 52 | 53 | /** Duplicate the specified string, but truncate after l characters */ 54 | char *pa_xstrndup(const char *s, size_t l) PA_GCC_MALLOC; 55 | 56 | /** Duplicate the specified memory block */ 57 | void* pa_xmemdup(const void *p, size_t l) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE(2); 58 | 59 | /** Internal helper for pa_xnew() */ 60 | static void* _pa_xnew_internal(size_t n, size_t k) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE2(1,2); 61 | 62 | static inline void* _pa_xnew_internal(size_t n, size_t k) { 63 | assert(n < INT_MAX/k); 64 | return pa_xmalloc(n*k); 65 | } 66 | 67 | /** Allocate n new structures of the specified type. */ 68 | #define pa_xnew(type, n) ((type*) _pa_xnew_internal((n), sizeof(type))) 69 | 70 | /** Internal helper for pa_xnew0() */ 71 | static void* _pa_xnew0_internal(size_t n, size_t k) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE2(1,2); 72 | 73 | static inline void* _pa_xnew0_internal(size_t n, size_t k) { 74 | assert(n < INT_MAX/k); 75 | return pa_xmalloc0(n*k); 76 | } 77 | 78 | /** Same as pa_xnew() but set the memory to zero */ 79 | #define pa_xnew0(type, n) ((type*) _pa_xnew0_internal((n), sizeof(type))) 80 | 81 | /** Internal helper for pa_xnew0() */ 82 | static void* _pa_xnewdup_internal(const void *p, size_t n, size_t k) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE2(2,3); 83 | 84 | static inline void* _pa_xnewdup_internal(const void *p, size_t n, size_t k) { 85 | assert(n < INT_MAX/k); 86 | return pa_xmemdup(p, n*k); 87 | } 88 | 89 | /** Same as pa_xnew() but duplicate the specified data */ 90 | #define pa_xnewdup(type, p, n) ((type*) _pa_xnewdup_internal((p), (n), sizeof(type))) 91 | 92 | /** Internal helper for pa_xrenew() */ 93 | static void* _pa_xrenew_internal(void *p, size_t n, size_t k) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE2(2,3); 94 | 95 | static inline void* _pa_xrenew_internal(void *p, size_t n, size_t k) { 96 | assert(n < INT_MAX/k); 97 | return pa_xrealloc(p, n*k); 98 | } 99 | 100 | /** Reallocate n new structures of the specified type. */ 101 | #define pa_xrenew(type, p, n) ((type*) _pa_xrenew_internal(p, (n), sizeof(type))) 102 | 103 | PA_C_DECL_END 104 | 105 | #endif 106 | --------------------------------------------------------------------------------