msvcr80: Add some 64-bit only exports.
[wine] / dlls / dmusic / clock.c
1 /*
2  * IReferenceClock Implementation
3  *
4  * Copyright (C) 2003-2004 Rok Mandeljc
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
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 GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include "dmusic_private.h"
22
23 WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
24
25 static inline IReferenceClockImpl *impl_from_IReferenceClock(IReferenceClock *iface)
26 {
27     return CONTAINING_RECORD(iface, IReferenceClockImpl, IReferenceClock_iface);
28 }
29
30 /* IReferenceClockImpl IUnknown part: */
31 static HRESULT WINAPI IReferenceClockImpl_QueryInterface(IReferenceClock *iface, REFIID riid, LPVOID *ppobj)
32 {
33         IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
34         TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
35
36         if (IsEqualIID (riid, &IID_IUnknown) || 
37             IsEqualIID (riid, &IID_IReferenceClock)) {
38                 IUnknown_AddRef(iface);
39                 *ppobj = This;
40                 return S_OK;
41         }
42         WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
43         return E_NOINTERFACE;
44 }
45
46 static ULONG WINAPI IReferenceClockImpl_AddRef(IReferenceClock *iface)
47 {
48     IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
49     ULONG ref = InterlockedIncrement(&This->ref);
50
51     TRACE("(%p)->(): new ref = %u\n", This, ref);
52
53     DMUSIC_LockModule();
54
55     return ref;
56 }
57
58 static ULONG WINAPI IReferenceClockImpl_Release(IReferenceClock *iface)
59 {
60     IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
61     ULONG ref = InterlockedDecrement(&This->ref);
62
63     TRACE("(%p)->(): new ref = %u\n", This, ref);
64
65     if (!ref)
66         HeapFree(GetProcessHeap(), 0, This);
67
68     DMUSIC_UnlockModule();
69
70     return ref;
71 }
72
73 /* IReferenceClockImpl IReferenceClock part: */
74 static HRESULT WINAPI IReferenceClockImpl_GetTime(IReferenceClock *iface, REFERENCE_TIME* pTime)
75 {
76     IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
77
78     TRACE("(%p)->(%p)\n", This, pTime);
79
80     *pTime = This->rtTime;
81
82     return S_OK;
83 }
84
85 static HRESULT WINAPI IReferenceClockImpl_AdviseTime(IReferenceClock *iface, REFERENCE_TIME baseTime, REFERENCE_TIME streamTime, HANDLE hEvent, DWORD* pdwAdviseCookie)
86 {
87     IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
88
89     FIXME("(%p)->(0x%s, 0x%s, %p, %p): stub\n", This, wine_dbgstr_longlong(baseTime), wine_dbgstr_longlong(streamTime), hEvent, pdwAdviseCookie);
90
91     return S_OK;
92 }
93
94 static HRESULT WINAPI IReferenceClockImpl_AdvisePeriodic(IReferenceClock *iface, REFERENCE_TIME startTime, REFERENCE_TIME periodTime, HANDLE hSemaphore, DWORD* pdwAdviseCookie)
95 {
96     IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
97
98     FIXME("(%p)->(0x%s, 0x%s, %p, %p): stub\n", This, wine_dbgstr_longlong(startTime), wine_dbgstr_longlong(periodTime), hSemaphore, pdwAdviseCookie);
99
100     return S_OK;
101 }
102
103 static HRESULT WINAPI IReferenceClockImpl_Unadvise(IReferenceClock *iface, DWORD dwAdviseCookie)
104 {
105     IReferenceClockImpl *This = impl_from_IReferenceClock(iface);
106
107     FIXME("(%p)->(%d): stub\n", This, dwAdviseCookie);
108
109     return S_OK;
110 }
111
112 static const IReferenceClockVtbl ReferenceClock_Vtbl = {
113         IReferenceClockImpl_QueryInterface,
114         IReferenceClockImpl_AddRef,
115         IReferenceClockImpl_Release,
116         IReferenceClockImpl_GetTime,
117         IReferenceClockImpl_AdviseTime,
118         IReferenceClockImpl_AdvisePeriodic,
119         IReferenceClockImpl_Unadvise
120 };
121
122 /* for ClassFactory */
123 HRESULT DMUSIC_CreateReferenceClockImpl(LPCGUID riid, LPVOID* ret_iface, LPUNKNOWN unkouter)
124 {
125     IReferenceClockImpl* clock;
126
127     TRACE("(%p,%p,%p)\n", riid, ret_iface, unkouter);
128
129     clock = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IReferenceClockImpl));
130     if (!clock) {
131         *ret_iface = NULL;
132         return E_OUTOFMEMORY;
133     }
134
135     clock->IReferenceClock_iface.lpVtbl = &ReferenceClock_Vtbl;
136     clock->ref = 0; /* Will be inited by QueryInterface */
137     clock->rtTime = 0;
138     clock->pClockInfo.dwSize = sizeof (DMUS_CLOCKINFO);
139
140     return IReferenceClockImpl_QueryInterface((IReferenceClock*)clock, riid, ret_iface);
141 }