Current File : //opt/imh-python/lib/python2.7/test/test_ossaudiodev.pyc
�
��Wc@sddlmZejd�ddlmZejd�ZddlZddlZddl	Z	ddl
Z
ddlZddlZyddlm
Z
Wn5ek
r�ejdkr�ejZ
q�ejZ
nXd�Zd	ejfd
��YZd�Zedkre�ndS(
i����(ttest_supporttaudio(tfindfiletossaudiodevN(tAFMT_S16_NEtlittlecCs�t|d��P}tj|�}|j�}|j�}|j}|jd�|j�}WdQX|tjkrtd��nt	j
|d�}||d|fS(Ntrbis)Expect .au file with 8-bit mu-law samplesii(topentsunautgetframeratetgetnchannelst	_encodingtseektreadtAUDIO_FILE_ENCODING_MULAW_8tRuntimeErrortaudiooptulaw2lin(tpathtfptautratet	nchannelstencodingtdata((sn/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_ossaudiodev.pytread_sound_files	
tOSSAudioDevTestscBs5eZd�Zd�Zd�Zd�Zd�ZRS(c
Cs�ytjd�}WnStk
rh}|jdtjtjtjtjfkrbt	j
|��n�nX|j�|j�|j
�|j�|j�|j|j�|j|jd�|j|jdd|j�xGdD]?}yt||d�Wntk
rq�X|jd	|�q�Wtt|��|d
||}|jt||�|jt|d�dk|�tj�}	|j|�|j �tj�}
|
|	}t||�|d
}|j|dkd�dS(Ntwis/dev/dspsbad dsp.mode: %rtclosedtnametmodei*sdsp.%s not read-onlyig�G�z@g{�G�z�?idg$@s'elapsed time > 10% off of expected time(sclosedsnamesmode(!RRtIOErrortargsterrnotEACCEStENOENTtENODEVtEBUSYtunittesttSkipTesttbufsizet	obufcounttobuffreetgetptrtfilenotassertFalseRtassertEqualRRtsetattrt	TypeErrortfailtfloattlent
setparametersRt
assertTruetabsttimetwritetclose(
tselfRRtssizeRtdsptmsgtattrt
expected_timett1tt2telapsed_timetpercent_diff((sn/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_ossaudiodev.pytplay_sound_file,s@






" 


c	Cstjddf}tddf}xr||gD]X}|\}}}|j|�|kr.|j|�|kr.|j|�|kr.Pq.q.Wtd��|j|||t�}|j	||||fd||f�|j|||t
�}|j	||||fd||f�dS(Nii@iiD�sRunable to set audio sampling parameters: you must have really weird audio hardwaressetparameters%r: returned %r(RtAFMT_U8RtsetfmttchannelstspeedRR4tFalseR.tTrue(	R:R<tconfig1tconfig2tconfigtfmtRGRtresult((sn/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_ossaudiodev.pytset_parametersZscCs�t}d}d}x�|d|f|d|f||dfgD]�}|\}}}|j|||t�}|j||d�y|j|||t�}Wntjk
r�}q=X|jd�q=WdS(NiD�ii,i����i���s(unexpectedly got requested configurationsexpected OSSAudioError(RR4RItassertNotEqualRJRt
OSSAudioErrorR1(R:R<RNRRGRMROterr((sn/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_ossaudiodev.pytset_bad_parametersxscCs#ttd��}|j|�dS(Nsaudiotest.au(RRRD(R:t
sound_info((sn/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_ossaudiodev.pyt
test_playback�scCsBtjd�}z|j|�Wd|j�|j|j�XdS(NR(RRRPR9R5R(R:R<((sn/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_ossaudiodev.pyttest_set_parameters�s

(t__name__t
__module__RDRPRTRVRW(((sn/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_ossaudiodev.pyR*s
	.			cCs�ytjd�}Wn\tjtfk
rq}|jdtjtjtjtj	fkrkt
j|��n�nX|j�t
jt�dS(NRi(RRterrorRR R!R"R#R$R%R&R'R9Rtrun_unittestRX(R<R=((sn/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_ossaudiodev.pyt	test_main�s
t__main__(ttestRtrequiresttest.test_supportRt
import_moduleRR!tsysRR7RR&RtImportErrort	byteordertAFMT_S16_LEtAFMT_S16_BERtTestCaseRR\RX(((sn/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_ossaudiodev.pyt<module>s(


	x