HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //proc/thread-self/root/usr/local/lib/python3.7/test/__pycache__/test_ossaudiodev.cpython-37.pyc
B

��g:�@s�ddlmZe�d�ddlmZe�d�ZddlZddlZddl	Z	ddl
Z
ddlZddlZyddlm
Z
Wn,ek
r�ejdkr�ejZ
nejZ
YnXdd	�ZGd
d�dej�Zdd
�Zedkr�e�dS)�)�supportZaudio)�findfile�ossaudiodevN)�AFMT_S16_NE�littlec	Csrt|d��8}t�|�}|��}|��}|j}|�d�|��}WdQRX|tjkrZtd��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.7/test/test_ossaudiodev.py�read_sound_files


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

Cs�yt�d�}WnLtk
rZ}z.|jdtjtjtjtjfkrHt	�
|���Wdd}~XYnX|��|��|�
�|��|��|�|j�|�|jd�|�|jdd|j�xDdD]<}yt||d�Wnttfk
r�Yq�X|�d|�q�Wtt|��|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�timeZ	monotonic�write�close)
�selfrrZssizer�dsp�msg�attrZ
expected_timeZt1Zt2Zelapsed_timeZpercent_diffrrr�play_sound_file,sB



z OSSAudioDevTests.play_sound_filec	Cs�tjddf}tddf}xN||gD]:}|\}}}|�|�|kr |�|�|kr |�|�|kr Pq Wtd��|�|||d�}|�||||fd||f�|�|||d�}|�||||fd||f�dS)	N�i@riD�zRunable to set audio sampling parameters: you must have really weird audio hardwareFzsetparameters%r: returned %rT)	rZAFMT_U8rZsetfmt�channelsZspeedrr7r0)	r=r>Zconfig1Zconfig2�config�fmtrCr�resultrrr�set_parameters[s

zOSSAudioDevTests.set_parameterscCs�t}d}d}x�|d|f|d|f||dfgD]p}|\}}}|�|||d�}|�||d�y|�|||d�}Wn$tjk
r�}zWdd}~XYq*X|�d	�q*WdS)
NiD�ri,���i���Fz(unexpectedly got requested configurationTzexpected OSSAudioError)rr7ZassertNotEqualrZ
OSSAudioErrorr4)r=r>rErrCrDrF�errrrr�set_bad_parametersys

z#OSSAudioDevTests.set_bad_parameterscCsttd��}|j|�dS)Nzaudiotest.au)rrrA)r=Z
sound_inforrr�
test_playback�szOSSAudioDevTests.test_playbackc	Cs4t�d�}z|�|�Wd|��|�|j�XdS)Nr)rr
rGr<r8r)r=r>rrr�test_set_parameters�s

z$OSSAudioDevTests.test_set_parametersc	Cs(t���}|�|��d�WdQRXdS)Nr)r�	openmixerZassertGreaterEqualr/)r=�mixerrrr�test_mixer_methods�s
z#OSSAudioDevTests.test_mixer_methodsc	Cs&t�d��}WdQRX|�|j�dS)Nr)rr
r8r)r=r>rrr�	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)NrrB�x)rr
r<ZassertRaises�
ValueErrorr/rr;Zwriteallr+r,r-r.rM)r=r>rNrrr�test_on_closed�s
zOSSAudioDevTests.test_on_closedN)�__name__�
__module__�__qualname__rArGrJrKrLrOrPrSrrrrr*s/rc
Csxyt�d�}WnRtjtfk
r`}z.|jdtjtjtjtj	fkrNt
�|���Wdd}~XYnX|��t
�t�dS)Nrr)rr
�errorr"r#r$r%r&r'r(r)r*r<rZrun_unittestrT)r>r?rrr�	test_main�s
rX�__main__)ZtestrZrequiresZtest.supportr�
import_modulerr$�sysrr:rr)r�ImportError�	byteorderZAFMT_S16_LEZAFMT_S16_BErZTestCaserrXrTrrrr�<module>s*