dmband: Download segment tracks if performance auto-download is set.

This commit is contained in:
Rémi Bernon 2023-10-12 22:18:06 +02:00 committed by Alexandre Julliard
parent 4106217718
commit 10a1e533c3
4 changed files with 18 additions and 7 deletions

View file

@ -234,7 +234,7 @@ static HRESULT WINAPI band_track_SetParam(IDirectMusicTrack8 *iface, REFGUID typ
band_connect_to_collection(entry->band, param);
}
else if (IsEqualGUID(type, &GUID_Disable_Auto_Download))
FIXME("GUID_Disable_Auto_Download not handled yet\n");
This->header.bAutoDownload = FALSE;
else if (IsEqualGUID(type, &GUID_Download))
FIXME("GUID_Download not handled yet\n");
else if (IsEqualGUID(type, &GUID_DownloadToAudioPath))
@ -265,7 +265,7 @@ static HRESULT WINAPI band_track_SetParam(IDirectMusicTrack8 *iface, REFGUID typ
IDirectMusicPerformance_Release(performance);
}
else if (IsEqualGUID(type, &GUID_Enable_Auto_Download))
FIXME("GUID_Enable_Auto_Download not handled yet\n");
This->header.bAutoDownload = TRUE;
else if (IsEqualGUID(type, &GUID_IDirectMusicBand))
FIXME("GUID_IDirectMusicBand not handled yet\n");
else if (IsEqualGUID(type, &GUID_StandardMIDIFile))

View file

@ -75,7 +75,7 @@ extern void set_audiopath_primary_dsound_buffer(IDirectMusicAudioPath*,IDirectSo
extern HRESULT segment_state_create(IDirectMusicSegment *segment, MUSIC_TIME start_time,
IDirectMusicPerformance *performance, IDirectMusicSegmentState **ret_iface);
extern HRESULT segment_state_play(IDirectMusicSegmentState *iface, IDirectMusicPerformance *performance);
extern HRESULT segment_state_end_play(IDirectMusicSegmentState *iface);
extern HRESULT segment_state_end_play(IDirectMusicSegmentState *iface, IDirectMusicPerformance *performance);
extern HRESULT wave_track_create_from_chunk(IStream *stream, struct chunk_entry *parent,
IDirectMusicTrack8 **ret_iface);

View file

@ -1740,7 +1740,7 @@ static HRESULT WINAPI performance_tool_ProcessPMsg(IDirectMusicTool *iface,
if (IsEqualGUID(&notif->guidNotificationType, &GUID_NOTIFICATION_SEGMENT)
&& notif->dwNotificationOption == DMUS_NOTIFICATION_SEGEND)
{
if (FAILED(hr = segment_state_end_play((IDirectMusicSegmentState *)notif->punkUser)))
if (FAILED(hr = segment_state_end_play((IDirectMusicSegmentState *)notif->punkUser, performance)))
WARN("Failed to end segment state %p, hr %#lx\n", notif->punkUser, hr);
}

View file

@ -51,6 +51,7 @@ struct segment_state
MUSIC_TIME start_time;
MUSIC_TIME start_point;
MUSIC_TIME end_point;
BOOL auto_download;
struct list tracks;
};
@ -103,7 +104,7 @@ static ULONG WINAPI segment_state_Release(IDirectMusicSegmentState8 *iface)
if (!ref)
{
segment_state_end_play((IDirectMusicSegmentState *)iface);
segment_state_end_play((IDirectMusicSegmentState *)iface, NULL);
if (This->segment) IDirectMusicSegment_Release(This->segment);
free(This);
}
@ -224,8 +225,13 @@ HRESULT segment_state_create(IDirectMusicSegment *segment, MUSIC_TIME start_time
This->segment = segment;
IDirectMusicSegment_AddRef(This->segment);
if (SUCCEEDED(hr = IDirectMusicPerformance_GetGlobalParam(performance, &GUID_PerfAutoDownload,
&This->auto_download, sizeof(This->auto_download))) && This->auto_download)
hr = IDirectMusicSegment_SetParam(segment, &GUID_DownloadToAudioPath, -1,
DMUS_SEG_ALLTRACKS, 0, performance);
This->start_time = start_time;
hr = IDirectMusicSegment_GetStartPoint(segment, &This->start_point);
if (SUCCEEDED(hr)) hr = IDirectMusicSegment_GetStartPoint(segment, &This->start_point);
if (SUCCEEDED(hr)) hr = IDirectMusicSegment_GetLength(segment, &This->end_point);
for (i = 0; SUCCEEDED(hr); i++)
@ -283,10 +289,11 @@ HRESULT segment_state_play(IDirectMusicSegmentState *iface, IDirectMusicPerforma
return hr;
}
HRESULT segment_state_end_play(IDirectMusicSegmentState *iface)
HRESULT segment_state_end_play(IDirectMusicSegmentState *iface, IDirectMusicPerformance *performance)
{
struct segment_state *This = impl_from_IDirectMusicSegmentState8((IDirectMusicSegmentState8 *)iface);
struct track_entry *entry, *next;
HRESULT hr;
LIST_FOR_EACH_ENTRY_SAFE(entry, next, &This->tracks, struct track_entry, entry)
{
@ -294,5 +301,9 @@ HRESULT segment_state_end_play(IDirectMusicSegmentState *iface)
track_entry_destroy(entry);
}
if (performance && This->auto_download && FAILED(hr = IDirectMusicSegment_SetParam(This->segment,
&GUID_UnloadFromAudioPath, -1, DMUS_SEG_ALLTRACKS, 0, performance)))
ERR("Failed to unload segment from performance, hr %#lx\n", hr);
return S_OK;
}