예제 #1
0
파일: blthreading.cpp 프로젝트: blend2d/b2d
BLResult blThreadEventCreate(BLThreadEvent* self, bool manualReset, bool signaled) noexcept {
  HANDLE h = CreateEventW(nullptr, manualReset, signaled, nullptr);
  if (BL_UNLIKELY(!h)) {
    self->handle = -1;
    return blTraceError(blResultFromWinError(GetLastError()));
  }

  self->handle = (intptr_t)h;
  return BL_SUCCESS;
}
예제 #2
0
파일: Timer.cpp 프로젝트: 4ib3r/domoticz
Timer::Timer(TelldusCore::EventRef event)
	:TelldusCore::Thread(), d(new PrivateData) {
	d->event = event;
#ifdef _WINDOWS
	d->cond = CreateEventW(NULL, false, false, NULL);
#else
	pthread_cond_init(&d->cond, NULL);
	pthread_mutex_init(&d->waitMutex, NULL);
#endif
}
QEventDispatcherWin32Private::QEventDispatcherWin32Private()
    : threadId(GetCurrentThreadId()), interrupt(false), internalHwnd(0)
{
    resolveTimerAPI();

    wakeUpNotifier.setHandle(QT_WA_INLINE(CreateEventW(0, FALSE, FALSE, 0),
                                          CreateEventA(0, FALSE, FALSE, 0)));
    if (!wakeUpNotifier.handle())
        qWarning("QEventDispatcher: Creating QEventDispatcherWin32Private wakeup event failed");
}
예제 #4
0
QWindowsFileSystemWatcherEngine::QWindowsFileSystemWatcherEngine()
    : msg(0)
{
    HANDLE h = QT_WA_INLINE(CreateEventW(0, false, false, 0),
                                CreateEventA(0, false, false, 0));
    if (h != INVALID_HANDLE_VALUE) {
        handles.reserve(MAXIMUM_WAIT_OBJECTS);
        handles.append(h);
    }
}
/// <summary>
/// Create the first connected Kinect found 
/// </summary>
/// <returns>indicates success or failure</returns>
HRESULT CSkeletonBasics::CreateFirstConnected()
{
    INuiSensor * pNuiSensor;

    int iSensorCount = 0;
    HRESULT hr = NuiGetSensorCount(&iSensorCount);
    if (FAILED(hr))
    {
        return hr;
    }

    // Look at each Kinect sensor
    for (int i = 0; i < iSensorCount; ++i)
    {
        // Create the sensor so we can check status, if we can't create it, move on to the next
        hr = NuiCreateSensorByIndex(i, &pNuiSensor);
        if (FAILED(hr))
        {
            continue;
        }

        // Get the status of the sensor, and if connected, then we can initialize it
        hr = pNuiSensor->NuiStatus();
        if (S_OK == hr)
        {
            m_pNuiSensor = pNuiSensor;
            break;
        }

        // This sensor wasn't OK, so release it since we're not using it
        pNuiSensor->Release();
    }

    if (NULL != m_pNuiSensor)
    {
        // Initialize the Kinect and specify that we'll be using skeleton
        hr = m_pNuiSensor->NuiInitialize(NUI_INITIALIZE_FLAG_USES_SKELETON); 
        if (SUCCEEDED(hr))
        {
            // Create an event that will be signaled when skeleton data is available
            m_hNextSkeletonEvent = CreateEventW(NULL, TRUE, FALSE, NULL);

            // Open a skeleton stream to receive skeleton data
            hr = m_pNuiSensor->NuiSkeletonTrackingEnable(m_hNextSkeletonEvent, 0); 
        }
    }

    if (NULL == m_pNuiSensor || FAILED(hr))
    {
        SetStatusMessage(L"No ready Kinect found!");
        return E_FAIL;
    }

    return hr;
}
예제 #6
0
파일: ksproxy.cpp 프로젝트: Moteesh/reactos
KSDDKAPI
HRESULT
WINAPI
KsSynchronousDeviceControl(
    HANDLE     Handle,
    ULONG      IoControl,
    PVOID      InBuffer,
    ULONG      InLength,
    PVOID      OutBuffer,
    ULONG      OutLength,
    PULONG     BytesReturned)
{
    OVERLAPPED Overlapped;
    DWORD Transferred;

    /* zero overlapped */
    RtlZeroMemory(&Overlapped, sizeof(OVERLAPPED));

    /* create notification event */
    Overlapped.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);

    if (!Overlapped.hEvent)
    {
        /* failed */
        return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, GetLastError());
    }

    if (!DeviceIoControl(Handle, IoControl, InBuffer, InLength, OutBuffer, OutLength, BytesReturned, &Overlapped))
    {
        /* operation failed */
        if (GetLastError() != ERROR_IO_PENDING)
        {
            /* failed */
            CloseHandle(Overlapped.hEvent);
            return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, GetLastError());
        }
    }

    /* get result of pending operation */
    if (!GetOverlappedResult(Handle, &Overlapped, &Transferred, TRUE))
    {
        /* failed */
        CloseHandle(Overlapped.hEvent);
        return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, GetLastError());
    }

    /* store number of bytes transferred */
    *BytesReturned = Transferred;

    /* close event object */
    CloseHandle(Overlapped.hEvent);

    /* done */
    return NOERROR;
}
예제 #7
0
파일: procpage.c 프로젝트: AlexSteel/wine
static DWORD WINAPI ProcessPageRefreshThread(void *lpParameter)
{
    ULONG    OldProcessorUsage = 0;
    ULONG    OldProcessCount = 0;

    WCHAR    wszCPU_Usage[255];
    WCHAR    wszProcesses[255];

    LoadStringW(hInst, IDS_STATUS_BAR_CPU_USAGE, wszCPU_Usage, sizeof(wszCPU_Usage)/sizeof(WCHAR));
    LoadStringW(hInst, IDS_STATUS_BAR_PROCESSES, wszProcesses, sizeof(wszProcesses)/sizeof(WCHAR));

    /* Create the event */
    hProcessPageEvent = CreateEventW(NULL, TRUE, TRUE, NULL);

    /* If we couldn't create the event then exit the thread */
    if (!hProcessPageEvent)
        return 0;

    while (1) {
        DWORD    dwWaitVal;

        /* Wait on the event */
        dwWaitVal = WaitForSingleObject(hProcessPageEvent, INFINITE);

        /* If the wait failed then the event object must have been */
        /* closed and the task manager is exiting so exit this thread */
        if (dwWaitVal == WAIT_FAILED)
            return 0;

        if (dwWaitVal == WAIT_OBJECT_0) {
            WCHAR    text[256];

            /* Reset our event */
            ResetEvent(hProcessPageEvent);

            if (SendMessageW(hProcessPageListCtrl, LVM_GETITEMCOUNT, 0, 0) != PerfDataGetProcessCount())
                SendMessageW(hProcessPageListCtrl, LVM_SETITEMCOUNT, PerfDataGetProcessCount(), /*LVSICF_NOINVALIDATEALL|*/LVSICF_NOSCROLL);

            if (IsWindowVisible(hProcessPage))
                InvalidateRect(hProcessPageListCtrl, NULL, FALSE);

            if (OldProcessorUsage != PerfDataGetProcessorUsage()) {
                OldProcessorUsage = PerfDataGetProcessorUsage();
                wsprintfW(text, wszCPU_Usage, OldProcessorUsage);
                SendMessageW(hStatusWnd, SB_SETTEXTW, 1, (LPARAM)text);
            }
            if (OldProcessCount != PerfDataGetProcessCount()) {
                OldProcessCount = PerfDataGetProcessCount();
                wsprintfW(text, wszProcesses, OldProcessCount);
                SendMessageW(hStatusWnd, SB_SETTEXTW, 0, (LPARAM)text);
            }
        }
    }
        return 0;
}
예제 #8
0
	bool TaskSchedulerImpl::Initialize(std::size_t workerCount)
	{
		if (IsInitialized())
			return true; // Déjà initialisé

		#if NAZARA_CORE_SAFE
		if (workerCount == 0)
		{
			NazaraError("Invalid worker count ! (0)");
			return false;
		}
		#endif

		s_workerCount = workerCount;
		s_doneEvents.reset(new HANDLE[workerCount]);
		s_workers.reset(new Worker[workerCount]);
		s_workerThreads.reset(new HANDLE[workerCount]);

		// L'identifiant de chaque worker doit rester en vie jusqu'à ce que chaque thread soit correctement lancé
		std::unique_ptr<std::size_t[]> workerIDs(new std::size_t[workerCount]);

		for (std::size_t i = 0; i < workerCount; ++i)
		{
			// On initialise les évènements, mutex et threads de chaque worker
			Worker& worker = s_workers[i];
			InitializeCriticalSection(&worker.queueMutex);
			worker.wakeEvent = CreateEventW(nullptr, false, false, nullptr);
			worker.running = true;
			worker.workCount = 0;

			s_doneEvents[i] = CreateEventW(nullptr, true, false, nullptr);

			// Le thread va se lancer, signaler qu'il est prêt à travailler (s_doneEvents) et attendre d'être réveillé
			workerIDs[i] = i;
			s_workerThreads[i] = reinterpret_cast<HANDLE>(_beginthreadex(nullptr, 0, &WorkerProc, &workerIDs[i], 0, nullptr));
		}

		// On attend que les workers se mettent en attente
		WaitForMultipleObjects(s_workerCount, &s_doneEvents[0], true, INFINITE);

		return true;
	}
