mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	generate default sink/source names from the device files they belong to
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1223 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
		
							parent
							
								
									005017647b
								
							
						
					
					
						commit
						bf79e97591
					
				
					 3 changed files with 56 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -36,6 +36,7 @@
 | 
			
		|||
#include <limits.h>
 | 
			
		||||
 | 
			
		||||
#include <pulse/xmalloc.h>
 | 
			
		||||
#include <pulse/util.h>
 | 
			
		||||
 | 
			
		||||
#include <pulsecore/core-error.h>
 | 
			
		||||
#include <pulsecore/iochannel.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -96,8 +97,6 @@ static const char* const valid_modargs[] = {
 | 
			
		|||
    NULL
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define DEFAULT_SINK_NAME "oss_output"
 | 
			
		||||
#define DEFAULT_SOURCE_NAME "oss_input"
 | 
			
		||||
#define DEFAULT_DEVICE "/dev/dsp"
 | 
			
		||||
 | 
			
		||||
static void update_usage(struct userdata *u) {
 | 
			
		||||
| 
						 | 
				
			
			@ -354,6 +353,9 @@ int pa__init(pa_core *c, pa_module*m) {
 | 
			
		|||
    pa_channel_map map;
 | 
			
		||||
    pa_modargs *ma = NULL;
 | 
			
		||||
    char hwdesc[64], *t;
 | 
			
		||||
    const char *name;
 | 
			
		||||
    char *name_buf = NULL;
 | 
			
		||||
    int namereg_fail;
 | 
			
		||||
    
 | 
			
		||||
    assert(c);
 | 
			
		||||
    assert(m);
 | 
			
		||||
| 
						 | 
				
			
			@ -431,7 +433,14 @@ int pa__init(pa_core *c, pa_module*m) {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    if (mode != O_WRONLY) {
 | 
			
		||||
        if (!(u->source = pa_source_new(c, __FILE__, pa_modargs_get_value(ma, "source_name", DEFAULT_SOURCE_NAME), 0, &ss, &map)))
 | 
			
		||||
        if ((name = pa_modargs_get_value(ma, "source_name", NULL)))
 | 
			
		||||
            namereg_fail = 1;
 | 
			
		||||
        else {
 | 
			
		||||
            name = name_buf = pa_sprintf_malloc("oss_input.%s", pa_path_get_filename(p));
 | 
			
		||||
            namereg_fail = 0;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (!(u->source = pa_source_new(c, __FILE__, name, namereg_fail, &ss, &map)))
 | 
			
		||||
            goto fail;
 | 
			
		||||
 | 
			
		||||
        u->source->userdata = u;
 | 
			
		||||
| 
						 | 
				
			
			@ -450,8 +459,18 @@ int pa__init(pa_core *c, pa_module*m) {
 | 
			
		|||
    } else
 | 
			
		||||
        u->source = NULL;
 | 
			
		||||
 | 
			
		||||
    pa_xfree(name_buf);
 | 
			
		||||
    name_buf = NULL;
 | 
			
		||||
 | 
			
		||||
    if (mode != O_RDONLY) {
 | 
			
		||||
        if (!(u->sink = pa_sink_new(c, __FILE__, pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME), 0, &ss, &map)))
 | 
			
		||||
        if ((name = pa_modargs_get_value(ma, "sink_name", NULL)))
 | 
			
		||||
            namereg_fail = 1;
 | 
			
		||||
        else {
 | 
			
		||||
            name = name_buf = pa_sprintf_malloc("oss_output.%s", pa_path_get_filename(p));
 | 
			
		||||
            namereg_fail = 0;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (!(u->sink = pa_sink_new(c, __FILE__, name, namereg_fail, &ss, &map)))
 | 
			
		||||
            goto fail;
 | 
			
		||||
 | 
			
		||||
        u->sink->get_latency = sink_get_latency_cb;
 | 
			
		||||
| 
						 | 
				
			
			@ -469,6 +488,9 @@ int pa__init(pa_core *c, pa_module*m) {
 | 
			
		|||
    } else
 | 
			
		||||
        u->sink = NULL;
 | 
			
		||||
 | 
			
		||||
    pa_xfree(name_buf);
 | 
			
		||||
    name_buf = NULL;
 | 
			
		||||
    
 | 
			
		||||
    assert(u->source || u->sink);
 | 
			
		||||
 | 
			
		||||
    u->io = pa_iochannel_new(c->mainloop, u->source ? fd : -1, u->sink ? fd : -1);
 | 
			
		||||
| 
						 | 
				
			
			@ -516,6 +538,8 @@ fail:
 | 
			
		|||
 | 
			
		||||
    if (ma)
 | 
			
		||||
        pa_modargs_free(ma);
 | 
			
		||||
 | 
			
		||||
    pa_xfree(name_buf);
 | 
			
		||||
    
 | 
			
		||||
    return -1;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue