Robert Reif : dmusic: Implement just enough of IDirectMusicPortImpl_GetFormat

Alexandre Julliard julliard at wine.codeweavers.com
Wed Jan 3 05:37:28 CST 2007


Module: wine
Branch: master
Commit: 0b0b72ec35be1655247cf7128835138f58420b9b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0b0b72ec35be1655247cf7128835138f58420b9b

Author: Robert Reif <reif at earthlink.net>
Date:   Tue Jan  2 20:03:33 2007 -0500

dmusic: Implement just enough of IDirectMusicPortImpl_GetFormat
to keep Direct Sound from crashing from unitialized data.

---

 dlls/dmusic/port.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/dlls/dmusic/port.c b/dlls/dmusic/port.c
index 7329a87..63ee351 100644
--- a/dlls/dmusic/port.c
+++ b/dlls/dmusic/port.c
@@ -171,7 +171,45 @@ static HRESULT WINAPI IDirectMusicPortIm
 
 static HRESULT WINAPI IDirectMusicPortImpl_GetFormat (LPDIRECTMUSICPORT iface, LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSize, LPDWORD pdwBufferSize) {
 	IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface;
+	WAVEFORMATEX format;
 	FIXME("(%p, %p, %p, %p): stub\n", This, pWaveFormatEx, pdwWaveFormatExSize, pdwBufferSize);
+
+	if (pWaveFormatEx == NULL)
+	{
+		if (pdwWaveFormatExSize)
+			*pdwWaveFormatExSize = sizeof(format);
+		else
+			return E_POINTER;
+	}
+	else
+	{
+		if (pdwWaveFormatExSize == NULL)
+			return E_POINTER;
+
+		/* Just fill this in with something that will not crash Direct Sound for now. */
+		/* It won't be used anyway until Performances are completed */
+		format.wFormatTag = WAVE_FORMAT_PCM;
+		format.nChannels = 2; /* This->params.dwAudioChannels; */
+		format.nSamplesPerSec = 44100; /* This->params.dwSampleRate; */
+		format.wBitsPerSample = 16;	/* FIXME: check this */
+		format.nBlockAlign = (format.wBitsPerSample * format.nChannels) / 8;
+		format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign;
+		format.cbSize = 0;
+
+		if (*pdwWaveFormatExSize >= sizeof(format))
+		{
+			CopyMemory(pWaveFormatEx, &format, min(sizeof(format), *pdwWaveFormatExSize));
+			*pdwWaveFormatExSize = sizeof(format);	/* FIXME check if this is set */
+		}
+		else
+			return E_POINTER;	/* FIXME find right error */
+	}
+
+	if (pdwBufferSize)
+		*pdwBufferSize = 44100 * 2 * 2;
+	else
+		return E_POINTER;
+
 	return S_OK;
 }
 




More information about the wine-cvs mailing list