예제 #9
0
파일: services.c 프로젝트: bilboed/wine
DWORD service_start(struct service_entry *service, DWORD service_argc, LPCWSTR *service_argv)
{
    DWORD err;
    LPWSTR name;
    HANDLE process_handle = NULL;

    err = scmdatabase_lock_startup(service->db);
    if (err != ERROR_SUCCESS)
        return err;

    if (service->control_pipe != INVALID_HANDLE_VALUE)
    {
        scmdatabase_unlock_startup(service->db);
        return ERROR_SERVICE_ALREADY_RUNNING;
    }

    service->control_mutex = CreateMutexW(NULL, TRUE, NULL);

    if (!service->status_changed_event)
        service->status_changed_event = CreateEventW(NULL, FALSE, FALSE, NULL);

    name = service_get_pipe_name();
    service->control_pipe = CreateNamedPipeW(name, PIPE_ACCESS_DUPLEX,
                  PIPE_TYPE_BYTE|PIPE_WAIT, 1, 256, 256, 10000, NULL );
    HeapFree(GetProcessHeap(), 0, name);
    if (service->control_pipe==INVALID_HANDLE_VALUE)
    {
        WINE_ERR("failed to create pipe for %s, error = %d\n",
            wine_dbgstr_w(service->name), GetLastError());
        scmdatabase_unlock_startup(service->db);
        return GetLastError();
    }

    err = service_start_process(service, &process_handle);

    if (err == ERROR_SUCCESS)
    {
        if (!service_send_start_message(service, service_argv, service_argc))
            err = ERROR_SERVICE_REQUEST_TIMEOUT;
    }

    if (err == ERROR_SUCCESS)
        err = service_wait_for_startup(service, process_handle);

    if (process_handle)
        CloseHandle(process_handle);

    ReleaseMutex(service->control_mutex);
    scmdatabase_unlock_startup(service->db);

    WINE_TRACE("returning %d\n", err);

    return err;
}
예제 #10
0
Kinect::Kinect(void)
{
	HRESULT hr = NuiCreateSensorByIndex(0,  &m_kinect_handle);
    if (SUCCEEDED(hr))
    {
		
		m_kinect_handle->NuiInitialize( NUI_INITIALIZE_FLAG_USES_SKELETON);
		m_hNextSkeletonEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
		hr = m_kinect_handle->NuiSkeletonTrackingEnable(m_hNextSkeletonEvent, NUI_SKELETON_TRACKING_FLAG_ENABLE_IN_NEAR_RANGE | NUI_SKELETON_TRACKING_FLAG_ENABLE_SEATED_SUPPORT);
	}
}
예제 #11
0
BOOL RPCSS_Initialize(void)
{
  static unsigned short irot_protseq[] = IROT_PROTSEQ;
  static unsigned short irot_endpoint[] = IROT_ENDPOINT;
  static unsigned short epm_protseq[] = {'n','c','a','c','n','_','n','p',0};
  static unsigned short epm_endpoint[] = {'\\','p','i','p','e','\\','e','p','m','a','p','p','e','r',0};
  static unsigned short epm_protseq_lrpc[] = {'n','c','a','l','r','p','c',0};
  static unsigned short epm_endpoint_lrpc[] = {'e','p','m','a','p','p','e','r',0};
  RPC_STATUS status;

  WINE_TRACE("\n");

  status = RpcServerRegisterIf(epm_v3_0_s_ifspec, NULL, NULL);
  if (status != RPC_S_OK)
    return status;
  status = RpcServerRegisterIf(Irot_v0_2_s_ifspec, NULL, NULL);
  if (status != RPC_S_OK)
  {
    RpcServerUnregisterIf(epm_v3_0_s_ifspec, NULL, FALSE);
    return FALSE;
  }

  status = RpcServerUseProtseqEpW(epm_protseq, RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
                                  epm_endpoint, NULL);
  if (status != RPC_S_OK)
    goto fail;

  status = RpcServerUseProtseqEpW(epm_protseq_lrpc, RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
                                  epm_endpoint_lrpc, NULL);
  if (status != RPC_S_OK)
      goto fail;

  status = RpcServerUseProtseqEpW(irot_protseq, RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
                                  irot_endpoint, NULL);
  if (status != RPC_S_OK)
    goto fail;

  status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, TRUE);
  if (status != RPC_S_OK)
    goto fail;

