master
 1/**
 2 * This file has no copyright assigned and is placed in the Public Domain.
 3 * This file is part of the mingw-w64 runtime package.
 4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
 5 */
 6#ifndef __MSPTHRD_H
 7#define __MSPTHRD_H
 8
 9typedef enum {
10  WORK_ITEM,STOP
11} COMMAND;
12
13typedef struct {
14  COMMAND cmd;
15  LPTHREAD_START_ROUTINE pfn;
16  PVOID pContext;
17  HANDLE hEvent;
18} COMMAND_NODE;
19
20typedef struct {
21  LIST_ENTRY link;
22  COMMAND_NODE node;
23} COMMAND_QUEUE_ITEM;
24
25typedef struct _NOTIF_LIST {
26  CMSPAddress *addr;
27  _NOTIF_LIST *next;
28} NOTIF_LIST,*PNOTIF_LIST;
29
30class CMSPThread {
31public:
32  CMSPThread() {
33    InitializeListHead(&m_CommandQueue);
34    m_hCommandEvent = NULL;
35    m_hThread = NULL;
36    m_NotifList = NULL;
37    m_iStartCount = 0;
38  }
39  ~CMSPThread() { };
40  HRESULT Start();
41  HRESULT Stop();
42  HRESULT Shutdown();
43  HRESULT ThreadProc();
44  static LRESULT CALLBACK NotifWndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
45  HRESULT RegisterPnpNotification(CMSPAddress *pCMSPAddress);
46  HRESULT UnregisterPnpNotification(CMSPAddress *pCMSPAddress);
47  HRESULT QueueWorkItem(LPTHREAD_START_ROUTINE Function,PVOID Context,WINBOOL fSynchronous);
48private:
49  WINBOOL SignalThreadProc() { return SetEvent(m_hCommandEvent); }
50  CMSPCritSection m_CountLock;
51  CMSPCritSection m_QueueLock;
52  int m_iStartCount;
53  LIST_ENTRY m_CommandQueue;
54  HANDLE m_hCommandEvent;
55  HANDLE m_hThread;
56  HDEVNOTIFY m_hDevNotifyVideo;
57  HDEVNOTIFY m_hDevNotifyAudio;
58  HWND m_hWndNotif;
59  PNOTIF_LIST m_NotifList;
60  CMSPCritSection m_NotifLock;
61};
62
63extern CMSPThread g_Thread;
64#endif