void lazyopen_wresp(struct puffs_usermount *pu, struct puffs_framebuf *pb, void *arg, int error) { struct psshfs_node *psn = arg; /* XXX: this is not enough */ if (psn->stat & PSN_RECLAIMED) { error = ENOENT; goto moreout; } if (error) goto out; error = psbuf_expect_handle(pb, &psn->fhand_w, &psn->fhand_w_len); out: psn->lazyopen_err_w = error; psn->lazyopen_w = NULL; if (error) psn->stat &= ~PSN_DOLAZY_W; if (psn->stat & PSN_HANDLECLOSE && (psn->stat & PSN_LAZYWAIT_W) == 0) closehandles(pu, psn, HANDLE_WRITE); moreout: puffs_framebuf_destroy(pb); }
static int init(struct ao *ao) { MP_VERBOSE(ao, "init!\n"); ao->format = af_fmt_from_planar(ao->format); struct mp_chmap_sel sel = {0}; mp_chmap_sel_add_waveext(&sel); if (!ao_chmap_sel_adjust(ao, &sel, &ao->channels)) return -1; struct wasapi_state *state = (struct wasapi_state *)ao->priv; state->log = ao->log; wasapi_fill_VistaBlob(state); if (state->opt_list) { wasapi_enumerate_devices(state->log, NULL, NULL); } if (state->opt_exclusive) { state->share_mode = AUDCLNT_SHAREMODE_EXCLUSIVE; } else { state->share_mode = AUDCLNT_SHAREMODE_SHARED; } state->init_done = CreateEventW(NULL, FALSE, FALSE, NULL); state->hUninit = CreateEventW(NULL, FALSE, FALSE, NULL); state->hFeed = CreateEventW(NULL, FALSE, FALSE, NULL); /* for wasapi event mode */ state->hForceFeed = CreateEventW(NULL, FALSE, FALSE, NULL); state->hFeedDone = CreateEventW(NULL, FALSE, FALSE, NULL); if (!state->init_done || !state->hFeed || !state->hUninit || !state->hForceFeed || !state->hFeedDone) { closehandles(ao); /* failed to init events */ return -1; } state->init_ret = -1; state->threadLoop = (HANDLE)CreateThread(NULL, 0, &ThreadLoop, ao, 0, NULL); if (!state->threadLoop) { /* failed to init thread */ MP_ERR(ao, "fail to create thread!\n"); return -1; } WaitForSingleObject(state->init_done, INFINITE); /* wait on init complete */ if (state->init_ret) { if (!ao->probing) { MP_ERR(ao, "thread_init failed!\n"); } } else MP_VERBOSE(ao, "Init Done!\n"); wasapi_setup_proxies(state); return state->init_ret; }
static void uninit(struct ao *ao) { MP_VERBOSE(ao, "uninit!\n"); struct wasapi_state *state = (struct wasapi_state *)ao->priv; wasapi_release_proxies(state); SetEvent(state->hUninit); /* wait up to 10 seconds */ if (WaitForSingleObject(state->threadLoop, 10000) == WAIT_TIMEOUT) MP_ERR(ao, "audio loop thread refuses to abort!"); if (state->VistaBlob.hAvrt) FreeLibrary(state->VistaBlob.hAvrt); closehandles(ao); MP_VERBOSE(ao, "uninit END!\n"); }
void cleanup() { closehandles(); }