#ifndef __REACTOS__
  exit_event = __wine_make_process_system();
#else
  exit_event = CreateEventW(NULL, FALSE, FALSE, NULL); // never fires
#endif

  return TRUE;

fail:
  RpcServerUnregisterIf(epm_v3_0_s_ifspec, NULL, FALSE);
  RpcServerUnregisterIf(Irot_v0_2_s_ifspec, NULL, FALSE);
  return FALSE;
}
예제 #12
0
/******************************************************************
 *		NAS_InitRingMessage
 *
 * Initialize the ring of messages for passing between driver's caller and playback/record
 * thread
 */
static int NAS_InitRingMessage(MSG_RING* mr)
{
    mr->msg_toget = 0;
    mr->msg_tosave = 0;
    mr->msg_event = CreateEventW(NULL, FALSE, FALSE, NULL);
    mr->ring_buffer_size = NAS_RING_BUFFER_INCREMENT;
    mr->messages = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,mr->ring_buffer_size * sizeof(RING_MSG));
    InitializeCriticalSection(&mr->msg_crst);
    mr->msg_crst.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": MSG_RING.msg_crst");
    return 0;
}
 HOOKFUNC HANDLE WINAPI MyCreateEventW(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCWSTR lpName)
 {
     HANDLE rv = CreateEventW(lpEventAttributes, bManualReset, bInitialState, lpName);
     debuglog(LCF_SYNCOBJ | LCF_TODO, __FUNCTION__ " returned 0x%X.\n", rv);
     EnterCriticalSection(&s_handleCS);
     std::set<HANDLE>& handles = s_threadIdHandles[GetCurrentThreadId()];
     handles.insert(rv);
     //for(unsigned int i = 0; i < handles.size(); i++)
     //	debugprintf(" . 0x%X . ", handles[i]);
     LeaveCriticalSection(&s_handleCS);
     return rv;
 }
