Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pa_converters.c lrintf usage is [was] suspect: does not reproduce the same values as non-lrintf code #390

Open
RossBencina opened this issue Dec 22, 2020 · 12 comments · Fixed by #403
Assignees
Labels
P2 Priority: High src-common Common sources in /src/common
Milestone

Comments

@RossBencina
Copy link
Collaborator

RossBencina commented Dec 22, 2020

When PA_USE_C99_LRINTF is defined, pa_converters.c uses lrintf for truncating floats to integers. For example here is one case:

#ifdef PA_USE_C99_LRINTF
        float scaled = *src * 0x7FFFFFFF;
        *dest = lrintf(scaled-0.5f);
#else
        double scaled = *src * 0x7FFFFFFF;
        *dest = (PaInt32) scaled;        
#endif

The code in context is here:

*dest = lrintf(scaled-0.5f);

I am guessing that the code is intended to implement a fast truncation.

Problem 1: Presumably the code assumes that the rounding mode is set to round to nearest, however this file never checks or sets the rounding mode. Is it set elsewhere? that is not documented. I would expect there to be clear usage of fesetround and/or fegetround.

Problem 2: The code doesn't work the way the author expected. For example if scaled == 3.0 then lrintf(scaled-0.5f) == 2. This is because of the way odd/even round to nearest works in IEEE floating point.

The following test program:

#include <iostream>
#include <fenv.h>       /* fesetround, FE_* */
#include <math.h>       /* rint */

long int myc99truncate(float x)
{
    return lrintf(x-0.5f);
}

long int mytruncate(float x)
{
    return (long int)x;
}


int main()
{
    fesetround(FE_TONEAREST);
    
    std::cout << 0.0f << "   truncates to " << mytruncate(0.0f) << " or " << myc99truncate(0.0f) << std::endl;
    std::cout << 0.5f << " truncates to " << mytruncate(0.5f) << " or " << myc99truncate(0.5f) << std::endl;
    std::cout << 1.0f << "   truncates to " << mytruncate(1.0f) << " or " << myc99truncate(1.0f) << " *" << std::endl;
    std::cout << 1.5f << " truncates to " << mytruncate(1.5f) << " or " << myc99truncate(1.5f) << std::endl;
    std::cout << 2.0f << "   truncates to " << mytruncate(2.0f) << " or " << myc99truncate(2.0f) << std::endl;
    std::cout << 2.5f << " truncates to " << mytruncate(2.5f) << " or " << myc99truncate(2.5f) << std::endl;
    std::cout << 3.0f << "   truncates to " << mytruncate(3.0f) << " or " << myc99truncate(3.0f) << " *" << std::endl;
    std::cout << 3.5f << " truncates to " << mytruncate(3.5f) << " or " << myc99truncate(3.5f) << std::endl;
    std::cout << 4.0f << "   truncates to " << mytruncate(4.0f) << " or " << myc99truncate(4.0f) << std::endl;
    std::cout << 4.5f << " truncates to " << mytruncate(4.5f) << " or " << myc99truncate(4.5f) << std::endl;
}

outputs (non-matching entries marked with *):

0   truncates to 0 or 0
0.5 truncates to 0 or 0
1   truncates to 1 or 0 *
1.5 truncates to 1 or 1
2   truncates to 2 or 2
2.5 truncates to 2 or 2
3   truncates to 3 or 2 *
3.5 truncates to 3 or 3
4   truncates to 4 or 4
4.5 truncates to 4 or 4

Here is the above test code running in a sandbox:
https://wandbox.org/permlink/ZIZOsQjfIgv3DKAb

If continued use of lrintf is desired, the fix that I would recommend is to set the rounding mode to truncate prior to the loop, and reset it to the old rounding mode afterwards. Then simply use *dest = lrintf(scaled) in the loop.

@RossBencina RossBencina added the src-common Common sources in /src/common label Dec 22, 2020
@RossBencina RossBencina changed the title pa_converters.c lrint usage is suspect pa_converters.c lrintf usage is suspect Dec 22, 2020
@jmelas
Copy link
Contributor

jmelas commented Dec 22, 2020

Thank you for the insight @RossBencina !
OK I won't use PA_USE_C99_LRINTF

@RossBencina RossBencina changed the title pa_converters.c lrintf usage is suspect pa_converters.c lrintf usage is suspect: does not reproduce the same values as non-lrintf code Dec 23, 2020
@philburk
Copy link
Collaborator

(long int)x;
will truncate towards zero. So it is not symmetric about zero.
What behavior do we really want? Do we want round to nearest? Or floor towards negative infinity?

It probably does not matter for PaInt32.

This feels like an old discussion.

@RossBencina
Copy link
Collaborator Author

RossBencina commented Dec 27, 2020

@philburk the truncation operation is perfectly symmetric. The problem you mention is that the integer representation is not symmetric. In any case, none of that is relevant to this issue.

This ticket is about an "optimisation" that has crept into the code that is only enabled by the PA_USE_C99_LRINTF #ifdef. The problem is that lrintf(scaled-0.5f); (which is supposed to be an optimised truncation) DOES NOT truncate towards zero, as I showed above. It has issues due to IEEE 754 odd/even rounding.

I can only guess that the "optimisation" was intended to go faster than the non-optimised truncation.

PA_USE_C99_LRINTF is defined nowhere. Not in any build file. So this buggy code is not usually called. I think we should just remove the lrint code. If someone wants to submit a fixed version they can do it later. (It needs to truncate correctly, and it would need to be demonstrably faster than the usual truncate code).

@RossBencina
Copy link
Collaborator Author

In case there is any question that the current PA_USE_C99_LRINTF is bad, I have written a program that tests all normalized floats between -1 and 1, and converted them using both the truncate and the buggy lrint code. 830472190 values are incorrectly converted using the lrint code.

#include <iostream>
#include <fenv.h>       /* fesetround, FE_* */
#include <math.h>       /* rint */
#include <cstdint>

//#define GOOD_APPROACH

using std::uint32_t;
using std::int32_t;

long int mytruncate(float x)
{
    return lrintf(x-0.5f);
}

// IEEE 754
// sign: 1 bit
// exponent: 8 bits signed [-126, 127]
// mantissa: 23 bits (implicit leading 1)
float make_float(uint32_t sign, int32_t exponent, uint32_t mantissa)
{
    uint32_t uexponent = static_cast<uint32_t>(exponent + 127) & 0xFF;
    uint32_t iresult = (sign << 31) | (uexponent << 23) | mantissa;
    char *src = (char*)&iresult;
    
    float result;
    char *dest = (char*)&result;
    
    // assume that float and uint32_t have the same endianness. note this is not guaranteed by IEEE 754
    dest[0] = src[0];
    dest[1] = src[1];
    dest[2] = src[2];
    dest[3] = src[3];
    
    return result;
}

