Commit 18e828d7 authored by robiwan's avatar robiwan

Merged WaveRT branch (excluding stuff pertaining to ticket #169)

git-svn-id: https://subversion.assembla.com/svn/portaudio/portaudio/trunk@1812 0f58301d-fd10-0410-b4af-bbb618454e57
parent d3d9b42a
......@@ -7,12 +7,17 @@ PROJECT( portaudio )
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
OPTION(PORTAUDIO_CONFIG_LIB_OUTPUT_PATH "Make sure that output paths are kept neat" OFF)
IF(CMAKE_CL_64)
SET(TARGET_POSTFIX x64)
IF(PORTAUDIO_CONFIG_LIB_OUTPUT_PATH)
SET(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin/x64)
ENDIF(PORTAUDIO_CONFIG_LIB_OUTPUT_PATH)
ELSE(CMAKE_CL_64)
SET(TARGET_POSTFIX x86)
IF(PORTAUDIO_CONFIG_LIB_OUTPUT_PATH)
SET(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin/Win32)
ENDIF(PORTAUDIO_CONFIG_LIB_OUTPUT_PATH)
ENDIF(CMAKE_CL_64)
IF(WIN32 AND MSVC)
......@@ -316,7 +321,6 @@ SET_TARGET_PROPERTIES(portaudio_static PROPERTIES OUTPUT_NAME portaudio_static_$
ENDIF(WIN32)
OPTION(PORTAUDIO_BUILD_TESTS "Include test projects" OFF)
MARK_AS_ADVANCED(PORTAUDIO_BUILD_TESTS)
# Prepared for inclusion of test files
IF(PORTAUDIO_BUILD_TESTS)
......
#ifndef PA_WIN_WDMKS_H
#define PA_WIN_WDMKS_H
/*
* $Id$
* PortAudio Portable Real-Time Audio Library
* WDM/KS specific extensions
*
* Copyright (c) 1999-2007 Ross Bencina and Phil Burk
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
* they can be incorporated into the canonical version. It is also
* requested that these non-binding requests be included along with the
* license above.
*/
/** @file
@ingroup public_header
@brief WDM Kernel Streaming-specific PortAudio API extension header file.
*/
#include "portaudio.h"
#include <windows.h>
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
typedef struct PaWinWDMKSInfo{
unsigned long size; /**< sizeof(PaWinWDMKSInfo) */
PaHostApiTypeId hostApiType; /**< paWDMKS */
unsigned long version; /**< 1 */
/* The number of packets to use for WaveCyclic devices, range is [2, 8]. Set to zero for default value of 2. */
unsigned noOfPackets;
} PaWinWDMKSInfo;
typedef enum PaWDMKSType
{
Type_kNotUsed,
Type_kWaveCyclic,
Type_kWaveRT,
Type_kCnt,
} PaWDMKSType;
typedef enum PaWDMKSSubType
{
SubType_kUnknown,
SubType_kNotification,
SubType_kPolled,
SubType_kCnt,
} PaWDMKSSubType;
typedef struct PaWinWDMKSDeviceInfo {
wchar_t filterPath[MAX_PATH]; /**< KS filter path in Unicode! */
wchar_t topologyPath[MAX_PATH]; /**< Topology filter path in Unicode! */
PaWDMKSType streamingType;
GUID deviceProductGuid; /**< The product GUID of the device (if supported) */
} PaWinWDMKSDeviceInfo;
typedef struct PaWDMKSDirectionSpecificStreamInfo
{
PaDeviceIndex device;
unsigned channels; /**< No of channels the device is opened with */
unsigned framesPerHostBuffer; /**< No of frames of the device buffer */
int endpointPinId; /**< Endpoint pin ID (on topology filter if topologyName is not empty) */
int muxNodeId; /**< Only valid for input */
PaWDMKSSubType streamingSubType; /**< Not known until device is opened for streaming */
} PaWDMKSDirectionSpecificStreamInfo;
typedef struct PaWDMKSSpecificStreamInfo {
PaWDMKSDirectionSpecificStreamInfo input;
PaWDMKSDirectionSpecificStreamInfo output;
} PaWDMKSSpecificStreamInfo;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* PA_WIN_DS_H */
......@@ -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
......
This diff is collapsed.
......@@ -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).
\ No newline at end of file
with G++(CPP).
# Test projects
# Use the macro to add test projects
MACRO(ADD_TEST appl_name)
ADD_EXECUTABLE(${appl_name} "${appl_name}.c")
TARGET_LINK_LIBRARIES(${appl_name} portaudio_static)
ENDMACRO(ADD_TEST)
ADD_TEST(patest_longsine)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment