Skip to content

Commit

Permalink
wasapi: Add passthrough support (AC3, E-AC3, ...) (#778)
Browse files Browse the repository at this point in the history
* add AC3 and E-AC3 passthrough support for wasapi
* Use WAVEFORMATEXTENSIBLE_UNION to contain PCM and SPDIF specific structures and clearly differentiate between PCM and SPDIF modes configuration.
* Made implementation generic and added all other known passthrough formats.
* Known issues documented in #816
Resolves #778
Co-authored-by: Dmitry Kostjučenko <dmitrykos@neutroncode.com>
  • Loading branch information
gabys999 authored May 19, 2023
1 parent b323e01 commit 2fe67f3
Show file tree
Hide file tree
Showing 5 changed files with 601 additions and 73 deletions.
66 changes: 65 additions & 1 deletion include/pa_win_wasapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ typedef enum PaWasapiFlags
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)
paWinWasapiAutoConvert = (1 << 6),

/* use Passthrough mode for sending encoded audio data in PCM containers to the audio device */
paWinWasapiPassthrough = (1 << 7),
}
PaWasapiFlags;
#define paWinWasapiExclusive (paWinWasapiExclusive)
Expand All @@ -92,6 +95,7 @@ PaWasapiFlags;
#define paWinWasapiThreadPriority (paWinWasapiThreadPriority)
#define paWinWasapiExplicitSampleFormat (paWinWasapiExplicitSampleFormat)
#define paWinWasapiAutoConvert (paWinWasapiAutoConvert)
#define paWinWasapiPassthrough (paWinWasapiPassthrough)


/* Stream state.
Expand Down Expand Up @@ -302,6 +306,59 @@ typedef enum PaWasapiStreamOption
PaWasapiStreamOption;


/** Passthrough format.
Format ids are taken from the Microsoft documentation "Representing Formats for IEC 61937 Transmissions"
and are composed by such formula where GUID is the guid of passthrough format:
GUID.Data1 << 16 | GUID.Data2.
@version Available as of 19.8.0
*/
typedef enum PaWasapiPassthroughFormat
{
ePassthroughFormatPcmIec60958 = 0x00000000,
ePassthroughFormatDolbyDigital = 0x00920000,
ePassthroughFormatMpeg1 = 0x00030cea,
ePassthroughFormatMpeg3 = 0x00040cea,
ePassthroughFormatMpeg2 = 0x00050cea,
ePassthroughFormatAac = 0x00060cea,
ePassthroughFormatDts = 0x00080cea,
ePassthroughFormatDolbyDigitalPlus = 0x000a0cea,
ePassthroughFormatDolbyDigitalPlusAtmos = 0x010a0cea,
ePassthroughFormatDtsHd = 0x000b0cea,
ePassthroughFormatDtsXE1 = 0x010b0cea,
ePassthroughFormatDtsXE2 = 0x030b0cea,
ePassthroughFormatDolbyMlp = 0x000c0cea,
ePassthroughFormatDolbyMat20 = 0x010c0cea,
ePassthroughFormatDolbyMat21 = 0x030c0cea,
ePassthroughFormatWmaPro = 0x01640000,
ePassthroughFormatAtrac = 0x00080cea,
ePassthroughFormatOneBitAudio = 0x00090cea,
ePassthroughFormatDst = 0x000d0cea,
}
PaWasapiPassthroughFormat;


/** Passthrough details.
Passthrough details provide direct link to the additional members in WAVEFORMATEXTENSIBLE_IEC61937.
Passthrough mode allows to pass encoded data inside the PCM containers to the audio device.
Detailed description about supported formats and examples are provided in Microsoft documentation:
"Representing Formats for IEC 61937 Transmissions".
@version Available as of 19.8.0
*/
typedef struct PaWasapiStreamPassthrough
{
PaWasapiPassthroughFormat formatId;
unsigned int encodedSamplesPerSec;
unsigned int encodedChannelCount;
unsigned int averageBytesPerSec;
}
PaWasapiStreamPassthrough;


/* Stream descriptor. */
typedef struct PaWasapiStreamInfo
{
Expand Down Expand Up @@ -347,6 +404,13 @@ typedef struct PaWasapiStreamInfo
@version Available as of 19.6.0
*/
PaWasapiStreamOption streamOption;

/** Passthrough details.
@note paWinWasapiPassthrough flag must be specified in PaWasapiStreamInfo::flags to enable Passthrough mode.
@see paWinWasapiPassthrough
@version Available as of 19.7.0
*/
PaWasapiStreamPassthrough passthrough;
}
PaWasapiStreamInfo;

Expand Down
Loading

0 comments on commit 2fe67f3

Please sign in to comment.