Skip to content

Commit d2cdb9c

Browse files
rbernonjulliard
authored andcommitted
dmime: Use one-liners for segment parameter checks.
1 parent 3ff263d commit d2cdb9c

File tree

1 file changed

+95
-107
lines changed

1 file changed

+95
-107
lines changed

dlls/dmime/segment.c

+95-107
Original file line numberDiff line numberDiff line change
@@ -98,67 +98,71 @@ static ULONG WINAPI segment_Release(IDirectMusicSegment8 *iface)
9898
return ref;
9999
}
100100

101-
static HRESULT WINAPI segment_GetLength(IDirectMusicSegment8 *iface, MUSIC_TIME *pmtLength)
101+
static HRESULT WINAPI segment_GetLength(IDirectMusicSegment8 *iface, MUSIC_TIME *length)
102102
{
103-
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
103+
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
104104

105-
TRACE("(%p, %p)\n", This, pmtLength);
106-
if (NULL == pmtLength) {
107-
return E_POINTER;
108-
}
109-
*pmtLength = This->header.mtLength;
110-
return S_OK;
105+
TRACE("(%p, %p)\n", This, length);
106+
107+
if (!length) return E_POINTER;
108+
*length = This->header.mtLength;
109+
110+
return S_OK;
111111
}
112112

113-
static HRESULT WINAPI segment_SetLength(IDirectMusicSegment8 *iface, MUSIC_TIME mtLength)
113+
static HRESULT WINAPI segment_SetLength(IDirectMusicSegment8 *iface, MUSIC_TIME length)
114114
{
115-
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
115+
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
116116

117-
TRACE("(%p, %ld)\n", This, mtLength);
118-
This->header.mtLength = mtLength;
119-
return S_OK;
117+
TRACE("(%p, %ld)\n", This, length);
118+
119+
This->header.mtLength = length;
120+
121+
return S_OK;
120122
}
121123

122-
static HRESULT WINAPI segment_GetRepeats(IDirectMusicSegment8 *iface, DWORD *pdwRepeats)
124+
static HRESULT WINAPI segment_GetRepeats(IDirectMusicSegment8 *iface, DWORD *repeats)
123125
{
124-
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
126+
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
125127

126-
TRACE("(%p, %p)\n", This, pdwRepeats);
127-
if (NULL == pdwRepeats) {
128-
return E_POINTER;
129-
}
130-
*pdwRepeats = This->header.dwRepeats;
131-
return S_OK;
128+
TRACE("(%p, %p)\n", This, repeats);
129+
130+
if (!repeats) return E_POINTER;
131+
*repeats = This->header.dwRepeats;
132+
133+
return S_OK;
132134
}
133135

134-
static HRESULT WINAPI segment_SetRepeats(IDirectMusicSegment8 *iface, DWORD dwRepeats)
136+
static HRESULT WINAPI segment_SetRepeats(IDirectMusicSegment8 *iface, DWORD repeats)
135137
{
136-
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
138+
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
137139

138-
TRACE("(%p, %ld)\n", This, dwRepeats);
139-
This->header.dwRepeats = dwRepeats;
140-
return S_OK;
140+
TRACE("(%p, %ld)\n", This, repeats);
141+
This->header.dwRepeats = repeats;
142+
143+
return S_OK;
141144
}
142145

143-
static HRESULT WINAPI segment_GetDefaultResolution(IDirectMusicSegment8 *iface, DWORD *pdwResolution)
146+
static HRESULT WINAPI segment_GetDefaultResolution(IDirectMusicSegment8 *iface, DWORD *resolution)
144147
{
145-
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
148+
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
146149

147-
TRACE("(%p, %p)\n", This, pdwResolution);
148-
if (NULL == pdwResolution) {
149-
return E_POINTER;
150-
}
151-
*pdwResolution = This->header.dwResolution;
152-
return S_OK;
150+
TRACE("(%p, %p)\n", This, resolution);
151+
152+
if (!resolution) return E_POINTER;
153+
*resolution = This->header.dwResolution;
154+
155+
return S_OK;
153156
}
154157

