HRESULT avcCmdSignalSource(AVC_HEADER *pHeader, PB *packetBlock, pDataStream pStream) { HRESULT hResultError = E_PKT_AVC_NOT_IMPLEMENTED; HRESULT hResult = NO_ERROR; uint8 inByte = 0; uint16 inVal = 0; uint8 dest_su = 0; uint8 dest_plug_id = 0; uint8 source_su = 0; uint8 source_plug_id = 0; uint8 status = 0; AVC_SIGNAL_PATH *path = NULL; switch (pHeader->ctype) { case AVC_CTYPE_NOTIFY: // - : M:Mandatory, R:Recommended, O:Optional, -:Not Defined hResultError = E_PKT_AVC_REJECTED; break; case AVC_CTYPE_STATUS: // - : M:Mandatory, R:Recommended, O:Optional, -:Not Defined hResultError = E_PKT_AVC_REJECTED; // operand[0,1]: 0xFFFF hResult = dsRead16Bits(pStream, &inVal); if (hResult != NO_ERROR) return hResultError; if (inVal != 0xFFFF) return hResultError; // operand[2]: 0xFE hResult = dsRead8Bits(pStream, &inByte); if (hResult != NO_ERROR) return hResultError; if (inByte != 0xFE) return hResultError; // operand[3]: signal_dest_su hResult = dsRead8Bits(pStream, &dest_su); if (hResult != NO_ERROR) return hResultError; // operand[4]: signal_dest_plug_id hResult = dsRead8Bits(pStream, &dest_plug_id); if (hResult != NO_ERROR) return hResultError; // incoming status command has parsed successfully SYS_DEBUG(SYSDEBUG_TRACE_AVC_MUSIC, "Sig Src status: dest_su: 0x%02x, dest_plug_id 0x%02x\n\r", dest_su, dest_plug_id); hResult = targetSignalSourceFindPath(dest_plug_id, dest_su, &source_plug_id, &source_su, &status, &path); if (NO_ERROR != hResult) { return E_PKT_AVC_REJECTED; } // reply with the appropriate contents - go back to beginning of operand[0] hResult = dsGotoMarker(pStream, DSMARKER_OPERAND_0); if (hResult != NO_ERROR) return hResultError; hResult = dsSwitchMode(pStream, dsMODE_WRITE); if (hResult != NO_ERROR) return hResultError; // operand[0]: 3:output_status, 1:conv, 4:signal_status hResult = dsWrite8Bits(pStream, status); if (hResult != NO_ERROR) return hResultError; // operand[1]: source_su hResult = dsWrite8Bits(pStream, source_su); if (hResult != NO_ERROR) return hResultError; // operand[2]: source_plug_id hResult = dsWrite8Bits(pStream, source_plug_id); if (hResult != NO_ERROR) return hResultError; // operand[3]: dest_su hResult = dsWrite8Bits(pStream, dest_su); if (hResult != NO_ERROR) return hResultError; // operand[4]: dest_plug_id hResult = dsWrite8Bits(pStream, dest_plug_id); if (hResult != NO_ERROR) return hResultError; if (pHeader->ctype == AVC_CTYPE_STATUS) { hResult = E_PKT_AVC_STABLE; } break; case AVC_CTYPE_SPECIFIC_INQUIRY: // asking if a plug is a possible clock sync source case AVC_CTYPE_CONTROL: // setting the clock sync source to a plug { BYTE src_su = 0; BYTE src_plug_id = 0; BYTE dst_su = 0; BYTE dst_plug_id = 0; hResultError = E_PKT_AVC_NOT_IMPLEMENTED; // operand[1]: 0x0F hResult = dsRead8Bits(pStream, &inByte); if (hResult != NO_ERROR) return hResultError; // operand[2]: signal_src subunit hResult = dsRead8Bits(pStream, &src_su); if (hResult != NO_ERROR) return hResultError; // operand[3]: signal_src plug id hResult = dsRead8Bits(pStream, &src_plug_id); if (hResult != NO_ERROR) return hResultError; // operand[4]: signal_dest subunit hResult = dsRead8Bits(pStream, &dst_su); if (hResult != NO_ERROR) return hResultError; // operand[5]: signal_dest plug id hResult = dsRead8Bits(pStream, &dst_plug_id); if (hResult != NO_ERROR) return hResultError; SYS_DEBUG(SYSDEBUG_TRACE_AVC_MUSIC, "Sig Src s_su 0x%02x, s_id 0x%02x, d_su 0x%02x, d_id 0x%02x\n\r", src_su, src_plug_id, dst_su, dst_plug_id); if ( avcDriverPlugIsSyncPath(dst_su, dst_plug_id, src_su, src_plug_id) ) { // host is asking if it can connect a unit input plug to a subunit output plug (i.e. for sync) hResult = dsGotoMarker(pStream, DSMARKER_OPERAND_0); if (hResult != NO_ERROR) return hResultError; hResult = dsSwitchMode(pStream, dsMODE_WRITE); if (hResult != NO_ERROR) return hResultError; hResult = dsWrite8Bits(pStream, 0x00); // accepted if (hResult != NO_ERROR) return hResultError; hResult = dsWrite8Bits(pStream, 0xff); if (hResult != NO_ERROR) return hResultError; if (AVC_CTYPE_SPECIFIC_INQUIRY == pHeader->ctype) { SYS_DEBUG(SYSDEBUG_TRACE_AVC_MUSIC, " accepted clock source inquiry, src_plug_id: %d\n\r", src_plug_id); return E_PKT_AVC_ACCEPTED; } else if (AVC_CTYPE_CONTROL == pHeader->ctype) // set clock source { hResult = avcDriverSetClockSrc(src_su, src_plug_id); if (hResult != NO_ERROR) return hResultError; SYS_DEBUG(SYSDEBUG_TRACE_AVC_MUSIC, " accepted set clock source, src_plug_id: %d\n\r", src_plug_id); } return E_PKT_AVC_ACCEPTED; } SYS_DEBUG(SYSDEBUG_TRACE_AVC_MUSIC, " rejected clock source inquiry\n\r"); hResult = E_PKT_AVC_REJECTED; } break; case AVC_CTYPE_GENERAL_INQUIRY: // don't even bother parsing hResult = E_PKT_AVC_IMPLEMENTED; break; default: hResult = hResultError; break; } return hResult; }
HRESULT avcUnitNotifyCheck(LM_CONTEXT* notifyList, NOTIFY_CHECK_CALLBACK notifyCheckCB, NOTIFY_UPDATE_CALLBACK notifyUpdateCB) { HRESULT hResult = NO_ERROR; uint32 pos = 0; uint32 index = 0; pDataStream pStream = NULL; UNION_NOTIFY* notify = NULL; AVC_HEADER avcHeader; BOOL bChanged = FALSE; PB *packetBlock; // determine if there is a notify on the specified subunit DO_FOREVER { hResult = lmGetNthElement(notifyList, (void **) ¬ify, pos, &index); if (hResult != NO_ERROR) return NO_ERROR; bChanged = FALSE; // call callback to make notify specific check on notify state hResult = (* notifyCheckCB) (notify, &bChanged); if (bChanged) { #ifdef _SYSDEBUG if (sysDebugIsEnabled(SYSDEBUG_TRACE_AVC & SYSDEBUG_TRACE_ERRORS)) //SYSDEBUG_TRACE_AVC { sysPrintCurTime(); sysDebugPrintf("avcUnitNotify changed state for notify\n\r"); } #endif //_SYSDEBUG hResult = pbGetApplicationDatastream(notify->notifyComm.packetBlock, &pStream); if (hResult != NO_ERROR) break; hResult = avcDecodeHeader(pStream, &avcHeader); if (hResult != NO_ERROR) break; hResult = dsGotoMarker(pStream, DSMARKER_OPERAND_0); if (hResult != NO_ERROR) break; hResult = dsSwitchMode(pStream, dsMODE_WRITE); if (hResult != NO_ERROR) break; // call callback to write notify specific data into stream (from operand[0]) hResult = (* notifyUpdateCB) (notify, pStream); if (hResult != NO_ERROR) break; packetBlock = notify->notifyComm.packetBlock; hResult = lmReleaseElement(notifyList, index); if (hResult != NO_ERROR) break; hResult = lmRemoveElement(notifyList, index); if (hResult != NO_ERROR) break; hResult = avcReplyResponse (AVC_RESPONSE_CHANGED, packetBlock); if (hResult != NO_ERROR) break; } else { lmReleaseElement(notifyList, index); pos++; } } lmReleaseElement(notifyList, index); return hResult; }