cmRtSysMsg.h,cmRtNet.h/c: Added use of kMsgSetRtId to all non-net-sync msg's sent via network.

This commit is contained in:
kevin 2013-05-04 08:56:44 -07:00
parent 48884c3389
commit 6dfbab8037
3 changed files with 46 additions and 37 deletions

View File

@ -737,11 +737,13 @@ cmRtNetRC_t cmRtNetSend( cmRtNetH_t h, cmRtNetEndptH_t epH, const void* msg, uns
assert( ep != NULL ); assert( ep != NULL );
unsigned dN = sizeof(unsigned) + msgByteCnt; unsigned dN = sizeof(cmRtSysMsgHdr_t) + msgByteCnt;
char data[ dN ]; char data[ dN ];
unsigned *hdr = (unsigned*)data;
hdr[0] = ep->id; cmRtSysMsgHdr_t* hdr = (cmRtSysMsgHdr_t*)data;
memcpy(hdr+1,msg,msgByteCnt); hdr->rtSubIdx = ep->id;
hdr->selId = kMsgSelRtId;
memcpy(data+sizeof(cmRtSysMsgHdr_t),msg,msgByteCnt);
if( cmUdpSendTo(p->udpH, data, dN, &ep->np->sockaddr ) != kOkUdpRC ) if( cmUdpSendTo(p->udpH, data, dN, &ep->np->sockaddr ) != kOkUdpRC )
return cmErrMsg(&p->err,kUdpPortFailNetRC,"Send to node:%s endpt:%s failed.\n",cmStringNullGuard(ep->np->label),cmStringNullGuard(ep->label)); return cmErrMsg(&p->err,kUdpPortFailNetRC,"Send to node:%s endpt:%s failed.\n",cmStringNullGuard(ep->np->label),cmStringNullGuard(ep->label));
@ -812,6 +814,7 @@ void cmRtNetReport( cmRtNetH_t h )
//========================================================================== //==========================================================================
#include "cmThread.h" #include "cmThread.h"
typedef struct typedef struct
{ {
cmThreadH_t thH; cmThreadH_t thH;
@ -819,12 +822,14 @@ typedef struct
unsigned msgVal; unsigned msgVal;
} _cmRtNetTest_t; } _cmRtNetTest_t;
// This function is called within the context of cmRtNetReceive().
void _cmRtNetTestRecv( void* cbArg, const char* data, unsigned dataByteCnt, const struct sockaddr_in* fromAddr ) void _cmRtNetTestRecv( void* cbArg, const char* data, unsigned dataByteCnt, const struct sockaddr_in* fromAddr )
{ {
//_cmRtNetTest_t* p = (_cmRtNetTest_t*)cbArg; //_cmRtNetTest_t* p = (_cmRtNetTest_t*)cbArg;
unsigned* hdr = (unsigned*)data; cmRtSysMsgHdr_t* hdr = (cmRtSysMsgHdr_t*)data;
printf("%i %i\n",hdr[0],hdr[1]); unsigned i = *(unsigned*)(data + sizeof(cmRtSysMsgHdr_t));
printf("%i %i\n",hdr->rtSubIdx,i);
} }

View File

@ -93,26 +93,26 @@ extern "C" {
Machine A Machine B Machine A Machine B
================================== ==================================== ================================== ====================================
broadcast 'hello' --------------------> create node-A w/ ei=0 -------+ broadcast 'hello' ------------------=-> create node-A w/ ei=0 -------+
| |
+<-- create node-B w/ ei=0 <----------- send 'node' <----------------+ +<-- create node-B w/ ei=0 <--------=-- send 'node' <----------------+
| |
+--> switch(ei,m_t) +--> switch(ei,m_t)
| ei < en : send endpt[ei++] ---> create endpt[] on node-A -->+ | ei < en : send endpt[ei++] -=--> create endpt[] on node-A -->+
| | | |
| ei == en : ++ei,send 'done' -------------------------------->+ | | ei == en : ++ei,send 'done' -=------------------------------->+ |
| | | |
| m_t!='done' : send 'done' -------------------------------->+ | | m_t!='done': send 'done' -=------------------------------->+ |
| | | |
| (stop) : | | (stop) : |
| | | |
| v | v
| switch(ei,m_t) | switch(ei,m_t)
+<-- create endpt[] on node-B <--------- send endpt[ei++] : ei < en +<-- create endpt[] on node-B <---=----- send endpt[ei++] : ei < en
| |
+<--------------------------------------- send 'done',++ei : ei == en +<---------------------------------=----- send 'done',++ei : ei == en
| |
+<--------------------------------------- send 'done' : m_t!= 'done' +<---------------------------------=----- send 'done' : m_t!= 'done'
: (stop) : (stop)
@ -121,6 +121,7 @@ extern "C" {
2) 'en' is the count of local endpoints. 2) 'en' is the count of local endpoints.
3) 'm_t' is the msg type (i.e.'hello','node','endpoint','done') 3) 'm_t' is the msg type (i.e.'hello','node','endpoint','done')
of the incoming message. of the incoming message.
4) The symbol -=- in the flow chart implies a network transmission.
*/ */

