mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	media-session: set node volume
This commit is contained in:
		
							parent
							
								
									f2e03077a8
								
							
						
					
					
						commit
						e59a7c0848
					
				
					 1 changed files with 19 additions and 1 deletions
				
			
		| 
						 | 
					@ -28,6 +28,7 @@
 | 
				
			||||||
#include <spa/node/node.h>
 | 
					#include <spa/node/node.h>
 | 
				
			||||||
#include <spa/utils/hook.h>
 | 
					#include <spa/utils/hook.h>
 | 
				
			||||||
#include <spa/param/audio/format-utils.h>
 | 
					#include <spa/param/audio/format-utils.h>
 | 
				
			||||||
 | 
					#include <spa/param/props.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "pipewire/core.h"
 | 
					#include "pipewire/core.h"
 | 
				
			||||||
#include "pipewire/control.h"
 | 
					#include "pipewire/control.h"
 | 
				
			||||||
| 
						 | 
					@ -809,6 +810,22 @@ static int link_nodes(struct node *peer, enum pw_direction direction, struct nod
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void stream_set_volume(struct impl *impl, struct node *node, float volume, bool mute)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						char buf[1024];
 | 
				
			||||||
 | 
						struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buf, sizeof(buf));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						pw_log_debug(NAME " %p: node %d set volume:%f mute:%d", impl, node->obj.id, volume, mute);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						pw_node_proxy_set_param((struct pw_node_proxy*)node->obj.proxy,
 | 
				
			||||||
 | 
								SPA_PARAM_Props, 0,
 | 
				
			||||||
 | 
								spa_pod_builder_object(&b,
 | 
				
			||||||
 | 
									SPA_TYPE_OBJECT_Props, SPA_PARAM_Props,
 | 
				
			||||||
 | 
									SPA_PROP_volume,	&SPA_POD_Float(volume),
 | 
				
			||||||
 | 
									SPA_PROP_mute,		&SPA_POD_Bool(mute),
 | 
				
			||||||
 | 
									0));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int rescan_node(struct impl *impl, struct node *node)
 | 
					static int rescan_node(struct impl *impl, struct node *node)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct spa_dict *props;
 | 
						struct spa_dict *props;
 | 
				
			||||||
| 
						 | 
					@ -966,9 +983,10 @@ static int rescan_node(struct impl *impl, struct node *node)
 | 
				
			||||||
			SPA_PARAM_PROFILE_format,    spa_format_audio_raw_build(&b,
 | 
								SPA_PARAM_PROFILE_format,    spa_format_audio_raw_build(&b,
 | 
				
			||||||
							SPA_PARAM_Format, &audio_info),
 | 
												SPA_PARAM_Format, &audio_info),
 | 
				
			||||||
			0);
 | 
								0);
 | 
				
			||||||
 | 
					 | 
				
			||||||
		pw_node_proxy_set_param((struct pw_node_proxy*)node->obj.proxy,
 | 
							pw_node_proxy_set_param((struct pw_node_proxy*)node->obj.proxy,
 | 
				
			||||||
				SPA_PARAM_Profile, 0, param);
 | 
									SPA_PARAM_Profile, 0, param);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							stream_set_volume(impl, node, 1.0, false);
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		audio_info.channels = 1;
 | 
							audio_info.channels = 1;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue