本文整理汇总了C++中pa_xfree函数的典型用法代码示例。如果您正苦于以下问题:C++ pa_xfree函数的具体用法?C++ pa_xfree怎么用?C++ pa_xfree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pa_xfree函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: subscribe_callback
static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint32_t idx, void *userdata) {
struct userdata *u = userdata;
pa_sink_input *si = NULL;
pa_source_output *so = NULL;
struct rule *r;
char *name;
pa_assert(c);
pa_assert(u);
if (t != (PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_NEW) &&
t != (PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_CHANGE) &&
t != (PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT|PA_SUBSCRIPTION_EVENT_NEW) &&
t != (PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT|PA_SUBSCRIPTION_EVENT_CHANGE))
return;
if ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SINK_INPUT) {
if (!(si = pa_idxset_get_by_index(c->sink_inputs, idx)))
return;
if (!si->client || !(name = client_name(si->client)))
return;
} else {
pa_assert((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT);
if (!(so = pa_idxset_get_by_index(c->source_outputs, idx)))
return;
if (!so->client || !(name = client_name(so->client)))
return;
}
if ((r = pa_hashmap_get(u->hashmap, name))) {
pa_xfree(name);
if (si) {
if (!r->volume_is_set || !pa_cvolume_equal(pa_sink_input_get_volume(si), &r->volume)) {
pa_log_info("Saving volume for <%s>", r->name);
r->volume = *pa_sink_input_get_volume(si);
r->volume_is_set = TRUE;
u->modified = TRUE;
}
if (!r->sink || strcmp(si->sink->name, r->sink) != 0) {
pa_log_info("Saving sink for <%s>", r->name);
pa_xfree(r->sink);
r->sink = pa_xstrdup(si->sink->name);
u->modified = TRUE;
}
} else {
pa_assert(so);
if (!r->source || strcmp(so->source->name, r->source) != 0) {
pa_log_info("Saving source for <%s>", r->name);
pa_xfree(r->source);
r->source = pa_xstrdup(so->source->name);
u->modified = TRUE;
}
}
} else {
pa_log_info("Creating new entry for <%s>", name);
r = pa_xnew(struct rule, 1);
r->name = name;
if (si) {
r->volume = *pa_sink_input_get_volume(si);
r->volume_is_set = TRUE;
r->sink = pa_xstrdup(si->sink->name);
r->source = NULL;
} else {
pa_assert(so);
r->volume_is_set = FALSE;
r->sink = NULL;
r->source = pa_xstrdup(so->source->name);
}
pa_hashmap_put(u->hashmap, r->name, r);
u->modified = TRUE;
}
if (u->modified && !u->save_time_event) {
struct timeval tv;
pa_gettimeofday(&tv);
tv.tv_sec += SAVE_INTERVAL;
u->save_time_event = u->core->mainloop->time_new(u->core->mainloop, &tv, save_time_callback, u);
}
}
开发者ID:thewb,项目名称:mokoiax,代码行数:90,代码来源:module-volume-restore.c
示例2: pa__init
//.........这里部分代码省略.........
pa_source_output_new_data_init(&data);
pa_proplist_sets(data.proplist, PA_PROP_MEDIA_NAME, "RTP Monitor Stream");
pa_proplist_sets(data.proplist, "rtp.source", src_addr);
pa_proplist_sets(data.proplist, "rtp.destination", dst_addr);
pa_proplist_setf(data.proplist, "rtp.mtu", "%lu", (unsigned long) mtu);
pa_proplist_setf(data.proplist, "rtp.port", "%lu", (unsigned long) port);
pa_proplist_setf(data.proplist, "rtp.ttl", "%lu", (unsigned long) ttl);
data.driver = __FILE__;
data.module = m;
pa_source_output_new_data_set_source(&data, s, false, true);
pa_source_output_new_data_set_sample_spec(&data, &ss);
pa_source_output_new_data_set_channel_map(&data, &cm);
data.flags |= get_dont_inhibit_auto_suspend_flag(s, inhibit_auto_suspend);
pa_source_output_new(&o, m->core, &data);
pa_source_output_new_data_done(&data);
if (!o) {
pa_log("failed to create source output.");
goto fail;
}
o->parent.process_msg = source_output_process_msg;
o->push = source_output_push_cb;
o->moving = source_output_moving_cb;
o->kill = source_output_kill_cb;
pa_log_info("Configured source latency of %llu ms.",
(unsigned long long) pa_source_output_set_requested_latency(o, pa_bytes_to_usec(mtu, &o->sample_spec)) / PA_USEC_PER_MSEC);
m->userdata = o->userdata = u = pa_xnew(struct userdata, 1);
u->module = m;
u->source_output = o;
u->memblockq = pa_memblockq_new(
"module-rtp-send memblockq",
0,
MEMBLOCKQ_MAXLENGTH,
MEMBLOCKQ_MAXLENGTH,
&ss,
1,
0,
0,
NULL);
u->mtu = mtu;
k = sizeof(sa_dst);
pa_assert_se((r = getsockname(fd, (struct sockaddr*) &sa_dst, &k)) >= 0);
n = pa_xstrdup(pa_modargs_get_value(ma, "stream_name", NULL));
if (n == NULL)
n = pa_sprintf_malloc("PulseAudio RTP Stream on %s", pa_get_fqdn(hn, sizeof(hn)));
if (af == AF_INET) {
p = pa_sdp_build(af,
(void*) &((struct sockaddr_in*) &sa_dst)->sin_addr,
(void*) &dst_sa4.sin_addr,
n, (uint16_t) port, payload, &ss);
#ifdef HAVE_IPV6
} else {
p = pa_sdp_build(af,
(void*) &((struct sockaddr_in6*) &sa_dst)->sin6_addr,
(void*) &dst_sa6.sin6_addr,
n, (uint16_t) port, payload, &ss);
#endif
}
pa_xfree(n);
pa_rtp_context_init_send(&u->rtp_context, fd, m->core->cookie, payload, pa_frame_size(&ss));
pa_sap_context_init_send(&u->sap_context, sap_fd, p);
pa_log_info("RTP stream initialized with mtu %u on %s:%u from %s ttl=%u, SSRC=0x%08x, payload=%u, initial sequence #%u", mtu, dst_addr, port, src_addr, ttl, u->rtp_context.ssrc, payload, u->rtp_context.sequence);
pa_log_info("SDP-Data:\n%s\nEOF", p);
pa_sap_send(&u->sap_context, 0);
u->sap_event = pa_core_rttime_new(m->core, pa_rtclock_now() + SAP_INTERVAL, sap_event_cb, u);
u->inhibit_auto_suspend = inhibit_auto_suspend;
pa_source_output_put(u->source_output);
pa_modargs_free(ma);
return 0;
fail:
if (ma)
pa_modargs_free(ma);
if (fd >= 0)
pa_close(fd);
if (sap_fd >= 0)
pa_close(sap_fd);
return -1;
}
开发者ID:jprvita,项目名称:pulseaudio,代码行数:101,代码来源:module-rtp-send.c
示例3: pa_cmdline_parse
int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d) {
pa_strbuf *buf = NULL;
int c;
int b;
pa_assert(conf);
pa_assert(argc > 0);
pa_assert(argv);
buf = pa_strbuf_new();
if (conf->script_commands)
pa_strbuf_puts(buf, conf->script_commands);
while ((c = getopt_long(argc, argv, "L:F:ChDnp:kv", long_options, NULL)) != -1) {
switch (c) {
case ARG_HELP:
case 'h':
conf->cmd = PA_CMD_HELP;
break;
case ARG_VERSION:
conf->cmd = PA_CMD_VERSION;
break;
case ARG_DUMP_CONF:
conf->cmd = PA_CMD_DUMP_CONF;
break;
case ARG_DUMP_MODULES:
conf->cmd = PA_CMD_DUMP_MODULES;
break;
case ARG_DUMP_RESAMPLE_METHODS:
conf->cmd = PA_CMD_DUMP_RESAMPLE_METHODS;
break;
case ARG_CLEANUP_SHM:
conf->cmd = PA_CMD_CLEANUP_SHM;
break;
case 'k':
case ARG_KILL:
conf->cmd = PA_CMD_KILL;
break;
case ARG_START:
conf->cmd = PA_CMD_START;
conf->daemonize = true;
break;
case ARG_CHECK:
conf->cmd = PA_CMD_CHECK;
break;
case ARG_LOAD:
case 'L':
pa_strbuf_printf(buf, "load-module %s\n", optarg);
break;
case ARG_FILE:
case 'F': {
char *p;
pa_strbuf_printf(buf, ".include %s\n", p = pa_make_path_absolute(optarg));
pa_xfree(p);
break;
}
case 'C':
pa_strbuf_puts(buf, "load-module module-cli exit_on_eof=1\n");
break;
case ARG_DAEMONIZE:
case 'D':
if ((b = optarg ? pa_parse_boolean(optarg) : 1) < 0) {
pa_log(_("--daemonize expects boolean argument"));
goto fail;
}
conf->daemonize = !!b;
break;
case ARG_FAIL:
if ((b = optarg ? pa_parse_boolean(optarg) : 1) < 0) {
pa_log(_("--fail expects boolean argument"));
goto fail;
}
conf->fail = !!b;
break;
case 'v':
case ARG_LOG_LEVEL:
if (optarg) {
if (pa_daemon_conf_set_log_level(conf, optarg) < 0) {
pa_log(_("--log-level expects log level argument (either numeric in range 0..4 or one of debug, info, notice, warn, error)."));
goto fail;
}
} else {
if (conf->log_level < PA_LOG_LEVEL_MAX-1)
conf->log_level++;
//.........这里部分代码省略.........
开发者ID:UlrichEckhardt,项目名称:pulseaudio,代码行数:101,代码来源:cmdline.c
示例4: main
int main(int argc, char *argv[]) {
pa_mainloop* m = NULL;
int ret = 1, c;
char *bn, *server = NULL;
pa_time_event *time_event = NULL;
const char *filename = NULL;
/* type for pa_read/_write. passed as userdata to the callbacks */
unsigned long type = 0;
static const struct option long_options[] = {
{"record", 0, NULL, 'r'},
{"playback", 0, NULL, 'p'},
{"device", 1, NULL, 'd'},
{"server", 1, NULL, 's'},
{"client-name", 1, NULL, 'n'},
{"stream-name", 1, NULL, ARG_STREAM_NAME},
{"version", 0, NULL, ARG_VERSION},
{"help", 0, NULL, 'h'},
{"verbose", 0, NULL, 'v'},
{"volume", 1, NULL, ARG_VOLUME},
{"rate", 1, NULL, ARG_SAMPLERATE},
{"format", 1, NULL, ARG_SAMPLEFORMAT},
{"channels", 1, NULL, ARG_CHANNELS},
{"channel-map", 1, NULL, ARG_CHANNELMAP},
{"fix-format", 0, NULL, ARG_FIX_FORMAT},
{"fix-rate", 0, NULL, ARG_FIX_RATE},
{"fix-channels", 0, NULL, ARG_FIX_CHANNELS},
{"no-remap", 0, NULL, ARG_NO_REMAP},
{"no-remix", 0, NULL, ARG_NO_REMIX},
{"latency", 1, NULL, ARG_LATENCY},
{"process-time", 1, NULL, ARG_PROCESS_TIME},
{"property", 1, NULL, ARG_PROPERTY},
{"raw", 0, NULL, ARG_RAW},
{"passthrough", 0, NULL, ARG_PASSTHROUGH},
{"file-format", 2, NULL, ARG_FILE_FORMAT},
{"list-file-formats", 0, NULL, ARG_LIST_FILE_FORMATS},
{"latency-msec", 1, NULL, ARG_LATENCY_MSEC},
{"process-time-msec", 1, NULL, ARG_PROCESS_TIME_MSEC},
{"monitor-stream", 1, NULL, ARG_MONITOR_STREAM},
{NULL, 0, NULL, 0}
};
setlocale(LC_ALL, "");
#ifdef ENABLE_NLS
bindtextdomain(GETTEXT_PACKAGE, PULSE_LOCALEDIR);
#endif
bn = pa_path_get_filename(argv[0]);
if (strstr(bn, "play")) {
mode = PLAYBACK;
raw = false;
} else if (strstr(bn, "record")) {
mode = RECORD;
raw = false;
} else if (strstr(bn, "cat")) {
mode = PLAYBACK;
raw = true;
} else if (strstr(bn, "rec") || strstr(bn, "mon")) {
mode = RECORD;
raw = true;
}
proplist = pa_proplist_new();
while ((c = getopt_long(argc, argv, "rpd:s:n:hv", long_options, NULL)) != -1) {
switch (c) {
case 'h' :
help(bn);
ret = 0;
goto quit;
case ARG_VERSION:
printf(_("pacat %s\n"
"Compiled with libpulse %s\n"
"Linked with libpulse %s\n"),
PACKAGE_VERSION,
pa_get_headers_version(),
pa_get_library_version());
ret = 0;
goto quit;
case 'r':
mode = RECORD;
break;
case 'p':
mode = PLAYBACK;
break;
case 'd':
pa_xfree(device);
device = pa_xstrdup(optarg);
break;
case 's':
pa_xfree(server);
server = pa_xstrdup(optarg);
break;
//.........这里部分代码省略.........
开发者ID:DryakhlyyZlodey,项目名称:pulseaudio,代码行数:101,代码来源:pacat.c
示例5: context_state_cb
static void context_state_cb(pa_context *c, void *userdata) {
struct userdata *u = userdata;
pa_assert(u);
switch (pa_context_get_state(c)) {
case PA_CONTEXT_UNCONNECTED:
case PA_CONTEXT_CONNECTING:
case PA_CONTEXT_AUTHORIZING:
case PA_CONTEXT_SETTING_NAME:
break;
case PA_CONTEXT_READY: {
pa_proplist *proplist;
pa_buffer_attr bufferattr;
pa_usec_t requested_latency;
char *username = pa_get_user_name_malloc();
char *hostname = pa_get_host_name_malloc();
/* TODO: old tunnel put here the remote sink_name into stream name e.g. 'Null Output for [email protected]' */
char *stream_name = pa_sprintf_malloc(_("Tunnel for %[email protected]%s"), username, hostname);
pa_xfree(hostname);
pa_xfree(username);
pa_log_debug("Connection successful. Creating stream.");
pa_assert(!u->stream);
proplist = tunnel_new_proplist(u);
if(u->transcode.encoding != -1) {
unsigned int n_formats = 1;
pa_format_info *formats[1];
formats[0] = pa_format_info_new();
formats[0]->encoding = u->transcode.encoding;
pa_format_info_set_sample_format(formats[0], u->sink->sample_spec.format);
pa_format_info_set_rate(formats[0], u->sink->sample_spec.rate);
pa_format_info_set_channels(formats[0], u->sink->sample_spec.channels);
pa_format_info_set_channel_map(formats[0], &u->sink->channel_map);
pa_transcode_set_format_info(&u->transcode, formats[0]);
u->stream = pa_stream_new_extended(u->context, stream_name, formats, n_formats, proplist);
}
else
u->stream = pa_stream_new_with_proplist(u->context,
stream_name,
&u->sink->sample_spec,
&u->sink->channel_map,
proplist);
pa_proplist_free(proplist);
pa_xfree(stream_name);
if (!u->stream) {
pa_log_error("Could not create a stream.");
u->thread_mainloop_api->quit(u->thread_mainloop_api, TUNNEL_THREAD_FAILED_MAINLOOP);
return;
}
requested_latency = pa_sink_get_requested_latency_within_thread(u->sink);
if (requested_latency == (pa_usec_t) -1)
requested_latency = u->sink->thread_info.max_latency;
reset_bufferattr(&bufferattr);
bufferattr.tlength = pa_usec_to_bytes(requested_latency, &u->sink->sample_spec);
pa_stream_set_state_callback(u->stream, stream_state_cb, userdata);
pa_stream_set_buffer_attr_callback(u->stream, stream_changed_buffer_attr_cb, userdata);
if (pa_stream_connect_playback(u->stream,
u->remote_sink_name,
&bufferattr,
PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_DONT_MOVE | PA_STREAM_START_CORKED | PA_STREAM_AUTO_TIMING_UPDATE,
NULL,
NULL) < 0) {
pa_log_error("Could not connect stream.");
u->thread_mainloop_api->quit(u->thread_mainloop_api, TUNNEL_THREAD_FAILED_MAINLOOP);
}
u->connected = true;
break;
}
case PA_CONTEXT_FAILED:
pa_log_debug("Context failed: %s.", pa_strerror(pa_context_errno(u->context)));
u->connected = false;
u->thread_mainloop_api->quit(u->thread_mainloop_api, TUNNEL_THREAD_FAILED_MAINLOOP);
break;
case PA_CONTEXT_TERMINATED:
pa_log_debug("Context terminated.");
u->connected = false;
u->thread_mainloop_api->quit(u->thread_mainloop_api, TUNNEL_THREAD_FAILED_MAINLOOP);
break;
}
}
开发者ID:indrwthaachen,项目名称:pulseaudio,代码行数:90,代码来源:module-tunnel-sink-new.c
示例6: pa_module_load
pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) {
pa_module *m = NULL;
pa_bool_t (*load_once)(void);
const char* (*get_deprecated)(void);
pa_modinfo *mi;
pa_assert(c);
pa_assert(name);
if (c->disallow_module_loading)
goto fail;
m = pa_xnew(pa_module, 1);
m->name = pa_xstrdup(name);
m->argument = pa_xstrdup(argument);
m->load_once = FALSE;
m->proplist = pa_proplist_new();
if (!(m->dl = lt_dlopenext(name))) {
pa_log("Failed to open module \"%s\": %s", name, lt_dlerror());
goto fail;
}
if ((load_once = (pa_bool_t (*)(void)) pa_load_sym(m->dl, name, PA_SYMBOL_LOAD_ONCE))) {
m->load_once = load_once();
if (m->load_once) {
pa_module *i;
uint32_t idx;
/* OK, the module only wants to be loaded once, let's make sure it is */
for (i = pa_idxset_first(c->modules, &idx); i; i = pa_idxset_next(c->modules, &idx)) {
if (strcmp(name, i->name) == 0) {
pa_log("Module \"%s\" should be loaded once at most. Refusing to load.", name);
goto fail;
}
}
}
}
if ((get_deprecated = (const char* (*) (void)) pa_load_sym(m->dl, name, PA_SYMBOL_GET_DEPRECATE))) {
const char *t;
if ((t = get_deprecated()))
pa_log_warn("%s is deprecated: %s", name, t);
}
if (!(m->init = (int (*)(pa_module*_m)) pa_load_sym(m->dl, name, PA_SYMBOL_INIT))) {
pa_log("Failed to load module \"%s\": symbol \""PA_SYMBOL_INIT"\" not found.", name);
goto fail;
}
m->done = (void (*)(pa_module*_m)) pa_load_sym(m->dl, name, PA_SYMBOL_DONE);
m->get_n_used = (int (*)(pa_module*_m)) pa_load_sym(m->dl, name, PA_SYMBOL_GET_N_USED);
m->userdata = NULL;
m->core = c;
m->unload_requested = FALSE;
if (m->init(m) < 0) {
pa_log_error("Failed to load module \"%s\" (argument: \"%s\"): initialization failed.", name, argument ? argument : "");
goto fail;
}
pa_assert_se(pa_idxset_put(c->modules, m, &m->index) >= 0);
pa_assert(m->index != PA_IDXSET_INVALID);
pa_log_info("Loaded \"%s\" (index: #%u; argument: \"%s\").", m->name, m->index, m->argument ? m->argument : "");
pa_subscription_post(c, PA_SUBSCRIPTION_EVENT_MODULE|PA_SUBSCRIPTION_EVENT_NEW, m->index);
if ((mi = pa_modinfo_get_by_handle(m->dl, name))) {
if (mi->author && !pa_proplist_contains(m->proplist, PA_PROP_MODULE_AUTHOR))
pa_proplist_sets(m->proplist, PA_PROP_MODULE_AUTHOR, mi->author);
if (mi->description && !pa_proplist_contains(m->proplist, PA_PROP_MODULE_DESCRIPTION))
pa_proplist_sets(m->proplist, PA_PROP_MODULE_DESCRIPTION, mi->description);
if (mi->version && !pa_proplist_contains(m->proplist, PA_PROP_MODULE_VERSION))
pa_proplist_sets(m->proplist, PA_PROP_MODULE_VERSION, mi->version);
pa_modinfo_free(mi);
}
return m;
fail:
if (m) {
if (m->proplist)
pa_proplist_free(m->proplist);
pa_xfree(m->argument);
pa_xfree(m->name);
if (m->dl)
lt_dlclose(m->dl);
pa_xfree(m);
//.........这里部分代码省略.........
开发者ID:KimT,项目名称:pulseaudio_kt,代码行数:101,代码来源:module.c
示例7: verify_access
static void verify_access(struct userdata *u, struct device *d) {
char *cd;
pa_card *card;
bool accessible;
pa_assert(u);
pa_assert(d);
cd = pa_sprintf_malloc("/dev/snd/controlC%s", path_get_card_id(d->path));
accessible = access(cd, R_OK|W_OK) >= 0;
pa_log_debug("%s is accessible: %s", cd, pa_yes_no(accessible));
pa_xfree(cd);
if (d->module == PA_INVALID_INDEX) {
/* If we are not loaded, try to load */
if (accessible) {
pa_module *m;
bool busy;
/* Check if any of the PCM devices that belong to this
* card are currently busy. If they are, don't try to load
* right now, to make sure the probing phase can
* successfully complete. When the current user of the
* device closes it we will get another notification via
* inotify and can then recheck. */
busy = is_card_busy(path_get_card_id(d->path));
pa_log_debug("%s is busy: %s", d->path, pa_yes_no(busy));
if (!busy) {
/* So, why do we rate limit here? It's certainly ugly,
* but there seems to be no other way. Problem is
* this: if we are unable to configure/probe an audio
* device after opening it we will close it again and
* the module initialization will fail. This will then
* cause an inotify event on the device node which
* will be forwarded to us. We then try to reopen the
* audio device again, practically entering a busy
* loop.
*
* A clean fix would be if we would be able to ignore
* our own inotify close events. However, inotify
* lacks such functionality. Also, during probing of
* the device we cannot really distinguish between
* other processes causing EBUSY or ourselves, which
* means we have no way to figure out if the probing
* during opening was canceled by a "try again"
* failure or a "fatal" failure. */
if (pa_ratelimit_test(&d->ratelimit, PA_LOG_DEBUG)) {
pa_log_debug("Loading module-alsa-card with arguments '%s'", d->args);
m = pa_module_load(u->core, "module-alsa-card", d->args);
if (m) {
d->module = m->index;
pa_log_info("Card %s (%s) module loaded.", d->path, d->card_name);
} else
pa_log_info("Card %s (%s) failed to load module.", d->path, d->card_name);
} else
pa_log_warn("Tried to configure %s (%s) more often than %u times in %llus",
d->path,
d->card_name,
d->ratelimit.burst,
(long long unsigned) (d->ratelimit.interval / PA_USEC_PER_SEC));
}
}
} else {
/* If we are already loaded update suspend status with
* accessible boolean */
if ((card = pa_namereg_get(u->core, d->card_name, PA_NAMEREG_CARD))) {
pa_log_debug("%s all sinks and sources of card %s.", accessible ? "Resuming" : "Suspending", d->card_name);
pa_card_suspend(card, !accessible, PA_SUSPEND_SESSION);
}
}
}
开发者ID:DryakhlyyZlodey,项目名称:pulseaudio,代码行数:82,代码来源:module-udev-detect.c
示例8: pa_reserve_monitor_wrapper_get
pa_reserve_monitor_wrapper* pa_reserve_monitor_wrapper_get(pa_core *c, const char *device_name) {
pa_reserve_monitor_wrapper *w;
int k;
char *t;
#ifdef HAVE_DBUS
DBusError error;
dbus_error_init(&error);
#endif
pa_assert(c);
pa_assert(device_name);
t = pa_sprintf_malloc("[email protected]%s", device_name);
if ((w = pa_shared_get(c, t))) {
pa_xfree(t);
pa_assert(PA_REFCNT_VALUE(w) >= 1);
PA_REFCNT_INC(w);
return w;
}
w = pa_xnew0(pa_reserve_monitor_wrapper, 1);
PA_REFCNT_INIT(w);
w->core = c;
pa_hook_init(&w->hook, w);
w->shared_name = t;
pa_assert_se(pa_shared_set(c, w->shared_name, w) >= 0);
#ifdef HAVE_DBUS
if (!(w->connection = pa_dbus_bus_get(c, DBUS_BUS_SESSION, &error)) || dbus_error_is_set(&error)) {
pa_log_debug("Unable to contact D-Bus session bus: %s: %s", error.name, error.message);
/* We don't treat this as error here because we want allow PA
* to run even when no session bus is available. */
return w;
}
if ((k = rm_watch(
&w->monitor,
pa_dbus_connection_get(w->connection),
device_name,
change_cb,
NULL)) < 0) {
pa_log_debug("Failed to create watch on device '%s': %s", device_name, pa_cstrerror(-k));
goto fail;
}
pa_log_debug("Successfully create reservation lock monitor for device '%s'", device_name);
rm_set_userdata(w->monitor, w);
return w;
fail:
dbus_error_free(&error);
reserve_monitor_wrapper_free(w);
return NULL;
#else
return w;
#endif
}
开发者ID:KimT,项目名称:pulseaudio_kt,代码行数:67,代码来源:reserve-wrap.c
示例9: time_event_destroy_cb
static void time_event_destroy_cb(pa_mainloop_api *a, pa_time_event *e, void *userdata) {
pa_xfree(userdata);
}
开发者ID:Klayv,项目名称:pulseaudio,代码行数:3,代码来源:dbus-util.c
示例10: pa_assert
//.........这里部分代码省略.........
data.namereg_fail = namereg_fail;
pa_source_new_data_set_sample_spec(&data, &sample_spec);
pa_source_new_data_set_channel_map(&data, &channel_map);
pa_source_new_data_set_alternate_sample_rate(&data, alternate_sample_rate);
if (am)
pa_droid_add_ports(data.ports, am, card);
u->source = pa_source_new(m->core, &data, PA_SOURCE_HARDWARE);
pa_source_new_data_done(&data);
if (!u->source) {
pa_log("Failed to create source.");
goto fail;
}
u->source->userdata = u;
u->source->parent.process_msg = source_process_msg;
source_set_mute_control(u);
u->source->set_port = source_set_port_cb;
pa_source_set_asyncmsgq(u->source, u->thread_mq.inq);
pa_source_set_rtpoll(u->source, u->rtpoll);
/* Disable rewind for droid source */
pa_source_set_max_rewind(u->source, 0);
thread_name = pa_sprintf_malloc("droid-source-%s", module_id);
if (!(u->thread = pa_thread_new(thread_name, thread_func, u))) {
pa_log("Failed to create thread.");
goto fail;
}
pa_xfree(thread_name);
thread_name = NULL;
pa_source_set_fixed_latency(u->source, pa_bytes_to_usec(u->buffer_size, &sample_spec));
pa_log_debug("Set fixed latency %" PRIu64 " usec", pa_bytes_to_usec(u->buffer_size, &sample_spec));
if (u->source->active_port)
source_set_port_cb(u->source, u->source->active_port);
pa_source_put(u->source);
return u->source;
fail:
pa_xfree(thread_name);
if (config)
pa_xfree(config);
if (u)
userdata_free(u);
return NULL;
}
void pa_droid_source_free(pa_source *s) {
struct userdata *u;
pa_source_assert_ref(s);
pa_assert_se(u = s->userdata);
userdata_free(u);
}
static void userdata_free(struct userdata *u) {
if (u->source)
pa_source_unlink(u->source);
if (u->thread) {
pa_asyncmsgq_send(u->thread_mq.inq, NULL, PA_MESSAGE_SHUTDOWN, NULL, 0, NULL);
pa_thread_free(u->thread);
}
pa_thread_mq_done(&u->thread_mq);
if (u->source)
pa_source_unref(u->source);
if (u->memchunk.memblock)
pa_memblock_unref(u->memchunk.memblock);
if (u->hw_module && u->stream) {
pa_droid_hw_module_lock(u->hw_module);
u->hw_module->device->close_input_stream(u->hw_module->device, u->stream);
pa_droid_hw_module_unlock(u->hw_module);
}
// Stand alone source
if (u->hw_module)
pa_droid_hw_module_unref(u->hw_module);
pa_xfree(u);
}
开发者ID:morphis,项目名称:pulseaudio,代码行数:101,代码来源:droid-source.c
示例11: pa_reserve_wrapper_get
pa_reserve_wrapper* pa_reserve_wrapper_get(pa_core *c, const char *device_name) {
pa_reserve_wrapper *r;
int k;
char *t;
#ifdef HAVE_DBUS
DBusError error;
dbus_error_init(&error);
#endif
pa_assert(c);
pa_assert(device_name);
t = pa_sprintf_malloc("[email protected]%s", device_name);
if ((r = pa_shared_get(c, t))) {
pa_xfree(t);
pa_assert(PA_REFCNT_VALUE(r) >= 1);
PA_REFCNT_INC(r);
return r;
}
r = pa_xnew0(pa_reserve_wrapper, 1);
PA_REFCNT_INIT(r);
r->core = c;
pa_hook_init(&r->hook, r);
r->shared_name = t;
pa_assert_se(pa_shared_set(c, r->shared_name, r) >= 0);
#ifdef HAVE_DBUS
if (!(r->connection = pa_dbus_bus_get(c, DBUS_BUS_SESSION, &error)) || dbus_error_is_set(&error)) {
pa_log_debug("Unable to contact D-Bus session bus: %s: %s", error.name, error.message);
/* We don't treat this as error here because we want allow PA
* to run even when no session bus is available. */
return r;
}
if ((k = rd_acquire(
&r->device,
pa_dbus_connection_get(r->connection),
device_name,
_("PulseAudio Sound Server"),
0,
request_cb,
NULL)) < 0) {
if (k == -EBUSY) {
pa_log_debug("Device '%s' already locked.", device_name);
goto fail;
} else {
pa_log_debug("Failed to acquire reservation lock on device '%s': %s", device_name, pa_cstrerror(-k));
return r;
}
}
pa_log_debug("Successfully acquired reservation lock on device '%s'", device_name);
rd_set_userdata(r->device, r);
return r;
fail:
dbus_error_free(&error);
reserve_wrapper_free(r);
return NULL;
#else
return r;
#endif
}
开发者ID:KimT,项目名称:pulseaudio_kt,代码行数:74,代码来源:reserve-wrap.c
示例12: pa_source_new_data_set_port
void pa_source_new_data_set_port(pa_source_new_data *data, const char *port) {
pa_assert(data);
pa_xfree(data->active_port);
data->active_port = pa_xstrdup(port);
}
开发者ID:felfert,项目名称:pulseaudio,代码行数:6,代码来源:source.c
示例13: pa_source_new_data_set_name
void pa_source_new_data_set_name(pa_source_new_data *data, const char *name) {
pa_assert(data);
pa_xfree(data->name);
data->name = pa_xstrdup(name);
}
开发者ID:felfert,项目名称:pulseaudio,代码行数:6,代码来源:source.c
示例14: pa_source_new
/* Called from main context */
pa_source* pa_source_new(
pa_core *core,
pa_source_new_data *data,
pa_source_flags_t flags) {
pa_source *s;
const char *name;
char st[PA_SAMPLE_SPEC_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX];
char *pt;
pa_assert(core);
pa_assert(data);
pa_assert(data->name);
pa_assert_ctl_context();
s = pa_msgobject_new(pa_source);
if (!(name = pa_namereg_register(core, data->name, PA_NAMEREG_SOURCE, s, data->namereg_fail))) {
pa_log_debug("Failed to register name %s.", data->name);
pa_xfree(s);
return NULL;
}
pa_source_new_data_set_name(data, name);
if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SOURCE_NEW], data) < 0) {
pa_xfree(s);
pa_namereg_unregister(core, name);
return NULL;
}
/* FIXME, need to free s here on failure */
pa_return_null_if_fail(!data->driver || pa_utf8_valid(data->driver));
pa_return_null_if_fail(data->name && pa_utf8_valid(data->name) && data->name[0]);
pa_return_null_if_fail(data->sample_spec_is_set && pa_sample_spec_valid(&data->sample_spec));
if (!data->channel_map_is_set)
pa_return_null_if_fail(pa_channel_map_init_auto(&data->channel_map, data->sample_spec.channels, PA_CHANNEL_MAP_DEFAULT));
pa_return_null_if_fail(pa_channel_map_valid(&data->channel_map));
pa_return_null_if_fail(data->channel_map.channels == data->sample_spec.channels);
if (!data->volume_is_set)
pa_cvolume_reset(&data->volume, data->sample_spec.channels);
pa_return_null_if_fail(pa_cvolume_valid(&data->volume));
pa_return_null_if_fail(pa_cvolume_compatible(&data->volume, &data->sample_spec));
if (!data->muted_is_set)
data->muted = FALSE;
if (data->card)
pa_proplist_update(data->proplist, PA_UPDATE_MERGE, data->card->proplist);
pa_device_init_description(data->proplist);
pa_device_init_icon(data->proplist, FALSE);
pa_device_init_intended_roles(data->proplist);
if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SOURCE_FIXATE], data) < 0) {
pa_xfree(s);
pa_namereg_unregister(core, name);
return NULL;
}
s->parent.parent.free = source_free;
s->parent.process_msg = pa_source_process_msg;
s->core = core;
s->state = PA_SOURCE_INIT;
s->flags = flags;
s->priority = 0;
s->suspend_cause = 0;
s->name = pa_xstrdup(name);
s->proplist = pa_proplist_copy(data->proplist);
s->driver = pa_xstrdup(pa_path_get_filename(data->driver));
s->module = data->module;
s->card = data->card;
s->priority = pa_device_init_priority(s->proplist);
s->sample_spec = data->sample_spec;
s->channel_map = data->channel_map;
s->outputs = pa_idxset_new(NULL, NULL);
s->n_corked = 0;
s->monitor_of = NULL;
s->output_from_master = NULL;
s->volume = data->volume;
pa_cvolume_reset(&s->soft_volume, s->sample_spec.channels);
s->base_volume = PA_VOLUME_NORM;
s->n_volume_steps = PA_VOLUME_NORM+1;
s->muted = data->muted;
s->refresh_volume = s->refresh_muted = FALSE;
reset_callbacks(s);
s->userdata = NULL;
//.........这里部分代码省略.........
开发者ID:felfert,项目名称:pulseaudio,代码行数:101,代码来源:source.c
示例15: pa__init
//.........这里部分代码省略.........
m->userdata = u;
u->fd = fd;
u->mixer_fd = -1;
u->mixer_devmask = 0;
u->use_getospace = u->use_getispace = true;
u->use_getodelay = true;
u->mode = mode;
u->frame_size = pa_frame_size(&ss);
u->device_name = pa_xstrdup(dev);
u->in_nfrags = u->out_nfrags = (uint32_t) (u->nfrags = nfrags);
u->out_fragment_size = u->in_fragment_size = (uint32_t) (u->frag_size = frag_size);
u->orig_frag_size = orig_frag_size;
u->use_mmap = use_mmap;
u->rtpoll = pa_rtpoll_new();
if (pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll) < 0) {
pa_log("pa_thread_mq_init() failed.");
goto fail;
}
u->rtpoll_item = NULL;
build_pollfd(u);
if (ioctl(fd, SNDCTL_DSP_GETISPACE, &info) >= 0) {
pa_log_info("Input -- %u fragments of size %u.", info.fragstotal, info.fragsize);
u->in_fragment_size = (uint32_t) info.fragsize;
u->in_nfrags = (uint32_t) info.fragstotal;
u->use_getispace = true;
}
if (ioctl(fd, SNDCTL_DSP_GETOSPACE, &info) >= 0) {
pa_log_info("Output -- %u fragments of size %u.", info.fragstotal, info.fragsize);
u->out_fragment_size = (uint32_t) info.fragsize;
u->out_nfrags = (uint32_t) info.fragstotal;
u->use_getospace = true;
}
u->in_hwbuf_size = u->in_nfrags * u->in_fragment_size;
u->out_hwbuf_size = u->out_nfrags * u->out_fragment_size;
if (mode != O_WRONLY) {
char *name_buf = NULL;
if (use_mmap) {
if ((u->in_mmap = mmap(NULL, u->in_hwbuf_size, PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED) {
pa_log_warn("mmap(PROT_READ) failed, reverting to non-mmap mode: %s", pa_cstrerror(errno));
use_mmap = u->use_mmap = false;
u->in_mmap = NULL;
} else
pa_log_debug("Successfully mmap()ed input buffer.");
}
if ((name = pa_modargs_get_value(ma, "source_name", NULL)))
namereg_fail = true;
else {
name = name_buf = pa_sprintf_malloc("oss_input.%s", pa_path_get_filename(dev));
namereg_fail = false;
}
pa_source_new_data_init(&source_new_data);
source_new_data.driver = __FILE__;
source_new_data.module = m;
pa_source_new_data_set_name(&source_new_data, name);
source_new_data.namereg_fail = namereg_fail;
pa_source_new_data_set_sample_spec(&source_new_data, &ss);
pa_source_new_data_set_channel_map(&source_new_data, &map);
pa_proplist_sets(source_new_data.proplist, PA_PROP_DEVICE_STRING, dev);
pa_proplist_sets(source_new_data.proplist, PA_PROP_DEVICE_API, "oss");
pa_proplist_sets(source_new_data.proplist, PA_PROP_DEVICE_DESCRIPTION, hwdesc[0] ? hwdesc : dev);
pa_proplist_sets(source_new_data.proplist, PA_PROP_DEVICE_ACCESS_MODE, use_mmap ? "mmap" : "serial");
pa_proplist_setf(source_new_data.proplist, PA_PROP_DEVICE_BUFFERING_BUFFER_SIZE, "%lu", (unsigned long) (u->in_hwbuf_size));
pa_proplist_setf(source_new_data.proplist, PA_PROP_DEVICE_BUFFERING_FRAGMENT_SIZE, "%lu", (unsigned long) (u->in_fragment_size));
if (pa_modargs_get_proplist(ma, "source_properties", source_new_data.proplist, PA_UPDATE_REPLACE) < 0) {
pa_log("Invalid properties");
pa_source_new_data_done(&source_new_data);
pa_xfree(name_buf);
goto fail;
}
u->source = pa_source_new(m->core, &source_new_data, PA_SOURCE_HARDWARE|PA_SOURCE_LATENCY);
pa_source_new_data_done(&source_new_data);
pa_xfree(name_buf);
if (!u->source) {
pa_log("Failed to create source object");
goto fail;
}
u->source->parent.process_msg = source_process_msg;
u->source->userdata = u;
pa_source_set_asyncmsgq(u->source, u->thread_mq.inq);
pa_source_set_rtpoll(u->source, u->rtpoll);
pa_source_set_fixed_latency(u->source, pa_bytes_to_usec(u->in_hwbuf_size, &u->source->sample_spec));
u->source->refresh_volume = true;
if (use_mmap)
u->in_mmap_memblocks = pa_xnew0(pa_memblock*, u->in_nfrags);
}
开发者ID:ford-prefect,项目名称:pulseaudio,代码行数:101,代码来源:module-oss.c
示例16: pa__init
int pa__init(pa_module*m) {
struct userdata *u;
pa_sample_spec ss;
pa_channel_map map;
pa_modargs *ma;
char *t;
pa_sink *master;
pa_sink_input_new_data sink_input_data;
pa_sink_new_data sink_data;
const char *plugin, *label, *input_ladspaport_map, *output_ladspaport_map;
LADSPA_Descriptor_Function descriptor_func;
unsigned long input_ladspaport[PA_CHANNELS_MAX], output_ladspaport[PA_CHANNELS_MAX];
const char *e, *cdata;
const LADSPA_Descriptor *d;
unsigned long p, h, j, n_control, c;
pa_bool_t *use_default = NULL;
pa_assert(m);
pa_assert_cc(sizeof(LADSPA_Data) == sizeof(float));
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("Failed to parse module arguments.");
goto fail;
}
if (!(master = pa_namereg_get(m->core, pa_modargs_get_value(ma, "master", NULL), PA_NAMEREG_SINK))) {
pa_log("Master sink not found");
goto fail;
}
ss = master->sample_spec;
ss.format = PA_SAMPLE_FLOAT32;
|
请发表评论