diff --git a/OCAMicro/OCAMicro/OCAMicro.sln b/OCAMicro/OCAMicro/OCAMicro.sln index ac73656..b147553 100644 --- a/OCAMicro/OCAMicro/OCAMicro.sln +++ b/OCAMicro/OCAMicro/OCAMicro.sln @@ -31,7 +31,6 @@ Global {6647BA68-ABF1-44DC-B10A-B1C14DDC460D}.Release|Win32.Build.0 = Release|Win32 {34C33AF7-9D4B-4A41-8511-6B9919F58132}.Debug|Win32.ActiveCfg = Debug|Win32 {34C33AF7-9D4B-4A41-8511-6B9919F58132}.Release|Win32.ActiveCfg = Release|Win32 - {34C33AF7-9D4B-4A41-8511-6B9919F58132}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/OCAMicro/OCAMicro/Src/app/OCALiteDante/DanteLiteConMon.cpp b/OCAMicro/OCAMicro/Src/app/OCALiteDante/DanteLiteConMon.cpp index 92bc089..c5bd016 100644 --- a/OCAMicro/OCAMicro/Src/app/OCALiteDante/DanteLiteConMon.cpp +++ b/OCAMicro/OCAMicro/Src/app/OCALiteDante/DanteLiteConMon.cpp @@ -653,7 +653,7 @@ static void DanteLiteStatusMessageCallback(conmon_client_t * client, conmon_chan uint16_t aud_type = conmon_audinate_message_get_type(body); const char *device_name = conmon_client_device_name_for_instance_id(client, &id); // check the message is a status message for us - if(0 != strcmp(DanteCMControlledDeviceName, device_name)) { + if((!device_name) || (0 != strcmp(DanteCMControlledDeviceName, device_name))) { return; } switch(aud_type) { @@ -678,6 +678,11 @@ static void DanteLiteStatusMessageCallback(conmon_client_t * client, conmon_chan case CONMON_AUDINATE_MESSAGE_TYPE_RX_FLOW_CHANGE: DanteLiteHostInterfaceRouterMarkComponentStale(DR_DEVICE_COMPONENT_RXFLOWS); break; +#ifndef BKN_1 + case CONMON_AUDINATE_MESSAGE_TYPE_LOCK_STATUS: + DanteLiteHandleLockStatus(body); + break; +#endif // BKN_1 default: deviceConMonDump && printf("DanteLiteStatusMessageCallback: Audinate msg (local): %d\n", aud_type); break; @@ -1067,6 +1072,7 @@ int DanteCMSendVendorMessage(conmon_message_body_t *msg, uint32_t size, const co void DanteCMForceUpdate(void) { aud_utime_t connectWait, currentTime; + int loops = 2; while(loops) { DanteLiteHostInterfaceRun(); diff --git a/OCAMicro/OCAMicro/Src/app/OCALiteDante/DanteLiteHostInterface.cpp b/OCAMicro/OCAMicro/Src/app/OCALiteDante/DanteLiteHostInterface.cpp index 6f577c7..e3b889a 100644 --- a/OCAMicro/OCAMicro/Src/app/OCALiteDante/DanteLiteHostInterface.cpp +++ b/OCAMicro/OCAMicro/Src/app/OCALiteDante/DanteLiteHostInterface.cpp @@ -1,4 +1,4 @@ -/* By downloading or using this file, the user agrees to be bound by the terms of the license +/* By downloading or using this file, the user agrees to be bound by the terms of the license * agreement located at http://ocaalliance.com/EULA as an original contracting party. */ @@ -30,13 +30,13 @@ static aud_bool_t gs_bDrDeviceComm(AUD_FALSE); typedef struct sSystemInterface { - ::OcaLiteString ipaddr; - ::OcaLiteString gatewayaddr; - ::OcaLiteString dnsaddr; - ::OcaLiteString maskaddr; - ::OcaBoolean linkup; - ::OcaUint64 linkspeed; - ::OcaUint8 macaddr[6]; + ::OcaLiteString ipaddr; + ::OcaLiteString gatewayaddr; + ::OcaLiteString dnsaddr; + ::OcaLiteString maskaddr; + ::OcaBoolean linkup; + ::OcaUint64 linkspeed; + ::OcaUint8 macaddr[6]; }; struct sSystemInterface interfaces[2]; @@ -48,6 +48,12 @@ static DanteClockStatus gs_DeviceClockStatus; static conmon_info DanteCMCtrlInfo; static const conmon_networks_t * DanteCMNetworkInfo; static uint32_t DanteCMMediaClockOjectNumber(0); +static uint8_t NDanteNetworks = 0; +static void * DanteCMPrefMasterContext = 0; +static void * DanteCMDeviceLockContext = 0; +static void(*DanteCMPrefMasterCB)(void *, OcaUint32) = 0; +static void(*DanteCMClockMasterCB)(void *, OcaUint32) = 0; +static void(*DanteCMDeviceLockCB)(void *, OcaUint32) = 0; static aud_bool_t gs_runningLocal = AUD_TRUE; extern uint32_t DanteCMhadSampleRateStat; @@ -92,7 +98,7 @@ bool DanteLiteHostInterfaceInitializeConMon(char *devName) memset(&gs_DeviceClocking, sizeof(DanteDeviceClocking), 0); memset(&gs_DeviceClockStatus, sizeof(DanteClockStatus), 0); // If devName == NULL then we're controlling the local device - if(!devName) + if (!devName) devName = (char *)localDevice; // setup the DanteCM return DanteCMInitialize(&DanteCMCtrlInfo, devName, GetDeviceStatusMessageCB(), GetDeviceMeteringMessageCB()) == AUD_SUCCESS; @@ -101,118 +107,124 @@ bool DanteLiteHostInterfaceInitializeConMon(char *devName) // Wait for a remote device to become "resolved", 10 second timeout aud_error_t DanteLiteWaitforRemoteHostResolved(void) { - aud_error_t result; - const aud_utime_t comms_timeout = {10, 0}; - aud_utime_t now, then; - aud_utime_get(&now); - then = now; - aud_utime_add(&then, &comms_timeout); - while(aud_utime_compare(&now, &then) < 0) - { - // update our sockets - dante_sockets_clear(&gs_sockets); - dr_devices_get_sockets(gs_devices, &gs_sockets); - timeval timeout = {0,1000}; - int select_result = select(gs_sockets.n, &gs_sockets.read_fds, NULL, NULL, &timeout); - if (select_result < 0) - { - result = aud_error_get_last(); - -#ifdef _WIN32 - int errCode = WSAGetLastError(); - - if(!errCode) - { - aud_utime_get(&now); - continue; - } -#endif - return result; - } - else if (select_result == 0) - { - aud_utime_get(&now); - continue; - } - result = dr_devices_process(gs_devices, &gs_sockets); - if (dr_device_get_state(gs_device) == DR_DEVICE_STATE_RESOLVED) - { - return AUD_SUCCESS; - } - aud_utime_get(&now); - } + aud_error_t result; + const aud_utime_t comms_timeout = { 10, 0 }; + aud_utime_t now, then; + aud_utime_get(&now); + then = now; + aud_utime_add(&then, &comms_timeout); + while (aud_utime_compare(&now, &then) < 0) + { + // update our sockets + dante_sockets_clear(&gs_sockets); + dr_devices_get_sockets(gs_devices, &gs_sockets); + timeval timeout = { 0,1000 }; + int select_result = select(gs_sockets.n, &gs_sockets.read_fds, NULL, NULL, &timeout); + if (select_result < 0) + { + result = aud_error_get_last(); + +#ifdef _WIN32 + int errCode = WSAGetLastError(); + + if (!errCode) + { + aud_utime_get(&now); + continue; + } +#endif + return result; + } + else if (select_result == 0) + { + aud_utime_get(&now); + continue; + } + result = dr_devices_process(gs_devices, &gs_sockets); + if (dr_device_get_state(gs_device) == DR_DEVICE_STATE_RESOLVED) + { + return AUD_SUCCESS; + } + aud_utime_get(&now); + } return AUD_ERR_DONE; } +uint8_t DanteLiteHostInterfaceGetNumberNetworks(void) +{ + return NDanteNetworks; +} + ::OcaLiteString DanteLiteHostInterfaceGetIPAddress(OcaUint32 interfaceid) { - return interfaces[interfaceid].ipaddr; + return interfaces[interfaceid].ipaddr; } ::OcaLiteString DanteLiteHostInterfaceGetNetMaskAddress(OcaUint32 interfaceid) { - return interfaces[interfaceid].maskaddr; + return interfaces[interfaceid].maskaddr; } ::OcaLiteString DanteLiteHostInterfaceGetDNSAddress(OcaUint32 interfaceid) { - return interfaces[interfaceid].dnsaddr; + return interfaces[interfaceid].dnsaddr; } ::OcaLiteString DanteLiteHostInterfaceGetGatewayAddress(OcaUint32 interfaceid) { - return interfaces[interfaceid].gatewayaddr; + return interfaces[interfaceid].gatewayaddr; } ::OcaUint64 DanteLiteHostInterfaceGetLinkSpeed(OcaUint32 interfaceid) { - return interfaces[interfaceid].linkspeed; + return interfaces[interfaceid].linkspeed; } ::OcaUint8 * DanteLiteHostInterfaceGetMACAddress(OcaUint32 interfaceid) { - return interfaces[interfaceid].macaddr; + return interfaces[interfaceid].macaddr; } ::OcaBoolean DanteLiteHostInterfaceGetLinkState(OcaUint32 interfaceid) { - return interfaces[interfaceid].linkup; + return interfaces[interfaceid].linkup; } void DanteLiteHostInterfacePopulateSystemInterface(const conmon_networks_t * networks, int interfaceid) { - struct in_addr a; - char in_buf[22], mask_buf[22], gw_buf[22], dns_buf[22]; - - const conmon_network_t * n = networks->networks + interfaceid; - - // Convert addresses to strings - a.s_addr = n->ip_address; - strcpy ((char *)&in_buf, inet_ntoa (a)); - interfaces[interfaceid].ipaddr = static_cast< ::OcaLiteString>(in_buf); - - a.s_addr = n->netmask; - strcpy (mask_buf, inet_ntoa (a)); - interfaces[interfaceid].maskaddr = static_cast< ::OcaLiteString>(mask_buf); - - a.s_addr = n->gateway; - strcpy (gw_buf, inet_ntoa (a)); - interfaces[interfaceid].gatewayaddr = static_cast< ::OcaLiteString>(gw_buf); - - a.s_addr = n->dns_server; - strcpy (dns_buf, inet_ntoa (a)); - interfaces[interfaceid].dnsaddr = static_cast< ::OcaLiteString>(dns_buf); - - for (uint8_t i=0; i<6; i++) - { - interfaces[interfaceid].macaddr[i] = n->mac_address[i]; - } - - interfaces[interfaceid].linkup = n->is_up ? true : false; - - interfaces[interfaceid].linkspeed = n->link_speed; + struct in_addr a; + char in_buf[22], mask_buf[22], gw_buf[22], dns_buf[22]; + + const conmon_network_t * n = networks->networks + interfaceid; + + // Convert addresses to strings + a.s_addr = n->ip_address; + strcpy((char *)&in_buf, inet_ntoa(a)); + interfaces[interfaceid].ipaddr = static_cast< ::OcaLiteString>(in_buf); + + a.s_addr = n->netmask; + strcpy(mask_buf, inet_ntoa(a)); + interfaces[interfaceid].maskaddr = static_cast< ::OcaLiteString>(mask_buf); + + a.s_addr = n->gateway; + strcpy(gw_buf, inet_ntoa(a)); + interfaces[interfaceid].gatewayaddr = static_cast< ::OcaLiteString>(gw_buf); + + a.s_addr = n->dns_server; + strcpy(dns_buf, inet_ntoa(a)); + interfaces[interfaceid].dnsaddr = static_cast< ::OcaLiteString>(dns_buf); + + for (uint8_t i = 0; i < 6; i++) + { + interfaces[interfaceid].macaddr[i] = n->mac_address[i]; + } + + interfaces[interfaceid].linkup = n->is_up ? true : false; + + interfaces[interfaceid].linkspeed = n->link_speed; } + bool DanteLiteHostInterfaceInitialize(char *devName) { ::aud_error_t audResult(::aud_env_setup(&gs_audEnv)); @@ -222,7 +234,7 @@ bool DanteLiteHostInterfaceInitialize(char *devName) if (AUD_SUCCESS == audResult) { // if no device name is given open locally - if(!devName) + if (!devName) { // open local device audResult = ::dr_device_open_local(gs_devices, &gs_device); gs_runningLocal = AUD_TRUE; @@ -235,9 +247,9 @@ bool DanteLiteHostInterfaceInitialize(char *devName) } dr_device_set_changed_callback(gs_device, cbDeviceRouterDeviceChanged); // If we're connecting to a remote device we need to wait until it's "Resolved" - if(devName) + if (devName) { - if(AUD_SUCCESS != DanteLiteWaitforRemoteHostResolved()) + if (AUD_SUCCESS != DanteLiteWaitforRemoteHostResolved()) { printf("Failed to connect to remote device %s\n", devName); return false; @@ -257,16 +269,19 @@ bool DanteLiteHostInterfaceInitialize(char *devName) } } - if (AUD_SUCCESS == audResult) - { - DanteCMNetworkInfo = conmon_client_get_networks(gs_conmon); + if (AUD_SUCCESS == audResult) + { + DanteCMNetworkInfo = conmon_client_get_networks(gs_conmon); + + NDanteNetworks = DanteCMNetworkInfo->num_networks; - DanteLiteHostInterfacePopulateSystemInterface(DanteCMNetworkInfo, 0); - DanteLiteHostInterfacePopulateSystemInterface(DanteCMNetworkInfo, 1); - } + for (uint8_t i = 0; i < NDanteNetworks; i++) { + DanteLiteHostInterfacePopulateSystemInterface(DanteCMNetworkInfo, i); + } + } - if (AUD_SUCCESS == audResult) - { + if (AUD_SUCCESS == audResult) + { gs_bDrDeviceComm = AUD_TRUE; audResult = dr_device_query_capabilities(gs_device, handleDrDeviceResponse, &gs_requestId); @@ -296,7 +311,7 @@ bool DanteLiteHostInterfaceInitialize(char *devName) static void UpdateComponent(dr_device_component_t component) { - if(gs_device) { + if (gs_device) { if (dr_device_is_component_stale(gs_device, component)) { deviceRoutingDump && printf("Component %d stale\n", component); @@ -310,7 +325,7 @@ static void UpdateComponent(dr_device_component_t component) dr_devices_get_sockets(gs_devices, &sockets); dr_devices_process(gs_devices, &sockets); } - switch(component) { + switch (component) { case DR_DEVICE_COMPONENT_RXCHANNELS: UpdateStreamNetworkDanteRxChannels(); break; @@ -335,9 +350,9 @@ static void UpdateComponent(dr_device_component_t component) int DanteLiteHostInterfaceGetSocket() { int socketFd = -1; - if(DanteCMCtrlInfo.running) + if (DanteCMCtrlInfo.running) { - socketFd = conmon_client_get_socket (DanteCMCtrlInfo.client); + socketFd = conmon_client_get_socket(DanteCMCtrlInfo.client); } return socketFd; } @@ -388,8 +403,8 @@ bool DanteLiteHostInterfaceSetDanteChannelSubscription(UINT16 channel, const cha if (pos != sSubscription.end()) { std::string portName(sSubscription.substr(0, sSubscription.find("@"))); - std::string nodeName(sSubscription.substr(sSubscription.find("@")+1, sSubscription.size() - 3)); - + std::string nodeName(sSubscription.substr(sSubscription.find("@") + 1, sSubscription.size() - 3)); + gs_bDrDeviceComm = AUD_TRUE; audResult = dr_rxchannel_subscribe(rxChannels[channel], handleDrDeviceResponse, &gs_requestId, nodeName.c_str(), portName.c_str()); } @@ -558,7 +573,7 @@ const char* DanteLiteHostInterfaceGetDanteChannelName(UINT16 channel, bool bRxCh return ""; } -const char* DanteLiteHostInterfaceGetDanteChannelLabel(UINT16 channel, bool bRxChannel) +OcaLiteStatus DanteLiteHostInterfaceGetDanteChannelLabel(UINT16 channel, bool bRxChannel, OcaLiteString& label) { if (bRxChannel) { @@ -568,7 +583,7 @@ const char* DanteLiteHostInterfaceGetDanteChannelLabel(UINT16 channel, bool bRxC uint16_t numChannels; if (AUD_SUCCESS == dr_device_get_rxchannels(gs_device, &numChannels, &rxChannels)) { - return dr_rxchannel_get_name(rxChannels[channel]); + label = static_cast < ::OcaLiteString> (dr_rxchannel_get_name(rxChannels[channel])); } } else @@ -584,23 +599,89 @@ const char* DanteLiteHostInterfaceGetDanteChannelLabel(UINT16 channel, bool bRxC if ((AUD_SUCCESS == dr_txchannel_get_txlabels(txChannels[channel], &len, labels)) && (len > 0)) { - return labels[0].name; + label = static_cast < ::OcaLiteString> (labels[0].name); } else { - return dr_txchannel_get_canonical_name(txChannels[channel]); + label = static_cast < ::OcaLiteString> (dr_txchannel_get_canonical_name(txChannels[channel])); } } } - return ""; + return OCASTATUS_OK; +} + +OcaLiteStatus DanteLiteHostInterfaceSetDanteChannelLabel(UINT16 channel, bool bRxChannel, OcaLiteString * name) +{ + if (bRxChannel) + { + UpdateComponent(DR_DEVICE_COMPONENT_RXCHANNELS); + + dr_rxchannel_t** rxChannels; + uint16_t numChannels; + if (AUD_SUCCESS == dr_device_get_rxchannels(gs_device, &numChannels, &rxChannels)) + { + dr_rxchannel_set_name(rxChannels[channel], handleDrDeviceResponse, &gs_requestId, (const char *)name->GetValue()); + } + } + else + { + UpdateComponent(DR_DEVICE_COMPONENT_TXCHANNELS); + + dr_txchannel_t** txChannels; + uint16_t numChannels; + if (AUD_SUCCESS == dr_device_get_txchannels(gs_device, &numChannels, &txChannels)) + { + uint16_t len = 1; + dr_txlabel_t labels[1]; + if ((AUD_SUCCESS == dr_txchannel_get_txlabels(txChannels[channel], &len, labels)) && + (len > 0)) + { + dr_txchannel_replace_txlabel(txChannels[channel], handleDrDeviceResponse, &gs_requestId, labels[0].name, (const char *)name->GetValue(), 0); + } + else + { + // No label exists + dr_txchannel_add_txlabel(txChannels[channel], handleDrDeviceResponse, &gs_requestId, (const char *)name->GetValue(), 0); + } + } + } + + return OCASTATUS_OK; +} + +uint8_t DanteLiteHostInterfaceSetDeviceName(const char * newname) +{ + uint8_t result = AUD_FALSE; + +#ifndef BKN_1 // Older versions of API don't have name check function + + if (newname && dante_name_is_valid_device_name(newname)) + { + result = dr_device_close_rename(gs_device, newname); + } + +#else + if (newname) + { + result = dr_device_close_rename(gs_device, newname); + } + +#endif + + if (result != AUD_SUCCESS) + { + printf("Error renaming device\n"); + } + + return result; } const char* DanteLiteHostInterfaceGetDeviceName(void) { UpdateComponent(DR_DEVICE_COMPONENT_PROPERTIES); - if(gs_device) + if (gs_device) return dr_device_get_name(gs_device); else return OcfLiteConfigureGetDeviceName().c_str(); @@ -612,7 +693,7 @@ bool DanteLiteHostInterfaceGetNumberOfChannels(UINT16& nrRxChannels, UINT16& nrT UpdateComponent(DR_DEVICE_COMPONENT_RXCHANNELS); nrRxChannels = 0; nrTxChannels = 0; - if(gs_device) { + if (gs_device) { nrRxChannels = dr_device_num_rxchannels(gs_device); nrTxChannels = dr_device_num_txchannels(gs_device); } @@ -624,8 +705,8 @@ static void cbDeviceRouterDeviceChanged(dr_device_t *device, dr_device_change_fl dr_device_change_index_t i; - (void) device; - + (void)device; + deviceRoutingDump && printf("cbDeviceRouterDeviceChanged with changes"); for (i = 0; i < DR_DEVICE_CHANGE_INDEX_COUNT; i++) { @@ -653,16 +734,18 @@ static void cbDeviceRouterDeviceChanged(dr_device_t *device, dr_device_change_fl void cbDeviceRouterSocketsChanged(const dr_devices_t * devices) { dante_sockets_clear(&gs_sockets); - aud_error_t result = dr_devices_get_sockets(devices, &gs_sockets); + aud_error_t result = dr_devices_get_sockets(devices, &gs_sockets); } void DanteLiteHandleClockStatus(const conmon_message_body_t *aud_msg) { - conmon_audinate_servo_state_t servo_state = conmon_audinate_clocking_status_get_servo_state(aud_msg); - conmon_audinate_clock_source_t clock_source = conmon_audinate_clocking_status_get_clock_source(aud_msg); - conmon_audinate_clock_state_t clock_state = conmon_audinate_clocking_status_get_clock_state(aud_msg); + conmon_audinate_servo_state_t servo_state = conmon_audinate_clocking_status_get_servo_state(aud_msg); + conmon_audinate_clock_source_t clock_source = conmon_audinate_clocking_status_get_clock_source(aud_msg); + conmon_audinate_clock_state_t clock_state = conmon_audinate_clocking_status_get_clock_state(aud_msg); + aud_bool_t isprefmaster = conmon_audinate_clocking_status_is_clock_preferred(aud_msg); + uint32_t clockmaster = gs_DeviceClockStatus.ClockMaster; //const char *domainName = conmon_audinate_clocking_status_get_subdomain_name(aud_msg); - conmon_audinate_ext_wc_state_t ext_wc_state = conmon_audinate_clocking_status_get_ext_wc_state(aud_msg); + conmon_audinate_ext_wc_state_t ext_wc_state = conmon_audinate_clocking_status_get_ext_wc_state(aud_msg); uint16_t mute_state = conmon_audinate_clocking_status_get_mute_flags(aud_msg); // we'll assume there's only one clock @@ -672,44 +755,64 @@ void DanteLiteHandleClockStatus(const conmon_message_body_t *aud_msg) if (port_0_status) { gs_DeviceClockStatus.ClockPortState[0] = conmon_audinate_port_status_get_port_state(port_0_status, aud_msg); - if(gs_DeviceClockStatus.ClockPortState[0] == CONMON_AUDINATE_PORT_STATE_MASTER) { + if (gs_DeviceClockStatus.ClockPortState[0] == CONMON_AUDINATE_PORT_STATE_MASTER) { gs_DeviceClockStatus.ClockMaster = 1; - } else { + } + else { gs_DeviceClockStatus.ClockMaster = 0; } - } else { + } + else { gs_DeviceClockStatus.ClockMaster = 0; } if (!gs_DeviceClockStatus.ClockMaster && port_1_status) { conmon_audinate_port_state_t state1 = conmon_audinate_port_status_get_port_state(port_1_status, aud_msg); - if(state1 == CONMON_AUDINATE_PORT_STATE_MASTER) { + if (state1 == CONMON_AUDINATE_PORT_STATE_MASTER) { gs_DeviceClockStatus.ClockMaster = 1; deviceRoutingDump && printf("handleClockStatus: setting Master state from Secondary Port\n"); } } - if ((mute_state != gs_DeviceClockStatus.ClockMuteState ) || + if (isprefmaster != gs_DeviceClockStatus.IsPrefMaster) { + gs_DeviceClockStatus.IsPrefMaster = isprefmaster; + + if (DanteCMPrefMasterCB) { + (*DanteCMPrefMasterCB)(DanteCMPrefMasterContext, gs_DeviceClockStatus.IsPrefMaster); + } + + } + + if (clockmaster != gs_DeviceClockStatus.ClockMaster) { + // Clock master has changed + if (DanteCMClockMasterCB) { + (*DanteCMClockMasterCB)(DanteCMPrefMasterContext, gs_DeviceClockStatus.ClockMaster); + } + } + + if ((mute_state != gs_DeviceClockStatus.ClockMuteState) || (clock_source != gs_DeviceClockStatus.ClockSource) || - (clock_state != gs_DeviceClockStatus.ClockState ) || + (clock_state != gs_DeviceClockStatus.ClockState) || (ext_wc_state != gs_DeviceClockStatus.ClockExternalWordClockState)) { - deviceRoutingDump && printf("handleClockStatus: Servo (%d) = %s (%s), src = %d, Status = 0x%04x, Mute = 0x%04x ExtWc = %d\n", - servo_state, gs_DeviceClockStatus.ClockLocked ? "Locked" : "Unlocked", - gs_DeviceClockStatus.ClockMaster ? "Master" : "Slave", - clock_source, clock_state, mute_state, ext_wc_state ); - } - gs_DeviceClockStatus.ClockSource = clock_source; - gs_DeviceClockStatus.ClockState = clock_state; - gs_DeviceClockStatus.ClockMuteState = mute_state; + deviceRoutingDump && printf("handleClockStatus: Servo (%d) = %s (%s), src = %d, Status = 0x%04x, Mute = 0x%04x ExtWc = %d\n", + servo_state, gs_DeviceClockStatus.ClockLocked ? "Locked" : "Unlocked", + gs_DeviceClockStatus.ClockMaster ? "Master" : "Slave", + clock_source, clock_state, mute_state, ext_wc_state); + } + gs_DeviceClockStatus.ClockSource = clock_source; + gs_DeviceClockStatus.ClockState = clock_state; + gs_DeviceClockStatus.ClockMuteState = mute_state; gs_DeviceClockStatus.ClockExternalWordClockState = ext_wc_state; - if( ((servo_state == CONMON_AUDINATE_SERVO_STATE_SYNC) || (servo_state == CONMON_AUDINATE_SERVO_STATE_SYNCING)) && - (mute_state == 0) ) { + if (((servo_state == CONMON_AUDINATE_SERVO_STATE_SYNC) || (servo_state == CONMON_AUDINATE_SERVO_STATE_SYNCING)) && + (mute_state == 0)) { gs_DeviceClockStatus.ClockLocked = 1; - } else if(mute_state != 0) { + } + else if (mute_state != 0) { gs_DeviceClockStatus.ClockLocked = 0; - } else { + } + else { gs_DeviceClockStatus.ClockLocked = 1; } DanteCMhadClockStat = 1; @@ -717,10 +820,10 @@ void DanteLiteHandleClockStatus(const conmon_message_body_t *aud_msg) // On a Brooklyn module we'll get this and DanteLiteHandleSampleRateStatus() #ifdef WIN32 // only need to do this if we're not remotely connected to a Brooklyn module - if(gs_runningLocal == AUD_TRUE) + if (gs_runningLocal == AUD_TRUE) DanteCMhadSampleRateStat = 1; #endif - if(DanteCMhadSampleRateStat & !DanteCMctrlInitialized) { + if (DanteCMhadSampleRateStat & !DanteCMctrlInitialized) { DanteCMctrlInitialized = 1; } // TODO: Need to update OCA media clock with changes @@ -730,7 +833,7 @@ void DanteLiteHandleSampleRateStatus(const conmon_message_body_t *aud_msg) { uint32_t value; value = conmon_audinate_srate_get_current(aud_msg); - if(gs_DeviceClocking.CurrentSampleRate != value) { + if (gs_DeviceClocking.CurrentSampleRate != value) { gs_DeviceClocking.CurrentSampleRate = value; deviceRoutingDump && printf("Sample Rate = %u\n", value); // TODO: Need to update OCA media clock with change @@ -740,21 +843,35 @@ void DanteLiteHandleSampleRateStatus(const conmon_message_body_t *aud_msg) } } value = conmon_audinate_srate_get_available_count(aud_msg); - if(gs_DeviceClocking.NumberOfSupportedRates != value) { + if (gs_DeviceClocking.NumberOfSupportedRates != value) { deviceRoutingDump && printf("Number of Supported Sample Rates = %u\n", value); gs_DeviceClocking.NumberOfSupportedRates = value; - for(uint32_t i = 0; i < value; i++) { + for (uint32_t i = 0; i < value; i++) { gs_DeviceClocking.SupportedSampleRates[i] = conmon_audinate_srate_get_available(aud_msg, i); deviceRoutingDump && printf("Rate[%d]: %u\n", i, gs_DeviceClocking.SupportedSampleRates[i]); } // TODO: Need to update OCA media clock with change } DanteCMhadSampleRateStat = 1; - if(DanteCMhadClockStat & !DanteCMctrlInitialized) { + if (DanteCMhadClockStat & !DanteCMctrlInitialized) { DanteCMctrlInitialized = 1; } } +#ifndef BKN_1 +void DanteLiteHandleLockStatus(const conmon_message_body_t *aud_msg) +{ + aud_bool_t value; + value = conmon_audinate_get_lock_status(aud_msg); + + if (DanteCMDeviceLockCB) { + (*DanteCMDeviceLockCB)(DanteCMDeviceLockContext, (OcaUint32)value); + } + + printf("Audinate Lock Status %s\n", value == AUD_TRUE ? "True" : "False"); +} +#endif // BKN_1 + pDanteClockStatus DanteLiteHostInterfaceGetDanteDanteDanteClockStatus() { return &gs_DeviceClockStatus; @@ -770,6 +887,36 @@ void DanteLiteHostInterfaceSetMediaClockObjectNumber(uint32_t objNumber) DanteCMMediaClockOjectNumber = objNumber; } +void DanteListHostInterfaceSetPrefMasterCallback(void * context, tDanteLiteHostInterfaceCB prefmastercb, tDanteLiteHostInterfaceCB clockmastercb) +{ + + DanteCMPrefMasterContext = context; + DanteCMPrefMasterCB = prefmastercb; + DanteCMClockMasterCB = clockmastercb; + + // If already initialised then send value + if (DanteCMctrlInitialized) { + (*DanteCMPrefMasterCB)(DanteCMPrefMasterContext, gs_DeviceClockStatus.IsPrefMaster); + (*DanteCMClockMasterCB)(DanteCMPrefMasterContext, gs_DeviceClockStatus.ClockMaster); + } +} + +void DanteListHostInterfaceSetDeviceLockCallback(void * context, tDanteLiteHostInterfaceCB devicelockcb) +{ +#ifndef BKN_1 + DanteCMDeviceLockContext = context; + DanteCMDeviceLockCB = devicelockcb; + + if (DanteCMctrlInitialized) { + // Get initial state + conmon_message_body_t aud_msg; + conmon_audinate_init_query_message(&aud_msg, CONMON_AUDINATE_MESSAGE_TYPE_LOCK_QUERY, 0); + uint16_t msg_size = conmon_audinate_query_message_get_size(&aud_msg); + DanteCMSendAudinateMessage(&aud_msg, msg_size); + } +#endif // BKN_1 +} + bool DanteLiteHostInterfaceSetSampleRate(uint32_t srate) { uint16_t msg_size; @@ -777,9 +924,9 @@ bool DanteLiteHostInterfaceSetSampleRate(uint32_t srate) aud_error_t rc; conmon_message_body_t aud_msg; // check if the sample rate is different - if(srate == gs_DeviceClocking.CurrentSampleRate) + if (srate == gs_DeviceClocking.CurrentSampleRate) return true; - conmon_audinate_init_srate_control (&aud_msg, /*CongestionDelay_uS*/0); + conmon_audinate_init_srate_control(&aud_msg, /*CongestionDelay_uS*/0); conmon_audinate_srate_control_set_rate(&aud_msg, srate); msg_size = conmon_audinate_srate_control_get_size(&aud_msg); mode = (uint32_t)conmon_audinate_srate_get_mode(&aud_msg); @@ -787,9 +934,24 @@ bool DanteLiteHostInterfaceSetSampleRate(uint32_t srate) return (rc == AUD_SUCCESS); } +bool DanteLiteHostInterfaceSetPrefMaster(uint32_t prefmaster) +{ + uint16_t msg_size; + aud_error_t rc; + conmon_message_body_t aud_msg; + // check if the sample rate is different + if (prefmaster == gs_DeviceClockStatus.IsPrefMaster) + return true; + conmon_audinate_init_clocking_control(&aud_msg, 0); + conmon_audinate_clocking_control_set_preferred(&aud_msg, (uint8_t)prefmaster); + msg_size = conmon_audinate_clocking_control_get_size(&aud_msg); + rc = DanteCMSendAudinateMessage(&aud_msg, msg_size); + return (rc == AUD_SUCCESS); +} + void DanteLiteHostInterfaceRouterMarkComponentStale(dr_device_component_t devComponent) { - if(gs_device && (devComponent < DR_DEVICE_COMPONENT_COUNT)) + if (gs_device && (devComponent < DR_DEVICE_COMPONENT_COUNT)) ::dr_device_mark_component_stale(gs_device, devComponent); } @@ -808,13 +970,13 @@ void UpdateStreamNetworkDanteRxChannels() unsigned int n = dr_device_num_rxchannels(gs_device); OcaLiteStreamNetworkDante *pSNDante = reinterpret_cast(::OcaLiteBlock::GetRootBlock().GetObject(OcaLiteStreamNetworkDanteONo)); - if(!pSNDante || !DanteCMctrlInitialized) + if (!pSNDante || !DanteCMctrlInitialized) return; - for(unsigned int chan = 0; chan < n; chan++) { + for (unsigned int chan = 0; chan < n; chan++) { // get each channels subscription and pass to the OcaLiteStreamNetworkDante object to sort out dr_rxchannel_t * rxc = dr_device_rxchannel_at_index(gs_device, chan); const char * sub = dr_rxchannel_get_subscription(rxc); - if(pSNDante->CheckforNewSubscription(chan, sub)) { + if (pSNDante->CheckforNewSubscription(chan, sub)) { deviceRoutingDump && printf("Rx Subscription Updated for channel %d to %s\n", chan, sub); } } diff --git a/OCAMicro/OCAMicro/Src/app/OCALiteDante/DanteLiteHostInterface.h b/OCAMicro/OCAMicro/Src/app/OCALiteDante/DanteLiteHostInterface.h index f088288..165d400 100644 --- a/OCAMicro/OCAMicro/Src/app/OCALiteDante/DanteLiteHostInterface.h +++ b/OCAMicro/OCAMicro/Src/app/OCALiteDante/DanteLiteHostInterface.h @@ -33,15 +33,16 @@ typedef struct _DanteDeviceClocking typedef struct _DanteClockStatus { - conmon_audinate_servo_state_t ServoState; - conmon_audinate_clock_source_t ClockSource; - conmon_audinate_clock_state_t ClockState; - conmon_audinate_ext_wc_state_t ClockExternalWordClockState; - char * DomainName; - conmon_audinate_port_state_t ClockPortState[2]; - uint32_t ClockMaster; - uint16_t ClockMuteState; - uint32_t ClockLocked; + conmon_audinate_servo_state_t ServoState; + conmon_audinate_clock_source_t ClockSource; + conmon_audinate_clock_state_t ClockState; + conmon_audinate_ext_wc_state_t ClockExternalWordClockState; + char * DomainName; + conmon_audinate_port_state_t ClockPortState[2]; + uint32_t ClockMaster; + uint16_t ClockMuteState; + uint32_t ClockLocked; + aud_bool_t IsPrefMaster; } DanteClockStatus, *pDanteClockStatus; /** @@ -93,7 +94,7 @@ const char* DanteLiteHostInterfaceGetDanteChannelName(UINT16 channel, bool bRxCh * * @return The channel label */ -const char* DanteLiteHostInterfaceGetDanteChannelLabel(UINT16 channel, bool bRxChannel); +OcaLiteStatus DanteLiteHostInterfaceGetDanteChannelLabel(UINT16 channel, bool bRxChannel, OcaLiteString& label); /** * Get the current dante channel subscription @@ -192,6 +193,14 @@ void DanteLiteHostInterfaceRunWithFdSet(fd_set* readSet); void DanteCMForceUpdate(void); +/** + * Get number of Dante networks on the device + * + * @return Number of Dante Networks + */ + +uint8_t DanteLiteHostInterfaceGetNumberNetworks(void); + /** * Get the ip address for a system interface * @@ -255,4 +264,78 @@ ::OcaUint8 * DanteLiteHostInterfaceGetMACAddress(OcaUint32 interfaceid); */ ::OcaBoolean DanteLiteHostInterfaceGetLinkState(OcaUint32 interfaceid); +/** + * Defines host interface callback type + */ + +typedef void (*tDanteLiteHostInterfaceCB)(void *, OcaUint32 prefmaster); + +/** + * Sets to callback if the preferred master state changes + * + * @param[in] context Context of OCA app to call callback with + * + * @param[in] prefmastercb Pointer to Preferred Master Callback Function + * + * @param[in] clockmastercb Pointer to Network Clock Master State Callback + */ + +void DanteListHostInterfaceSetPrefMasterCallback(void * context, tDanteLiteHostInterfaceCB prefmastercb, tDanteLiteHostInterfaceCB clockmastercb); + +/** + * Sets to callback if the dante device lock changes + * + * @param[in] context Context of OCA app to call callback with + * + * @param[in] devicelockcb Pointer to Dante Device Lock Callback Function + * + */ + +void DanteListHostInterfaceSetDeviceLockCallback(void * context, tDanteLiteHostInterfaceCB devicelockcb); + +/** + * Sets preferred master state of device + * + * @param[in] prefmaster State of preferred master (0: Off 1: On) + * + * @return Whether operation was sucessful + * + */ + +bool DanteLiteHostInterfaceSetPrefMaster(uint32_t prefmaster); + +/** + * Sets label for dante channel + * + * @param[in] channel Channel Number + * + * @param[in] bRxChannel Is it an RX channel? + * + * @param[in] name Pointer to new name string + * + */ + +OcaLiteStatus DanteLiteHostInterfaceSetDanteChannelLabel(UINT16 channel, bool bRxChannel, OcaLiteString * name); + +/** + * Sets device name of local device + * + * @param[in] newname Pointer to Device Name String + * + * @return Sucess of operation + * + */ + +uint8_t DanteLiteHostInterfaceSetDeviceName(const char * newname); + +/** + * Callback for Dante device lock status message + * + * @param[in] aud_msg Pointer to audinate message + * + */ +#ifndef BKN_1 +void DanteLiteHandleLockStatus(const conmon_message_body_t *aud_msg); +#endif // BKN_1 + #endif // DANTELITEHOSTINTERFACE_H diff --git a/OCAMicro/OCAMicro/Src/app/OCALiteDante/OCALiteDante.cpp b/OCAMicro/OCAMicro/Src/app/OCALiteDante/OCALiteDante.cpp index d108d5d..e90351f 100644 --- a/OCAMicro/OCAMicro/Src/app/OCALiteDante/OCALiteDante.cpp +++ b/OCAMicro/OCAMicro/Src/app/OCALiteDante/OCALiteDante.cpp @@ -121,9 +121,6 @@ int main(int argc, const char* argv[]) ::OcaLiteDeviceManager::GetInstance().SetErrorAndOperationalState(static_cast< ::OcaBoolean>(!bSuccess), ::OcaLiteDeviceManager::OCA_OPSTATE_OPERATIONAL); ::OcaLiteDeviceManager::GetInstance().SetEnabled(static_cast< ::OcaBoolean>(bSuccess)); - // From now onwards use the memory pool - InitializePool(); - INT32 highestFd; OcfLiteSelectableSet readSet; OcfLiteSelectableSet writeSet; @@ -180,7 +177,6 @@ int main(int argc, const char* argv[]) #endif // DANTE_CM_METERING_SUBSCRIPTIONS #endif // OCA_RUN } - ShutdownPool(); } } OCALiteOCCFactoryDestroy(); @@ -190,356 +186,3 @@ int main(int argc, const char* argv[]) return 0; } -#ifndef _WIN32 -// ---- Memory manager implementation ---- - -/* The size of a memory block header */ -#define MEMORY_BLOCK_HEADER_SIZE sizeof(struct MemoryBlock) -/* The size in bytes of a small block */ -#define SMALL_BLOCK_SIZE 64 -/* The size in bytes of a middle block */ -#define MIDDLE_BLOCK_SIZE 512 -/* The size in bytes of a large block */ -#define LARGE_BLOCK_SIZE 3096 -/* The size in bytes of a big block */ -#define BIG_BLOCK_SIZE 4096 - -/** Definition of a memory block */ -typedef struct MemoryBlock -{ - /* Is the block in use? */ - char inInuse; - /* The index in the array for a reverse lookup */ - char index; - /* The actual size */ - short size; - /* The original size */ - size_t origSize; - /* Pointer to the memory */ - unsigned int memory; -} MemoryBlock; - -/* The maximum number of blocks */ -#define MAX_NR_SMALL_BLOCKS 100 -#define MAX_NR_MIDDLE_BLOCKS 30 -#define MAX_NR_LARGE_BLOCKS 48 -#define MAX_NR_BIG_BLOCKS 16 - -/* The small blocks */ -static MemoryBlock* gs_smallBlocks[MAX_NR_SMALL_BLOCKS]; -/* The middle sized blocks */ -static MemoryBlock* gs_middleBlocks[MAX_NR_MIDDLE_BLOCKS]; -/* Large blocks */ -static MemoryBlock* gs_largeBlocks[MAX_NR_LARGE_BLOCKS]; -/* Big blocks */ -static MemoryBlock* gs_bigBlocks[MAX_NR_BIG_BLOCKS]; - -#ifdef MEMORY_MANAGER_PROFILE -static int gs_highestSmallBlock = 0; -static int gs_highestMiddleBlock = 0; -static int gs_highestLargeBlock = 0; -static int gs_highestBigBlock = 0; -#endif - -int gs_initialized = 0; - -void ShutdownPool() -{ - int i = 0; - for (i = 0; i < MAX_NR_SMALL_BLOCKS; i++) - { -#ifdef MEMORY_MANAGER_PROFILE - if (gs_smallBlocks[i]->inInuse) - { - printf("Small block %d still in use. Deleting anyhow\r\n", i); - } -#endif - free(gs_smallBlocks[i]); - gs_smallBlocks[i] = NULL; - } - - for (i = 0; i < MAX_NR_MIDDLE_BLOCKS; i++) - { -#ifdef MEMORY_MANAGER_PROFILE - if (gs_middleBlocks[i]->inInuse) - { - printf("Middle block %d still in use. Deleting anyhow\r\n", i); - } -#endif - free(gs_middleBlocks[i]); - gs_middleBlocks[i] = NULL; - } - - for (i = 0; i < MAX_NR_LARGE_BLOCKS; i++) - { -#ifdef MEMORY_MANAGER_PROFILE - if (gs_largeBlocks[i]->inInuse) - { - printf("Large block %d still in use. Deleting anyhow\r\n", i); - } -#endif - free(gs_largeBlocks[i]); - gs_largeBlocks[i] = NULL; - } - - for (i = 0; i < MAX_NR_BIG_BLOCKS; i++) - { -#ifdef MEMORY_MANAGER_PROFILE - if (gs_bigBlocks[i]->inInuse) - { - printf("Big block %d still in use. Deleting anyhow\r\n", i); - } -#endif - free(gs_bigBlocks[i]); - gs_bigBlocks[i] = NULL; - } -} - -void InitializePool() -{ - int i; - - printf("Memory manager allocating %d Bytes (%d KB) in %d blocks for client\r\n", - ((MAX_NR_SMALL_BLOCKS * SMALL_BLOCK_SIZE) + (MAX_NR_MIDDLE_BLOCKS * MIDDLE_BLOCK_SIZE) + (MAX_NR_LARGE_BLOCKS * LARGE_BLOCK_SIZE) + (MAX_NR_BIG_BLOCKS * BIG_BLOCK_SIZE)), - (((MAX_NR_SMALL_BLOCKS * SMALL_BLOCK_SIZE) + (MAX_NR_MIDDLE_BLOCKS * MIDDLE_BLOCK_SIZE) + (MAX_NR_LARGE_BLOCKS * LARGE_BLOCK_SIZE) + (MAX_NR_BIG_BLOCKS * BIG_BLOCK_SIZE)) / 1024), - (MAX_NR_SMALL_BLOCKS + MAX_NR_MIDDLE_BLOCKS + MAX_NR_LARGE_BLOCKS + MAX_NR_BIG_BLOCKS)); - - // Allocate the memory - for (i = 0; i < MAX_NR_SMALL_BLOCKS; i++) - { - gs_smallBlocks[i] = (MemoryBlock*)malloc(SMALL_BLOCK_SIZE + MEMORY_BLOCK_HEADER_SIZE); - MemoryBlock* mbPtr = gs_smallBlocks[i]; - mbPtr->index = i + 1; - mbPtr->inInuse = 0; - mbPtr->size = SMALL_BLOCK_SIZE; - mbPtr->origSize = SMALL_BLOCK_SIZE; - mbPtr->memory = ((unsigned int)gs_smallBlocks[i]) + (MEMORY_BLOCK_HEADER_SIZE); - } - - for (i = 0; i < MAX_NR_MIDDLE_BLOCKS; i++) - { - gs_middleBlocks[i] = (MemoryBlock*)malloc(MIDDLE_BLOCK_SIZE + MEMORY_BLOCK_HEADER_SIZE); - MemoryBlock* mbPtr = gs_middleBlocks[i]; - mbPtr->index = i + 1; - mbPtr->inInuse = 0; - mbPtr->size = MIDDLE_BLOCK_SIZE; - mbPtr->origSize = MIDDLE_BLOCK_SIZE; - mbPtr->memory = ((unsigned int)gs_middleBlocks[i]) + (MEMORY_BLOCK_HEADER_SIZE); - } - - for (i = 0; i < MAX_NR_LARGE_BLOCKS; i++) - { - gs_largeBlocks[i] = (MemoryBlock*)malloc(LARGE_BLOCK_SIZE + MEMORY_BLOCK_HEADER_SIZE); - MemoryBlock* mbPtr = gs_largeBlocks[i]; - mbPtr->index = i + 1; - mbPtr->inInuse = 0; - mbPtr->size = LARGE_BLOCK_SIZE; - mbPtr->origSize = LARGE_BLOCK_SIZE; - mbPtr->memory = ((unsigned int)gs_largeBlocks[i]) + (MEMORY_BLOCK_HEADER_SIZE); - } - - for (i = 0; i < MAX_NR_BIG_BLOCKS; i++) - { - gs_bigBlocks[i] = (MemoryBlock*)malloc(BIG_BLOCK_SIZE + MEMORY_BLOCK_HEADER_SIZE); - MemoryBlock* mbPtr = gs_bigBlocks[i]; - mbPtr->index = i + 1; - mbPtr->inInuse = 0; - mbPtr->size = BIG_BLOCK_SIZE; - mbPtr->origSize = BIG_BLOCK_SIZE; - mbPtr->memory = ((unsigned int)gs_bigBlocks[i]) + (MEMORY_BLOCK_HEADER_SIZE); - } - - gs_initialized = 1; -} - -void* GetFromPool(size_t size) -{ - void* ptr = NULL; - - if (gs_initialized) - { - int i; - if (SMALL_BLOCK_SIZE >= size) - { - int nrBlocks = MAX_NR_SMALL_BLOCKS; - for (i = 0; i < nrBlocks; i++) - { - if (0 == gs_smallBlocks[i]->inInuse) - { - gs_smallBlocks[i]->inInuse = 1; - gs_smallBlocks[i]->size = size; - ptr = (void*)gs_smallBlocks[i]->memory; - break; - } - } - -#ifdef MEMORY_MANAGER_PROFILE - if (!ptr) - { - printf("Not enough small sized blocks, trying bigger block (%d,%d)\r\n", i, nrBlocks); - } - - if (i > gs_highestSmallBlock) - { - gs_highestSmallBlock = i; - } -#endif - } - - if (!ptr && (MIDDLE_BLOCK_SIZE >= size)) - { - int nrBlocks = MAX_NR_MIDDLE_BLOCKS; - for (i = 0; i < nrBlocks; i++) - { - if (0 == gs_middleBlocks[i]->inInuse) - { - gs_middleBlocks[i]->inInuse = 1; - gs_middleBlocks[i]->size = size; - ptr = (void*)gs_middleBlocks[i]->memory; - break; - } - } - -#ifdef MEMORY_MANAGER_PROFILE - if (!ptr) - { - printf("Not enough middle sized blocks, trying bigger block (%d,%d)\r\n", i, nrBlocks); - } - - if (i > gs_highestMiddleBlock) - { - gs_highestMiddleBlock = i; - } -#endif - } - - if (!ptr && (LARGE_BLOCK_SIZE >= size)) - { - int nrBlocks = MAX_NR_LARGE_BLOCKS; - for (i = 0; i < nrBlocks; i++) - { - if (0 == gs_largeBlocks[i]->inInuse) - { - gs_largeBlocks[i]->inInuse = 1; - gs_largeBlocks[i]->size = size; - ptr = (void*)gs_largeBlocks[i]->memory; - break; - } - } - -#ifdef MEMORY_MANAGER_PROFILE - if (!ptr) - { - printf("Not enough large sized blocks, trying bigger block (%d,%d)\r\n", i, nrBlocks); - } - - if (i > gs_highestLargeBlock) - { - gs_highestLargeBlock = i; - } -#endif - } - - if (!ptr && (BIG_BLOCK_SIZE >= size)) - { - int nrBlocks = MAX_NR_BIG_BLOCKS; - for (i = 0; i < nrBlocks; i++) - { - if (0 == gs_bigBlocks[i]->inInuse) - { - gs_bigBlocks[i]->inInuse = 1; - gs_bigBlocks[i]->size = size; - ptr = (void*)gs_bigBlocks[i]->memory; - break; - } - } - -#ifdef MEMORY_MANAGER_PROFILE - if (!ptr) - { - printf("Not enough big sized blocks, using dynamic memory (%d,%d)\r\n", i, nrBlocks); - } - - if (i > gs_highestBigBlock) - { - gs_highestBigBlock = i; - } -#endif - } - -#ifdef MEMORY_MANAGER_PROFILE - if (BIG_BLOCK_SIZE < size) - { - printf("Using dynamic memory allocation for size %zu\r\n", size); - } - else - { - printf("Assigned pool block (%d-%d,%d-%d,%d-%d,%d-%d). Size=%ld\r\n", - gs_highestSmallBlock, MAX_NR_SMALL_BLOCKS, - gs_highestMiddleBlock, MAX_NR_MIDDLE_BLOCKS, - gs_highestLargeBlock, MAX_NR_LARGE_BLOCKS, - gs_highestBigBlock, MAX_NR_BIG_BLOCKS, - size); - } -#endif - } - - if (!ptr) - { - void* result = malloc(size + MEMORY_BLOCK_HEADER_SIZE); - - MemoryBlock* mbPtr = (MemoryBlock*)result; - mbPtr->index = 0; - mbPtr->inInuse = 1; - mbPtr->size = size; - mbPtr->origSize = size; - mbPtr->memory = ((unsigned int)result) + (MEMORY_BLOCK_HEADER_SIZE); - ptr = (void*)mbPtr->memory; - } - - return ptr; -} - -void ReturnToPool(void* ptr) -{ - if (ptr) - { - MemoryBlock* mbPtr = (MemoryBlock*)(((unsigned int)ptr) - (MEMORY_BLOCK_HEADER_SIZE)); - if ((1 == mbPtr->inInuse) && ((void*)mbPtr->memory == ptr)) - { - if (!mbPtr->index) - { - /* Dynamic allocated item */ - free(mbPtr); - } - else - { - mbPtr->inInuse = 0; - } - } - else - { - /* This should not occur */ - printf("Free: Strange memory pointer 0x%x and %p?!\r\n", mbPtr->memory, ptr); - free(ptr); - } - } -} - -void* operator new (size_t size) -{ - return GetFromPool(size); -} - -void operator delete(void* p) -{ - ReturnToPool(p); -} -#else -void InitializePool() -{ -} -void ShutdownPool() -{ -} -#endif diff --git a/OCAMicro/OCAMicro/Src/app/OCALiteDante/OCALiteDante.vcxproj b/OCAMicro/OCAMicro/Src/app/OCALiteDante/OCALiteDante.vcxproj index 39a9509..f422af2 100644 --- a/OCAMicro/OCAMicro/Src/app/OCALiteDante/OCALiteDante.vcxproj +++ b/OCAMicro/OCAMicro/Src/app/OCALiteDante/OCALiteDante.vcxproj @@ -88,7 +88,6 @@ - @@ -102,6 +101,7 @@ + diff --git a/OCAMicro/OCAMicro/Src/app/OCALiteDante/OCALiteDante.vcxproj.filters b/OCAMicro/OCAMicro/Src/app/OCALiteDante/OCALiteDante.vcxproj.filters index 5bedec2..4fdea73 100644 --- a/OCAMicro/OCAMicro/Src/app/OCALiteDante/OCALiteDante.vcxproj.filters +++ b/OCAMicro/OCAMicro/Src/app/OCALiteDante/OCALiteDante.vcxproj.filters @@ -132,15 +132,15 @@ Source Files\OCALite\OCC\ControlClasses\Agents - - Source Files - Source Files\Platform\HostInterface\Dante Source Files\OCALite\OCC\ControlClasses\Worker\Sensors + + Source Files + diff --git a/OCAMicro/OCAMicro/Src/app/OCA_BKNII/OCALiteOCCFactory.cpp b/OCAMicro/OCAMicro/Src/app/OCALiteDante/OCALiteOCCFactory.cpp similarity index 100% rename from OCAMicro/OCAMicro/Src/app/OCA_BKNII/OCALiteOCCFactory.cpp rename to OCAMicro/OCAMicro/Src/app/OCALiteDante/OCALiteOCCFactory.cpp diff --git a/OCAMicro/OCAMicro/Src/app/OCALiteDante/OcaLiteNetworkSignalChannelDante.cpp b/OCAMicro/OCAMicro/Src/app/OCALiteDante/OcaLiteNetworkSignalChannelDante.cpp index 97f04fb..5768e61 100644 --- a/OCAMicro/OCAMicro/Src/app/OCALiteDante/OcaLiteNetworkSignalChannelDante.cpp +++ b/OCAMicro/OCAMicro/Src/app/OCALiteDante/OcaLiteNetworkSignalChannelDante.cpp @@ -102,7 +102,8 @@ ::OcaLiteStatus OcaLiteNetworkSignalChannelDante::Execute(const ::IOcaLiteReader if (reader.Read(bytesLeft, &pCmdParameters, numberOfParameters) && (0 == numberOfParameters)) { - ::OcaLiteString label(std::string(DanteLiteHostInterfaceGetDanteChannelLabel(m_channelNr, (GetSourceOrSink() == OCANETWORKMEDIASOURCEORSINK_SINK)))); + ::OcaLiteString label; + DanteLiteHostInterfaceGetDanteChannelLabel(m_channelNr, (GetSourceOrSink() == OCANETWORKMEDIASOURCEORSINK_SINK), label); ::OcaUint32 responseSize(::GetSizeValue< ::OcaUint8>(static_cast< ::OcaUint8>(1), writer) + label.GetSize(writer)); responseBuffer = ::OcaLiteCommandHandler::GetInstance().GetResponseBuffer(responseSize); diff --git a/OCAMicro/OCAMicro/Src/app/OCALiteDante/makefileBIN b/OCAMicro/OCAMicro/Src/app/OCALiteDante/makefileBIN deleted file mode 100644 index 57da78d..0000000 --- a/OCAMicro/OCAMicro/Src/app/OCALiteDante/makefileBIN +++ /dev/null @@ -1,52 +0,0 @@ -# By downloading or using this file, the user agrees to be bound by the terms of the license -# agreement located at http://ocaalliance.com/EULA as an original contracting party. -# -# Description : Makefile for the OCALite proto -# - -NAME_MKE := makefileBIN - -TARGETS = uBlaze - -TYPE = EXE -NAME = OCALiteProto - -USRINC = $(OCA_HOME)/../Application/inc; \ - $(OCA_HOME)/Src; \ - $(OCA_HOME)/Src/common; \ - $(OCA_HOME)/Src/inc; \ - $(OCA_HOME)/Src/common/OCALite; \ - $(OCA_HOME)/Src/platform; - -USRDEFS = __LINUX__ HAVE_CONFIG_H - -UBLAZESYSTEMLIBS = dapi dns_sd - -# The order of the libs is important for the GNU linker! -# A library that depends on another library should before the library it depends on. -LIBS = OCALiteProtoLIB - -SRC_INC = $(OCA_HOME)/../Application/src \ - $(OCA_HOME)/Src/app/OCA_PI \ - $(OCA_HOME)/Src/app/Stm32CortexM3/OCALitePrototype \ - ./HostInterface/OCA/OCF/Configuration \ - ./HostInterface/OCA/OCF/Logging \ - ./HostInterface/OCA/OCF/Timer \ - ./HostInterface/OCA/OCF \ - ./HostInterface/OCA/OCP.1/Network \ - ./HostInterface/OCA/OCP.1/ZeroConf \ - ./HostInterface/OCA/OCP.1 - -SRCS = OCALiteDante.cpp \ - Ocp1HostInterfaceOcaLite.cpp \ - OcaLiteOcp1Network.cpp \ - OcaLiteOcp1Socket.cpp \ - OcaLiteOcp1Service.cpp \ - OcaLiteOcfConfiguration.cpp \ - OcaLiteOcfLogger.cpp \ - OcaLiteOcfTimer.cpp \ - OcaLiteStreamNetworkDante.cpp \ - OcaLiteNetworkSignalChannelDante.cpp \ - DanteLiteHostInterface.cpp - -include $(OCA_HOME)/Src/makeCpp.inc diff --git a/OCAMicro/OCAMicro/Src/app/OCALiteDante/makefileLIB b/OCAMicro/OCAMicro/Src/app/OCALiteDante/makefileLIB deleted file mode 100644 index 1b08b27..0000000 --- a/OCAMicro/OCAMicro/Src/app/OCALiteDante/makefileLIB +++ /dev/null @@ -1,150 +0,0 @@ -# By downloading or using this file, the user agrees to be bound by the terms of the license -# agreement located at http://ocaalliance.com/EULA as an original contracting party. -# -# Description : Makefile for the OCALite proto -# - -NAME_MKE := makefileLIB - -TARGETS = uBlaze - -TYPE = LIB -NAME = OCALiteProtoLIB - -USRINC = $(OCA_HOME)/../Application/inc; \ - $(OCA_HOME)/Src; \ - $(OCA_HOME)/Src/common; \ - $(OCA_HOME)/Src/common/OCALite/OCF; \ - $(OCA_HOME)/Src/inc; \ - $(OCA_HOME)/Src/common/OCALite; \ - $(OCA_HOME)/Src/platform; - -USRDEFS = - -SRC_INC = $(OCA_HOME)/../Application/src \ - $(OCA_HOME)/Src/common/HostInterfaceLite/OCA/OCF \ - $(OCA_HOME)/Src/common/HostInterfaceLite/OCA/OCP.1 \ - $(OCA_HOME)/Src/common/OCALite/OCC/ControlClasses/Agents \ - $(OCA_HOME)/Src/common/OCALite/OCC/ControlClasses/Managers \ - $(OCA_HOME)/Src/common/OCALite/OCC/ControlClasses/Networks \ - $(OCA_HOME)/Src/common/OCALite/OCC/ControlClasses/Workers \ - $(OCA_HOME)/Src/common/OCALite/OCC/ControlClasses/Workers/Networking \ - $(OCA_HOME)/Src/common/OCALite/OCC/ControlClasses/Workers/Actuators \ - $(OCA_HOME)/Src/common/OCALite/OCC/ControlClasses/Workers/BlocksAndMatrices \ - $(OCA_HOME)/Src/common/OCALite/OCC/ControlClasses/Workers/Sensors \ - $(OCA_HOME)/Src/common/OCALite/OCC/ControlClasses \ - $(OCA_HOME)/Src/common/OCALite/OCC/ControlDataTypes \ - $(OCA_HOME)/Src/common/OCALite/OCF \ - $(OCA_HOME)/Src/common/OCALite/OCF/Messages \ - $(OCA_HOME)/Src/common/OCALite/OCP.1 \ - $(OCA_HOME)/Src/common/OCALite/OCP.1/Messages \ - $(OCA_HOME)/Src/platform/common/OcaLite/LogicalDevices/ClockGenerator \ - $(OCA_HOME)/Src/platform/common/OcaLite/LogicalDevices/Switch \ - $(OCA_HOME)/Src/platform/common/OcaLite/HostInterface/OCA/OCF/Logging \ - $(OCA_HOME)/Src/platform/common/OcaLite/HostInterface/OCA/OCF/Timer \ - $(OCA_HOME)/Src/platform/common/OcaLite/HostInterface/OCA/OCF/Configuration \ - $(OCA_HOME)/Src/platform/common/OcaLite/HostInterface/OCA/OCP.1 \ - $(OCA_HOME)/Src/platform/common/OcaLite/HostInterface/OCA/OCP.1/Network \ - $(OCA_HOME)/Src/platform/common/OcaLite/HostInterface/OCA/OCP.1/ZeroConf - -SRCS = OcfLiteHostInterface.cpp \ - Ocp1LiteHostInterface.cpp \ - OcaLiteAgent.cpp \ - OcaLiteNetwork.cpp \ - OcaLiteDeviceManager.cpp \ - OcaLiteFirmwareManager.cpp \ - OcaLiteManager.cpp \ - OcaLiteNetworkManager.cpp \ - OcaLiteSubscriptionManager.cpp \ - OcaLiteWorker.cpp \ - OcaLiteBooleanActuator.cpp \ - OcaLiteSwitch.cpp \ - OcaLiteGain.cpp \ - OcaLiteActuator.cpp \ - OcaLiteBasicActuator.cpp \ - OcaLiteBitstringActuator.cpp \ - OcaLiteBlock.cpp \ - OcaLiteBlobDataType.cpp \ - OcaLiteBasicSensor.cpp \ - OcaLiteBitstringSensor.cpp \ - OcaLiteInt8Sensor.cpp \ - OcaLiteLevelSensor.cpp \ - OcaLiteSensor.cpp \ - OcaLiteStreamNetwork.cpp \ - OcaLiteNetworkSignalChannel.cpp \ - OcaLiteMediaClockRate.cpp \ - OcaLiteMediaClock.cpp \ - OcaLiteMediaClockManager.cpp \ - OcaLiteRoot.cpp \ - OcaLiteBlob.cpp \ - OcaLiteMap.cpp \ - OcaLiteMultiMap.cpp \ - OcaLiteMediaSinkConnector.cpp \ - OcaLiteNetworkSystemInterfaceDescriptor.cpp \ - OcaLiteMediaSinkConnectorChangedEventData.cpp \ - OcaLiteMediaSourceConnector.cpp \ - OcaLiteMediaSourceConnectorChangedEventData.cpp \ - OcaLiteMediaStreamParameters.cpp \ - OcaLiteMediaStreamParametersAes67.cpp \ - OcaLiteBlobFixedLen.cpp \ - OcaLiteBlockMember.cpp \ - OcaLiteClassID.cpp \ - OcaLiteClassIdentification.cpp \ - OcaLiteEvent.cpp \ - OcaLiteStreamNetwork.cpp \ - OcaLiteStreamConnector.cpp \ - OcaLiteApplicationNetwork.cpp \ - OcaLiteMediaTransportNetwork.cpp \ - OcaLiteMediaTransportNetworkAES67.cpp \ - OcaLiteAES67NetworkAddress.cpp \ - OcaLiteApplicationNetworkDataTypes.cpp \ - OcaLiteEventData.cpp \ - OcaLiteEventID.cpp \ - OcaLiteEventSubscriptionDataTypes.cpp \ - OcaLiteFrameworkDataTypes.cpp \ - OcaLiteList.cpp \ - OcaLiteManagementDataTypes.cpp \ - OcaLiteManagerDescriptor.cpp \ - OcaLiteMethod.cpp \ - OcaLiteMethodID.cpp \ - OcaLiteModelDescription.cpp \ - OcaLiteModelGUID.cpp \ - OcaLiteNetworkAddress.cpp \ - OcaLiteNetworkDataTypes.cpp \ - OcaLiteNetworkStatistics.cpp \ - OcaLiteNetworkSystemInterfaceID.cpp \ - OcaLiteObjectIdentification.cpp \ - OcaLitePort.cpp \ - OcaLitePortID.cpp \ - OcaLiteStream.cpp \ - OcaLiteStreamID.cpp \ - OcaLiteStreamParameters.cpp \ - OcaLiteStreamConnectorID.cpp \ - OcaLitePropertyChangedEventData.cpp \ - OcaLitePropertyID.cpp \ - OcaLiteString.cpp \ - OcaLiteStringInABlob.cpp \ - OcaLiteTemplateHelpers.cpp \ - OcaLiteVersion.cpp \ - OcaLiteWorkerDataTypes.cpp \ - OcaLiteBitstring.cpp \ - OcaLiteCommandHandler.cpp \ - OcaLiteHeader.cpp \ - OcaLiteMessageCommand.cpp \ - OcaLiteMessageGeneral.cpp \ - OcaLiteMessageKeepAlive.cpp \ - OcaLiteMessageNotification.cpp \ - OcaLiteMessageResponse.cpp \ - Ocp1LiteNetwork.cpp \ - Ocp1LiteNetworkAddress.cpp \ - Ocp1LiteNetworkSystemInterfaceID.cpp \ - Ocp1LiteReader.cpp \ - Ocp1LiteSocketConnection.cpp \ - Ocp1LiteWriter.cpp \ - Ocp1LiteMessageCommand.cpp \ - Ocp1LiteMessageHeader.cpp \ - Ocp1LiteMessageKeepAlive.cpp \ - Ocp1LiteMessageNotification.cpp \ - Ocp1LiteMessageResponse.cpp - -include $(OCA_HOME)/Src/makeCpp.inc diff --git a/OCAMicro/OCAMicro/Src/app/OCA_BKNII/OCAMicroBrk.vcxproj b/OCAMicro/OCAMicro/Src/app/OCA_BKNII/OCAMicroBrk.vcxproj index f8f34b6..3b5a6c1 100644 --- a/OCAMicro/OCAMicro/Src/app/OCA_BKNII/OCAMicroBrk.vcxproj +++ b/OCAMicro/OCAMicro/Src/app/OCA_BKNII/OCAMicroBrk.vcxproj @@ -173,8 +173,8 @@ + - diff --git a/OCAMicro/OCAMicro/Src/app/OCA_BKNII/OCAMicroBrk.vcxproj.filters b/OCAMicro/OCAMicro/Src/app/OCA_BKNII/OCAMicroBrk.vcxproj.filters index 67125da..d814328 100644 --- a/OCAMicro/OCAMicro/Src/app/OCA_BKNII/OCAMicroBrk.vcxproj.filters +++ b/OCAMicro/OCAMicro/Src/app/OCA_BKNII/OCAMicroBrk.vcxproj.filters @@ -375,10 +375,10 @@ Platform\HostInterface\Dante - + App - + App diff --git a/OCAMicro/OCAMicro/Src/app/OCA_BKNII/makefileBIN b/OCAMicro/OCAMicro/Src/app/OCA_BKNII/makefileBIN index ff7cbf0..8a8c456 100644 --- a/OCAMicro/OCAMicro/Src/app/OCA_BKNII/makefileBIN +++ b/OCAMicro/OCAMicro/Src/app/OCA_BKNII/makefileBIN @@ -9,7 +9,7 @@ NAME_MKE := makefileBIN TARGETS = uBlaze TYPE = EXE -NAME = OCALiteProto +NAME = OCALiteBKNII USRINC = $(OCA_HOME)/../Application/inc; \ $(OCA_HOME)/Src; \ @@ -20,13 +20,13 @@ USRINC = $(OCA_HOME)/../Application/inc; \ $(OCA_HOME)/Src/app/OCALiteDante; \ -USRDEFS = __LINUX__ HAVE_CONFIG_H _LINUX_ DANTE_CM_METERING_SUBSCRIPTIONS +USRDEFS = __LINUX__ HAVE_CONFIG_H _LINUX_ DANTE_CM_METERING_SUBSCRIPTIONS BKN_1 UBLAZESYSTEMLIBS = dapi dns_sd # The order of the libs is important for the GNU linker! # A library that depends on another library should before the library it depends on. -LIBS = OCALiteProtoLIB +LIBS = OCALiteBKNLIB SRC_INC = $(OCA_HOME)/../Application/src \ $(OCA_HOME)/Src/app/OCA_PI \ @@ -49,11 +49,11 @@ SRCS = OCALiteDante.cpp \ OcaLiteOcfConfiguration.cpp \ OcaLiteOcfLogger.cpp \ OcaLiteOcfTimer.cpp \ - DanteLiteHostInterface.cpp \ - DanteLiteConMon.cpp \ OcaLiteStreamNetworkDante.cpp \ OcaLiteNetworkSignalChannelDante.cpp \ OcaLiteDanteLvlSensor.cpp \ - OcaLiteDanteMediaClock.cpp + DanteLiteHostInterface.cpp \ + OcaLiteDanteMediaClock.cpp \ + DanteLiteConMon.cpp include $(OCA_HOME)/Src/makeCpp.inc diff --git a/OCAMicro/OCAMicro/Src/app/OCA_BKNII/makefileLIB b/OCAMicro/OCAMicro/Src/app/OCA_BKNII/makefileLIB index 1b08b27..76a2932 100644 --- a/OCAMicro/OCAMicro/Src/app/OCA_BKNII/makefileLIB +++ b/OCAMicro/OCAMicro/Src/app/OCA_BKNII/makefileLIB @@ -9,7 +9,7 @@ NAME_MKE := makefileLIB TARGETS = uBlaze TYPE = LIB -NAME = OCALiteProtoLIB +NAME = OCALiteBKNLIB USRINC = $(OCA_HOME)/../Application/inc; \ $(OCA_HOME)/Src; \ diff --git a/OCAMicro/OCAMicro/buildmicro b/OCAMicro/OCAMicro/buildmicro index 78c407f..645f73d 100644 --- a/OCAMicro/OCAMicro/buildmicro +++ b/OCAMicro/OCAMicro/buildmicro @@ -2,10 +2,6 @@ # agreement located at http://ocaalliance.com/EULA as an original contracting party. #!/bin/bash -export LOGFILE=/dev/null -export BBE_REV=3.4.1 -export BBE_HOME=~/bbe-${BBE_REV} - export here=`pwd` export OCA_HOME=$here