View File

@ -5,16 +5,18 @@
extern "C" { extern "C" {
#endif #endif
/// Reserved DSP message selector id's (second field of all host<->audio system messages) // Reserved DSP message selector id's (second field of all
// host<->audio system messages)
enum enum
{ {
kMidiMsgArraySelRtId = 1000, kMidiMsgArraySelRtId = 1000,
kMidiSysExSelRtId, kMidiSysExSelRtId,
kUiDrvrSelRtId, // cmUiDriverArg_t message to/from the UI driver kUiDrvrSelRtId, // cmUiDriverArg_t message to/from the UI driver
kUiSelRtId, // cmUiDriverArg-t message from the UI mgr to a client kUiSelRtId, // cmUiDriverArg_t message from the UI mgr to a client
kUiMstrSelRtId, // indicates a cmDspUiHdr_t msg containing master control information for the audio system kUiMstrSelRtId, // indicates a cmDspUiHdr_t msg containing master control information for the audio system
kStatusSelRtId, // indicates the msg is of type cmRtSysStatus_t kStatusSelRtId, // indicates the msg is of type cmRtSysStatus_t
kNetSyncSelRtId, // sent with a cmDspNetMsg_t object kNetSyncSelRtId, // sent with a cmDspNetMsg_t object
kMsgSelRtId, // client defined msg transmitted between threads or network nodes
}; };
typedef struct typedef struct
@ -46,7 +48,7 @@ extern "C" {
/// Control id's used to identify the control type of master contols. // Control id's used to identify the control type of master contols.
enum enum
{ {
kSliderUiRtId = 0, kSliderUiRtId = 0,
@ -57,28 +59,29 @@ extern "C" {
}; };
/// Audio sub-system status record - this message can be transmitted to the host at // Audio sub-system status record - this message can be transmitted to the host at
/// periodic intervals. See cmRtSysStatusNotifyEnable(). // periodic intervals. See cmRtSysStatusNotifyEnable().
/// When transmitted to the host this record acts as the message header. // When transmitted to the host this record acts as the message header.
/// This header is followed by two arrays of doubles containing the input and output meter values // This header is followed by two arrays of doubles containing the input
/// associated with the input and output audio devices. // and output meter values associated with the input and output audio devices.
/// Message Layout: [ rtSubIdx kStatusSelId cmRtSysStatus_t iMeterArray[iMeterCnt] oMeterArray[oMeterCnt] ] // Message Layout:
// [ rtSubIdx kStatusSelId cmRtSysStatus_t iMeterArray[iMeterCnt] oMeterArray[oMeterCnt] ]
typedef struct typedef struct
{ {
cmRtSysMsgHdr_t hdr; cmRtSysMsgHdr_t hdr;
unsigned updateCnt; ///< count of callbacks from the audio devices. unsigned updateCnt; // count of callbacks from the audio devices.
unsigned wakeupCnt; ///< count of times the audio system thread has woken up after the cond. var has been signaled by the audio update thread. unsigned wakeupCnt; // count of times the audio system thread has woken up after the cond. var has been signaled by the audio update thread.
unsigned msgCbCnt; ///< count of msgs delivered via cmRtCallback() . unsigned msgCbCnt; // count of msgs delivered via cmRtCallback() .
unsigned audioCbCnt; ///< count of times the DSP execution was requested via cmRtCallback(). unsigned audioCbCnt; // count of times the DSP execution was requested via cmRtCallback().
unsigned iDevIdx; ///< Input device index unsigned iDevIdx; // Input device index
unsigned oDevIdx; ///< Output device index unsigned oDevIdx; // Output device index
unsigned overflowCnt; ///< count of times the audio input buffers overflowed unsigned overflowCnt; // count of times the audio input buffers overflowed
unsigned underflowCnt; ///< count of times the audio output buffers underflowed unsigned underflowCnt; // count of times the audio output buffers underflowed
unsigned iMeterCnt; ///< count of input meter channels unsigned iMeterCnt; // count of input meter channels
unsigned oMeterCnt; ///< count of output meter channels unsigned oMeterCnt; // count of output meter channels
} cmRtSysStatus_t; } cmRtSysStatus_t;