155-
static HRESULT WINAPI segment_SetDefaultResolution(IDirectMusicSegment8 *iface, DWORD dwResolution)
158+
static HRESULT WINAPI segment_SetDefaultResolution(IDirectMusicSegment8 *iface, DWORD resolution)
156159
{
157-
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
160+
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
158161

159-
TRACE("(%p, %ld)\n", This, dwResolution);
160-
This->header.dwResolution = dwResolution;
161-
return S_OK;
162+
TRACE("(%p, %ld)\n", This, resolution);
163+
This->header.dwResolution = resolution;
164+
165+
return S_OK;
162166
}
163167

164168
static HRESULT WINAPI segment_GetTrack(IDirectMusicSegment8 *iface, REFGUID rguidType,
@@ -294,56 +298,43 @@ static HRESULT WINAPI segment_RemoveTrack(IDirectMusicSegment8 *iface, IDirectMu
294298
}
295299

296300
static HRESULT WINAPI segment_InitPlay(IDirectMusicSegment8 *iface,
297-
IDirectMusicSegmentState **ppSegState, IDirectMusicPerformance *pPerformance, DWORD dwFlags)
301+
IDirectMusicSegmentState **state, IDirectMusicPerformance *performance, DWORD flags)
298302
{
299-
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
300-
HRESULT hr;
303+
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
304+
HRESULT hr;
301305

302-
FIXME("(%p, %p, %p, %ld): semi-stub\n", This, ppSegState, pPerformance, dwFlags);
303-
if (NULL == ppSegState) {
304-
return E_POINTER;
305-
}
306-
hr = create_dmsegmentstate(&IID_IDirectMusicSegmentState,(void**) ppSegState);
307-
if (FAILED(hr)) {
308-
return hr;
309-
}
310-
/* TODO: DMUS_SEGF_FLAGS */
311-
return S_OK;
306+
FIXME("(%p, %p, %p, %ld): semi-stub\n", This, state, performance, flags);
307+
308+
if (!state) return E_POINTER;
309+
if (FAILED(hr = create_dmsegmentstate(&IID_IDirectMusicSegmentState, (void **)state))) return hr;
310+
311+
/* TODO: DMUS_SEGF_FLAGS */
312+
return S_OK;
312313
}
313314

314-
static HRESULT WINAPI segment_GetGraph(IDirectMusicSegment8 *iface, IDirectMusicGraph **ppGraph)
315+
static HRESULT WINAPI segment_GetGraph(IDirectMusicSegment8 *iface, IDirectMusicGraph **graph)
315316
{
316-
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
317+
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
317318

318-
FIXME("(%p, %p): semi-stub\n", This, ppGraph);
319-
if (NULL == ppGraph) {
320-
return E_POINTER;
321-
}
322-
if (NULL == This->pGraph) {
323-
return DMUS_E_NOT_FOUND;
324-
}
325-
/**
326-
* should return This, as seen in msdn
327-
* "...The segment object implements IDirectMusicGraph directly..."
328-
*/
329-
*ppGraph = This->pGraph;
330-
IDirectMusicGraph_AddRef(This->pGraph);
331-
return S_OK;
319+
FIXME("(%p, %p): semi-stub\n", This, graph);
320+
321+
if (!graph) return E_POINTER;
322+
if (!(*graph = This->pGraph)) return DMUS_E_NOT_FOUND;
323+
IDirectMusicGraph_AddRef(This->pGraph);
324+
325+
return S_OK;
332326
}
333327

334-
static HRESULT WINAPI segment_SetGraph(IDirectMusicSegment8 *iface, IDirectMusicGraph *pGraph)
328+
static HRESULT WINAPI segment_SetGraph(IDirectMusicSegment8 *iface, IDirectMusicGraph *graph)
335329
{
336-
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
330+
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
337331

338-
FIXME("(%p, %p): to complete\n", This, pGraph);
339-
if (NULL != This->pGraph) {
340-
IDirectMusicGraph_Release(This->pGraph);
341-
}
342-
This->pGraph = pGraph;
343-
if (NULL != This->pGraph) {
344-
IDirectMusicGraph_AddRef(This->pGraph);
345-
}
346-
return S_OK;
332+
FIXME("(%p, %p): to complete\n", This, graph);
333+
334+
if (This->pGraph) IDirectMusicGraph_Release(This->pGraph);
335+
if ((This->pGraph = graph)) IDirectMusicGraph_AddRef(This->pGraph);
336+
337+
return S_OK;
347338
}
348339

