PortAudio / portaudio

PortAudio is a cross-platform, open-source C language library for real-time audio input and output.
Other
1.43k stars 296 forks source link

Win32/WASAPI: suggestion: improve symbol names for the "stereo to mono mixer" code #946

Open RossBencina opened 1 month ago

RossBencina commented 1 month ago

[Hi Dmitry, this is just a suggestion for changing internal function names. I'm not proposing to have a lengthy debate. Please close this issue if you don't want to action it]

During the review of #934 I had a bit of confusion about the meaning of the phrase "internal stereo to mono mixer" in a comment.

Upon review of the code in pa_win_wasapi.c I see that there is a mechanism for selecting functions for changing channel count: GetMonoToStereoMixer, it is called on line 3339:

pSub->monoMixer = GetMonoToStereoMixer(&pSub->wavexu.ext, (output ? MIX_DIR__1TO2 : MIX_DIR__2TO1_L));

Note that this function, and the functions that it calls are used for 2->1 mixing or channel selection for input, or 1->2 channel duplication for output. There are two sources of confusion:

I think it is good to aim to reduce the amount of confusion in the code base. Here are some options:

pSub->monoStereoConverter = GetMonoStereoConverter(&pSub->wavexu.ext, (output ? CONVERT__1TO2 : CONVERT_2TO1_L));

or

pSub->monoStereoConverter = output ? GetMonoToStereoConverter(&pSub->wavexu.ext) :  GetStereoToMonoConverter(&pSub->wavexu.ext, CONVERT__2TO1_L);

Then I would change the name of in individual converters:

_StereoToMono_2TO1_8, _MonoToStereo_1TO2_24

or, probably better:

_Convert_2TO1_8, _Convert_1TO2_24

Hope you see what I mean.

Thank you.

dmitrykos commented 1 month ago

Hi Ross! I like your proposal, it will improve code readability indeed.

I would choose:

pSub->monoStereoConverter = GetMonoStereoConverter(&pSub->wavexu.ext, (output ? CONVERT__1TO2 : CONVERT_2TO1_L));

and:

_Convert_2TO1_8, _Convert_1TO2_24

Once PRs touching this area are merged, will create new one to address this issue.