RtAudio WWW site: http://www.music.mcgill.ca/~gary/rtaudio/\r
\r
RtAudio: realtime audio i/o C++ classes\r
- Copyright (c) 2001-2014 Gary P. Scavone\r
+ Copyright (c) 2001-2016 Gary P. Scavone\r
\r
Permission is hereby granted, free of charge, to any person\r
obtaining a copy of this software and associated documentation files\r
*/\r
/************************************************************************/\r
\r
-// RtAudio: Version 4.1.1\r
+// RtAudio: Version 4.1.2\r
\r
#include "RtAudio.h"\r
#include <iostream>\r
\r
CoreHandle *handle = (CoreHandle *) stream_.apiHandle;\r
if ( stream_.mode == OUTPUT || stream_.mode == DUPLEX ) {\r
+ if (handle) {\r
+ AudioObjectPropertyAddress property = { kAudioHardwarePropertyDevices,\r
+ kAudioObjectPropertyScopeGlobal,\r
+ kAudioObjectPropertyElementMaster };\r
+\r
+ property.mSelector = kAudioDeviceProcessorOverload;\r
+ property.mScope = kAudioObjectPropertyScopeGlobal;\r
+ if (AudioObjectRemovePropertyListener( handle->id[0], &property, xrunListener, (void *) handle ) != noErr) {\r
+ errorText_ = "RtApiCore::closeStream(): error removing property listener!";\r
+ error( RtAudioError::WARNING );\r
+ }\r
+ }\r
if ( stream_.state == STREAM_RUNNING )\r
AudioDeviceStop( handle->id[0], callbackHandler );\r
#if defined( MAC_OS_X_VERSION_10_5 ) && ( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 )\r
}\r
\r
if ( stream_.mode == INPUT || ( stream_.mode == DUPLEX && stream_.device[0] != stream_.device[1] ) ) {\r
+ if (handle) {\r
+ AudioObjectPropertyAddress property = { kAudioHardwarePropertyDevices,\r
+ kAudioObjectPropertyScopeGlobal,\r
+ kAudioObjectPropertyElementMaster };\r
+\r
+ property.mSelector = kAudioDeviceProcessorOverload;\r
+ property.mScope = kAudioObjectPropertyScopeGlobal;\r
+ if (AudioObjectRemovePropertyListener( handle->id[1], &property, xrunListener, (void *) handle ) != noErr) {\r
+ errorText_ = "RtApiCore::closeStream(): error removing property listener!";\r
+ error( RtAudioError::WARNING );\r
+ }\r
+ }\r
if ( stream_.state == STREAM_RUNNING )\r
AudioDeviceStop( handle->id[1], callbackHandler );\r
#if defined( MAC_OS_X_VERSION_10_5 ) && ( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 )\r
// if the callback buffer was pushed renderBuffer reset callbackPulled flag\r
if ( callbackPushed ) {\r
callbackPulled = false;\r
+ // tick stream time\r
+ RtApi::tickStreamTime();\r
}\r
\r
- // tick stream time\r
- RtApi::tickStreamTime();\r
}\r
\r
Exit:\r
if ( FAILED( result ) ) {\r
errorStream_ << "RtApiDs::callbackEvent: error (" << getErrorString( result ) << ") getting current write position!";\r
errorText_ = errorStream_.str();\r
+ MUTEX_UNLOCK( &stream_.mutex );\r
error( RtAudioError::SYSTEM_ERROR );\r
return;\r
}\r
errorStream_ << "RtApiAlsa::callbackEvent: error preparing device after underrun, " << snd_strerror( result ) << ".";\r
errorText_ = errorStream_.str();\r
}\r
+ else\r
+ errorText_ = "RtApiAlsa::callbackEvent: audio write error, underrun.";\r
}\r
else {\r
errorStream_ << "RtApiAlsa::callbackEvent: error, current state is " << snd_pcm_state_name( state ) << ", " << snd_strerror( result ) << ".";\r
bool *isRunning = &info->isRunning;\r
\r
#ifdef SCHED_RR // Undefined with some OSes (eg: NetBSD 1.6.x with GNU Pthread)\r
- if ( &info->doRealtime ) {\r
+ if ( info->doRealtime ) {\r
pthread_t tID = pthread_self(); // ID of this thread\r
sched_param prio = { info->priority }; // scheduling priority of thread\r
pthread_setschedparam( tID, SCHED_RR, &prio );\r
}\r
break;\r
case OUTPUT:\r
- pah->s_play = pa_simple_new( NULL, "RtAudio", PA_STREAM_PLAYBACK, NULL, "Playback", &ss, NULL, NULL, &error );\r
+ pah->s_play = pa_simple_new( NULL, streamName.c_str(), PA_STREAM_PLAYBACK, NULL, "Playback", &ss, NULL, NULL, &error );\r
if ( !pah->s_play ) {\r
errorText_ = "RtApiPulse::probeDeviceOpen: error connecting output to PulseAudio server.";\r
goto error;\r
\r
void RtApi :: byteSwapBuffer( char *buffer, unsigned int samples, RtAudioFormat format )\r
{\r
- register char val;\r
- register char *ptr;\r
+ char val;\r
+ char *ptr;\r
\r
ptr = buffer;\r
if ( format == RTAUDIO_SINT16 ) {\r