HEX
Server: Apache
System: Linux insrv.serversdaddy.com 5.14.0-362.24.2.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Mar 30 14:11:54 EDT 2024 x86_64
User: jsaha (1066)
PHP: 8.3.6
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3.9/site-packages/tuned/plugins/__pycache__/plugin_audio.cpython-39.opt-1.pyc
a

Y��d��@sfddlmZddlTddlZddlmZddlZddlZddl	Z	ej
��Ze�Z
Gdd�dej�ZdS)�)�hotplug)�*�N)�commandsc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zed
d��Z	dd
�Z
dd�Zeddd�dd��Z
ed�ddd��Zeddd�dd��Zed�ddd��ZdS) �AudioPlugina�
	`audio`::
	
	Sets audio cards power saving options. The plug-in sets the auto suspend
	timeout for audio codecs to the value specified by the [option]`timeout`
	option.
	+
	Currently, the `snd_hda_intel` and `snd_ac97_codec` codecs are
	supported and the [option]`timeout` value is in seconds. To disable
	auto suspend for these codecs, set the [option]`timeout` value
	to `0`. To enforce the controller reset, set the option
	[option]`reset_controller` to `true`. Note that power management
	is supported per module. Hence, the kernel module names are used as
	device names.
	+
	.Set the timeout value to 10s and enforce the controller reset
	====
	----
	[audio]
	timeout=10
	reset_controller=true
	----
	====
	cCsPd|_t�|_t�|_|j�d��d�D]"}|�|�}|dvr(|j�|�q(dS)NTZsoundzcard*)Z
snd_hda_intelZsnd_ac97_codec)	Z_devices_supported�setZ_assigned_devicesZ
_free_devicesZ_hardware_inventoryZget_devicesZmatch_sys_name�_device_module_name�add)�self�deviceZmodule_name�r�>/usr/lib/python3.9/site-packages/tuned/plugins/plugin_audio.py�
_init_devices's
zAudioPlugin._init_devicescCsd|_d|_dS)NTF)Z_has_static_tuningZ_has_dynamic_tuning�r
�instancerrr
�_instance_init1szAudioPlugin._instance_initcCsdS�Nrrrrr
�_instance_cleanup5szAudioPlugin._instance_cleanupcCsz
|jjWSYdS0dSr)�parentZdriver�r
rrrr
r8s
zAudioPlugin._device_module_namecCs
ddd�S)NrF)�timeout�reset_controllerr)�clsrrr
�_get_config_options>s�zAudioPlugin._get_config_optionscCsd|S)Nz$/sys/module/%s/parameters/power_saverrrrr
�
_timeout_pathEszAudioPlugin._timeout_pathcCsd|S)Nz//sys/module/%s/parameters/power_save_controllerrrrrr
�_reset_controller_pathHsz"AudioPlugin._reset_controller_pathrT)Z
per_devicecCsbzt|�}Wn"ty.t�d|�YdS0|dkrZ|�|�}|sVt�|d|�|SdSdS)Nz!timeout value '%s' is not integerrz%d)�int�
ValueError�log�errorr�cmd�
write_to_file)r
�valuer�simr�sys_filerrr
�_set_timeoutKs
zAudioPlugin._set_timeoutFcCs,|�|�}tj||d�}t|�dkr(|SdS)N)Zno_errorr)rr �	read_file�len�r
rZignore_missingr$r"rrr
�_get_timeoutZs

zAudioPlugin._get_timeoutrcCs8t�|�}|�|�}tj�|�r4|s0t�||�|SdSr)r �get_boolr�os�path�existsr!)r
r"rr#�vr$rrr
�_set_reset_controllerbs

z!AudioPlugin._set_reset_controllercCs:|�|�}tj�|�r6t�|�}t|�dkr6t�|�SdS)Nr)rr+r,r-r r&r'r*r(rrr
�_get_reset_controllerls


z!AudioPlugin._get_reset_controllerN)F)F)�__name__�
__module__�__qualname__�__doc__rrrr�classmethodrrrZcommand_setr%Zcommand_getr)r/r0rrrr
r
s"





	r)�rZ
decoratorsZ
tuned.logsZtunedZtuned.utils.commandsrr+�struct�globZlogs�getrr ZPluginrrrrr
�<module>s