349340
static HRESULT WINAPI segment_AddNotificationType(IDirectMusicSegment8 *iface, REFGUID rguidNotificationType)
@@ -451,28 +442,27 @@ static HRESULT WINAPI segment_Clone(IDirectMusicSegment8 *iface, MUSIC_TIME star
451442
return track_clone_fail ? S_FALSE : S_OK;
452443
}
453444

454-
static HRESULT WINAPI segment_SetStartPoint(IDirectMusicSegment8 *iface, MUSIC_TIME mtStart)
445+
static HRESULT WINAPI segment_SetStartPoint(IDirectMusicSegment8 *iface, MUSIC_TIME start)
455446
{
456-
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
447+
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
457448

458-
TRACE("(%p, %ld)\n", This, mtStart);
459-
if (mtStart >= This->header.mtLength) {
460-
return DMUS_E_OUT_OF_RANGE;
461-
}
462-
This->header.mtPlayStart = mtStart;
463-
return S_OK;
449+
TRACE("(%p, %ld)\n", This, start);
450+
451+
if (start >= This->header.mtLength) return DMUS_E_OUT_OF_RANGE;
452+
This->header.mtPlayStart = start;
453+
454+
return S_OK;
464455
}
465456

466-
static HRESULT WINAPI segment_GetStartPoint(IDirectMusicSegment8 *iface, MUSIC_TIME *pmtStart)
457+
static HRESULT WINAPI segment_GetStartPoint(IDirectMusicSegment8 *iface, MUSIC_TIME *start)
467458
{
468-
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
459+
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
469460

470-
TRACE("(%p, %p)\n", This, pmtStart);
471-
if (NULL == pmtStart) {
472-
return E_POINTER;
473-
}
474-
*pmtStart = This->header.mtPlayStart;
475-
return S_OK;
461+
TRACE("(%p, %p)\n", This, start);
462+
if (!start) return E_POINTER;
463+
*start = This->header.mtPlayStart;
464+
465+
return S_OK;
476466
}
477467

478468
static HRESULT WINAPI segment_SetLoopPoints(IDirectMusicSegment8 *iface, MUSIC_TIME start, MUSIC_TIME end)
@@ -481,27 +471,25 @@ static HRESULT WINAPI segment_SetLoopPoints(IDirectMusicSegment8 *iface, MUSIC_T
481471

482472
TRACE("(%p, %ld, %ld)\n", This, start, end);
483473

484-
if ((end || start) &&
485-
(start >= This->header.mtLength || end > This->header.mtLength || start > end))
474+
if ((end || start) && (start >= This->header.mtLength || end > This->header.mtLength || start > end))
486475
return DMUS_E_OUT_OF_RANGE;
487-
488476
This->header.mtLoopStart = start;
489477
This->header.mtLoopEnd = end;
490478

491479
return S_OK;
492480
}
493481

494-
static HRESULT WINAPI segment_GetLoopPoints(IDirectMusicSegment8 *iface, MUSIC_TIME *pmtStart, MUSIC_TIME *pmtEnd)
482+
static HRESULT WINAPI segment_GetLoopPoints(IDirectMusicSegment8 *iface, MUSIC_TIME *start, MUSIC_TIME *end)
495483
{
496-
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
484+
IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
497485

498-
TRACE("(%p, %p, %p)\n", This, pmtStart, pmtEnd);
499-
if (NULL == pmtStart || NULL == pmtEnd) {
500-
return E_POINTER;
501-
}
502-
*pmtStart = This->header.mtLoopStart;
503-
*pmtEnd = This->header.mtLoopEnd;
504-
return S_OK;
486+
TRACE("(%p, %p, %p)\n", This, start, end);
487+
488+
if (!start || !end) return E_POINTER;
489+
*start = This->header.mtLoopStart;
490+
*end = This->header.mtLoopEnd;
491+
492+
return S_OK;
505493
}
506494

507495
static HRESULT WINAPI segment_SetPChannelsUsed(IDirectMusicSegment8 *iface, DWORD dwNumPChannels, DWORD *paPChannels)

0 commit comments

Comments
 (0)