mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -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) {
 | 
			
		||||
    char buf[PATH_MAX];
 | 
			
		||||
    const char *p, *e;
 | 
			
		||||
    char *rp = NULL;
 | 
			
		||||
    int r;
 | 
			
		||||
 | 
			
		||||
    if (readlink(dev, buf, sizeof(buf)) < 0) {
 | 
			
		||||
        if (errno != EINVAL && errno != ENOLINK)
 | 
			
		||||
            return -1;
 | 
			
		||||
    if (!(p = rp = pa_readlink(dev))) {
 | 
			
		||||
        if (errno != EINVAL && errno != ENOLINK) {
 | 
			
		||||
            r = -1;
 | 
			
		||||
            goto finish;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        p = dev;
 | 
			
		||||
    } else
 | 
			
		||||
        p = buf;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if ((e = strrchr(p, '/')))
 | 
			
		||||
        p = e+1;
 | 
			
		||||
 | 
			
		||||
    if (p == 0)
 | 
			
		||||
        return 0;
 | 
			
		||||
    if (p == 0) {
 | 
			
		||||
        r = 0;
 | 
			
		||||
        goto finish;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    p = strchr(p, 0) -1;
 | 
			
		||||
 | 
			
		||||
    if (*p >= '0' && *p <= '9')
 | 
			
		||||
        return *p - '0';
 | 
			
		||||
    if (*p >= '0' && *p <= '9') {
 | 
			
		||||
        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) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -55,6 +55,7 @@
 | 
			
		|||
#include <sys/prctl.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <pulse/xmalloc.h>
 | 
			
		||||
#include <pulsecore/winsock.h>
 | 
			
		||||
#include <pulsecore/core-error.h>
 | 
			
		||||
#include <pulsecore/log.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -172,13 +173,13 @@ char *pa_get_binary_name(char *s, size_t l) {
 | 
			
		|||
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
    {
 | 
			
		||||
        int i;
 | 
			
		||||
        char path[PATH_MAX];
 | 
			
		||||
        char *rp;
 | 
			
		||||
        /* This works on Linux only */
 | 
			
		||||
 | 
			
		||||
        if ((i = readlink("/proc/self/exe", path, sizeof(path)-1)) >= 0) {
 | 
			
		||||
            path[i] = 0;
 | 
			
		||||
            return pa_strlcpy(s, pa_path_get_filename(path), l);
 | 
			
		||||
        if ((rp = pa_readlink("/proc/self/exe"))) {
 | 
			
		||||
            pa_strlcpy(s, pa_path_get_filename(rp), l);
 | 
			
		||||
            pa_xfree(rp);
 | 
			
		||||
            return s;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue