3 * Copyright (c) 2002 Frodo
4 * Portions Copyright (c) by the authors of ffmpeg and xvid
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 //////////////////////////////////////////////////////////////////////
25 // Construction/Destruction
26 //////////////////////////////////////////////////////////////////////
28 CEvent::CEvent(bool manual
)
31 m_hEvent
= CreateEvent(NULL
, TRUE
, FALSE
, NULL
);
33 m_hEvent
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
36 CEvent::CEvent(const CEvent
& src
)
38 if(DuplicateHandle( GetCurrentProcess()
44 , DUPLICATE_SAME_ACCESS
))
46 CLog::Log(LOGERROR
, "CEvent - failed to duplicate handle");
47 m_hEvent
= INVALID_HANDLE_VALUE
;
53 CloseHandle(m_hEvent
);
56 CEvent
& CEvent::operator=(const CEvent
& src
)
58 CloseHandle(m_hEvent
);
60 if(DuplicateHandle( GetCurrentProcess()
66 , DUPLICATE_SAME_ACCESS
))
68 CLog::Log(LOGERROR
, "CEvent - failed to duplicate handle");
69 m_hEvent
= INVALID_HANDLE_VALUE
;
79 WaitForSingleObject(m_hEvent
, INFINITE
);
85 if (m_hEvent
) SetEvent(m_hEvent
);
91 if (m_hEvent
) ResetEvent(m_hEvent
);
94 HANDLE
CEvent::GetHandle()
99 bool CEvent::WaitMSec(unsigned int milliSeconds
)
104 DWORD dwResult
= WaitForSingleObject(m_hEvent
, milliSeconds
);
105 if (dwResult
== WAIT_OBJECT_0
) return true;