예제 #14
0
파일: change.c 프로젝트: AmesianX/RosWine
/****************************************************************************
 *		ReadDirectoryChangesW (KERNEL32.@)
 *
 * NOTES
 *
 *  The filter is remember from the first run and ignored on successive runs.
 *
 *  If there's no output buffer on the first run, it's ignored successive runs
 *   and STATUS_NOTIFY_ENUM_DIRECTORY is returned with an empty buffer.
 *
 *  If a NULL overlapped->hEvent is passed, the directory handle is used
 *   for signalling.
 */
BOOL WINAPI ReadDirectoryChangesW( HANDLE handle, LPVOID buffer, DWORD len, BOOL subtree,
                                   DWORD filter, LPDWORD returned, LPOVERLAPPED overlapped,
                                   LPOVERLAPPED_COMPLETION_ROUTINE completion )
{
    OVERLAPPED ov, *pov;
    IO_STATUS_BLOCK *ios;
    NTSTATUS status;
    BOOL ret = TRUE;
    LPVOID cvalue = NULL;

    TRACE("%p %p %08x %d %08x %p %p %p\n", handle, buffer, len, subtree, filter,
           returned, overlapped, completion );

    if (!overlapped)
    {
        memset( &ov, 0, sizeof ov );
        ov.hEvent = CreateEventW( NULL, 0, 0, NULL );
        pov = &ov;
    }
    else
    {
        pov = overlapped;
        if(completion) cvalue = completion;
        else if (((ULONG_PTR)overlapped->hEvent & 1) == 0) cvalue = overlapped;
    }

    ios = (PIO_STATUS_BLOCK) pov;
    ios->u.Status = STATUS_PENDING;

    status = NtNotifyChangeDirectoryFile( handle, completion && overlapped ? NULL : pov->hEvent,
            completion && overlapped ? invoke_completion : NULL,
            cvalue, ios, buffer, len, filter, subtree );
    if (status == STATUS_PENDING)
    {
        if (overlapped)
            return TRUE;

        WaitForSingleObjectEx( ov.hEvent, INFINITE, TRUE );
        CloseHandle( ov.hEvent );
        if (returned)
            *returned = ios->Information;
        status = ios->u.Status;
    }

    if (status != STATUS_SUCCESS)
    {
        SetLastError( RtlNtStatusToDosError(status) );
        ret = FALSE;
    }

    return ret;
}
예제 #15
0
HANDLE CreateEventA(SECURITY_ATTRIBUTES *sa, 
	BOOL manual_reset, BOOL initial_state, LPCSTR name)
{
	HANDLE h;
	LPWSTR wname;

	wname = wce_mbtowc(name);
	h = CreateEventW(sa, manual_reset,
		initial_state, wname);
	free(wname);

	return h;
}
예제 #16
0
/* Silvio Moioli: updated to use Unicode */
sbevent_t *
sbevent_init(void)
{
    sbevent_t *evt;

    evt = ckd_calloc(1, sizeof(*evt));
    evt->evt = CreateEventW(NULL, FALSE, FALSE, NULL);
    if (evt->evt == NULL) {
        ckd_free(evt);
        return NULL;
    }
    return evt;
}
예제 #17
0
파일: ao_wasapi.c 프로젝트: BILIHUBSU/mpv
static int init(struct ao *ao)
{
    MP_DBG(ao, "Init wasapi\n");
    CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);

    struct wasapi_state *state = ao->priv;
    state->log = ao->log;
    if(!wasapi_fill_VistaBlob(state))
        MP_WARN(ao, "Error loading thread priority functions\n");

    state->hInitDone = CreateEventW(NULL, FALSE, FALSE, NULL);
    state->hWake     = CreateEventW(NULL, FALSE, FALSE, NULL);
    if (!state->hInitDone || !state->hWake) {
        MP_ERR(ao, "Error creating events\n");
        uninit(ao);
        return -1;
    }

    state->init_ret = E_FAIL;
    state->hAudioThread = CreateThread(NULL, 0, &AudioThread, ao, 0, NULL);
    if (!state->hAudioThread) {
        MP_ERR(ao, "Failed to create audio thread\n");
        uninit(ao);
        return -1;
    }

    WaitForSingleObject(state->hInitDone, INFINITE); /* wait on init complete */
    SAFE_RELEASE(state->hInitDone,CloseHandle(state->hInitDone));
    if (state->init_ret != S_OK) {
        if (!ao->probing)
            MP_ERR(ao, "Received failure from audio thread\n");
        uninit(ao);
        return -1;
    }

    wasapi_setup_proxies(state);
    MP_DBG(ao, "Init wasapi done\n");
    return 0;
}
예제 #18
0
//----------------------------------------------------------------------------------------
amf_handle AMF_CDECL_CALL amf_create_event(amf_bool bInitiallyOwned, amf_bool bManualReset, const wchar_t* pName)
{
#if defined(METRO_APP)
    DWORD flags = ((bManualReset) ? CREATE_EVENT_MANUAL_RESET : 0) |
        ((bInitiallyOwned) ? CREATE_EVENT_INITIAL_SET : 0);

    return CreateEventEx(NULL, pName, flags, STANDARD_RIGHTS_ALL | EVENT_MODIFY_STATE);

#else
    return CreateEventW(NULL, bManualReset == true, bInitiallyOwned == true, pName);

#endif
}
예제 #19
0
int alcnd_init(alcnd_t *cond)
{
    _int_alcnd_t *icond = calloc(1, sizeof(*icond));
    if(!icond) return althrd_nomem;

    InitRef(&icond->wait_count, 0);

    icond->events[SIGNAL] = CreateEventW(NULL, FALSE, FALSE, NULL);
    icond->events[BROADCAST] = CreateEventW(NULL, TRUE, FALSE, NULL);
    if(!icond->events[SIGNAL] || !icond->events[BROADCAST])
    {
        if(icond->events[SIGNAL])
            CloseHandle(icond->events[SIGNAL]);
        if(icond->events[BROADCAST])
            CloseHandle(icond->events[BROADCAST]);
        free(icond);
        return althrd_error;
    }

    cond->Ptr = icond;
    return althrd_success;
}
예제 #20
0
파일: test2.c 프로젝트: l1183479157/coreclr
BOOL CreateEventTest()
{
    BOOL bRet = FALSE;
    DWORD dwRet = 0;

    LPSECURITY_ATTRIBUTES lpEventAttributes = 0;
    BOOL bManualReset = TRUE; 
    BOOL bInitialState = FALSE;
  

    /* Create an event with the Initial State set to FALSE */

    HANDLE hEvent = CreateEventW(lpEventAttributes, 
                                 bManualReset, 
                                 bInitialState, 
                                 NULL); 
 
    if (hEvent != NULL)
    {
        /* This should ensure that the object is reset, or
           non-signaled.
        */
        
        dwRet = WaitForSingleObject(hEvent,0);

        if (dwRet != WAIT_TIMEOUT)
        {
            Trace("CloseEventTest:WaitForSingleObject failed (%x)\n", GetLastError());
        }
        else
        {
            /* At this point, we've tested the function with success.
               So long as the HANDLE can be closed, this test should
               pass.
            */
            
            bRet = CloseHandle(hEvent);

            if (!bRet)
            {
                Trace("CloseEventTest:CloseHandle failed (%x)\n", GetLastError());
            }
        }
    }
    else
    {
        Trace("CloseEventTest:CreateEvent failed (%x)\n", GetLastError());
    }
    
    return bRet;
}
예제 #21
0
파일: renderer.c 프로젝트: AndreRH/wine
HRESULT WINAPI BaseRenderer_Init(BaseRenderer * This, const IBaseFilterVtbl *Vtbl, IUnknown *pUnkOuter, const CLSID *pClsid,
    DWORD_PTR DebugInfo, const BaseRendererFuncTable* pBaseFuncsTable)
{
    PIN_INFO piInput;
    HRESULT hr;

    BaseFilter_Init(&This->filter, Vtbl, pClsid, DebugInfo, &RendererBaseFilterFuncTable);

    This->pFuncsTable = pBaseFuncsTable;

    /* construct input pin */
    piInput.dir = PINDIR_INPUT;
    piInput.pFilter = &This->filter.IBaseFilter_iface;
    lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));

    hr = BaseInputPin_Construct(&BaseRenderer_InputPin_Vtbl, sizeof(BaseInputPin), &piInput,
            &input_BaseInputFuncTable, &This->filter.csFilter, NULL, (IPin **)&This->pInputPin);

    if (SUCCEEDED(hr))
    {
        hr = CreatePosPassThru(pUnkOuter ? pUnkOuter: (IUnknown *)&This->filter.IBaseFilter_iface, TRUE,
                &This->pInputPin->pin.IPin_iface, &This->pPosition);
        if (FAILED(hr))
            return hr;

        InitializeCriticalSection(&This->csRenderLock);
        This->csRenderLock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__": BaseRenderer.csRenderLock");
        This->evComplete = CreateEventW(NULL, TRUE, TRUE, NULL);
        This->ThreadSignal = CreateEventW(NULL, TRUE, TRUE, NULL);
        This->RenderEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
        This->pMediaSample = NULL;

        QualityControlImpl_Create(&This->pInputPin->pin.IPin_iface, &This->filter.IBaseFilter_iface, &This->qcimpl);
        This->qcimpl->IQualityControl_iface.lpVtbl = &Renderer_QualityControl_Vtbl;
    }

    return hr;
}
예제 #22
0
파일: time.c 프로젝트: GYGit/reactos
/**************************************************************************
 * 				TIME_SetEventInternal	[internal]
 */
