From cd6b1868de2c74874ff978e7315027e291a55f59 Mon Sep 17 00:00:00 2001 From: philburk Date: Tue, 3 Mar 2015 17:28:15 +0000 Subject: [PATCH] Add version numbering with major.minor.subminor format. Bump version to 19.5.0 --- examples/pa_devs.c | 2 +- include/portaudio.h | 22 +++++++++++++++------- src/common/pa_front.c | 33 +++++++++++++++++++++++++++------ 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/examples/pa_devs.c b/examples/pa_devs.c index 42f8f9f..4d6324c 100644 --- a/examples/pa_devs.c +++ b/examples/pa_devs.c @@ -114,7 +114,7 @@ int main(void) goto error; } - printf( "PortAudio version number = %d\nPortAudio version text = '%s'\n", + printf( "PortAudio version number = 0x%08X\nPortAudio version text = '%s'\n", Pa_GetVersion(), Pa_GetVersionText() ); diff --git a/include/portaudio.h b/include/portaudio.h index 1d23233..6485958 100644 --- a/include/portaudio.h +++ b/include/portaudio.h @@ -50,18 +50,26 @@ extern "C" { #endif /* __cplusplus */ - -/** Retrieve the release number of the currently running PortAudio build, - eg 1900. -*/ +/** Retrieve the release number of the currently running PortAudio build. + * For example, for version "19.5.1" this will return 0x00130501. + */ int Pa_GetVersion( void ); - /** Retrieve a textual description of the current PortAudio build, - eg "PortAudio V19-devel 13 October 2002". -*/ + * eg "PortAudio V19.5.0-devel (built Mar 3 2015 09:16:35)". + * The format of the text may change so do not try to parse the returned string. + */ const char* Pa_GetVersionText( void ); +/** + * Generate a packed integer version number in the same format used + * by Pa_GetVersion(). Use this to compare a specified version number with + * the currently running version. For example: + * + * if (Pa_GetVersion() < paMakeVersionNumber(19.5.1)) {} + */ +#define paMakeVersionNumber(major, minor, subminor) \ + (((major)&0xFF)<<16 | ((minor)&0xFF)<<8 | ((subminor)&0xFF)) /** Error codes returned by PortAudio functions. Note that with the exception of paNoError, all PaErrorCodes are negative. diff --git a/src/common/pa_front.c b/src/common/pa_front.c index 4e4bb68..197516d 100644 --- a/src/common/pa_front.c +++ b/src/common/pa_front.c @@ -76,26 +76,47 @@ #include "pa_trace.h" /* still usefull?*/ #include "pa_debugprint.h" +/** + * This is incremented if we make incompatible API changes. + * This version scheme is based loosely on http://semver.org/ + */ +#define paVersionMajor 19 + +/** + * This is incremented when we add functionality in a backwards-compatible manner. + * Or it is set to zero when paVersionMajor is incremented. + */ +#define paVersionMinor 5 -#define PA_VERSION_ 1899 -#define PA_VERSION_TEXT_ "PortAudio V19-devel (built " __DATE__ " " __TIME__ ")" +/** + * This is incremented when we make backwards-compatible bug fixes. + * Or it is set to zero when paVersionMinor changes. + */ +#define paVersionSubMinor 0 +/** + * This is a combination of paVersionMajor, paVersionMinor and paVersionSubMinor. + * It will always increase so that version numbers can be compared as integers to + * see which is later. + */ +#define paVersion paMakeVersionNumber(paVersionMajor, paVersionMinor, paVersionSubMinor) +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) +#define PA_VERSION_STRING_ TOSTRING(paVersionMajor) "." TOSTRING(paVersionMinor) "." TOSTRING(paVersionSubMinor) +#define PA_VERSION_TEXT_ "PortAudio V" PA_VERSION_STRING_ "-devel (built " __DATE__ " " __TIME__ ")" int Pa_GetVersion( void ) { - return PA_VERSION_; + return paVersion; } - const char* Pa_GetVersionText( void ) { return PA_VERSION_TEXT_; } - - #define PA_LAST_HOST_ERROR_TEXT_LENGTH_ 1024 static char lastHostErrorText_[ PA_LAST_HOST_ERROR_TEXT_LENGTH_ + 1 ] = {0}; -- 2.43.0