mspthrd.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. typedef enum {
  9. WORK_ITEM,STOP
  10. } COMMAND;
  11. typedef struct {
  12. COMMAND cmd;
  13. LPTHREAD_START_ROUTINE pfn;
  14. PVOID pContext;
  15. HANDLE hEvent;
  16. } COMMAND_NODE;
  17. typedef struct {
  18. LIST_ENTRY link;
  19. COMMAND_NODE node;
  20. } COMMAND_QUEUE_ITEM;
  21. typedef struct _NOTIF_LIST {
  22. CMSPAddress *addr;
  23. _NOTIF_LIST *next;
  24. } NOTIF_LIST,*PNOTIF_LIST;
  25. class CMSPThread {
  26. public:
  27. CMSPThread() {
  28. InitializeListHead(&m_CommandQueue);
  29. m_hCommandEvent = NULL;
  30. m_hThread = NULL;
  31. m_NotifList = NULL;
  32. m_iStartCount = 0;
  33. }
  34. ~CMSPThread() { };
  35. HRESULT Start();
  36. HRESULT Stop();
  37. HRESULT Shutdown();
  38. HRESULT ThreadProc();
  39. static LRESULT CALLBACK NotifWndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
  40. HRESULT RegisterPnpNotification(CMSPAddress *pCMSPAddress);
  41. HRESULT UnregisterPnpNotification(CMSPAddress *pCMSPAddress);
  42. HRESULT QueueWorkItem(LPTHREAD_START_ROUTINE Function,PVOID Context,WINBOOL fSynchronous);
  43. private:
  44. WINBOOL SignalThreadProc() { return SetEvent(m_hCommandEvent); }
  45. CMSPCritSection m_CountLock;
  46. CMSPCritSection m_QueueLock;
  47. int m_iStartCount;
  48. LIST_ENTRY m_CommandQueue;
  49. HANDLE m_hCommandEvent;
  50. HANDLE m_hThread;
  51. HDEVNOTIFY m_hDevNotifyVideo;
  52. HDEVNOTIFY m_hDevNotifyAudio;
  53. HWND m_hWndNotif;
  54. PNOTIF_LIST m_NotifList;
  55. CMSPCritSection m_NotifLock;
  56. };
  57. extern CMSPThread g_Thread;
  58. #endif