
    ^j#              
          U d Z ddlmZmZmZmZmZmZmZm	Z	m
Z
mZmZmZ ddlmZ ddlmZ  ej        d          ZedZ ej        e          Z G d d	e          Z G d
 de          Z G d de          Z G d de          ZdZeZeZeZeej        _        eegej        _         eej!        _        ee ee          egej!        _         eej"        _        eeeegej"        _         eej        _        eegej        _         eZ#eZ$ eeeeee ee                    Z% eee          Z&eej'        _        ee%ee&ee# ee$          gej'        _         eej(        _        e$e ee          gej(        _         eej)        _        e ee           ee          gej)        _         eej*        _        eegej*        _         eej+        _        egej+        _         eej,        _        e$gej,        _         de-de.fdZ/ e/d          Z0 e/d          Z1 e/d          Z2 e/d          Z3 e/d          Z4dZ5dZ6dZ7dZ8dZ9e5e9z  e8z  Z: e/d          Z;dZ<dZ=dZ>d Z?d!Z@d"ZAd#ZBdZC e/d$          ZD e/d%          ZE e/d&          ZF e/d'          ZG e/d(          ZH e/d)          ZI e/d*          ZJ e/d+          ZK e/d,          ZL e/d-          ZM e/d.          ZN e/d/          ZOi e@d0eAd1eBd2eCd3eDd4eEd5eFd6eGd7eHd8eId9eJd:eKd;eLd<eMd=eNd>eOd?ZPeeQe.e-f                  eRd@<    G dA dBeS          ZTdCe.ddfdDZUdS )EaY  Bindings, constants, and helpers for Mac's CoreAudio

Relevant Apple documentation is located at:

* https://developer.apple.com/documentation/audiotoolbox/
* https://developer.apple.com/documentation/coreaudio

This module includes:

* ctypes structs and function bindings
* Constants for audio file read and decoding
* Error checking helpers

    )c_void_pc_intc_bool	Structurec_uint32utilcdllc_uintc_doublePOINTERc_int64	CFUNCTYPE)Final)CFURLRef	CoreAudioNz8/System/Library/Frameworks/CoreAudio.framework/CoreAudioc                   $    e Zd ZdefdefdefgZdS )AudioStreamPacketDescriptionmStartOffsetmVariableFramesInPacketmDataByteSizeN)__name__
__module____qualname__r   r   _fields_     W/home/agentuser/manim-venv/lib/python3.11/site-packages/pyglet/libs/darwin/coreaudio.pyr   r      s-        	!	"H-	(#HHHr   r   c            
       N    e Zd Zdefdefdefdefdefdefdefdefd	efg	Zd
 ZdS )AudioStreamBasicDescriptionmSampleRate	mFormatIDmFormatFlagsmBytesPerPacketmFramesPerPacketmBytesPerFramemChannelsPerFramemBitsPerChannel	mReservedc                 x    d| j          d| j         d| j         d| j         d| j         d| j         d| j         dS )	Nz(AudioStreamBasicDescription(sample_rate=z, channels=z, fmt=z, bytes_per_packet=z, bits=z, frames_per_packet=z, bytes_per_frame=))r    r&   r!   r#   r'   r$   r%   )selfs    r   __repr__z$AudioStreamBasicDescription.__repr__2   s    d$:J d dW[Wm d dnd d9=9Md dVZVjd d$($9d dMQM`d d d 	dr   N)r   r   r   r   r   r   r,   r   r   r   r   r   %   sw        	!	h	"	H%	X&	8$	h'	H%	h
Hd d d d dr   r   c                   $    e Zd ZdefdefdefgZdS )AudioBuffermNumberChannelsr   mDataN)r   r   r   r
   r   r   r   r   r   r.   r.   8   s-        	F#	&!	(HHHr   r.   c                   $    e Zd Zdefdedz  fgZdS )AudioBufferListmNumberBuffersmBuffers   N)r   r   r   r
   r.   r   r   r   r   r2   r2   @   s)        	6"	[1_%HHHr   r2   mnemonicreturnc                     d}t          |           D ]0\  }}|t          |          t          |           |z
  dz
  dz  z  z  }1|S )a  Pack a tiny ASCII string into a 32-bit int.

    Example: 'xyz' -> 0x78797a (Base 10: 7895418)

    Although many CoreAudio constants use this function, the only
    consistent rule seems to be a max of 4 ASCII characters to fit
    into a 32-bit int.

    Otherwise, error code constants may follow a loose convention:

    * '?' at the start error codes for unsupported actions
      Example: c_literal('?wht') # as in "what?"

    * '!' at the end of error codes for unintelligible data
      Example: c_literal('?siz') # "this data is the wrong size!"

    Args:
        mnemonic:
            Up to 4 ASCII characters to shift left
    Returns:
        A 32-bit int equivalent of the string.
    r   r5      )	enumerateordlen)r6   numidxchars       r   	c_literalr@   s   sU    . Cx(( : :	Ts4yyS]]S014999Jr   mgicffmtcfmtz#frmlpcmr5         r9   aqmciiiiiizwht?ztyp?zfmt?zpty?z!sizzprm?optmzchk?zoff?zpck?zdta?zop?zThe file is closed.zEnd of file.zInvalid file position.zFile not found.z"An unspecified error has occurred.zThe file type is not supported.z3The data format is not supported by this file type.zThe property is not supported.z.The size of the property data was not correct.z,The operation violated the file permissions.zThe chunks following the audio data chunk are preventing the extension of the audio data chunk. To write more data, you must optimize the file.zOEither the chunk does not exist in the file or it is not supported by the file.zrThe file offset was too large for the file type. The AIFF and WAVE file format types have 32-bit file size limits.zA packet offset was past the end of the file, or not at the end of the file when a VBR format was written, or a corrupt packet size was read when the packet table was built.zVThe file is malformed, or otherwise not a valid instance of an audio file of its type.z"The operation cannot be performed.
