Don't use old_spacing-1 if old_spacing already has the minimum value.
[wine] / dlls / dsound / propset.c
1 /*                      DirectSound
2  *
3  * Copyright 1998 Marcus Meissner
4  * Copyright 1998 Rob Riggs
5  * Copyright 2000-2002 TransGaming Technologies, Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #include "config.h"
23 #include <assert.h>
24 #include <stdio.h>
25 #include <sys/types.h>
26 #include <sys/fcntl.h>
27 #ifdef HAVE_UNISTD_H
28 # include <unistd.h>
29 #endif
30 #include <stdlib.h>
31 #include <string.h>
32 #include <math.h>       /* Insomnia - pow() function */
33
34 #include "windef.h"
35 #include "winbase.h"
36 #include "wingdi.h"
37 #include "winuser.h"
38 #include "winerror.h"
39 #include "mmsystem.h"
40 #include "winternl.h"
41 #include "mmddk.h"
42 #include "wine/windef16.h"
43 #include "wine/debug.h"
44 #include "dsound.h"
45 #include "dsdriver.h"
46 #include "dsound_private.h"
47
48 WINE_DEFAULT_DEBUG_CHANNEL(dsound);
49
50
51 /*******************************************************************************
52  *              IKsPropertySet
53  */
54
55 /* IUnknown methods */
56 static HRESULT WINAPI IKsPropertySetImpl_QueryInterface(
57         LPKSPROPERTYSET iface, REFIID riid, LPVOID *ppobj
58 ) {
59         ICOM_THIS(IKsPropertySetImpl,iface);
60
61         TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
62         return IDirectSoundBuffer_QueryInterface((LPDIRECTSOUNDBUFFER8)This->dsb, riid, ppobj);
63 }
64
65 static ULONG WINAPI IKsPropertySetImpl_AddRef(LPKSPROPERTYSET iface) {
66         ICOM_THIS(IKsPropertySetImpl,iface);
67         ULONG ulReturn;
68
69         ulReturn = InterlockedIncrement(&This->ref);
70         if (ulReturn == 1)
71                 IDirectSoundBuffer_AddRef((LPDIRECTSOUND3DBUFFER)This->dsb);
72         return ulReturn;
73 }
74
75 static ULONG WINAPI IKsPropertySetImpl_Release(LPKSPROPERTYSET iface) {
76         ICOM_THIS(IKsPropertySetImpl,iface);
77         ULONG ulReturn;
78
79         ulReturn = InterlockedDecrement(&This->ref);
80         if (ulReturn)
81                 return ulReturn;
82         IDirectSoundBuffer_Release((LPDIRECTSOUND3DBUFFER)This->dsb);
83         return 0;
84 }
85
86 static HRESULT WINAPI IKsPropertySetImpl_Get(LPKSPROPERTYSET iface,
87         REFGUID guidPropSet, ULONG dwPropID,
88         LPVOID pInstanceData, ULONG cbInstanceData,
89         LPVOID pPropData, ULONG cbPropData,
90         PULONG pcbReturned
91 ) {
92         ICOM_THIS(IKsPropertySetImpl,iface);
93
94         FIXME("(%p,%s,%ld,%p,%ld,%p,%ld,%p), stub!\n",This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData,pcbReturned);
95         return E_PROP_ID_UNSUPPORTED;
96 }
97
98 static HRESULT WINAPI IKsPropertySetImpl_Set(LPKSPROPERTYSET iface,
99         REFGUID guidPropSet, ULONG dwPropID,
100         LPVOID pInstanceData, ULONG cbInstanceData,
101         LPVOID pPropData, ULONG cbPropData
102 ) {
103         ICOM_THIS(IKsPropertySetImpl,iface);
104
105         FIXME("(%p,%s,%ld,%p,%ld,%p,%ld), stub!\n",This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData);
106         return E_PROP_ID_UNSUPPORTED;
107 }
108
109 static HRESULT WINAPI IKsPropertySetImpl_QuerySupport(LPKSPROPERTYSET iface,
110         REFGUID guidPropSet, ULONG dwPropID, PULONG pTypeSupport
111 ) {
112         ICOM_THIS(IKsPropertySetImpl,iface);
113
114         FIXME("(%p,%s,%ld,%p), stub!\n",This,debugstr_guid(guidPropSet),dwPropID,pTypeSupport);
115         return E_PROP_ID_UNSUPPORTED;
116 }
117
118 static ICOM_VTABLE(IKsPropertySet) iksvt = {
119         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
120         IKsPropertySetImpl_QueryInterface,
121         IKsPropertySetImpl_AddRef,
122         IKsPropertySetImpl_Release,
123         IKsPropertySetImpl_Get,
124         IKsPropertySetImpl_Set,
125         IKsPropertySetImpl_QuerySupport
126 };
127
128 HRESULT WINAPI IKsPropertySetImpl_Create(
129         IDirectSoundBufferImpl *This,
130         IKsPropertySetImpl **piks)
131 {
132         IKsPropertySetImpl *iks;
133
134         iks = (IKsPropertySetImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(*iks));
135         iks->ref = 0;
136         iks->dsb = This;
137         ICOM_VTBL(iks) = &iksvt;
138
139         *piks = iks;
140         return S_OK;
141 }