int main()
{
#ifdef GOOD_APPROACH
    fesetround(FE_TOWARDZERO);
#else
    fesetround(FE_TONEAREST);   
#endif
    
    std::cout << make_float(0, 1, 0) << std::endl; // 2.0
    std::cout << make_float(0, 0, 0) << std::endl; // 1.0
    std::cout << make_float(0, -1, 0) << std::endl; // 0.5
    
    std::cout << make_float(1, 1, 0) << std::endl; // -2.0
    std::cout << make_float(1, 0, 0) << std::endl; // -1.0
    std::cout << make_float(1, -1, 0) << std::endl; // -0.5
    
    uint32_t badCount = 0;
    
    // try all normalized numbers from 0 up to +/- 0.99999999 (i.e. just less than 1)
    for (int32_t e = -126; e < 0; ++e) { 
        for (uint32_t m=0; m < 0x01000000; ++m) { // 24 bit mantissae 
            for (uint32_t sign=0; sign < 2; ++sign) {
                float f = make_float(sign, e, m);
                float scaled = f * 0x7FFFFFFF;
                
#ifdef GOOD_APPROACH
    uint32_t munged = lrintf(scaled);
#else
    uint32_t munged = lrintf(scaled-0.5f); 
#endif

                uint32_t truncated = (uint32_t) scaled;
                
                if (munged != truncated) {
                    //std::cout << f << std::endl;
                    ++badCount;
                }
            }            
        }
    }
    
    std::cout << "bad count: " << badCount << std::endl;
}

Output:

2
1
0.5
-2
-1
-0.5
bad count: 830472190

Sandbox: https://wandbox.org/permlink/oUHF6t0jCzaO6ebO

@philburk
Copy link
Collaborator

the truncation operation is perfectly symmetric.

Right. I meant that ((int)x) is not a straight line as it crosses zero.

I am not a fan of lrintf(). We can get rid of it.

There are a number of interesting conversion functions in the Android code here:

https://cs.android.com/android/platform/superproject/+/master:system/media/audio_utils/include/audio_utils/primitives.h;l=961;drc=master

@RossBencina
Copy link
Collaborator Author

To be clear: I have no problem with lrintf but the way it is being used here is to emulate truncation, and it is buggy. I would be happy to see a correct use of lrintf if it proved faster than truncation (truncation can be slow). To reproduce the existing truncation behavior the code would need to

  1. save and restore the rounding mode outside the loop
  2. set the rounding mode correctly prior to the loop (e.g. to round to zero, although we could consider round to nearest)
  3. use lrintf without out any +/-0.5 weirdness.

I will prepare a patch to remove the existing code.

@RossBencina
Copy link
Collaborator Author

Here is the original commit:

svn2github/PortAudio@5134080

added code from David Viens to use C99's lrintf for float->int conversion when PA_USE_C99_LRINTF is defined
git-svn-id: https://subversion.assembla.com/svn/portaudio@491 0f58301d-fd10-0410-b4af-bbb618454e57
master
rossbencina committed on Mar 27, 2003

@dmitrykos
Copy link
Collaborator

@RossBencina, I have commented in #403 and in favor of removing lrintf().

@RossBencina RossBencina added the P2 Priority: High label Apr 5, 2022
@RossBencina RossBencina added this to the V19.8 milestone Apr 5, 2022
@RossBencina
Copy link
Collaborator Author

Related #100

@RossBencina
Copy link
Collaborator Author

Interesting and extensive analysis by Dmitry here: #403 (comment)

RossBencina added a commit that referenced this issue Aug 25, 2023
…erters.c. this is code guarded by PA_USE_C99_LRINTF. Fixes #390.
@dmitrykos
Copy link
Collaborator

dmitrykos commented Aug 26, 2023

