1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
|
/*
Copyright (C) 2014 by Leonhard Oelke <leonhard@in-verted.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <inttypes.h>
#include <pulse/stream.h>
#include <pulse/context.h>
#include <pulse/introspect.h>
#pragma once
/**
* Initialize the pulseaudio mainloop and increase the reference count
*/
int_fast32_t pulse_init();
/**
* Unreference the pulseaudio mainloop, when the reference count reaches
* zero the mainloop will automatically be destroyed
*/
void pulse_unref();
/**
* Lock the mainloop
*
* In order to allow for multiple threads to use the same mainloop pulseaudio
* provides it's own locking mechanism. This function should be called before
* using any pulseaudio function that is in any way related to the mainloop or
* context.
*
* @note use of this function may cause deadlocks
*
* @warning do not use with pulse_ wrapper functions
*/
void pulse_lock();
/**
* Unlock the mainloop
*
* @see pulse_lock()
*/
void pulse_unlock();
/**
* Wait for events to happen
*
* This function should be called when waiting for an event to happen.
*/
void pulse_wait();
/**
* Wait for accept signal from calling thread
*
* This function tells the pulseaudio mainloop wheter the data provided to
* the callback should be retained until the calling thread executes
* pulse_accept()
*
* If wait_for_accept is 0 the function returns and the data is freed.
*/
void pulse_signal(int wait_for_accept);
/**
* Signal the waiting callback to return
*
* This function is used in conjunction with pulse_signal()
*/
void pulse_accept();
/**
* Request source information
*
* The function will block until the operation was executed and the mainloop
* called the provided callback function.
*
* @return negative on error
*
* @note The function will block until the server context is ready.
*
* @warning call without active locks
*/
int_fast32_t pulse_get_source_info_list(pa_source_info_cb_t cb, void *userdata);
/**
* Request sink information
*
* The function will block until the operation was executed and the mainloop
* called the provided callback function.
*
* @return negative on error
*
* @note The function will block until the server context is ready.
*
* @warning call without active locks
*/
int_fast32_t pulse_get_sink_info_list(pa_sink_info_cb_t cb, void *userdata);
/**
* Request source information from a specific source
*
* The function will block until the operation was executed and the mainloop
* called the provided callback function.
*
* @param cb pointer to the callback function
* @param name the source name to get information for
* @param userdata pointer to userdata the callback will be called with
*
* @return negative on error
*
* @note The function will block until the server context is ready.
*
* @warning call without active locks
*/
int_fast32_t pulse_get_source_info(pa_source_info_cb_t cb, const char *name,
void *userdata);
/**
* Request server information
*
* The function will block until the operation was executed and the mainloop
* called the provided callback function.
*
* @return negative on error
*
* @note The function will block until the server context is ready.
*
* @warning call without active locks
*/
int_fast32_t pulse_get_server_info(pa_server_info_cb_t cb, void *userdata);
/**
* Create a new stream with the default properties
*
* @note The function will block until the server context is ready.
*
* @warning call without active locks
*/
pa_stream *pulse_stream_new(const char *name, const pa_sample_spec *ss,
const pa_channel_map *map);
|