private static NvHostEvent GetFreeEvent( ServiceCtx Context, NvHostSyncpt Syncpt, int Id, out int EventIndex) { NvHostEvent[] Events = GetUserCtx(Context).Events; EventIndex = NvHostCtrlUserCtx.EventsCount; int NullIndex = NvHostCtrlUserCtx.EventsCount; for (int Index = 0; Index < NvHostCtrlUserCtx.EventsCount; Index++) { NvHostEvent Event = Events[Index]; if (Event != null) { if (Event.State == NvHostEventState.Registered || Event.State == NvHostEventState.Free) { EventIndex = Index; if (Event.Id == Id) { return(Event); } } } else if (NullIndex == NvHostCtrlUserCtx.EventsCount) { NullIndex = Index; } } if (NullIndex < NvHostCtrlUserCtx.EventsCount) { EventIndex = NullIndex; return(Events[NullIndex] = new NvHostEvent()); } if (EventIndex < NvHostCtrlUserCtx.EventsCount) { return(Events[EventIndex]); } return(null); }
private static NvHostEvent GetFreeEvent( ServiceCtx context, NvHostSyncpt syncpt, int id, out int eventIndex) { NvHostEvent[] events = GetUserCtx(context).Events; eventIndex = NvHostCtrlUserCtx.EventsCount; int nullIndex = NvHostCtrlUserCtx.EventsCount; for (int index = 0; index < NvHostCtrlUserCtx.EventsCount; index++) { NvHostEvent Event = events[index]; if (Event != null) { if (Event.State == NvHostEventState.Registered || Event.State == NvHostEventState.Free) { eventIndex = index; if (Event.Id == id) { return(Event); } } } else if (nullIndex == NvHostCtrlUserCtx.EventsCount) { nullIndex = index; } } if (nullIndex < NvHostCtrlUserCtx.EventsCount) { eventIndex = nullIndex; return(events[nullIndex] = new NvHostEvent()); } if (eventIndex < NvHostCtrlUserCtx.EventsCount) { return(events[eventIndex]); } return(null); }