Hi Ross! I propose to remove lrint (my comment #403 gives some grounding for this change) and rely on compiler optimization for the float to int C-style cast.

In this case PA conversion routines have to enforce rounding mode FE_TOWARDZERO to avoid unexpected result if user code sets it to something else. Because rounding mode will be set outside the conversion loop it will be quite cheap on any platform.

Example:

static void Float32_To_Int16(
    void *destinationBuffer, signed int destinationStride,
    void *sourceBuffer, signed int sourceStride,
    unsigned int count, struct PaUtilTriangularDitherGenerator *ditherGenerator )
{
    float *src = (float*)sourceBuffer;
    PaInt16 *dest =  (PaInt16*)destinationBuffer;
    int prevRound = fegetround();
    (void)ditherGenerator; /* unused parameter */
    
    if (fesetround(FE_TOWARDZERO) != 0)
        prevRound = -1;

    while( count-- )
    {
        short samp = (short) (*src * (32767.0f));
        *dest = samp;

        src += sourceStride;
        dest += destinationStride;
    }
    
    if (prevRound != -1)
        fesetround(prevRound);
}

It can be further improved by wrapping fegetround/fesetround into own static inline functions that simplifies implementation of each converter:

static inline int setTruncRoundingMode()
{
    int prev = fegetround();    
    if (fesetround(FE_TOWARDZERO) != 0)
        prev = -1;
        
    return prev;
}

static inline void resetRoundingMode(int prev)
{
    if (prev != -1)
        fesetround(prev);
}

static void Float32_To_Int16(
    void *destinationBuffer, signed int destinationStride,
    void *sourceBuffer, signed int sourceStride,
    unsigned int count, struct PaUtilTriangularDitherGenerator *ditherGenerator )
{
    float *src = (float*)sourceBuffer;
    PaInt16 *dest =  (PaInt16*)destinationBuffer;
    int prevRoundingMode = setTruncRoundingMode();
    (void)ditherGenerator; /* unused parameter */
    
    while( count-- )
    {
        short samp = (short) (*src * (32767.0f));
        *dest = samp;

        src += sourceStride;
        dest += destinationStride;
    }
    
    resetRoundingMode(prevRoundingMode);
}

This implementation will work fine and consistently on any CPU/platform.

We can go even further then and optimize usage of fegetround/fesetround depending on CPU, for example if CPU provides instruction to truncate float to int with rounding toward zero then calls to fegetround/fesetround can be avoided:

#if !(defined(HAVE_SSE) || (__ARM_ARCH >= 8) || defined(__ARM_ARCH_8__) || defined(__ARM_ARCH_8A__))
    #define PA_USE_FESETROUND
#endif

static inline int setTruncRoundingMode()
{
#ifdef PA_USE_FESETROUND
    int prev = fegetround();
    
    if (fesetround(FE_TOWARDZERO) != 0)
        prev = -1;
        
    return prev;
#else
    return 0;
#endif
}

static inline void resetRoundingMode(int prev)
{
#ifdef PA_USE_FESETROUND
    if (prev != -1)
        fesetround(prev);
#endif
}

static inline int truncFloatToInt(float v)
{
#if defined(HAVE_SSE)
    return _mm_cvttss_si32(_mm_load_ss(&v));
#elif (__ARM_ARCH >= 8) || defined(__ARM_ARCH_8__) || defined(__ARM_ARCH_8A__)
    int ret;
    __asm__ ("fcvtzs %x0, %s1" : "=r"(ret) : "w"(v));
    return ret;
#else
    return (int)v;
#endif
}

static void Float32_To_Int16(
    void *destinationBuffer, signed int destinationStride,
    void *sourceBuffer, signed int sourceStride,
    unsigned int count, struct PaUtilTriangularDitherGenerator *ditherGenerator )
{
    float *src = (float*)sourceBuffer;
    PaInt16 *dest =  (PaInt16*)destinationBuffer;
    int prevRoundingMode = setTruncRoundingMode();
    (void)ditherGenerator; /* unused parameter */
    
    while( count-- )
    {
        short samp = (short)truncFloatToInt (*src * (32767.0f));
        *dest = samp;

        src += sourceStride;
        dest += destinationStride;
    }
    
    resetRoundingMode(prevRoundingMode);
}

I could update #403 with this implementation (last 3-rd version), let me know about it.

RossBencina added a commit that referenced this issue Sep 1, 2023
…erters.c (#403)

removes the code guarded by PA_USE_C99_LRINTF
See #390
@RossBencina
Copy link
Collaborator Author

We've removed the bad lrintf code from pa_converters.c in #403, but the conversation continues about how to fix the conversion algorithm. There is useful discussion in this ticket and in the #403 PR that we should keep active for now.

@RossBencina RossBencina reopened this Sep 1, 2023
@RossBencina RossBencina changed the title pa_converters.c lrintf usage is suspect: does not reproduce the same values as non-lrintf code pa_converters.c lrintf usage is [was] suspect: does not reproduce the same values as non-lrintf code Sep 1, 2023
bear101 added a commit to bear101/portaudio that referenced this issue Mar 6, 2024
* Preparation to start patching - TODOS and directory src/hostapi/Oboe

* Added src/hostapi/oboe/README.md

* Added include/pa_oboe.h and src/hostapi/oboe/pa_oboe.cpp

* Added PA_USE_OBOE section to CMakeLists.txt

* Added PA_USE_OBOE section to CMakeLists.txt

* Heavily reworked CMake dependencies, added FindOboe.cmake, updated pa_oboe.cpp, more work needed

* Included build_all_PaOboe.sh, more work needed on CMake

* Included build_all_PaOboe.sh, more work needed on CMake

* Update src/hostapi/oboe/README.md

* bindings/cpp: CMake: support pkgconfig with RelWithDebInfo (PortAudio#822)

bindings/cpp: add  `RelWithDebInfo` to the configurations allowed to install portaudiocpp.pc, otherwise you won't have support for pkg-config when building a release package with separate debugging information. Besides that, RelWithDebInfo is identical to Release.

* Fix MSVC warning C4018 signed/unsigned mismatch (PortAudio#821)

See PortAudio#810

* Built shared library

* Polished bits

* mme: don't restrict the host buffer to 16-bit

Currently, the MME Host API code only creates 16-bit integer MME
buffers. All audio data provided by the user is therefore converted by
PortAudio to and from 16-bit, regardless of the user buffer format.

This basically makes it impossible to pass 24-bit audio through the
MME Host API.

If the user buffer format is not 16-bit, this also causes pointless
conversions to take place, *even if the hardware is running at 16-bit*,
because modern Windows versions (Vista+) convert the data to floating
point behind the scenes before it is handed off to the hardware. This
can lead to silly situations where 32-bit float samples from the user
are (lossily) converted to 16-bit by PortAudio, then ended off to
Windows via MME, only to be converted back to 32-bit float again, before
finally being converted to the format the hardware device is configured
to use. This can easily lead to two layers of 16-bit dithering (one from
PortAudio, and one from Windows) being piled on top of each other,
resulting in an elevated noise floor.

This commit fixes this problem by configuring the MME buffers to use the
same format as the user buffer. This should stop PortAudio from
converting samples in all cases except paInt8, which is not supported by
WAVEFORMATEX (only paUInt8 is). This is pretty much the same idea as
PortAudio#774.

The new code assumes that MME will accept whatever format we throw at
it. I feel confident that this is always true on Vista+ regardless of
hardware, because starting from Vista MME does not access hardware
directly - it always goes through the Windows Audio Engine which
supports all formats in both directions (I verified this using
paloopback).

On pre-Vista Windows, this should still work all the way back to Windows
98 SE, because MME goes through KMixer which supports all formats [1].
Nevertheless, it's difficult to be sure, so this code checks the Windows
version it's running on and preserves the old behavior (i.e. always use
Int16) on pre-Vista Windows.

[1]: https://learn.microsoft.com/en-us/windows-hardware/drivers/audio/background-of-non-pcm-support#waveout-api

Fixes PortAudio#139

* Don't use absolute path when linking to macOS frameworks (PortAudio#829)

fixes PortAudio#828

* Fixing old problems

* Added some debug messages

* added new build script

* Added paOboe in the paHostApi array

* Added paOboe in pa_unix_hostapis.c

* Working patch

* win: New PaWinUtil_GetOsVersion() function for getting Windows OS version. Refactored WASAPI, DS, MME and WDMKS host back-ends to use PaWinUtil_GetOsVersion() instead of direct OS API.

* Ready for other users to compile/build

* Updated oboe/Readme.md

* Added sharing mode selection

* Fixed minor issue with sharing mode selection

* Removed references to KCTI

* Fixed error callback, added performance mode autoselection

* Minor change to CMakeLists, added low latency costant in pa_oboe.h

* Deleted Build_PaOboe.sh

* Ready to push (removed my paths to Oboe directory and Android NDK)

* Update README.md

* Update README.md

* remove all alternative sample conversion code using lrintf in pa_converters.c (PortAudio#403)

removes the code guarded by PA_USE_C99_LRINTF
See PortAudio#390

* updated readme

* fixed CMakeLists.txt

* fixed FindOboe.cmake

* Preparation to start patching - TODOS and directory src/hostapi/Oboe

* Added src/hostapi/oboe/README.md

* Added include/pa_oboe.h and src/hostapi/oboe/pa_oboe.cpp

* Added PA_USE_OBOE section to CMakeLists.txt

* Added PA_USE_OBOE section to CMakeLists.txt

* Heavily reworked CMake dependencies, added FindOboe.cmake, updated pa_oboe.cpp, more work needed

* Included build_all_PaOboe.sh, more work needed on CMake

* Included build_all_PaOboe.sh, more work needed on CMake

* Built shared library

* Polished bits

* Fixing old problems

* Added some debug messages

* added new build script

* Added paOboe in the paHostApi array

* Added paOboe in pa_unix_hostapis.c

* Working patch

* Ready for other users to compile/build

* Updated oboe/Readme.md

* Added sharing mode selection

* Fixed minor issue with sharing mode selection

* Removed references to KCTI

* Fixed error callback, added performance mode autoselection

* Minor change to CMakeLists, added low latency costant in pa_oboe.h

* Deleted Build_PaOboe.sh

* Ready to push (removed my paths to Oboe directory and Android NDK)

* Update src/hostapi/oboe/README.md

* Update README.md

* Update README.md

* updated readme

* fixed CMakeLists.txt

* fixed FindOboe.cmake

* corrected oboe/Readme.md

* Updated oboe/Readme.md

* PulseAudio Portaudio HostAPI (PortAudio#336)

Adds support for PulseAudio API on Linux.

For more information about Pulseaudio visit: https://www.freedesktop.org/wiki/Software/PulseAudio/

---------

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Co-authored-by: sqweek <sqweek@gmail.com>
Co-authored-by: Daniel Schürmann <daschuer@mixxx.org>
Co-authored-by: Mooneer Salem <mooneer@gmail.com>
Co-authored-by: Be <be.0@gmx.com>
Co-authored-by: Mario Kleiner <mario.kleiner.de@gmail.com>

* pulseaudio: Move Pulseaudio include in correct place when using autoconf (PortAudio#843)

As Jack and Pulseaudio both needs Ringbuffer that include can
be done in same place. In configure.in also Pulseaudio header
file was included before it was sure that it was really needed.

Commit makes sure that Pulseaudio include is available only if
it's needed as it can cause failing in build if Pulseaudio
develoment files are not available.

* added .idea to gitignore

* added .idea to gitignore

* restored workflows directory

* Minor fixes to FindOboe.cmake

* Enhanced prebuilt libraries compatibility in FindOboe.cmake

* Minor changes to Pa_Oboe/Readme and pa_oboe.cpp

* Removed auto latency tuning in favor of simpler impleentation in pa_oboe.cpp

* Set paFloat32 as default format in pa_oboe.cpp

* Renamed most of the variables according to best coding practices.

* Added separate callback class to fix the single-stream issue.

* Modified OboeEngine accordingly

* Adjusted the code in the rest of pa_oboe.cpp

* Removed stop and close phases of OboeEngine::restartStream

* Updated functions' description

* minor description corrections

* fixed all compiling errors generated by typos

* Added OboeMediator class in place of OboeCallback, that mediates PortAudio C stream struct and the C++ OboeEngine class

* Fixed allocation problem, working PaOboe implementation

* Fix 'pulseaudioHostApi' use-after-free/null ptr deref in PaPulseAudio_Initialize (PortAudio#847)

The call to PaPulseAudio_UnLock( pulseaudioHostApi->mainloop ) in error-label is performed on 'pulseaudioHostApi' after 'pulseaudioHostApi' has been freed by PaPulseAudio_Free and set to NULL.

* wdmks: declare GUIDs with selectany attribute (PortAudio#846)

* wdmks: declare GUIDs with selectany attribute

Match the behavior of guiddef.h in both mingw and the Windows SDK headers. This prevents linking errors caused by multiply defined symbols when linking against certain Windows SDK libs (like dxguid.lib).

* Make sure this works even if DECLSPEC_SELECTANY is not defined

---------

Co-authored-by: Ross Bencina <rossb@audiomulch.com>

* fixed README.md indenting

* Removed .idea folder from repo

* replaced 'g_' with 'paOboe_' in non-static global variables

* replaced 'm_' prefix with 'm' prefix

* fixed OboeEngine::tryStream as requested

* PulseAudio Portaudio HostAPI (PortAudio#336)

Adds support for PulseAudio API on Linux.

For more information about Pulseaudio visit: https://www.freedesktop.org/wiki/Software/PulseAudio/

---------

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Co-authored-by: sqweek <sqweek@gmail.com>
Co-authored-by: Daniel Schürmann <daschuer@mixxx.org>
Co-authored-by: Mooneer Salem <mooneer@gmail.com>
Co-authored-by: Be <be.0@gmx.com>
Co-authored-by: Mario Kleiner <mario.kleiner.de@gmail.com>

* pulseaudio: Move Pulseaudio include in correct place when using autoconf (PortAudio#843)

As Jack and Pulseaudio both needs Ringbuffer that include can
be done in same place. In configure.in also Pulseaudio header
file was included before it was sure that it was really needed.

Commit makes sure that Pulseaudio include is available only if
it's needed as it can cause failing in build if Pulseaudio
develoment files are not available.

* restored workflows directory

* Minor fixes to FindOboe.cmake

* Enhanced prebuilt libraries compatibility in FindOboe.cmake

* Minor changes to Pa_Oboe/Readme and pa_oboe.cpp

* Removed auto latency tuning in favor of simpler impleentation in pa_oboe.cpp

* Set paFloat32 as default format in pa_oboe.cpp

* Renamed most of the variables according to best coding practices.

* Added separate callback class to fix the single-stream issue.

* Modified OboeEngine accordingly

* Adjusted the code in the rest of pa_oboe.cpp

* Removed stop and close phases of OboeEngine::restartStream

* Updated functions' description

* minor description corrections

* fixed all compiling errors generated by typos

* Added OboeMediator class in place of OboeCallback, that mediates PortAudio C stream struct and the C++ OboeEngine class

* Fixed allocation problem, working PaOboe implementation

* fixed README.md indenting

* Removed .idea folder from repo

* replaced 'g_' with 'paOboe_' in non-static global variables

* replaced 'm_' prefix with 'm' prefix

* fixed OboeEngine::tryStream as requested

* Changed names to improve readability, i.e. OboeStream -> PaOboeStream

* fixed all compiling errors generated by typos

* Fixed minor problem with TryStream

* fixed long line in FindOboe.cmake

* fixed typos in pa_oboe.cpp

* set to verbose some logs

* Fixed minor problem with TryStream

* fixed long line in FindOboe.cmake

* fixed typos in pa_oboe.cpp

* set to verbose some logs

* Better handling of format in paOboe, removed junk code from CMakeLists

* Improved readability of some variables

* Removed '#include oboe/Oboe.h' from pa_oboe.h, and modified host api implementation accordingly

* static cast fixes

---------

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Co-authored-by: Carlo Benfatti <benfatti@netresults.it>
Co-authored-by: hopefulGiupplo <116260612+hopefulGiupplo@users.noreply.github.com>
Co-authored-by: Carlo Bramini <30959007+carlo-bramini@users.noreply.github.com>
Co-authored-by: Etienne Dechamps <etienne@edechamps.fr>
Co-authored-by: Daniel Schürmann <daschuer@mixxx.org>
Co-authored-by: dmitrykos <dmitrykos@neutroncode.com>
Co-authored-by: Ross Bencina <rossb@audiomulch.com>
Co-authored-by: Tuukka Pasanen <pasanen.tuukka@gmail.com>
Co-authored-by: sqweek <sqweek@gmail.com>
Co-authored-by: Mooneer Salem <mooneer@gmail.com>
Co-authored-by: Be <be.0@gmx.com>
Co-authored-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Co-authored-by: Tuukka Pasanen <tuukka.pasanen@ilmi.fi>
Co-authored-by: invertego <invertego@users.noreply.github.com>
bear101 added a commit to bear101/portaudio that referenced this issue Mar 6, 2024
* Preparation to start patching - TODOS and directory src/hostapi/Oboe

* Added src/hostapi/oboe/README.md

* Added include/pa_oboe.h and src/hostapi/oboe/pa_oboe.cpp

* Added PA_USE_OBOE section to CMakeLists.txt

* Added PA_USE_OBOE section to CMakeLists.txt

* Heavily reworked CMake dependencies, added FindOboe.cmake, updated pa_oboe.cpp, more work needed

* Included build_all_PaOboe.sh, more work needed on CMake

* Included build_all_PaOboe.sh, more work needed on CMake

* Update src/hostapi/oboe/README.md

* bindings/cpp: CMake: support pkgconfig with RelWithDebInfo (PortAudio#822)

bindings/cpp: add  `RelWithDebInfo` to the configurations allowed to install portaudiocpp.pc, otherwise you won't have support for pkg-config when building a release package with separate debugging information. Besides that, RelWithDebInfo is identical to Release.

* Fix MSVC warning C4018 signed/unsigned mismatch (PortAudio#821)

See PortAudio#810

* Built shared library

* Polished bits

* mme: don't restrict the host buffer to 16-bit

Currently, the MME Host API code only creates 16-bit integer MME
buffers. All audio data provided by the user is therefore converted by
PortAudio to and from 16-bit, regardless of the user buffer format.

This basically makes it impossible to pass 24-bit audio through the
MME Host API.

If the user buffer format is not 16-bit, this also causes pointless
conversions to take place, *even if the hardware is running at 16-bit*,
because modern Windows versions (Vista+) convert the data to floating
point behind the scenes before it is handed off to the hardware. This
can lead to silly situations where 32-bit float samples from the user
are (lossily) converted to 16-bit by PortAudio, then ended off to
Windows via MME, only to be converted back to 32-bit float again, before
finally being converted to the format the hardware device is configured
to use. This can easily lead to two layers of 16-bit dithering (one from
PortAudio, and one from Windows) being piled on top of each other,
resulting in an elevated noise floor.

This commit fixes this problem by configuring the MME buffers to use the
same format as the user buffer. This should stop PortAudio from
converting samples in all cases except paInt8, which is not supported by
WAVEFORMATEX (only paUInt8 is). This is pretty much the same idea as

The new code assumes that MME will accept whatever format we throw at
it. I feel confident that this is always true on Vista+ regardless of
hardware, because starting from Vista MME does not access hardware
directly - it always goes through the Windows Audio Engine which
supports all formats in both directions (I verified this using
paloopback).

On pre-Vista Windows, this should still work all the way back to Windows
98 SE, because MME goes through KMixer which supports all formats [1].
Nevertheless, it's difficult to be sure, so this code checks the Windows
version it's running on and preserves the old behavior (i.e. always use
Int16) on pre-Vista Windows.

[1]: https://learn.microsoft.com/en-us/windows-hardware/drivers/audio/background-of-non-pcm-support#waveout-api

Fixes PortAudio#139

* Don't use absolute path when linking to macOS frameworks (PortAudio#829)

fixes PortAudio#828

* Fixing old problems

* Added some debug messages

* added new build script

* Added paOboe in the paHostApi array

* Added paOboe in pa_unix_hostapis.c

* Working patch

* win: New PaWinUtil_GetOsVersion() function for getting Windows OS version. Refactored WASAPI, DS, MME and WDMKS host back-ends to use PaWinUtil_GetOsVersion() instead of direct OS API.

* Ready for other users to compile/build

* Updated oboe/Readme.md

* Added sharing mode selection

* Fixed minor issue with sharing mode selection

* Removed references to KCTI

* Fixed error callback, added performance mode autoselection

* Minor change to CMakeLists, added low latency costant in pa_oboe.h

* Deleted Build_PaOboe.sh

* Ready to push (removed my paths to Oboe directory and Android NDK)

* Update README.md

* Update README.md

* remove all alternative sample conversion code using lrintf in pa_converters.c (PortAudio#403)

removes the code guarded by PA_USE_C99_LRINTF
See PortAudio#390

* updated readme

* fixed CMakeLists.txt

* fixed FindOboe.cmake

* Preparation to start patching - TODOS and directory src/hostapi/Oboe

* Added src/hostapi/oboe/README.md

* Added include/pa_oboe.h and src/hostapi/oboe/pa_oboe.cpp

* Added PA_USE_OBOE section to CMakeLists.txt

* Added PA_USE_OBOE section to CMakeLists.txt

* Heavily reworked CMake dependencies, added FindOboe.cmake, updated pa_oboe.cpp, more work needed

* Included build_all_PaOboe.sh, more work needed on CMake

* Included build_all_PaOboe.sh, more work needed on CMake

* Built shared library

* Polished bits

* Fixing old problems

* Added some debug messages

* added new build script

* Added paOboe in the paHostApi array

* Added paOboe in pa_unix_hostapis.c

* Working patch

* Ready for other users to compile/build

* Updated oboe/Readme.md

* Added sharing mode selection

* Fixed minor issue with sharing mode selection

* Removed references to KCTI

* Fixed error callback, added performance mode autoselection

* Minor change to CMakeLists, added low latency costant in pa_oboe.h

* Deleted Build_PaOboe.sh

* Ready to push (removed my paths to Oboe directory and Android NDK)

* Update src/hostapi/oboe/README.md

* Update README.md

* Update README.md

* updated readme

* fixed CMakeLists.txt

* fixed FindOboe.cmake

* corrected oboe/Readme.md

* Updated oboe/Readme.md

* PulseAudio Portaudio HostAPI (PortAudio#336)

Adds support for PulseAudio API on Linux.

For more information about Pulseaudio visit: https://www.freedesktop.org/wiki/Software/PulseAudio/

---------

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Co-authored-by: sqweek <sqweek@gmail.com>
Co-authored-by: Daniel Schürmann <daschuer@mixxx.org>
Co-authored-by: Mooneer Salem <mooneer@gmail.com>
Co-authored-by: Be <be.0@gmx.com>
Co-authored-by: Mario Kleiner <mario.kleiner.de@gmail.com>

* pulseaudio: Move Pulseaudio include in correct place when using autoconf (PortAudio#843)

As Jack and Pulseaudio both needs Ringbuffer that include can
be done in same place. In configure.in also Pulseaudio header
file was included before it was sure that it was really needed.

Commit makes sure that Pulseaudio include is available only if
it's needed as it can cause failing in build if Pulseaudio
develoment files are not available.

* added .idea to gitignore

* added .idea to gitignore

* restored workflows directory

* Minor fixes to FindOboe.cmake

* Enhanced prebuilt libraries compatibility in FindOboe.cmake

* Minor changes to Pa_Oboe/Readme and pa_oboe.cpp

* Removed auto latency tuning in favor of simpler impleentation in pa_oboe.cpp

* Set paFloat32 as default format in pa_oboe.cpp

* Renamed most of the variables according to best coding practices.

* Added separate callback class to fix the single-stream issue.

* Modified OboeEngine accordingly

* Adjusted the code in the rest of pa_oboe.cpp

* Removed stop and close phases of OboeEngine::restartStream

* Updated functions' description

* minor description corrections

* fixed all compiling errors generated by typos

* Added OboeMediator class in place of OboeCallback, that mediates PortAudio C stream struct and the C++ OboeEngine class

* Fixed allocation problem, working PaOboe implementation

* Fix 'pulseaudioHostApi' use-after-free/null ptr deref in PaPulseAudio_Initialize (PortAudio#847)

The call to PaPulseAudio_UnLock( pulseaudioHostApi->mainloop ) in error-label is performed on 'pulseaudioHostApi' after 'pulseaudioHostApi' has been freed by PaPulseAudio_Free and set to NULL.

* wdmks: declare GUIDs with selectany attribute (PortAudio#846)

* wdmks: declare GUIDs with selectany attribute

Match the behavior of guiddef.h in both mingw and the Windows SDK headers. This prevents linking errors caused by multiply defined symbols when linking against certain Windows SDK libs (like dxguid.lib).

* Make sure this works even if DECLSPEC_SELECTANY is not defined

---------

Co-authored-by: Ross Bencina <rossb@audiomulch.com>

* fixed README.md indenting

* Removed .idea folder from repo

* replaced 'g_' with 'paOboe_' in non-static global variables

* replaced 'm_' prefix with 'm' prefix

* fixed OboeEngine::tryStream as requested

* PulseAudio Portaudio HostAPI (PortAudio#336)

Adds support for PulseAudio API on Linux.

For more information about Pulseaudio visit: https://www.freedesktop.org/wiki/Software/PulseAudio/

---------

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Co-authored-by: sqweek <sqweek@gmail.com>
Co-authored-by: Daniel Schürmann <daschuer@mixxx.org>
Co-authored-by: Mooneer Salem <mooneer@gmail.com>
Co-authored-by: Be <be.0@gmx.com>
Co-authored-by: Mario Kleiner <mario.kleiner.de@gmail.com>

* pulseaudio: Move Pulseaudio include in correct place when using autoconf (PortAudio#843)

As Jack and Pulseaudio both needs Ringbuffer that include can
be done in same place. In configure.in also Pulseaudio header
file was included before it was sure that it was really needed.

Commit makes sure that Pulseaudio include is available only if
it's needed as it can cause failing in build if Pulseaudio
develoment files are not available.

* restored workflows directory

* Minor fixes to FindOboe.cmake

* Enhanced prebuilt libraries compatibility in FindOboe.cmake

* Minor changes to Pa_Oboe/Readme and pa_oboe.cpp

* Removed auto latency tuning in favor of simpler impleentation in pa_oboe.cpp

* Set paFloat32 as default format in pa_oboe.cpp

* Renamed most of the variables according to best coding practices.

* Added separate callback class to fix the single-stream issue.

* Modified OboeEngine accordingly

* Adjusted the code in the rest of pa_oboe.cpp

* Removed stop and close phases of OboeEngine::restartStream

* Updated functions' description

* minor description corrections

* fixed all compiling errors generated by typos

* Added OboeMediator class in place of OboeCallback, that mediates PortAudio C stream struct and the C++ OboeEngine class

* Fixed allocation problem, working PaOboe implementation

* fixed README.md indenting

* Removed .idea folder from repo

* replaced 'g_' with 'paOboe_' in non-static global variables

* replaced 'm_' prefix with 'm' prefix

* fixed OboeEngine::tryStream as requested

* Changed names to improve readability, i.e. OboeStream -> PaOboeStream

* fixed all compiling errors generated by typos

* Fixed minor problem with TryStream

* fixed long line in FindOboe.cmake

* fixed typos in pa_oboe.cpp

* set to verbose some logs

* Fixed minor problem with TryStream

* fixed long line in FindOboe.cmake

* fixed typos in pa_oboe.cpp

* set to verbose some logs

* Better handling of format in paOboe, removed junk code from CMakeLists

* Improved readability of some variables

* Removed '#include oboe/Oboe.h' from pa_oboe.h, and modified host api implementation accordingly

* static cast fixes

---------

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Co-authored-by: Carlo Benfatti <benfatti@netresults.it>
Co-authored-by: hopefulGiupplo <116260612+hopefulGiupplo@users.noreply.github.com>
Co-authored-by: Carlo Bramini <30959007+carlo-bramini@users.noreply.github.com>
Co-authored-by: Etienne Dechamps <etienne@edechamps.fr>
Co-authored-by: Daniel Schürmann <daschuer@mixxx.org>
Co-authored-by: dmitrykos <dmitrykos@neutroncode.com>
Co-authored-by: Ross Bencina <rossb@audiomulch.com>
Co-authored-by: Tuukka Pasanen <pasanen.tuukka@gmail.com>
Co-authored-by: sqweek <sqweek@gmail.com>
Co-authored-by: Mooneer Salem <mooneer@gmail.com>
Co-authored-by: Be <be.0@gmx.com>
Co-authored-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Co-authored-by: Tuukka Pasanen <tuukka.pasanen@ilmi.fi>
Co-authored-by: invertego <invertego@users.noreply.github.com>
bear101 added a commit to bear101/portaudio that referenced this issue Mar 6, 2024
* Preparation to start patching - TODOS and directory src/hostapi/Oboe

* Added src/hostapi/oboe/README.md

* Added include/pa_oboe.h and src/hostapi/oboe/pa_oboe.cpp

* Added PA_USE_OBOE section to CMakeLists.txt

* Added PA_USE_OBOE section to CMakeLists.txt

* Heavily reworked CMake dependencies, added FindOboe.cmake, updated pa_oboe.cpp, more work needed

* Included build_all_PaOboe.sh, more work needed on CMake

* Included build_all_PaOboe.sh, more work needed on CMake

* Update src/hostapi/oboe/README.md

* bindings/cpp: CMake: support pkgconfig with RelWithDebInfo (PortAudio#822)

bindings/cpp: add  `RelWithDebInfo` to the configurations allowed to install portaudiocpp.pc, otherwise you won't have support for pkg-config when building a release package with separate debugging information. Besides that, RelWithDebInfo is identical to Release.

* Fix MSVC warning C4018 signed/unsigned mismatch (PortAudio#821)

See PortAudio#810

* Built shared library

* Polished bits

* mme: don't restrict the host buffer to 16-bit

Currently, the MME Host API code only creates 16-bit integer MME
buffers. All audio data provided by the user is therefore converted by
PortAudio to and from 16-bit, regardless of the user buffer format.

This basically makes it impossible to pass 24-bit audio through the
MME Host API.

If the user buffer format is not 16-bit, this also causes pointless
conversions to take place, *even if the hardware is running at 16-bit*,
because modern Windows versions (Vista+) convert the data to floating
point behind the scenes before it is handed off to the hardware. This
can lead to silly situations where 32-bit float samples from the user
are (lossily) converted to 16-bit by PortAudio, then ended off to
Windows via MME, only to be converted back to 32-bit float again, before
finally being converted to the format the hardware device is configured
to use. This can easily lead to two layers of 16-bit dithering (one from
PortAudio, and one from Windows) being piled on top of each other,
resulting in an elevated noise floor.

This commit fixes this problem by configuring the MME buffers to use the
same format as the user buffer. This should stop PortAudio from
converting samples in all cases except paInt8, which is not supported by
WAVEFORMATEX (only paUInt8 is). This is pretty much the same idea as

The new code assumes that MME will accept whatever format we throw at
it. I feel confident that this is always true on Vista+ regardless of
hardware, because starting from Vista MME does not access hardware
directly - it always goes through the Windows Audio Engine which
supports all formats in both directions (I verified this using
paloopback).

On pre-Vista Windows, this should still work all the way back to Windows
98 SE, because MME goes through KMixer which supports all formats [1].
Nevertheless, it's difficult to be sure, so this code checks the Windows
version it's running on and preserves the old behavior (i.e. always use
Int16) on pre-Vista Windows.

[1]: https://learn.microsoft.com/en-us/windows-hardware/drivers/audio/background-of-non-pcm-support#waveout-api

Fixes PortAudio#139

* Don't use absolute path when linking to macOS frameworks (PortAudio#829)

fixes PortAudio#828

* Fixing old problems

* Added some debug messages

* added new build script

* Added paOboe in the paHostApi array

* Added paOboe in pa_unix_hostapis.c

* Working patch

* win: New PaWinUtil_GetOsVersion() function for getting Windows OS version. Refactored WASAPI, DS, MME and WDMKS host back-ends to use PaWinUtil_GetOsVersion() instead of direct OS API.

* Ready for other users to compile/build

* Updated oboe/Readme.md

* Added sharing mode selection

* Fixed minor issue with sharing mode selection

* Removed references to KCTI

* Fixed error callback, added performance mode autoselection

* Minor change to CMakeLists, added low latency costant in pa_oboe.h

* Deleted Build_PaOboe.sh

* Ready to push (removed my paths to Oboe directory and Android NDK)

* Update README.md

* Update README.md

* remove all alternative sample conversion code using lrintf in pa_converters.c (PortAudio#403)

removes the code guarded by PA_USE_C99_LRINTF
See PortAudio#390

* updated readme

* fixed CMakeLists.txt

* fixed FindOboe.cmake

* Preparation to start patching - TODOS and directory src/hostapi/Oboe

* Added src/hostapi/oboe/README.md

* Added include/pa_oboe.h and src/hostapi/oboe/pa_oboe.cpp

* Added PA_USE_OBOE section to CMakeLists.txt

* Added PA_USE_OBOE section to CMakeLists.txt

* Heavily reworked CMake dependencies, added FindOboe.cmake, updated pa_oboe.cpp, more work needed

* Included build_all_PaOboe.sh, more work needed on CMake

* Included build_all_PaOboe.sh, more work needed on CMake

* Built shared library

* Polished bits

* Fixing old problems

* Added some debug messages

* added new build script

* Added paOboe in the paHostApi array

* Added paOboe in pa_unix_hostapis.c

* Working patch

* Ready for other users to compile/build

* Updated oboe/Readme.md

* Added sharing mode selection

* Fixed minor issue with sharing mode selection

* Removed references to KCTI

* Fixed error callback, added performance mode autoselection

* Minor change to CMakeLists, added low latency costant in pa_oboe.h

* Deleted Build_PaOboe.sh

* Ready to push (removed my paths to Oboe directory and Android NDK)

* Update src/hostapi/oboe/README.md

* Update README.md

* Update README.md

* updated readme

* fixed CMakeLists.txt

* fixed FindOboe.cmake

* corrected oboe/Readme.md

* Updated oboe/Readme.md

* PulseAudio Portaudio HostAPI (PortAudio#336)

Adds support for PulseAudio API on Linux.

For more information about Pulseaudio visit: https://www.freedesktop.org/wiki/Software/PulseAudio/

---------

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Co-authored-by: sqweek <sqweek@gmail.com>
Co-authored-by: Daniel Schürmann <daschuer@mixxx.org>
Co-authored-by: Mooneer Salem <mooneer@gmail.com>
Co-authored-by: Be <be.0@gmx.com>
Co-authored-by: Mario Kleiner <mario.kleiner.de@gmail.com>

* pulseaudio: Move Pulseaudio include in correct place when using autoconf (PortAudio#843)

As Jack and Pulseaudio both needs Ringbuffer that include can
be done in same place. In configure.in also Pulseaudio header
file was included before it was sure that it was really needed.

Commit makes sure that Pulseaudio include is available only if
it's needed as it can cause failing in build if Pulseaudio
develoment files are not available.

* added .idea to gitignore

* added .idea to gitignore

* restored workflows directory

* Minor fixes to FindOboe.cmake

* Enhanced prebuilt libraries compatibility in FindOboe.cmake

* Minor changes to Pa_Oboe/Readme and pa_oboe.cpp

* Removed auto latency tuning in favor of simpler impleentation in pa_oboe.cpp

* Set paFloat32 as default format in pa_oboe.cpp

* Renamed most of the variables according to best coding practices.

* Added separate callback class to fix the single-stream issue.

* Modified OboeEngine accordingly

* Adjusted the code in the rest of pa_oboe.cpp

* Removed stop and close phases of OboeEngine::restartStream

* Updated functions' description

* minor description corrections

* fixed all compiling errors generated by typos

* Added OboeMediator class in place of OboeCallback, that mediates PortAudio C stream struct and the C++ OboeEngine class

* Fixed allocation problem, working PaOboe implementation

* Fix 'pulseaudioHostApi' use-after-free/null ptr deref in PaPulseAudio_Initialize (PortAudio#847)

The call to PaPulseAudio_UnLock( pulseaudioHostApi->mainloop ) in error-label is performed on 'pulseaudioHostApi' after 'pulseaudioHostApi' has been freed by PaPulseAudio_Free and set to NULL.

* wdmks: declare GUIDs with selectany attribute (PortAudio#846)

* wdmks: declare GUIDs with selectany attribute

Match the behavior of guiddef.h in both mingw and the Windows SDK headers. This prevents linking errors caused by multiply defined symbols when linking against certain Windows SDK libs (like dxguid.lib).

* Make sure this works even if DECLSPEC_SELECTANY is not defined

---------

Co-authored-by: Ross Bencina <rossb@audiomulch.com>

* fixed README.md indenting

* Removed .idea folder from repo

* replaced 'g_' with 'paOboe_' in non-static global variables

* replaced 'm_' prefix with 'm' prefix

* fixed OboeEngine::tryStream as requested

* PulseAudio Portaudio HostAPI (PortAudio#336)

Adds support for PulseAudio API on Linux.

For more information about Pulseaudio visit: https://www.freedesktop.org/wiki/Software/PulseAudio/

---------

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Co-authored-by: sqweek <sqweek@gmail.com>
Co-authored-by: Daniel Schürmann <daschuer@mixxx.org>
Co-authored-by: Mooneer Salem <mooneer@gmail.com>
Co-authored-by: Be <be.0@gmx.com>
Co-authored-by: Mario Kleiner <mario.kleiner.de@gmail.com>

* pulseaudio: Move Pulseaudio include in correct place when using autoconf (PortAudio#843)

As Jack and Pulseaudio both needs Ringbuffer that include can
be done in same place. In configure.in also Pulseaudio header
file was included before it was sure that it was really needed.

Commit makes sure that Pulseaudio include is available only if
it's needed as it can cause failing in build if Pulseaudio
develoment files are not available.

* restored workflows directory

* Minor fixes to FindOboe.cmake

* Enhanced prebuilt libraries compatibility in FindOboe.cmake

* Minor changes to Pa_Oboe/Readme and pa_oboe.cpp

* Removed auto latency tuning in favor of simpler impleentation in pa_oboe.cpp

* Set paFloat32 as default format in pa_oboe.cpp

* Renamed most of the variables according to best coding practices.

* Added separate callback class to fix the single-stream issue.

* Modified OboeEngine accordingly

* Adjusted the code in the rest of pa_oboe.cpp

* Removed stop and close phases of OboeEngine::restartStream

* Updated functions' description

* minor description corrections

* fixed all compiling errors generated by typos

* Added OboeMediator class in place of OboeCallback, that mediates PortAudio C stream struct and the C++ OboeEngine class

* Fixed allocation problem, working PaOboe implementation

* fixed README.md indenting

* Removed .idea folder from repo

* replaced 'g_' with 'paOboe_' in non-static global variables

* replaced 'm_' prefix with 'm' prefix

* fixed OboeEngine::tryStream as requested

* Changed names to improve readability, i.e. OboeStream -> PaOboeStream

* fixed all compiling errors generated by typos

* Fixed minor problem with TryStream

* fixed long line in FindOboe.cmake

* fixed typos in pa_oboe.cpp

* set to verbose some logs

* Fixed minor problem with TryStream

* fixed long line in FindOboe.cmake

* fixed typos in pa_oboe.cpp

* set to verbose some logs

* Better handling of format in paOboe, removed junk code from CMakeLists

* Improved readability of some variables

* Removed '#include oboe/Oboe.h' from pa_oboe.h, and modified host api implementation accordingly

* static cast fixes

---------

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Co-authored-by: Carlo Benfatti <benfatti@netresults.it>
Co-authored-by: hopefulGiupplo <116260612+hopefulGiupplo@users.noreply.github.com>
Co-authored-by: Carlo Bramini <30959007+carlo-bramini@users.noreply.github.com>
Co-authored-by: Etienne Dechamps <etienne@edechamps.fr>
Co-authored-by: Daniel Schürmann <daschuer@mixxx.org>
Co-authored-by: dmitrykos <dmitrykos@neutroncode.com>
Co-authored-by: Ross Bencina <rossb@audiomulch.com>
Co-authored-by: Tuukka Pasanen <pasanen.tuukka@gmail.com>
Co-authored-by: sqweek <sqweek@gmail.com>
Co-authored-by: Mooneer Salem <mooneer@gmail.com>
Co-authored-by: Be <be.0@gmx.com>
Co-authored-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Co-authored-by: Tuukka Pasanen <tuukka.pasanen@ilmi.fi>
Co-authored-by: invertego <invertego@users.noreply.github.com>
@philburk philburk modified the milestones: V19.8, V19.9 May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 Priority: High src-common Common sources in /src/common
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants