Browse Source

Added Wasapi code (though untested); Updates for better data format support in PulseAudio; Commented-out various unused function arguments in tests/ files.

tags/4.1.0
Gary Scavone 10 years ago
parent
commit
18e6f51260
8 changed files with 1595 additions and 190 deletions
  1. +1540
    -173
      RtAudio.cpp
  2. +39
    -1
      RtAudio.h
  3. +2
    -2
      tests/duplex.cpp
  4. +2
    -2
      tests/playraw.cpp
  5. +2
    -2
      tests/playsaw.cpp
  6. +2
    -2
      tests/record.cpp
  7. +6
    -6
      tests/testall.cpp
  8. +2
    -2
      tests/teststops.cpp

+ 1540
- 173
RtAudio.cpp
File diff suppressed because it is too large
View File


+ 39
- 1
RtAudio.h View File

@@ -270,6 +270,7 @@ class RtAudio
LINUX_OSS, /*!< The Linux Open Sound System API. */
UNIX_JACK, /*!< The Jack Low-Latency Audio Server API. */
MACOSX_CORE, /*!< Macintosh OS-X Core Audio API. */
WINDOWS_WASAPI, /*!< The Microsoft WASAPI API. */
WINDOWS_ASIO, /*!< The Steinberg Audio Stream I/O API. */
WINDOWS_DS, /*!< The Microsoft Direct Sound API. */
RTAUDIO_DUMMY /*!< A compilable but non-functional API. */
@@ -566,7 +567,7 @@ class RtAudio
};

// Operating system dependent thread functionality.
#if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__)
#if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__) || defined(__WINDOWS_WASAPI__)
#include <windows.h>
#include <process.h>

@@ -977,6 +978,43 @@ public:

#endif

#if defined(__WINDOWS_WASAPI__)

struct IMMDeviceEnumerator;

class RtApiWasapi : public RtApi
{
public:
RtApiWasapi();
~RtApiWasapi();

RtAudio::Api getCurrentApi( void ) { return RtAudio::WINDOWS_WASAPI; }
unsigned int getDeviceCount( void );
RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
unsigned int getDefaultOutputDevice( void );
unsigned int getDefaultInputDevice( void );
void closeStream( void );
void startStream( void );
void stopStream( void );
void abortStream( void );

private:
bool coInitialized_;
IMMDeviceEnumerator* deviceEnumerator_;

bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
unsigned int firstChannel, unsigned int sampleRate,
RtAudioFormat format, unsigned int* bufferSize,
RtAudio::StreamOptions* options );

static DWORD WINAPI runWasapiThread( void* wasapiPtr );
static DWORD WINAPI stopWasapiThread( void* wasapiPtr );
static DWORD WINAPI abortWasapiThread( void* wasapiPtr );
void wasapiThread();
};

#endif

#if defined(__LINUX_ALSA__)

class RtApiAlsa: public RtApi


+ 2
- 2
tests/duplex.cpp View File

@@ -48,8 +48,8 @@ void usage( void ) {
exit( 0 );
}

int inout( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
double streamTime, RtAudioStreamStatus status, void *data )
int inout( void *outputBuffer, void *inputBuffer, unsigned int /*nBufferFrames*/,
double /*streamTime*/, RtAudioStreamStatus status, void *data )
{
// Since the number of input and output channels is equal, we can do
// a simple buffer copy operation here.


+ 2
- 2
tests/playraw.cpp View File

@@ -70,8 +70,8 @@ struct OutputData {
};

// Interleaved buffers
int output( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
double streamTime, RtAudioStreamStatus status, void *data )
int output( void *outputBuffer, void * /*inputBuffer*/, unsigned int nBufferFrames,
double /*streamTime*/, RtAudioStreamStatus /*status*/, void *data )
{
OutputData *oData = (OutputData*) data;



+ 2
- 2
tests/playsaw.cpp View File

@@ -112,8 +112,8 @@ int saw( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,

#else // Use non-interleaved buffers

int saw( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
double streamTime, RtAudioStreamStatus status, void *data )
int saw( void *outputBuffer, void * /*inputBuffer*/, unsigned int nBufferFrames,
double /*streamTime*/, RtAudioStreamStatus status, void *data )
{
unsigned int i, j;
extern unsigned int channels;


+ 2
- 2
tests/record.cpp View File

@@ -67,8 +67,8 @@ struct InputData {
};

// Interleaved buffers
int input( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
double streamTime, RtAudioStreamStatus status, void *data )
int input( void * /*outputBuffer*/, void *inputBuffer, unsigned int nBufferFrames,
double /*streamTime*/, RtAudioStreamStatus /*status*/, void *data )
{
InputData *iData = (InputData *) data;



+ 6
- 6
tests/testall.cpp View File

@@ -32,8 +32,8 @@ void usage( void ) {
unsigned int channels;

// Interleaved buffers
int sawi( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
double streamTime, RtAudioStreamStatus status, void *data )
int sawi( void *outputBuffer, void * /*inputBuffer*/, unsigned int nBufferFrames,
double /*streamTime*/, RtAudioStreamStatus status, void *data )
{
unsigned int i, j;
extern unsigned int channels;
@@ -55,8 +55,8 @@ int sawi( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
}

// Non-interleaved buffers
int sawni( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
double streamTime, RtAudioStreamStatus status, void *data )
int sawni( void *outputBuffer, void * /*inputBuffer*/, unsigned int nBufferFrames,
double /*streamTime*/, RtAudioStreamStatus status, void *data )
{
unsigned int i, j;
extern unsigned int channels;
@@ -79,8 +79,8 @@ int sawni( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
return 0;
}

int inout( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
double streamTime, RtAudioStreamStatus status, void *data )
int inout( void *outputBuffer, void *inputBuffer, unsigned int /*nBufferFrames*/,
double /*streamTime*/, RtAudioStreamStatus status, void *data )
{
// Since the number of input and output channels is equal, we can do
// a simple buffer copy operation here.


+ 2
- 2
tests/teststops.cpp View File

@@ -51,8 +51,8 @@ struct MyData {
};
// Interleaved buffers
int pulse( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
double streamTime, RtAudioStreamStatus status, void *mydata )
int pulse( void *outputBuffer, void * /*inputBuffer*/, unsigned int nBufferFrames,
double /*streamTime*/, RtAudioStreamStatus status, void *mydata )
{
// Write out a pulse signal and ignore the input buffer.
unsigned int i, j;


Loading…
Cancel
Save