Browse Source

Bug fix in Core, Jack, ASIO, and DS for internal draining in INPUT mode only; Added some mutexes in DS to fix input-only errors; Added libraries to CMakeLists.txt for MinGW compile of WASAPI.

tags/4.1.1
Gary Scavone 11 years ago
parent
commit
9a920447e1
2 changed files with 37 additions and 17 deletions
  1. +3
    -1
      CMakeLists.txt
  2. +34
    -16
      RtAudio.cpp

+ 3
- 1
CMakeLists.txt View File

@@ -91,15 +91,17 @@ if (WIN32)
endif()

include_directories(include)
list(APPEND LINKLIBS dsound winmm ole32)
list(APPEND LINKLIBS winmm ole32)

if (AUDIO_WINDOWS_DS)
add_definitions(-D__WINDOWS_DS__)
message(STATUS "Using Windows DirectSound")
list(APPEND LINKLIBS dsound)
endif (AUDIO_WINDOWS_DS)
if (AUDIO_WINDOWS_WASAPI)
add_definitions(-D__WINDOWS_WASAPI__)
message(STATUS "Using Windows WASAPI")
list(APPEND LINKLIBS uuid ksuser)
endif (AUDIO_WINDOWS_WASAPI)
if (AUDIO_WINDOWS_ASIO)
list(APPEND rtaudio_SOURCES


+ 34
- 16
RtAudio.cpp View File

@@ -1682,11 +1682,12 @@ bool RtApiCore :: callbackEvent( AudioDeviceID deviceId,
}
}
}
}
if ( handle->drainCounter ) {
handle->drainCounter++;
goto unlock;
}
// Don't bother draining input
if ( handle->drainCounter ) {
handle->drainCounter++;
goto unlock;
}
AudioDeviceID inputDevice;
@@ -2572,11 +2573,12 @@ bool RtApiJack :: callbackEvent( unsigned long nframes )
memcpy( jackbuffer, &stream_.userBuffer[0][i*bufferBytes], bufferBytes );
}
}
}
if ( handle->drainCounter ) {
handle->drainCounter++;
goto unlock;
}
// Don't bother draining input
if ( handle->drainCounter ) {
handle->drainCounter++;
goto unlock;
}
if ( stream_.mode == INPUT || stream_.mode == DUPLEX ) {
@@ -3403,11 +3405,12 @@ bool RtApiAsio :: callbackEvent( long bufferIndex )
}
}
}
if ( handle->drainCounter ) {
handle->drainCounter++;
goto unlock;
}
// Don't bother draining input
if ( handle->drainCounter ) {
handle->drainCounter++;
goto unlock;
}
if ( stream_.mode == INPUT || stream_.mode == DUPLEX ) {
@@ -6063,6 +6066,8 @@ void RtApiDs :: stopStream()
stream_.state = STREAM_STOPPED;
MUTEX_LOCK( &stream_.mutex );
// Stop the buffer and clear memory
LPDIRECTSOUNDBUFFER buffer = (LPDIRECTSOUNDBUFFER) handle->buffer[0];
result = buffer->Stop();
@@ -6103,6 +6108,9 @@ void RtApiDs :: stopStream()
stream_.state = STREAM_STOPPED;
if ( stream_.mode != DUPLEX )
MUTEX_LOCK( &stream_.mutex );
result = buffer->Stop();
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::stopStream: error (" << getErrorString( result ) << ") stopping input buffer!";
@@ -6136,6 +6144,8 @@ void RtApiDs :: stopStream()
unlock:
timeEndPeriod( 1 ); // revert to normal scheduler frequency on lesser windows.
MUTEX_UNLOCK( &stream_.mutex );
if ( FAILED( result ) ) error( RtAudioError::SYSTEM_ERROR );
}
@@ -6222,6 +6232,12 @@ void RtApiDs :: callbackEvent()
char *buffer;
long bufferBytes;
MUTEX_LOCK( &stream_.mutex );
if ( stream_.state == STREAM_STOPPED ) {
MUTEX_UNLOCK( &stream_.mutex );
return;
}
if ( buffersRolling == false ) {
if ( stream_.mode == DUPLEX ) {
//assert( handle->dsBufferSize[0] == handle->dsBufferSize[1] );
@@ -6402,11 +6418,12 @@ void RtApiDs :: callbackEvent()
}
nextWritePointer = ( nextWritePointer + bufferSize1 + bufferSize2 ) % dsBufferSize;
handle->bufferPointer[0] = nextWritePointer;
}
if ( handle->drainCounter ) {
handle->drainCounter++;
goto unlock;
}
// Don't bother draining input
if ( handle->drainCounter ) {
handle->drainCounter++;
goto unlock;
}
if ( stream_.mode == INPUT || stream_.mode == DUPLEX ) {
@@ -6545,6 +6562,7 @@ void RtApiDs :: callbackEvent()
}
unlock:
MUTEX_UNLOCK( &stream_.mutex );
RtApi::tickStreamTime();
}


Loading…
Cancel
Save