err_str_dbc                       e Zd ZdZdS )CoreAudioExceptiona8  A stub to mark a problem as a CoreAudio issue.

    Ideally, there would be appropriate subclasses of typical
    Python exceptions for specific issues, For example:

    * kAudio_FileNotFoundError -> OSError (The typical Python file read error
    * kAudioFileInvalidChunkError -> ValueError (Invalid data)
    N)r   r   r   __doc__r   r   r   rL   rL      s          Cr   rL   errc                 d    | dk    r)t          | t                              | d                    dS )zlRaise an exception of somethings wrong, otherwise return None.

    Raises:
         CoreAudioException
    r   zUnknown ErrorN)rL   rJ   get)rN   s    r   	err_checkrQ      s2     axx jnnS/&J&JKKK xr   )VrM   ctypesr   r   r   r   r   r   r	   r
   r   r   r   r   typingr   pyglet.libs.darwinr   find_librarylibLoadLibrarycar   r   r.   r2   kCFURLPOSIXPathStyleExtAudioFilePropertyIDOSStatusExtAudioFileRefExtAudioFileOpenURLrestypeargtypesExtAudioFileGetPropertyExtAudioFileSetPropertyAudioFileTypeIDAudioFileIDAudioFile_ReadProcAudioFile_GetSizeProcAudioFileOpenWithCallbacksExtAudioFileWrapAudioFileIDExtAudioFileReadExtAudioFileSeekExtAudioFileDisposeAudioFileClosestrintr@   !kAudioFilePropertyMagicCookieData$kExtAudioFileProperty_FileDataFormat&kExtAudioFileProperty_ClientDataFormat&kExtAudioFileProperty_FileLengthFrameskAudioFormatLinearPCMkAudioFormatFlagIsFloatkAudioFormatFlagIsBigEndiankAudioFormatFlagIsSignedIntegerkAudioFormatFlagIsPackedkAudioFormatFlagsNativeEndiankAudioFormatFlagsCanonicalkAudioQueueProperty_MagicCookiekAudio_UnimplementedErrorkAudio_FileNotFoundErrorkAudio_ParamErrorkAudio_MemFullErrorkAudioFileNotOpenErrorkAudioFileEndOfFileErrorkAudioFilePositionErrorkAudioFileFileNotFoundErrorkAudioFileUnspecifiedError"kAudioFileUnsupportedFileTypeError$kAudioFileUnsupportedDataFormatError"kAudioFileUnsupportedPropertyErrorkAudioFileBadPropertySizeErrorkAudioFilePermissionsErrorkAudioFileNotOptimizedErrorkAudioFileInvalidChunkError(kAudioFileDoesNotAllow64BitDataSizeError"kAudioFileInvalidPacketOffsetErrorkAudioFileInvalidFileError$kAudioFileOperationNotSupportedErrorrJ   dict__annotations__	ExceptionrL   rQ   r   r   r   <module>r      s`                                      ' ' ' ' ' 'd$$;
DCTc    9   d d d d d) d d d&    )       i     ! !&  #+_"=  %*  "'68NPWPWX`PaPack&l  #%*  "'68NPXZb&c  #!)  #+_"=  Yuh8WWU]M^M^__ !	'844 (0  %*24FRgiq*977;;O;O*Q  & *2  &+6@X@X*Y  '&   /1B1BGGOD\D\]  &   /9  !)  #2"3  $  )]       < %.If$5$5 !'0y'8'8 $)26):): &)26):): &!	&))   $ "( !  ! 47TTWoo "+)F"3"3          !  'Yv.. %.Yv%6%6 "'0y'8'8 $%.Yv%6%6 "!*6!2!2 &Yv.. 'i//  (i// +49V+<+< (%.Yv%6%6 "&Yv.. '0y'7'7 $%1%n% 5%  !2	%
  D% '(I% )*_% '(H% #$T%  N%    "s%  !r% -  /c% '  )X%  x%  )*N!%
E$sCx.!   (	 	 	 	 	 	 	 	L3 L4 L L L L L Lr   