mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	add support for parsing channel maps as module arguments
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@802 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
		
							parent
							
								
									292b237e35
								
							
						
					
					
						commit
						fbb0d1436c
					
				
					 2 changed files with 58 additions and 0 deletions
				
			
		| 
						 | 
					@ -259,3 +259,50 @@ int pa_modargs_get_sample_spec(pa_modargs *ma, pa_sample_spec *rss) {
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int pa_modargs_get_channel_map(pa_modargs *ma, pa_channel_map *rmap) {
 | 
				
			||||||
 | 
					    pa_channel_map map;
 | 
				
			||||||
 | 
					    const char *cm;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    assert(ma);
 | 
				
			||||||
 | 
					    assert(rmap);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    map = *rmap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if ((cm = pa_modargs_get_value(ma, "channel_map", NULL)))
 | 
				
			||||||
 | 
					        if (!pa_channel_map_parse(&map, cm))
 | 
				
			||||||
 | 
					            return -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!pa_channel_map_valid(&map))
 | 
				
			||||||
 | 
					        return -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    *rmap = map;
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int pa_modargs_get_sample_spec_and_channel_map(pa_modargs *ma, pa_sample_spec *rss, pa_channel_map *rmap) {
 | 
				
			||||||
 | 
					    pa_sample_spec ss;
 | 
				
			||||||
 | 
					    pa_channel_map map;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    assert(ma);
 | 
				
			||||||
 | 
					    assert(rss);
 | 
				
			||||||
 | 
					    assert(rmap);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ss = *rss;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (pa_modargs_get_sample_spec(ma, &ss) < 0)
 | 
				
			||||||
 | 
					        return -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_channel_map_init_auto(&map, ss.channels);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (pa_modargs_get_channel_map(ma, &map) < 0)
 | 
				
			||||||
 | 
					        return -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (map.channels != ss.channels)
 | 
				
			||||||
 | 
					        return -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    *rmap = map;
 | 
				
			||||||
 | 
					    *rss = ss;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,6 +24,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <inttypes.h>
 | 
					#include <inttypes.h>
 | 
				
			||||||
#include <polyp/sample.h>
 | 
					#include <polyp/sample.h>
 | 
				
			||||||
 | 
					#include <polyp/channelmap.h>
 | 
				
			||||||
#include <polypcore/core.h>
 | 
					#include <polypcore/core.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct pa_modargs pa_modargs;
 | 
					typedef struct pa_modargs pa_modargs;
 | 
				
			||||||
| 
						 | 
					@ -46,4 +47,14 @@ int pa_modargs_get_value_boolean(pa_modargs *ma, const char *key, int *value);
 | 
				
			||||||
/* Return sample spec data from the three arguments "rate", "format" and "channels" */
 | 
					/* Return sample spec data from the three arguments "rate", "format" and "channels" */
 | 
				
			||||||
int pa_modargs_get_sample_spec(pa_modargs *ma, pa_sample_spec *ss);
 | 
					int pa_modargs_get_sample_spec(pa_modargs *ma, pa_sample_spec *ss);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Return channel map data from the argument "channel_map" */
 | 
				
			||||||
 | 
					int pa_modargs_get_channel_map(pa_modargs *ma, pa_channel_map *map);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Combination of pa_modargs_get_sample_spec() and
 | 
				
			||||||
 | 
					pa_modargs_get_channel_map(). Not always suitable, since this routine
 | 
				
			||||||
 | 
					initializes the map parameter based on the channels field of the ss
 | 
				
			||||||
 | 
					structure if no channel_map is found, using pa_channel_map_init_auto() */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int pa_modargs_get_sample_spec_and_channel_map(pa_modargs *ma, pa_sample_spec *ss, pa_channel_map *map);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue