本文整理汇总了C++中pa_sprintf_malloc函数的典型用法代码示例。如果您正苦于以下问题:C++ pa_sprintf_malloc函数的具体用法?C++ pa_sprintf_malloc怎么用?C++ pa_sprintf_malloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pa_sprintf_malloc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: pa_sprintf_malloc
static char *list_string(struct string_conversion *list, uint32_t flags) {
char *str = NULL;
char *tmp;
#if AUDIO_API_VERSION_MAJ >= 2
if (flags & AUDIO_DEVICE_BIT_IN)
flags &= ~AUDIO_DEVICE_BIT_IN;
#endif
for (unsigned int i = 0; list[i].str; i++) {
#if AUDIO_API_VERSION_MAJ >= 2
if (list[i].value & AUDIO_DEVICE_BIT_IN) {
if (popcount(list[i].value & ~AUDIO_DEVICE_BIT_IN) != 1)
continue;
} else
#endif
if (popcount(list[i].value) != 1)
continue;
if (flags & list[i].value) {
if (str) {
tmp = pa_sprintf_malloc("%s|%s", str, list[i].str);
pa_xfree(str);
str = tmp;
} else {
str = pa_sprintf_malloc("%s", list[i].str);
}
}
}
return str;
}
开发者ID:jusa,项目名称:pulseaudio-modules-droid,代码行数:32,代码来源:conversion.c
示例2: pa_sprintf_malloc
static pa_strlist *prepend_per_user(pa_strlist *l) {
char *ufn;
#ifdef ENABLE_LEGACY_RUNTIME_DIR
char *legacy_dir;
/* The very old per-user instance path (< 0.9.11). This is supported only to ease upgrades */
if ((legacy_dir = get_very_old_legacy_runtime_dir())) {
char *p = pa_sprintf_malloc("%s" PA_PATH_SEP PA_NATIVE_DEFAULT_UNIX_SOCKET, legacy_dir);
l = pa_strlist_prepend(l, p);
pa_xfree(p);
pa_xfree(legacy_dir);
}
/* The old per-user instance path (< 0.9.12). This is supported only to ease upgrades */
if ((legacy_dir = get_old_legacy_runtime_dir())) {
char *p = pa_sprintf_malloc("%s" PA_PATH_SEP PA_NATIVE_DEFAULT_UNIX_SOCKET, legacy_dir);
l = pa_strlist_prepend(l, p);
pa_xfree(p);
pa_xfree(legacy_dir);
}
#endif
/* The per-user instance */
if ((ufn = pa_runtime_path(PA_NATIVE_DEFAULT_UNIX_SOCKET))) {
l = pa_strlist_prepend(l, ufn);
pa_xfree(ufn);
}
return l;
}
开发者ID:felfert,项目名称:pulseaudio,代码行数:31,代码来源:context.c
示例3: card_changed
static void card_changed(struct userdata *u, struct udev_device *dev) {
struct device *d;
const char *path;
const char *t;
char *n;
pa_assert(u);
pa_assert(dev);
/* Maybe /dev/snd is now available? */
setup_inotify(u);
path = udev_device_get_devpath(dev);
if ((d = pa_hashmap_get(u->devices, path))) {
verify_access(u, d);
return;
}
d = pa_xnew0(struct device, 1);
d->path = pa_xstrdup(path);
d->module = PA_INVALID_INDEX;
PA_INIT_RATELIMIT(d->ratelimit, 10*PA_USEC_PER_SEC, 5);
if (!(t = udev_device_get_property_value(dev, "PULSE_NAME")))
if (!(t = udev_device_get_property_value(dev, "ID_ID")))
if (!(t = udev_device_get_property_value(dev, "ID_PATH")))
t = path_get_card_id(path);
n = pa_namereg_make_valid_name(t);
d->card_name = pa_sprintf_malloc("alsa_card.%s", n);
d->args = pa_sprintf_malloc("device_id=\"%s\" "
"name=\"%s\" "
"card_name=\"%s\" "
"namereg_fail=false "
"tsched=%s "
"fixed_latency_range=%s "
"ignore_dB=%s "
"deferred_volume=%s "
"use_ucm=1 "
"card_properties=\"module-udev-detect.discovered=1\"",
path_get_card_id(path),
n,
d->card_name,
pa_yes_no(u->use_tsched),
pa_yes_no(u->fixed_latency_range),
pa_yes_no(u->ignore_dB),
pa_yes_no(u->deferred_volume));
pa_xfree(n);
pa_hashmap_put(u->devices, d->path, d);
verify_access(u, d);
}
开发者ID:BYSTROSTREL,项目名称:pulseaudio,代码行数:54,代码来源:module-udev-detect.c
示例4: pa_assert
char *pa_sample_spec_to_mime_type(const pa_sample_spec *ss, const pa_channel_map *cm) {
pa_assert(pa_channel_map_compatible(cm, ss));
pa_assert(pa_sample_spec_valid(ss));
if (!pa_sample_spec_is_mime(ss, cm))
return NULL;
switch (ss->format) {
case PA_SAMPLE_S16BE:
case PA_SAMPLE_S24BE:
case PA_SAMPLE_U8:
/* Stupid UPnP implementations (PS3...) choke on spaces in
* the mime type, that's why we write only ';' here,
* instead of '; '. */
return pa_sprintf_malloc("audio/%s;rate=%u;channels=%u",
ss->format == PA_SAMPLE_S16BE ? "L16" :
(ss->format == PA_SAMPLE_S24BE ? "L24" : "L8"),
ss->rate, ss->channels);
case PA_SAMPLE_ULAW:
return pa_xstrdup("audio/basic");
default:
pa_assert_not_reached();
}
}
开发者ID:Distrotech,项目名称:pulseaudio,代码行数:27,代码来源:mime-type.c
示例5: pa_assert
static struct service *get_service(struct userdata *u, pa_object *device) {
struct service *s;
char *hn, *un;
const char *n;
pa_assert(u);
pa_object_assert_ref(device);
if ((s = pa_hashmap_get(u->services, device)))
return s;
s = pa_xnew0(struct service, 1);
s->userdata = u;
s->device = device;
if (pa_sink_isinstance(device)) {
if (!(n = pa_proplist_gets(PA_SINK(device)->proplist, PA_PROP_DEVICE_DESCRIPTION)))
n = PA_SINK(device)->name;
} else {
if (!(n = pa_proplist_gets(PA_SOURCE(device)->proplist, PA_PROP_DEVICE_DESCRIPTION)))
n = PA_SOURCE(device)->name;
}
hn = pa_get_host_name_malloc();
un = pa_get_user_name_malloc();
s->service_name = pa_truncate_utf8(pa_sprintf_malloc("%[email protected]%s: %s", un, hn, n), kDNSServiceMaxDomainName-1);
pa_xfree(un);
pa_xfree(hn);
pa_hashmap_put(u->services, s->device, s);
return s;
}
开发者ID:Elemecca,项目名称:pulseaudio,代码行数:35,代码来源:module-bonjour-publish.c
示例6: pa_auth_cookie_get
pa_auth_cookie* pa_auth_cookie_get(pa_core *core, const char *cn, bool create, size_t size) {
pa_auth_cookie *c;
char *t;
pa_assert(core);
pa_assert(size > 0);
t = pa_sprintf_malloc("auth-cookie%s%s", cn ? "@" : "", cn ? cn : "");
if ((c = pa_shared_get(core, t))) {
pa_xfree(t);
if (c->size != size)
return NULL;
return pa_auth_cookie_ref(c);
}
c = pa_xmalloc(PA_ALIGN(sizeof(pa_auth_cookie)) + size);
PA_REFCNT_INIT(c);
c->core = core;
c->name = t;
c->size = size;
pa_assert_se(pa_shared_set(core, t, c) >= 0);
if (pa_authkey_load(cn, create, (uint8_t*) c + PA_ALIGN(sizeof(pa_auth_cookie)), size) < 0) {
pa_auth_cookie_unref(c);
return NULL;
}
return c;
}
开发者ID:Distrotech,项目名称:pulseaudio,代码行数:34,代码来源:auth-cookie.c
示例7: source_new_hook_callback
static pa_hook_result_t source_new_hook_callback(pa_core *c, pa_source_new_data *new_data, struct userdata *u) {
char *name;
struct entry *e;
pa_assert(c);
pa_assert(new_data);
pa_assert(u);
pa_assert(u->restore_port);
name = pa_sprintf_malloc("source:%s", new_data->name);
if ((e = read_entry(u, name))) {
if (e->port_valid) {
if (!new_data->active_port) {
pa_log_info("Restoring port for source %s.", name);
pa_source_new_data_set_port(new_data, e->port);
new_data->save_port = TRUE;
} else
pa_log_debug("Not restoring port for source %s, because already set.", name);
}
pa_xfree(e);
}
pa_xfree(name);
return PA_HOOK_OK;
}
开发者ID:felfert,项目名称:pulseaudio,代码行数:29,代码来源:module-device-restore.c
示例8: source_put_hook_callback
/* When a source is created, loopback it to default sink */
static pa_hook_result_t source_put_hook_callback(pa_core *c, pa_source *source, void* userdata) {
const char *s;
const char *role;
char *args;
pa_assert(c);
pa_assert(source);
/* Only consider bluetooth sinks and sources */
s = pa_proplist_gets(source->proplist, PA_PROP_DEVICE_BUS);
if (!s)
return PA_HOOK_OK;
if (!pa_streq(s, "bluetooth"))
return PA_HOOK_OK;
/* Restrict to A2DP profile (sink role) */
s = pa_proplist_gets(source->proplist, "bluetooth.protocol");
if (!s)
return PA_HOOK_OK;
if (pa_streq(s, "a2dp_source"))
role = "music";
else {
pa_log_debug("Profile %s cannot be selected for loopback", s);
return PA_HOOK_OK;
}
/* Load module-loopback */
args = pa_sprintf_malloc("source=\"%s\" source_dont_move=\"true\" sink_input_properties=\"media.role=%s\"", source->name, role);
(void) pa_module_load(c, "module-loopback", args);
pa_xfree(args);
return PA_HOOK_OK;
}
开发者ID:dzrongg,项目名称:pulseaudio-1,代码行数:36,代码来源:module-bluetooth-policy.c
示例9: pa_database_open
pa_database* pa_database_open(const char *fn, bool for_write) {
GDBM_FILE f;
int gdbm_cache_size;
char *path;
pa_assert(fn);
/* We include the host identifier in the file name because gdbm
* files are CPU dependent, and we don't want things to go wrong
* if we are on a multiarch system. */
path = pa_sprintf_malloc("%s."CANONICAL_HOST".gdbm", fn);
errno = 0;
/* We need to set the block size explicitly here, since otherwise
* gdbm takes the native block size of the underlying file system
* which might be incredibly large. */
f = gdbm_open((char*) path, 1024, GDBM_NOLOCK | (for_write ? GDBM_WRCREAT : GDBM_READER), 0644, NULL);
if (f)
pa_log_debug("Opened GDBM database '%s'", path);
pa_xfree(path);
if (!f) {
if (errno == 0)
errno = EIO;
return NULL;
}
/* By default the cache of gdbm is rather large, let's reduce it a bit to save memory */
gdbm_cache_size = 10;
gdbm_setopt(f, GDBM_CACHESIZE, &gdbm_cache_size, sizeof(gdbm_cache_size));
return (pa_database*) f;
}
开发者ID:Distrotech,项目名称:pulseaudio,代码行数:35,代码来源:database-gdbm.c
示例10: sink_input_moving_cb
/* Called from main thread */
static void sink_input_moving_cb(pa_sink_input *i, pa_sink *dest) {
struct userdata *u;
char *output_description;
const char *n;
if (!dest)
return;
pa_sink_input_assert_ref(i);
pa_assert_ctl_context();
pa_assert_se(u = i->userdata);
output_description = pa_sprintf_malloc("Loopback to %s",
pa_strnull(pa_proplist_gets(dest->proplist, PA_PROP_DEVICE_DESCRIPTION)));
pa_source_output_set_property(u->source_output, PA_PROP_MEDIA_NAME, output_description);
pa_xfree(output_description);
if ((n = pa_proplist_gets(dest->proplist, PA_PROP_DEVICE_ICON_NAME)))
pa_source_output_set_property(u->source_output, PA_PROP_MEDIA_ICON_NAME, n);
if (pa_sink_get_state(dest) == PA_SINK_SUSPENDED)
pa_source_output_cork(u->source_output, true);
else
pa_source_output_cork(u->source_output, false);
update_adjust_timer(u);
}
开发者ID:ford-prefect,项目名称:pulseaudio,代码行数:28,代码来源:module-loopback.c
示例11: thread_func
static void thread_func(void *data) {
char *s = data;
int n = 0;
int b = 1;
while (!quit) {
char *text;
/* Allocate some memory, if possible take it from the flist */
if (b && (text = pa_flist_pop(flist)))
pa_log("%s: popped '%s'", s, text);
else {
text = pa_sprintf_malloc("Block %i, allocated by %s", n++, s);
pa_log("%s: allocated '%s'", s, text);
}
b = !b;
spin();
/* Give it back to the flist if possible */
if (pa_flist_push(flist, text) < 0) {
pa_log("%s: failed to push back '%s'", s, text);
pa_xfree(text);
} else
pa_log("%s: pushed", s);
spin();
}
if (pa_flist_push(flist, s) < 0)
pa_xfree(s);
}
开发者ID:BYSTROSTREL,项目名称:pulseaudio,代码行数:33,代码来源:flist-test.c
示例12: client_name
static char* client_name(pa_client *c) {
char *t, *e;
if (!c->name || !c->driver)
return NULL;
t = pa_sprintf_malloc("%s$%s", c->driver, c->name);
t[strcspn(t, "\n\r#")] = 0;
if (!*t) {
pa_xfree(t);
return NULL;
}
if ((e = strrchr(t, '('))) {
char *k = e + 1 + strspn(e + 1, "0123456789-");
/* Dirty trick: truncate all trailing parens with numbers in
* between, since they are usually used to identify multiple
* sessions of the same application, which is something we
* explicitly don't want. Besides other stuff this makes xmms
* with esound work properly for us. */
if (*k == ')' && *(k+1) == 0)
*e = 0;
}
return t;
}
开发者ID:thewb,项目名称:mokoiax,代码行数:29,代码来源:module-volume-restore.c
示例13: pa_load_sym
pa_void_func_t pa_load_sym(lt_dlhandle handle, const char *module, const char *symbol) {
char *sn, *c;
pa_void_func_t f;
pa_assert(handle);
pa_assert(module);
pa_assert(symbol);
if ((f = ((pa_void_func_t) (long) lt_dlsym(handle, symbol))))
return f;
/* As the .la files might have been cleansed from the system, we should
* try with the ltdl prefix as well. */
sn = pa_sprintf_malloc("%s_LTX_%s", module, symbol);
for (c = sn; *c; c++)
if (!isalnum(*c))
*c = '_';
f = (pa_void_func_t) (long) lt_dlsym(handle, sn);
pa_xfree(sn);
return f;
}
开发者ID:thewb,项目名称:mokoiax,代码行数:25,代码来源:ltdl-helper.c
示例14: pa_rtsp_record
int pa_rtsp_record(pa_rtsp_client *c, uint16_t *seq, uint32_t *rtptime) {
pa_headerlist *headers;
char *info;
int rv;
pa_assert(c);
if (!c->session) {
/* No session in progress */
return -1;
}
pa_random(seq, sizeof(*seq));
pa_random(rtptime, sizeof(*rtptime));
headers = pa_headerlist_new();
pa_headerlist_puts(headers, "Range", "npt=0-");
info = pa_sprintf_malloc("seq=%u;rtptime=%u", *seq, *rtptime);
pa_headerlist_puts(headers, "RTP-Info", info);
pa_xfree(info);
c->state = STATE_RECORD;
rv = rtsp_exec(c, "RECORD", NULL, NULL, 1, headers);
pa_headerlist_free(headers);
return rv;
}
开发者ID:ford-prefect,项目名称:pulseaudio,代码行数:27,代码来源:rtsp_client.c
示例15: load_null_sink_if_needed
static void load_null_sink_if_needed(pa_core *c, pa_sink *sink, struct userdata* u) {
pa_sink *target;
uint32_t idx;
char *t;
pa_module *m;
pa_assert(c);
pa_assert(u);
pa_assert(u->null_module == PA_INVALID_INDEX);
/* Loop through all sinks and check to see if we have *any*
* sinks. Ignore the sink passed in (if it's not null) */
for (target = pa_idxset_first(c->sinks, &idx); target; target = pa_idxset_next(c->sinks, &idx))
if (!sink || target != sink)
break;
if (target)
return;
pa_log_debug("Autoloading null-sink as no other sinks detected.");
u->ignore = TRUE;
t = pa_sprintf_malloc("sink_name=%s sink_properties='device.description=\"%s\"'", u->sink_name,
_("Dummy Output"));
m = pa_module_load(c, "module-null-sink", t);
u->null_module = m ? m->index : PA_INVALID_INDEX;
pa_xfree(t);
u->ignore = FALSE;
if (!m)
pa_log_warn("Unable to load module-null-sink");
}
开发者ID:BYSTROSTREL,项目名称:pulseaudio,代码行数:34,代码来源:module-always-sink.c
示例16: pa_rtsp_record
int pa_rtsp_record(pa_rtsp_client* c, uint16_t* seq, uint32_t* rtptime) {
pa_headerlist* headers;
int rv;
char *info;
pa_assert(c);
if (!c->session) {
/* No session in progress */
return -1;
}
/* Todo: Generate these values randomly as per spec */
*seq = *rtptime = 0;
headers = pa_headerlist_new();
pa_headerlist_puts(headers, "Range", "npt=0-");
info = pa_sprintf_malloc("seq=%u;rtptime=%u", *seq, *rtptime);
pa_headerlist_puts(headers, "RTP-Info", info);
pa_xfree(info);
c->state = STATE_RECORD;
rv = rtsp_exec(c, "RECORD", NULL, NULL, 1, headers);
pa_headerlist_free(headers);
return rv;
}
开发者ID:almosthappy4u,项目名称:PulseAudio-UCM,代码行数:25,代码来源:rtsp_client.c
示例17: proc_name_ours
static int proc_name_ours(pid_t pid, const char *procname) {
#ifdef __linux__
char bn[PATH_MAX];
FILE *f;
pa_snprintf(bn, sizeof(bn), "/proc/%lu/stat", (unsigned long) pid);
if (!(f = pa_fopen_cloexec(bn, "r"))) {
pa_log_info("Failed to open %s: %s", bn, pa_cstrerror(errno));
return -1;
} else {
char *expected;
pa_bool_t good;
char stored[64];
if (!(fgets(stored, sizeof(stored), f))) {
int saved_errno = feof(f) ? EINVAL : errno;
pa_log_info("Failed to read from %s: %s", bn, feof(f) ? "EOF" : pa_cstrerror(errno));
fclose(f);
errno = saved_errno;
return -1;
}
fclose(f);
expected = pa_sprintf_malloc("%lu (%s)", (unsigned long) pid, procname);
good = pa_startswith(stored, expected);
pa_xfree(expected);
/*#if !defined(__OPTIMIZE__)*/
if (!good) {
/* libtool likes to rename our binary names ... */
expected = pa_sprintf_malloc("%lu (lt-%s)", (unsigned long) pid, procname);
good = pa_startswith(stored, expected);
pa_xfree(expected);
}
/*#endif*/
return !!good;
}
#else
return 1;
#endif
}
开发者ID:KimT,项目名称:pulseaudio_kt,代码行数:47,代码来源:pid.c
示例18: pa_parse_address
int pa_parse_address(const char *name, pa_parsed_address *ret_p) {
const char *p;
pa_assert(name);
pa_assert(ret_p);
memset(ret_p, 0, sizeof(pa_parsed_address));
ret_p->type = PA_PARSED_ADDRESS_TCP_AUTO;
if (*name == '{') {
char *id, *pfx;
/* The URL starts with a host id for detecting local connections */
if (!(id = pa_machine_id()))
return -1;
pfx = pa_sprintf_malloc("{%s}", id);
pa_xfree(id);
if (!pa_startswith(name, pfx)) {
pa_xfree(pfx);
/* Not local */
return -1;
}
p = name + strlen(pfx);
pa_xfree(pfx);
} else
p = name;
if (*p == '/')
ret_p->type = PA_PARSED_ADDRESS_UNIX;
else if (pa_startswith(p, "unix:")) {
ret_p->type = PA_PARSED_ADDRESS_UNIX;
p += sizeof("unix:")-1;
} else if (pa_startswith(p, "tcp:")) {
ret_p->type = PA_PARSED_ADDRESS_TCP4;
p += sizeof("tcp:")-1;
} else if (pa_startswith(p, "tcp4:")) {
ret_p->type = PA_PARSED_ADDRESS_TCP4;
p += sizeof("tcp4:")-1;
} else if (pa_startswith(p, "tcp6:")) {
ret_p->type = PA_PARSED_ADDRESS_TCP6;
p += sizeof("tcp6:")-1;
}
if (ret_p->type == PA_PARSED_ADDRESS_UNIX)
ret_p->path_or_host = pa_xstrdup(p);
else
if (!(ret_p->path_or_host = parse_host(p, &ret_p->port)))
return -1;
return 0;
}
开发者ID:BYSTROSTREL,项目名称:pulseaudio,代码行数:54,代码来源:parseaddr.c
示例19: pa__init
int pa__init(pa_module*m) {
struct userdata *u;
pa_modargs *ma = NULL;
char *hn, *un;
int error;
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("Failed to parse module arguments.");
goto fail;
}
m->userdata = u = pa_xnew(struct userdata, 1);
u->core = m->core;
u->module = m;
u->native = pa_native_protocol_get(u->core);
u->avahi_poll = pa_avahi_poll_new(m->core->mainloop);
u->services = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
u->sink_new_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_PUT], PA_HOOK_LATE, (pa_hook_cb_t) device_new_or_changed_cb, u);
u->sink_changed_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_PROPLIST_CHANGED], PA_HOOK_LATE, (pa_hook_cb_t) device_new_or_changed_cb, u);
u->sink_unlink_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_UNLINK], PA_HOOK_LATE, (pa_hook_cb_t) device_unlink_cb, u);
u->source_new_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_PUT], PA_HOOK_LATE, (pa_hook_cb_t) device_new_or_changed_cb, u);
u->source_changed_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_PROPLIST_CHANGED], PA_HOOK_LATE, (pa_hook_cb_t) device_new_or_changed_cb, u);
u->source_unlink_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_UNLINK], PA_HOOK_LATE, (pa_hook_cb_t) device_unlink_cb, u);
u->main_entry_group = NULL;
un = pa_get_user_name_malloc();
hn = pa_get_host_name_malloc();
u->service_name = pa_truncate_utf8(pa_sprintf_malloc("%[email protected]%s", un, hn), AVAHI_LABEL_MAX-1);
pa_xfree(un);
pa_xfree(hn);
if (!(u->client = avahi_client_new(u->avahi_poll, AVAHI_CLIENT_NO_FAIL, client_callback, u, &error))) {
pa_log("avahi_client_new() failed: %s", avahi_strerror(error));
goto fail;
}
pa_modargs_free(ma);
return 0;
fail:
pa__done(m);
if (ma)
pa_modargs_free(ma);
return -1;
}
开发者ID:BYSTROSTREL,项目名称:pulseaudio,代码行数:53,代码来源:module-zeroconf-publish.c
示例20: find_desktop_file_in_dir
static char * find_desktop_file_in_dir(struct rule *r, const char *desktop_file_dir, struct stat *st) {
char *fn = NULL;
pa_assert(st);
fn = pa_sprintf_malloc("%s" PA_PATH_SEP "%s.desktop", desktop_file_dir, r->process_name);
if (stat(fn, st) == 0)
return fn;
pa_xfree(fn);
#ifdef DT_DIR
{
DIR *desktopfiles_dir;
struct dirent *dir;
/* Let's try a more aggressive search, but only one level */
if ((desktopfiles_dir = opendir(desktop_file_dir))) {
while ((dir = readdir(desktopfiles_dir))) {
if (dir->d_type != DT_DIR
|| pa_streq(dir->d_name, ".")
|| pa_streq(dir->d_name, ".."))
continue;
fn = pa_sprintf_malloc("%s" PA_PATH_SEP "%s" PA_PATH_SEP "%s.desktop", desktop_file_dir, dir->d_name, r->process_name);
if (stat(fn, st) == 0) {
closedir(desktopfiles_dir);
return fn;
}
pa_xfree(fn);
}
closedir(desktopfiles_dir);
}
}
#endif
return NULL;
}
开发者ID:jprvita,项目名称:pulseaudio,代码行数:40,代码来源:module-augment-properties.c
注:本文中的pa_sprintf_malloc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论