]> Repos - portaudio/commitdiff
wasapi:
authordmitrykos <dmitrykos@0f58301d-fd10-0410-b4af-bbb618454e57>
Fri, 16 Apr 2010 08:31:19 +0000 (08:31 +0000)
committerdmitrykos <dmitrykos@0f58301d-fd10-0410-b4af-bbb618454e57>
Fri, 16 Apr 2010 08:31:19 +0000 (08:31 +0000)
 - new method PaWasapi_GetFramesPerHostBuffer which allows to get number of input/output frames per host (WASAPI) buffer, this method helps to find out maximal values for PaWasapiHostProcessorCallback
 - documentation fixes

build/msvc/portaudio.def
include/pa_win_wasapi.h
src/hostapi/wasapi/pa_win_wasapi.c

index c57bdbf8e24a842eb4bbf2c1f7bc3639f4c9ba02..90c01a3be71c681215288df0092293ecb0c3ca4f 100644 (file)
@@ -45,3 +45,4 @@ PaWasapi_GetDeviceDefaultFormat     @56
 PaWasapi_GetDeviceRole              @57
 PaWasapi_ThreadPriorityBoost        @58
 PaWasapi_ThreadPriorityRevert       @59
+PaWasapi_GetFramesPerHostBuffer     @60
\ No newline at end of file
index 9023ff163d0ea6a7ccdd27be66c8177258f52afe..a0bcf7ace5bb5cdca28b3c548b36266ad4428266 100644 (file)
@@ -84,8 +84,8 @@ PaWasapiFlags;
 /* Host processor. Allows to skip internal PA processing completely. \r
    You must set paWinWasapiRedirectHostProcessor flag to PaWasapiStreamInfo::flags member\r
    in order to have host processor redirected to your callback.\r
-   Use with caution! inputFrames and outputFrames depend solely on final device setup (buffer\r
-   size is just recommendation) but are not changing during run-time once stream is started.\r
+   Use with caution! inputFrames and outputFrames depend solely on final device setup.\r
+   To query maximal values of inputFrames/outputFrames use PaWasapi_GetFramesPerHostBuffer.\r
 */\r
 typedef void (*PaWasapiHostProcessorCallback) (void *inputBuffer,  long inputFrames,\r
                                                void *outputBuffer, long outputFrames,\r
@@ -164,11 +164,11 @@ PaWasapiStreamInfo;
 /** Returns default sound format for device. Format is represented by PaWinWaveFormat or \r
     WAVEFORMATEXTENSIBLE structure.\r
 \r
- @param pFormat pointer to PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure.\r
- @param nFormatSize pize of PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure in bytes.\r
- @param nDevice device index.\r
+ @param pFormat Pointer to PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure.\r
+ @param nFormatSize Size of PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure in bytes.\r
+ @param nDevice Device index.\r
 \r
- @return A non-negative value indicating the number of bytes copied into format decriptor\r
+ @return Non-negative value indicating the number of bytes copied into format decriptor\r
          or, a PaErrorCode (which are always negative) if PortAudio is not initialized\r
          or an error is encountered.\r
 */\r
@@ -179,7 +179,7 @@ int PaWasapi_GetDeviceDefaultFormat( void *pFormat, unsigned int nFormatSize, Pa
 \r
  @param nDevice device index.\r
 \r
- @return A non-negative value indicating device role or, a PaErrorCode (which are always negative)\r
+ @return Non-negative value indicating device role or, a PaErrorCode (which are always negative)\r
          if PortAudio is not initialized or an error is encountered.\r
 */\r
 int/*PaWasapiDeviceRole*/ PaWasapi_GetDeviceRole( PaDeviceIndex nDevice );\r
@@ -188,14 +188,14 @@ int/*PaWasapiDeviceRole*/ PaWasapi_GetDeviceRole( PaDeviceIndex nDevice );
 /** Boost thread priority of calling thread (MMCSS). Use it for Blocking Interface only for thread\r
     which makes calls to Pa_WriteStream/Pa_ReadStream.\r
 \r
- @param hTask a handle to pointer to priority task. Must be used with PaWasapi_RevertThreadPriority\r
+ @param hTask Handle to pointer to priority task. Must be used with PaWasapi_RevertThreadPriority\r
               method to revert thread priority to initial state.\r
 \r
- @param nPriorityClass an Id of thread priority of PaWasapiThreadPriority type. Specifying \r
+ @param nPriorityClass Id of thread priority of PaWasapiThreadPriority type. Specifying \r
                        eThreadPriorityNone does nothing.\r
 \r
  @return Error code indicating success or failure.\r
- @see PaWasapi_RevertThreadPriority\r
+ @see    PaWasapi_RevertThreadPriority\r
 */\r
 PaError PaWasapi_ThreadPriorityBoost( void **hTask, PaWasapiThreadPriority nPriorityClass );\r
 \r
@@ -203,13 +203,26 @@ PaError PaWasapi_ThreadPriorityBoost( void **hTask, PaWasapiThreadPriority nPrio
 /** Boost thread priority of calling thread (MMCSS). Use it for Blocking Interface only for thread\r
     which makes calls to Pa_WriteStream/Pa_ReadStream.\r
 \r
- @param hTask Task handle obtained by PaWasapi_BoostThreadPriority method.\r
+ @param  hTask Task handle obtained by PaWasapi_BoostThreadPriority method.\r
  @return Error code indicating success or failure.\r
- @see PaWasapi_BoostThreadPriority\r
+ @see    PaWasapi_BoostThreadPriority\r
 */\r
 PaError PaWasapi_ThreadPriorityRevert( void *hTask );\r
 \r
 \r
+/** Get number of frames per host buffer. This is maximal value of frames of WASAPI buffer which \r
+    can be locked for operations. Use this method as helper to findout maximal values of \r
+    inputFrames/outputFrames of PaWasapiHostProcessorCallback.\r
+\r
+ @param  pStream Pointer to PaStream to query.\r
+ @param  nInput  Pointer to variable to receive number of input frames. Can be NULL.\r
+ @param  nOutput Pointer to variable to receive number of output frames. Can be NULL.\r
+ @return Error code indicating success or failure.\r
+ @see    PaWasapiHostProcessorCallback\r
+*/\r
+PaError PaWasapi_GetFramesPerHostBuffer( PaStream *pStream, unsigned int *nInput, unsigned int *nOutput );\r
+\r
+\r
 /*\r
     IMPORTANT:\r
 \r
@@ -228,24 +241,31 @@ PaError PaWasapi_ThreadPriorityRevert( void *hTask );
         two versions:\r
 \r
         1) Event-Driven:\r
-        This is the most powerful WASAPI implementation which is capable to provides glitch-free\r
-        audio at 2ms latency in Exclusive mode. Lowest possible latency for this mode is \r
-        usually - 2ms for HD Audio class audio chips (including on-board audio, 2ms was achieved \r
-        on Realtek ALC888/S/T). For Shared mode latency can not go lower than 20ms.\r
+        This is the most powerful WASAPI implementation which provides glitch-free\r
+        audio at around 3ms latency in Exclusive mode. Lowest possible latency for this mode is \r
+        usually - 1.4(Vista only)-3ms(Windows 7+) for HD Audio class audio chips. For the \r
+        Shared mode latency can not be lower than 20ms.\r
 \r
         2) Poll-Driven:\r
         Polling is another 2-nd method to operate with WASAPI. It is less efficient than Event-Driven\r
-        and provides latency at around 12-13ms. Polling must be used to overcome a system bug\r
-        under Windows Vista x64 when application is WOW64(32-bit) and Event-Driven method simply times\r
-        out (event handle is never signalled on buffer completion). Please note, such Vista bug \r
-        does not exist in Windows 7 x64.\r
-        Polling is setup by speciying 'paWinWasapiPolling' flag.\r
-        Thread priority can be boosted by specifying 'paWinWasapiBlockingThreadPriorityPro' flag.\r
+        and provides latency at around 10-13ms. Polling must be used to overcome a system bug\r
+        under Windows Vista x64 when application is WOW64(32-bit) and Event-Driven method simply \r
+        times out (event handle is never signalled on buffer completion). Please note, such WOW64 bug \r
+        does not exist in Vista x86 or Windows 7.\r
+        Polling can be setup by speciying 'paWinWasapiPolling' flag. Our WASAPI implementation detects\r
+        WOW64 bug and sets 'paWinWasapiPolling' automatically.\r
+\r
+    Thread priority:\r
+\r
+        Normally thread priority is set automatically and does not require modification. Although\r
+        if user wants some tweaking thread priority can be modified by setting 'paWinWasapiThreadPriority'\r
+        flag and specifying 'PaWasapiStreamInfo::threadPriority' with value from PaWasapiThreadPriority \r
+        enum.\r
 \r
     Blocking Interface:\r
 \r
         Blocking interface is implemented but due to above described Poll-Driven method can not\r
-        deliver low latency audio. Specifying too low latency in Shared mode will result in \r
+        deliver lowest possible latency. Specifying too low latency in Shared mode will result in \r
         distorted audio although Exclusive mode adds stability.\r
 \r
     Pa_IsFormatSupported:\r
index f659096b749c9667224dadacc66b2790b424db33..c83a973b634166c7897b7dd5386138b628a40fe4 100644 (file)
@@ -1391,6 +1391,22 @@ int PaWasapi_GetDeviceRole( PaDeviceIndex nDevice )
        return paWasapi->devInfo[ index ].formFactor;\r
 }\r
 \r
+// ------------------------------------------------------------------------------------------\r
+PaError PaWasapi_GetFramesPerHostBuffer( PaStream *pStream, unsigned int *nInput, unsigned int *nOutput )\r
+{\r
+    PaWasapiStream *stream = (PaWasapiStream *)pStream;\r
+       if (stream == NULL)\r
+               return paBadStreamPtr;\r
+\r
+       if (nInput != NULL)\r
+               (*nInput) = stream->in.framesPerHostCallback;\r
+\r
+       if (nOutput != NULL)\r
+               (*nOutput) = stream->out.framesPerHostCallback;\r
+\r
+       return paNoError;\r
+}\r
+\r
 // ------------------------------------------------------------------------------------------\r
 static void LogWAVEFORMATEXTENSIBLE(const WAVEFORMATEXTENSIBLE *in)\r
 {\r