soundd: change system sound mixer volume (#26633)
	
		
	
				
					
				
			* test changing sound volume * create system/hardware/pc/hardware.h * soundd: use Hardware::set_volume * implement Hardware::set_volume using pactl * Revert "test changing sound volume" This reverts commit 4bbd870746ec86d1c9871a6175def96cf7f751a6. * don't run command in background * pactl: use default sinkpull/214/head
							parent
							
								
									821d8ff12f
								
							
						
					
					
						commit
						02b5b6fe1f
					
				
				 6 changed files with 33 additions and 15 deletions
			
			
		| @ -0,0 +1,21 @@ | ||||
| #pragma once | ||||
| 
 | ||||
| #include "system/hardware/base.h" | ||||
| 
 | ||||
| class HardwarePC : public HardwareNone { | ||||
| public: | ||||
|   static std::string get_os_version() { return "openpilot for PC"; } | ||||
|   static std::string get_name() { return "pc"; }; | ||||
|   static cereal::InitData::DeviceType get_device_type() { return cereal::InitData::DeviceType::PC; }; | ||||
|   static bool PC() { return true; } | ||||
|   static bool TICI() { return util::getenv("TICI", 0) == 1; } | ||||
|   static bool AGNOS() { return util::getenv("TICI", 0) == 1; } | ||||
| 
 | ||||
|   static void set_volume(float volume) { | ||||
|     volume = util::map_val(volume, 0.f, 1.f, MIN_VOLUME, MAX_VOLUME); | ||||
| 
 | ||||
|     char volume_str[6]; | ||||
|     snprintf(volume_str, sizeof(volume_str), "%.3f", volume); | ||||
|     std::system(("pactl set-sink-volume @DEFAULT_SINK@ " + std::string(volume_str)).c_str()); | ||||
|   } | ||||
| }; | ||||
					Loading…
					
					
				
		Reference in new issue