|
22 | 22 | WINE_DEFAULT_DEBUG_CHANNEL(dmband);
|
23 | 23 | WINE_DECLARE_DEBUG_CHANNEL(dmfile);
|
24 | 24 |
|
| 25 | +struct band_entry |
| 26 | +{ |
| 27 | + struct list entry; |
| 28 | + DMUS_PRIVATE_BAND_ITEM_HEADER head; |
| 29 | + IDirectMusicBand *band; |
| 30 | +}; |
| 31 | + |
| 32 | +static void band_entry_destroy(struct band_entry *entry) |
| 33 | +{ |
| 34 | + IDirectMusicTrack_Release(entry->band); |
| 35 | + free(entry); |
| 36 | +} |
| 37 | + |
25 | 38 | struct band_track
|
26 | 39 | {
|
27 | 40 | IDirectMusicTrack8 IDirectMusicTrack8_iface;
|
28 | 41 | struct dmobject dmobj; /* IPersistStream only */
|
29 | 42 | LONG ref;
|
30 | 43 | DMUS_IO_BAND_TRACK_HEADER header;
|
31 |
| - struct list Bands; |
| 44 | + struct list bands; |
32 | 45 | };
|
33 | 46 |
|
34 | 47 | static inline struct band_track *impl_from_IDirectMusicTrack8(IDirectMusicTrack8 *iface)
|
@@ -76,7 +89,18 @@ static ULONG WINAPI band_track_Release(IDirectMusicTrack8 *iface)
|
76 | 89 |
|
77 | 90 | TRACE("(%p) ref=%ld\n", This, ref);
|
78 | 91 |
|
79 |
| - if (!ref) free(This); |
| 92 | + if (!ref) |
| 93 | + { |
| 94 | + struct band_entry *entry, *next; |
| 95 | + |
| 96 | + LIST_FOR_EACH_ENTRY_SAFE(entry, next, &This->bands, struct band_entry, entry) |
| 97 | + { |
| 98 | + list_remove(&entry->entry); |
| 99 | + band_entry_destroy(entry); |
| 100 | + } |
| 101 | + |
| 102 | + free(This); |
| 103 | + } |
80 | 104 |
|
81 | 105 | return ref;
|
82 | 106 | }
|
@@ -337,13 +361,14 @@ static HRESULT load_band(struct band_track *This, IStream *pClonedStream,
|
337 | 361 | /*
|
338 | 362 | * @TODO insert pBand into This
|
339 | 363 | */
|
340 |
| - if (SUCCEEDED(hr)) { |
341 |
| - LPDMUS_PRIVATE_BAND pNewBand; |
342 |
| - if (!(pNewBand = calloc(1, sizeof(*pNewBand)))) return E_OUTOFMEMORY; |
343 |
| - pNewBand->BandHeader = *pHeader; |
344 |
| - pNewBand->band = *ppBand; |
345 |
| - IDirectMusicBand_AddRef(*ppBand); |
346 |
| - list_add_tail (&This->Bands, &pNewBand->entry); |
| 364 | + if (SUCCEEDED(hr)) |
| 365 | + { |
| 366 | + struct band_entry *entry; |
| 367 | + if (!(entry = calloc(1, sizeof(*entry)))) return E_OUTOFMEMORY; |
| 368 | + entry->head = *pHeader; |
| 369 | + entry->band = *ppBand; |
| 370 | + IDirectMusicBand_AddRef(*ppBand); |
| 371 | + list_add_tail(&This->bands, &entry->entry); |
347 | 372 | }
|
348 | 373 |
|
349 | 374 | return S_OK;
|
@@ -635,7 +660,7 @@ HRESULT create_dmbandtrack(REFIID lpcGUID, void **ppobj)
|
635 | 660 | track->ref = 1;
|
636 | 661 | dmobject_init(&track->dmobj, &CLSID_DirectMusicBandTrack, (IUnknown *)&track->IDirectMusicTrack8_iface);
|
637 | 662 | track->dmobj.IPersistStream_iface.lpVtbl = &band_track_persist_stream_vtbl;
|
638 |
| - list_init (&track->Bands); |
| 663 | + list_init(&track->bands); |
639 | 664 |
|
640 | 665 | hr = IDirectMusicTrack8_QueryInterface(&track->IDirectMusicTrack8_iface, lpcGUID, ppobj);
|
641 | 666 | IDirectMusicTrack8_Release(&track->IDirectMusicTrack8_iface);
|
|
0 commit comments