switch pa_win_hostapis.c to use PA_USE_* #defines instead of PA_NO_*
Consider using PA_USE_WMME etc instead of PA_NO_WMME to enable API support in pa_win_hostapis.c. This is what the Unix version does, we should be consistent.
Making this change will close-out #47 too.
The change involves:
- renaming the preprocessor variables in pa_win_hostapis.c
- modifying all build files (msvc, configure) to use the new flag formulation (grep for the old flags and work out the correct list)
Making this change will close-out #47 too.
The change involves:
- renaming the preprocessor variables in pa_win_hostapis.c
- modifying all build files (msvc, configure) to use the new flag formulation (grep for the old flags and work out the correct list)
Leave a comment
Note how the tutorial defines how one has to turn off ASIO and other APIs.
http://www.portaudio.com/trac/wiki/TutorialDir/Compile/Windows
http://www.portaudio.com/trac/wiki/TutorialDir/Compile/Windows
LIST-REVIEW results seem conclusive, we'll do it:
+1 from Robert Bielik and Thomas Blom
Phil points out:
> +1 Absolutely. I had to take special steps to disable ASIO when I wanted
> a simple build. This makes it harder for first time users. Note how it
> complicates this tutorial.
rossb says:
I think it's too risky to do this before SS2, so I've scheduled it for M1
+1 from Robert Bielik and Thomas Blom
Phil points out:
> +1 Absolutely. I had to take special steps to disable ASIO when I wanted
> a simple build. This makes it harder for first time users. Note how it
> complicates this tutorial.
rossb says:
I think it's too risky to do this before SS2, so I've scheduled it for M1
The new defines will be: PA_USE_ASIO, PA_USE_WMME, PA_USE_DIRECTSOUND, PA_USE_WASAPI and PA_USE_WDMKS. Also, to ease exclusion of ASIO, the compilation of ASIO SDK is wrapped in two added CPP files, so no change is required of the VS project settings other than removing PA_USE_ASIO. Also, a new project will be added (for static library) as well as a ReleaseMinDependency configuration that removes dependency on MS runtime libraries.
Dmitry Kostjuchenko wrote:
To my view this change will affect everybody who compiles PA in
non-standard way. To preserve compatibility I propose to do something
like this, in one of internal PA headers (pa_hostapi.h for example):
#ifdef PA_NO_SOMETHING
#pragma message("PortAudio: using obsolete PA_NO_SOMETHING,
consider PA_USE_SOMETHING instead.")
#undef PA_USE_SOMETHING
#else
#define PA_USE_SOMETHING
#endif
So, when project still uses PA_NO_SOMETHING, during compilation
compiler will issue a message, like this in MSVC:
------------------
1>PortAudio: using obsolete PA_NO_SOMETHING, consider PA_USE_SOMETHING instead.
------------------
To my view this change will affect everybody who compiles PA in
non-standard way. To preserve compatibility I propose to do something
like this, in one of internal PA headers (pa_hostapi.h for example):
#ifdef PA_NO_SOMETHING
#pragma message("PortAudio: using obsolete PA_NO_SOMETHING,
consider PA_USE_SOMETHING instead.")
#undef PA_USE_SOMETHING
#else
#define PA_USE_SOMETHING
#endif
So, when project still uses PA_NO_SOMETHING, during compilation
compiler will issue a message, like this in MSVC:
------------------
1>PortAudio: using obsolete PA_NO_SOMETHING, consider PA_USE_SOMETHING instead.
------------------
(The above) Will unfortunately be a problem with new projects (which do use PA_USE_SOMETHING): If you really don't want to use that SOMETHING, then
the above scheme will define PA_USE_SOMETHING (since PA_NO_SOMETHING is undefined), but since I didn't define PA_USE_SOMETHING from
the start, the end result will not be what I want.
The only way I see it is to enforce setting PA_USE_SOMETHING to a value of 0 or 1 always, i.e. (the code below would reside in pa_hostapi.h)
#ifdef PA_NO_SOMETHING
#pragma message("Portaudio: PA_NO_SOMETHING is deprecated")
#ifndef PA_USE_SOMETHING
#pragma message("Portaudio: PA_USE_SOMETHING not defined, using PA_USE_SOMETHING=0")
#define PA_USE_SOMETHING 0
#endif
#endif
#ifndef PA_USE_SOMETHING
#pragma message("Portaudio: PA_USE_SOMETHING not defined, using PA_USE_SOMETHING=1 (default)")
#define PA_USE_SOMETHING 1
#endif
Then where PA_USE_SOMETHING is used, we do:
#if PA_USE_SOMETHING
instead of
#ifdef PA_USE_SOMETHING
the above scheme will define PA_USE_SOMETHING (since PA_NO_SOMETHING is undefined), but since I didn't define PA_USE_SOMETHING from
the start, the end result will not be what I want.
The only way I see it is to enforce setting PA_USE_SOMETHING to a value of 0 or 1 always, i.e. (the code below would reside in pa_hostapi.h)
#ifdef PA_NO_SOMETHING
#pragma message("Portaudio: PA_NO_SOMETHING is deprecated")
#ifndef PA_USE_SOMETHING
#pragma message("Portaudio: PA_USE_SOMETHING not defined, using PA_USE_SOMETHING=0")
#define PA_USE_SOMETHING 0
#endif
#endif
#ifndef PA_USE_SOMETHING
#pragma message("Portaudio: PA_USE_SOMETHING not defined, using PA_USE_SOMETHING=1 (default)")
#define PA_USE_SOMETHING 1
#endif
Then where PA_USE_SOMETHING is used, we do:
#if PA_USE_SOMETHING
instead of
#ifdef PA_USE_SOMETHING
Feedback on latest diff (pa_ticket_#132_cmake.diff)
- CMakeLists.txt should have instructions at top with how to run it.
- pa_hostapi.h: Not sure what's going on with PA_USE_SOMETHING since earlier diff (pa_ticket_#132.diff). you seem to be assuming that it's 0 or 1 (use of #if not #ifdef in impl files) but pa_hostapis.h diff no longer contains code to default it to zero if it's undefined.
- Comment on latest pa_ticket_#132.diff: Not sure we should be warning if PA_USE_SOMETHING is undefined. I don't think gcc has #pragma message() .. you could check. It has #warning though.
- rename:
src/hostapi/asio/pa_asiosdk_code1.cpp -> src/hostapi/asio/pa_asiosdk_asiolist.cpp
src/hostapi/asio/pa_asiosdk_code2.cpp -> src/hostapi/asio/pa_asiosdk_asiodrivers.cpp
move to /build/msvc too?
- build/msvc/readme.txt:
- probably not worth saying "NOTE: MSVC6 support is dropped." in the readme. It's not like we're dropping support for building on msvc6, we're just not shipping a project file.
- processor pack reference i think needs to be annotated with "(for MSVC6)"
- probably best to add your name to the readme as well as davids.. if you feel like it. Or at least delete David's email address.
- CMakeLists.txt should have instructions at top with how to run it.
- pa_hostapi.h: Not sure what's going on with PA_USE_SOMETHING since earlier diff (pa_ticket_#132.diff). you seem to be assuming that it's 0 or 1 (use of #if not #ifdef in impl files) but pa_hostapis.h diff no longer contains code to default it to zero if it's undefined.
- Comment on latest pa_ticket_#132.diff: Not sure we should be warning if PA_USE_SOMETHING is undefined. I don't think gcc has #pragma message() .. you could check. It has #warning though.
- rename:
src/hostapi/asio/pa_asiosdk_code1.cpp -> src/hostapi/asio/pa_asiosdk_asiolist.cpp
src/hostapi/asio/pa_asiosdk_code2.cpp -> src/hostapi/asio/pa_asiosdk_asiodrivers.cpp
move to /build/msvc too?
- build/msvc/readme.txt:
- probably not worth saying "NOTE: MSVC6 support is dropped." in the readme. It's not like we're dropping support for building on msvc6, we're just not shipping a project file.
- processor pack reference i think needs to be annotated with "(for MSVC6)"
- probably best to add your name to the readme as well as davids.. if you feel like it. Or at least delete David's email address.
Replying to [comment:15 rossb]:
>
>
> Feedback on latest diff (pa_ticket_#132_cmake.diff)
>
> - CMakeLists.txt should have instructions at top with how to run it.
Yes, will be included.
> - pa_hostapi.h: Not sure what's going on with PA_USE_SOMETHING since earlier diff (pa_ticket_#132.diff). you seem to be assuming that it's 0 or 1 (use of #if not #ifdef in impl files) but pa_hostapis.h diff no longer contains code to default it to zero if it's undefined.
Sorry, my bad, disappeared when reverting for doing the CMake file. Those are now back acc. to your idea.
> - Comment on latest pa_ticket_#132.diff: Not sure we should be warning if PA_USE_SOMETHING is undefined. I don't think gcc has #pragma message() .. you could check. It has #warning though.
Hmm... I think we'll now settle on not warning, since its a bit cumbersome to do the compile warnings work on all platforms.
> - rename:
> src/hostapi/asio/pa_asiosdk_code1.cpp -> src/hostapi/asio/pa_asiosdk_asiolist.cpp
> src/hostapi/asio/pa_asiosdk_code2.cpp -> src/hostapi/asio/pa_asiosdk_asiodrivers.cpp
>
> move to /build/msvc too?
With the CMake solution, those files are no longer needed.
> - build/msvc/readme.txt:
>
> - probably not worth saying "NOTE: MSVC6 support is dropped." in the readme. It's not like we're dropping support for building on msvc6, we're just not shipping a project file.
>
> - processor pack reference i think needs to be annotated with "(for MSVC6)"
Oki.
> - probably best to add your name to the readme as well as davids.. if you feel like it. Or at least delete David's email address.
Ok, I'll add my name/email at bottom.
>
>
> Feedback on latest diff (pa_ticket_#132_cmake.diff)
>
> - CMakeLists.txt should have instructions at top with how to run it.
Yes, will be included.
> - pa_hostapi.h: Not sure what's going on with PA_USE_SOMETHING since earlier diff (pa_ticket_#132.diff). you seem to be assuming that it's 0 or 1 (use of #if not #ifdef in impl files) but pa_hostapis.h diff no longer contains code to default it to zero if it's undefined.
Sorry, my bad, disappeared when reverting for doing the CMake file. Those are now back acc. to your idea.
> - Comment on latest pa_ticket_#132.diff: Not sure we should be warning if PA_USE_SOMETHING is undefined. I don't think gcc has #pragma message() .. you could check. It has #warning though.
Hmm... I think we'll now settle on not warning, since its a bit cumbersome to do the compile warnings work on all platforms.
> - rename:
> src/hostapi/asio/pa_asiosdk_code1.cpp -> src/hostapi/asio/pa_asiosdk_asiolist.cpp
> src/hostapi/asio/pa_asiosdk_code2.cpp -> src/hostapi/asio/pa_asiosdk_asiodrivers.cpp
>
> move to /build/msvc too?
With the CMake solution, those files are no longer needed.
> - build/msvc/readme.txt:
>
> - probably not worth saying "NOTE: MSVC6 support is dropped." in the readme. It's not like we're dropping support for building on msvc6, we're just not shipping a project file.
>
> - processor pack reference i think needs to be annotated with "(for MSVC6)"
Oki.
> - probably best to add your name to the readme as well as davids.. if you feel like it. Or at least delete David's email address.
Ok, I'll add my name/email at bottom.
New CMake diff added which adds support for autoconfig of ASIO SDK and Direct X SDK if they are present + fixing the stuff Ross mentions above. The CMakeLists.txt file refers to a tutorial under http://www.portaudio.com/trac/wiki/TutorialDir/Compile/CMake which thus should be created when this patch is commited.
Two things:
1. comment at line 52 of src/common/pa_hostapi.h implies that the PA_USE_* macros need to be defined. They don't. I suggest:
{{{
/**
The PA_NO_* host API macros are now deprecated in favor of PA_USE_* macros.
PA_USE_* indicates whether a particular host API will be initialized by PortAudio.
An undefined or 0 value indicates that the host API will not be used. A value of 1
indicates that the host API will be used. PA_USE_* macros should be left undefined
or defined to either 0 or 1.
The code below ensures that PA_USE_* macros are always defined and have value
0 or 1. Undefined symbols are defaulted to 0. Symbols that are neither 0 nor 1
are defaulted to 1.
*/
}}}
2. #error at src/hostapi/dsound/pa_win_ds.c says "Portaudio: PA_USE_WMME=0/1 not defined". This should probably be revised to indicate that it's an internal error. Something like:
{{{
"Portaudio internal error: PA_USE_WMME=0/1 not defined. pa_hostapi.h should ensure that it is."
}}}
Aside from that it looks good to me.
1. comment at line 52 of src/common/pa_hostapi.h implies that the PA_USE_* macros need to be defined. They don't. I suggest:
{{{
/**
The PA_NO_* host API macros are now deprecated in favor of PA_USE_* macros.
PA_USE_* indicates whether a particular host API will be initialized by PortAudio.
An undefined or 0 value indicates that the host API will not be used. A value of 1
indicates that the host API will be used. PA_USE_* macros should be left undefined
or defined to either 0 or 1.
The code below ensures that PA_USE_* macros are always defined and have value
0 or 1. Undefined symbols are defaulted to 0. Symbols that are neither 0 nor 1
are defaulted to 1.
*/
}}}
2. #error at src/hostapi/dsound/pa_win_ds.c says "Portaudio: PA_USE_WMME=0/1 not defined". This should probably be revised to indicate that it's an internal error. Something like:
{{{
"Portaudio internal error: PA_USE_WMME=0/1 not defined. pa_hostapi.h should ensure that it is."
}}}
Aside from that it looks good to me.