mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	types: add function to convert audio channel short name to type
Move some functions around for this
This commit is contained in:
		
							parent
							
								
									b5cccdb382
								
							
						
					
					
						commit
						41f9abc733
					
				
					 5 changed files with 27 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -39,10 +39,7 @@ static inline const struct spa_type_info *spa_debug_type_find(const struct spa_t
 | 
			
		|||
 | 
			
		||||
static inline const char *spa_debug_type_short_name(const char *name)
 | 
			
		||||
{
 | 
			
		||||
	const char *h;
 | 
			
		||||
	if ((h = strrchr(name, ':')) != NULL)
 | 
			
		||||
		name = h + 1;
 | 
			
		||||
	return name;
 | 
			
		||||
	return spa_type_short_name(name);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline const char *spa_debug_type_find_name(const struct spa_type_info *info, uint32_t type)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,6 +15,7 @@ extern "C" {
 | 
			
		|||
 */
 | 
			
		||||
 | 
			
		||||
#include <spa/utils/type.h>
 | 
			
		||||
#include <spa/utils/string.h>
 | 
			
		||||
#include <spa/param/audio/raw.h>
 | 
			
		||||
 | 
			
		||||
#define SPA_TYPE_INFO_AudioFormat		SPA_TYPE_INFO_ENUM_BASE "AudioFormat"
 | 
			
		||||
| 
						 | 
				
			
			@ -247,6 +248,17 @@ static const struct spa_type_info spa_type_audio_channel[] = {
 | 
			
		|||
	{ 0, 0, NULL, NULL },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static inline uint32_t spa_type_audio_channel_from_short_name(const char *name)
 | 
			
		||||
{
 | 
			
		||||
	int i;
 | 
			
		||||
	for (i = 0; spa_type_audio_channel[i].name; i++) {
 | 
			
		||||
		if (spa_streq(name, spa_type_short_name(spa_type_audio_channel[i].name)))
 | 
			
		||||
			return spa_type_audio_channel[i].type;
 | 
			
		||||
	}
 | 
			
		||||
	return SPA_AUDIO_CHANNEL_UNKNOWN;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * \}
 | 
			
		||||
 */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,10 +20,6 @@ extern "C" {
 | 
			
		|||
#define SPA_TYPE_ROOT	spa_types
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
static inline bool spa_type_is_a(const char *type, const char *parent)
 | 
			
		||||
{
 | 
			
		||||
	return type != NULL && parent != NULL && strncmp(type, parent, strlen(parent)) == 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#include <spa/utils/type.h>
 | 
			
		||||
#include <spa/utils/enum-types.h>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -123,6 +123,19 @@ struct spa_type_info {
 | 
			
		|||
	const struct spa_type_info *values;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static inline bool spa_type_is_a(const char *type, const char *parent)
 | 
			
		||||
{
 | 
			
		||||
	return type != NULL && parent != NULL && strncmp(type, parent, strlen(parent)) == 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline const char *spa_type_short_name(const char *name)
 | 
			
		||||
{
 | 
			
		||||
	const char *h;
 | 
			
		||||
	if ((h = strrchr(name, ':')) != NULL)
 | 
			
		||||
		name = h + 1;
 | 
			
		||||
	return name;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * \}
 | 
			
		||||
 */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,7 +19,7 @@
 | 
			
		|||
 | 
			
		||||
#include <spa/param/audio/layout.h>
 | 
			
		||||
#include <spa/param/audio/format-utils.h>
 | 
			
		||||
#include <spa/param/audio/type-info.h>
 | 
			
		||||
#include <spa/utils/type-info.h>
 | 
			
		||||
#include <spa/param/tag-utils.h>
 | 
			
		||||
#include <spa/param/props.h>
 | 
			
		||||
#include <spa/utils/result.h>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue