@@ -190,52 +190,44 @@ static HRESULT WINAPI segment_SetDefaultResolution(IDirectMusicSegment8 *iface,
190
190
return S_OK ;
191
191
}
192
192
193
- static HRESULT WINAPI segment_GetTrack (IDirectMusicSegment8 * iface , REFGUID rguidType ,
194
- DWORD dwGroupBits , DWORD dwIndex , IDirectMusicTrack * * ppTrack )
193
+ static HRESULT WINAPI segment_GetTrack (IDirectMusicSegment8 * iface , REFGUID type , DWORD group ,
194
+ DWORD index , IDirectMusicTrack * * ret_track )
195
195
{
196
196
struct segment * This = impl_from_IDirectMusicSegment8 (iface );
197
- CLSID pIt_clsid ;
198
- struct list * pEntry = NULL ;
199
- struct track_entry * pIt = NULL ;
200
- IPersistStream * pCLSIDStream = NULL ;
197
+ struct track_entry * entry ;
201
198
HRESULT hr = S_OK ;
202
199
203
- TRACE ("(%p, %s, %#lx, %#lx, %p)\n" , This , debugstr_dmguid (rguidType ), dwGroupBits , dwIndex , ppTrack );
200
+ TRACE ("(%p, %s, %#lx, %#lx, %p)\n" , This , debugstr_dmguid (type ), group , index , ret_track );
204
201
205
- if (NULL == ppTrack ) {
206
- return E_POINTER ;
207
- }
202
+ if (!ret_track ) return E_POINTER ;
208
203
209
- LIST_FOR_EACH (pEntry , & This -> tracks ) {
210
- pIt = LIST_ENTRY (pEntry , struct track_entry , entry );
211
- TRACE (" - %p -> %#lx,%p\n" , pIt , pIt -> dwGroupBits , pIt -> pTrack );
212
- if (0xFFFFFFFF != dwGroupBits && 0 == (pIt -> dwGroupBits & dwGroupBits )) continue ;
213
- if (FALSE == IsEqualGUID (& GUID_NULL , rguidType )) {
214
- /**
215
- * it rguidType is not null we must check if CLSIDs are equal
216
- * and the unique way to get it is using IPersistStream Interface
217
- */
218
- hr = IDirectMusicTrack_QueryInterface (pIt -> pTrack , & IID_IPersistStream , (void * * ) & pCLSIDStream );
219
- if (FAILED (hr )) {
220
- ERR ("(%p): object %p don't implement IPersistStream Interface. Expect a crash (critical problem)\n" , This , pIt -> pTrack );
221
- continue ;
204
+ LIST_FOR_EACH_ENTRY (entry , & This -> tracks , struct track_entry , entry )
205
+ {
206
+ if (group != -1 && !(entry -> dwGroupBits & group )) continue ;
207
+
208
+ if (!IsEqualGUID (& GUID_NULL , type ))
209
+ {
210
+ CLSID entry_type = GUID_NULL ;
211
+ IPersistStream * persist ;
212
+
213
+ if (SUCCEEDED (hr = IDirectMusicTrack_QueryInterface (entry -> pTrack , & IID_IPersistStream , (void * * )& persist )))
214
+ {
215
+ hr = IPersistStream_GetClassID (persist , & entry_type );
216
+ if (SUCCEEDED (hr )) TRACE (" - %p -> %s\n" , entry , debugstr_dmguid (& entry_type ));
217
+ IPersistStream_Release (persist );
218
+ }
219
+
220
+ if (!IsEqualGUID (& entry_type , type )) continue ;
222
221
}
223
- hr = IPersistStream_GetClassID (pCLSIDStream , & pIt_clsid );
224
- IPersistStream_Release (pCLSIDStream ); pCLSIDStream = NULL ;
225
- if (FAILED (hr )) {
226
- ERR ("(%p): non-implemented GetClassID for object %p\n" , This , pIt -> pTrack );
227
- continue ;
222
+
223
+ if (!index -- )
224
+ {
225
+ * ret_track = entry -> pTrack ;
226
+ IDirectMusicTrack_AddRef (entry -> pTrack );
227
+ return S_OK ;
228
228
}
229
- TRACE (" - %p -> %s\n" , pIt , debugstr_dmguid (& pIt_clsid ));
230
- if (FALSE == IsEqualGUID (& pIt_clsid , rguidType )) continue ;
231
- }
232
- if (0 == dwIndex ) {
233
- * ppTrack = pIt -> pTrack ;
234
- IDirectMusicTrack_AddRef (* ppTrack );
235
- return S_OK ;
236
- }
237
- -- dwIndex ;
238
- }
229
+ }
230
+
239
231
return DMUS_E_NOT_FOUND ;
240
232
}
241
233
0 commit comments