WORD	TIME_SetEventInternal(UINT wDelay, UINT wResol,
                              LPTIMECALLBACK lpFunc, DWORD dwUser, UINT wFlags)
{
    WORD 		wNewID = 0;
    LPWINE_TIMERENTRY	lpNewTimer;
    LPWINE_TIMERENTRY	lpTimer;

    TRACE("(%u, %u, %p, %08lX, %04X);\n", wDelay, wResol, lpFunc, dwUser, wFlags);

    if (wDelay < MMSYSTIME_MININTERVAL || wDelay > MMSYSTIME_MAXINTERVAL)
	return 0;

    lpNewTimer = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_TIMERENTRY));
    if (lpNewTimer == NULL)
	return 0;

    TIME_MMTimeStart();

    lpNewTimer->wDelay = wDelay;
    lpNewTimer->dwTriggerTime = GetTickCount() + wDelay;

    /* FIXME - wResol is not respected, although it is not clear
               that we could change our precision meaningfully  */
    lpNewTimer->wResol = wResol;
    lpNewTimer->lpFunc = lpFunc;
    lpNewTimer->dwUser = dwUser;
    lpNewTimer->wFlags = wFlags;

    EnterCriticalSection(&WINMM_cs);

    if ((wFlags & TIME_KILL_SYNCHRONOUS) && !TIME_hKillEvent)
        TIME_hKillEvent = CreateEventW(NULL, TRUE, TRUE, NULL);

    for (lpTimer = TIME_TimersList; lpTimer != NULL; lpTimer = lpTimer->lpNext) {
	wNewID = max(wNewID, lpTimer->wTimerID);
    }

    lpNewTimer->lpNext = TIME_TimersList;
    TIME_TimersList = lpNewTimer;
    lpNewTimer->wTimerID = wNewID + 1;

    LeaveCriticalSection(&WINMM_cs);

    /* Wake the service thread in case there is work to be done */
    SetEvent(TIME_hWakeEvent);

    TRACE("=> %u\n", wNewID + 1);

    return wNewID + 1;
}
예제 #23
0
static NTSTATUS CreateHelperProcess(PWSTR FileName, ULONG Timeout, PHANDLE PProcess)
{
    HANDLE Event;
    SECURITY_ATTRIBUTES EventAttributes;
    WCHAR CommandLine[MAX_PATH + 64];
    STARTUPINFOW StartupInfo;
    PROCESS_INFORMATION ProcessInfo;
    DWORD WaitResult;
    NTSTATUS Result;

    memset(&EventAttributes, 0, sizeof EventAttributes);
    EventAttributes.nLength = sizeof EventAttributes;
    EventAttributes.bInheritHandle = TRUE;

    Event = CreateEventW(&EventAttributes, TRUE, FALSE, 0);
    if (0 == Event)
        return FspNtStatusFromWin32(GetLastError());

    StringCbPrintfW(CommandLine, sizeof CommandLine, L"\"%s\" %lx %lx",
        FileName, (ULONG)(UINT_PTR)Event, Timeout);

    memset(&StartupInfo, 0, sizeof StartupInfo);
    StartupInfo.cb = sizeof StartupInfo;

    // !!!: need hook
    if (!CreateProcessW(FileName, CommandLine, 0, 0, TRUE, 0, 0, 0, &StartupInfo, &ProcessInfo))
    {
        Result = FspNtStatusFromWin32(GetLastError());
        CloseHandle(Event);
        return Result;
    }

    WaitResult = WaitForSingleObject(Event, 3000);
    if (WaitResult == WAIT_FAILED)
        Result = FspNtStatusFromWin32(GetLastError());
    else if (WaitResult == WAIT_TIMEOUT)
        Result = STATUS_UNSUCCESSFUL;
    else
        Result = STATUS_SUCCESS;

    CloseHandle(Event);
    CloseHandle(ProcessInfo.hThread);

    if (!NT_SUCCESS(Result))
        CloseHandle(ProcessInfo.hProcess);
    else
        *PProcess = ProcessInfo.hProcess;

    return Result;
}
예제 #24
0
int CALLBACK wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int)
{
	RoInitializeWrapper roInit;

	KeywordRecognizer recognizer(ABI::Windows::Media::SpeechRecognition::SpeechRecognitionConfidence_Low,
	{
		L"Hello, world!",
		L"F**k you",
		L"DAMN SON",
		L"Allahu akbar",
		L"Google",
		L"Gmail",
		L"Why won't you f**k off"
	});

	AudioManager::Initialize();

	Sound allahu(L"ALLAHU_AKBAR", false, false);

	auto quitEvent = CreateEventW(nullptr, TRUE, FALSE, nullptr);
	Assert(quitEvent != nullptr);

	recognizer.AddCallback([&allahu, &quitEvent](const std::wstring& word)
	{
		OutputDebugStringW(word.c_str());
		OutputDebugStringW(L"\r\n");

		if (word.compare(L"Allahu akbar") == 0)
		{
			allahu.Play();
		}
		else if (word.compare(L"Google") == 0)
		{
			ShellExecute(NULL, L"open", L"http://www.google.com", NULL, NULL, SW_SHOWDEFAULT);
		}
		else if (word.compare(L"Gmail") == 0)
		{
			ShellExecute(NULL, L"open", L"http://www.gmail.com", NULL, NULL, SW_SHOWDEFAULT);
		}
		else if (word.compare(L"Why won't you f**k off") == 0)
		{
			SetEvent(quitEvent);
		}
	});

	recognizer.StartAsync();

	WaitForSingleObject(quitEvent, INFINITE);
	return 0;
};
예제 #25
0
DWORD MCIAVI_OpenAudio(WINE_MCIAVI* wma, unsigned* nHdr, LPWAVEHDR* pWaveHdr)
{
    DWORD	dwRet;
    LPWAVEHDR	waveHdr;
    unsigned	i;

    dwRet = waveOutOpen((HWAVEOUT *)&wma->hWave, WAVE_MAPPER, wma->lpWaveFormat,
                       (DWORD_PTR)MCIAVI_waveCallback, wma->wDevID, CALLBACK_FUNCTION);
    if (dwRet != 0) {
	TRACE("Can't open low level audio device %d\n", dwRet);
	dwRet = MCIERR_DEVICE_OPEN;
	wma->hWave = 0;
	goto cleanUp;
    }

    /* FIXME: should set up a heuristic to compute the number of wave headers
     * to be used...
     */
    *nHdr = 7;
    waveHdr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
			*nHdr * (sizeof(WAVEHDR) + wma->ash_audio.dwSuggestedBufferSize));
    if (!waveHdr) {
	TRACE("Can't alloc wave headers\n");
	dwRet = MCIERR_DEVICE_OPEN;
	goto cleanUp;
    }

    for (i = 0; i < *nHdr; i++) {
	/* other fields are zero:ed on allocation */
	waveHdr[i].lpData = (char*)waveHdr +
	    *nHdr * sizeof(WAVEHDR) + i * wma->ash_audio.dwSuggestedBufferSize;
	waveHdr[i].dwBufferLength = wma->ash_audio.dwSuggestedBufferSize;
	if (waveOutPrepareHeader(wma->hWave, &waveHdr[i], sizeof(WAVEHDR))) {
	    dwRet = MCIERR_INTERNAL;
	    goto cleanUp;
	}
    }

    if (wma->dwCurrVideoFrame != 0 && wma->lpWaveFormat) {
	FIXME("Should recompute dwCurrAudioBlock, except unsynchronized sound & video\n");
    }
    wma->dwCurrAudioBlock = 0;

    wma->hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
    wma->dwEventCount = *nHdr - 1;
    *pWaveHdr = waveHdr;
 cleanUp:
    return dwRet;
}
예제 #26
0
/* DP messaging stuff */
static HANDLE DP_MSG_BuildAndLinkReplyStruct( IDirectPlayImpl *This,
        DP_MSG_REPLY_STRUCT_LIST *lpReplyStructList, WORD wReplyCommandId )
{
  lpReplyStructList->replyExpected.hReceipt       = CreateEventW( NULL, FALSE, FALSE, NULL );
  lpReplyStructList->replyExpected.wExpectedReply = wReplyCommandId;
  lpReplyStructList->replyExpected.lpReplyMsg     = NULL;
  lpReplyStructList->replyExpected.dwMsgBodySize  = 0;

  /* Insert into the message queue while locked */
  EnterCriticalSection( &This->lock );
    DPQ_INSERT( This->dp2->repliesExpected, lpReplyStructList, repliesExpected );
  LeaveCriticalSection( &This->lock );

  return lpReplyStructList->replyExpected.hReceipt;
}
예제 #27
0
static struct file *dsp_alloc()
{
	struct dsp_file *f = (struct dsp_file *)kmalloc(sizeof(struct dsp_file));
	file_init(&f->custom_file.base_file, &dsp_ops, O_LARGEFILE | O_RDWR);
	virtualfs_init_custom(f, &dsp_desc);
	f->waveout = NULL;
	SECURITY_ATTRIBUTES attr;
	attr.nLength = sizeof(SECURITY_ATTRIBUTES);
	attr.bInheritHandle = FALSE;
	attr.lpSecurityDescriptor = NULL;
	for (int i = 0; i < DSP_BUFFER_COUNT; i++)
		f->buffer[i].event = CreateEventW(&attr, FALSE, TRUE, NULL);
	dsp_reset(f);
	return (struct file *)f;
}
예제 #28
0
파일: module.c 프로젝트: howard5888/wineT
/***********************************************************************
 *		MZ_RunInThread
 */
