本文整理汇总了C++中pa_log_warn函数的典型用法代码示例。如果您正苦于以下问题:C++ pa_log_warn函数的具体用法?C++ pa_log_warn怎么用?C++ pa_log_warn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pa_log_warn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pa_memchunk_dump_to_file
void pa_memchunk_dump_to_file(pa_memchunk *c, const char *fn) {
FILE *f;
void *p;
pa_assert(c);
pa_assert(fn);
/* Only for debugging purposes */
f = pa_fopen_cloexec(fn, "a");
if (!f) {
pa_log_warn("Failed to open '%s': %s", fn, pa_cstrerror(errno));
return;
}
p = pa_memblock_acquire(c->memblock);
if (fwrite((uint8_t*) p + c->index, 1, c->length, f) != c->length)
pa_log_warn("Failed to write to '%s': %s", fn, pa_cstrerror(errno));
pa_memblock_release(c->memblock);
fclose(f);
}
示例2: read_pid
/* Read the PID data from the file descriptor fd, and return it. If no
* pid could be read, return 0, on failure (pid_t) -1 */
static pid_t read_pid(const char *fn, int fd) {
ssize_t r;
char t[20], *e;
uint32_t pid;
pa_assert(fn);
pa_assert(fd >= 0);
if ((r = pa_loop_read(fd, t, sizeof(t)-1, NULL)) < 0) {
pa_log_warn("Failed to read PID file '%s': %s", fn, pa_cstrerror(errno));
return (pid_t) -1;
}
if (r == 0)
return (pid_t) 0;
t[r] = 0;
if ((e = strchr(t, '\n')))
*e = 0;
if (pa_atou(t, &pid) < 0) {
pa_log_warn("Failed to parse PID file '%s'", fn);
errno = EINVAL;
return (pid_t) -1;
}
return (pid_t) pid;
}
示例3: pa_raise_priority
/* Raise the priority of the current process as much as possible that
* is <= the specified nice level..*/
int pa_raise_priority(int nice_level) {
#ifdef HAVE_SYS_RESOURCE_H
if (setpriority(PRIO_PROCESS, 0, nice_level) < 0) {
int n;
for (n = nice_level+1; n < 0; n++) {
if (setpriority(PRIO_PROCESS, 0, n) == 0) {
pa_log_info("Successfully acquired nice level %i, which is lower than the requested %i.", n, nice_level);
return 0;
}
}
pa_log_warn("setpriority(): %s", pa_cstrerror(errno));
return -1;
}
pa_log_info("Successfully gained nice level %i.", nice_level);
#endif
#ifdef OS_IS_WIN32
if (nice_level < 0) {
if (!SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS)) {
pa_log_warn("SetPriorityClass() failed: 0x%08X", GetLastError());
return .-1;
} else
示例4: dbus_error_init
static pa_dbus_connection *register_dbus(pa_core *c) {
DBusError error;
pa_dbus_connection *conn;
dbus_error_init(&error);
if (!(conn = pa_dbus_bus_get(c, pa_in_system_mode() ? DBUS_BUS_SYSTEM : DBUS_BUS_SESSION, &error)) || dbus_error_is_set(&error)) {
pa_log_warn("Unable to contact D-Bus: %s: %s", error.name, error.message);
goto fail;
}
if (dbus_bus_request_name(pa_dbus_connection_get(conn), "org.pulseaudio.Server", DBUS_NAME_FLAG_DO_NOT_QUEUE, &error) == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
pa_log_debug("Got org.pulseaudio.Server!");
return conn;
}
if (dbus_error_is_set(&error))
pa_log_warn("Failed to acquire org.pulseaudio.Server: %s: %s", error.name, error.message);
else
pa_log_warn("D-Bus name org.pulseaudio.Server already taken. Weird shit!");
/* PA cannot be started twice by the same user and hence we can
* ignore mostly the case that org.pulseaudio.Server is already
* taken. */
fail:
if (conn)
pa_dbus_connection_unref(conn);
dbus_error_free(&error);
return NULL;
}
示例5: load
/* Load an authorization cookie from file fn and store it in data. If
* the cookie file doesn't exist, create it */
static int load(const char *fn, void *data, size_t length) {
int fd = -1;
int writable = 1;
int unlock = 0, ret = -1;
ssize_t r;
pa_assert(fn);
pa_assert(data);
pa_assert(length > 0);
if ((fd = pa_open_cloexec(fn, O_RDWR|O_CREAT|O_BINARY, S_IRUSR|S_IWUSR)) < 0) {
if (errno != EACCES || (fd = open(fn, O_RDONLY|O_BINARY)) < 0) {
pa_log_warn("Failed to open cookie file '%s': %s", fn, pa_cstrerror(errno));
goto finish;
} else
writable = 0;
}
unlock = pa_lock_fd(fd, 1) >= 0;
if ((r = pa_loop_read(fd, data, length, NULL)) < 0) {
pa_log("Failed to read cookie file '%s': %s", fn, pa_cstrerror(errno));
goto finish;
}
if ((size_t) r != length) {
pa_log_debug("Got %d bytes from cookie file '%s', expected %d", (int) r, fn, (int) length);
if (!writable) {
pa_log_warn("Unable to write cookie to read-only file");
goto finish;
}
if (generate(fd, data, length) < 0)
goto finish;
}
ret = 0;
finish:
if (fd >= 0) {
if (unlock)
pa_lock_fd(fd, 0);
if (pa_close(fd) < 0) {
pa_log_warn("Failed to close cookie file: %s", pa_cstrerror(errno));
ret = -1;
}
}
return ret;
}
示例6: open_pid_file
static int open_pid_file(const char *fn, int mode) {
int fd;
pa_assert(fn);
for (;;) {
struct stat st;
if ((fd = pa_open_cloexec(fn, mode
#ifdef O_NOFOLLOW
|O_NOFOLLOW
#endif
, S_IRUSR|S_IWUSR
)) < 0) {
if (mode != O_RDONLY || errno != ENOENT)
pa_log_warn("Failed to open PID file '%s': %s", fn, pa_cstrerror(errno));
goto fail;
}
/* Try to lock the file. If that fails, go without */
if (pa_lock_fd(fd, 1) < 0)
goto fail;
if (fstat(fd, &st) < 0) {
pa_log_warn("Failed to fstat() PID file '%s': %s", fn, pa_cstrerror(errno));
goto fail;
}
/* Does the file still exist in the file system? When yes, we're done, otherwise restart */
if (st.st_nlink >= 1)
break;
if (pa_lock_fd(fd, 0) < 0)
goto fail;
if (pa_close(fd) < 0) {
pa_log_warn("Failed to close file '%s': %s", fn, pa_cstrerror(errno));
fd = -1;
goto fail;
}
}
return fd;
fail:
if (fd >= 0) {
int saved_errno = errno;
pa_lock_fd(fd, 0);
pa_close(fd);
errno = saved_errno;
}
return -1;
}
示例7: read_entry
static struct entry* read_entry(struct userdata *u, const char *name) {
pa_datum key, data;
struct entry *e;
pa_assert(u);
pa_assert(name);
key.data = (char*) name;
key.size = strlen(name);
pa_zero(data);
if (!pa_database_get(u->database, &key, &data))
goto fail;
if (data.size != sizeof(struct entry)) {
pa_log_debug("Database contains entry for device %s of wrong size %lu != %lu. Probably due to upgrade, ignoring.", name, (unsigned long) data.size, (unsigned long) sizeof(struct entry));
goto fail;
}
e = (struct entry*) data.data;
if (e->version != ENTRY_VERSION) {
pa_log_debug("Version of database entry for device %s doesn't match our version. Probably due to upgrade, ignoring.", name);
goto fail;
}
if (!memchr(e->port, 0, sizeof(e->port))) {
pa_log_warn("Database contains entry for device %s with missing NUL byte in port name", name);
goto fail;
}
if (e->volume_valid && !pa_channel_map_valid(&e->channel_map)) {
pa_log_warn("Invalid channel map stored in database for device %s", name);
goto fail;
}
if (e->volume_valid && (!pa_cvolume_valid(&e->volume) || !pa_cvolume_compatible_with_channel_map(&e->volume, &e->channel_map))) {
pa_log_warn("Volume and channel map don't match in database entry for device %s", name);
goto fail;
}
return e;
fail:
pa_datum_free(&data);
return NULL;
}
示例8: sco_acquire_cb
static int sco_acquire_cb(pa_bluetooth_transport *t, bool optional, size_t *imtu, size_t *omtu) {
int sock;
socklen_t len;
if (optional)
sock = sco_do_accept(t);
else
sock = sco_do_connect(t);
if (sock < 0)
goto fail;
if (imtu) *imtu = 48;
if (omtu) *omtu = 48;
if (t->device->autodetect_mtu) {
struct sco_options sco_opt;
len = sizeof(sco_opt);
memset(&sco_opt, 0, len);
if (getsockopt(sock, SOL_SCO, SCO_OPTIONS, &sco_opt, &len) < 0)
pa_log_warn("getsockopt(SCO_OPTIONS) failed, loading defaults");
else {
if (imtu) *imtu = sco_opt.mtu;
if (omtu) *omtu = sco_opt.mtu;
}
}
return sock;
fail:
return -1;
}
示例9: parse_rlimit
static int parse_rlimit(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata) {
#ifdef HAVE_SYS_RESOURCE_H
struct pa_rlimit *r = data;
pa_assert(filename);
pa_assert(lvalue);
pa_assert(rvalue);
pa_assert(r);
if (rvalue[strspn(rvalue, "\t ")] == 0) {
/* Empty string */
r->is_set = 0;
r->value = 0;
} else {
int32_t k;
if (pa_atoi(rvalue, &k) < 0) {
pa_log(_("[%s:%u] Invalid rlimit '%s'."), filename, line, rvalue);
return -1;
}
r->is_set = k >= 0;
r->value = k >= 0 ? (rlim_t) k : 0;
}
#else
pa_log_warn(_("[%s:%u] rlimit not supported on this platform."), filename, line);
#endif
return 0;
}
示例10: dbus_error_init
static pa_dbus_connection *register_dbus_name(pa_core *c, DBusBusType bus, const char* name) {
DBusError error;
pa_dbus_connection *conn;
dbus_error_init(&error);
if (!(conn = pa_dbus_bus_get(c, bus, &error)) || dbus_error_is_set(&error)) {
pa_log_warn("Unable to contact D-Bus: %s: %s", error.name, error.message);
goto fail;
}
if (dbus_bus_request_name(pa_dbus_connection_get(conn), name, DBUS_NAME_FLAG_DO_NOT_QUEUE, &error) == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
pa_log_debug("Got %s!", name);
return conn;
}
if (dbus_error_is_set(&error))
pa_log_error("Failed to acquire %s: %s: %s", name, error.name, error.message);
else
pa_log_error("D-Bus name %s already taken.", name);
/* PA cannot be started twice by the same user and hence we can
* ignore mostly the case that a name is already taken. */
fail:
if (conn)
pa_dbus_connection_unref(conn);
dbus_error_free(&error);
return NULL;
}
示例11: inotify_cb
static void inotify_cb(
pa_mainloop_api *a,
pa_io_event *e,
int fd,
pa_io_event_flags_t events,
void *userdata) {
struct {
struct inotify_event event;
char name[NAME_MAX+1];
} buf;
pa_inotify *i = userdata;
int pid_fd;
pa_assert(i);
if (pa_read(fd, &buf, sizeof(buf), NULL) < (int) sizeof(buf.event))
pa_log_warn("inotify did not read a full event.");
else
pa_log_debug("inotify callback, event mask: 0x%x", (int) buf.event.mask);
pid_fd = pa_open_cloexec(i->filename, O_RDONLY
#ifdef O_NOFOLLOW
|O_NOFOLLOW
#endif
, S_IRUSR);
if (pid_fd < 0) {
if (i->callback)
i->callback(i->callback_data);
} else
pa_close(pid_fd);
}
示例12: 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");
}
示例13: pa_mempool_free
void pa_mempool_free(pa_mempool *p) {
pa_assert(p);
pa_mutex_lock(p->mutex);
while (p->imports)
pa_memimport_free(p->imports);
while (p->exports)
pa_memexport_free(p->exports);
pa_mutex_unlock(p->mutex);
pa_flist_free(p->free_slots, NULL);
if (pa_atomic_load(&p->stat.n_allocated) > 0) {
/* raise(SIGTRAP); */
pa_log_warn("Memory pool destroyed but not all memory blocks freed! %u remain.", pa_atomic_load(&p->stat.n_allocated));
}
pa_shm_free(&p->memory);
pa_mutex_free(p->mutex);
pa_semaphore_free(p->semaphore);
pa_xfree(p);
}
示例14: dbus_error_init
pa_dbusobj_server_lookup *pa_dbusobj_server_lookup_new(pa_core *c) {
pa_dbusobj_server_lookup *sl;
DBusError error;
dbus_error_init(&error);
sl = pa_xnew(pa_dbusobj_server_lookup, 1);
sl->core = c;
sl->path_registered = false;
if (!(sl->conn = pa_dbus_bus_get(c, DBUS_BUS_SESSION, &error)) || dbus_error_is_set(&error)) {
pa_log_warn("Unable to contact D-Bus: %s: %s", error.name, error.message);
goto fail;
}
if (!dbus_connection_register_object_path(pa_dbus_connection_get(sl->conn), OBJECT_PATH, &vtable, sl)) {
pa_log("dbus_connection_register_object_path() failed for " OBJECT_PATH ".");
goto fail;
}
sl->path_registered = true;
return sl;
fail:
dbus_error_free(&error);
pa_dbusobj_server_lookup_free(sl);
return NULL;
}
示例15: parse_device_list
static bool parse_device_list(const char *str, audio_devices_t *dst) {
char *dev;
const char *state = NULL;
pa_assert(str);
pa_assert(dst);
*dst = 0;
while ((dev = pa_split(str, "|", &state))) {
audio_devices_t d;
if (!pa_string_convert_input_device_str_to_num(dev, &d)) {
pa_log_warn("Unknown device %s", dev);
pa_xfree(dev);
return false;
}
*dst |= d;
pa_xfree(dev);
}
return true;
}