Mini Shell

Direktori : /lib/python3.6/site-packages/orca/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/orca/__pycache__/sound.cpython-36.opt-1.pyc

3

�2[g�	@s�dZdZdZdZdZdZddlZddlmZyej	d	d
�ddlm
Z
WndaYnXe
jd�\aZ
d
dlmZd
dlmZmZGdd�d�Ze�Zdd�ZdS)zUtilities for playing sounds.z$Id:$z$Revision:$z$Date:$zCopyright (c) 2016 Orca TeamZLGPL�N)�GLib�Gstz1.0)rF�)�debug)�Icon�Tonec@sheZdZdZdd�Zdd�Zdd�Zdd	�Zddd�Zdd
d�Z	dd�Z
ddd�Zddd�Zdd�Z
dS)�PlayerzPlays Icons and Tones.cCs:d|_d|_d|_ts.d}tjtj|d�dS|j�dS)NFz'SOUND ERROR: Gstreamer is not availableT)�_initialized�_source�_sink�_gstreamerAvailabler�println�
LEVEL_INFO�init)�self�msg�r�/usr/lib/python3.6/sound.py�__init__-szPlayer.__init__cCsf|jtjjkr |jjtjj�nB|jtjjkrb|jjtjj�|j	�\}}d|}t
jt
j|d�dS)NzSOUND ERROR: %sT)
�typer�MessageType�EOS�_player�	set_state�State�NULL�ERROR�parse_errorrr
r)r�bus�message�error�inforrrr�_onPlayerMessage9szPlayer._onPlayerMessagecCsf|jtjjkr |jjtjj�nB|jtjjkrb|jjtjj�|j	�\}}d|}t
jt
j|d�dS)NzSOUND ERROR: %sT)
rrrr�	_pipelinerrrrrrr
r)rrrr r!rrrr�_onPipelineMessageBszPlayer._onPipelineMessagecCs|jtjj�dS)NF)rrrr)r�elementrrr�
_onTimeoutKszPlayer._onTimeoutTcCs<|r|jjtjj�|jjdd|j�|jjtjj�dS)zIPlays a sound icon, interrupting the current play first unless specified.Zuriz	file://%sN)rrrrr�set_property�path�PLAYING)rZicon�	interruptrrr�	_playIconOszPlayer._playIconcCsx|r|jjtjj�|jjd|j�|jjd|j�|jjd|j	�|jjtjj
�td|j�}t
j||j|j�dS)zCPlays a tone, interrupting the current play first unless specified.�volumeZfreq�wavei�N)r#rrrrr
r'r,Z	frequencyr-r)�int�durationrZtimeout_addr&)rZtoner*r/rrr�	_playToneXszPlayer._playTonecCs�|jr
dStsdStjjdd�|_|jj�}|j�|jd|j	�tj
dd�|_|jj�}|j�|jd|j�tjjdd�|_
tjjd	d
�|_|jj|j
�|jj|j�|j
j|j�d|_dS)z(Re)Initializes the Player.NZplaybinZplayerrz
orca-pipeline)�nameZaudiotestsrc�srcZ
autoaudiosink�outputT)r	rrZElementFactoryZmakerZget_busZadd_signal_watchZconnectr"ZPipeliner#r$r
r�add�link)rrrrrres$

zPlayer.initcCsLt|t�r|j||�n0t|t�r0|j||�nd|}tjtj|d�dS)zDPlays a sound, interrupting the current play first unless specified.z&SOUND ERROR: %s is not an Icon or ToneTN)�
isinstancerr+rr0rr
r)r�itemr*rrrr�play�s

zPlayer.playNcCsBtsdS|r|jtjj�dS|jjtjj�|jjtjj�dS)zStops play.N)rrrrrrr#)rr%rrr�stop�szPlayer.stopcCstsdS|j�d|_dadS)zShuts down the sound utilities.NF)rr9r	)rrrr�shutdown�s
zPlayer.shutdown)T)T)T)N)�__name__�
__module__�__qualname__�__doc__rr"r$r&r+r0rr8r9r:rrrrr*s		
	




rcCstS)N)rrrrr�	getPlayer�sr?)r>Z__id__�__version__Z__date__Z
__copyright__Z__license__ZgiZ
gi.repositoryrZrequire_versionrrZ
init_check�args�rZsound_generatorrrrrr?rrrr�<module>s$
y