Commit 3cfa740c authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dmsynth: Create a fluid_synth instance on Open.

parent fcc8a1be
...@@ -232,6 +232,7 @@ struct synth ...@@ -232,6 +232,7 @@ struct synth
struct list waves; struct list waves;
fluid_settings_t *fluid_settings; fluid_settings_t *fluid_settings;
fluid_synth_t *fluid_synth;
}; };
static inline struct synth *impl_from_IDirectMusicSynth8(IDirectMusicSynth8 *iface) static inline struct synth *impl_from_IDirectMusicSynth8(IDirectMusicSynth8 *iface)
...@@ -351,7 +352,8 @@ static HRESULT WINAPI synth_Open(IDirectMusicSynth8 *iface, DMUS_PORTPARAMS *par ...@@ -351,7 +352,8 @@ static HRESULT WINAPI synth_Open(IDirectMusicSynth8 *iface, DMUS_PORTPARAMS *par
if ((params->dwValidParams & DMUS_PORTPARAMS_AUDIOCHANNELS) && params->dwAudioChannels) if ((params->dwValidParams & DMUS_PORTPARAMS_AUDIOCHANNELS) && params->dwAudioChannels)
{ {
actual.dwAudioChannels = min(params->dwAudioChannels, This->caps.dwMaxAudioChannels); /* FluidSynth only works with stereo */
actual.dwAudioChannels = 2;
modified |= actual.dwAudioChannels != params->dwAudioChannels; modified |= actual.dwAudioChannels != params->dwAudioChannels;
} }
...@@ -384,6 +386,9 @@ static HRESULT WINAPI synth_Open(IDirectMusicSynth8 *iface, DMUS_PORTPARAMS *par ...@@ -384,6 +386,9 @@ static HRESULT WINAPI synth_Open(IDirectMusicSynth8 *iface, DMUS_PORTPARAMS *par
memcpy(params, &actual, size); memcpy(params, &actual, size);
} }
fluid_settings_setnum(This->fluid_settings, "synth.sample-rate", actual.dwSampleRate);
if (!(This->fluid_synth = new_fluid_synth(This->fluid_settings))) return E_OUTOFMEMORY;
This->params = actual; This->params = actual;
This->open = TRUE; This->open = TRUE;
...@@ -399,6 +404,8 @@ static HRESULT WINAPI synth_Close(IDirectMusicSynth8 *iface) ...@@ -399,6 +404,8 @@ static HRESULT WINAPI synth_Close(IDirectMusicSynth8 *iface)
if (!This->open) if (!This->open)
return DMUS_E_ALREADYCLOSED; return DMUS_E_ALREADYCLOSED;
delete_fluid_synth(This->fluid_synth);
This->fluid_synth = NULL;
This->open = FALSE; This->open = FALSE;
return S_OK; return S_OK;
......
...@@ -437,7 +437,7 @@ static void test_dmsynth(void) ...@@ -437,7 +437,7 @@ static void test_dmsynth(void)
ok(params.dwValidParams == all_params, "dwValidParams: %#lx\n", params.dwValidParams); ok(params.dwValidParams == all_params, "dwValidParams: %#lx\n", params.dwValidParams);
ok(params.dwVoices == 1, "dwVoices: %ld\n", params.dwVoices); ok(params.dwVoices == 1, "dwVoices: %ld\n", params.dwVoices);
ok(params.dwChannelGroups == 1, "dwChannelGroups: %ld\n", params.dwChannelGroups); ok(params.dwChannelGroups == 1, "dwChannelGroups: %ld\n", params.dwChannelGroups);
ok(params.dwAudioChannels == 1, "dwAudioChannels: %ld\n", params.dwAudioChannels); todo_wine ok(params.dwAudioChannels == 1, "dwAudioChannels: %ld\n", params.dwAudioChannels);
ok(params.dwSampleRate == 11025, "dwSampleRate: %ld\n", params.dwSampleRate); ok(params.dwSampleRate == 11025, "dwSampleRate: %ld\n", params.dwSampleRate);
test_synth_getformat(dmsynth, &params, "min"); test_synth_getformat(dmsynth, &params, "min");
IDirectMusicSynth_Close(dmsynth); IDirectMusicSynth_Close(dmsynth);
...@@ -525,7 +525,7 @@ static void test_dmsynth(void) ...@@ -525,7 +525,7 @@ static void test_dmsynth(void)
params.dwValidParams = DMUS_PORTPARAMS_AUDIOCHANNELS; params.dwValidParams = DMUS_PORTPARAMS_AUDIOCHANNELS;
params.dwAudioChannels = 1; params.dwAudioChannels = 1;
hr = IDirectMusicSynth_Open(dmsynth, &params); hr = IDirectMusicSynth_Open(dmsynth, &params);
ok(hr == S_OK, "Open failed: %#lx\n", hr); todo_wine_if(SUCCEEDED(hr)) ok(hr == S_OK, "Open failed: %#lx\n", hr);
hr = IDirectMusicSynthSink_GetDesiredBufferSize(dmsynth_sink, &size); hr = IDirectMusicSynthSink_GetDesiredBufferSize(dmsynth_sink, &size);
ok(hr == S_OK, "IDirectMusicSynthSink_GetDesiredBufferSize returned: %#lx\n", hr); ok(hr == S_OK, "IDirectMusicSynthSink_GetDesiredBufferSize returned: %#lx\n", hr);
ok(size == params.dwSampleRate * params.dwAudioChannels * 4, "size: %ld\n", size); ok(size == params.dwSampleRate * params.dwAudioChannels * 4, "size: %ld\n", size);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment