Mercurial > hg > beaglert
changeset 176:fb2cf9c00024
It is now possible to create an auxiliary task in the constructor of a global object. Closes #1374
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Mon, 28 Dec 2015 16:22:54 +0100 |
parents | 1e629f126322 |
children | 3b364fb8c4ee |
files | core/RTAudio.cpp |
diffstat | 1 files changed, 9 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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<InternalAuxiliaryTask*> gAuxTasks; +vector<InternalAuxiliaryTask*> &getAuxTasks(){ + static vector<InternalAuxiliaryTask*> 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<InternalAuxiliaryTask*>::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<InternalAuxiliaryTask*>::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<InternalAuxiliaryTask*>::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