Browse Source

Added a load of debugging traces

master
nebogeo 23 years ago
parent
commit
b8e4ca4fec
1 changed files with 34 additions and 4 deletions
  1. +34
    -4
      SpiralSound/ChannelHandler.C

+ 34
- 4
SpiralSound/ChannelHandler.C View File

@@ -19,6 +19,8 @@
#include "ChannelHandler.h" #include "ChannelHandler.h"
#include <unistd.h> #include <unistd.h>


//#define CHANNEL_DEBUG

ChannelHandler::ChannelHandler() : ChannelHandler::ChannelHandler() :
m_UpdateIndicator(false) m_UpdateIndicator(false)
{ {
@@ -48,28 +50,41 @@ ChannelHandler::~ChannelHandler()


void ChannelHandler::UpdateDataNow() void ChannelHandler::UpdateDataNow()
{ {
#ifdef CHANNEL_DEBUG
cerr<<"Started update"<<endl;
#endif
// make sure the command is cleared even if // make sure the command is cleared even if
// we can't get a lock on the data // we can't get a lock on the data
m_Command[0]=0; m_Command[0]=0;


if (pthread_mutex_trylock(m_Mutex)) if (pthread_mutex_trylock(m_Mutex))
{ {
m_UpdateIndicator=!m_UpdateIndicator;
#ifdef CHANNEL_DEBUG
cerr<<"Got lock"<<endl;
#endif
m_UpdateIndicator=!m_UpdateIndicator;

for(map<string, Channel*>::iterator i=m_ChannelMap.begin(); for(map<string, Channel*>::iterator i=m_ChannelMap.begin();
i!=m_ChannelMap.end(); i++) i!=m_ChannelMap.end(); i++)
{ {
Channel *ch = i->second; Channel *ch = i->second;
switch (ch->type) switch (ch->type)
{ {
case INPUT : case INPUT :
{ {
#ifdef CHANNEL_DEBUG
cerr<<"memcpy input channel: ["<<i->first<<"]"<<endl;
#endif
memcpy(ch->data,ch->data_buf,ch->size); memcpy(ch->data,ch->data_buf,ch->size);
} break; } break;
case OUTPUT : case OUTPUT :
{ {
#ifdef CHANNEL_DEBUG
cerr<<"memcpy output channel: ["<<i->first<<"]"<<endl;
#endif
memcpy(ch->data_buf,ch->data,ch->size); memcpy(ch->data_buf,ch->data,ch->size);
} break; } break;
@@ -82,11 +97,17 @@ void ChannelHandler::UpdateDataNow()
if (m_BulkPos+ch->size>m_BulkSize) if (m_BulkPos+ch->size>m_BulkSize)
{ {
// last transfer // last transfer
#ifdef CHANNEL_DEBUG
cerr<<"memcpy (last) bulk output channel: ["<<i->first<<"]"<<endl;
#endif
memcpy(ch->data_buf,((char*)m_BulkSrc)+m_BulkPos,m_BulkSize-m_BulkPos); memcpy(ch->data_buf,((char*)m_BulkSrc)+m_BulkPos,m_BulkSize-m_BulkPos);
m_BulkPos=-1; m_BulkPos=-1;
} }
else else
{ {
#ifdef CHANNEL_DEBUG
cerr<<"memcpy bulk output channel: ["<<i->first<<"]"<<endl;
#endif
memcpy(ch->data_buf,((char*)m_BulkSrc)+m_BulkPos,ch->size); memcpy(ch->data_buf,((char*)m_BulkSrc)+m_BulkPos,ch->size);
m_BulkPos+=ch->size; m_BulkPos+=ch->size;
} }
@@ -97,6 +118,9 @@ void ChannelHandler::UpdateDataNow()
// normal request transfer // normal request transfer
if (ch->requested) if (ch->requested)
{ {
#ifdef CHANNEL_DEBUG
cerr<<"memcpy output channel: ["<<i->first<<"]"<<endl;
#endif
memcpy(ch->data_buf,ch->data,ch->size); memcpy(ch->data_buf,ch->data,ch->size);
ch->updated=true; ch->updated=true;
} }
@@ -117,7 +141,11 @@ void ChannelHandler::UpdateDataNow()
else else
{ {
//cerr<<"Couldn't get lock"<<endl; //cerr<<"Couldn't get lock"<<endl;
}
}
#ifdef CHANNEL_DEBUG
cerr<<"Ended update"<<endl;
#endif
} }


void ChannelHandler::RegisterData(const string &ID, Type t,void* pData, int size) void ChannelHandler::RegisterData(const string &ID, Type t,void* pData, int size)
@@ -126,7 +154,9 @@ void ChannelHandler::RegisterData(const string &ID, Type t,void* pData, int size
// the channels have been set up they won't work anyway, but... // the channels have been set up they won't work anyway, but...
//pthread_mutex_lock(m_Mutex); //pthread_mutex_lock(m_Mutex);


cerr<<"Registering ["<<ID<<"] "<<hex<<pData<<dec<<" as "<<size<<" bytes big"<<endl;
#ifdef CHANNEL_DEBUG
cerr<<"Registering ["<<ID<<"] "<<hex<<pData<<dec<<" as "<<size<<" bytes big"<<endl;
#endif


map<string,Channel*>::iterator i=m_ChannelMap.find(ID); map<string,Channel*>::iterator i=m_ChannelMap.find(ID);
if (i!=m_ChannelMap.end()) if (i!=m_ChannelMap.end())


Loading…
Cancel
Save