Add Pa_GetVersionInfo()
Add scripts to update pa_svnrevision.h
This commit is contained in:
parent
05bcd37d1f
commit
199e88fa66
6 changed files with 81 additions and 8 deletions
12
clear_svnrevision.sh
Executable file
12
clear_svnrevision.sh
Executable file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Clear the SVN revision in the include file.
|
||||||
|
# This should be run before checking in code to SVN.
|
||||||
|
#
|
||||||
|
revision_filename=src/common/pa_svnrevision.h
|
||||||
|
|
||||||
|
# Update the include file with the current SVN revision.
|
||||||
|
echo "#define PA_SVN_REVISION unknown" > ${revision_filename}
|
||||||
|
|
||||||
|
echo ${revision_filename} now contains
|
||||||
|
cat ${revision_filename}
|
||||||
|
|
@ -113,11 +113,10 @@ int main(void)
|
||||||
printf( "ERROR: Pa_Initialize returned 0x%x\n", err );
|
printf( "ERROR: Pa_Initialize returned 0x%x\n", err );
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf( "PortAudio version: 0x%08X\n", Pa_GetVersion());
|
||||||
|
printf( "Version text: '%s'\n", Pa_GetVersionInfo()->versionText );
|
||||||
|
|
||||||
printf( "PortAudio version number = 0x%08X\nPortAudio version text = '%s'\n",
|
|
||||||
Pa_GetVersion(), Pa_GetVersionText() );
|
|
||||||
|
|
||||||
|
|
||||||
numDevices = Pa_GetDeviceCount();
|
numDevices = Pa_GetDeviceCount();
|
||||||
if( numDevices < 0 )
|
if( numDevices < 0 )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,9 @@ extern "C"
|
||||||
int Pa_GetVersion( void );
|
int Pa_GetVersion( void );
|
||||||
|
|
||||||
/** Retrieve a textual description of the current PortAudio build,
|
/** Retrieve a textual description of the current PortAudio build,
|
||||||
* eg "PortAudio V19.5.0-devel (built Mar 3 2015 09:16:35)".
|
* eg "PortAudio V19.5.0-devel, revision 1952M".
|
||||||
* The format of the text may change so do not try to parse the returned string.
|
* The format of the text may change so do not try to parse the returned string.
|
||||||
|
* @deprecated use PaVersionInfo() instead
|
||||||
*/
|
*/
|
||||||
const char* Pa_GetVersionText( void );
|
const char* Pa_GetVersionText( void );
|
||||||
|
|
||||||
|
|
@ -66,11 +67,36 @@ const char* Pa_GetVersionText( void );
|
||||||
* by Pa_GetVersion(). Use this to compare a specified version number with
|
* by Pa_GetVersion(). Use this to compare a specified version number with
|
||||||
* the currently running version. For example:
|
* the currently running version. For example:
|
||||||
*
|
*
|
||||||
* if (Pa_GetVersion() < paMakeVersionNumber(19.5.1)) {}
|
* if (Pa_GetVersion() < paMakeVersionNumber(19,5,1)) {}
|
||||||
*/
|
*/
|
||||||
#define paMakeVersionNumber(major, minor, subminor) \
|
#define paMakeVersionNumber(major, minor, subminor) \
|
||||||
(((major)&0xFF)<<16 | ((minor)&0xFF)<<8 | ((subminor)&0xFF))
|
(((major)&0xFF)<<16 | ((minor)&0xFF)<<8 | ((subminor)&0xFF))
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A structure containing the components of the version numbers.
|
||||||
|
*/
|
||||||
|
typedef struct PaVersionInfo {
|
||||||
|
int versionMajor;
|
||||||
|
int versionMinor;
|
||||||
|
int versionSubMinor;
|
||||||
|
/**
|
||||||
|
* This is currently the SVN revision but may change in the future.
|
||||||
|
* The versionControlRevision is updated by running a script before compiling code.
|
||||||
|
* If the update does not occur then this value may be less
|
||||||
|
* than the actual SVN revision number.
|
||||||
|
*/
|
||||||
|
const char *versionControlRevision;
|
||||||
|
/** Version as a string, for example "PortAudio V19.5.0-devel, revision 1952M" */
|
||||||
|
const char *versionText;
|
||||||
|
} PaVersionInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The structure that this points to is statically allocated.
|
||||||
|
* Do not attempt to free it or modify it.
|
||||||
|
*/
|
||||||
|
const PaVersionInfo* Pa_GetVersionInfo();
|
||||||
|
|
||||||
/** Error codes returned by PortAudio functions.
|
/** Error codes returned by PortAudio functions.
|
||||||
Note that with the exception of paNoError, all PaErrorCodes are negative.
|
Note that with the exception of paNoError, all PaErrorCodes are negative.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdlib.h> /* needed for strtol() */
|
||||||
#include <assert.h> /* needed by PA_VALIDATE_ENDIANNESS */
|
#include <assert.h> /* needed by PA_VALIDATE_ENDIANNESS */
|
||||||
|
|
||||||
#include "portaudio.h"
|
#include "portaudio.h"
|
||||||
|
|
@ -76,6 +77,10 @@
|
||||||
#include "pa_trace.h" /* still usefull?*/
|
#include "pa_trace.h" /* still usefull?*/
|
||||||
#include "pa_debugprint.h"
|
#include "pa_debugprint.h"
|
||||||
|
|
||||||
|
#ifndef PA_SVN_REVISION
|
||||||
|
#include "pa_svnrevision.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is incremented if we make incompatible API changes.
|
* This is incremented if we make incompatible API changes.
|
||||||
* This version scheme is based loosely on http://semver.org/
|
* This version scheme is based loosely on http://semver.org/
|
||||||
|
|
@ -104,8 +109,8 @@
|
||||||
#define STRINGIFY(x) #x
|
#define STRINGIFY(x) #x
|
||||||
#define TOSTRING(x) STRINGIFY(x)
|
#define TOSTRING(x) STRINGIFY(x)
|
||||||
|
|
||||||
#define PA_VERSION_STRING_ TOSTRING(paVersionMajor) "." TOSTRING(paVersionMinor) "." TOSTRING(paVersionSubMinor)
|
#define PA_VERSION_STRING_ TOSTRING(paVersionMajor) "." TOSTRING(paVersionMinor) "." TOSTRING(paVersionSubMinor)
|
||||||
#define PA_VERSION_TEXT_ "PortAudio V" PA_VERSION_STRING_ "-devel (built " __DATE__ " " __TIME__ ")"
|
#define PA_VERSION_TEXT_ "PortAudio V" PA_VERSION_STRING_ "-devel, revision " TOSTRING(PA_SVN_REVISION)
|
||||||
|
|
||||||
int Pa_GetVersion( void )
|
int Pa_GetVersion( void )
|
||||||
{
|
{
|
||||||
|
|
@ -117,6 +122,19 @@ const char* Pa_GetVersionText( void )
|
||||||
return PA_VERSION_TEXT_;
|
return PA_VERSION_TEXT_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PaVersionInfo versionInfo_ = {
|
||||||
|
.versionMajor = paVersionMajor,
|
||||||
|
.versionMinor = paVersionMinor,
|
||||||
|
.versionSubMinor = paVersionSubMinor,
|
||||||
|
.versionControlRevision = TOSTRING(PA_SVN_REVISION),
|
||||||
|
.versionText = PA_VERSION_TEXT_
|
||||||
|
};
|
||||||
|
|
||||||
|
const PaVersionInfo* Pa_GetVersionInfo()
|
||||||
|
{
|
||||||
|
return &versionInfo_;
|
||||||
|
}
|
||||||
|
|
||||||
#define PA_LAST_HOST_ERROR_TEXT_LENGTH_ 1024
|
#define PA_LAST_HOST_ERROR_TEXT_LENGTH_ 1024
|
||||||
|
|
||||||
static char lastHostErrorText_[ PA_LAST_HOST_ERROR_TEXT_LENGTH_ + 1 ] = {0};
|
static char lastHostErrorText_[ PA_LAST_HOST_ERROR_TEXT_LENGTH_ + 1 ] = {0};
|
||||||
|
|
|
||||||
1
src/common/pa_svnrevision.h
Normal file
1
src/common/pa_svnrevision.h
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
#define PA_SVN_REVISION unknown
|
||||||
17
update_svnrevision.sh
Executable file
17
update_svnrevision.sh
Executable file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Write the SVN revision to an include file.
|
||||||
|
# This should be run before compiling code on Linux or Macintosh.
|
||||||
|
#
|
||||||
|
revision_filename=src/common/pa_svnrevision.h
|
||||||
|
|
||||||
|
# Run svnversion first to make sure it is installed before corrupting the
|
||||||
|
# include file.
|
||||||
|
svnversion .
|
||||||
|
|
||||||
|
# Update the include file with the current SVN revision.
|
||||||
|
echo -n "#define PA_SVN_REVISION " > ${revision_filename}
|
||||||
|
svnversion . >> ${revision_filename}
|
||||||
|
|
||||||
|
echo ${revision_filename} now contains
|
||||||
|
cat ${revision_filename}
|
||||||
Loading…
Reference in a new issue