mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	device-manager: Expose the priority lists in the protocol extension.
Also leave space for 'icon' and 'available' details too, althought currently this info is dummy.
This commit is contained in:
		
							parent
							
								
									4dedba73a6
								
							
						
					
					
						commit
						8b2cc4def3
					
				
					 3 changed files with 86 additions and 38 deletions
				
			
		| 
						 | 
				
			
			@ -26,6 +26,7 @@
 | 
			
		|||
 | 
			
		||||
#include <pulse/context.h>
 | 
			
		||||
#include <pulse/gccmacro.h>
 | 
			
		||||
#include <pulse/xmalloc.h>
 | 
			
		||||
 | 
			
		||||
#include <pulsecore/macro.h>
 | 
			
		||||
#include <pulsecore/pstream-util.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -128,20 +129,48 @@ static void ext_device_manager_read_cb(pa_pdispatch *pd, uint32_t command, uint3
 | 
			
		|||
 | 
			
		||||
        while (!pa_tagstruct_eof(t)) {
 | 
			
		||||
            pa_ext_device_manager_info i;
 | 
			
		||||
            pa_bool_t available;
 | 
			
		||||
 | 
			
		||||
            memset(&i, 0, sizeof(i));
 | 
			
		||||
            available = FALSE;
 | 
			
		||||
 | 
			
		||||
            if (pa_tagstruct_gets(t, &i.name) < 0 ||
 | 
			
		||||
                pa_tagstruct_gets(t, &i.description) < 0) {
 | 
			
		||||
                pa_tagstruct_gets(t, &i.description) < 0 ||
 | 
			
		||||
                pa_tagstruct_gets(t, &i.icon) < 0 ||
 | 
			
		||||
                pa_tagstruct_get_boolean(t, &available) < 0 ||
 | 
			
		||||
                pa_tagstruct_getu32(t, &i.n_role_priorities) < 0) {
 | 
			
		||||
 | 
			
		||||
                pa_context_fail(o->context, PA_ERR_PROTOCOL);
 | 
			
		||||
                goto finish;
 | 
			
		||||
            }
 | 
			
		||||
            i.available = (uint8_t)available;
 | 
			
		||||
 | 
			
		||||
            if (i.n_role_priorities > 0) {
 | 
			
		||||
                uint32_t j;
 | 
			
		||||
                i.role_priorities = pa_xnew0(pa_ext_device_manager_role_priority_info, i.n_role_priorities+1);
 | 
			
		||||
 | 
			
		||||
                for (j = 0; j < i.n_role_priorities; j++) {
 | 
			
		||||
 | 
			
		||||
                    if (pa_tagstruct_gets(t, &i.role_priorities[j].role) < 0 ||
 | 
			
		||||
                        pa_tagstruct_getu32(t, &i.role_priorities[j].priority) < 0) {
 | 
			
		||||
 | 
			
		||||
                        pa_context_fail(o->context, PA_ERR_PROTOCOL);
 | 
			
		||||
                        pa_xfree(i.role_priorities);
 | 
			
		||||
                        goto finish;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                /* Terminate with an extra NULL entry, just to make sure */
 | 
			
		||||
                i.role_priorities[j].role = NULL;
 | 
			
		||||
                i.role_priorities[j].priority = 0;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (o->callback) {
 | 
			
		||||
                pa_ext_device_manager_read_cb_t cb = (pa_ext_device_manager_read_cb_t) o->callback;
 | 
			
		||||
                cb(o->context, &i, 0, o->userdata);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            pa_xfree(i.role_priorities);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,11 +33,20 @@
 | 
			
		|||
 | 
			
		||||
PA_C_DECL_BEGIN
 | 
			
		||||
 | 
			
		||||
typedef struct pa_ext_device_manager_role_priority_info {
 | 
			
		||||
    const char *role;
 | 
			
		||||
    uint32_t priority;
 | 
			
		||||
} pa_ext_device_manager_role_priority_info;
 | 
			
		||||
 | 
			
		||||
/** Stores information about one device in the device database that is
 | 
			
		||||
 * maintained by module-device-manager. \since 0.9.19 */
 | 
			
		||||
typedef struct pa_ext_device_manager_info {
 | 
			
		||||
    const char *name;            /**< Identifier string of the device. A string like "sink:" or similar followed by the name of the device. */
 | 
			
		||||
    const char *description;     /**< The description of the device when it was last seen, if applicable and saved */
 | 
			
		||||
    const char *icon;            /**< The icon given to the device */
 | 
			
		||||
    uint8_t available;           /**< Is the device currently available? */
 | 
			
		||||
    uint32_t n_role_priorities;  /**< How many role priorities do we have? */
 | 
			
		||||
    pa_ext_device_manager_role_priority_info *role_priorities; /**< An array of role priority structures or NULL */
 | 
			
		||||
} pa_ext_device_manager_info;
 | 
			
		||||
 | 
			
		||||
/** Callback prototype for pa_ext_device_manager_test(). \since 0.9.19 */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue