Mercurial > hg > beaglert
changeset 254:173978a5ab6a aux_task_args
Allow arguments to be passed to aux task function
author | Liam Donovan <l.b.donovan@qmul.ac.uk> |
---|---|
date | Tue, 03 May 2016 11:04:56 +0100 |
parents | cbf70fe3711b |
children | 0f813ddf5773 3e93d9793da3 |
files | core/RTAudio.cpp include/BeagleRT.h |
diffstat | 2 files changed, 7 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/core/RTAudio.cpp Thu Apr 28 19:40:41 2016 +0100 +++ b/core/RTAudio.cpp Tue May 03 11:04:56 2016 +0100 @@ -41,10 +41,11 @@ // can schedule typedef struct { RT_TASK task; - void (*function)(void); + void (*function)(void*); char *name; int priority; bool started; + void* args; } InternalAuxiliaryTask; const char gRTAudioThreadName[] = "beaglert-audio"; @@ -291,7 +292,7 @@ // (equal or lower) priority. Audio priority is defined in BEAGLERT_AUDIO_PRIORITY; // priority should be generally be less than this. // Returns an (opaque) pointer to the created task on success; 0 on failure -AuxiliaryTask BeagleRT_createAuxiliaryTask(void (*functionToCall)(void), int priority, const char *name) +AuxiliaryTask BeagleRT_createAuxiliaryTask(void (*functionToCall)(void*), int priority, const char *name, void* args) { InternalAuxiliaryTask *newTask = (InternalAuxiliaryTask*)malloc(sizeof(InternalAuxiliaryTask)); @@ -307,6 +308,7 @@ newTask->name = strdup(name); newTask->priority = priority; newTask->started = false; + newTask->args = args; getAuxTasks().push_back(newTask); @@ -331,7 +333,7 @@ void auxiliaryTaskLoop(void *taskStruct) { // Get function to call from the argument - void (*auxiliary_function)(void) = ((InternalAuxiliaryTask *)taskStruct)->function; + void (*auxiliary_function)(void*) = ((InternalAuxiliaryTask *)taskStruct)->function; const char *name = ((InternalAuxiliaryTask *)taskStruct)->name; // Wait for a notification @@ -339,7 +341,7 @@ while(!gShouldStop) { // Then run the calculations - auxiliary_function(); + auxiliary_function(((InternalAuxiliaryTask *)taskStruct)->args); // Wait for a notification rt_task_suspend(NULL);
--- a/include/BeagleRT.h Thu Apr 28 19:40:41 2016 +0100 +++ b/include/BeagleRT.h Tue May 03 11:04:56 2016 +0100 @@ -579,7 +579,7 @@ * \param priority Xenomai priority level at which the task should run. * \param name Name for this task, which should be unique system-wide (no other running program should use this name). */ -AuxiliaryTask BeagleRT_createAuxiliaryTask(void (*functionToCall)(void), int priority, const char *name); +AuxiliaryTask BeagleRT_createAuxiliaryTask(void (*functionToCall)(void*), int priority, const char *name, void* args); /** * \brief Start an auxiliary task so that it can be run.