void WINAPI MZ_RunInThread( PAPCFUNC proc, ULONG_PTR arg )
{
  if (loop_thread) {
    DOS_SPC spc;
    HANDLE event;

    spc.proc = proc;
    spc.arg = arg;
    event = CreateEventW(NULL, TRUE, FALSE, NULL);
    PostThreadMessageA(loop_tid, WM_USER, (WPARAM)event, (LPARAM)&spc);
    WaitForSingleObject(event, INFINITE);
    CloseHandle(event);
  } else
    proc(arg);
}
예제 #29
0
파일: mciqtz.c 프로젝트: kholia/wine
/**************************************************************************
 *                              MCIQTZ_drvOpen                  [internal]
 */
static DWORD MCIQTZ_drvOpen(LPCWSTR str, LPMCI_OPEN_DRIVER_PARMSW modp)
{
    WINE_MCIQTZ* wma;
    static const WCHAR mciAviWStr[] = {'M','C','I','A','V','I',0};

    TRACE("(%s, %p)\n", debugstr_w(str), modp);

    /* session instance */
    if (!modp)
        return 0xFFFFFFFF;

    wma = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINE_MCIQTZ));
    if (!wma)
        return 0;

    wma->stop_event = CreateEventW(NULL, FALSE, FALSE, NULL);
    wma->task.notify = CreateEventW(NULL, FALSE, FALSE, NULL);
    if (!wma->task.notify) goto err;
    wma->task.done = CreateEventW(NULL, FALSE, FALSE, NULL);
    if (!wma->task.done)   goto err;
    wma->task.thread = CreateThread(NULL, 0, MCIQTZ_taskThread, &wma->task, 0, NULL);
    if (!wma->task.thread) goto err;
    InitializeCriticalSection(&wma->cs);
    wma->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": WINE_MCIQTZ");
    modp->wType = MCI_DEVTYPE_DIGITAL_VIDEO;
    wma->wDevID = modp->wDeviceID;
    modp->wCustomCommandTable = wma->command_table = mciLoadCommandResource(MCIQTZ_hInstance, mciAviWStr, 0);
    mciSetDriverData(wma->wDevID, (DWORD_PTR)wma);

    return modp->wDeviceID;
err:
    if (wma->task.notify) CloseHandle(wma->task.notify);
    if (wma->task.done)   CloseHandle(wma->task.done);
    HeapFree(GetProcessHeap(), 0, wma);
    return 0;
}
예제 #30
-1
파일: time.c 프로젝트: GYGit/reactos
/**************************************************************************
 * 				TIME_MMTimeStart
 */
void	TIME_MMTimeStart(void)
{
    if (!TIME_hMMTimer) {
	TIME_TimersList = NULL;
        TIME_hWakeEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
        TIME_TimeToDie = FALSE;
	TIME_hMMTimer = CreateThread(NULL, 0, TIME_MMSysTimeThread, NULL, 0, NULL);
        SetThreadPriority(TIME_hMMTimer, THREAD_PRIORITY_TIME_CRITICAL);
    }
}