# HG changeset patch # User Giulio Moro # Date 1451316174 -3600 # Node ID fb2cf9c00024b0b131e72edab10f26c4203aa6d3 # Parent 1e629f12632283798ef88dc1bb96bd650d6bce74 It is now possible to create an auxiliary task in the constructor of a global object. Closes #1374 diff -r 1e629f126322 -r fb2cf9c00024 core/RTAudio.cpp --- a/core/RTAudio.cpp Mon Dec 28 13:53:11 2015 +0100 +++ b/core/RTAudio.cpp Mon Dec 28 16:22:54 2015 +0100 @@ -58,7 +58,10 @@ PRU *gPRU = 0; I2c_Codec *gAudioCodec = 0; -vector gAuxTasks; +vector &getAuxTasks(){ + static vector auxTasks; + return auxTasks; +} // Flag which tells the audio task to stop bool gShouldStop = false; @@ -305,7 +308,7 @@ newTask->priority = priority; newTask->started = false; - gAuxTasks.push_back(newTask); + getAuxTasks().push_back(newTask); return (AuxiliaryTask)newTask; } @@ -389,7 +392,7 @@ // The user may have created other tasks. Start those also. vector::iterator it; - for(it = gAuxTasks.begin(); it != gAuxTasks.end(); it++) { + for(it = getAuxTasks().begin(); it != getAuxTasks().end(); it++) { return BeagleRT_startAuxiliaryTask(*it); } @@ -412,7 +415,7 @@ // Stop all the auxiliary threads too vector::iterator it; - for(it = gAuxTasks.begin(); it != gAuxTasks.end(); it++) { + for(it = getAuxTasks().begin(); it != getAuxTasks().end(); it++) { InternalAuxiliaryTask *taskStruct = *it; // Wake up each thread and join it @@ -428,7 +431,7 @@ // Clean up the auxiliary tasks vector::iterator it; - for(it = gAuxTasks.begin(); it != gAuxTasks.end(); it++) { + for(it = getAuxTasks().begin(); it != getAuxTasks().end(); it++) { InternalAuxiliaryTask *taskStruct = *it; // Delete the task @@ -438,7 +441,7 @@ free(taskStruct->name); free(taskStruct); } - gAuxTasks.clear(); + getAuxTasks().clear(); // Delete the audio task and its interrupt #ifdef BEAGLERT_USE_XENOMAI_INTERRUPTS