Sindbad~EG File Manager
3
�<�e��@snddlmZddlTddlZddlmZddlZddlZddl Z ddl
Z
ejj�Z
e�ZGdd�dej�ZdS)�)�hotplug)�*�N)�commandsc@s�eZdZdZdd�Zdd�Zdd�Zdd �Zed
d��Z dd
�Z
dd�Zeddd�dd��Z
ed�ddd��Zeddd�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
----
====
cCsTd|_t�|_t�|_x8|jjd�jd�D]"}|j|�}|dkr*|jj|�q*WdS)NTZsoundzcard*�
snd_hda_intel�snd_ac97_codec)rr) Z_devices_supported�setZ_assigned_devicesZ
_free_devicesZ_hardware_inventoryZget_devicesZmatch_sys_name�_device_module_name�add)�self�deviceZmodule_name�r�"/usr/lib/python3.6/plugin_audio.py�
_init_devices(s
zAudioPlugin._init_devicescCsd|_d|_dS)NTF)Z_has_static_tuningZ_has_dynamic_tuning)r�instancerrr�_instance_init2szAudioPlugin._instance_initcCsdS)Nr)rrrrr�_instance_cleanup6szAudioPlugin._instance_cleanupc Csy|jjSdSdS)N)�parentZdriver)rr
rrrr
9szAudioPlugin._device_module_namecCs
ddd�S)NrF)�timeout�reset_controllerr)�clsrrr�_get_config_options?szAudioPlugin._get_config_optionscCsd|S)Nz$/sys/module/%s/parameters/power_saver)rr
rrr�
_timeout_pathFszAudioPlugin._timeout_pathcCsd|S)Nz//sys/module/%s/parameters/power_save_controllerr)rr
rrr�_reset_controller_pathIsz"AudioPlugin._reset_controller_pathrT)Z
per_devicec
Csryt|�}Wn"tk
r.tjd|�dSX|dkrj|j|�}|sftj|d||r^tjgndd�|SdSdS)Nz!timeout value '%s' is not integerrz%dF)�no_error) �int�
ValueError�log�errorr�cmd�
write_to_file�errno�ENOENT)r�valuer
�sim�remover�sys_filerrr�_set_timeoutLs
zAudioPlugin._set_timeoutFcCs,|j|�}tj||d�}t|�dkr(|SdS)N)rr)rr � read_file�len)rr
�ignore_missingr'r$rrr�_get_timeout\s
zAudioPlugin._get_timeoutrcCsHtj|�}|j|�}tjj|�rD|s@tj|||r8tjgndd�|SdS)NF)r) r �get_boolr�os�path�existsr!r"r#)rr$r
r%r&�vr'rrr�_set_reset_controllerds
z!AudioPlugin._set_reset_controllercCs:|j|�}tjj|�r6tj|�}t|�dkr6tj|�SdS)Nr)rr.r/r0r r)r*r-)rr
r+r'r$rrr�_get_reset_controlleros
z!AudioPlugin._get_reset_controllerN)F)F)�__name__�
__module__�__qualname__�__doc__rrrr
�classmethodrrrZcommand_setr(Zcommand_getr,r2r3rrrrrs
r)�rZ
decoratorsZ
tuned.logsZtunedZtuned.utils.commandsrr.r"�structZglobZlogs�getrr ZPluginrrrrr�<module>s
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists