Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_ossaudiodev.cpython-39.pyc

a

��g�@s�ddlmZe�d�ddlmZe�d�ZddlZddlZddl	Z	ddl
Z
ddlZddlZzddlm
Z
Wn*ey�ejdkr�ejZ
nejZ
Yn0dd	�ZGd
d�dej�Zdd
�Zedkr�e��dS)�)�supportZaudio)�findfile�ossaudiodevN)�AFMT_S16_NE�littlecCs�t|d��B}t�|�}|��}|��}|j}|�d�|��}Wd�n1sR0Y|tjkrntd��t	�
|d�}||d|fS)N�rbrz)Expect .au file with 8-bit mu-law samples��)�open�sunauZgetframerateZgetnchannels�	_encoding�seek�readZAUDIO_FILE_ENCODING_MULAW_8�RuntimeError�audioopZulaw2lin)�path�fpZau�rate�	nchannels�encoding�data�r�1/usr/local/lib/python3.9/test/test_ossaudiodev.py�read_sound_files

&
rc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�OSSAudioDevTestsc

Cs�zt�d�}WnNty\}z6|jdtjtjtjtjfvrFt	�
|���WYd}~n
d}~00|��|��|�
�|��|��|�|j�|�|jd�|�|jdd|j�dD]:}zt||d�Wnttfy�Yq�0|�d|�q�tt|��|d||}|�t||�|�t|d	�d
k|�t� �}	|�!|�|�"�t� �}
|
|	}t||�|d}|�|dkd
||f�dS)N�wrz/dev/dspzbad dsp.mode: %r)�closed�name�mode�*zdsp.%s not read-only�g�G�z@g{�G�z�?�dg$@z2elapsed time (%s) > 10%% off of expected time (%s))#rr
�OSError�args�errno�EACCES�ENOENT�ENODEV�EBUSY�unittest�SkipTest�bufsize�	obufcount�obuffree�getptr�filenoZassertFalser�assertEqualrr�setattr�	TypeError�AttributeError�fail�float�len�
setparametersr�
assertTrue�abs�time�	monotonic�write�close)
�selfrrZssizer�dsp�msg�attrZ
expected_time�t1�t2Zelapsed_timeZpercent_diffrrr�play_sound_file,sH�


��z OSSAudioDevTests.play_sound_filec	Cs�tjddf}tddf}||fD]<}|\}}}|�|�|kr|�|�|kr|�|�|krqdqtd��|�|||d�}|�||||fd||f�|�|||d�}|�||||fd||f�dS)	N�i@r�D�zRunable to set audio sampling parameters: you must have really weird audio hardwareFzsetparameters%r: returned %rT)	rZAFMT_U8rZsetfmt�channelsZspeedrr7r0)	r>r?Zconfig1Zconfig2�config�fmtrGr�resultrrr�set_parameters[s&

��
�
�zOSSAudioDevTests.set_parameterscCs�t}d}d}|d|f|d|f||dffD]r}|\}}}|�|||d�}|�||d�z|�|||d�}Wn&tjy�}zWYd}~q(d}~00|�d	�q(dS)
NrFri,���i���Fz(unexpectedly got requested configurationTzexpected OSSAudioError)rr7ZassertNotEqualrZ
OSSAudioErrorr4)r>r?rIrrGrHrJ�errrrr�set_bad_parametersys"�
�z#OSSAudioDevTests.set_bad_parameterscCsttd��}|j|�dS)Nzaudiotest.au)rrrD)r>Z
sound_inforrr�
test_playback�szOSSAudioDevTests.test_playbackc	CsHt�d�}z"|�|�W|��|�|j�n|��|�|j�0dS�Nr)rr
rKr=r8r�r>r?rrr�test_set_parameters�s
�z$OSSAudioDevTests.test_set_parameterscCs<t��� }|�|��d�Wd�n1s.0YdS)Nr)r�	openmixerZassertGreaterEqualr/)r>�mixerrrr�test_mixer_methods�s
z#OSSAudioDevTests.test_mixer_methodscCs:t�d��}Wd�n1s 0Y|�|j�dSrP)rr
r8rrQrrr�	test_with�szOSSAudioDevTests.test_withcCs�t�d�}|��|�t|j�|�t|jd�|�t|jd�|�t|jd�|�t|j	�|�t|j
�|�t|j
�|�t|j�|�t|j�t�
�}|��|�t|j�dS)NrrE�x)rr
r=ZassertRaises�
ValueErrorr/rr<Zwriteallr+r,r-r.rS)r>r?rTrrr�test_on_closed�s
zOSSAudioDevTests.test_on_closedN)�__name__�
__module__�__qualname__rDrKrNrOrRrUrVrYrrrrr*s/rc
Cspzt�d�}WnTtjtfyb}z6|jdtjtjtjtj	fvrLt
�|���WYd}~n
d}~00|��dS)Nrr)
rr
�errorr"r#r$r%r&r'r(r)r*r=)r?r@rrr�setUpModule�s�
r^�__main__)�testrZrequiresZtest.supportr�
import_modulerr$�sysrr:rr)r�ImportError�	byteorderZAFMT_S16_LEZAFMT_S16_BErZTestCaserr^rZ�mainrrrr�<module>s*





Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists