mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
make use of new pa_readlink() where applicable
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1975 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
ca98c544ab
commit
27d6b7b473
2 changed files with 27 additions and 16 deletions
|
|
@ -293,29 +293,39 @@ int pa_oss_set_volume(int fd, long mixer, const pa_sample_spec *ss, const pa_cvo
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_device_number(const char *dev) {
|
static int get_device_number(const char *dev) {
|
||||||
char buf[PATH_MAX];
|
|
||||||
const char *p, *e;
|
const char *p, *e;
|
||||||
|
char *rp = NULL;
|
||||||
|
int r;
|
||||||
|
|
||||||
if (readlink(dev, buf, sizeof(buf)) < 0) {
|
if (!(p = rp = pa_readlink(dev))) {
|
||||||
if (errno != EINVAL && errno != ENOLINK)
|
if (errno != EINVAL && errno != ENOLINK) {
|
||||||
return -1;
|
r = -1;
|
||||||
|
goto finish;
|
||||||
|
}
|
||||||
|
|
||||||
p = dev;
|
p = dev;
|
||||||
} else
|
}
|
||||||
p = buf;
|
|
||||||
|
|
||||||
if ((e = strrchr(p, '/')))
|
if ((e = strrchr(p, '/')))
|
||||||
p = e+1;
|
p = e+1;
|
||||||
|
|
||||||
if (p == 0)
|
if (p == 0) {
|
||||||
return 0;
|
r = 0;
|
||||||
|
goto finish;
|
||||||
|
}
|
||||||
|
|
||||||
p = strchr(p, 0) -1;
|
p = strchr(p, 0) -1;
|
||||||
|
|
||||||
if (*p >= '0' && *p <= '9')
|
if (*p >= '0' && *p <= '9') {
|
||||||
return *p - '0';
|
r = *p - '0';
|
||||||
|
goto finish;
|
||||||
|
}
|
||||||
|
|
||||||
return -1;
|
r = -1;
|
||||||
|
|
||||||
|
finish:
|
||||||
|
pa_xfree(rp);
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pa_oss_get_hw_description(const char *dev, char *name, size_t l) {
|
int pa_oss_get_hw_description(const char *dev, char *name, size_t l) {
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <pulse/xmalloc.h>
|
||||||
#include <pulsecore/winsock.h>
|
#include <pulsecore/winsock.h>
|
||||||
#include <pulsecore/core-error.h>
|
#include <pulsecore/core-error.h>
|
||||||
#include <pulsecore/log.h>
|
#include <pulsecore/log.h>
|
||||||
|
|
@ -172,13 +173,13 @@ char *pa_get_binary_name(char *s, size_t l) {
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
{
|
{
|
||||||
int i;
|
char *rp;
|
||||||
char path[PATH_MAX];
|
|
||||||
/* This works on Linux only */
|
/* This works on Linux only */
|
||||||
|
|
||||||
if ((i = readlink("/proc/self/exe", path, sizeof(path)-1)) >= 0) {
|
if ((rp = pa_readlink("/proc/self/exe"))) {
|
||||||
path[i] = 0;
|
pa_strlcpy(s, pa_path_get_filename(rp), l);
|
||||||
return pa_strlcpy(s, pa_path_get_filename(path), l);
|
pa_xfree(rp);
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue