Hi there!
You seem to miss the point of the commanddata.. That is data you pass along / define once when you call the callback-setup! You seem to pass 0 at the moment, that is why its zero. Just pass a pointer to your AudioDevice and it should work. That pointer-data then is passed to the
callback each time it is called. At least that is, how callbacks usually work..
You should have mentioned, that AudioDevice is a singleton.. Because than you can call the DoEndCallBack directly, even if your
callback doesn't provide a user-defined-data (which I think it does => commanddata).
protected:
void DoEndCallBack() {emit soundStopped();}
DoEndCallback just emits the soundStopped signal, as I defined it... But you can of course code it directly, see below:
Let me give you a more complete
Callback scenario:
class TDAQCaptureThread : public
{
friend int32 CVICALLBACK DoneCallback(TaskHandle taskHandle, int32 status, void *callbackData);
Q_OBJECT
signals:
void Finished();
protected:
void run();
};
#include "DAQCaptureThread.h"
int32 CVICALLBACK DoneCallback(TaskHandle taskHandle, int32 status, void *callbackData);
void TDAQCaptureThread::run()
{
...
DAQmxRegisterDoneEvent(taskHandle,1,DoneCallback,this);
..
DAQmxStartTask(taskHandle);
exec();
...
}
int32 CVICALLBACK DoneCallback(TaskHandle taskHandle, int32 status, void *callbackData)
{
..
emit ((TDAQCaptureThread*)callbackData)->Finished();
...
return 0;
}
class TDAQCaptureThread : public QThread
{
friend int32 CVICALLBACK DoneCallback(TaskHandle taskHandle, int32 status, void *callbackData);
Q_OBJECT
signals:
void Finished();
protected:
void run();
};
#include "DAQCaptureThread.h"
int32 CVICALLBACK DoneCallback(TaskHandle taskHandle, int32 status, void *callbackData);
void TDAQCaptureThread::run()
{
...
DAQmxRegisterDoneEvent(taskHandle,1,DoneCallback,this);
..
DAQmxStartTask(taskHandle);
exec();
...
}
int32 CVICALLBACK DoneCallback(TaskHandle taskHandle, int32 status, void *callbackData)
{
..
emit ((TDAQCaptureThread*)callbackData)->Finished();
...
return 0;
}
To copy to clipboard, switch view to plain text mode
The DAQmxRegisterDoneEvent is defined int the used DAQmx library as follows:
int32 __CFUNC DAQmxRegisterDoneEvent(TaskHandle task, uInt32 options, DAQmxDoneEventCallbackPtr callbackFunction, void *callbackData);
int32 __CFUNC DAQmxRegisterDoneEvent(TaskHandle task, uInt32 options, DAQmxDoneEventCallbackPtr callbackFunction, void *callbackData);
To copy to clipboard, switch view to plain text mode
This callbackData is what I'm talking about.. If you decide one day to have several AudioDevices :->
HIH
Johannes