I have code used to monitor data received over a network.
I have a static instance of a class which is used to calculate the bitrate and has a static method as follows:
static int DataReceivedCallBack(long bytesReceived, void* userData);
This function is called from inside various dlls whenever data is received.
int MyBandwidthManager::DataReceivedCallBack(long dataLength, void* userData )
MyBandwidthManager* bwMgr = static_cast<MyBandwidthManager*>(userData);
void MyBandwidthManager::UpdateBitrate( long bytesReceived)
unsigned long timeStampNow = timeGetTime();
// blah blah
// do bitrate calculations
The various dlls in question are used to receive video from different sources, I pass the DataReceivedCallBack into these dlls as a callback function.
The problem I am having is that I see sometimes (using debug messages) that timeStampNow
contains the exact same time but the function DataReceivedCallBack has been called by two different dlls.
I thought that the fact that the method was static meant that it could be called only once at any one time??? And not twice at the same time??
To calculate the bite rate correctly I need the timestamp between incoming data to be always incrementing.