[wdmaudiodev] Different channel counts for APO?

  • From: IL <developer@xxxxxxxxxxxxxxx>
  • To: wdmaudiodev@xxxxxxxxxxxxx
  • Date: Wed, 24 Jun 2020 19:24:02 +0100

Greetings,

I'm incorporating an algorithm that upmixes a stereo input signal to 
multichannel output into an APO, using the MFX SwapAPO from Sysvad as 
reference. For the time being, I'd like to save the multichannel output as a 
.wav file for testing (Sysvad's normal behaviour). I'm having trouble 
understanding how to correctly change the number of channels and hence the 
interleaved buffer size I receive during the APOProcess call. So far I have 
done the following:

1. Removed the assertion lock from ValidateCacheAndConnectionInfo in the MFX 
cpp file
"_ASSERTE(UncompOutputFormat. dwSamplesPerFrame == 
UncompInputFormat.dwSamplesPerFrame);"

2. Added only (APO_FLAG_BITSPERSAMPLE_MUST_MATCH | 
APO_FLAG_FRAMESPERSECOND_MUST_MATCH) in the CRegAPOProperties

3. In isOutputFormatSupported() I have tried a 'hacky' approach with explicitly 
setting the channel count as follows:

    hResult = 
recommendedFormat->GetUncompressedAudioFormat(&uncompOutputFormat);
        IF_FAILED_JUMP(hResult, Exit);
        uncompOutputFormat.dwSamplesPerFrame = this->numberOfPlaybackChannels; 
// explicit fixed channel count
    hResult = 
CreateAudioMediaTypeFromUncompressedAudioFormat(&uncompOutputFormat, 
ppSupportedOutputFormat);
    IF_FAILED_JUMP(hResult, Exit);
        hResult = S_OK; // S_FALSE;
Exit:
        if (recommendedFormat)
        {
                recommendedFormat->Release();
        }
        return hResult;

However when checking the channel count for outputs in 
ValidateCacheAndConnectionInfo it is still set to 2. (I am also getting the 
feeling that this is not a good idea/approach to begin with). 

Should I be making edits in the kernel code? Please correct me if I'm wrong, 
but from inspecting the Sysvad solution, I see that CMiniportWaveRTSTream::Init 
is where the saving occurs, and I presume therefore nothing exits the output 
pin of the Wave KS filter to the corresponding topology filter at this stage - 
in other words, I would assume explicitly setting the channel count on the pin 
here would be redundant for the current purpose of saving multichannel output 
(and therefore I must be missing something else?)

How can I make this work and ensure that the APOProcess output buffer I get has 
the same number of frames but different number of channels? I presume the 
correct approach would also automatically set the desired channel count in the 
RIFF wave header for output (I see that the PKSDATAFORMAT DataFormat_ supplied 
to CMiniportWaveRTStream::Init is responsible for this).

Apologies for my confusions, I'm still wrapping my head around a lot of these 
concepts

Thanks!

Other related posts:

  • » [wdmaudiodev] Different channel counts for APO? - IL