wasapi: some cleanup of Jörn Heusipp's patch
This commit is contained in:
parent
aa0748a5b5
commit
c40b969e1b
1 changed files with 18 additions and 8 deletions
|
|
@ -282,7 +282,7 @@ typedef struct _pa_AudioClientProperties {
|
|||
PA_THREAD_FUNC ProcThreadEvent(void *param);
|
||||
PA_THREAD_FUNC ProcThreadPoll(void *param);
|
||||
|
||||
// Availabe from Windows 7
|
||||
// Error codes (availabe since Windows 7)
|
||||
#ifndef AUDCLNT_E_BUFFER_ERROR
|
||||
#define AUDCLNT_E_BUFFER_ERROR AUDCLNT_ERR(0x018)
|
||||
#endif
|
||||
|
|
@ -293,6 +293,7 @@ PA_THREAD_FUNC ProcThreadPoll(void *param);
|
|||
#define AUDCLNT_E_INVALID_DEVICE_PERIOD AUDCLNT_ERR(0x020)
|
||||
#endif
|
||||
|
||||
// Stream flags (availabe since Windows 7)
|
||||
#ifndef AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY
|
||||
#define AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY 0x08000000
|
||||
#endif
|
||||
|
|
@ -2674,10 +2675,13 @@ static PaError GetClosestFormat(IAudioClient *client, double sampleRate, const P
|
|||
|
||||
// Try standard approach, e.g. if data is > 16 bits it will be packed into 32-bit containers
|
||||
MakeWaveFormatFromParams(outWavex, ¶ms, sampleRate, FALSE);
|
||||
if ((GetWindowsVersion() >= WINDOWS_7_SERVER2008R2) && (shareMode == AUDCLNT_SHAREMODE_SHARED) && _params->hostApiSpecificStreamInfo && (((PaWasapiStreamInfo *)_params->hostApiSpecificStreamInfo)->flags & paWinWasapiAutoConvert))
|
||||
{
|
||||
|
||||
// If built-in PCM converter requested then shared mode format will always succeed
|
||||
if ((GetWindowsVersion() >= WINDOWS_7_SERVER2008R2) &&
|
||||
(shareMode == AUDCLNT_SHAREMODE_SHARED) &&
|
||||
((streamInfo != NULL) && (streamInfo->flags & paWinWasapiAutoConvert)))
|
||||
return paFormatIsSupported;
|
||||
}
|
||||
|
||||
hr = IAudioClient_IsFormatSupported(client, shareMode, &outWavex->Format, (shareMode == AUDCLNT_SHAREMODE_SHARED ? &sharedClosestMatch : NULL));
|
||||
|
||||
// Exclusive mode can require packed format for some devices
|
||||
|
|
@ -3597,8 +3601,11 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
|
|||
if (fullDuplex)
|
||||
stream->in.streamFlags = 0; // polling interface is implemented for full-duplex mode also
|
||||
|
||||
if ((GetWindowsVersion() >= WINDOWS_7_SERVER2008R2) && (stream->in.shareMode == AUDCLNT_SHAREMODE_SHARED) && (inputStreamInfo != NULL) && (inputStreamInfo->flags & paWinWasapiAutoConvert))
|
||||
stream->in.streamFlags |= AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY;
|
||||
// Use built-in PCM converter (channel count and sample rate) if requested
|
||||
if ((GetWindowsVersion() >= WINDOWS_7_SERVER2008R2) &&
|
||||
(stream->in.shareMode == AUDCLNT_SHAREMODE_SHARED) &&
|
||||
((inputStreamInfo != NULL) && (inputStreamInfo->flags & paWinWasapiAutoConvert)))
|
||||
stream->in.streamFlags |= (AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY);
|
||||
|
||||
// Fill parameters for Audio Client creation
|
||||
stream->in.params.device_info = info;
|
||||
|
|
@ -3728,8 +3735,11 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
|
|||
if (fullDuplex)
|
||||
stream->out.streamFlags = 0; // polling interface is implemented for full-duplex mode also
|
||||
|
||||
if ((GetWindowsVersion() >= WINDOWS_7_SERVER2008R2) && (stream->out.shareMode == AUDCLNT_SHAREMODE_SHARED) && (outputStreamInfo != NULL) && (outputStreamInfo->flags & paWinWasapiAutoConvert))
|
||||
stream->out.streamFlags |= AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY;
|
||||
// Use built-in PCM converter (channel count and sample rate) if requested
|
||||
if ((GetWindowsVersion() >= WINDOWS_7_SERVER2008R2) &&
|
||||
(stream->out.shareMode == AUDCLNT_SHAREMODE_SHARED) &&
|
||||
((outputStreamInfo != NULL) && (outputStreamInfo->flags & paWinWasapiAutoConvert)))
|
||||
stream->out.streamFlags |= (AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY);
|
||||
|
||||
// Fill parameters for Audio Client creation
|
||||
stream->out.params.device_info = info;
|
||||
|
|
|
|||
Loading…
Reference in a new issue