Merge branch 'winrt' into 'master'
WASAPI: Add paWinWasapiAutoConvert flag, which sets AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY for Shared mode streams. Merged-on: https://assembla.com/code/portaudio/git/merge_requests/7481081
This commit is contained in:
commit
eb6b5e2598
2 changed files with 36 additions and 2 deletions
|
|
@ -78,7 +78,13 @@ typedef enum PaWasapiFlags
|
||||||
/* force explicit sample format and do not allow PA to select suitable working format, API will
|
/* force explicit sample format and do not allow PA to select suitable working format, API will
|
||||||
fail if provided sample format is not supported by audio hardware in Exclusive mode
|
fail if provided sample format is not supported by audio hardware in Exclusive mode
|
||||||
or system mixer in Shared mode */
|
or system mixer in Shared mode */
|
||||||
paWinWasapiExplicitSampleFormat = (1 << 5)
|
paWinWasapiExplicitSampleFormat = (1 << 5),
|
||||||
|
|
||||||
|
/* allow API to insert system-level channel matrix mixer and sample rate converter to allow
|
||||||
|
playback formats that do not match the current configured system settings.
|
||||||
|
this is in particular required for streams not matching the system mixer sample rate.
|
||||||
|
only applies in Shared mode. */
|
||||||
|
paWinWasapiAutoConvert = (1 << 6)
|
||||||
}
|
}
|
||||||
PaWasapiFlags;
|
PaWasapiFlags;
|
||||||
#define paWinWasapiExclusive (paWinWasapiExclusive)
|
#define paWinWasapiExclusive (paWinWasapiExclusive)
|
||||||
|
|
@ -87,6 +93,7 @@ PaWasapiFlags;
|
||||||
#define paWinWasapiPolling (paWinWasapiPolling)
|
#define paWinWasapiPolling (paWinWasapiPolling)
|
||||||
#define paWinWasapiThreadPriority (paWinWasapiThreadPriority)
|
#define paWinWasapiThreadPriority (paWinWasapiThreadPriority)
|
||||||
#define paWinWasapiExplicitSampleFormat (paWinWasapiExplicitSampleFormat)
|
#define paWinWasapiExplicitSampleFormat (paWinWasapiExplicitSampleFormat)
|
||||||
|
#define paWinWasapiAutoConvert (paWinWasapiAutoConvert)
|
||||||
|
|
||||||
|
|
||||||
/* Stream state.
|
/* Stream state.
|
||||||
|
|
|
||||||
|
|
@ -287,7 +287,7 @@ typedef struct _pa_AudioClientProperties {
|
||||||
PA_THREAD_FUNC ProcThreadEvent(void *param);
|
PA_THREAD_FUNC ProcThreadEvent(void *param);
|
||||||
PA_THREAD_FUNC ProcThreadPoll(void *param);
|
PA_THREAD_FUNC ProcThreadPoll(void *param);
|
||||||
|
|
||||||
// Availabe from Windows 7
|
// Error codes (availabe since Windows 7)
|
||||||
#ifndef AUDCLNT_E_BUFFER_ERROR
|
#ifndef AUDCLNT_E_BUFFER_ERROR
|
||||||
#define AUDCLNT_E_BUFFER_ERROR AUDCLNT_ERR(0x018)
|
#define AUDCLNT_E_BUFFER_ERROR AUDCLNT_ERR(0x018)
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -298,6 +298,14 @@ PA_THREAD_FUNC ProcThreadPoll(void *param);
|
||||||
#define AUDCLNT_E_INVALID_DEVICE_PERIOD AUDCLNT_ERR(0x020)
|
#define AUDCLNT_E_INVALID_DEVICE_PERIOD AUDCLNT_ERR(0x020)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Stream flags (availabe since Windows 7)
|
||||||
|
#ifndef AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY
|
||||||
|
#define AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY 0x08000000
|
||||||
|
#endif
|
||||||
|
#ifndef AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM
|
||||||
|
#define AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM 0x80000000
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MAX_STR_LEN 512
|
#define MAX_STR_LEN 512
|
||||||
|
|
||||||
#ifdef PA_WINRT
|
#ifdef PA_WINRT
|
||||||
|
|
@ -2672,6 +2680,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
|
// Try standard approach, e.g. if data is > 16 bits it will be packed into 32-bit containers
|
||||||
MakeWaveFormatFromParams(outWavex, ¶ms, sampleRate, FALSE);
|
MakeWaveFormatFromParams(outWavex, ¶ms, sampleRate, FALSE);
|
||||||
|
|
||||||
|
// 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));
|
hr = IAudioClient_IsFormatSupported(client, shareMode, &outWavex->Format, (shareMode == AUDCLNT_SHAREMODE_SHARED ? &sharedClosestMatch : NULL));
|
||||||
|
|
||||||
// Exclusive mode can require packed format for some devices
|
// Exclusive mode can require packed format for some devices
|
||||||
|
|
@ -3591,6 +3606,12 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
|
||||||
if (fullDuplex)
|
if (fullDuplex)
|
||||||
stream->in.streamFlags = 0; // polling interface is implemented for full-duplex mode also
|
stream->in.streamFlags = 0; // polling interface is implemented for full-duplex mode also
|
||||||
|
|
||||||
|
// 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
|
// Fill parameters for Audio Client creation
|
||||||
stream->in.params.device_info = info;
|
stream->in.params.device_info = info;
|
||||||
stream->in.params.stream_params = (*inputParameters);
|
stream->in.params.stream_params = (*inputParameters);
|
||||||
|
|
@ -3719,6 +3740,12 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
|
||||||
if (fullDuplex)
|
if (fullDuplex)
|
||||||
stream->out.streamFlags = 0; // polling interface is implemented for full-duplex mode also
|
stream->out.streamFlags = 0; // polling interface is implemented for full-duplex mode also
|
||||||
|
|
||||||
|
// 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
|
// Fill parameters for Audio Client creation
|
||||||
stream->out.params.device_info = info;
|
stream->out.params.device_info = info;
|
||||||
stream->out.params.stream_params = (*outputParameters);
|
stream->out.params.stream_params = (*outputParameters);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue