Merged WaveRT branch (excluding stuff pertaining to ticket #169)
This commit is contained in:
parent
de1d97419b
commit
c5874f23c4
7 changed files with 5211 additions and 1704 deletions
|
|
@ -46,12 +46,16 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include "pa_trace.h"
|
||||
#include "pa_util.h"
|
||||
#include "pa_debugprint.h"
|
||||
|
||||
#if PA_TRACE_REALTIME_EVENTS
|
||||
|
||||
static char *traceTextArray[PA_MAX_TRACE_RECORDS];
|
||||
static char const *traceTextArray[PA_MAX_TRACE_RECORDS];
|
||||
static int traceIntArray[PA_MAX_TRACE_RECORDS];
|
||||
static int traceIndex = 0;
|
||||
static int traceBlock = 0;
|
||||
|
|
@ -94,4 +98,133 @@ void PaUtil_AddTraceMessage( const char *msg, int data )
|
|||
}
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
/* High performance log alternative */
|
||||
/************************************************************************/
|
||||
|
||||
typedef unsigned long long PaUint64;
|
||||
|
||||
typedef struct __PaHighPerformanceLog
|
||||
{
|
||||
unsigned magik;
|
||||
int writePtr;
|
||||
int readPtr;
|
||||
int size;
|
||||
double refTime;
|
||||
char* data;
|
||||
} PaHighPerformanceLog;
|
||||
|
||||
static const unsigned kMagik = 0xcafebabe;
|
||||
|
||||
#define USEC_PER_SEC (1000000ULL)
|
||||
|
||||
int PaUtil_InitializeHighSpeedLog( LogHandle* phLog, unsigned maxSizeInBytes )
|
||||
{
|
||||
PaHighPerformanceLog* pLog = (PaHighPerformanceLog*)PaUtil_AllocateMemory(sizeof(PaHighPerformanceLog));
|
||||
if (pLog == 0)
|
||||
{
|
||||
return paInsufficientMemory;
|
||||
}
|
||||
assert(phLog != 0);
|
||||
*phLog = pLog;
|
||||
|
||||
pLog->data = (char*)PaUtil_AllocateMemory(maxSizeInBytes);
|
||||
if (pLog->data == 0)
|
||||
{
|
||||
PaUtil_FreeMemory(pLog);
|
||||
return paInsufficientMemory;
|
||||
}
|
||||
pLog->magik = kMagik;
|
||||
pLog->size = maxSizeInBytes;
|
||||
pLog->refTime = PaUtil_GetTime();
|
||||
return paNoError;
|
||||
}
|
||||
|
||||
void PaUtil_ResetHighSpeedLogTimeRef( LogHandle hLog )
|
||||
{
|
||||
PaHighPerformanceLog* pLog = (PaHighPerformanceLog*)hLog;
|
||||
assert(pLog->magik == kMagik);
|
||||
pLog->refTime = PaUtil_GetTime();
|
||||
}
|
||||
|
||||
typedef struct __PaLogEntryHeader
|
||||
{
|
||||
int size;
|
||||
double timeStamp;
|
||||
} PaLogEntryHeader;
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define _vsnprintf vsnprintf
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
#endif
|
||||
|
||||
|
||||
int PaUtil_AddHighSpeedLogMessage( LogHandle hLog, const char* fmt, ... )
|
||||
{
|
||||
va_list l;
|
||||
int n = 0;
|
||||
PaHighPerformanceLog* pLog = (PaHighPerformanceLog*)hLog;
|
||||
if (pLog != 0)
|
||||
{
|
||||
PaLogEntryHeader* pHeader;
|
||||
char* p;
|
||||
int maxN;
|
||||
assert(pLog->magik == kMagik);
|
||||
pHeader = (PaLogEntryHeader*)( pLog->data + pLog->writePtr );
|
||||
p = (char*)( pHeader + 1 );
|
||||
maxN = pLog->size - pLog->writePtr - 2 * sizeof(PaLogEntryHeader);
|
||||
|
||||
pHeader->timeStamp = PaUtil_GetTime() - pLog->refTime;
|
||||
if (maxN > 0)
|
||||
{
|
||||
if (maxN > 32)
|
||||
{
|
||||
va_start(l, fmt);
|
||||
n = _vsnprintf(p, min(1024, maxN), fmt, l);
|
||||
va_end(l);
|
||||
}
|
||||
else {
|
||||
n = sprintf(p, "End of log...");
|
||||
}
|
||||
n = ((n + sizeof(unsigned)) & ~(sizeof(unsigned)-1)) + sizeof(PaLogEntryHeader);
|
||||
pHeader->size = n;
|
||||
#if 0
|
||||
PaUtil_DebugPrint("%05u.%03u: %s\n", pHeader->timeStamp/1000, pHeader->timeStamp%1000, p);
|
||||
#endif
|
||||
pLog->writePtr += n;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
void PaUtil_DumpHighSpeedLog( LogHandle hLog, const char* fileName )
|
||||
{
|
||||
FILE* f = (fileName != NULL) ? fopen(fileName, "w") : stdout;
|
||||
unsigned localWritePtr;
|
||||
PaHighPerformanceLog* pLog = (PaHighPerformanceLog*)hLog;
|
||||
assert(pLog->magik == kMagik);
|
||||
localWritePtr = pLog->writePtr;
|
||||
while (pLog->readPtr != localWritePtr)
|
||||
{
|
||||
const PaLogEntryHeader* pHeader = (const PaLogEntryHeader*)( pLog->data + pLog->readPtr );
|
||||
const char* p = (const char*)( pHeader + 1 );
|
||||
const PaUint64 ts = (const PaUint64)( pHeader->timeStamp * USEC_PER_SEC );
|
||||
assert(pHeader->size < (1024+sizeof(unsigned)+sizeof(PaLogEntryHeader)));
|
||||
fprintf(f, "%05u.%03u: %s\n", (unsigned)(ts/1000), (unsigned)(ts%1000), p);
|
||||
pLog->readPtr += pHeader->size;
|
||||
}
|
||||
if (f != stdout)
|
||||
{
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
void PaUtil_DiscardHighSpeedLog( LogHandle hLog )
|
||||
{
|
||||
PaHighPerformanceLog* pLog = (PaHighPerformanceLog*)hLog;
|
||||
assert(pLog->magik == kMagik);
|
||||
PaUtil_FreeMemory(pLog->data);
|
||||
PaUtil_FreeMemory(pLog);
|
||||
}
|
||||
|
||||
#endif /* TRACE_REALTIME_EVENTS */
|
||||
|
|
|
|||
|
|
@ -84,13 +84,29 @@ extern "C"
|
|||
void PaUtil_ResetTraceMessages();
|
||||
void PaUtil_AddTraceMessage( const char *msg, int data );
|
||||
void PaUtil_DumpTraceMessages();
|
||||
|
||||
|
||||
/* Alternative interface */
|
||||
|
||||
typedef void* LogHandle;
|
||||
|
||||
int PaUtil_InitializeHighSpeedLog(LogHandle* phLog, unsigned maxSizeInBytes);
|
||||
void PaUtil_ResetHighSpeedLogTimeRef(LogHandle hLog);
|
||||
int PaUtil_AddHighSpeedLogMessage(LogHandle hLog, const char* fmt, ...);
|
||||
void PaUtil_DumpHighSpeedLog(LogHandle hLog, const char* fileName);
|
||||
void PaUtil_DiscardHighSpeedLog(LogHandle hLog);
|
||||
|
||||
#else
|
||||
|
||||
#define PaUtil_ResetTraceMessages() /* noop */
|
||||
#define PaUtil_AddTraceMessage(msg,data) /* noop */
|
||||
#define PaUtil_DumpTraceMessages() /* noop */
|
||||
|
||||
#define PaUtil_InitializeHighSpeedLog(phLog, maxSizeInBytes) (0)
|
||||
#define PaUtil_ResetHighSpeedLogTimeRef(hLog)
|
||||
#define PaUtil_AddHighSpeedLogMessage(...) (0)
|
||||
#define PaUtil_DumpHighSpeedLog(hLog, fileName)
|
||||
#define PaUtil_DiscardHighSpeedLog(hLog)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -3,12 +3,15 @@ Notes about WDM-KS host API
|
|||
|
||||
Status history
|
||||
--------------
|
||||
16th January 2011:
|
||||
Added support for WaveRT device API (Vista and later) for even lesser
|
||||
latency support.
|
||||
|
||||
10th November 2005:
|
||||
Made following changes:
|
||||
* OpenStream: Try all PaSampleFormats internally if the the chosen
|
||||
format is not supported natively. This fixed several problems
|
||||
with soundcards that soundcards that did not take kindly to
|
||||
using 24-bit 3-byte formats.
|
||||
with soundcards that did not take kindly to using 24-bit 3-byte formats.
|
||||
* OpenStream: Make the minimum framesPerHostIBuffer (and framesPerHostOBuffer)
|
||||
the default frameSize for the playback/recording pin.
|
||||
* ProcessingThread: Added a switch to only call PaUtil_EndBufferProcessing
|
||||
|
|
@ -71,7 +74,7 @@ In PortAudio terms, this means having a stream Open on a WDMKS device.
|
|||
Usage
|
||||
-----
|
||||
To add the WDMKS backend to your program which is already using
|
||||
PortAudio, you must undefine PA_NO_WDMKS from your build file,
|
||||
PortAudio, you must define PA_USE_WDMKS=1 in your build file,
|
||||
and include the pa_win_wdmks\pa_win_wdmks.c into your build.
|
||||
The file should compile in both C and C++.
|
||||
You will need a DirectX SDK installed on your system for the
|
||||
|
|
@ -79,4 +82,4 @@ ks.h and ksmedia.h header files.
|
|||
You will need to link to the system "setupapi" library.
|
||||
Note that if you use MinGW, you will get more warnings from
|
||||
the DX header files when using GCC(C), and still a few warnings
|
||||
with G++(CPP).
|
||||
with G++(CPP).
|
||||
|
|
|
|||
Loading…
Reference in a new issue