Skip to content

Commit f559b37

Browse files
committed
Expand and add debugging info.
I'm working on this branch to try to understand why when running no$sns (and some other apps) waveOutOpen() is called with a sample rate of 0.
1 parent 7f5e14d commit f559b37

File tree

13 files changed

+117
-21
lines changed

13 files changed

+117
-21
lines changed

dll/win32/mciavi32/mmoutput.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ DWORD MCIAVI_OpenAudio(WINE_MCIAVI* wma, unsigned* nHdr, LPWAVEHDR* pWaveHdr)
527527
DWORD dwRet;
528528
LPWAVEHDR waveHdr;
529529
unsigned i;
530-
530+
TRACE("MCIAVI_OpenAudio()\n");
531531
dwRet = waveOutOpen((HWAVEOUT *)&wma->hWave, WAVE_MAPPER, wma->lpWaveFormat,
532532
(DWORD_PTR)MCIAVI_waveCallback, wma->wDevID, CALLBACK_FUNCTION);
533533
if (dwRet != 0) {

dll/win32/mciwave/mciwave.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ static DWORD WAVE_mciPlay(MCIDEVICEID wDevID, DWORD_PTR dwFlags, DWORD_PTR pmt,
747747
HANDLE oldcb;
748748
int whidx;
749749

750-
TRACE("(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
750+
TRACE("WAVE_mciPlay(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
751751

752752
if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID;
753753
if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
@@ -1007,7 +1007,7 @@ static DWORD WAVE_mciRecord(MCIDEVICEID wDevID, DWORD_PTR dwFlags, DWORD_PTR pmt
10071007
WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID);
10081008
HANDLE oldcb;
10091009

1010-
TRACE("(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
1010+
TRACE("WAVE_mciRecord(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
10111011

10121012
if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID;
10131013
if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;

dll/win32/mmdrv/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include "mmdrv.h"
1313

14-
#define NDEBUG
14+
//#define NDEBUG
1515
#include <debug.h>
1616

1717
/*

dll/win32/mmdrv/wave.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ SetWaveFormat(
355355

356356
size = GetWaveFormatExSize(format);
357357

358-
DPRINT("SetWaveFormat\n");
358+
DPRINT1("SetWaveFormat() called\n");
359359

360360
return DeviceIoControl(device_handle,
361361
IOCTL_WAVE_SET_FORMAT,

dll/win32/msacm32.drv/wavemap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static DWORD wodOpenHelper(WAVEMAPDATA* wom, UINT idx,
126126
{
127127
DWORD ret;
128128

129-
TRACE("(%p %04x %p %p %08x)\n", wom, idx, lpDesc, lpwfx, dwFlags);
129+
TRACE("wodOpenHelper(%p %04x %p %p %08x)\n", wom, idx, lpDesc, lpwfx, dwFlags);
130130

131131
/* destination is always PCM, so the formulas below apply */
132132
lpwfx->nBlockAlign = (lpwfx->nChannels * lpwfx->wBitsPerSample) / 8;
@@ -156,7 +156,7 @@ static DWORD wodOpen(DWORD_PTR *lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
156156
WAVEMAPDATA* wom = HeapAlloc(GetProcessHeap(), 0, sizeof(WAVEMAPDATA));
157157
DWORD res;
158158

159-
TRACE("(%p %p %08x)\n", lpdwUser, lpDesc, dwFlags);
159+
TRACE("wodOpen(%p %p %08x)\n", lpdwUser, lpDesc, dwFlags);
160160

161161
if (!wom) {
162162
WARN("no memory\n");

dll/win32/wdmaud.drv/legacy.c

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include "wdmaud.h"
1717

18-
#define NDEBUG
18+
//#define NDEBUG
1919
#include <debug.h>
2020
#include <mmebuddy_debug.h>
2121

@@ -498,6 +498,25 @@ WdmAudSetWaveDeviceFormatByLegacy(
498498
/* device is already open */
499499
return MMSYSERR_NOERROR;
500500
}
501+
502+
DPRINT1("WdmAudSetWaveDeviceFormatByLegacy(%p, %ul, %p, %ul)\n", Instance, DeviceId, WaveFormat, WaveFormatSize);
503+
504+
/*
505+
WORD wFormatTag;
506+
WORD nChannels;
507+
DWORD nSamplesPerSec;
508+
DWORD nAvgBytesPerSec;
509+
WORD nBlockAlign;
510+
WORD wBitsPerSample;
511+
WORD cbSize;
512+
*/
513+
DPRINT1("wFormatTag: %u\n", WaveFormat->wFormatTag);
514+
DPRINT1("nChannels: %u\n", WaveFormat->nChannels);
515+
DPRINT1("nSamplesPerSec: %ul\n", WaveFormat->nSamplesPerSec);
516+
DPRINT1("nAvgBytesPerSec: %ul\n", WaveFormat->nAvgBytesPerSec);
517+
DPRINT1("nBlockAlign: %u\n", WaveFormat->nBlockAlign);
518+
DPRINT1("wBitsPerSample: %u\n", WaveFormat->wBitsPerSample);
519+
DPRINT1("cbSize: %u\n", WaveFormat->cbSize);
501520

502521
Result = GetSoundDeviceType(SoundDevice, &DeviceType);
503522

@@ -519,6 +538,18 @@ WdmAudSetWaveDeviceFormatByLegacy(
519538
DeviceInfo.u.WaveFormatEx.nSamplesPerSec = WaveFormat->nSamplesPerSec;
520539
DeviceInfo.u.WaveFormatEx.nBlockAlign = WaveFormat->nBlockAlign;
521540
DeviceInfo.u.WaveFormatEx.nAvgBytesPerSec = WaveFormat->nAvgBytesPerSec;
541+
//NT_ASSERT(FALSE);
542+
if (DeviceInfo.u.WaveFormatEx.nSamplesPerSec == 0 || DeviceInfo.u.WaveFormatEx.nChannels == 0)
543+
return WAVERR_BADFORMAT;
544+
/*{
545+
DPRINT1("DeviceInfo.u.WaveFormatEx.nSamplesPerSec is zero. Using 44100 instead.\n");
546+
DeviceInfo.u.WaveFormatEx.nSamplesPerSec = 44100;
547+
}
548+
if ()
549+
{
550+
DPRINT1("DeviceInfo.u.WaveFormatEx.nChannels is zero. Using 2 instead.\n");
551+
DeviceInfo.u.WaveFormatEx.nChannels = 2;
552+
}*/
522553
DeviceInfo.u.WaveFormatEx.wBitsPerSample = (DeviceInfo.u.WaveFormatEx.nAvgBytesPerSec * 8) / (DeviceInfo.u.WaveFormatEx.nSamplesPerSec * DeviceInfo.u.WaveFormatEx.nChannels);
523554
#endif
524555

dll/win32/wdmaud.drv/mmixer.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <setupapi.h>
1414
#include <mmixer.h>
1515

16-
#define NDEBUG
16+
//#define NDEBUG
1717
#include <debug.h>
1818
#include <mmebuddy_debug.h>
1919

@@ -496,6 +496,25 @@ WdmAudSetWaveDeviceFormatByMMixer(
496496
return TranslateInternalMmResult(Result);
497497
}
498498

499+
DPRINT1("WdmAudSetWaveDeviceFormatByMMixer(%p, %ul, %p, %u)\n", Instance, DeviceId, WaveFormat, WaveFormatSize);
500+
501+
/*
502+
WORD wFormatTag;
503+
WORD nChannels;
504+
DWORD nSamplesPerSec;
505+
DWORD nAvgBytesPerSec;
506+
WORD nBlockAlign;
507+
WORD wBitsPerSample;
508+
WORD cbSize;
509+
*/
510+
DPRINT1("wFormatTag: %u\n", WaveFormat->wFormatTag);
511+
DPRINT1("nChannels: %u\n", WaveFormat->nChannels);
512+
DPRINT1("nSamplesPerSec: %ul\n", WaveFormat->nSamplesPerSec);
513+
DPRINT1("nAvgBytesPerSec: %ul\n", WaveFormat->nAvgBytesPerSec);
514+
DPRINT1("nBlockAlign: %u\n", WaveFormat->nBlockAlign);
515+
DPRINT1("wBitsPerSample: %u\n", WaveFormat->wBitsPerSample);
516+
DPRINT1("cbSize: %u\n", WaveFormat->cbSize);
517+
499518
Result = GetSoundDeviceType(SoundDevice, &DeviceType);
500519
SND_ASSERT( Result == MMSYSERR_NOERROR );
501520

dll/win32/wdmaud.drv/wdmaud.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include "wdmaud.h"
1616

17-
#define NDEBUG
17+
//#define NDEBUG
1818
#include <debug.h>
1919
#include <mmebuddy_debug.h>
2020

dll/win32/winmm/lolvldrv.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ DWORD MMDRV_Open(LPWINE_MLD mld, UINT wMsg, DWORD_PTR dwParam1, DWORD dwFlags)
185185
DWORD dwRet = MMSYSERR_BADDEVICEID;
186186
DWORD_PTR dwInstance;
187187
WINE_LLTYPE* llType = &llTypes[mld->type];
188-
TRACE("(%p, %04x, 0x%08lx, 0x%08x)\n", mld, wMsg, dwParam1, dwFlags);
188+
TRACE("MMDRV_Open(%p, %04x, 0x%08lx, 0x%08x)\n", mld, wMsg, dwParam1, dwFlags);
189189

190190
mld->dwDriverInstance = (DWORD_PTR)&dwInstance;
191191

@@ -236,7 +236,7 @@ DWORD MMDRV_Close(LPWINE_MLD mld, UINT wMsg)
236236
*/
237237
static LPWINE_MLD MMDRV_GetByID(UINT uDevID, UINT type)
238238
{
239-
TRACE("(%04x, %04x)\n", uDevID, type);
239+
TRACE("MMDRV_GetByID(%04x, %04x)\n", uDevID, type);
240240
if (uDevID < llTypes[type].wMaxId)
241241
return &llTypes[type].lpMlds[uDevID];
242242
if ((uDevID == (UINT16)-1 || uDevID == (UINT)-1) && llTypes[type].nMapper != -1)
@@ -251,7 +251,7 @@ LPWINE_MLD MMDRV_Get(HANDLE _hndl, UINT type, BOOL bCanBeID)
251251
{
252252
LPWINE_MLD mld = NULL;
253253
UINT_PTR hndl = (UINT_PTR)_hndl;
254-
TRACE("(%p, %04x, %c)\n", _hndl, type, bCanBeID ? 'Y' : 'N');
254+
TRACE("MMDRV_Get(%p, %04x, %c)\n", _hndl, type, bCanBeID ? 'Y' : 'N');
255255

256256
assert(type < MMDRV_MAX);
257257

@@ -362,7 +362,7 @@ static BOOL MMDRV_InitPerType(LPWINE_MM_DRIVER lpDrv, UINT type, UINT wMsg)
362362
DWORD ret;
363363
UINT count = 0;
364364
int i, k;
365-
TRACE("(%p, %04x, %04x)\n", lpDrv, type, wMsg);
365+
TRACE("MMDRV_InitPerType(%p, %04x, %04x)\n", lpDrv, type, wMsg);
366366

367367
part->nIDMin = part->nIDMax = 0;
368368

dll/win32/winmm/winmm.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad)
195195
*/
196196
MMRESULT WINMM_CheckCallback(DWORD_PTR dwCallback, DWORD fdwOpen, BOOL mixer)
197197
{
198+
TRACE("WINMM_CheckCallback(%p, %u, %u)\n", dwCallback, fdwOpen, mixer);
198199
switch (fdwOpen & CALLBACK_TYPEMASK) {
199200
case CALLBACK_NULL: /* dwCallback need not be NULL */
200201
break;
@@ -819,7 +820,7 @@ UINT WINAPI midiOutGetDevCapsW(UINT_PTR uDeviceID, LPMIDIOUTCAPSW lpCaps,
819820
{
820821
LPWINE_MLD wmld;
821822

822-
TRACE("(%lu, %p, %u);\n", uDeviceID, lpCaps, uSize);
823+
TRACE("midiOutGetDevCapsW(%lu, %p, %u);\n", uDeviceID, lpCaps, uSize);
823824

824825
if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
825826

@@ -2061,24 +2062,34 @@ static UINT WAVE_Open(HANDLE* lphndl, UINT uDeviceID, UINT uType,
20612062
DWORD dwRet;
20622063
WAVEOPENDESC wod;
20632064

2064-
TRACE("(%p, %d, %s, %p, %08lX, %08lX, %08X);\n",
2065+
TRACE("WAVE_Open(%p, %d, %s, %p, %08lX, %08lX, %08X - );\n",
20652066
lphndl, (int)uDeviceID, (uType==MMDRV_WAVEOUT)?"Out":"In", lpFormat, dwCallback,
20662067
dwInstance, dwFlags);
20672068

20682069
if (dwFlags & WAVE_FORMAT_QUERY)
20692070
TRACE("WAVE_FORMAT_QUERY requested !\n");
2071+
else
2072+
{
2073+
if (lpFormat->nChannels == 0 || lpFormat->nSamplesPerSec == 0)
2074+
{
2075+
TRACE("bad format\n");
2076+
return WAVERR_BADFORMAT;
2077+
}
2078+
}
20702079

20712080
dwRet = WINMM_CheckCallback(dwCallback, dwFlags, FALSE);
20722081
if (dwRet != MMSYSERR_NOERROR)
20732082
return dwRet;
20742083

2084+
TRACE("No error\n");
2085+
20752086
if (lpFormat == NULL) {
2076-
WARN("bad format\n");
2087+
TRACE("bad format\n");
20772088
return WAVERR_BADFORMAT;
20782089
}
20792090

20802091
if ((dwFlags & WAVE_MAPPED) && (uDeviceID == (UINT)-1)) {
2081-
WARN("invalid parameter\n");
2092+
TRACE("invalid parameter\n");
20822093
return MMSYSERR_INVALPARAM;
20832094
}
20842095

@@ -2250,6 +2261,9 @@ MMRESULT WINAPI waveOutOpen(LPHWAVEOUT lphWaveOut, UINT uDeviceID,
22502261
LPCWAVEFORMATEX lpFormat, DWORD_PTR dwCallback,
22512262
DWORD_PTR dwInstance, DWORD dwFlags)
22522263
{
2264+
TRACE("waveOutOpen() called\nwFormatTag=%u, nChannels=%u, nSamplesPerSec=%u, nAvgBytesPerSec=%u, nBlockAlign=%u, wBitsPerSample=%u\n",
2265+
lpFormat->wFormatTag, lpFormat->nChannels, lpFormat->nSamplesPerSec,
2266+
lpFormat->nAvgBytesPerSec, lpFormat->nBlockAlign, lpFormat->wBitsPerSample);
22532267
return WAVE_Open((HANDLE*)lphWaveOut, uDeviceID, MMDRV_WAVEOUT, lpFormat,
22542268
dwCallback, dwInstance, dwFlags);
22552269
}
@@ -2627,6 +2641,7 @@ MMRESULT WINAPI waveInOpen(HWAVEIN* lphWaveIn, UINT uDeviceID,
26272641
LPCWAVEFORMATEX lpFormat, DWORD_PTR dwCallback,
26282642
DWORD_PTR dwInstance, DWORD dwFlags)
26292643
{
2644+
TRACE("waveInOpen() called\n");
26302645
return WAVE_Open((HANDLE*)lphWaveIn, uDeviceID, MMDRV_WAVEIN, lpFormat,
26312646
dwCallback, dwInstance, dwFlags);
26322647
}

sdk/lib/drivers/sound/mmebuddy/mmewrap.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "precomp.h"
1212

13+
#include <debug.h>
1314

1415
/*
1516
Sets the device into running or stopped state
@@ -144,6 +145,25 @@ MmeOpenDevice(
144145

145146
SND_TRACE(L"Opening device");
146147

148+
DPRINT1("MMeOpenDevice(%d, %ul, %p, %ul, %p)\n", DeviceType, DeviceId, OpenParameters, Flags, PrivateHandle);
149+
150+
/*
151+
WORD wFormatTag;
152+
WORD nChannels;
153+
DWORD nSamplesPerSec;
154+
DWORD nAvgBytesPerSec;
155+
WORD nBlockAlign;
156+
WORD wBitsPerSample;
157+
WORD cbSize;
158+
*/
159+
DPRINT1("wFormatTag: %u\n", OpenParameters->lpFormat->wFormatTag);
160+
DPRINT1("nChannels: %u\n", OpenParameters->lpFormat->nChannels);
161+
DPRINT1("nSamplesPerSec: %ul\n", OpenParameters->lpFormat->nSamplesPerSec);
162+
DPRINT1("nAvgBytesPerSec: %ul\n", OpenParameters->lpFormat->nAvgBytesPerSec);
163+
DPRINT1("nBlockAlign: %u\n", OpenParameters->lpFormat->nBlockAlign);
164+
DPRINT1("wBitsPerSample: %u\n", OpenParameters->lpFormat->wBitsPerSample);
165+
DPRINT1("cbSize: %u\n", OpenParameters->lpFormat->cbSize);
166+
147167
VALIDATE_MMSYS_PARAMETER( IS_WAVE_DEVICE_TYPE(DeviceType) || IS_MIXER_DEVICE_TYPE(DeviceType) || IS_MIDI_DEVICE_TYPE(DeviceType) ); /* FIXME? wave in too? */
148168
VALIDATE_MMSYS_PARAMETER( OpenParameters );
149169

sdk/lib/drivers/sound/mmebuddy/wave/format.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010

1111
#include "precomp.h"
12-
12+
#include <debug.h>
1313
MMRESULT
1414
QueryWaveDeviceFormatSupport(
1515
IN PSOUND_DEVICE SoundDevice,
@@ -57,7 +57,7 @@ SetWaveDeviceFormat(
5757
PMMFUNCTION_TABLE FunctionTable;
5858
PSOUND_DEVICE SoundDevice;
5959

60-
SND_TRACE(L"Setting wave format\n");
60+
DPRINT1("SetWaveDeviceFormat() Setting wave format\n");
6161

6262
VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
6363

sdk/lib/drivers/sound/mmebuddy/wave/widMessage.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "precomp.h"
1313

14+
#include <debug.h>
1415
/*
1516
Standard MME driver entry-point for messages relating to wave audio
1617
input.
@@ -60,7 +61,17 @@ widMessage(
6061
break;
6162
}
6263
case WIDM_OPEN :
63-
{
64+
{
65+
DPRINT1("widMessage(%ul, WIDM_OPEN, %p, %p, %p)\n", DeviceId, PrivateHandle, Parameter1, Parameter2);
66+
67+
DPRINT1("wFormatTag: %u\n", ((LPWAVEOPENDESC)Parameter1)->lpFormat->wFormatTag);
68+
DPRINT1("nChannels: %u\n", ((LPWAVEOPENDESC)Parameter1)->lpFormat->nChannels);
69+
DPRINT1("nSamplesPerSec: %ul\n", ((LPWAVEOPENDESC)Parameter1)->lpFormat->nSamplesPerSec);
70+
DPRINT1("nAvgBytesPerSec: %ul\n", ((LPWAVEOPENDESC)Parameter1)->lpFormat->nAvgBytesPerSec);
71+
DPRINT1("nBlockAlign: %u\n", ((LPWAVEOPENDESC)Parameter1)->lpFormat->nBlockAlign);
72+
DPRINT1("wBitsPerSample: %u\n", ((LPWAVEOPENDESC)Parameter1)->lpFormat->wBitsPerSample);
73+
DPRINT1("cbSize: %u\n", ((LPWAVEOPENDESC)Parameter1)->lpFormat->cbSize);
74+
6475
Result = MmeOpenDevice(WAVE_IN_DEVICE_TYPE,
6576
DeviceId,
6677
(LPWAVEOPENDESC) Parameter1,

0 commit comments

Comments
 (0)