mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-08 13:29:59 -05:00
merge 'lennart' branch back into trunk.
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1971 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
6687dd0131
commit
a67c21f093
294 changed files with 79057 additions and 11614 deletions
|
|
@ -25,7 +25,6 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <avahi-client/lookup.h>
|
||||
|
|
@ -36,8 +35,9 @@
|
|||
|
||||
#include <pulsecore/log.h>
|
||||
#include <pulsecore/core-util.h>
|
||||
|
||||
#include <pulsecore/avahi-wrap.h>
|
||||
#include <pulsecore/refcnt.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
#include "browser.h"
|
||||
|
||||
|
|
@ -46,7 +46,8 @@
|
|||
#define SERVICE_TYPE_SERVER "_pulse-server._tcp."
|
||||
|
||||
struct pa_browser {
|
||||
int ref;
|
||||
PA_REFCNT_DECLARE;
|
||||
|
||||
pa_mainloop_api *mainloop;
|
||||
AvahiPoll* avahi_poll;
|
||||
|
||||
|
|
@ -62,6 +63,7 @@ struct pa_browser {
|
|||
};
|
||||
|
||||
static int map_to_opcode(const char *type, int new) {
|
||||
|
||||
if (avahi_domain_equal(type, SERVICE_TYPE_SINK))
|
||||
return new ? PA_BROWSE_NEW_SINK : PA_BROWSE_REMOVE_SINK;
|
||||
else if (avahi_domain_equal(type, SERVICE_TYPE_SOURCE))
|
||||
|
|
@ -97,7 +99,8 @@ static void resolve_callback(
|
|||
int ss_valid = 0;
|
||||
char *key = NULL, *value = NULL;
|
||||
|
||||
assert(b);
|
||||
pa_assert(b);
|
||||
pa_assert(PA_REFCNT_VALUE(b) >= 1);
|
||||
|
||||
memset(&i, 0, sizeof(i));
|
||||
i.name = name;
|
||||
|
|
@ -109,13 +112,13 @@ static void resolve_callback(
|
|||
goto fail;
|
||||
|
||||
opcode = map_to_opcode(type, 1);
|
||||
assert(opcode >= 0);
|
||||
pa_assert(opcode >= 0);
|
||||
|
||||
if (aa->proto == AVAHI_PROTO_INET)
|
||||
snprintf(a, sizeof(a), "tcp:%s:%u", avahi_address_snprint(ip, sizeof(ip), aa), port);
|
||||
pa_snprintf(a, sizeof(a), "tcp:%s:%u", avahi_address_snprint(ip, sizeof(ip), aa), port);
|
||||
else {
|
||||
assert(aa->proto == AVAHI_PROTO_INET6);
|
||||
snprintf(a, sizeof(a), "tcp6:%s:%u", avahi_address_snprint(ip, sizeof(ip), aa), port);
|
||||
pa_assert(aa->proto == AVAHI_PROTO_INET6);
|
||||
pa_snprintf(a, sizeof(a), "tcp6:%s:%u", avahi_address_snprint(ip, sizeof(ip), aa), port);
|
||||
}
|
||||
i.server = a;
|
||||
|
||||
|
|
@ -146,7 +149,7 @@ static void resolve_callback(
|
|||
value = NULL;
|
||||
|
||||
l = strlen(a);
|
||||
assert(l+1 <= sizeof(a));
|
||||
pa_assert(l+1 <= sizeof(a));
|
||||
strncat(a, " ", sizeof(a)-l-1);
|
||||
strncat(a, i.fqdn, sizeof(a)-l-2);
|
||||
} else if (!strcmp(key, "cookie")) {
|
||||
|
|
@ -211,7 +214,9 @@ fail:
|
|||
|
||||
static void handle_failure(pa_browser *b) {
|
||||
const char *e = NULL;
|
||||
assert(b);
|
||||
|
||||
pa_assert(b);
|
||||
pa_assert(PA_REFCNT_VALUE(b) >= 1);
|
||||
|
||||
if (b->sink_browser)
|
||||
avahi_service_browser_free(b->sink_browser);
|
||||
|
|
@ -245,7 +250,9 @@ static void browse_callback(
|
|||
void *userdata) {
|
||||
|
||||
pa_browser *b = userdata;
|
||||
assert(b);
|
||||
|
||||
pa_assert(b);
|
||||
pa_assert(PA_REFCNT_VALUE(b) >= 1);
|
||||
|
||||
switch (event) {
|
||||
case AVAHI_BROWSER_NEW: {
|
||||
|
|
@ -276,7 +283,7 @@ static void browse_callback(
|
|||
i.name = name;
|
||||
|
||||
opcode = map_to_opcode(type, 0);
|
||||
assert(opcode >= 0);
|
||||
pa_assert(opcode >= 0);
|
||||
|
||||
b->callback(b, opcode, &i, b->userdata);
|
||||
}
|
||||
|
|
@ -295,7 +302,10 @@ static void browse_callback(
|
|||
|
||||
static void client_callback(AvahiClient *s, AvahiClientState state, void *userdata) {
|
||||
pa_browser *b = userdata;
|
||||
assert(s);
|
||||
|
||||
pa_assert(s);
|
||||
pa_assert(b);
|
||||
pa_assert(PA_REFCNT_VALUE(b) >= 1);
|
||||
|
||||
if (state == AVAHI_CLIENT_FAILURE)
|
||||
handle_failure(b);
|
||||
|
|
@ -311,14 +321,14 @@ pa_browser *pa_browser_new_full(pa_mainloop_api *mainloop, pa_browse_flags_t fla
|
|||
pa_browser *b;
|
||||
int error;
|
||||
|
||||
assert(mainloop);
|
||||
pa_assert(mainloop);
|
||||
|
||||
if (flags & ~(PA_BROWSE_FOR_SERVERS|PA_BROWSE_FOR_SINKS|PA_BROWSE_FOR_SOURCES) || flags == 0)
|
||||
return NULL;
|
||||
|
||||
b = pa_xnew(pa_browser, 1);
|
||||
b->mainloop = mainloop;
|
||||
b->ref = 1;
|
||||
PA_REFCNT_INIT(b);
|
||||
b->callback = NULL;
|
||||
b->userdata = NULL;
|
||||
b->error_callback = NULL;
|
||||
|
|
@ -391,7 +401,8 @@ fail:
|
|||
}
|
||||
|
||||
static void browser_free(pa_browser *b) {
|
||||
assert(b && b->mainloop);
|
||||
pa_assert(b);
|
||||
pa_assert(b->mainloop);
|
||||
|
||||
if (b->sink_browser)
|
||||
avahi_service_browser_free(b->sink_browser);
|
||||
|
|
@ -410,29 +421,32 @@ static void browser_free(pa_browser *b) {
|
|||
}
|
||||
|
||||
pa_browser *pa_browser_ref(pa_browser *b) {
|
||||
assert(b);
|
||||
assert(b->ref >= 1);
|
||||
b->ref++;
|
||||
pa_assert(b);
|
||||
pa_assert(PA_REFCNT_VALUE(b) >= 1);
|
||||
|
||||
PA_REFCNT_INC(b);
|
||||
return b;
|
||||
}
|
||||
|
||||
void pa_browser_unref(pa_browser *b) {
|
||||
assert(b);
|
||||
assert(b->ref >= 1);
|
||||
pa_assert(b);
|
||||
pa_assert(PA_REFCNT_VALUE(b) >= 1);
|
||||
|
||||
if ((-- (b->ref)) <= 0)
|
||||
if (PA_REFCNT_DEC(b) <= 0)
|
||||
browser_free(b);
|
||||
}
|
||||
|
||||
void pa_browser_set_callback(pa_browser *b, pa_browse_cb_t cb, void *userdata) {
|
||||
assert(b);
|
||||
pa_assert(b);
|
||||
pa_assert(PA_REFCNT_VALUE(b) >= 1);
|
||||
|
||||
b->callback = cb;
|
||||
b->userdata = userdata;
|
||||
}
|
||||
|
||||
void pa_browser_set_error_callback(pa_browser *b, pa_browser_error_cb_t cb, void *userdata) {
|
||||
assert(b);
|
||||
pa_assert(b);
|
||||
pa_assert(PA_REFCNT_VALUE(b) >= 1);
|
||||
|
||||
b->error_callback = cb;
|
||||
b->error_userdata = userdata;
|
||||
|
|
|
|||
|
|
@ -41,4 +41,22 @@
|
|||
|
||||
#endif
|
||||
|
||||
#ifndef PA_GCC_PURE
|
||||
#ifdef __GNUCC__
|
||||
#define PA_GCC_PURE __attribute__ ((pure))
|
||||
#else
|
||||
/** This function's return value depends only the arguments list and global state **/
|
||||
#define PA_GCC_PURE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef PA_GCC_CONST
|
||||
#ifdef __GNUCC__
|
||||
#define PA_GCC_CONST __attribute__ ((pure))
|
||||
#else
|
||||
/** This function's return value depends only the arguments list (stricter version of PA_GCC_CONST) **/
|
||||
#define PA_GCC_CONST
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -27,12 +27,12 @@
|
|||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <pulse/xmalloc.h>
|
||||
#include <pulsecore/core-util.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
#include "channelmap.h"
|
||||
|
||||
|
|
@ -90,18 +90,81 @@ const char *const table[] = {
|
|||
|
||||
[PA_CHANNEL_POSITION_TOP_CENTER] = "top-center",
|
||||
|
||||
[PA_CHANNEL_POSITION_TOP_FRONT_CENTER] = "top-front-center",
|
||||
[PA_CHANNEL_POSITION_TOP_FRONT_LEFT] = "top-front-left",
|
||||
[PA_CHANNEL_POSITION_TOP_FRONT_RIGHT] = "top-front-right",
|
||||
[PA_CHANNEL_POSITION_TOP_FRONT_CENTER] = "top-front-center",
|
||||
|
||||
[PA_CHANNEL_POSITION_TOP_REAR_CENTER] = "top-rear-center",
|
||||
[PA_CHANNEL_POSITION_TOP_REAR_LEFT] = "top-rear-left",
|
||||
[PA_CHANNEL_POSITION_TOP_REAR_RIGHT] = "top-rear-right",
|
||||
[PA_CHANNEL_POSITION_TOP_REAR_CENTER] = "top-rear-center"
|
||||
[PA_CHANNEL_POSITION_TOP_REAR_RIGHT] = "top-rear-right"
|
||||
};
|
||||
|
||||
const char *const pretty_table[] = {
|
||||
[PA_CHANNEL_POSITION_MONO] = "Mono",
|
||||
|
||||
[PA_CHANNEL_POSITION_FRONT_CENTER] = "Front Center",
|
||||
[PA_CHANNEL_POSITION_FRONT_LEFT] = "Front Left",
|
||||
[PA_CHANNEL_POSITION_FRONT_RIGHT] = "Front Right",
|
||||
|
||||
[PA_CHANNEL_POSITION_REAR_CENTER] = "Rear Center",
|
||||
[PA_CHANNEL_POSITION_REAR_LEFT] = "Rear Left",
|
||||
[PA_CHANNEL_POSITION_REAR_RIGHT] = "Rear Right",
|
||||
|
||||
[PA_CHANNEL_POSITION_LFE] = "Low Frequency Emmiter",
|
||||
|
||||
[PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER] = "Front Left-of-center",
|
||||
[PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER] = "Front Right-of-center",
|
||||
|
||||
[PA_CHANNEL_POSITION_SIDE_LEFT] = "Side Left",
|
||||
[PA_CHANNEL_POSITION_SIDE_RIGHT] = "Side Right",
|
||||
|
||||
[PA_CHANNEL_POSITION_AUX0] = "Auxiliary 0",
|
||||
[PA_CHANNEL_POSITION_AUX1] = "Auxiliary 1",
|
||||
[PA_CHANNEL_POSITION_AUX2] = "Auxiliary 2",
|
||||
[PA_CHANNEL_POSITION_AUX3] = "Auxiliary 3",
|
||||
[PA_CHANNEL_POSITION_AUX4] = "Auxiliary 4",
|
||||
[PA_CHANNEL_POSITION_AUX5] = "Auxiliary 5",
|
||||
[PA_CHANNEL_POSITION_AUX6] = "Auxiliary 6",
|
||||
[PA_CHANNEL_POSITION_AUX7] = "Auxiliary 7",
|
||||
[PA_CHANNEL_POSITION_AUX8] = "Auxiliary 8",
|
||||
[PA_CHANNEL_POSITION_AUX9] = "Auxiliary 9",
|
||||
[PA_CHANNEL_POSITION_AUX10] = "Auxiliary 10",
|
||||
[PA_CHANNEL_POSITION_AUX11] = "Auxiliary 11",
|
||||
[PA_CHANNEL_POSITION_AUX12] = "Auxiliary 12",
|
||||
[PA_CHANNEL_POSITION_AUX13] = "Auxiliary 13",
|
||||
[PA_CHANNEL_POSITION_AUX14] = "Auxiliary 14",
|
||||
[PA_CHANNEL_POSITION_AUX15] = "Auxiliary 15",
|
||||
[PA_CHANNEL_POSITION_AUX16] = "Auxiliary 16",
|
||||
[PA_CHANNEL_POSITION_AUX17] = "Auxiliary 17",
|
||||
[PA_CHANNEL_POSITION_AUX18] = "Auxiliary 18",
|
||||
[PA_CHANNEL_POSITION_AUX19] = "Auxiliary 19",
|
||||
[PA_CHANNEL_POSITION_AUX20] = "Auxiliary 20",
|
||||
[PA_CHANNEL_POSITION_AUX21] = "Auxiliary 21",
|
||||
[PA_CHANNEL_POSITION_AUX22] = "Auxiliary 22",
|
||||
[PA_CHANNEL_POSITION_AUX23] = "Auxiliary 23",
|
||||
[PA_CHANNEL_POSITION_AUX24] = "Auxiliary 24",
|
||||
[PA_CHANNEL_POSITION_AUX25] = "Auxiliary 25",
|
||||
[PA_CHANNEL_POSITION_AUX26] = "Auxiliary 26",
|
||||
[PA_CHANNEL_POSITION_AUX27] = "Auxiliary 27",
|
||||
[PA_CHANNEL_POSITION_AUX28] = "Auxiliary 28",
|
||||
[PA_CHANNEL_POSITION_AUX29] = "Auxiliary 29",
|
||||
[PA_CHANNEL_POSITION_AUX30] = "Auxiliary 30",
|
||||
[PA_CHANNEL_POSITION_AUX31] = "Auxiliary 31",
|
||||
|
||||
[PA_CHANNEL_POSITION_TOP_CENTER] = "Top Center",
|
||||
|
||||
[PA_CHANNEL_POSITION_TOP_FRONT_CENTER] = "Top Front Center",
|
||||
[PA_CHANNEL_POSITION_TOP_FRONT_LEFT] = "Top Front Left",
|
||||
[PA_CHANNEL_POSITION_TOP_FRONT_RIGHT] = "Top Front Right",
|
||||
|
||||
[PA_CHANNEL_POSITION_TOP_REAR_CENTER] = "Top Rear Center",
|
||||
[PA_CHANNEL_POSITION_TOP_REAR_LEFT] = "Top Rear left",
|
||||
[PA_CHANNEL_POSITION_TOP_REAR_RIGHT] = "Top Rear Right"
|
||||
};
|
||||
|
||||
pa_channel_map* pa_channel_map_init(pa_channel_map *m) {
|
||||
unsigned c;
|
||||
assert(m);
|
||||
pa_assert(m);
|
||||
|
||||
m->channels = 0;
|
||||
|
||||
|
|
@ -112,7 +175,7 @@ pa_channel_map* pa_channel_map_init(pa_channel_map *m) {
|
|||
}
|
||||
|
||||
pa_channel_map* pa_channel_map_init_mono(pa_channel_map *m) {
|
||||
assert(m);
|
||||
pa_assert(m);
|
||||
|
||||
pa_channel_map_init(m);
|
||||
|
||||
|
|
@ -122,7 +185,7 @@ pa_channel_map* pa_channel_map_init_mono(pa_channel_map *m) {
|
|||
}
|
||||
|
||||
pa_channel_map* pa_channel_map_init_stereo(pa_channel_map *m) {
|
||||
assert(m);
|
||||
pa_assert(m);
|
||||
|
||||
pa_channel_map_init(m);
|
||||
|
||||
|
|
@ -133,9 +196,9 @@ pa_channel_map* pa_channel_map_init_stereo(pa_channel_map *m) {
|
|||
}
|
||||
|
||||
pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, pa_channel_map_def_t def) {
|
||||
assert(m);
|
||||
assert(channels > 0);
|
||||
assert(channels <= PA_CHANNELS_MAX);
|
||||
pa_assert(m);
|
||||
pa_assert(channels > 0);
|
||||
pa_assert(channels <= PA_CHANNELS_MAX);
|
||||
|
||||
pa_channel_map_init(m);
|
||||
|
||||
|
|
@ -342,11 +405,18 @@ const char* pa_channel_position_to_string(pa_channel_position_t pos) {
|
|||
return table[pos];
|
||||
}
|
||||
|
||||
const char* pa_channel_position_to_pretty_string(pa_channel_position_t pos) {
|
||||
if (pos < 0 || pos >= PA_CHANNEL_POSITION_MAX)
|
||||
return NULL;
|
||||
|
||||
return pretty_table[pos];
|
||||
}
|
||||
|
||||
int pa_channel_map_equal(const pa_channel_map *a, const pa_channel_map *b) {
|
||||
unsigned c;
|
||||
|
||||
assert(a);
|
||||
assert(b);
|
||||
pa_assert(a);
|
||||
pa_assert(b);
|
||||
|
||||
if (a->channels != b->channels)
|
||||
return 0;
|
||||
|
|
@ -363,14 +433,14 @@ char* pa_channel_map_snprint(char *s, size_t l, const pa_channel_map *map) {
|
|||
int first = 1;
|
||||
char *e;
|
||||
|
||||
assert(s);
|
||||
assert(l > 0);
|
||||
assert(map);
|
||||
pa_assert(s);
|
||||
pa_assert(l > 0);
|
||||
pa_assert(map);
|
||||
|
||||
*(e = s) = 0;
|
||||
|
||||
for (channel = 0; channel < map->channels && l > 1; channel++) {
|
||||
l -= snprintf(e, l, "%s%s",
|
||||
l -= pa_snprintf(e, l, "%s%s",
|
||||
first ? "" : ",",
|
||||
pa_channel_position_to_string(map->map[channel]));
|
||||
|
||||
|
|
@ -386,8 +456,8 @@ pa_channel_map *pa_channel_map_parse(pa_channel_map *rmap, const char *s) {
|
|||
pa_channel_map map;
|
||||
char *p;
|
||||
|
||||
assert(rmap);
|
||||
assert(s);
|
||||
pa_assert(rmap);
|
||||
pa_assert(s);
|
||||
|
||||
memset(&map, 0, sizeof(map));
|
||||
|
||||
|
|
@ -447,7 +517,7 @@ finish:
|
|||
int pa_channel_map_valid(const pa_channel_map *map) {
|
||||
unsigned c;
|
||||
|
||||
assert(map);
|
||||
pa_assert(map);
|
||||
|
||||
if (map->channels <= 0 || map->channels > PA_CHANNELS_MAX)
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -172,7 +172,10 @@ pa_channel_map* pa_channel_map_init_stereo(pa_channel_map *m);
|
|||
pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, pa_channel_map_def_t def);
|
||||
|
||||
/** Return a text label for the specified channel position */
|
||||
const char* pa_channel_position_to_string(pa_channel_position_t pos);
|
||||
const char* pa_channel_position_to_string(pa_channel_position_t pos) PA_GCC_PURE;
|
||||
|
||||
/** Return a human readable text label for the specified channel position. \since 0.9.7 */
|
||||
const char* pa_channel_position_to_pretty_string(pa_channel_position_t pos);
|
||||
|
||||
/** The maximum length of strings returned by pa_channel_map_snprint() */
|
||||
#define PA_CHANNEL_MAP_SNPRINT_MAX 336
|
||||
|
|
@ -184,10 +187,10 @@ char* pa_channel_map_snprint(char *s, size_t l, const pa_channel_map *map);
|
|||
pa_channel_map *pa_channel_map_parse(pa_channel_map *map, const char *s);
|
||||
|
||||
/** Compare two channel maps. Return 1 if both match. */
|
||||
int pa_channel_map_equal(const pa_channel_map *a, const pa_channel_map *b);
|
||||
int pa_channel_map_equal(const pa_channel_map *a, const pa_channel_map *b) PA_GCC_PURE;
|
||||
|
||||
/** Return non-zero of the specified channel map is considered valid */
|
||||
int pa_channel_map_valid(const pa_channel_map *map);
|
||||
int pa_channel_map_valid(const pa_channel_map *map) PA_GCC_PURE;
|
||||
|
||||
PA_C_DECL_END
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
|
|
@ -36,6 +35,7 @@
|
|||
#include <pulsecore/x11prop.h>
|
||||
#include <pulsecore/log.h>
|
||||
#include <pulsecore/core-util.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
#include "client-conf-x11.h"
|
||||
|
||||
|
|
@ -44,6 +44,8 @@ int pa_client_conf_from_x11(pa_client_conf *c, const char *dname) {
|
|||
int ret = -1;
|
||||
char t[1024];
|
||||
|
||||
pa_assert(c);
|
||||
|
||||
if (!dname && (!(dname = getenv("DISPLAY")) || *dname == '\0'))
|
||||
goto finish;
|
||||
|
||||
|
|
@ -75,7 +77,7 @@ int pa_client_conf_from_x11(pa_client_conf *c, const char *dname) {
|
|||
goto finish;
|
||||
}
|
||||
|
||||
assert(sizeof(cookie) == sizeof(c->cookie));
|
||||
pa_assert(sizeof(cookie) == sizeof(c->cookie));
|
||||
memcpy(c->cookie, cookie, sizeof(cookie));
|
||||
|
||||
c->cookie_valid = 1;
|
||||
|
|
|
|||
|
|
@ -27,14 +27,14 @@
|
|||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <pulsecore/core-error.h>
|
||||
#include <pulse/xmalloc.h>
|
||||
|
||||
#include <pulsecore/macro.h>
|
||||
#include <pulsecore/core-error.h>
|
||||
#include <pulsecore/log.h>
|
||||
#include <pulsecore/conf-parser.h>
|
||||
#include <pulsecore/core-util.h>
|
||||
|
|
@ -42,13 +42,7 @@
|
|||
|
||||
#include "client-conf.h"
|
||||
|
||||
#ifndef OS_IS_WIN32
|
||||
# define PATH_SEP "/"
|
||||
#else
|
||||
# define PATH_SEP "\\"
|
||||
#endif
|
||||
|
||||
#define DEFAULT_CLIENT_CONFIG_FILE PA_DEFAULT_CONFIG_DIR PATH_SEP "client.conf"
|
||||
#define DEFAULT_CLIENT_CONFIG_FILE PA_DEFAULT_CONFIG_DIR PA_PATH_SEP "client.conf"
|
||||
#define DEFAULT_CLIENT_CONFIG_FILE_USER "client.conf"
|
||||
|
||||
#define ENV_CLIENT_CONFIG_FILE "PULSE_CLIENTCONFIG"
|
||||
|
|
@ -81,7 +75,7 @@ pa_client_conf *pa_client_conf_new(void) {
|
|||
}
|
||||
|
||||
void pa_client_conf_free(pa_client_conf *c) {
|
||||
assert(c);
|
||||
pa_assert(c);
|
||||
pa_xfree(c->daemon_binary);
|
||||
pa_xfree(c->extra_arguments);
|
||||
pa_xfree(c->default_sink);
|
||||
|
|
@ -90,6 +84,7 @@ void pa_client_conf_free(pa_client_conf *c) {
|
|||
pa_xfree(c->cookie_file);
|
||||
pa_xfree(c);
|
||||
}
|
||||
|
||||
int pa_client_conf_load(pa_client_conf *c, const char *filename) {
|
||||
FILE *f = NULL;
|
||||
char *fn = NULL;
|
||||
|
|
@ -122,7 +117,7 @@ int pa_client_conf_load(pa_client_conf *c, const char *filename) {
|
|||
pa_open_config_file(DEFAULT_CLIENT_CONFIG_FILE, DEFAULT_CLIENT_CONFIG_FILE_USER, ENV_CLIENT_CONFIG_FILE, &fn, "r");
|
||||
|
||||
if (!f && errno != EINTR) {
|
||||
pa_log("WARNING: failed to open configuration file '%s': %s", fn, pa_cstrerror(errno));
|
||||
pa_log_warn("Failed to open configuration file '%s': %s", fn, pa_cstrerror(errno));
|
||||
goto finish;
|
||||
}
|
||||
|
||||
|
|
@ -175,7 +170,7 @@ int pa_client_conf_env(pa_client_conf *c) {
|
|||
}
|
||||
|
||||
int pa_client_conf_load_cookie(pa_client_conf* c) {
|
||||
assert(c);
|
||||
pa_assert(c);
|
||||
|
||||
c->cookie_valid = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
|
@ -67,6 +66,7 @@
|
|||
#include <pulsecore/log.h>
|
||||
#include <pulsecore/socket-util.h>
|
||||
#include <pulsecore/creds.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ static const pa_pdispatch_cb_t command_table[PA_COMMAND_MAX] = {
|
|||
};
|
||||
|
||||
static void unlock_autospawn_lock_file(pa_context *c) {
|
||||
assert(c);
|
||||
pa_assert(c);
|
||||
|
||||
if (c->autospawn_lock_fd >= 0) {
|
||||
char lf[PATH_MAX];
|
||||
|
|
@ -106,11 +106,11 @@ static void context_free(pa_context *c);
|
|||
pa_context *pa_context_new(pa_mainloop_api *mainloop, const char *name) {
|
||||
pa_context *c;
|
||||
|
||||
assert(mainloop);
|
||||
assert(name);
|
||||
pa_assert(mainloop);
|
||||
pa_assert(name);
|
||||
|
||||
c = pa_xnew(pa_context, 1);
|
||||
c->ref = 1;
|
||||
PA_REFCNT_INIT(c);
|
||||
c->name = pa_xstrdup(name);
|
||||
c->mainloop = mainloop;
|
||||
c->client = NULL;
|
||||
|
|
@ -168,7 +168,7 @@ pa_context *pa_context_new(pa_mainloop_api *mainloop, const char *name) {
|
|||
}
|
||||
|
||||
static void context_free(pa_context *c) {
|
||||
assert(c);
|
||||
pa_assert(c);
|
||||
|
||||
unlock_autospawn_lock_file(c);
|
||||
|
||||
|
|
@ -183,7 +183,7 @@ static void context_free(pa_context *c) {
|
|||
if (c->pdispatch)
|
||||
pa_pdispatch_unref(c->pdispatch);
|
||||
if (c->pstream) {
|
||||
pa_pstream_close(c->pstream);
|
||||
pa_pstream_unlink(c->pstream);
|
||||
pa_pstream_unref(c->pstream);
|
||||
}
|
||||
|
||||
|
|
@ -206,24 +206,24 @@ static void context_free(pa_context *c) {
|
|||
}
|
||||
|
||||
pa_context* pa_context_ref(pa_context *c) {
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
c->ref++;
|
||||
PA_REFCNT_INC(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
void pa_context_unref(pa_context *c) {
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
if (--c->ref <= 0)
|
||||
if (PA_REFCNT_DEC(c) <= 0)
|
||||
context_free(c);
|
||||
}
|
||||
|
||||
void pa_context_set_state(pa_context *c, pa_context_state_t st) {
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
if (c->state == st)
|
||||
return;
|
||||
|
|
@ -250,7 +250,7 @@ void pa_context_set_state(pa_context *c, pa_context_state_t st) {
|
|||
c->pdispatch = NULL;
|
||||
|
||||
if (c->pstream) {
|
||||
pa_pstream_close(c->pstream);
|
||||
pa_pstream_unlink(c->pstream);
|
||||
pa_pstream_unref(c->pstream);
|
||||
}
|
||||
c->pstream = NULL;
|
||||
|
|
@ -264,16 +264,16 @@ void pa_context_set_state(pa_context *c, pa_context_state_t st) {
|
|||
}
|
||||
|
||||
void pa_context_fail(pa_context *c, int error) {
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
pa_context_set_error(c, error);
|
||||
pa_context_set_state(c, PA_CONTEXT_FAILED);
|
||||
}
|
||||
|
||||
int pa_context_set_error(pa_context *c, int error) {
|
||||
assert(error >= 0);
|
||||
assert(error < PA_ERR_MAX);
|
||||
pa_assert(error >= 0);
|
||||
pa_assert(error < PA_ERR_MAX);
|
||||
|
||||
if (c)
|
||||
c->error = error;
|
||||
|
|
@ -284,8 +284,8 @@ int pa_context_set_error(pa_context *c, int error) {
|
|||
static void pstream_die_callback(pa_pstream *p, void *userdata) {
|
||||
pa_context *c = userdata;
|
||||
|
||||
assert(p);
|
||||
assert(c);
|
||||
pa_assert(p);
|
||||
pa_assert(c);
|
||||
|
||||
pa_context_fail(c, PA_ERR_CONNECTIONTERMINATED);
|
||||
}
|
||||
|
|
@ -293,9 +293,9 @@ static void pstream_die_callback(pa_pstream *p, void *userdata) {
|
|||
static void pstream_packet_callback(pa_pstream *p, pa_packet *packet, const pa_creds *creds, void *userdata) {
|
||||
pa_context *c = userdata;
|
||||
|
||||
assert(p);
|
||||
assert(packet);
|
||||
assert(c);
|
||||
pa_assert(p);
|
||||
pa_assert(packet);
|
||||
pa_assert(c);
|
||||
|
||||
pa_context_ref(c);
|
||||
|
||||
|
|
@ -309,18 +309,19 @@ static void pstream_memblock_callback(pa_pstream *p, uint32_t channel, int64_t o
|
|||
pa_context *c = userdata;
|
||||
pa_stream *s;
|
||||
|
||||
assert(p);
|
||||
assert(chunk);
|
||||
assert(chunk->memblock);
|
||||
assert(chunk->length);
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(p);
|
||||
pa_assert(chunk);
|
||||
pa_assert(chunk->memblock);
|
||||
pa_assert(chunk->length);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
pa_context_ref(c);
|
||||
|
||||
if ((s = pa_dynarray_get(c->record_streams, channel))) {
|
||||
|
||||
assert(seek == PA_SEEK_RELATIVE && offset == 0);
|
||||
pa_assert(seek == PA_SEEK_RELATIVE);
|
||||
pa_assert(offset == 0);
|
||||
|
||||
pa_memblockq_seek(s->record_memblockq, offset, seek);
|
||||
pa_memblockq_push_align(s->record_memblockq, chunk);
|
||||
|
|
@ -337,11 +338,11 @@ static void pstream_memblock_callback(pa_pstream *p, uint32_t channel, int64_t o
|
|||
}
|
||||
|
||||
int pa_context_handle_error(pa_context *c, uint32_t command, pa_tagstruct *t) {
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
if (command == PA_COMMAND_ERROR) {
|
||||
assert(t);
|
||||
pa_assert(t);
|
||||
|
||||
if (pa_tagstruct_getu32(t, &c->error) < 0) {
|
||||
pa_context_fail(c, PA_ERR_PROTOCOL);
|
||||
|
|
@ -361,9 +362,9 @@ int pa_context_handle_error(pa_context *c, uint32_t command, pa_tagstruct *t) {
|
|||
static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
|
||||
pa_context *c = userdata;
|
||||
|
||||
assert(pd);
|
||||
assert(c);
|
||||
assert(c->state == PA_CONTEXT_AUTHORIZING || c->state == PA_CONTEXT_SETTING_NAME);
|
||||
pa_assert(pd);
|
||||
pa_assert(c);
|
||||
pa_assert(c->state == PA_CONTEXT_AUTHORIZING || c->state == PA_CONTEXT_SETTING_NAME);
|
||||
|
||||
pa_context_ref(c);
|
||||
|
||||
|
|
@ -423,7 +424,7 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t
|
|||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
pa_assert(0);
|
||||
}
|
||||
|
||||
finish:
|
||||
|
|
@ -434,19 +435,19 @@ static void setup_context(pa_context *c, pa_iochannel *io) {
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(io);
|
||||
pa_assert(c);
|
||||
pa_assert(io);
|
||||
|
||||
pa_context_ref(c);
|
||||
|
||||
assert(!c->pstream);
|
||||
pa_assert(!c->pstream);
|
||||
c->pstream = pa_pstream_new(c->mainloop, io, c->mempool);
|
||||
|
||||
pa_pstream_set_die_callback(c->pstream, pstream_die_callback, c);
|
||||
pa_pstream_set_recieve_packet_callback(c->pstream, pstream_packet_callback, c);
|
||||
pa_pstream_set_recieve_memblock_callback(c->pstream, pstream_memblock_callback, c);
|
||||
|
||||
assert(!c->pdispatch);
|
||||
pa_assert(!c->pdispatch);
|
||||
c->pdispatch = pa_pdispatch_new(c->mainloop, command_table, PA_COMMAND_MAX);
|
||||
|
||||
if (!c->conf->cookie_valid)
|
||||
|
|
@ -497,10 +498,10 @@ static int context_connect_spawn(pa_context *c) {
|
|||
goto fail;
|
||||
}
|
||||
|
||||
pa_fd_set_cloexec(fds[0], 1);
|
||||
pa_make_fd_cloexec(fds[0]);
|
||||
|
||||
pa_socket_low_delay(fds[0]);
|
||||
pa_socket_low_delay(fds[1]);
|
||||
pa_make_socket_low_delay(fds[0]);
|
||||
pa_make_socket_low_delay(fds[1]);
|
||||
|
||||
if (c->spawn_api.prefork)
|
||||
c->spawn_api.prefork();
|
||||
|
|
@ -523,7 +524,7 @@ static int context_connect_spawn(pa_context *c) {
|
|||
int n;
|
||||
|
||||
/* Not required, since fds[0] has CLOEXEC enabled anyway */
|
||||
close(fds[0]);
|
||||
pa_assert_se(pa_close(fds[0]) == 0);
|
||||
|
||||
if (c->spawn_api.atfork)
|
||||
c->spawn_api.atfork();
|
||||
|
|
@ -535,7 +536,7 @@ static int context_connect_spawn(pa_context *c) {
|
|||
argv[n++] = c->conf->daemon_binary;
|
||||
argv[n++] = "--daemonize=yes";
|
||||
|
||||
snprintf(t, sizeof(t), "-Lmodule-native-protocol-fd fd=%i", fds[1]);
|
||||
pa_snprintf(t, sizeof(t), "-Lmodule-native-protocol-fd fd=%i", fds[1]);
|
||||
argv[n++] = strdup(t);
|
||||
|
||||
while (n < MAX_ARGS) {
|
||||
|
|
@ -570,7 +571,7 @@ static int context_connect_spawn(pa_context *c) {
|
|||
goto fail;
|
||||
}
|
||||
|
||||
close(fds[1]);
|
||||
pa_assert_se(pa_close(fds[1]) == 0);
|
||||
|
||||
c->is_local = 1;
|
||||
|
||||
|
|
@ -584,10 +585,7 @@ static int context_connect_spawn(pa_context *c) {
|
|||
return 0;
|
||||
|
||||
fail:
|
||||
if (fds[0] != -1)
|
||||
close(fds[0]);
|
||||
if (fds[1] != -1)
|
||||
close(fds[1]);
|
||||
pa_close_pipe(fds);
|
||||
|
||||
unlock_autospawn_lock_file(c);
|
||||
|
||||
|
|
@ -602,8 +600,8 @@ static int try_next_connection(pa_context *c) {
|
|||
char *u = NULL;
|
||||
int r = -1;
|
||||
|
||||
assert(c);
|
||||
assert(!c->client);
|
||||
pa_assert(c);
|
||||
pa_assert(!c->client);
|
||||
|
||||
for (;;) {
|
||||
pa_xfree(u);
|
||||
|
|
@ -648,9 +646,9 @@ finish:
|
|||
static void on_connection(pa_socket_client *client, pa_iochannel*io, void *userdata) {
|
||||
pa_context *c = userdata;
|
||||
|
||||
assert(client);
|
||||
assert(c);
|
||||
assert(c->state == PA_CONTEXT_CONNECTING);
|
||||
pa_assert(client);
|
||||
pa_assert(c);
|
||||
pa_assert(c->state == PA_CONTEXT_CONNECTING);
|
||||
|
||||
pa_context_ref(c);
|
||||
|
||||
|
|
@ -683,8 +681,8 @@ int pa_context_connect(
|
|||
|
||||
int r = -1;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY(c, c->state == PA_CONTEXT_UNCONNECTED, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY(c, !(flags & ~PA_CONTEXT_NOAUTOSPAWN), PA_ERR_INVALID);
|
||||
|
|
@ -695,7 +693,7 @@ int pa_context_connect(
|
|||
|
||||
pa_context_ref(c);
|
||||
|
||||
assert(!c->server_list);
|
||||
pa_assert(!c->server_list);
|
||||
|
||||
if (server) {
|
||||
if (!(c->server_list = pa_strlist_parse(server))) {
|
||||
|
|
@ -735,7 +733,7 @@ int pa_context_connect(
|
|||
|
||||
pa_runtime_path(AUTOSPAWN_LOCK, lf, sizeof(lf));
|
||||
pa_make_secure_parent_dir(lf, 0700, (uid_t)-1, (gid_t)-1);
|
||||
assert(c->autospawn_lock_fd <= 0);
|
||||
pa_assert(c->autospawn_lock_fd <= 0);
|
||||
c->autospawn_lock_fd = pa_lock_lockfile(lf);
|
||||
|
||||
if (api)
|
||||
|
|
@ -755,37 +753,37 @@ finish:
|
|||
}
|
||||
|
||||
void pa_context_disconnect(pa_context *c) {
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
pa_context_set_state(c, PA_CONTEXT_TERMINATED);
|
||||
}
|
||||
|
||||
pa_context_state_t pa_context_get_state(pa_context *c) {
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
return c->state;
|
||||
}
|
||||
|
||||
int pa_context_errno(pa_context *c) {
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
return c->error;
|
||||
}
|
||||
|
||||
void pa_context_set_state_callback(pa_context *c, pa_context_notify_cb_t cb, void *userdata) {
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
c->state_callback = cb;
|
||||
c->state_userdata = userdata;
|
||||
}
|
||||
|
||||
int pa_context_is_pending(pa_context *c) {
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY(c,
|
||||
c->state == PA_CONTEXT_CONNECTING ||
|
||||
|
|
@ -811,11 +809,11 @@ static void pstream_drain_callback(PA_GCC_UNUSED pa_pstream *s, void *userdata)
|
|||
static void set_dispatch_callbacks(pa_operation *o) {
|
||||
int done = 1;
|
||||
|
||||
assert(o);
|
||||
assert(o->ref >= 1);
|
||||
assert(o->context);
|
||||
assert(o->context->ref >= 1);
|
||||
assert(o->context->state == PA_CONTEXT_READY);
|
||||
pa_assert(o);
|
||||
pa_assert(PA_REFCNT_VALUE(o) >= 1);
|
||||
pa_assert(o->context);
|
||||
pa_assert(PA_REFCNT_VALUE(o->context) >= 1);
|
||||
pa_assert(o->context->state == PA_CONTEXT_READY);
|
||||
|
||||
pa_pstream_set_drain_callback(o->context->pstream, NULL, NULL);
|
||||
pa_pdispatch_set_drain_callback(o->context->pdispatch, NULL, NULL);
|
||||
|
|
@ -844,8 +842,8 @@ static void set_dispatch_callbacks(pa_operation *o) {
|
|||
pa_operation* pa_context_drain(pa_context *c, pa_context_notify_cb_t cb, void *userdata) {
|
||||
pa_operation *o;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, pa_context_is_pending(c), PA_ERR_BADSTATE);
|
||||
|
|
@ -860,9 +858,9 @@ void pa_context_simple_ack_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_U
|
|||
pa_operation *o = userdata;
|
||||
int success = 1;
|
||||
|
||||
assert(pd);
|
||||
assert(o);
|
||||
assert(o->ref >= 1);
|
||||
pa_assert(pd);
|
||||
pa_assert(o);
|
||||
pa_assert(PA_REFCNT_VALUE(o) >= 1);
|
||||
|
||||
if (!o->context)
|
||||
goto finish;
|
||||
|
|
@ -892,8 +890,8 @@ pa_operation* pa_context_exit_daemon(pa_context *c, pa_context_success_cb_t cb,
|
|||
pa_operation *o;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
|
||||
|
|
@ -911,8 +909,8 @@ pa_operation* pa_context_send_simple_command(pa_context *c, uint32_t command, pa
|
|||
pa_operation *o;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
|
||||
|
|
@ -930,8 +928,8 @@ pa_operation* pa_context_set_default_sink(pa_context *c, const char *name, pa_co
|
|||
pa_operation *o;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
|
||||
|
|
@ -950,8 +948,8 @@ pa_operation* pa_context_set_default_source(pa_context *c, const char *name, pa_
|
|||
pa_operation *o;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
|
||||
|
|
@ -966,7 +964,7 @@ pa_operation* pa_context_set_default_source(pa_context *c, const char *name, pa_
|
|||
}
|
||||
|
||||
int pa_context_is_local(pa_context *c) {
|
||||
assert(c);
|
||||
pa_assert(c);
|
||||
|
||||
return c->is_local;
|
||||
}
|
||||
|
|
@ -976,9 +974,9 @@ pa_operation* pa_context_set_name(pa_context *c, const char *name, pa_context_su
|
|||
pa_operation *o;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
assert(name);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
pa_assert(name);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
|
||||
|
|
@ -997,8 +995,8 @@ const char* pa_get_library_version(void) {
|
|||
}
|
||||
|
||||
const char* pa_context_get_server(pa_context *c) {
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
if (!c->server)
|
||||
return NULL;
|
||||
|
|
@ -1016,8 +1014,8 @@ uint32_t pa_context_get_protocol_version(PA_GCC_UNUSED pa_context *c) {
|
|||
}
|
||||
|
||||
uint32_t pa_context_get_server_protocol_version(pa_context *c) {
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
return c->version;
|
||||
}
|
||||
|
|
@ -1025,8 +1023,8 @@ uint32_t pa_context_get_server_protocol_version(pa_context *c) {
|
|||
pa_tagstruct *pa_tagstruct_command(pa_context *c, uint32_t command, uint32_t *tag) {
|
||||
pa_tagstruct *t;
|
||||
|
||||
assert(c);
|
||||
assert(tag);
|
||||
pa_assert(c);
|
||||
pa_assert(tag);
|
||||
|
||||
t = pa_tagstruct_new(NULL, 0);
|
||||
pa_tagstruct_putu32(t, command);
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@
|
|||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <pulse/xmalloc.h>
|
||||
#include <pulse/timeval.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -41,13 +41,14 @@
|
|||
#include <pulsecore/mcalign.h>
|
||||
#include <pulsecore/memblockq.h>
|
||||
#include <pulsecore/hashmap.h>
|
||||
#include <pulsecore/refcnt.h>
|
||||
|
||||
#include "client-conf.h"
|
||||
|
||||
#define DEFAULT_TIMEOUT (30)
|
||||
|
||||
struct pa_context {
|
||||
int ref;
|
||||
PA_REFCNT_DECLARE;
|
||||
|
||||
char *name;
|
||||
pa_mainloop_api* mainloop;
|
||||
|
|
@ -96,7 +97,7 @@ typedef struct pa_index_correction {
|
|||
} pa_index_correction;
|
||||
|
||||
struct pa_stream {
|
||||
int ref;
|
||||
PA_REFCNT_DECLARE;
|
||||
pa_context *context;
|
||||
pa_mainloop_api *mainloop;
|
||||
PA_LLIST_FIELDS(pa_stream);
|
||||
|
|
@ -116,6 +117,7 @@ struct pa_stream {
|
|||
uint32_t requested_bytes;
|
||||
|
||||
pa_memchunk peek_memchunk;
|
||||
void *peek_data;
|
||||
pa_memblockq *record_memblockq;
|
||||
|
||||
int corked;
|
||||
|
|
@ -160,7 +162,8 @@ struct pa_stream {
|
|||
typedef void (*pa_operation_cb_t)(void);
|
||||
|
||||
struct pa_operation {
|
||||
int ref;
|
||||
PA_REFCNT_DECLARE;
|
||||
|
||||
pa_context *context;
|
||||
pa_stream *stream;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,11 +26,10 @@
|
|||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <pulse/context.h>
|
||||
|
||||
#include <pulsecore/gccmacro.h>
|
||||
#include <pulsecore/macro.h>
|
||||
#include <pulsecore/pstream-util.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
|
@ -43,9 +42,11 @@ static void context_stat_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNU
|
|||
pa_operation *o = userdata;
|
||||
pa_stat_info i, *p = &i;
|
||||
|
||||
assert(pd);
|
||||
assert(o);
|
||||
assert(o->ref >= 1);
|
||||
pa_assert(pd);
|
||||
pa_assert(o);
|
||||
pa_assert(PA_REFCNT_VALUE(o) >= 1);
|
||||
|
||||
memset(&i, 0, sizeof(i));
|
||||
|
||||
if (!o->context)
|
||||
goto finish;
|
||||
|
|
@ -59,8 +60,7 @@ static void context_stat_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNU
|
|||
pa_tagstruct_getu32(t, &i.memblock_total_size) < 0 ||
|
||||
pa_tagstruct_getu32(t, &i.memblock_allocated) < 0 ||
|
||||
pa_tagstruct_getu32(t, &i.memblock_allocated_size) < 0 ||
|
||||
pa_tagstruct_getu32(t, &i.scache_size) < 0 ||
|
||||
!pa_tagstruct_eof(t)) {
|
||||
pa_tagstruct_getu32(t, &i.scache_size) < 0) {
|
||||
pa_context_fail(o->context, PA_ERR_PROTOCOL);
|
||||
goto finish;
|
||||
}
|
||||
|
|
@ -85,9 +85,11 @@ static void context_get_server_info_callback(pa_pdispatch *pd, uint32_t command,
|
|||
pa_operation *o = userdata;
|
||||
pa_server_info i, *p = &i;
|
||||
|
||||
assert(pd);
|
||||
assert(o);
|
||||
assert(o->ref >= 1);
|
||||
pa_assert(pd);
|
||||
pa_assert(o);
|
||||
pa_assert(PA_REFCNT_VALUE(o) >= 1);
|
||||
|
||||
memset(&i, 0, sizeof(i));
|
||||
|
||||
if (!o->context)
|
||||
goto finish;
|
||||
|
|
@ -104,8 +106,7 @@ static void context_get_server_info_callback(pa_pdispatch *pd, uint32_t command,
|
|||
pa_tagstruct_get_sample_spec(t, &i.sample_spec) < 0 ||
|
||||
pa_tagstruct_gets(t, &i.default_sink_name) < 0 ||
|
||||
pa_tagstruct_gets(t, &i.default_source_name) < 0 ||
|
||||
pa_tagstruct_getu32(t, &i.cookie) < 0 ||
|
||||
!pa_tagstruct_eof(t)) {
|
||||
pa_tagstruct_getu32(t, &i.cookie) < 0) {
|
||||
|
||||
pa_context_fail(o->context, PA_ERR_PROTOCOL);
|
||||
goto finish;
|
||||
|
|
@ -131,9 +132,9 @@ static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, P
|
|||
pa_operation *o = userdata;
|
||||
int eol = 1;
|
||||
|
||||
assert(pd);
|
||||
assert(o);
|
||||
assert(o->ref >= 1);
|
||||
pa_assert(pd);
|
||||
pa_assert(o);
|
||||
pa_assert(PA_REFCNT_VALUE(o) >= 1);
|
||||
|
||||
if (!o->context)
|
||||
goto finish;
|
||||
|
|
@ -148,6 +149,7 @@ static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, P
|
|||
|
||||
while (!pa_tagstruct_eof(t)) {
|
||||
pa_sink_info i;
|
||||
memset(&i, 0, sizeof(i));
|
||||
|
||||
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
|
||||
pa_tagstruct_gets(t, &i.name) < 0 ||
|
||||
|
|
@ -195,9 +197,9 @@ pa_operation* pa_context_get_sink_info_by_index(pa_context *c, uint32_t idx, pa_
|
|||
pa_operation *o;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
assert(cb);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
pa_assert(cb);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
|
||||
|
|
@ -217,9 +219,9 @@ pa_operation* pa_context_get_sink_info_by_name(pa_context *c, const char *name,
|
|||
pa_operation *o;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
assert(cb);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
pa_assert(cb);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
|
||||
|
|
@ -241,9 +243,9 @@ static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command,
|
|||
pa_operation *o = userdata;
|
||||
int eol = 1;
|
||||
|
||||
assert(pd);
|
||||
assert(o);
|
||||
assert(o->ref >= 1);
|
||||
pa_assert(pd);
|
||||
pa_assert(o);
|
||||
pa_assert(PA_REFCNT_VALUE(o) >= 1);
|
||||
|
||||
if (!o->context)
|
||||
goto finish;
|
||||
|
|
@ -258,6 +260,7 @@ static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command,
|
|||
while (!pa_tagstruct_eof(t)) {
|
||||
pa_source_info i;
|
||||
uint32_t flags;
|
||||
memset(&i, 0, sizeof(i));
|
||||
|
||||
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
|
||||
pa_tagstruct_gets(t, &i.name) < 0 ||
|
||||
|
|
@ -305,9 +308,9 @@ pa_operation* pa_context_get_source_info_by_index(pa_context *c, uint32_t idx, p
|
|||
pa_operation *o;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
assert(cb);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
pa_assert(cb);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
|
||||
|
|
@ -327,9 +330,9 @@ pa_operation* pa_context_get_source_info_by_name(pa_context *c, const char *name
|
|||
pa_operation *o;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
assert(cb);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
pa_assert(cb);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
|
||||
|
|
@ -351,9 +354,9 @@ static void context_get_client_info_callback(pa_pdispatch *pd, uint32_t command,
|
|||
pa_operation *o = userdata;
|
||||
int eol = 1;
|
||||
|
||||
assert(pd);
|
||||
assert(o);
|
||||
assert(o->ref >= 1);
|
||||
pa_assert(pd);
|
||||
pa_assert(o);
|
||||
pa_assert(PA_REFCNT_VALUE(o) >= 1);
|
||||
|
||||
if (!o->context)
|
||||
goto finish;
|
||||
|
|
@ -367,6 +370,7 @@ static void context_get_client_info_callback(pa_pdispatch *pd, uint32_t command,
|
|||
|
||||
while (!pa_tagstruct_eof(t)) {
|
||||
pa_client_info i;
|
||||
memset(&i, 0, sizeof(i));
|
||||
|
||||
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
|
||||
pa_tagstruct_gets(t, &i.name) < 0 ||
|
||||
|
|
@ -398,9 +402,9 @@ pa_operation* pa_context_get_client_info(pa_context *c, uint32_t idx, pa_client_
|
|||
pa_operation *o;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
assert(cb);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
pa_assert(cb);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
||||
|
|
@ -425,9 +429,9 @@ static void context_get_module_info_callback(pa_pdispatch *pd, uint32_t command,
|
|||
pa_operation *o = userdata;
|
||||
int eol = 1;
|
||||
|
||||
assert(pd);
|
||||
assert(o);
|
||||
assert(o->ref >= 1);
|
||||
pa_assert(pd);
|
||||
pa_assert(o);
|
||||
pa_assert(PA_REFCNT_VALUE(o) >= 1);
|
||||
|
||||
if (!o->context)
|
||||
goto finish;
|
||||
|
|
@ -441,6 +445,7 @@ static void context_get_module_info_callback(pa_pdispatch *pd, uint32_t command,
|
|||
|
||||
while (!pa_tagstruct_eof(t)) {
|
||||
pa_module_info i;
|
||||
memset(&i, 0, sizeof(i));
|
||||
|
||||
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
|
||||
pa_tagstruct_gets(t, &i.name) < 0 ||
|
||||
|
|
@ -473,9 +478,9 @@ pa_operation* pa_context_get_module_info(pa_context *c, uint32_t idx, pa_module_
|
|||
pa_operation *o;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
assert(cb);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
pa_assert(cb);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
||||
|
|
@ -500,9 +505,9 @@ static void context_get_sink_input_info_callback(pa_pdispatch *pd, uint32_t comm
|
|||
pa_operation *o = userdata;
|
||||
int eol = 1;
|
||||
|
||||
assert(pd);
|
||||
assert(o);
|
||||
assert(o->ref >= 1);
|
||||
pa_assert(pd);
|
||||
pa_assert(o);
|
||||
pa_assert(PA_REFCNT_VALUE(o) >= 1);
|
||||
|
||||
if (!o->context)
|
||||
goto finish;
|
||||
|
|
@ -516,6 +521,7 @@ static void context_get_sink_input_info_callback(pa_pdispatch *pd, uint32_t comm
|
|||
|
||||
while (!pa_tagstruct_eof(t)) {
|
||||
pa_sink_input_info i;
|
||||
memset(&i, 0, sizeof(i));
|
||||
|
||||
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
|
||||
pa_tagstruct_gets(t, &i.name) < 0 ||
|
||||
|
|
@ -528,7 +534,8 @@ static void context_get_sink_input_info_callback(pa_pdispatch *pd, uint32_t comm
|
|||
pa_tagstruct_get_usec(t, &i.buffer_usec) < 0 ||
|
||||
pa_tagstruct_get_usec(t, &i.sink_usec) < 0 ||
|
||||
pa_tagstruct_gets(t, &i.resample_method) < 0 ||
|
||||
pa_tagstruct_gets(t, &i.driver) < 0) {
|
||||
pa_tagstruct_gets(t, &i.driver) < 0 ||
|
||||
(o->context->version >= 11 && pa_tagstruct_get_boolean(t, &i.mute) < 0)) {
|
||||
|
||||
pa_context_fail(o->context, PA_ERR_PROTOCOL);
|
||||
goto finish;
|
||||
|
|
@ -556,9 +563,9 @@ pa_operation* pa_context_get_sink_input_info(pa_context *c, uint32_t idx, pa_sin
|
|||
pa_operation *o;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
assert(cb);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
pa_assert(cb);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
||||
|
|
@ -583,9 +590,9 @@ static void context_get_source_output_info_callback(pa_pdispatch *pd, uint32_t c
|
|||
pa_operation *o = userdata;
|
||||
int eol = 1;
|
||||
|
||||
assert(pd);
|
||||
assert(o);
|
||||
assert(o->ref >= 1);
|
||||
pa_assert(pd);
|
||||
pa_assert(o);
|
||||
pa_assert(PA_REFCNT_VALUE(o) >= 1);
|
||||
|
||||
if (!o->context)
|
||||
goto finish;
|
||||
|
|
@ -600,6 +607,8 @@ static void context_get_source_output_info_callback(pa_pdispatch *pd, uint32_t c
|
|||
while (!pa_tagstruct_eof(t)) {
|
||||
pa_source_output_info i;
|
||||
|
||||
memset(&i, 0, sizeof(i));
|
||||
|
||||
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
|
||||
pa_tagstruct_gets(t, &i.name) < 0 ||
|
||||
pa_tagstruct_getu32(t, &i.owner_module) < 0 ||
|
||||
|
|
@ -638,9 +647,9 @@ pa_operation* pa_context_get_source_output_info(pa_context *c, uint32_t idx, pa_
|
|||
pa_operation *o;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
assert(cb);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
pa_assert(cb);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
||||
|
|
@ -666,9 +675,9 @@ pa_operation* pa_context_set_sink_volume_by_index(pa_context *c, uint32_t idx, c
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
assert(volume);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
pa_assert(volume);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
|
||||
|
|
@ -690,10 +699,10 @@ pa_operation* pa_context_set_sink_volume_by_name(pa_context *c, const char *name
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
assert(name);
|
||||
assert(volume);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
pa_assert(name);
|
||||
pa_assert(volume);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
|
||||
|
|
@ -716,8 +725,8 @@ pa_operation* pa_context_set_sink_mute_by_index(pa_context *c, uint32_t idx, int
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
|
||||
|
|
@ -738,9 +747,9 @@ pa_operation* pa_context_set_sink_mute_by_name(pa_context *c, const char *name,
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
assert(name);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
pa_assert(name);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
|
||||
|
|
@ -762,9 +771,9 @@ pa_operation* pa_context_set_sink_input_volume(pa_context *c, uint32_t idx, cons
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
assert(volume);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
pa_assert(volume);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
||||
|
|
@ -781,14 +790,37 @@ pa_operation* pa_context_set_sink_input_volume(pa_context *c, uint32_t idx, cons
|
|||
return o;
|
||||
}
|
||||
|
||||
pa_operation* pa_context_set_sink_input_mute(pa_context *c, uint32_t idx, int mute, pa_context_success_cb_t cb, void *userdata) {
|
||||
pa_operation *o;
|
||||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 11, PA_ERR_NOTSUPPORTED);
|
||||
|
||||
o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
|
||||
|
||||
t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_INPUT_MUTE, &tag);
|
||||
pa_tagstruct_putu32(t, idx);
|
||||
pa_tagstruct_put_boolean(t, mute);
|
||||
pa_pstream_send_tagstruct(c->pstream, t);
|
||||
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
pa_operation* pa_context_set_source_volume_by_index(pa_context *c, uint32_t idx, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata) {
|
||||
pa_operation *o;
|
||||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
assert(volume);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
pa_assert(volume);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
|
||||
|
|
@ -810,10 +842,10 @@ pa_operation* pa_context_set_source_volume_by_name(pa_context *c, const char *na
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
assert(name);
|
||||
assert(volume);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
pa_assert(name);
|
||||
pa_assert(volume);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
|
||||
|
|
@ -836,8 +868,8 @@ pa_operation* pa_context_set_source_mute_by_index(pa_context *c, uint32_t idx, i
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
|
||||
|
|
@ -858,9 +890,9 @@ pa_operation* pa_context_set_source_mute_by_name(pa_context *c, const char *name
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
assert(name);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
pa_assert(name);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
|
||||
|
|
@ -883,9 +915,9 @@ static void context_get_sample_info_callback(pa_pdispatch *pd, uint32_t command,
|
|||
pa_operation *o = userdata;
|
||||
int eol = 1;
|
||||
|
||||
assert(pd);
|
||||
assert(o);
|
||||
assert(o->ref >= 1);
|
||||
pa_assert(pd);
|
||||
pa_assert(o);
|
||||
pa_assert(PA_REFCNT_VALUE(o) >= 1);
|
||||
|
||||
if (!o->context)
|
||||
goto finish;
|
||||
|
|
@ -900,6 +932,8 @@ static void context_get_sample_info_callback(pa_pdispatch *pd, uint32_t command,
|
|||
while (!pa_tagstruct_eof(t)) {
|
||||
pa_sample_info i;
|
||||
|
||||
memset(&i, 0, sizeof(i));
|
||||
|
||||
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
|
||||
pa_tagstruct_gets(t, &i.name) < 0 ||
|
||||
pa_tagstruct_get_cvolume(t, &i.volume) < 0 ||
|
||||
|
|
@ -936,9 +970,9 @@ pa_operation* pa_context_get_sample_info_by_name(pa_context *c, const char *name
|
|||
pa_operation *o;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
assert(cb);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
pa_assert(cb);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, name && *name, PA_ERR_INVALID);
|
||||
|
|
@ -959,9 +993,9 @@ pa_operation* pa_context_get_sample_info_by_index(pa_context *c, uint32_t idx, p
|
|||
pa_operation *o;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
assert(cb);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
pa_assert(cb);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
||||
|
|
@ -986,8 +1020,8 @@ static pa_operation* command_kill(pa_context *c, uint32_t command, uint32_t idx,
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
||||
|
|
@ -1018,9 +1052,9 @@ static void context_index_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UN
|
|||
pa_operation *o = userdata;
|
||||
uint32_t idx;
|
||||
|
||||
assert(pd);
|
||||
assert(o);
|
||||
assert(o->ref >= 1);
|
||||
pa_assert(pd);
|
||||
pa_assert(o);
|
||||
pa_assert(PA_REFCNT_VALUE(o) >= 1);
|
||||
|
||||
if (!o->context)
|
||||
goto finish;
|
||||
|
|
@ -1052,8 +1086,8 @@ pa_operation* pa_context_load_module(pa_context *c, const char*name, const char
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, name && *name, PA_ERR_INVALID);
|
||||
|
|
@ -1079,9 +1113,9 @@ static void context_get_autoload_info_callback(pa_pdispatch *pd, uint32_t comman
|
|||
pa_operation *o = userdata;
|
||||
int eol = 1;
|
||||
|
||||
assert(pd);
|
||||
assert(o);
|
||||
assert(o->ref >= 1);
|
||||
pa_assert(pd);
|
||||
pa_assert(o);
|
||||
pa_assert(PA_REFCNT_VALUE(o) >= 1);
|
||||
|
||||
if (!o->context)
|
||||
goto finish;
|
||||
|
|
@ -1096,6 +1130,8 @@ static void context_get_autoload_info_callback(pa_pdispatch *pd, uint32_t comman
|
|||
while (!pa_tagstruct_eof(t)) {
|
||||
pa_autoload_info i;
|
||||
|
||||
memset(&i, 0, sizeof(i));
|
||||
|
||||
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
|
||||
pa_tagstruct_gets(t, &i.name) < 0 ||
|
||||
pa_tagstruct_getu32(t, &i.type) < 0 ||
|
||||
|
|
@ -1127,9 +1163,9 @@ pa_operation* pa_context_get_autoload_info_by_name(pa_context *c, const char *na
|
|||
pa_operation *o;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
assert(cb);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
pa_assert(cb);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, name && *name, PA_ERR_INVALID);
|
||||
|
|
@ -1151,9 +1187,9 @@ pa_operation* pa_context_get_autoload_info_by_index(pa_context *c, uint32_t idx,
|
|||
pa_operation *o;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
assert(cb);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
pa_assert(cb);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
||||
|
|
@ -1177,8 +1213,8 @@ pa_operation* pa_context_add_autoload(pa_context *c, const char *name, pa_autolo
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, name && *name, PA_ERR_INVALID);
|
||||
|
|
@ -1203,8 +1239,8 @@ pa_operation* pa_context_remove_autoload_by_name(pa_context *c, const char *name
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, name && *name, PA_ERR_INVALID);
|
||||
|
|
@ -1226,8 +1262,8 @@ pa_operation* pa_context_remove_autoload_by_index(pa_context *c, uint32_t idx, p
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
||||
|
|
@ -1247,8 +1283,8 @@ pa_operation* pa_context_move_sink_input_by_name(pa_context *c, uint32_t idx, ch
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 10, PA_ERR_NOTSUPPORTED);
|
||||
|
|
@ -1272,8 +1308,8 @@ pa_operation* pa_context_move_sink_input_by_index(pa_context *c, uint32_t idx, u
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 10, PA_ERR_NOTSUPPORTED);
|
||||
|
|
@ -1297,8 +1333,8 @@ pa_operation* pa_context_move_source_output_by_name(pa_context *c, uint32_t idx,
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 10, PA_ERR_NOTSUPPORTED);
|
||||
|
|
@ -1322,8 +1358,8 @@ pa_operation* pa_context_move_source_output_by_index(pa_context *c, uint32_t idx
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 10, PA_ERR_NOTSUPPORTED);
|
||||
|
|
@ -1341,3 +1377,97 @@ pa_operation* pa_context_move_source_output_by_index(pa_context *c, uint32_t idx
|
|||
|
||||
return o;
|
||||
}
|
||||
|
||||
pa_operation* pa_context_suspend_sink_by_name(pa_context *c, char *sink_name, int suspend, pa_context_success_cb_t cb, void* userdata) {
|
||||
pa_operation *o;
|
||||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 11, PA_ERR_NOTSUPPORTED);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, !sink_name || *sink_name, PA_ERR_INVALID);
|
||||
|
||||
o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
|
||||
|
||||
t = pa_tagstruct_command(c, PA_COMMAND_SUSPEND_SINK, &tag);
|
||||
pa_tagstruct_putu32(t, PA_INVALID_INDEX);
|
||||
pa_tagstruct_puts(t, sink_name);
|
||||
pa_tagstruct_put_boolean(t, suspend);
|
||||
pa_pstream_send_tagstruct(c->pstream, t);
|
||||
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
pa_operation* pa_context_suspend_sink_by_index(pa_context *c, uint32_t idx, int suspend, pa_context_success_cb_t cb, void* userdata) {
|
||||
pa_operation *o;
|
||||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 11, PA_ERR_NOTSUPPORTED);
|
||||
|
||||
o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
|
||||
|
||||
t = pa_tagstruct_command(c, PA_COMMAND_SUSPEND_SINK, &tag);
|
||||
pa_tagstruct_putu32(t, idx);
|
||||
pa_tagstruct_puts(t, idx == PA_INVALID_INDEX ? "" : NULL);
|
||||
pa_tagstruct_put_boolean(t, suspend);
|
||||
pa_pstream_send_tagstruct(c->pstream, t);
|
||||
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
pa_operation* pa_context_suspend_source_by_name(pa_context *c, char *source_name, int suspend, pa_context_success_cb_t cb, void* userdata) {
|
||||
pa_operation *o;
|
||||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 11, PA_ERR_NOTSUPPORTED);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, !source_name || *source_name, PA_ERR_INVALID);
|
||||
|
||||
o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
|
||||
|
||||
t = pa_tagstruct_command(c, PA_COMMAND_SUSPEND_SOURCE, &tag);
|
||||
pa_tagstruct_putu32(t, PA_INVALID_INDEX);
|
||||
pa_tagstruct_puts(t, source_name);
|
||||
pa_tagstruct_put_boolean(t, suspend);
|
||||
pa_pstream_send_tagstruct(c->pstream, t);
|
||||
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
pa_operation* pa_context_suspend_source_by_index(pa_context *c, uint32_t idx, int suspend, pa_context_success_cb_t cb, void* userdata) {
|
||||
pa_operation *o;
|
||||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 11, PA_ERR_NOTSUPPORTED);
|
||||
|
||||
o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
|
||||
|
||||
t = pa_tagstruct_command(c, PA_COMMAND_SUSPEND_SOURCE, &tag);
|
||||
pa_tagstruct_putu32(t, idx);
|
||||
pa_tagstruct_puts(t, idx == PA_INVALID_INDEX ? "" : NULL);
|
||||
pa_tagstruct_put_boolean(t, suspend);
|
||||
pa_pstream_send_tagstruct(c->pstream, t);
|
||||
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -331,6 +331,7 @@ typedef struct pa_sink_input_info {
|
|||
pa_usec_t sink_usec; /**< Latency of the sink device, see pa_latency_info for details */
|
||||
const char *resample_method; /**< Thre resampling method used by this sink input. \since 0.7 */
|
||||
const char *driver; /**< Driver name \since 0.8 */
|
||||
int mute; /**< Stream muted \since 0.9.7 */
|
||||
} pa_sink_input_info;
|
||||
|
||||
/** Callback prototype for pa_context_get_sink_input_info() and firends*/
|
||||
|
|
@ -381,6 +382,9 @@ pa_operation* pa_context_set_sink_mute_by_name(pa_context *c, const char *name,
|
|||
/** Set the volume of a sink input stream */
|
||||
pa_operation* pa_context_set_sink_input_volume(pa_context *c, uint32_t idx, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata);
|
||||
|
||||
/** Set the mute switch of a sink input stream \since 0.9.7 */
|
||||
pa_operation* pa_context_set_sink_input_mute(pa_context *c, uint32_t idx, int mute, pa_context_success_cb_t cb, void *userdata);
|
||||
|
||||
/** Set the volume of a source device specified by its index \since 0.8 */
|
||||
pa_operation* pa_context_set_source_volume_by_index(pa_context *c, uint32_t idx, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata);
|
||||
|
||||
|
|
@ -499,6 +503,18 @@ pa_operation* pa_context_move_source_output_by_name(pa_context *c, uint32_t idx,
|
|||
/** Move the specified source output to a different source. \since 0.9.5 */
|
||||
pa_operation* pa_context_move_source_output_by_index(pa_context *c, uint32_t idx, uint32_t source_idx, pa_context_success_cb_t cb, void* userdata);
|
||||
|
||||
/** Suspend/Resume a sink. \since 0.9.7 */
|
||||
pa_operation* pa_context_suspend_sink_by_name(pa_context *c, char *sink_name, int suspend, pa_context_success_cb_t cb, void* userdata);
|
||||
|
||||
/** Suspend/Resume a sink. If idx is PA_INVALID_INDEX all sinks will be suspended. \since 0.9.7 */
|
||||
pa_operation* pa_context_suspend_sink_by_index(pa_context *c, uint32_t idx, int suspend, pa_context_success_cb_t cb, void* userdata);
|
||||
|
||||
/** Suspend/Resume a source. \since 0.9.7 */
|
||||
pa_operation* pa_context_suspend_source_by_name(pa_context *c, char *source_name, int suspend, pa_context_success_cb_t cb, void* userdata);
|
||||
|
||||
/** Suspend/Resume a source. If idx is PA_INVALID_INDEX all sources will be suspended. \since 0.9.7 */
|
||||
pa_operation* pa_context_suspend_source_by_index(pa_context *c, uint32_t idx, int suspend, pa_context_success_cb_t cb, void* userdata);
|
||||
|
||||
PA_C_DECL_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -25,12 +25,12 @@
|
|||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <pulse/xmalloc.h>
|
||||
|
||||
#include <pulsecore/gccmacro.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
#include "mainloop-api.h"
|
||||
|
||||
|
|
@ -41,32 +41,38 @@ struct once_info {
|
|||
|
||||
static void once_callback(pa_mainloop_api *m, pa_defer_event *e, void *userdata) {
|
||||
struct once_info *i = userdata;
|
||||
assert(m && i && i->callback);
|
||||
|
||||
pa_assert(m);
|
||||
pa_assert(i);
|
||||
|
||||
pa_assert(i->callback);
|
||||
i->callback(m, i->userdata);
|
||||
|
||||
assert(m->defer_free);
|
||||
pa_assert(m->defer_free);
|
||||
m->defer_free(e);
|
||||
}
|
||||
|
||||
static void free_callback(pa_mainloop_api *m, PA_GCC_UNUSED pa_defer_event *e, void *userdata) {
|
||||
struct once_info *i = userdata;
|
||||
assert(m && i);
|
||||
|
||||
pa_assert(m);
|
||||
pa_assert(i);
|
||||
pa_xfree(i);
|
||||
}
|
||||
|
||||
void pa_mainloop_api_once(pa_mainloop_api* m, void (*callback)(pa_mainloop_api *m, void *userdata), void *userdata) {
|
||||
struct once_info *i;
|
||||
pa_defer_event *e;
|
||||
assert(m && callback);
|
||||
|
||||
pa_assert(m);
|
||||
pa_assert(callback);
|
||||
|
||||
i = pa_xnew(struct once_info, 1);
|
||||
i->callback = callback;
|
||||
i->userdata = userdata;
|
||||
|
||||
assert(m->defer_new);
|
||||
e = m->defer_new(m, once_callback, i);
|
||||
assert(e);
|
||||
pa_assert(m->defer_new);
|
||||
pa_assert_se(e = m->defer_new(m, once_callback, i));
|
||||
m->defer_set_destroy(e, free_callback);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -39,12 +38,13 @@
|
|||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <pulsecore/core-error.h>
|
||||
#include <pulse/xmalloc.h>
|
||||
|
||||
#include <pulsecore/core-error.h>
|
||||
#include <pulsecore/core-util.h>
|
||||
#include <pulsecore/log.h>
|
||||
#include <pulsecore/gccmacro.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
#include "mainloop-signal.h"
|
||||
|
||||
|
|
@ -74,11 +74,11 @@ static void signal_handler(int sig) {
|
|||
}
|
||||
|
||||
static void dispatch(pa_mainloop_api*a, int sig) {
|
||||
pa_signal_event*s;
|
||||
pa_signal_event *s;
|
||||
|
||||
for (s = signals; s; s = s->next)
|
||||
if (s->sig == sig) {
|
||||
assert(s->callback);
|
||||
pa_assert(s->callback);
|
||||
s->callback(a, s, sig, s->userdata);
|
||||
break;
|
||||
}
|
||||
|
|
@ -87,7 +87,12 @@ static void dispatch(pa_mainloop_api*a, int sig) {
|
|||
static void callback(pa_mainloop_api*a, pa_io_event*e, int fd, pa_io_event_flags_t f, PA_GCC_UNUSED void *userdata) {
|
||||
ssize_t r;
|
||||
int sig;
|
||||
assert(a && e && f == PA_IO_EVENT_INPUT && e == io_event && fd == signal_pipe[0]);
|
||||
|
||||
pa_assert(a);
|
||||
pa_assert(e);
|
||||
pa_assert(f == PA_IO_EVENT_INPUT);
|
||||
pa_assert(e == io_event);
|
||||
pa_assert(fd == signal_pipe[0]);
|
||||
|
||||
if ((r = pa_read(signal_pipe[0], &sig, sizeof(sig), NULL)) < 0) {
|
||||
if (errno == EAGAIN)
|
||||
|
|
@ -107,28 +112,34 @@ static void callback(pa_mainloop_api*a, pa_io_event*e, int fd, pa_io_event_flags
|
|||
|
||||
int pa_signal_init(pa_mainloop_api *a) {
|
||||
|
||||
assert(!api && a && signal_pipe[0] == -1 && signal_pipe[1] == -1 && !io_event);
|
||||
pa_assert(a);
|
||||
pa_assert(!api);
|
||||
pa_assert(signal_pipe[0] == -1);
|
||||
pa_assert(signal_pipe[1] == -1);
|
||||
pa_assert(!io_event);
|
||||
|
||||
if (pipe(signal_pipe) < 0) {
|
||||
pa_log("pipe(): %s", pa_cstrerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
pa_make_nonblock_fd(signal_pipe[0]);
|
||||
pa_make_nonblock_fd(signal_pipe[1]);
|
||||
pa_fd_set_cloexec(signal_pipe[0], 1);
|
||||
pa_fd_set_cloexec(signal_pipe[1], 1);
|
||||
pa_make_fd_nonblock(signal_pipe[0]);
|
||||
pa_make_fd_nonblock(signal_pipe[1]);
|
||||
pa_make_fd_cloexec(signal_pipe[0]);
|
||||
pa_make_fd_cloexec(signal_pipe[1]);
|
||||
|
||||
api = a;
|
||||
|
||||
io_event = api->io_new(api, signal_pipe[0], PA_IO_EVENT_INPUT, callback, NULL);
|
||||
assert(io_event);
|
||||
pa_assert_se(io_event = api->io_new(api, signal_pipe[0], PA_IO_EVENT_INPUT, callback, NULL));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pa_signal_done(void) {
|
||||
assert(api && signal_pipe[0] >= 0 && signal_pipe[1] >= 0 && io_event);
|
||||
pa_assert(api);
|
||||
pa_assert(signal_pipe[0] >= 0);
|
||||
pa_assert(signal_pipe[1] >= 0);
|
||||
pa_assert(io_event);
|
||||
|
||||
while (signals)
|
||||
pa_signal_free(signals);
|
||||
|
|
@ -136,9 +147,7 @@ void pa_signal_done(void) {
|
|||
api->io_free(io_event);
|
||||
io_event = NULL;
|
||||
|
||||
close(signal_pipe[0]);
|
||||
close(signal_pipe[1]);
|
||||
signal_pipe[0] = signal_pipe[1] = -1;
|
||||
pa_close_pipe(signal_pipe);
|
||||
|
||||
api = NULL;
|
||||
}
|
||||
|
|
@ -150,13 +159,14 @@ pa_signal_event* pa_signal_new(int sig, void (*_callback) (pa_mainloop_api *api,
|
|||
struct sigaction sa;
|
||||
#endif
|
||||
|
||||
assert(sig > 0 && _callback);
|
||||
pa_assert(sig > 0);
|
||||
pa_assert(_callback);
|
||||
|
||||
for (e = signals; e; e = e->next)
|
||||
if (e->sig == sig)
|
||||
goto fail;
|
||||
|
||||
e = pa_xmalloc(sizeof(pa_signal_event));
|
||||
e = pa_xnew(pa_signal_event, 1);
|
||||
e->sig = sig;
|
||||
e->callback = _callback;
|
||||
e->userdata = userdata;
|
||||
|
|
@ -186,7 +196,7 @@ fail:
|
|||
}
|
||||
|
||||
void pa_signal_free(pa_signal_event *e) {
|
||||
assert(e);
|
||||
pa_assert(e);
|
||||
|
||||
if (e->next)
|
||||
e->next->previous = e->previous;
|
||||
|
|
@ -196,9 +206,9 @@ void pa_signal_free(pa_signal_event *e) {
|
|||
signals = e->next;
|
||||
|
||||
#ifdef HAVE_SIGACTION
|
||||
sigaction(e->sig, &e->saved_sigaction, NULL);
|
||||
pa_assert_se(sigaction(e->sig, &e->saved_sigaction, NULL) == 0);
|
||||
#else
|
||||
signal(e->sig, e->saved_handler);
|
||||
pa_assert_se(signal(e->sig, e->saved_handler) == signal_handler);
|
||||
#endif
|
||||
|
||||
if (e->destroy_callback)
|
||||
|
|
@ -208,6 +218,7 @@ void pa_signal_free(pa_signal_event *e) {
|
|||
}
|
||||
|
||||
void pa_signal_set_destroy(pa_signal_event *e, void (*_callback) (pa_mainloop_api *api, pa_signal_event*e, void *userdata)) {
|
||||
assert(e);
|
||||
pa_assert(e);
|
||||
|
||||
e->destroy_callback = _callback;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,29 +31,28 @@
|
|||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef HAVE_SYS_POLL_H
|
||||
#include <sys/poll.h>
|
||||
#ifdef HAVE_POLL_H
|
||||
#include <poll.h>
|
||||
#else
|
||||
#include "../pulsecore/poll.h"
|
||||
#include <pulsecore/poll.h>
|
||||
#endif
|
||||
|
||||
#include "../pulsecore/winsock.h"
|
||||
|
||||
#ifndef HAVE_PIPE
|
||||
#include "../pulsecore/pipe.h"
|
||||
#include <pulsecore/pipe.h>
|
||||
#endif
|
||||
|
||||
#include <pulsecore/core-error.h>
|
||||
#include <pulse/timeval.h>
|
||||
#include <pulse/xmalloc.h>
|
||||
|
||||
#include <pulsecore/core-util.h>
|
||||
#include <pulsecore/llist.h>
|
||||
#include <pulsecore/log.h>
|
||||
#include <pulsecore/core-error.h>
|
||||
#include <pulsecore/winsock.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
#include "mainloop.h"
|
||||
|
||||
|
|
@ -161,13 +160,13 @@ static pa_io_event* mainloop_io_new(
|
|||
pa_mainloop *m;
|
||||
pa_io_event *e;
|
||||
|
||||
assert(a);
|
||||
assert(a->userdata);
|
||||
assert(fd >= 0);
|
||||
assert(callback);
|
||||
pa_assert(a);
|
||||
pa_assert(a->userdata);
|
||||
pa_assert(fd >= 0);
|
||||
pa_assert(callback);
|
||||
|
||||
m = a->userdata;
|
||||
assert(a == &m->api);
|
||||
pa_assert(a == &m->api);
|
||||
|
||||
e = pa_xnew(pa_io_event, 1);
|
||||
e->mainloop = m;
|
||||
|
|
@ -195,7 +194,7 @@ static pa_io_event* mainloop_io_new(
|
|||
if ((select((SELECT_TYPE_ARG1) fd, NULL, NULL, SELECT_TYPE_ARG234 &xset,
|
||||
SELECT_TYPE_ARG5 &tv) == -1) &&
|
||||
(WSAGetLastError() == WSAENOTSOCK)) {
|
||||
pa_log_warn("WARNING: cannot monitor non-socket file descriptors.");
|
||||
pa_log_warn("Cannot monitor non-socket file descriptors.");
|
||||
e->dead = 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -211,8 +210,8 @@ static pa_io_event* mainloop_io_new(
|
|||
}
|
||||
|
||||
static void mainloop_io_enable(pa_io_event *e, pa_io_event_flags_t events) {
|
||||
assert(e);
|
||||
assert(!e->dead);
|
||||
pa_assert(e);
|
||||
pa_assert(!e->dead);
|
||||
|
||||
if (e->events == events)
|
||||
return;
|
||||
|
|
@ -228,8 +227,8 @@ static void mainloop_io_enable(pa_io_event *e, pa_io_event_flags_t events) {
|
|||
}
|
||||
|
||||
static void mainloop_io_free(pa_io_event *e) {
|
||||
assert(e);
|
||||
assert(!e->dead);
|
||||
pa_assert(e);
|
||||
pa_assert(!e->dead);
|
||||
|
||||
e->dead = 1;
|
||||
e->mainloop->io_events_please_scan ++;
|
||||
|
|
@ -241,7 +240,7 @@ static void mainloop_io_free(pa_io_event *e) {
|
|||
}
|
||||
|
||||
static void mainloop_io_set_destroy(pa_io_event *e, pa_io_event_destroy_cb_t callback) {
|
||||
assert(e);
|
||||
pa_assert(e);
|
||||
|
||||
e->destroy_callback = callback;
|
||||
}
|
||||
|
|
@ -255,12 +254,12 @@ static pa_defer_event* mainloop_defer_new(
|
|||
pa_mainloop *m;
|
||||
pa_defer_event *e;
|
||||
|
||||
assert(a);
|
||||
assert(a->userdata);
|
||||
assert(callback);
|
||||
pa_assert(a);
|
||||
pa_assert(a->userdata);
|
||||
pa_assert(callback);
|
||||
|
||||
m = a->userdata;
|
||||
assert(a == &m->api);
|
||||
pa_assert(a == &m->api);
|
||||
|
||||
e = pa_xnew(pa_defer_event, 1);
|
||||
e->mainloop = m;
|
||||
|
|
@ -281,11 +280,11 @@ static pa_defer_event* mainloop_defer_new(
|
|||
}
|
||||
|
||||
static void mainloop_defer_enable(pa_defer_event *e, int b) {
|
||||
assert(e);
|
||||
assert(!e->dead);
|
||||
pa_assert(e);
|
||||
pa_assert(!e->dead);
|
||||
|
||||
if (e->enabled && !b) {
|
||||
assert(e->mainloop->n_enabled_defer_events > 0);
|
||||
pa_assert(e->mainloop->n_enabled_defer_events > 0);
|
||||
e->mainloop->n_enabled_defer_events--;
|
||||
} else if (!e->enabled && b) {
|
||||
e->mainloop->n_enabled_defer_events++;
|
||||
|
|
@ -296,21 +295,22 @@ static void mainloop_defer_enable(pa_defer_event *e, int b) {
|
|||
}
|
||||
|
||||
static void mainloop_defer_free(pa_defer_event *e) {
|
||||
assert(e);
|
||||
assert(!e->dead);
|
||||
pa_assert(e);
|
||||
pa_assert(!e->dead);
|
||||
|
||||
e->dead = 1;
|
||||
e->mainloop->defer_events_please_scan ++;
|
||||
|
||||
if (e->enabled) {
|
||||
assert(e->mainloop->n_enabled_defer_events > 0);
|
||||
pa_assert(e->mainloop->n_enabled_defer_events > 0);
|
||||
e->mainloop->n_enabled_defer_events--;
|
||||
e->enabled = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void mainloop_defer_set_destroy(pa_defer_event *e, pa_defer_event_destroy_cb_t callback) {
|
||||
assert(e);
|
||||
assert(!e->dead);
|
||||
pa_assert(e);
|
||||
pa_assert(!e->dead);
|
||||
|
||||
e->destroy_callback = callback;
|
||||
}
|
||||
|
|
@ -325,12 +325,12 @@ static pa_time_event* mainloop_time_new(
|
|||
pa_mainloop *m;
|
||||
pa_time_event *e;
|
||||
|
||||
assert(a);
|
||||
assert(a->userdata);
|
||||
assert(callback);
|
||||
pa_assert(a);
|
||||
pa_assert(a->userdata);
|
||||
pa_assert(callback);
|
||||
|
||||
m = a->userdata;
|
||||
assert(a == &m->api);
|
||||
pa_assert(a == &m->api);
|
||||
|
||||
e = pa_xnew(pa_time_event, 1);
|
||||
e->mainloop = m;
|
||||
|
|
@ -342,7 +342,7 @@ static pa_time_event* mainloop_time_new(
|
|||
m->n_enabled_time_events++;
|
||||
|
||||
if (m->cached_next_time_event) {
|
||||
assert(m->cached_next_time_event->enabled);
|
||||
pa_assert(m->cached_next_time_event->enabled);
|
||||
|
||||
if (pa_timeval_cmp(tv, &m->cached_next_time_event->timeval) < 0)
|
||||
m->cached_next_time_event = e;
|
||||
|
|
@ -362,11 +362,11 @@ static pa_time_event* mainloop_time_new(
|
|||
}
|
||||
|
||||
static void mainloop_time_restart(pa_time_event *e, const struct timeval *tv) {
|
||||
assert(e);
|
||||
assert(!e->dead);
|
||||
pa_assert(e);
|
||||
pa_assert(!e->dead);
|
||||
|
||||
if (e->enabled && !tv) {
|
||||
assert(e->mainloop->n_enabled_time_events > 0);
|
||||
pa_assert(e->mainloop->n_enabled_time_events > 0);
|
||||
e->mainloop->n_enabled_time_events--;
|
||||
} else if (!e->enabled && tv)
|
||||
e->mainloop->n_enabled_time_events++;
|
||||
|
|
@ -377,7 +377,7 @@ static void mainloop_time_restart(pa_time_event *e, const struct timeval *tv) {
|
|||
}
|
||||
|
||||
if (e->mainloop->cached_next_time_event && e->enabled) {
|
||||
assert(e->mainloop->cached_next_time_event->enabled);
|
||||
pa_assert(e->mainloop->cached_next_time_event->enabled);
|
||||
|
||||
if (pa_timeval_cmp(tv, &e->mainloop->cached_next_time_event->timeval) < 0)
|
||||
e->mainloop->cached_next_time_event = e;
|
||||
|
|
@ -386,15 +386,16 @@ static void mainloop_time_restart(pa_time_event *e, const struct timeval *tv) {
|
|||
}
|
||||
|
||||
static void mainloop_time_free(pa_time_event *e) {
|
||||
assert(e);
|
||||
assert(!e->dead);
|
||||
pa_assert(e);
|
||||
pa_assert(!e->dead);
|
||||
|
||||
e->dead = 1;
|
||||
e->mainloop->time_events_please_scan ++;
|
||||
|
||||
if (e->enabled) {
|
||||
assert(e->mainloop->n_enabled_time_events > 0);
|
||||
pa_assert(e->mainloop->n_enabled_time_events > 0);
|
||||
e->mainloop->n_enabled_time_events--;
|
||||
e->enabled = 0;
|
||||
}
|
||||
|
||||
if (e->mainloop->cached_next_time_event == e)
|
||||
|
|
@ -404,8 +405,8 @@ static void mainloop_time_free(pa_time_event *e) {
|
|||
}
|
||||
|
||||
static void mainloop_time_set_destroy(pa_time_event *e, pa_time_event_destroy_cb_t callback) {
|
||||
assert(e);
|
||||
assert(!e->dead);
|
||||
pa_assert(e);
|
||||
pa_assert(!e->dead);
|
||||
|
||||
e->destroy_callback = callback;
|
||||
}
|
||||
|
|
@ -415,10 +416,10 @@ static void mainloop_time_set_destroy(pa_time_event *e, pa_time_event_destroy_cb
|
|||
static void mainloop_quit(pa_mainloop_api*a, int retval) {
|
||||
pa_mainloop *m;
|
||||
|
||||
assert(a);
|
||||
assert(a->userdata);
|
||||
pa_assert(a);
|
||||
pa_assert(a->userdata);
|
||||
m = a->userdata;
|
||||
assert(a == &m->api);
|
||||
pa_assert(a == &m->api);
|
||||
|
||||
pa_mainloop_quit(m, retval);
|
||||
}
|
||||
|
|
@ -456,8 +457,10 @@ pa_mainloop *pa_mainloop_new(void) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
pa_make_nonblock_fd(m->wakeup_pipe[0]);
|
||||
pa_make_nonblock_fd(m->wakeup_pipe[1]);
|
||||
pa_make_fd_nonblock(m->wakeup_pipe[0]);
|
||||
pa_make_fd_nonblock(m->wakeup_pipe[1]);
|
||||
pa_make_fd_cloexec(m->wakeup_pipe[0]);
|
||||
pa_make_fd_cloexec(m->wakeup_pipe[1]);
|
||||
m->wakeup_requested = 0;
|
||||
|
||||
PA_LLIST_HEAD_INIT(pa_io_event, m->io_events);
|
||||
|
|
@ -502,7 +505,7 @@ static void cleanup_io_events(pa_mainloop *m, int force) {
|
|||
PA_LLIST_REMOVE(pa_io_event, m->io_events, e);
|
||||
|
||||
if (e->dead) {
|
||||
assert(m->io_events_please_scan > 0);
|
||||
pa_assert(m->io_events_please_scan > 0);
|
||||
m->io_events_please_scan--;
|
||||
}
|
||||
|
||||
|
|
@ -517,7 +520,7 @@ static void cleanup_io_events(pa_mainloop *m, int force) {
|
|||
e = n;
|
||||
}
|
||||
|
||||
assert(m->io_events_please_scan == 0);
|
||||
pa_assert(m->io_events_please_scan == 0);
|
||||
}
|
||||
|
||||
static void cleanup_time_events(pa_mainloop *m, int force) {
|
||||
|
|
@ -534,13 +537,14 @@ static void cleanup_time_events(pa_mainloop *m, int force) {
|
|||
PA_LLIST_REMOVE(pa_time_event, m->time_events, e);
|
||||
|
||||
if (e->dead) {
|
||||
assert(m->time_events_please_scan > 0);
|
||||
pa_assert(m->time_events_please_scan > 0);
|
||||
m->time_events_please_scan--;
|
||||
}
|
||||
|
||||
if (!e->dead && e->enabled) {
|
||||
assert(m->n_enabled_time_events > 0);
|
||||
pa_assert(m->n_enabled_time_events > 0);
|
||||
m->n_enabled_time_events--;
|
||||
e->enabled = 0;
|
||||
}
|
||||
|
||||
if (e->destroy_callback)
|
||||
|
|
@ -552,7 +556,7 @@ static void cleanup_time_events(pa_mainloop *m, int force) {
|
|||
e = n;
|
||||
}
|
||||
|
||||
assert(m->time_events_please_scan == 0);
|
||||
pa_assert(m->time_events_please_scan == 0);
|
||||
}
|
||||
|
||||
static void cleanup_defer_events(pa_mainloop *m, int force) {
|
||||
|
|
@ -569,13 +573,14 @@ static void cleanup_defer_events(pa_mainloop *m, int force) {
|
|||
PA_LLIST_REMOVE(pa_defer_event, m->defer_events, e);
|
||||
|
||||
if (e->dead) {
|
||||
assert(m->defer_events_please_scan > 0);
|
||||
pa_assert(m->defer_events_please_scan > 0);
|
||||
m->defer_events_please_scan--;
|
||||
}
|
||||
|
||||
if (!e->dead && e->enabled) {
|
||||
assert(m->n_enabled_defer_events > 0);
|
||||
pa_assert(m->n_enabled_defer_events > 0);
|
||||
m->n_enabled_defer_events--;
|
||||
e->enabled = 0;
|
||||
}
|
||||
|
||||
if (e->destroy_callback)
|
||||
|
|
@ -587,12 +592,12 @@ static void cleanup_defer_events(pa_mainloop *m, int force) {
|
|||
e = n;
|
||||
}
|
||||
|
||||
assert(m->defer_events_please_scan == 0);
|
||||
pa_assert(m->defer_events_please_scan == 0);
|
||||
}
|
||||
|
||||
|
||||
void pa_mainloop_free(pa_mainloop* m) {
|
||||
assert(m);
|
||||
pa_assert(m);
|
||||
|
||||
cleanup_io_events(m, 1);
|
||||
cleanup_defer_events(m, 1);
|
||||
|
|
@ -600,16 +605,13 @@ void pa_mainloop_free(pa_mainloop* m) {
|
|||
|
||||
pa_xfree(m->pollfds);
|
||||
|
||||
if (m->wakeup_pipe[0] >= 0)
|
||||
close(m->wakeup_pipe[0]);
|
||||
if (m->wakeup_pipe[1] >= 0)
|
||||
close(m->wakeup_pipe[1]);
|
||||
pa_close_pipe(m->wakeup_pipe);
|
||||
|
||||
pa_xfree(m);
|
||||
}
|
||||
|
||||
static void scan_dead(pa_mainloop *m) {
|
||||
assert(m);
|
||||
pa_assert(m);
|
||||
|
||||
if (m->io_events_please_scan)
|
||||
cleanup_io_events(m, 0);
|
||||
|
|
@ -666,13 +668,14 @@ static int dispatch_pollfds(pa_mainloop *m) {
|
|||
pa_io_event *e;
|
||||
int r = 0, k;
|
||||
|
||||
assert(m->poll_func_ret > 0);
|
||||
pa_assert(m->poll_func_ret > 0);
|
||||
|
||||
for (e = m->io_events, k = m->poll_func_ret; e && !m->quit && k > 0; e = e->next) {
|
||||
if (e->dead || !e->pollfd || !e->pollfd->revents)
|
||||
continue;
|
||||
|
||||
assert(e->pollfd->fd == e->fd && e->callback);
|
||||
pa_assert(e->pollfd->fd == e->fd);
|
||||
pa_assert(e->callback);
|
||||
e->callback(&m->api, e, e->fd, map_flags_from_libc(e->pollfd->revents), e->userdata);
|
||||
e->pollfd->revents = 0;
|
||||
r++;
|
||||
|
|
@ -694,7 +697,7 @@ static int dispatch_defer(pa_mainloop *m) {
|
|||
if (e->dead || !e->enabled)
|
||||
continue;
|
||||
|
||||
assert(e->callback);
|
||||
pa_assert(e->callback);
|
||||
e->callback(&m->api, e, e->userdata);
|
||||
r++;
|
||||
}
|
||||
|
|
@ -704,7 +707,7 @@ static int dispatch_defer(pa_mainloop *m) {
|
|||
|
||||
static pa_time_event* find_next_time_event(pa_mainloop *m) {
|
||||
pa_time_event *t, *n = NULL;
|
||||
assert(m);
|
||||
pa_assert(m);
|
||||
|
||||
if (m->cached_next_time_event)
|
||||
return m->cached_next_time_event;
|
||||
|
|
@ -736,7 +739,7 @@ static int calc_next_timeout(pa_mainloop *m) {
|
|||
return -1;
|
||||
|
||||
t = find_next_time_event(m);
|
||||
assert(t);
|
||||
pa_assert(t);
|
||||
|
||||
if (t->timeval.tv_sec <= 0)
|
||||
return 0;
|
||||
|
|
@ -754,7 +757,7 @@ static int dispatch_timeout(pa_mainloop *m) {
|
|||
pa_time_event *e;
|
||||
struct timeval now;
|
||||
int r = 0;
|
||||
assert(m);
|
||||
pa_assert(m);
|
||||
|
||||
if (m->n_enabled_time_events <= 0)
|
||||
return 0;
|
||||
|
|
@ -767,7 +770,7 @@ static int dispatch_timeout(pa_mainloop *m) {
|
|||
continue;
|
||||
|
||||
if (pa_timeval_cmp(&e->timeval, &now) <= 0) {
|
||||
assert(e->callback);
|
||||
pa_assert(e->callback);
|
||||
|
||||
/* Disable time event */
|
||||
mainloop_time_restart(e, NULL);
|
||||
|
|
@ -783,7 +786,7 @@ static int dispatch_timeout(pa_mainloop *m) {
|
|||
|
||||
void pa_mainloop_wakeup(pa_mainloop *m) {
|
||||
char c = 'W';
|
||||
assert(m);
|
||||
pa_assert(m);
|
||||
|
||||
if (m->wakeup_pipe[1] >= 0 && m->state == STATE_POLLING) {
|
||||
pa_write(m->wakeup_pipe[1], &c, sizeof(c), &m->wakeup_pipe_type);
|
||||
|
|
@ -794,7 +797,7 @@ void pa_mainloop_wakeup(pa_mainloop *m) {
|
|||
static void clear_wakeup(pa_mainloop *m) {
|
||||
char c[10];
|
||||
|
||||
assert(m);
|
||||
pa_assert(m);
|
||||
|
||||
if (m->wakeup_pipe[0] < 0)
|
||||
return;
|
||||
|
|
@ -806,8 +809,8 @@ static void clear_wakeup(pa_mainloop *m) {
|
|||
}
|
||||
|
||||
int pa_mainloop_prepare(pa_mainloop *m, int timeout) {
|
||||
assert(m);
|
||||
assert(m->state == STATE_PASSIVE);
|
||||
pa_assert(m);
|
||||
pa_assert(m->state == STATE_PASSIVE);
|
||||
|
||||
clear_wakeup(m);
|
||||
scan_dead(m);
|
||||
|
|
@ -833,8 +836,8 @@ quit:
|
|||
}
|
||||
|
||||
int pa_mainloop_poll(pa_mainloop *m) {
|
||||
assert(m);
|
||||
assert(m->state == STATE_PREPARED);
|
||||
pa_assert(m);
|
||||
pa_assert(m->state == STATE_PREPARED);
|
||||
|
||||
if (m->quit)
|
||||
goto quit;
|
||||
|
|
@ -844,7 +847,7 @@ int pa_mainloop_poll(pa_mainloop *m) {
|
|||
if (m->n_enabled_defer_events )
|
||||
m->poll_func_ret = 0;
|
||||
else {
|
||||
assert(!m->rebuild_pollfds);
|
||||
pa_assert(!m->rebuild_pollfds);
|
||||
|
||||
if (m->poll_func)
|
||||
m->poll_func_ret = m->poll_func(m->pollfds, m->n_pollfds, m->prepared_timeout, m->poll_func_userdata);
|
||||
|
|
@ -870,8 +873,8 @@ quit:
|
|||
int pa_mainloop_dispatch(pa_mainloop *m) {
|
||||
int dispatched = 0;
|
||||
|
||||
assert(m);
|
||||
assert(m->state == STATE_POLLED);
|
||||
pa_assert(m);
|
||||
pa_assert(m->state == STATE_POLLED);
|
||||
|
||||
if (m->quit)
|
||||
goto quit;
|
||||
|
|
@ -902,13 +905,13 @@ quit:
|
|||
}
|
||||
|
||||
int pa_mainloop_get_retval(pa_mainloop *m) {
|
||||
assert(m);
|
||||
pa_assert(m);
|
||||
return m->retval;
|
||||
}
|
||||
|
||||
int pa_mainloop_iterate(pa_mainloop *m, int block, int *retval) {
|
||||
int r;
|
||||
assert(m);
|
||||
pa_assert(m);
|
||||
|
||||
if ((r = pa_mainloop_prepare(m, block ? -1 : 0)) < 0)
|
||||
goto quit;
|
||||
|
|
@ -942,7 +945,7 @@ int pa_mainloop_run(pa_mainloop *m, int *retval) {
|
|||
}
|
||||
|
||||
void pa_mainloop_quit(pa_mainloop *m, int retval) {
|
||||
assert(m);
|
||||
pa_assert(m);
|
||||
|
||||
m->quit = 1;
|
||||
m->retval = retval;
|
||||
|
|
@ -950,12 +953,12 @@ void pa_mainloop_quit(pa_mainloop *m, int retval) {
|
|||
}
|
||||
|
||||
pa_mainloop_api* pa_mainloop_get_api(pa_mainloop*m) {
|
||||
assert(m);
|
||||
pa_assert(m);
|
||||
return &m->api;
|
||||
}
|
||||
|
||||
void pa_mainloop_set_poll_func(pa_mainloop *m, pa_poll_func poll_func, void *userdata) {
|
||||
assert(m);
|
||||
pa_assert(m);
|
||||
|
||||
m->poll_func = poll_func;
|
||||
m->poll_func_userdata = userdata;
|
||||
|
|
|
|||
|
|
@ -25,19 +25,18 @@
|
|||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <pulse/xmalloc.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
#include "internal.h"
|
||||
#include "operation.h"
|
||||
|
||||
pa_operation *pa_operation_new(pa_context *c, pa_stream *s, pa_operation_cb_t cb, void *userdata) {
|
||||
pa_operation *o;
|
||||
assert(c);
|
||||
pa_assert(c);
|
||||
|
||||
o = pa_xnew(pa_operation, 1);
|
||||
o->ref = 1;
|
||||
PA_REFCNT_INIT(o);
|
||||
o->context = c;
|
||||
o->stream = s;
|
||||
|
||||
|
|
@ -53,27 +52,27 @@ pa_operation *pa_operation_new(pa_context *c, pa_stream *s, pa_operation_cb_t cb
|
|||
}
|
||||
|
||||
pa_operation *pa_operation_ref(pa_operation *o) {
|
||||
assert(o);
|
||||
assert(o->ref >= 1);
|
||||
pa_assert(o);
|
||||
pa_assert(PA_REFCNT_VALUE(o) >= 1);
|
||||
|
||||
o->ref++;
|
||||
PA_REFCNT_INC(o);
|
||||
return o;
|
||||
}
|
||||
|
||||
void pa_operation_unref(pa_operation *o) {
|
||||
assert(o);
|
||||
assert(o->ref >= 1);
|
||||
pa_assert(o);
|
||||
pa_assert(PA_REFCNT_VALUE(o) >= 1);
|
||||
|
||||
if ((--(o->ref)) == 0) {
|
||||
assert(!o->context);
|
||||
assert(!o->stream);
|
||||
if (PA_REFCNT_DEC(o) <= 0) {
|
||||
pa_assert(!o->context);
|
||||
pa_assert(!o->stream);
|
||||
pa_xfree(o);
|
||||
}
|
||||
}
|
||||
|
||||
static void operation_set_state(pa_operation *o, pa_operation_state_t st) {
|
||||
assert(o);
|
||||
assert(o->ref >= 1);
|
||||
pa_assert(o);
|
||||
pa_assert(PA_REFCNT_VALUE(o) >= 1);
|
||||
|
||||
if (st == o->state)
|
||||
return;
|
||||
|
|
@ -85,7 +84,7 @@ static void operation_set_state(pa_operation *o, pa_operation_state_t st) {
|
|||
if ((o->state == PA_OPERATION_DONE) || (o->state == PA_OPERATION_CANCELED)) {
|
||||
|
||||
if (o->context) {
|
||||
assert(o->ref >= 2);
|
||||
pa_assert(PA_REFCNT_VALUE(o) >= 2);
|
||||
|
||||
PA_LLIST_REMOVE(pa_operation, o->context->operations, o);
|
||||
pa_operation_unref(o);
|
||||
|
|
@ -101,22 +100,22 @@ static void operation_set_state(pa_operation *o, pa_operation_state_t st) {
|
|||
}
|
||||
|
||||
void pa_operation_cancel(pa_operation *o) {
|
||||
assert(o);
|
||||
assert(o->ref >= 1);
|
||||
pa_assert(o);
|
||||
pa_assert(PA_REFCNT_VALUE(o) >= 1);
|
||||
|
||||
operation_set_state(o, PA_OPERATION_CANCELED);
|
||||
}
|
||||
|
||||
void pa_operation_done(pa_operation *o) {
|
||||
assert(o);
|
||||
assert(o->ref >= 1);
|
||||
pa_assert(o);
|
||||
pa_assert(PA_REFCNT_VALUE(o) >= 1);
|
||||
|
||||
operation_set_state(o, PA_OPERATION_DONE);
|
||||
}
|
||||
|
||||
pa_operation_state_t pa_operation_get_state(pa_operation *o) {
|
||||
assert(o);
|
||||
assert(o->ref >= 1);
|
||||
pa_assert(o);
|
||||
pa_assert(PA_REFCNT_VALUE(o) >= 1);
|
||||
|
||||
return o->state;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,57 +27,58 @@
|
|||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <pulsecore/core-util.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
#include "sample.h"
|
||||
|
||||
size_t pa_sample_size(const pa_sample_spec *spec) {
|
||||
assert(spec);
|
||||
|
||||
switch (spec->format) {
|
||||
case PA_SAMPLE_U8:
|
||||
case PA_SAMPLE_ULAW:
|
||||
case PA_SAMPLE_ALAW:
|
||||
return 1;
|
||||
case PA_SAMPLE_S16LE:
|
||||
case PA_SAMPLE_S16BE:
|
||||
return 2;
|
||||
case PA_SAMPLE_FLOAT32LE:
|
||||
case PA_SAMPLE_FLOAT32BE:
|
||||
return 4;
|
||||
default:
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
static const size_t table[] = {
|
||||
[PA_SAMPLE_U8] = 1,
|
||||
[PA_SAMPLE_ULAW] = 1,
|
||||
[PA_SAMPLE_ALAW] = 1,
|
||||
[PA_SAMPLE_S16LE] = 2,
|
||||
[PA_SAMPLE_S16BE] = 2,
|
||||
[PA_SAMPLE_FLOAT32LE] = 4,
|
||||
[PA_SAMPLE_FLOAT32BE] = 4
|
||||
};
|
||||
|
||||
pa_assert(spec);
|
||||
pa_assert(spec->format >= 0);
|
||||
pa_assert(spec->format < PA_SAMPLE_MAX);
|
||||
|
||||
return table[spec->format];
|
||||
}
|
||||
|
||||
size_t pa_frame_size(const pa_sample_spec *spec) {
|
||||
assert(spec);
|
||||
pa_assert(spec);
|
||||
|
||||
return pa_sample_size(spec) * spec->channels;
|
||||
}
|
||||
|
||||
size_t pa_bytes_per_second(const pa_sample_spec *spec) {
|
||||
assert(spec);
|
||||
pa_assert(spec);
|
||||
return spec->rate*pa_frame_size(spec);
|
||||
}
|
||||
|
||||
pa_usec_t pa_bytes_to_usec(uint64_t length, const pa_sample_spec *spec) {
|
||||
assert(spec);
|
||||
pa_assert(spec);
|
||||
|
||||
return (pa_usec_t) (((double) length/pa_frame_size(spec)*1000000)/spec->rate);
|
||||
}
|
||||
|
||||
size_t pa_usec_to_bytes(pa_usec_t t, const pa_sample_spec *spec) {
|
||||
assert(spec);
|
||||
pa_assert(spec);
|
||||
|
||||
return (size_t) (((double) t * spec->rate / 1000000))*pa_frame_size(spec);
|
||||
}
|
||||
|
||||
int pa_sample_spec_valid(const pa_sample_spec *spec) {
|
||||
assert(spec);
|
||||
pa_assert(spec);
|
||||
|
||||
if (spec->rate <= 0 ||
|
||||
spec->rate > PA_RATE_MAX ||
|
||||
|
|
@ -91,7 +92,8 @@ int pa_sample_spec_valid(const pa_sample_spec *spec) {
|
|||
}
|
||||
|
||||
int pa_sample_spec_equal(const pa_sample_spec*a, const pa_sample_spec*b) {
|
||||
assert(a && b);
|
||||
pa_assert(a);
|
||||
pa_assert(b);
|
||||
|
||||
return (a->format == b->format) && (a->rate == b->rate) && (a->channels == b->channels);
|
||||
}
|
||||
|
|
@ -107,37 +109,42 @@ const char *pa_sample_format_to_string(pa_sample_format_t f) {
|
|||
[PA_SAMPLE_FLOAT32BE] = "float32be",
|
||||
};
|
||||
|
||||
if (f >= PA_SAMPLE_MAX)
|
||||
if (f < 0 || f >= PA_SAMPLE_MAX)
|
||||
return NULL;
|
||||
|
||||
return table[f];
|
||||
}
|
||||
|
||||
char *pa_sample_spec_snprint(char *s, size_t l, const pa_sample_spec *spec) {
|
||||
assert(s && l && spec);
|
||||
pa_assert(s);
|
||||
pa_assert(l);
|
||||
pa_assert(spec);
|
||||
|
||||
if (!pa_sample_spec_valid(spec))
|
||||
snprintf(s, l, "Invalid");
|
||||
pa_snprintf(s, l, "Invalid");
|
||||
else
|
||||
snprintf(s, l, "%s %uch %uHz", pa_sample_format_to_string(spec->format), spec->channels, spec->rate);
|
||||
pa_snprintf(s, l, "%s %uch %uHz", pa_sample_format_to_string(spec->format), spec->channels, spec->rate);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
char* pa_bytes_snprint(char *s, size_t l, unsigned v) {
|
||||
pa_assert(s);
|
||||
|
||||
if (v >= ((unsigned) 1024)*1024*1024)
|
||||
snprintf(s, l, "%0.1f GiB", ((double) v)/1024/1024/1024);
|
||||
pa_snprintf(s, l, "%0.1f GiB", ((double) v)/1024/1024/1024);
|
||||
else if (v >= ((unsigned) 1024)*1024)
|
||||
snprintf(s, l, "%0.1f MiB", ((double) v)/1024/1024);
|
||||
pa_snprintf(s, l, "%0.1f MiB", ((double) v)/1024/1024);
|
||||
else if (v >= (unsigned) 1024)
|
||||
snprintf(s, l, "%0.1f KiB", ((double) v)/1024);
|
||||
pa_snprintf(s, l, "%0.1f KiB", ((double) v)/1024);
|
||||
else
|
||||
snprintf(s, l, "%u B", (unsigned) v);
|
||||
pa_snprintf(s, l, "%u B", (unsigned) v);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
pa_sample_format_t pa_parse_sample_format(const char *format) {
|
||||
pa_assert(format);
|
||||
|
||||
if (strcasecmp(format, "s16le") == 0)
|
||||
return PA_SAMPLE_S16LE;
|
||||
|
|
@ -145,15 +152,19 @@ pa_sample_format_t pa_parse_sample_format(const char *format) {
|
|||
return PA_SAMPLE_S16BE;
|
||||
else if (strcasecmp(format, "s16ne") == 0 || strcasecmp(format, "s16") == 0 || strcasecmp(format, "16") == 0)
|
||||
return PA_SAMPLE_S16NE;
|
||||
else if (strcasecmp(format, "s16re") == 0)
|
||||
return PA_SAMPLE_S16RE;
|
||||
else if (strcasecmp(format, "u8") == 0 || strcasecmp(format, "8") == 0)
|
||||
return PA_SAMPLE_U8;
|
||||
else if (strcasecmp(format, "float32") == 0 || strcasecmp(format, "float32ne") == 0)
|
||||
return PA_SAMPLE_FLOAT32;
|
||||
return PA_SAMPLE_FLOAT32NE;
|
||||
else if (strcasecmp(format, "float32re") == 0)
|
||||
return PA_SAMPLE_FLOAT32RE;
|
||||
else if (strcasecmp(format, "float32le") == 0)
|
||||
return PA_SAMPLE_FLOAT32LE;
|
||||
else if (strcasecmp(format, "float32be") == 0)
|
||||
return PA_SAMPLE_FLOAT32BE;
|
||||
else if (strcasecmp(format, "ulaw") == 0)
|
||||
else if (strcasecmp(format, "ulaw") == 0 || strcasecmp(format, "mulaw") == 0)
|
||||
return PA_SAMPLE_ULAW;
|
||||
else if (strcasecmp(format, "alaw") == 0)
|
||||
return PA_SAMPLE_ALAW;
|
||||
|
|
|
|||
|
|
@ -155,31 +155,31 @@ typedef struct pa_sample_spec {
|
|||
typedef uint64_t pa_usec_t;
|
||||
|
||||
/** Return the amount of bytes playback of a second of audio with the specified sample type takes */
|
||||
size_t pa_bytes_per_second(const pa_sample_spec *spec);
|
||||
size_t pa_bytes_per_second(const pa_sample_spec *spec) PA_GCC_PURE;
|
||||
|
||||
/** Return the size of a frame with the specific sample type */
|
||||
size_t pa_frame_size(const pa_sample_spec *spec);
|
||||
size_t pa_frame_size(const pa_sample_spec *spec) PA_GCC_PURE;
|
||||
|
||||
/** Return the size of a sample with the specific sample type */
|
||||
size_t pa_sample_size(const pa_sample_spec *spec);
|
||||
size_t pa_sample_size(const pa_sample_spec *spec) PA_GCC_PURE;
|
||||
|
||||
/** Calculate the time the specified bytes take to play with the specified sample type */
|
||||
pa_usec_t pa_bytes_to_usec(uint64_t length, const pa_sample_spec *spec);
|
||||
pa_usec_t pa_bytes_to_usec(uint64_t length, const pa_sample_spec *spec) PA_GCC_PURE;
|
||||
|
||||
/** Calculates the number of bytes that are required for the specified time. \since 0.9 */
|
||||
size_t pa_usec_to_bytes(pa_usec_t t, const pa_sample_spec *spec);
|
||||
size_t pa_usec_to_bytes(pa_usec_t t, const pa_sample_spec *spec) PA_GCC_PURE;
|
||||
|
||||
/** Return non-zero when the sample type specification is valid */
|
||||
int pa_sample_spec_valid(const pa_sample_spec *spec);
|
||||
int pa_sample_spec_valid(const pa_sample_spec *spec) PA_GCC_PURE;
|
||||
|
||||
/** Return non-zero when the two sample type specifications match */
|
||||
int pa_sample_spec_equal(const pa_sample_spec*a, const pa_sample_spec*b);
|
||||
int pa_sample_spec_equal(const pa_sample_spec*a, const pa_sample_spec*b) PA_GCC_PURE;
|
||||
|
||||
/** Return a descriptive string for the specified sample format. \since 0.8 */
|
||||
const char *pa_sample_format_to_string(pa_sample_format_t f);
|
||||
const char *pa_sample_format_to_string(pa_sample_format_t f) PA_GCC_PURE;
|
||||
|
||||
/** Parse a sample format text. Inverse of pa_sample_format_to_string() */
|
||||
pa_sample_format_t pa_parse_sample_format(const char *format);
|
||||
pa_sample_format_t pa_parse_sample_format(const char *format) PA_GCC_PURE;
|
||||
|
||||
/** Maximum required string length for pa_sample_spec_snprint() */
|
||||
#define PA_SAMPLE_SPEC_SNPRINT_MAX 32
|
||||
|
|
|
|||
|
|
@ -25,12 +25,12 @@
|
|||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <pulsecore/pstream-util.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
|
@ -40,7 +40,8 @@ int pa_stream_connect_upload(pa_stream *s, size_t length) {
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(s);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_UNCONNECTED, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY(s->context, length > 0, PA_ERR_INVALID);
|
||||
|
|
@ -66,7 +67,9 @@ int pa_stream_connect_upload(pa_stream *s, size_t length) {
|
|||
int pa_stream_finish_upload(pa_stream *s) {
|
||||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
assert(s);
|
||||
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY(s->context, s->channel_valid, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY(s->context, s->context->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
|
|
@ -87,8 +90,8 @@ pa_operation *pa_context_play_sample(pa_context *c, const char *name, const char
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, name && *name, PA_ERR_INVALID);
|
||||
|
|
@ -115,8 +118,8 @@ pa_operation* pa_context_remove_sample(pa_context *c, const char *name, pa_conte
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, name && *name, PA_ERR_INVALID);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
/* $Id$ */
|
||||
|
||||
/***
|
||||
|
|
@ -27,7 +28,6 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <pulse/pulseaudio.h>
|
||||
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
#include <pulsecore/native-common.h>
|
||||
#include <pulsecore/log.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
#include "simple.h"
|
||||
|
||||
|
|
@ -83,8 +84,8 @@ if (!(p)->context || pa_context_get_state((p)->context) != PA_CONTEXT_READY || \
|
|||
|
||||
static void context_state_cb(pa_context *c, void *userdata) {
|
||||
pa_simple *p = userdata;
|
||||
assert(c);
|
||||
assert(p);
|
||||
pa_assert(c);
|
||||
pa_assert(p);
|
||||
|
||||
switch (pa_context_get_state(c)) {
|
||||
case PA_CONTEXT_READY:
|
||||
|
|
@ -103,8 +104,8 @@ static void context_state_cb(pa_context *c, void *userdata) {
|
|||
|
||||
static void stream_state_cb(pa_stream *s, void * userdata) {
|
||||
pa_simple *p = userdata;
|
||||
assert(s);
|
||||
assert(p);
|
||||
pa_assert(s);
|
||||
pa_assert(p);
|
||||
|
||||
switch (pa_stream_get_state(s)) {
|
||||
|
||||
|
|
@ -122,7 +123,7 @@ static void stream_state_cb(pa_stream *s, void * userdata) {
|
|||
|
||||
static void stream_request_cb(pa_stream *s, size_t length, void *userdata) {
|
||||
pa_simple *p = userdata;
|
||||
assert(p);
|
||||
pa_assert(p);
|
||||
|
||||
pa_threaded_mainloop_signal(p->mainloop, 0);
|
||||
}
|
||||
|
|
@ -130,21 +131,21 @@ static void stream_request_cb(pa_stream *s, size_t length, void *userdata) {
|
|||
static void stream_latency_update_cb(pa_stream *s, void *userdata) {
|
||||
pa_simple *p = userdata;
|
||||
|
||||
assert(p);
|
||||
pa_assert(p);
|
||||
|
||||
pa_threaded_mainloop_signal(p->mainloop, 0);
|
||||
}
|
||||
|
||||
pa_simple* pa_simple_new(
|
||||
const char *server,
|
||||
const char *name,
|
||||
pa_stream_direction_t dir,
|
||||
const char *dev,
|
||||
const char *stream_name,
|
||||
const pa_sample_spec *ss,
|
||||
const pa_channel_map *map,
|
||||
const pa_buffer_attr *attr,
|
||||
int *rerror) {
|
||||
const char *server,
|
||||
const char *name,
|
||||
pa_stream_direction_t dir,
|
||||
const char *dev,
|
||||
const char *stream_name,
|
||||
const pa_sample_spec *ss,
|
||||
const pa_channel_map *map,
|
||||
const pa_buffer_attr *attr,
|
||||
int *rerror) {
|
||||
|
||||
pa_simple *p;
|
||||
int error = PA_ERR_INTERNAL, r;
|
||||
|
|
@ -232,7 +233,7 @@ fail:
|
|||
}
|
||||
|
||||
void pa_simple_free(pa_simple *s) {
|
||||
assert(s);
|
||||
pa_assert(s);
|
||||
|
||||
if (s->mainloop)
|
||||
pa_threaded_mainloop_stop(s->mainloop);
|
||||
|
|
@ -250,7 +251,7 @@ void pa_simple_free(pa_simple *s) {
|
|||
}
|
||||
|
||||
int pa_simple_write(pa_simple *p, const void*data, size_t length, int *rerror) {
|
||||
assert(p);
|
||||
pa_assert(p);
|
||||
|
||||
CHECK_VALIDITY_RETURN_ANY(rerror, p->direction == PA_STREAM_PLAYBACK, PA_ERR_BADSTATE, -1);
|
||||
CHECK_VALIDITY_RETURN_ANY(rerror, data && length, PA_ERR_INVALID, -1);
|
||||
|
|
@ -289,7 +290,7 @@ unlock_and_fail:
|
|||
}
|
||||
|
||||
int pa_simple_read(pa_simple *p, void*data, size_t length, int *rerror) {
|
||||
assert(p);
|
||||
pa_assert(p);
|
||||
|
||||
CHECK_VALIDITY_RETURN_ANY(rerror, p->direction == PA_STREAM_RECORD, PA_ERR_BADSTATE, -1);
|
||||
CHECK_VALIDITY_RETURN_ANY(rerror, data && length, PA_ERR_INVALID, -1);
|
||||
|
|
@ -346,8 +347,8 @@ unlock_and_fail:
|
|||
static void success_cb(pa_stream *s, int success, void *userdata) {
|
||||
pa_simple *p = userdata;
|
||||
|
||||
assert(s);
|
||||
assert(p);
|
||||
pa_assert(s);
|
||||
pa_assert(p);
|
||||
|
||||
p->operation_success = success;
|
||||
pa_threaded_mainloop_signal(p->mainloop, 0);
|
||||
|
|
@ -356,7 +357,7 @@ static void success_cb(pa_stream *s, int success, void *userdata) {
|
|||
int pa_simple_drain(pa_simple *p, int *rerror) {
|
||||
pa_operation *o = NULL;
|
||||
|
||||
assert(p);
|
||||
pa_assert(p);
|
||||
|
||||
CHECK_VALIDITY_RETURN_ANY(rerror, p->direction == PA_STREAM_PLAYBACK, PA_ERR_BADSTATE, -1);
|
||||
|
||||
|
|
@ -392,7 +393,7 @@ unlock_and_fail:
|
|||
int pa_simple_flush(pa_simple *p, int *rerror) {
|
||||
pa_operation *o = NULL;
|
||||
|
||||
assert(p);
|
||||
pa_assert(p);
|
||||
|
||||
CHECK_VALIDITY_RETURN_ANY(rerror, p->direction == PA_STREAM_PLAYBACK, PA_ERR_BADSTATE, -1);
|
||||
|
||||
|
|
@ -429,7 +430,7 @@ pa_usec_t pa_simple_get_latency(pa_simple *p, int *rerror) {
|
|||
pa_usec_t t;
|
||||
int negative;
|
||||
|
||||
assert(p);
|
||||
pa_assert(p);
|
||||
|
||||
pa_threaded_mainloop_lock(p->mainloop);
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@
|
|||
* pa_simple *s;
|
||||
* pa_sample_spec ss;
|
||||
*
|
||||
* ss.format = PA_SAMPLE_S16_NE;
|
||||
* ss.format = PA_SAMPLE_S16NE;
|
||||
* ss.channels = 2;
|
||||
* ss.rate = 44100;
|
||||
*
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
|
@ -38,6 +37,7 @@
|
|||
#include <pulsecore/pstream-util.h>
|
||||
#include <pulsecore/log.h>
|
||||
#include <pulsecore/hashmap.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
|
@ -47,13 +47,14 @@ pa_stream *pa_stream_new(pa_context *c, const char *name, const pa_sample_spec *
|
|||
pa_stream *s;
|
||||
int i;
|
||||
|
||||
assert(c);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, ss && pa_sample_spec_valid(ss), PA_ERR_INVALID);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, !map || (pa_channel_map_valid(map) && map->channels == ss->channels), PA_ERR_INVALID);
|
||||
|
||||
s = pa_xnew(pa_stream, 1);
|
||||
s->ref = 1;
|
||||
PA_REFCNT_INIT(s);
|
||||
s->context = c;
|
||||
s->mainloop = c->mainloop;
|
||||
|
||||
|
|
@ -91,6 +92,7 @@ pa_stream *pa_stream_new(pa_context *c, const char *name, const pa_sample_spec *
|
|||
s->peek_memchunk.index = 0;
|
||||
s->peek_memchunk.length = 0;
|
||||
s->peek_memchunk.memblock = NULL;
|
||||
s->peek_data = NULL;
|
||||
|
||||
s->record_memblockq = NULL;
|
||||
|
||||
|
|
@ -118,15 +120,20 @@ pa_stream *pa_stream_new(pa_context *c, const char *name, const pa_sample_spec *
|
|||
}
|
||||
|
||||
static void stream_free(pa_stream *s) {
|
||||
assert(s && !s->context && !s->channel_valid);
|
||||
pa_assert(s);
|
||||
pa_assert(!s->context);
|
||||
pa_assert(!s->channel_valid);
|
||||
|
||||
if (s->auto_timing_update_event) {
|
||||
assert(s->mainloop);
|
||||
pa_assert(s->mainloop);
|
||||
s->mainloop->time_free(s->auto_timing_update_event);
|
||||
}
|
||||
|
||||
if (s->peek_memchunk.memblock)
|
||||
if (s->peek_memchunk.memblock) {
|
||||
if (s->peek_data)
|
||||
pa_memblock_release(s->peek_memchunk.memblock);
|
||||
pa_memblock_unref(s->peek_memchunk.memblock);
|
||||
}
|
||||
|
||||
if (s->record_memblockq)
|
||||
pa_memblockq_free(s->record_memblockq);
|
||||
|
|
@ -136,38 +143,38 @@ static void stream_free(pa_stream *s) {
|
|||
}
|
||||
|
||||
void pa_stream_unref(pa_stream *s) {
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
if (--(s->ref) == 0)
|
||||
if (PA_REFCNT_DEC(s) <= 0)
|
||||
stream_free(s);
|
||||
}
|
||||
|
||||
pa_stream* pa_stream_ref(pa_stream *s) {
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
s->ref++;
|
||||
PA_REFCNT_INC(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
pa_stream_state_t pa_stream_get_state(pa_stream *s) {
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
return s->state;
|
||||
}
|
||||
|
||||
pa_context* pa_stream_get_context(pa_stream *s) {
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
return s->context;
|
||||
}
|
||||
|
||||
uint32_t pa_stream_get_index(pa_stream *s) {
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE, PA_INVALID_INDEX);
|
||||
|
||||
|
|
@ -175,8 +182,8 @@ uint32_t pa_stream_get_index(pa_stream *s) {
|
|||
}
|
||||
|
||||
void pa_stream_set_state(pa_stream *s, pa_stream_state_t st) {
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
if (s->state == st)
|
||||
return;
|
||||
|
|
@ -214,6 +221,13 @@ void pa_stream_set_state(pa_stream *s, pa_stream_state_t st) {
|
|||
s->channel_valid = 0;
|
||||
|
||||
s->context = NULL;
|
||||
|
||||
s->read_callback = NULL;
|
||||
s->write_callback = NULL;
|
||||
s->state_callback = NULL;
|
||||
s->overflow_callback = NULL;
|
||||
s->underflow_callback = NULL;
|
||||
s->latency_update_callback = NULL;
|
||||
}
|
||||
|
||||
pa_stream_unref(s);
|
||||
|
|
@ -224,10 +238,11 @@ void pa_command_stream_killed(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED
|
|||
pa_stream *s;
|
||||
uint32_t channel;
|
||||
|
||||
assert(pd);
|
||||
assert(command == PA_COMMAND_PLAYBACK_STREAM_KILLED || command == PA_COMMAND_RECORD_STREAM_KILLED);
|
||||
assert(t);
|
||||
assert(c);
|
||||
pa_assert(pd);
|
||||
pa_assert(command == PA_COMMAND_PLAYBACK_STREAM_KILLED || command == PA_COMMAND_RECORD_STREAM_KILLED);
|
||||
pa_assert(t);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
pa_context_ref(c);
|
||||
|
||||
|
|
@ -252,10 +267,11 @@ void pa_command_request(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32
|
|||
pa_context *c = userdata;
|
||||
uint32_t bytes, channel;
|
||||
|
||||
assert(pd);
|
||||
assert(command == PA_COMMAND_REQUEST);
|
||||
assert(t);
|
||||
assert(c);
|
||||
pa_assert(pd);
|
||||
pa_assert(command == PA_COMMAND_REQUEST);
|
||||
pa_assert(t);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
pa_context_ref(c);
|
||||
|
||||
|
|
@ -285,10 +301,11 @@ void pa_command_overflow_or_underflow(pa_pdispatch *pd, uint32_t command, PA_GCC
|
|||
pa_context *c = userdata;
|
||||
uint32_t channel;
|
||||
|
||||
assert(pd);
|
||||
assert(command == PA_COMMAND_OVERFLOW || command == PA_COMMAND_UNDERFLOW);
|
||||
assert(t);
|
||||
assert(c);
|
||||
pa_assert(pd);
|
||||
pa_assert(command == PA_COMMAND_OVERFLOW || command == PA_COMMAND_UNDERFLOW);
|
||||
pa_assert(t);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
pa_context_ref(c);
|
||||
|
||||
|
|
@ -317,8 +334,8 @@ void pa_command_overflow_or_underflow(pa_pdispatch *pd, uint32_t command, PA_GCC
|
|||
}
|
||||
|
||||
static void request_auto_timing_update(pa_stream *s, int force) {
|
||||
struct timeval next;
|
||||
assert(s);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
if (!(s->flags & PA_STREAM_AUTO_TIMING_UPDATE))
|
||||
return;
|
||||
|
|
@ -335,13 +352,17 @@ static void request_auto_timing_update(pa_stream *s, int force) {
|
|||
}
|
||||
}
|
||||
|
||||
pa_gettimeofday(&next);
|
||||
pa_timeval_add(&next, LATENCY_IPOL_INTERVAL_USEC);
|
||||
s->mainloop->time_restart(s->auto_timing_update_event, &next);
|
||||
if (s->auto_timing_update_event) {
|
||||
struct timeval next;
|
||||
pa_gettimeofday(&next);
|
||||
pa_timeval_add(&next, LATENCY_IPOL_INTERVAL_USEC);
|
||||
s->mainloop->time_restart(s->auto_timing_update_event, &next);
|
||||
}
|
||||
}
|
||||
|
||||
static void invalidate_indexes(pa_stream *s, int r, int w) {
|
||||
assert(s);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
/* pa_log("invalidate r:%u w:%u tag:%u", r, w, s->context->ctag); */
|
||||
|
||||
|
|
@ -376,6 +397,9 @@ static void invalidate_indexes(pa_stream *s, int r, int w) {
|
|||
static void auto_timing_update_callback(PA_GCC_UNUSED pa_mainloop_api *m, PA_GCC_UNUSED pa_time_event *e, PA_GCC_UNUSED const struct timeval *tv, void *userdata) {
|
||||
pa_stream *s = userdata;
|
||||
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
/* pa_log("time event"); */
|
||||
|
||||
pa_stream_ref(s);
|
||||
|
|
@ -383,12 +407,32 @@ static void auto_timing_update_callback(PA_GCC_UNUSED pa_mainloop_api *m, PA_GCC
|
|||
pa_stream_unref(s);
|
||||
}
|
||||
|
||||
static void create_stream_complete(pa_stream *s) {
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
pa_assert(s->state == PA_STREAM_CREATING);
|
||||
|
||||
pa_stream_set_state(s, PA_STREAM_READY);
|
||||
|
||||
if (s->requested_bytes > 0 && s->write_callback)
|
||||
s->write_callback(s, s->requested_bytes, s->write_userdata);
|
||||
|
||||
if (s->flags & PA_STREAM_AUTO_TIMING_UPDATE) {
|
||||
struct timeval tv;
|
||||
pa_gettimeofday(&tv);
|
||||
tv.tv_usec += LATENCY_IPOL_INTERVAL_USEC; /* every 100 ms */
|
||||
pa_assert(!s->auto_timing_update_event);
|
||||
s->auto_timing_update_event = s->mainloop->time_new(s->mainloop, &tv, &auto_timing_update_callback, s);
|
||||
}
|
||||
}
|
||||
|
||||
void pa_create_stream_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
|
||||
pa_stream *s = userdata;
|
||||
|
||||
assert(pd);
|
||||
assert(s);
|
||||
assert(s->state == PA_STREAM_CREATING);
|
||||
pa_assert(pd);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
pa_assert(s->state == PA_STREAM_CREATING);
|
||||
|
||||
pa_stream_ref(s);
|
||||
|
||||
|
|
@ -431,7 +475,7 @@ void pa_create_stream_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED
|
|||
}
|
||||
|
||||
if (s->direction == PA_STREAM_RECORD) {
|
||||
assert(!s->record_memblockq);
|
||||
pa_assert(!s->record_memblockq);
|
||||
|
||||
s->record_memblockq = pa_memblockq_new(
|
||||
0,
|
||||
|
|
@ -446,23 +490,16 @@ void pa_create_stream_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED
|
|||
s->channel_valid = 1;
|
||||
pa_dynarray_put((s->direction == PA_STREAM_RECORD) ? s->context->record_streams : s->context->playback_streams, s->channel, s);
|
||||
|
||||
pa_stream_set_state(s, PA_STREAM_READY);
|
||||
|
||||
if (s->direction != PA_STREAM_UPLOAD &&
|
||||
s->flags & PA_STREAM_AUTO_TIMING_UPDATE) {
|
||||
struct timeval tv;
|
||||
|
||||
pa_gettimeofday(&tv);
|
||||
tv.tv_usec += LATENCY_IPOL_INTERVAL_USEC; /* every 100 ms */
|
||||
|
||||
assert(!s->auto_timing_update_event);
|
||||
s->auto_timing_update_event = s->mainloop->time_new(s->mainloop, &tv, &auto_timing_update_callback, s);
|
||||
|
||||
if (s->direction != PA_STREAM_UPLOAD && s->flags & PA_STREAM_AUTO_TIMING_UPDATE) {
|
||||
/* If automatic timing updates are active, we wait for the
|
||||
* first timing update before going to PA_STREAM_READY
|
||||
* state */
|
||||
s->state = PA_STREAM_READY;
|
||||
request_auto_timing_update(s, 1);
|
||||
}
|
||||
s->state = PA_STREAM_CREATING;
|
||||
|
||||
if (s->requested_bytes > 0 && s->ref > 1 && s->write_callback)
|
||||
s->write_callback(s, s->requested_bytes, s->write_userdata);
|
||||
} else
|
||||
create_stream_complete(s);
|
||||
|
||||
finish:
|
||||
pa_stream_unref(s);
|
||||
|
|
@ -480,8 +517,8 @@ static int create_stream(
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_UNCONNECTED, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY(s->context, !(flags & ~((direction != PA_STREAM_UPLOAD ?
|
||||
|
|
@ -503,12 +540,12 @@ static int create_stream(
|
|||
if (attr)
|
||||
s->buffer_attr = *attr;
|
||||
else {
|
||||
/* half a second */
|
||||
/* half a second, with minimum request of 10 ms */
|
||||
s->buffer_attr.tlength = pa_bytes_per_second(&s->sample_spec)/2;
|
||||
s->buffer_attr.maxlength = (s->buffer_attr.tlength*3)/2;
|
||||
s->buffer_attr.minreq = s->buffer_attr.tlength/100;
|
||||
s->buffer_attr.minreq = s->buffer_attr.tlength/50;
|
||||
s->buffer_attr.prebuf = s->buffer_attr.tlength - s->buffer_attr.minreq;
|
||||
s->buffer_attr.fragsize = s->buffer_attr.tlength/100;
|
||||
s->buffer_attr.fragsize = s->buffer_attr.tlength/50;
|
||||
}
|
||||
|
||||
if (!dev)
|
||||
|
|
@ -565,8 +602,8 @@ int pa_stream_connect_playback(
|
|||
pa_cvolume *volume,
|
||||
pa_stream *sync_stream) {
|
||||
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
return create_stream(PA_STREAM_PLAYBACK, s, dev, attr, flags, volume, sync_stream);
|
||||
}
|
||||
|
|
@ -577,8 +614,8 @@ int pa_stream_connect_record(
|
|||
const pa_buffer_attr *attr,
|
||||
pa_stream_flags_t flags) {
|
||||
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
return create_stream(PA_STREAM_RECORD, s, dev, attr, flags, NULL, NULL);
|
||||
}
|
||||
|
|
@ -593,9 +630,9 @@ int pa_stream_write(
|
|||
|
||||
pa_memchunk chunk;
|
||||
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
assert(data);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
pa_assert(data);
|
||||
|
||||
PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY(s->context, s->direction == PA_STREAM_PLAYBACK || s->direction == PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
|
||||
|
|
@ -608,8 +645,11 @@ int pa_stream_write(
|
|||
if (free_cb)
|
||||
chunk.memblock = pa_memblock_new_user(s->context->mempool, (void*) data, length, free_cb, 1);
|
||||
else {
|
||||
void *tdata;
|
||||
chunk.memblock = pa_memblock_new(s->context->mempool, length);
|
||||
memcpy(chunk.memblock->data, data, length);
|
||||
tdata = pa_memblock_acquire(chunk.memblock);
|
||||
memcpy(tdata, data, length);
|
||||
pa_memblock_release(chunk.memblock);
|
||||
}
|
||||
|
||||
chunk.index = 0;
|
||||
|
|
@ -660,10 +700,10 @@ int pa_stream_write(
|
|||
}
|
||||
|
||||
int pa_stream_peek(pa_stream *s, const void **data, size_t *length) {
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
assert(data);
|
||||
assert(length);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
pa_assert(data);
|
||||
pa_assert(length);
|
||||
|
||||
PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY(s->context, s->direction == PA_STREAM_RECORD, PA_ERR_BADSTATE);
|
||||
|
|
@ -675,27 +715,32 @@ int pa_stream_peek(pa_stream *s, const void **data, size_t *length) {
|
|||
*length = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
s->peek_data = pa_memblock_acquire(s->peek_memchunk.memblock);
|
||||
}
|
||||
|
||||
*data = (const char*) s->peek_memchunk.memblock->data + s->peek_memchunk.index;
|
||||
pa_assert(s->peek_data);
|
||||
*data = (uint8_t*) s->peek_data + s->peek_memchunk.index;
|
||||
*length = s->peek_memchunk.length;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pa_stream_drop(pa_stream *s) {
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY(s->context, s->direction == PA_STREAM_RECORD, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY(s->context, s->peek_memchunk.memblock, PA_ERR_BADSTATE);
|
||||
|
||||
pa_memblockq_drop(s->record_memblockq, &s->peek_memchunk, s->peek_memchunk.length);
|
||||
pa_memblockq_drop(s->record_memblockq, s->peek_memchunk.length);
|
||||
|
||||
/* Fix the simulated local read index */
|
||||
if (s->timing_info_valid && !s->timing_info.read_index_corrupt)
|
||||
s->timing_info.read_index += s->peek_memchunk.length;
|
||||
|
||||
pa_assert(s->peek_data);
|
||||
pa_memblock_release(s->peek_memchunk.memblock);
|
||||
pa_memblock_unref(s->peek_memchunk.memblock);
|
||||
s->peek_memchunk.length = 0;
|
||||
s->peek_memchunk.index = 0;
|
||||
|
|
@ -705,8 +750,8 @@ int pa_stream_drop(pa_stream *s) {
|
|||
}
|
||||
|
||||
size_t pa_stream_writable_size(pa_stream *s) {
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE, (size_t) -1);
|
||||
PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->direction != PA_STREAM_RECORD, PA_ERR_BADSTATE, (size_t) -1);
|
||||
|
|
@ -715,8 +760,8 @@ size_t pa_stream_writable_size(pa_stream *s) {
|
|||
}
|
||||
|
||||
size_t pa_stream_readable_size(pa_stream *s) {
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE, (size_t) -1);
|
||||
PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->direction == PA_STREAM_RECORD, PA_ERR_BADSTATE, (size_t) -1);
|
||||
|
|
@ -729,8 +774,8 @@ pa_operation * pa_stream_drain(pa_stream *s, pa_stream_success_cb_t cb, void *us
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction == PA_STREAM_PLAYBACK, PA_ERR_BADSTATE);
|
||||
|
|
@ -750,8 +795,9 @@ static void stream_get_timing_info_callback(pa_pdispatch *pd, uint32_t command,
|
|||
struct timeval local, remote, now;
|
||||
pa_timing_info *i;
|
||||
|
||||
assert(pd);
|
||||
assert(o);
|
||||
pa_assert(pd);
|
||||
pa_assert(o);
|
||||
pa_assert(PA_REFCNT_VALUE(o) >= 1);
|
||||
|
||||
if (!o->context || !o->stream)
|
||||
goto finish;
|
||||
|
|
@ -874,6 +920,10 @@ static void stream_get_timing_info_callback(pa_pdispatch *pd, uint32_t command,
|
|||
}
|
||||
}
|
||||
|
||||
/* First, let's complete the initialization, if necessary. */
|
||||
if (o->stream->state == PA_STREAM_CREATING)
|
||||
create_stream_complete(o->stream);
|
||||
|
||||
if (o->stream->latency_update_callback)
|
||||
o->stream->latency_update_callback(o->stream, o->stream->latency_update_userdata);
|
||||
|
||||
|
|
@ -895,8 +945,8 @@ pa_operation* pa_stream_update_timing_info(pa_stream *s, pa_stream_success_cb_t
|
|||
struct timeval now;
|
||||
int cidx = 0;
|
||||
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
|
||||
|
|
@ -938,9 +988,9 @@ pa_operation* pa_stream_update_timing_info(pa_stream *s, pa_stream_success_cb_t
|
|||
void pa_stream_disconnect_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
|
||||
pa_stream *s = userdata;
|
||||
|
||||
assert(pd);
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(pd);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
pa_stream_ref(s);
|
||||
|
||||
|
|
@ -965,8 +1015,8 @@ int pa_stream_disconnect(pa_stream *s) {
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY(s->context, s->channel_valid, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY(s->context, s->context->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
|
|
@ -987,48 +1037,48 @@ int pa_stream_disconnect(pa_stream *s) {
|
|||
}
|
||||
|
||||
void pa_stream_set_read_callback(pa_stream *s, pa_stream_request_cb_t cb, void *userdata) {
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
s->read_callback = cb;
|
||||
s->read_userdata = userdata;
|
||||
}
|
||||
|
||||
void pa_stream_set_write_callback(pa_stream *s, pa_stream_request_cb_t cb, void *userdata) {
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
s->write_callback = cb;
|
||||
s->write_userdata = userdata;
|
||||
}
|
||||
|
||||
void pa_stream_set_state_callback(pa_stream *s, pa_stream_notify_cb_t cb, void *userdata) {
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
s->state_callback = cb;
|
||||
s->state_userdata = userdata;
|
||||
}
|
||||
|
||||
void pa_stream_set_overflow_callback(pa_stream *s, pa_stream_notify_cb_t cb, void *userdata) {
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
s->overflow_callback = cb;
|
||||
s->overflow_userdata = userdata;
|
||||
}
|
||||
|
||||
void pa_stream_set_underflow_callback(pa_stream *s, pa_stream_notify_cb_t cb, void *userdata) {
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
s->underflow_callback = cb;
|
||||
s->underflow_userdata = userdata;
|
||||
}
|
||||
|
||||
void pa_stream_set_latency_update_callback(pa_stream *s, pa_stream_notify_cb_t cb, void *userdata) {
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
s->latency_update_callback = cb;
|
||||
s->latency_update_userdata = userdata;
|
||||
|
|
@ -1038,9 +1088,9 @@ void pa_stream_simple_ack_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UN
|
|||
pa_operation *o = userdata;
|
||||
int success = 1;
|
||||
|
||||
assert(pd);
|
||||
assert(o);
|
||||
assert(o->ref >= 1);
|
||||
pa_assert(pd);
|
||||
pa_assert(o);
|
||||
pa_assert(PA_REFCNT_VALUE(o) >= 1);
|
||||
|
||||
if (!o->context)
|
||||
goto finish;
|
||||
|
|
@ -1070,8 +1120,8 @@ pa_operation* pa_stream_cork(pa_stream *s, int b, pa_stream_success_cb_t cb, voi
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
|
||||
|
|
@ -1100,8 +1150,8 @@ static pa_operation* stream_send_simple_command(pa_stream *s, uint32_t command,
|
|||
pa_operation *o;
|
||||
uint32_t tag;
|
||||
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
|
||||
|
||||
|
|
@ -1118,6 +1168,9 @@ static pa_operation* stream_send_simple_command(pa_stream *s, uint32_t command,
|
|||
pa_operation* pa_stream_flush(pa_stream *s, pa_stream_success_cb_t cb, void *userdata) {
|
||||
pa_operation *o;
|
||||
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
|
||||
|
||||
if ((o = stream_send_simple_command(s, s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_FLUSH_PLAYBACK_STREAM : PA_COMMAND_FLUSH_RECORD_STREAM, cb, userdata))) {
|
||||
|
|
@ -1143,6 +1196,9 @@ pa_operation* pa_stream_flush(pa_stream *s, pa_stream_success_cb_t cb, void *use
|
|||
pa_operation* pa_stream_prebuf(pa_stream *s, pa_stream_success_cb_t cb, void *userdata) {
|
||||
pa_operation *o;
|
||||
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction == PA_STREAM_PLAYBACK, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->buffer_attr.prebuf > 0, PA_ERR_BADSTATE);
|
||||
|
||||
|
|
@ -1155,6 +1211,9 @@ pa_operation* pa_stream_prebuf(pa_stream *s, pa_stream_success_cb_t cb, void *us
|
|||
pa_operation* pa_stream_trigger(pa_stream *s, pa_stream_success_cb_t cb, void *userdata) {
|
||||
pa_operation *o;
|
||||
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction == PA_STREAM_PLAYBACK, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->buffer_attr.prebuf > 0, PA_ERR_BADSTATE);
|
||||
|
||||
|
|
@ -1169,9 +1228,9 @@ pa_operation* pa_stream_set_name(pa_stream *s, const char *name, pa_stream_succe
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
assert(name);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
pa_assert(name);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
|
||||
|
|
@ -1193,8 +1252,8 @@ pa_operation* pa_stream_set_name(pa_stream *s, const char *name, pa_stream_succe
|
|||
int pa_stream_get_time(pa_stream *s, pa_usec_t *r_usec) {
|
||||
pa_usec_t usec = 0;
|
||||
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
|
||||
|
|
@ -1277,8 +1336,8 @@ int pa_stream_get_time(pa_stream *s, pa_usec_t *r_usec) {
|
|||
}
|
||||
|
||||
static pa_usec_t time_counter_diff(pa_stream *s, pa_usec_t a, pa_usec_t b, int *negative) {
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
if (negative)
|
||||
*negative = 0;
|
||||
|
|
@ -1299,9 +1358,9 @@ int pa_stream_get_latency(pa_stream *s, pa_usec_t *r_usec, int *negative) {
|
|||
int r;
|
||||
int64_t cindex;
|
||||
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
assert(r_usec);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
pa_assert(r_usec);
|
||||
|
||||
PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
|
||||
|
|
@ -1331,8 +1390,8 @@ int pa_stream_get_latency(pa_stream *s, pa_usec_t *r_usec, int *negative) {
|
|||
}
|
||||
|
||||
const pa_timing_info* pa_stream_get_timing_info(pa_stream *s) {
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
|
||||
|
|
@ -1342,22 +1401,22 @@ const pa_timing_info* pa_stream_get_timing_info(pa_stream *s) {
|
|||
}
|
||||
|
||||
const pa_sample_spec* pa_stream_get_sample_spec(pa_stream *s) {
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
return &s->sample_spec;
|
||||
}
|
||||
|
||||
const pa_channel_map* pa_stream_get_channel_map(pa_stream *s) {
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
return &s->channel_map;
|
||||
}
|
||||
|
||||
const pa_buffer_attr* pa_stream_get_buffer_attr(pa_stream *s) {
|
||||
assert(s);
|
||||
assert(s->ref >= 1);
|
||||
pa_assert(s);
|
||||
pa_assert(PA_REFCNT_VALUE(s) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@
|
|||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <pulsecore/gccmacro.h>
|
||||
#include <pulsecore/macro.h>
|
||||
#include <pulsecore/pstream-util.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
|
@ -40,10 +40,11 @@ void pa_command_subscribe_event(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSE
|
|||
pa_subscription_event_type_t e;
|
||||
uint32_t idx;
|
||||
|
||||
assert(pd);
|
||||
assert(command == PA_COMMAND_SUBSCRIBE_EVENT);
|
||||
assert(t);
|
||||
assert(c);
|
||||
pa_assert(pd);
|
||||
pa_assert(command == PA_COMMAND_SUBSCRIBE_EVENT);
|
||||
pa_assert(t);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
pa_context_ref(c);
|
||||
|
||||
|
|
@ -67,8 +68,8 @@ pa_operation* pa_context_subscribe(pa_context *c, pa_subscription_mask_t m, pa_c
|
|||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
|
||||
|
|
@ -83,8 +84,8 @@ pa_operation* pa_context_subscribe(pa_context *c, pa_subscription_mask_t m, pa_c
|
|||
}
|
||||
|
||||
void pa_context_set_subscribe_callback(pa_context *c, pa_context_subscribe_cb_t cb, void *userdata) {
|
||||
assert(c);
|
||||
assert(c->ref >= 1);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
c->subscribe_callback = cb;
|
||||
c->subscribe_userdata = userdata;
|
||||
|
|
|
|||
|
|
@ -26,24 +26,24 @@
|
|||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_SYS_POLL_H
|
||||
#include <sys/poll.h>
|
||||
#ifdef HAVE_POLL_H
|
||||
#include <poll.h>
|
||||
#else
|
||||
#include "../pulsecore/poll.h"
|
||||
#include <pulsecore/poll.h>
|
||||
#endif
|
||||
|
||||
#include <pulse/xmalloc.h>
|
||||
#include <pulse/mainloop.h>
|
||||
|
||||
#include <pulsecore/log.h>
|
||||
#include <pulsecore/hashmap.h>
|
||||
#include <pulsecore/thread.h>
|
||||
#include <pulsecore/mutex.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
#include "mainloop.h"
|
||||
#include "thread-mainloop.h"
|
||||
|
||||
struct pa_threaded_mainloop {
|
||||
|
|
@ -63,7 +63,7 @@ static int poll_func(struct pollfd *ufds, unsigned long nfds, int timeout, void
|
|||
pa_mutex *mutex = userdata;
|
||||
int r;
|
||||
|
||||
assert(mutex);
|
||||
pa_assert(mutex);
|
||||
|
||||
/* Before entering poll() we unlock the mutex, so that
|
||||
* avahi_simple_poll_quit() can succeed from another thread. */
|
||||
|
|
@ -103,7 +103,7 @@ pa_threaded_mainloop *pa_threaded_mainloop_new(void) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
m->mutex = pa_mutex_new(1);
|
||||
m->mutex = pa_mutex_new(TRUE, FALSE);
|
||||
m->cond = pa_cond_new();
|
||||
m->accept_cond = pa_cond_new();
|
||||
m->thread = NULL;
|
||||
|
|
@ -116,10 +116,10 @@ pa_threaded_mainloop *pa_threaded_mainloop_new(void) {
|
|||
}
|
||||
|
||||
void pa_threaded_mainloop_free(pa_threaded_mainloop* m) {
|
||||
assert(m);
|
||||
pa_assert(m);
|
||||
|
||||
/* Make sure that this function is not called from the helper thread */
|
||||
assert((m->thread && !pa_thread_is_running(m->thread)) || !in_worker(m));
|
||||
pa_assert((m->thread && !pa_thread_is_running(m->thread)) || !in_worker(m));
|
||||
|
||||
pa_threaded_mainloop_stop(m);
|
||||
|
||||
|
|
@ -136,9 +136,9 @@ void pa_threaded_mainloop_free(pa_threaded_mainloop* m) {
|
|||
}
|
||||
|
||||
int pa_threaded_mainloop_start(pa_threaded_mainloop *m) {
|
||||
assert(m);
|
||||
pa_assert(m);
|
||||
|
||||
assert(!m->thread || !pa_thread_is_running(m->thread));
|
||||
pa_assert(!m->thread || !pa_thread_is_running(m->thread));
|
||||
|
||||
if (!(m->thread = pa_thread_new(thread, m)))
|
||||
return -1;
|
||||
|
|
@ -147,13 +147,13 @@ int pa_threaded_mainloop_start(pa_threaded_mainloop *m) {
|
|||
}
|
||||
|
||||
void pa_threaded_mainloop_stop(pa_threaded_mainloop *m) {
|
||||
assert(m);
|
||||
pa_assert(m);
|
||||
|
||||
if (!m->thread || !pa_thread_is_running(m->thread))
|
||||
return;
|
||||
|
||||
/* Make sure that this function is not called from the helper thread */
|
||||
assert(!in_worker(m));
|
||||
pa_assert(!in_worker(m));
|
||||
|
||||
pa_mutex_lock(m->mutex);
|
||||
pa_mainloop_quit(m->real_mainloop, 0);
|
||||
|
|
@ -163,25 +163,25 @@ void pa_threaded_mainloop_stop(pa_threaded_mainloop *m) {
|
|||
}
|
||||
|
||||
void pa_threaded_mainloop_lock(pa_threaded_mainloop *m) {
|
||||
assert(m);
|
||||
pa_assert(m);
|
||||
|
||||
/* Make sure that this function is not called from the helper thread */
|
||||
assert(!m->thread || !pa_thread_is_running(m->thread) || !in_worker(m));
|
||||
pa_assert(!m->thread || !pa_thread_is_running(m->thread) || !in_worker(m));
|
||||
|
||||
pa_mutex_lock(m->mutex);
|
||||
}
|
||||
|
||||
void pa_threaded_mainloop_unlock(pa_threaded_mainloop *m) {
|
||||
assert(m);
|
||||
pa_assert(m);
|
||||
|
||||
/* Make sure that this function is not called from the helper thread */
|
||||
assert(!m->thread || !pa_thread_is_running(m->thread) || !in_worker(m));
|
||||
pa_assert(!m->thread || !pa_thread_is_running(m->thread) || !in_worker(m));
|
||||
|
||||
pa_mutex_unlock(m->mutex);
|
||||
}
|
||||
|
||||
void pa_threaded_mainloop_signal(pa_threaded_mainloop *m, int wait_for_accept) {
|
||||
assert(m);
|
||||
pa_assert(m);
|
||||
|
||||
pa_cond_signal(m->cond, 1);
|
||||
|
||||
|
|
@ -190,36 +190,42 @@ void pa_threaded_mainloop_signal(pa_threaded_mainloop *m, int wait_for_accept) {
|
|||
}
|
||||
|
||||
void pa_threaded_mainloop_wait(pa_threaded_mainloop *m) {
|
||||
assert(m);
|
||||
pa_assert(m);
|
||||
|
||||
/* Make sure that this function is not called from the helper thread */
|
||||
assert(!m->thread || !pa_thread_is_running(m->thread) || !in_worker(m));
|
||||
pa_assert(!m->thread || !pa_thread_is_running(m->thread) || !in_worker(m));
|
||||
|
||||
m->n_waiting ++;
|
||||
|
||||
pa_cond_wait(m->cond, m->mutex);
|
||||
|
||||
assert(m->n_waiting > 0);
|
||||
pa_assert(m->n_waiting > 0);
|
||||
m->n_waiting --;
|
||||
}
|
||||
|
||||
void pa_threaded_mainloop_accept(pa_threaded_mainloop *m) {
|
||||
assert(m);
|
||||
pa_assert(m);
|
||||
|
||||
/* Make sure that this function is not called from the helper thread */
|
||||
assert(!m->thread || !pa_thread_is_running(m->thread) || !in_worker(m));
|
||||
pa_assert(!m->thread || !pa_thread_is_running(m->thread) || !in_worker(m));
|
||||
|
||||
pa_cond_signal(m->accept_cond, 0);
|
||||
}
|
||||
|
||||
int pa_threaded_mainloop_get_retval(pa_threaded_mainloop *m) {
|
||||
assert(m);
|
||||
pa_assert(m);
|
||||
|
||||
return pa_mainloop_get_retval(m->real_mainloop);
|
||||
}
|
||||
|
||||
pa_mainloop_api* pa_threaded_mainloop_get_api(pa_threaded_mainloop*m) {
|
||||
assert(m);
|
||||
pa_assert(m);
|
||||
|
||||
return pa_mainloop_get_api(m->real_mainloop);
|
||||
}
|
||||
|
||||
int pa_threaded_mainloop_in_thread(pa_threaded_mainloop *m) {
|
||||
pa_assert(m);
|
||||
|
||||
return m->thread && pa_thread_self() == m->thread;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -297,6 +297,9 @@ int pa_threaded_mainloop_get_retval(pa_threaded_mainloop *m);
|
|||
/** Return the abstract main loop abstraction layer vtable for this main loop. */
|
||||
pa_mainloop_api* pa_threaded_mainloop_get_api(pa_threaded_mainloop*m);
|
||||
|
||||
/** Returns non-zero when called from withing the event loop thread. \since 0.9.7 */
|
||||
int pa_threaded_mainloop_in_thread(pa_threaded_mainloop *m);
|
||||
|
||||
PA_C_DECL_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
|
|
@ -34,15 +33,17 @@
|
|||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "../pulsecore/winsock.h"
|
||||
#include <pulsecore/winsock.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
#include "timeval.h"
|
||||
|
||||
struct timeval *pa_gettimeofday(struct timeval *tv) {
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
assert(tv);
|
||||
pa_assert(tv);
|
||||
|
||||
return gettimeofday(tv, NULL) < 0 ? NULL : tv;
|
||||
pa_assert_se(gettimeofday(tv, NULL) == 0);
|
||||
return tv;
|
||||
#elif defined(OS_IS_WIN32)
|
||||
/*
|
||||
* Copied from implementation by Steven Edwards (LGPL).
|
||||
|
|
@ -59,7 +60,7 @@ struct timeval *pa_gettimeofday(struct timeval *tv) {
|
|||
LARGE_INTEGER li;
|
||||
__int64 t;
|
||||
|
||||
assert(tv);
|
||||
pa_assert(tv);
|
||||
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
li.LowPart = ft.dwLowDateTime;
|
||||
|
|
@ -67,8 +68,8 @@ struct timeval *pa_gettimeofday(struct timeval *tv) {
|
|||
t = li.QuadPart; /* In 100-nanosecond intervals */
|
||||
t -= EPOCHFILETIME; /* Offset to the Epoch time */
|
||||
t /= 10; /* In microseconds */
|
||||
tv->tv_sec = (long)(t / 1000000);
|
||||
tv->tv_usec = (long)(t % 1000000);
|
||||
tv->tv_sec = (time_t) (t / PA_USEC_PER_SEC);
|
||||
tv->tv_usec = (suseconds_t) (t % PA_USEC_PER_SEC);
|
||||
|
||||
return tv;
|
||||
#else
|
||||
|
|
@ -78,9 +79,11 @@ struct timeval *pa_gettimeofday(struct timeval *tv) {
|
|||
|
||||
pa_usec_t pa_timeval_diff(const struct timeval *a, const struct timeval *b) {
|
||||
pa_usec_t r;
|
||||
assert(a && b);
|
||||
|
||||
/* Check which whan is the earlier time and swap the two arguments if reuqired. */
|
||||
pa_assert(a);
|
||||
pa_assert(b);
|
||||
|
||||
/* Check which whan is the earlier time and swap the two arguments if required. */
|
||||
if (pa_timeval_cmp(a, b) < 0) {
|
||||
const struct timeval *c;
|
||||
c = a;
|
||||
|
|
@ -89,7 +92,7 @@ pa_usec_t pa_timeval_diff(const struct timeval *a, const struct timeval *b) {
|
|||
}
|
||||
|
||||
/* Calculate the second difference*/
|
||||
r = ((pa_usec_t) a->tv_sec - b->tv_sec)* 1000000;
|
||||
r = ((pa_usec_t) a->tv_sec - b->tv_sec) * PA_USEC_PER_SEC;
|
||||
|
||||
/* Calculate the microsecond difference */
|
||||
if (a->tv_usec > b->tv_usec)
|
||||
|
|
@ -101,7 +104,8 @@ pa_usec_t pa_timeval_diff(const struct timeval *a, const struct timeval *b) {
|
|||
}
|
||||
|
||||
int pa_timeval_cmp(const struct timeval *a, const struct timeval *b) {
|
||||
assert(a && b);
|
||||
pa_assert(a);
|
||||
pa_assert(b);
|
||||
|
||||
if (a->tv_sec < b->tv_sec)
|
||||
return -1;
|
||||
|
|
@ -120,26 +124,43 @@ int pa_timeval_cmp(const struct timeval *a, const struct timeval *b) {
|
|||
|
||||
pa_usec_t pa_timeval_age(const struct timeval *tv) {
|
||||
struct timeval now;
|
||||
assert(tv);
|
||||
pa_assert(tv);
|
||||
|
||||
return pa_timeval_diff(pa_gettimeofday(&now), tv);
|
||||
}
|
||||
|
||||
struct timeval* pa_timeval_add(struct timeval *tv, pa_usec_t v) {
|
||||
unsigned long secs;
|
||||
assert(tv);
|
||||
pa_assert(tv);
|
||||
|
||||
secs = (v/1000000);
|
||||
tv->tv_sec += (unsigned long) secs;
|
||||
v -= secs*1000000;
|
||||
secs = (unsigned long) (v/PA_USEC_PER_SEC);
|
||||
tv->tv_sec += secs;
|
||||
v -= ((pa_usec_t) secs) * PA_USEC_PER_SEC;
|
||||
|
||||
tv->tv_usec += v;
|
||||
tv->tv_usec += (suseconds_t) v;
|
||||
|
||||
/* Normalize */
|
||||
while (tv->tv_usec >= 1000000) {
|
||||
while (tv->tv_usec >= PA_USEC_PER_SEC) {
|
||||
tv->tv_sec++;
|
||||
tv->tv_usec -= 1000000;
|
||||
tv->tv_usec -= PA_USEC_PER_SEC;
|
||||
}
|
||||
|
||||
return tv;
|
||||
}
|
||||
|
||||
struct timeval* pa_timeval_store(struct timeval *tv, pa_usec_t v) {
|
||||
pa_assert(tv);
|
||||
|
||||
tv->tv_sec = v / PA_USEC_PER_SEC;
|
||||
tv->tv_usec = v % PA_USEC_PER_SEC;
|
||||
|
||||
return tv;
|
||||
}
|
||||
|
||||
pa_usec_t pa_timeval_load(const struct timeval *tv) {
|
||||
pa_assert(tv);
|
||||
|
||||
return
|
||||
(pa_usec_t) tv->tv_sec * PA_USEC_PER_SEC +
|
||||
(pa_usec_t) tv->tv_usec;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,11 @@
|
|||
|
||||
PA_C_DECL_BEGIN
|
||||
|
||||
#define PA_MSEC_PER_SEC 1000
|
||||
#define PA_USEC_PER_SEC 1000000
|
||||
#define PA_NSEC_PER_SEC 1000000000
|
||||
#define PA_USEC_PER_MSEC 1000
|
||||
|
||||
struct timeval;
|
||||
|
||||
/** Return the current timestamp, just like UNIX gettimeofday() */
|
||||
|
|
@ -40,16 +45,22 @@ struct timeval *pa_gettimeofday(struct timeval *tv);
|
|||
|
||||
/** Calculate the difference between the two specified timeval
|
||||
* structs. */
|
||||
pa_usec_t pa_timeval_diff(const struct timeval *a, const struct timeval *b);
|
||||
pa_usec_t pa_timeval_diff(const struct timeval *a, const struct timeval *b) PA_GCC_PURE;
|
||||
|
||||
/** Compare the two timeval structs and return 0 when equal, negative when a < b, positive otherwse */
|
||||
int pa_timeval_cmp(const struct timeval *a, const struct timeval *b);
|
||||
int pa_timeval_cmp(const struct timeval *a, const struct timeval *b) PA_GCC_PURE;
|
||||
|
||||
/** Return the time difference between now and the specified timestamp */
|
||||
pa_usec_t pa_timeval_age(const struct timeval *tv);
|
||||
|
||||
/** Add the specified time inmicroseconds to the specified timeval structure */
|
||||
struct timeval* pa_timeval_add(struct timeval *tv, pa_usec_t v);
|
||||
struct timeval* pa_timeval_add(struct timeval *tv, pa_usec_t v) PA_GCC_PURE;
|
||||
|
||||
/** Store the specified uec value in the timeval struct. \since 0.9.7 */
|
||||
struct timeval* pa_timeval_store(struct timeval *tv, pa_usec_t v);
|
||||
|
||||
/** Load the specified tv value and return it in usec. \since 0.9.7 */
|
||||
pa_usec_t pa_timeval_load(const struct timeval *tv);
|
||||
|
||||
PA_C_DECL_END
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
*
|
||||
* This library 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
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
|
|
@ -50,7 +50,6 @@
|
|||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
|
|
@ -60,12 +59,15 @@
|
|||
#include <iconv.h>
|
||||
#endif
|
||||
|
||||
#include <pulse/xmalloc.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
#include "utf8.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
#define FILTER_CHAR '_'
|
||||
|
||||
static inline int is_unicode_valid(uint32_t ch) {
|
||||
|
||||
if (ch >= 0x110000) /* End of unicode space */
|
||||
return 0;
|
||||
if ((ch & 0xFFFFF800) == 0xD800) /* Reserved area for UTF-16 */
|
||||
|
|
@ -74,6 +76,7 @@ static inline int is_unicode_valid(uint32_t ch) {
|
|||
return 0;
|
||||
if ((ch & 0xFFFE) == 0xFFFE) /* BOM (Byte Order Mark) */
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -95,6 +98,8 @@ static char* utf8_validate(const char *str, char *output) {
|
|||
int size;
|
||||
uint8_t *o;
|
||||
|
||||
pa_assert(str);
|
||||
|
||||
o = (uint8_t*) output;
|
||||
for (p = (const uint8_t*) str; *p; p++) {
|
||||
if (*p < 128) {
|
||||
|
|
@ -178,15 +183,15 @@ failure:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
const char* pa_utf8_valid (const char *str) {
|
||||
char* pa_utf8_valid (const char *str) {
|
||||
return utf8_validate(str, NULL);
|
||||
}
|
||||
|
||||
char* pa_utf8_filter (const char *str) {
|
||||
char *new_str;
|
||||
|
||||
pa_assert(str);
|
||||
new_str = pa_xnew(char, strlen(str) + 1);
|
||||
|
||||
return utf8_validate(str, new_str);
|
||||
}
|
||||
|
||||
|
|
@ -195,22 +200,24 @@ char* pa_utf8_filter (const char *str) {
|
|||
static char* iconv_simple(const char *str, const char *to, const char *from) {
|
||||
char *new_str;
|
||||
size_t len, inlen;
|
||||
|
||||
iconv_t cd;
|
||||
ICONV_CONST char *inbuf;
|
||||
char *outbuf;
|
||||
size_t res, inbytes, outbytes;
|
||||
|
||||
pa_assert(str);
|
||||
pa_assert(to);
|
||||
pa_assert(from);
|
||||
|
||||
cd = iconv_open(to, from);
|
||||
if (cd == (iconv_t)-1)
|
||||
return NULL;
|
||||
|
||||
inlen = len = strlen(str) + 1;
|
||||
new_str = pa_xmalloc(len);
|
||||
assert(new_str);
|
||||
new_str = pa_xnew(char, len);
|
||||
|
||||
while (1) {
|
||||
inbuf = (ICONV_CONST char*)str; /* Brain dead prototype for iconv() */
|
||||
for (;;) {
|
||||
inbuf = (ICONV_CONST char*) str; /* Brain dead prototype for iconv() */
|
||||
inbytes = inlen;
|
||||
outbuf = new_str;
|
||||
outbytes = len;
|
||||
|
|
@ -226,11 +233,10 @@ static char* iconv_simple(const char *str, const char *to, const char *from) {
|
|||
break;
|
||||
}
|
||||
|
||||
assert(inbytes != 0);
|
||||
pa_assert(inbytes != 0);
|
||||
|
||||
len += inbytes;
|
||||
new_str = pa_xrealloc(new_str, len);
|
||||
assert(new_str);
|
||||
}
|
||||
|
||||
iconv_close(cd);
|
||||
|
|
@ -249,10 +255,12 @@ char* pa_locale_to_utf8 (const char *str) {
|
|||
#else
|
||||
|
||||
char* pa_utf8_to_locale (const char *str) {
|
||||
pa_assert(str);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* pa_locale_to_utf8 (const char *str) {
|
||||
pa_assert(str);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
PA_C_DECL_BEGIN
|
||||
|
||||
/** Test if the specified strings qualifies as valid UTF8. Return the string if so, otherwise NULL */
|
||||
const char *pa_utf8_valid(const char *str);
|
||||
char *pa_utf8_valid(const char *str) PA_GCC_PURE;
|
||||
|
||||
/** 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() */
|
||||
char *pa_utf8_filter(const char *str);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
|
|
@ -56,20 +55,14 @@
|
|||
#include <sys/prctl.h>
|
||||
#endif
|
||||
|
||||
#include "../pulsecore/winsock.h"
|
||||
|
||||
#include <pulsecore/winsock.h>
|
||||
#include <pulsecore/core-error.h>
|
||||
#include <pulsecore/log.h>
|
||||
#include <pulsecore/core-util.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
#ifndef OS_IS_WIN32
|
||||
#define PATH_SEP '/'
|
||||
#else
|
||||
#define PATH_SEP '\\'
|
||||
#endif
|
||||
|
||||
char *pa_get_user_name(char *s, size_t l) {
|
||||
char *p;
|
||||
char buf[1024];
|
||||
|
|
@ -78,7 +71,8 @@ char *pa_get_user_name(char *s, size_t l) {
|
|||
struct passwd pw, *r;
|
||||
#endif
|
||||
|
||||
assert(s && l > 0);
|
||||
pa_assert(s);
|
||||
pa_assert(l > 0);
|
||||
|
||||
if (!(p = getenv("USER")) && !(p = getenv("LOGNAME")) && !(p = getenv("USERNAME"))) {
|
||||
#ifdef HAVE_PWD_H
|
||||
|
|
@ -90,7 +84,7 @@ char *pa_get_user_name(char *s, size_t l) {
|
|||
* that do not support getpwuid_r. */
|
||||
if ((r = getpwuid(getuid())) == NULL) {
|
||||
#endif
|
||||
snprintf(s, l, "%lu", (unsigned long) getuid());
|
||||
pa_snprintf(s, l, "%lu", (unsigned long) getuid());
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
@ -113,11 +107,15 @@ char *pa_get_user_name(char *s, size_t l) {
|
|||
}
|
||||
|
||||
char *pa_get_host_name(char *s, size_t l) {
|
||||
assert(s && l > 0);
|
||||
|
||||
pa_assert(s);
|
||||
pa_assert(l > 0);
|
||||
|
||||
if (gethostname(s, l) < 0) {
|
||||
pa_log("gethostname(): %s", pa_cstrerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s[l-1] = 0;
|
||||
return s;
|
||||
}
|
||||
|
|
@ -130,7 +128,8 @@ char *pa_get_home_dir(char *s, size_t l) {
|
|||
struct passwd pw, *r;
|
||||
#endif
|
||||
|
||||
assert(s && l);
|
||||
pa_assert(s);
|
||||
pa_assert(l > 0);
|
||||
|
||||
if ((e = getenv("HOME")))
|
||||
return pa_strlcpy(s, e, l);
|
||||
|
|
@ -159,8 +158,8 @@ char *pa_get_home_dir(char *s, size_t l) {
|
|||
|
||||
char *pa_get_binary_name(char *s, size_t l) {
|
||||
|
||||
assert(s);
|
||||
assert(l);
|
||||
pa_assert(s);
|
||||
pa_assert(l > 0);
|
||||
|
||||
#if defined(OS_IS_WIN32)
|
||||
{
|
||||
|
|
@ -171,7 +170,7 @@ char *pa_get_binary_name(char *s, size_t l) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_READLINK
|
||||
#ifdef __linux__
|
||||
{
|
||||
int i;
|
||||
char path[PATH_MAX];
|
||||
|
|
@ -206,13 +205,15 @@ char *pa_get_binary_name(char *s, size_t l) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
const char *pa_path_get_filename(const char *p) {
|
||||
char *pa_path_get_filename(const char *p) {
|
||||
char *fn;
|
||||
|
||||
if ((fn = strrchr(p, PATH_SEP)))
|
||||
pa_assert(p);
|
||||
|
||||
if ((fn = strrchr(p, PA_PATH_SEP_CHAR)))
|
||||
return fn+1;
|
||||
|
||||
return (const char*) p;
|
||||
return (char*) p;
|
||||
}
|
||||
|
||||
char *pa_get_fqdn(char *s, size_t l) {
|
||||
|
|
@ -221,6 +222,9 @@ char *pa_get_fqdn(char *s, size_t l) {
|
|||
struct addrinfo *a, hints;
|
||||
#endif
|
||||
|
||||
pa_assert(s);
|
||||
pa_assert(l > 0);
|
||||
|
||||
if (!pa_get_host_name(hn, sizeof(hn)))
|
||||
return NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ char *pa_get_binary_name(char *s, size_t l);
|
|||
|
||||
/** Return a pointer to the filename inside a path (which is the last
|
||||
* component). */
|
||||
const char *pa_path_get_filename(const char *p);
|
||||
char *pa_path_get_filename(const char *p);
|
||||
|
||||
/** Wait t milliseconds */
|
||||
int pa_msleep(unsigned long t);
|
||||
|
|
|
|||
|
|
@ -25,16 +25,18 @@
|
|||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <pulsecore/core-util.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
#include "volume.h"
|
||||
|
||||
int pa_cvolume_equal(const pa_cvolume *a, const pa_cvolume *b) {
|
||||
int i;
|
||||
assert(a);
|
||||
assert(b);
|
||||
pa_assert(a);
|
||||
pa_assert(b);
|
||||
|
||||
if (a->channels != b->channels)
|
||||
return 0;
|
||||
|
|
@ -49,9 +51,9 @@ int pa_cvolume_equal(const pa_cvolume *a, const pa_cvolume *b) {
|
|||
pa_cvolume* pa_cvolume_set(pa_cvolume *a, unsigned channels, pa_volume_t v) {
|
||||
int i;
|
||||
|
||||
assert(a);
|
||||
assert(channels > 0);
|
||||
assert(channels <= PA_CHANNELS_MAX);
|
||||
pa_assert(a);
|
||||
pa_assert(channels > 0);
|
||||
pa_assert(channels <= PA_CHANNELS_MAX);
|
||||
|
||||
a->channels = channels;
|
||||
|
||||
|
|
@ -64,7 +66,7 @@ pa_cvolume* pa_cvolume_set(pa_cvolume *a, unsigned channels, pa_volume_t v) {
|
|||
pa_volume_t pa_cvolume_avg(const pa_cvolume *a) {
|
||||
uint64_t sum = 0;
|
||||
int i;
|
||||
assert(a);
|
||||
pa_assert(a);
|
||||
|
||||
for (i = 0; i < a->channels; i++)
|
||||
sum += a->values[i];
|
||||
|
|
@ -118,14 +120,14 @@ char *pa_cvolume_snprint(char *s, size_t l, const pa_cvolume *c) {
|
|||
int first = 1;
|
||||
char *e;
|
||||
|
||||
assert(s);
|
||||
assert(l > 0);
|
||||
assert(c);
|
||||
pa_assert(s);
|
||||
pa_assert(l > 0);
|
||||
pa_assert(c);
|
||||
|
||||
*(e = s) = 0;
|
||||
|
||||
for (channel = 0; channel < c->channels && l > 1; channel++) {
|
||||
l -= snprintf(e, l, "%s%u: %3u%%",
|
||||
l -= pa_snprintf(e, l, "%s%u: %3u%%",
|
||||
first ? "" : " ",
|
||||
channel,
|
||||
(c->values[channel]*100)/PA_VOLUME_NORM);
|
||||
|
|
@ -140,7 +142,7 @@ char *pa_cvolume_snprint(char *s, size_t l, const pa_cvolume *c) {
|
|||
/** Return non-zero if the volume of all channels is equal to the specified value */
|
||||
int pa_cvolume_channels_equal_to(const pa_cvolume *a, pa_volume_t v) {
|
||||
unsigned c;
|
||||
assert(a);
|
||||
pa_assert(a);
|
||||
|
||||
for (c = 0; c < a->channels; c++)
|
||||
if (a->values[c] != v)
|
||||
|
|
@ -152,9 +154,9 @@ int pa_cvolume_channels_equal_to(const pa_cvolume *a, pa_volume_t v) {
|
|||
pa_cvolume *pa_sw_cvolume_multiply(pa_cvolume *dest, const pa_cvolume *a, const pa_cvolume *b) {
|
||||
unsigned i;
|
||||
|
||||
assert(dest);
|
||||
assert(a);
|
||||
assert(b);
|
||||
pa_assert(dest);
|
||||
pa_assert(a);
|
||||
pa_assert(b);
|
||||
|
||||
for (i = 0; i < a->channels && i < b->channels && i < PA_CHANNELS_MAX; i++) {
|
||||
|
||||
|
|
@ -169,7 +171,7 @@ pa_cvolume *pa_sw_cvolume_multiply(pa_cvolume *dest, const pa_cvolume *a, const
|
|||
}
|
||||
|
||||
int pa_cvolume_valid(const pa_cvolume *v) {
|
||||
assert(v);
|
||||
pa_assert(v);
|
||||
|
||||
if (v->channels <= 0 || v->channels > PA_CHANNELS_MAX)
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ typedef struct pa_cvolume {
|
|||
} pa_cvolume;
|
||||
|
||||
/** Return non-zero when *a == *b */
|
||||
int pa_cvolume_equal(const pa_cvolume *a, const pa_cvolume *b);
|
||||
int pa_cvolume_equal(const pa_cvolume *a, const pa_cvolume *b) PA_GCC_PURE;
|
||||
|
||||
/** Set the volume of all channels to PA_VOLUME_NORM */
|
||||
#define pa_cvolume_reset(a, n) pa_cvolume_set((a), (n), PA_VOLUME_NORM)
|
||||
|
|
@ -131,13 +131,13 @@ pa_cvolume* pa_cvolume_set(pa_cvolume *a, unsigned channels, pa_volume_t v);
|
|||
char *pa_cvolume_snprint(char *s, size_t l, const pa_cvolume *c);
|
||||
|
||||
/** Return the average volume of all channels */
|
||||
pa_volume_t pa_cvolume_avg(const pa_cvolume *a);
|
||||
pa_volume_t pa_cvolume_avg(const pa_cvolume *a) PA_GCC_PURE;
|
||||
|
||||
/** Return TRUE when the passed cvolume structure is valid, FALSE otherwise */
|
||||
int pa_cvolume_valid(const pa_cvolume *v);
|
||||
int pa_cvolume_valid(const pa_cvolume *v) PA_GCC_PURE;
|
||||
|
||||
/** Return non-zero if the volume of all channels is equal to the specified value */
|
||||
int pa_cvolume_channels_equal_to(const pa_cvolume *a, pa_volume_t v);
|
||||
int pa_cvolume_channels_equal_to(const pa_cvolume *a, pa_volume_t v) PA_GCC_PURE;
|
||||
|
||||
/** Return 1 if the specified volume has all channels muted */
|
||||
#define pa_cvolume_is_muted(a) pa_cvolume_channels_equal_to((a), PA_VOLUME_MUTED)
|
||||
|
|
@ -146,22 +146,22 @@ int pa_cvolume_channels_equal_to(const pa_cvolume *a, pa_volume_t v);
|
|||
#define pa_cvolume_is_norm(a) pa_cvolume_channels_equal_to((a), PA_VOLUME_NORM)
|
||||
|
||||
/** Multiply two volumes specifications, return the result. This uses PA_VOLUME_NORM as neutral element of multiplication. This is only valid for software volumes! */
|
||||
pa_volume_t pa_sw_volume_multiply(pa_volume_t a, pa_volume_t b);
|
||||
pa_volume_t pa_sw_volume_multiply(pa_volume_t a, pa_volume_t b) PA_GCC_CONST;
|
||||
|
||||
/** Multiply to per-channel volumes and return the result in *dest. This is only valid for software volumes! */
|
||||
pa_cvolume *pa_sw_cvolume_multiply(pa_cvolume *dest, const pa_cvolume *a, const pa_cvolume *b);
|
||||
pa_cvolume *pa_sw_cvolume_multiply(pa_cvolume *dest, const pa_cvolume *a, const pa_cvolume *b) PA_GCC_PURE;
|
||||
|
||||
/** Convert a decibel value to a volume. This is only valid for software volumes! \since 0.4 */
|
||||
pa_volume_t pa_sw_volume_from_dB(double f);
|
||||
pa_volume_t pa_sw_volume_from_dB(double f) PA_GCC_CONST;
|
||||
|
||||
/** Convert a volume to a decibel value. This is only valid for software volumes! \since 0.4 */
|
||||
double pa_sw_volume_to_dB(pa_volume_t v);
|
||||
double pa_sw_volume_to_dB(pa_volume_t v) PA_GCC_CONST;
|
||||
|
||||
/** Convert a linear factor to a volume. This is only valid for software volumes! \since 0.8 */
|
||||
pa_volume_t pa_sw_volume_from_linear(double v);
|
||||
pa_volume_t pa_sw_volume_from_linear(double v) PA_GCC_CONST;
|
||||
|
||||
/** Convert a volume to a linear factor. This is only valid for software volumes! \since 0.8 */
|
||||
double pa_sw_volume_to_linear(pa_volume_t v);
|
||||
double pa_sw_volume_to_linear(pa_volume_t v) PA_GCC_CONST;
|
||||
|
||||
#ifdef INFINITY
|
||||
#define PA_DECIBEL_MININFTY (-INFINITY)
|
||||
|
|
|
|||
|
|
@ -27,12 +27,12 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <pulsecore/core-util.h>
|
||||
#include <pulsecore/gccmacro.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
#include "xmalloc.h"
|
||||
|
||||
|
|
@ -60,8 +60,8 @@ static void oom(void) {
|
|||
|
||||
void* pa_xmalloc(size_t size) {
|
||||
void *p;
|
||||
assert(size > 0);
|
||||
assert(size < MAX_ALLOC_SIZE);
|
||||
pa_assert(size > 0);
|
||||
pa_assert(size < MAX_ALLOC_SIZE);
|
||||
|
||||
if (!(p = malloc(size)))
|
||||
oom();
|
||||
|
|
@ -71,8 +71,8 @@ void* pa_xmalloc(size_t size) {
|
|||
|
||||
void* pa_xmalloc0(size_t size) {
|
||||
void *p;
|
||||
assert(size > 0);
|
||||
assert(size < MAX_ALLOC_SIZE);
|
||||
pa_assert(size > 0);
|
||||
pa_assert(size < MAX_ALLOC_SIZE);
|
||||
|
||||
if (!(p = calloc(1, size)))
|
||||
oom();
|
||||
|
|
@ -82,8 +82,8 @@ void* pa_xmalloc0(size_t size) {
|
|||
|
||||
void *pa_xrealloc(void *ptr, size_t size) {
|
||||
void *p;
|
||||
assert(size > 0);
|
||||
assert(size < MAX_ALLOC_SIZE);
|
||||
pa_assert(size > 0);
|
||||
pa_assert(size < MAX_ALLOC_SIZE);
|
||||
|
||||
if (!(p = realloc(ptr, size)))
|
||||
oom();
|
||||
|
|
|
|||
|
|
@ -75,6 +75,15 @@ static inline void* pa_xnew0_internal(unsigned n, size_t k) {
|
|||
/** Same as pa_xnew() but set the memory to zero */
|
||||
#define pa_xnew0(type, n) ((type*) pa_xnew0_internal((n), sizeof(type)))
|
||||
|
||||
/** Internal helper for pa_xnew0() */
|
||||
static inline void* pa_xnewdup_internal(const void *p, unsigned n, size_t k) {
|
||||
assert(n < INT_MAX/k);
|
||||
return pa_xmemdup(p, n*k);
|
||||
}
|
||||
|
||||
/** Same as pa_xnew() but set the memory to zero */
|
||||
#define pa_xnewdup(type, p, n) ((type*) pa_xnewdup_internal((p), (n), sizeof(type)))
|
||||
|
||||
PA_C_DECL_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue