ó
‹wÛjc           @   sÏ   d  d l  m Z e j d ƒ d  d l m Z m Z d  d l Z d  d l Z d  d l Z d  d l	 Z	 e j
 d d e ƒZ e j
 d d e ƒZ d Z d	 e	 j f d
 „  ƒ  YZ d „  Z e d k rË e ƒ  n  d S(   iÿÿÿÿ(   t   test_supportt   audio(   t   findfilet   run_unittestNt   linuxaudiodevt
   deprecatedt   sunaudioi   t   LinuxAudioDevTestsc           B   s5   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s   t  j d ƒ |  _ d  S(   Nt   w(   R   t   opent   dev(   t   self(    (    s�   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_linuxaudiodev.pyt   setUp   s    c         C   s   |  j  j ƒ  d  S(   N(   R
   t   close(   R   (    (    s�   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_linuxaudiodev.pyt   tearDown   s    c         C   sE   |  j  j ƒ  |  j  j ƒ  |  j  j ƒ  |  j  j ƒ  |  j  j ƒ  d  S(   N(   R
   t   bufsizet	   obufcountt   obuffreet   getptrt   fileno(   R   (    (    s�   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_linuxaudiodev.pyt   test_methods   s
    c   
      C   sÛ   t  d ƒ } t | d ƒ } t j | ƒ \ } } } } } | j ƒ  } | j ƒ  | t k rk |  j d ƒ n  t j	 | d ƒ } t
 j d k r˜ t j }	 n	 t j }	 |  j j | d | |	 ƒ |  j j | ƒ |  j j ƒ  d  S(   Ns   audiotest.aut   rs)   Expect .au file with 8-bit mu-law samplesi   t   littlei   (   R   R	   R   t   gethdrt   readR   t   SND_FORMAT_MULAW_8t   failt   audioopt   ulaw2lint   syst	   byteorderR   t   AFMT_S16_LEt   AFMT_S16_BER
   t   setparameterst   writet   flush(
   R   t   patht   fpt   sizet   enct   ratet	   nchannelst   extrat   datat   fmt(    (    s�   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_linuxaudiodev.pyt   test_play_sound_file    s    
	c         C   sŞ  d } t  j } d } d } y |  j j d | | | ƒ Wn* t k
 rd } |  j | j d d ƒ n Xy |  j j | d | | ƒ Wn* t k
 r® } |  j | j d d ƒ n Xy |  j j | | d	 | ƒ Wn* t k
 rø } |  j | j d d
 ƒ n Xy |  j j | | | d ƒ Wn* t k
 rB} |  j | j d d ƒ n Xy  |  j j | | | t  j ƒ Wn* t k
 r�} |  j | j d d ƒ n Xy |  j j | d | | ƒ Wn* t k
 rÙ} |  j | j d d ƒ n Xd  S(   Ni   i@  i   iÿÿÿÿi    s   expected rate >= 0, not -1işÿÿÿs!   expected sample size >= 0, not -2i   s   nchannels must be 1 or 2, not 3i±   s   unknown audio encoding: 177sN   for linear unsigned 16-bit little-endian audio, expected sample size 16, not 8i   s?   for linear unsigned 8-bit audio, expected sample size 8, not 16(   R   t   AFMT_U8R
   R!   t
   ValueErrort   assertEqualt   argst   AFMT_U16_LE(   R   R&   R,   R(   R)   t   err(    (    s�   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_linuxaudiodev.pyt   test_errors8   s8    	 (   t   __name__t
   __module__R   R   R   R-   R4   (    (    (    s�   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_linuxaudiodev.pyR      s
   				c          C   s„   y t  j d ƒ }  WnV t  j k
 rk } | j d t j t j t j t j f k re t	 j
 | ƒ ‚ n  ‚  n X|  j ƒ  t t ƒ d  S(   NR   i    (   R   R	   t   errorR1   t   errnot   EACCESt   ENOENTt   ENODEVt   EBUSYt   unittestt   SkipTestR   R   R   (   t   dspt   msg(    (    s�   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_linuxaudiodev.pyt	   test_mainX   s    +
t   __main__(   t   testR    t   requirest   test.test_supportR   R   R8   R   R   R=   t   import_modulet   TrueR   R   R   t   TestCaseR   RA   R5   (    (    (    s�   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_linuxaudiodev.pyt   <module>   s   H	
