diff options
| author | Gary Scavone <gary@music.mcgill.ca> | 2011-02-17 21:26:23 +0000 |
|---|---|---|
| committer | Stephen Sinclair <sinclair@music.mcgill.ca> | 2013-10-11 01:38:27 +0200 |
| commit | 24a98a1971301e582dc56ef2c6ac94c342b674dd (patch) | |
| tree | 8b9aa705b0fd522cd0231f79f25a6cbcde8f06b2 /RtAudio.cpp | |
| parent | 3a4fb410cf0be7a7f4fc3777a15b104d8091f3b5 (diff) | |
Various changes in preparation for release 4.0.8
including fix of MinGW ASIO compile problem (iasiothiscallresolver),
OS-X problem handling device names in some languages (CFString
conversion), small change to OS-X MUTEX lock location to avoid
lockups, and correction to documentation regarding 24-bit data (should
be lower 3 bytes, not upper 3 bytes).
Diffstat (limited to 'RtAudio.cpp')
| -rw-r--r-- | RtAudio.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/RtAudio.cpp b/RtAudio.cpp index 9ac6c5b..028fffa 100644 --- a/RtAudio.cpp +++ b/RtAudio.cpp @@ -10,7 +10,7 @@ RtAudio WWW site: http://www.music.mcgill.ca/~gary/rtaudio/ RtAudio: realtime audio i/o C++ classes - Copyright (c) 2001-2010 Gary P. Scavone + Copyright (c) 2001-2011 Gary P. Scavone Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files @@ -38,7 +38,7 @@ */ /************************************************************************/ -// RtAudio: Version 4.0.7 +// RtAudio: Version 4.0.8 #include "RtAudio.h" #include <iostream> @@ -557,10 +557,14 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device ) return info; } - const char *mname = CFStringGetCStringPtr( cfname, CFStringGetSystemEncoding() ); + //const char *mname = CFStringGetCStringPtr( cfname, CFStringGetSystemEncoding() ); + int length = CFStringGetLength(cfname); + char *mname = (char *)malloc(length * 3 + 1); + CFStringGetCString(cfname, mname, length * 3 + 1, CFStringGetSystemEncoding()); info.name.append( (const char *)mname, strlen(mname) ); info.name.append( ": " ); CFRelease( cfname ); + free(mname); property.mSelector = kAudioObjectPropertyName; result = AudioObjectGetPropertyData( id, &property, 0, NULL, &dataSize, &cfname ); @@ -571,9 +575,13 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device ) return info; } - const char *name = CFStringGetCStringPtr( cfname, CFStringGetSystemEncoding() ); + //const char *name = CFStringGetCStringPtr( cfname, CFStringGetSystemEncoding() ); + length = CFStringGetLength(cfname); + char *name = (char *)malloc(length * 3 + 1); + CFStringGetCString(cfname, name, length * 3 + 1, CFStringGetSystemEncoding()); info.name.append( (const char *)name, strlen(name) ); CFRelease( cfname ); + free(name); // Get the output stream "configuration". AudioBufferList *bufferList = nil; @@ -1392,7 +1400,9 @@ void RtApiCore :: stopStream( void ) if ( stream_.mode == INPUT || ( stream_.mode == DUPLEX && stream_.device[0] != stream_.device[1] ) ) { + MUTEX_UNLOCK( &stream_.mutex ); result = AudioDeviceStop( handle->id[1], callbackHandler ); + MUTEX_LOCK( &stream_.mutex ); if ( result != noErr ) { errorStream_ << "RtApiCore::stopStream: system error (" << getErrorCode( result ) << ") stopping input callback procedure on device (" << stream_.device[1] << ")."; errorText_ = errorStream_.str(); @@ -1472,6 +1482,7 @@ bool RtApiCore :: callbackEvent( AudioDeviceID deviceId, status |= RTAUDIO_INPUT_OVERFLOW; handle->xrun[1] = false; } + handle->drainCounter = callback( stream_.userBuffer[0], stream_.userBuffer[1], stream_.bufferSize, streamTime, status, info->userData ); if ( handle->drainCounter == 2 ) { @@ -7393,7 +7404,7 @@ void RtApi :: convertBuffer( char *outBuffer, char *inBuffer, ConvertInfo &info { // This function does format conversion, input/output channel compensation, and // data interleaving/deinterleaving. 24-bit integers are assumed to occupy - // the upper three bytes of a 32-bit integer. + // the lower three bytes of a 32-bit integer. // Clear our device buffer when in/out duplex device channels are different if ( outBuffer == stream_.deviceBuffer && stream_.mode == DUPLEX && @@ -7581,7 +7592,7 @@ void RtApi :: convertBuffer( char *outBuffer, char *inBuffer, ConvertInfo &info out += info.outJump; } } - else if (info.inFormat == RTAUDIO_SINT24) { + else if (info.inFormat == RTAUDIO_SINT24) { // Hmmm ... we could just leave it in the lower 3 bytes Int32 *in = (Int32 *)inBuffer; for (unsigned int i=0; i<stream_.bufferSize; i++) { for (j=0; j<info.channels; j++) { |
