// Function that does getaddrinfo() and calls the callback function when // the result is available. // TODO: actually make this function asynchronous. Right now it just calls // getaddrinfo() (which blocks) and then schedules the callback. ResolveState * getaddrinfoAsync(const char *node, const char *service, const struct addrinfo *hints, ResolveFlags *flags, ResolveCallback callback, ResolveErrorCallback errorCallback, ResolveCallbackArg extra) { ResolveState *resolveState; resolveState = ResolveState_new(); resolveState->refCount = 1; #ifdef DEBUG_RESOLVE_REF log_add(log_Debug, "ResolveState %08" PRIxPTR ": ref=1 (%d)\n", (uintptr_t) resolveState, resolveState->refCount); #endif resolveState->state = Resolve_resolving; resolveState->flags = *flags; resolveState->callback = callback; resolveState->errorCallback = errorCallback; resolveState->extra = extra; resolveState->result = NULL; resolveState->error.gaiRes = getaddrinfo(node, service, hints, &resolveState->result); resolveState->error.err = errno; resolveState->callbackID = Callback_add( (CallbackFunction) resolveCallback, (CallbackArg) resolveState); return resolveState; }
static void DoTrackTag (TFB_SoundChunk *chunk) { if (chunk->callback) Callback_add(chunk->callback, 0); cur_sub_chunk = chunk; }