Class WASAPI


  • public class WASAPI
    extends Object
    Defines the native interface to Windows Audio Session API (WASAPI) and related Core Audio APIs such as Multimedia Device (MMDevice) API as used by WASAPISystem and its associated CaptureDevice, DataSource and Renderer implementations.
    Author:
    Lyubomir Marinov
    • Method Detail

      • CoTaskMemFree

        public static void CoTaskMemFree​(long pv)
      • CoUninitialize

        public static void CoUninitialize()
      • FAILED

        public static boolean FAILED​(int hresult)
        Determines whether a specific HRESULT value indicates failure.
        Parameters:
        hresult - the HRESULT value to be checked whether it indicates failure
        Returns:
        true if the specified hresult indicates failure; otherwise, false
      • IAudioCaptureClient_GetNextPacketSize

        public static int IAudioCaptureClient_GetNextPacketSize​(long thiz)
                                                         throws HResultException
        Throws:
        HResultException
      • IAudioCaptureClient_Read

        public static int IAudioCaptureClient_Read​(long thiz,
                                                   byte[] data,
                                                   int offset,
                                                   int length,
                                                   int srcSampleSize,
                                                   int srcChannels,
                                                   int dstSampleSize,
                                                   int dstChannels)
                                            throws HResultException
        Throws:
        HResultException
      • IAudioCaptureClient_Release

        public static void IAudioCaptureClient_Release​(long thiz)
      • IAudioClient_Initialize

        public static int IAudioClient_Initialize​(long thiz,
                                                  int shareMode,
                                                  int streamFlags,
                                                  long hnsBufferDuration,
                                                  long hnsPeriodicity,
                                                  long pFormat,
                                                  String audioSessionGuid)
                                           throws HResultException
        Throws:
        HResultException
      • IAudioClient_IsFormatSupported

        public static long IAudioClient_IsFormatSupported​(long thiz,
                                                          int shareMode,
                                                          long pFormat)
                                                   throws HResultException
        Throws:
        HResultException
      • IAudioClient_Release

        public static void IAudioClient_Release​(long thiz)
      • IAudioClient_SetEventHandle

        public static void IAudioClient_SetEventHandle​(long thiz,
                                                       long eventHandle)
                                                throws HResultException
        Throws:
        HResultException
      • IAudioRenderClient_Release

        public static void IAudioRenderClient_Release​(long thiz)
      • IAudioRenderClient_Write

        public static int IAudioRenderClient_Write​(long thiz,
                                                   byte[] data,
                                                   int offset,
                                                   int length,
                                                   int srcSampleSize,
                                                   int srcChannels,
                                                   int dstSampleSize,
                                                   int dstChannels)
                                            throws HResultException
        Writes specific audio data into the rendering endpoint buffer of a specific IAudioRenderClient. If the sample sizes and/or the numbers of channels of the specified audio data and the specified rendering endpoint buffer differ, the method may be able to perform the necessary conversions.
        Parameters:
        thiz - the IAudioRenderClient which abstracts the rendering endpoint buffer into which the specified audio data is to be written
        data - the bytes of the audio samples to be written into the specified rendering endpoint buffer
        offset - the offset in bytes within data at which valid audio samples begin
        length - the number of bytes of valid audio samples in data
        srcSampleSize - the size in bytes of an audio sample in data
        srcChannels - the number of channels of the audio signal provided in data
        dstSampleSize - the size in bytes of an audio sample in the rendering endpoint buffer
        dstChannels - the number of channels with which the rendering endpoint buffer has been initialized
        Returns:
        the number of bytes which have been read from data (beginning at offset, of course) and successfully written into the rendering endpoint buffer
        Throws:
        HResultException - if an HRESULT value indicating an error is returned by a function invoked by the method implementation or an I/O error is encountered during the execution of the method
      • IMMDevice_Release

        public static void IMMDevice_Release​(long thiz)
      • IMMDeviceCollection_Release

        public static void IMMDeviceCollection_Release​(long thiz)
      • IMMDeviceEnumerator_EnumAudioEndpoints

        public static long IMMDeviceEnumerator_EnumAudioEndpoints​(long thiz,
                                                                  int dataFlow,
                                                                  int dwStateMask)
                                                           throws HResultException
        Throws:
        HResultException
      • IMMDeviceEnumerator_Release

        public static void IMMDeviceEnumerator_Release​(long thiz)
      • IMMEndpoint_Release

        public static void IMMEndpoint_Release​(long thiz)
      • IPropertyStore_Release

        public static void IPropertyStore_Release​(long thiz)
      • SUCCEEDED

        public static boolean SUCCEEDED​(int hresult)
        Determines whether a specific HRESULT value indicates success.
        Parameters:
        hresult - the HRESULT value to be checked whether it indicates success
        Returns:
        true if the specified hresult indicates success; otherwise, false
      • WaitForSingleObject

        public static int WaitForSingleObject​(long hHandle,
                                              long dwMilliseconds)
                                       throws HResultException
        Waits until the specified object is in the signaled state or the specified time-out interval elapses.
        Parameters:
        hHandle - a HANDLE to the object to wait for
        dwMilliseconds - the time-out interval in milliseconds to wait. If a nonzero value is specified, the function waits until the specified object is signaled or the specified time-out interval elapses. If dwMilliseconds is zero, the function does not enter a wait state if the specified object is not signaled; it always returns immediately. If dwMilliseconds is INFINITE, the function will return only when the specified object is signaled.
        Returns:
        one of the WAIT_XXX constant values defined by the WASAPI class to indicate the event that caused the function to return
        Throws:
        HResultException - if the return value is WAIT_FAILED
      • WAVEFORMATEX_alloc

        public static long WAVEFORMATEX_alloc()
      • WAVEFORMATEX_fill

        public static void WAVEFORMATEX_fill​(long thiz,
                                             char wFormatTag,
                                             char nChannels,
                                             int nSamplesPerSec,
                                             int nAvgBytesPerSec,
                                             char nBlockAlign,
                                             char wBitsPerSample,
                                             char cbSize)
      • WAVEFORMATEX_getCbSize

        public static char WAVEFORMATEX_getCbSize​(long thiz)
      • WAVEFORMATEX_getNAvgBytesPerSec

        public static int WAVEFORMATEX_getNAvgBytesPerSec​(long thiz)
      • WAVEFORMATEX_getNBlockAlign

        public static char WAVEFORMATEX_getNBlockAlign​(long thiz)
      • WAVEFORMATEX_getNChannels

        public static char WAVEFORMATEX_getNChannels​(long thiz)
      • WAVEFORMATEX_getNSamplesPerSec

        public static int WAVEFORMATEX_getNSamplesPerSec​(long thiz)
      • WAVEFORMATEX_getWBitsPerSample

        public static char WAVEFORMATEX_getWBitsPerSample​(long thiz)
      • WAVEFORMATEX_getWFormatTag

        public static char WAVEFORMATEX_getWFormatTag​(long thiz)
      • WAVEFORMATEX_setCbSize

        public static void WAVEFORMATEX_setCbSize​(long thiz,
                                                  char cbSize)
      • WAVEFORMATEX_setNAvgBytesPerSec

        public static void WAVEFORMATEX_setNAvgBytesPerSec​(long thiz,
                                                           int nAvgBytesPerSec)
      • WAVEFORMATEX_setNBlockAlign

        public static void WAVEFORMATEX_setNBlockAlign​(long thiz,
                                                       char nBlockAlign)
      • WAVEFORMATEX_setNChannels

        public static void WAVEFORMATEX_setNChannels​(long thiz,
                                                     char nChannels)
      • WAVEFORMATEX_setNSamplesPerSec

        public static void WAVEFORMATEX_setNSamplesPerSec​(long thiz,
                                                          int nSamplesPerSec)
      • WAVEFORMATEX_setWBitsPerSample

        public static void WAVEFORMATEX_setWBitsPerSample​(long thiz,
                                                          char wBitsPerSample)
      • WAVEFORMATEX_setWFormatTag

        public static void WAVEFORMATEX_setWFormatTag​(long thiz,
                                                      char wFormatTag)
      • WAVEFORMATEX_sizeof

        public static int WAVEFORMATEX_sizeof()