Wait until the thread has created its message queue before posting a
[wine] / dlls / dmime / segmentstate.c
1 /* IDirectMusicSegmentState8 Implementation
2  *
3  * Copyright (C) 2003-2004 Rok Mandeljc
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #include "dmime_private.h"
21
22 WINE_DEFAULT_DEBUG_CHANNEL(dmime);
23
24 /* IDirectMusicSegmentState8Impl IUnknown part: */
25 HRESULT WINAPI IDirectMusicSegmentState8Impl_QueryInterface (LPDIRECTMUSICSEGMENTSTATE8 iface, REFIID riid, LPVOID *ppobj) {
26         IDirectMusicSegmentState8Impl *This = (IDirectMusicSegmentState8Impl *)iface;
27         TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
28
29         if (IsEqualIID(riid, &IID_IUnknown) || 
30             IsEqualIID(riid, &IID_IDirectMusicSegmentState) ||
31             IsEqualIID(riid, &IID_IDirectMusicSegmentState8)) {
32                 IDirectMusicSegmentState8Impl_AddRef(iface);
33                 *ppobj = This;
34                 return S_OK;
35         }
36         WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
37         return E_NOINTERFACE;
38 }
39
40 ULONG WINAPI IDirectMusicSegmentState8Impl_AddRef (LPDIRECTMUSICSEGMENTSTATE8 iface) {
41         IDirectMusicSegmentState8Impl *This = (IDirectMusicSegmentState8Impl *)iface;
42         TRACE("(%p): AddRef from %ld\n", This, This->ref);
43         return ++(This->ref);
44 }
45
46 ULONG WINAPI IDirectMusicSegmentState8Impl_Release (LPDIRECTMUSICSEGMENTSTATE8 iface) {
47         IDirectMusicSegmentState8Impl *This = (IDirectMusicSegmentState8Impl *)iface;
48         ULONG ref = --This->ref;
49         TRACE("(%p): ReleaseRef to %ld\n", This, This->ref);
50         if (ref == 0) {
51                 HeapFree(GetProcessHeap(), 0, This);
52         }
53         return ref;
54 }
55
56 /* IDirectMusicSegmentState8Impl IDirectMusicSegmentState part: */
57 HRESULT WINAPI IDirectMusicSegmentState8Impl_GetRepeats (LPDIRECTMUSICSEGMENTSTATE8 iface,  DWORD* pdwRepeats) {
58         IDirectMusicSegmentState8Impl *This = (IDirectMusicSegmentState8Impl *)iface;
59         FIXME("(%p, %p): stub\n", This, pdwRepeats);
60         return S_OK;
61 }
62
63 HRESULT WINAPI IDirectMusicSegmentState8Impl_GetSegment (LPDIRECTMUSICSEGMENTSTATE8 iface, IDirectMusicSegment** ppSegment) {
64         IDirectMusicSegmentState8Impl *This = (IDirectMusicSegmentState8Impl *)iface;
65         FIXME("(%p, %p): stub\n", This, ppSegment);
66         return S_OK;
67 }
68
69 HRESULT WINAPI IDirectMusicSegmentState8Impl_GetStartTime (LPDIRECTMUSICSEGMENTSTATE8 iface, MUSIC_TIME* pmtStart) {
70         IDirectMusicSegmentState8Impl *This = (IDirectMusicSegmentState8Impl *)iface;
71         FIXME("(%p, %p): stub\n", This, pmtStart);
72         return S_OK;
73 }
74
75 HRESULT WINAPI IDirectMusicSegmentState8Impl_GetSeek (LPDIRECTMUSICSEGMENTSTATE8 iface, MUSIC_TIME* pmtSeek) {
76         IDirectMusicSegmentState8Impl *This = (IDirectMusicSegmentState8Impl *)iface;
77         FIXME("(%p, %p): stub\n", This, pmtSeek);
78         return S_OK;
79 }
80
81 HRESULT WINAPI IDirectMusicSegmentState8Impl_GetStartPoint (LPDIRECTMUSICSEGMENTSTATE8 iface, MUSIC_TIME* pmtStart) {
82         IDirectMusicSegmentState8Impl *This = (IDirectMusicSegmentState8Impl *)iface;
83         FIXME("(%p, %p): stub\n", This, pmtStart);
84         return S_OK;
85 }
86
87 /* IDirectMusicSegmentState8Impl IDirectMusicSegmentState8 part: */
88 HRESULT WINAPI IDirectMusicSegmentState8Impl_SetTrackConfig (LPDIRECTMUSICSEGMENTSTATE8 iface, REFGUID rguidTrackClassID, DWORD dwGroupBits, DWORD dwIndex, DWORD dwFlagsOn, DWORD dwFlagsOff) {
89         IDirectMusicSegmentState8Impl *This = (IDirectMusicSegmentState8Impl *)iface;
90         FIXME("(%p, %s, %ld, %ld, %ld, %ld): stub\n", This, debugstr_dmguid(rguidTrackClassID), dwGroupBits, dwIndex, dwFlagsOn, dwFlagsOff);
91         return S_OK;
92 }
93
94 HRESULT WINAPI IDirectMusicSegmentState8Impl_GetObjectInPath (LPDIRECTMUSICSEGMENTSTATE8 iface, DWORD dwPChannel, DWORD dwStage, DWORD dwBuffer, REFGUID guidObject, DWORD dwIndex, REFGUID iidInterface, void** ppObject) {
95         IDirectMusicSegmentState8Impl *This = (IDirectMusicSegmentState8Impl *)iface;
96         FIXME("(%p, %ld, %ld, %ld, %s, %ld, %s, %p): stub\n", This, dwPChannel, dwStage, dwBuffer, debugstr_dmguid(guidObject), dwIndex, debugstr_dmguid(iidInterface), ppObject);
97         return S_OK;
98 }
99
100 IDirectMusicSegmentState8Vtbl DirectMusicSegmentState8_Vtbl = {
101         IDirectMusicSegmentState8Impl_QueryInterface,
102         IDirectMusicSegmentState8Impl_AddRef,
103         IDirectMusicSegmentState8Impl_Release,
104         IDirectMusicSegmentState8Impl_GetRepeats,
105         IDirectMusicSegmentState8Impl_GetSegment,
106         IDirectMusicSegmentState8Impl_GetStartTime,
107         IDirectMusicSegmentState8Impl_GetSeek,
108         IDirectMusicSegmentState8Impl_GetStartPoint,
109         IDirectMusicSegmentState8Impl_SetTrackConfig,
110         IDirectMusicSegmentState8Impl_GetObjectInPath
111 };
112
113 /* for ClassFactory */
114 HRESULT WINAPI DMUSIC_CreateDirectMusicSegmentStateImpl (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter) {
115         IDirectMusicSegmentState8Impl* obj;
116         
117         obj = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicSegmentState8Impl));
118         if (NULL == obj) {
119                 *ppobj = NULL;
120                 return E_OUTOFMEMORY;
121         }
122         obj->lpVtbl = &DirectMusicSegmentState8_Vtbl;
123         obj->ref = 0; /* will be inited by QueryInterface */
124         
125         return IDirectMusicSegmentState8Impl_QueryInterface ((LPDIRECTMUSICSEGMENTSTATE8)obj, lpcGUID, ppobj);
126 }