Commit ed8cf4e3 authored by Robert Reif's avatar Robert Reif Committed by Alexandre Julliard

Changed regression test to make sure position is correctly checked

when a different type is returned. Added Jeremy White's WAVE_FORMAT_DIRECT/WAVE_MAPPER fix. Added waveInGetPosition checks.
parent c002dfc0
......@@ -50,6 +50,87 @@ static const char * wave_in_error(MMRESULT error)
return long_msg;
}
static void check_position(int device, HWAVEIN win, DWORD bytes,
LPWAVEFORMATEX pwfx )
{
MMTIME mmtime;
DWORD samples;
double duration;
MMRESULT rc;
DWORD returned;
samples=bytes/(pwfx->wBitsPerSample/8*pwfx->nChannels);
duration=((double)samples)/pwfx->nSamplesPerSec;
mmtime.wType = TIME_BYTES;
rc=waveInGetPosition(win, &mmtime, sizeof(mmtime));
ok(rc==MMSYSERR_NOERROR,
"waveInGetPosition(%s): rc=%s\n",dev_name(device),wave_in_error(rc));
if (mmtime.wType != TIME_BYTES && winetest_debug > 1)
trace("waveInGetPosition(%s): TIME_BYTES not supported, returned %s\n",
dev_name(device),wave_time_format(mmtime.wType));
returned = time_to_bytes(&mmtime, pwfx);
ok(returned == bytes, "waveInGetPosition(%s): returned %ld bytes, "
"should be %ld\n", dev_name(device), returned, bytes);
mmtime.wType = TIME_SAMPLES;
rc=waveInGetPosition(win, &mmtime, sizeof(mmtime));
ok(rc==MMSYSERR_NOERROR,
"waveInGetPosition(%s): rc=%s\n",dev_name(device),wave_in_error(rc));
if (mmtime.wType != TIME_SAMPLES && winetest_debug > 1)
trace("waveInGetPosition(%s): TIME_SAMPLES not supported, "
"returned %s\n",dev_name(device),wave_time_format(mmtime.wType));
returned = time_to_bytes(&mmtime, pwfx);
ok(returned == bytes, "waveInGetPosition(%s): returned %ld samples, "
"should be %ld\n", dev_name(device), bytes_to_samples(returned, pwfx),
bytes_to_samples(bytes, pwfx));
mmtime.wType = TIME_MS;
rc=waveInGetPosition(win, &mmtime, sizeof(mmtime));
ok(rc==MMSYSERR_NOERROR,
"waveInGetPosition(%s): rc=%s\n",dev_name(device),wave_in_error(rc));
if (mmtime.wType != TIME_MS && winetest_debug > 1)
trace("waveInGetPosition(%s): TIME_MS not supported, returned %s\n",
dev_name(device), wave_time_format(mmtime.wType));
returned = time_to_bytes(&mmtime, pwfx);
ok(returned == bytes, "waveInGetPosition(%s): returned %ld ms, "
"should be %ld\n", dev_name(device), bytes_to_ms(returned, pwfx),
bytes_to_ms(bytes, pwfx));
mmtime.wType = TIME_SMPTE;
rc=waveInGetPosition(win, &mmtime, sizeof(mmtime));
ok(rc==MMSYSERR_NOERROR,
"waveInGetPosition(%s): rc=%s\n",dev_name(device),wave_in_error(rc));
if (mmtime.wType != TIME_SMPTE && winetest_debug > 1)
trace("waveInGetPosition(%s): TIME_SMPTE not supported, returned %s\n",
dev_name(device),wave_time_format(mmtime.wType));
returned = time_to_bytes(&mmtime, pwfx);
ok(returned == bytes, "waveInGetPosition(%s): SMPTE test failed\n",
dev_name(device));
mmtime.wType = TIME_MIDI;
rc=waveInGetPosition(win, &mmtime, sizeof(mmtime));
ok(rc==MMSYSERR_NOERROR,
"waveInGetPosition(%s): rc=%s\n",dev_name(device),wave_in_error(rc));
if (mmtime.wType != TIME_MIDI && winetest_debug > 1)
trace("waveInGetPosition(%s): TIME_MIDI not supported, returned %s\n",
dev_name(device),wave_time_format(mmtime.wType));
returned = time_to_bytes(&mmtime, pwfx);
ok(returned == bytes, "waveInGetPosition(%s): MIDI test failed\n",
dev_name(device));
mmtime.wType = TIME_TICKS;
rc=waveInGetPosition(win, &mmtime, sizeof(mmtime));
ok(rc==MMSYSERR_NOERROR,
"waveInGetPosition(%s): rc=%s\n",dev_name(device),wave_in_error(rc));
if (mmtime.wType != TIME_TICKS && winetest_debug > 1)
trace("waveInGetPosition(%s): TIME_TICKS not supported, returned %s\n",
dev_name(device),wave_time_format(mmtime.wType));
returned = time_to_bytes(&mmtime, pwfx);
ok(returned == bytes, "waveInGetPosition(%s): TICKS test failed\n",
dev_name(device));
}
static void wave_in_test_deviceIn(int device, LPWAVEFORMATEX pwfx, DWORD format, DWORD flags, LPWAVEINCAPS pcaps)
{
HWAVEIN win;
......@@ -107,6 +188,9 @@ static void wave_in_test_deviceIn(int device, LPWAVEFORMATEX pwfx, DWORD format,
pwfx->nSamplesPerSec, pwfx->wBitsPerSample,
pwfx->nChannels, nSamplesPerSec, wBitsPerSample, nChannels);
/* Check that the position is 0 at start */
check_position(device, win, 0, pwfx);
frag.lpData=malloc(pwfx->nAvgBytesPerSec);
frag.dwBufferLength=pwfx->nAvgBytesPerSec;
frag.dwBytesRecorded=0;
......@@ -131,6 +215,9 @@ static void wave_in_test_deviceIn(int device, LPWAVEFORMATEX pwfx, DWORD format,
ok(rc==MMSYSERR_NOERROR,"waveInAddBuffer(%s): rc=%s\n",
dev_name(device),wave_in_error(rc));
/* Check that the position is 0 at start */
check_position(device, win, 0, pwfx);
rc=waveInStart(win);
ok(rc==MMSYSERR_NOERROR,"waveInStart(%s): rc=%s\n",
dev_name(device),wave_in_error(rc));
......@@ -141,6 +228,7 @@ static void wave_in_test_deviceIn(int device, LPWAVEFORMATEX pwfx, DWORD format,
ok(frag.dwBytesRecorded==pwfx->nAvgBytesPerSec,
"frag.dwBytesRecorded=%ld, should=%ld\n",
frag.dwBytesRecorded,pwfx->nAvgBytesPerSec);
/* stop playing on error */
if (res!=WAIT_OBJECT_0) {
rc=waveInStop(win);
......@@ -316,12 +404,13 @@ static void wave_in_test_device(int device)
format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
format.cbSize=0;
wave_in_test_deviceIn(device,&format,win_formats[f][0],0, &capsA);
if (device != WAVE_MAPPER) {
wave_in_test_deviceIn(device,&format,win_formats[f][0],
WAVE_FORMAT_DIRECT, &capsA);
if (device != WAVE_MAPPER)
wave_in_test_deviceIn(device,&format,win_formats[f][0],
WAVE_MAPPED, &capsA);
}
}
/* Try a PCMWAVEFORMAT aligned next to an unaccessible page for bounds
* checking */
......@@ -342,12 +431,13 @@ static void wave_in_test_device(int device)
pwfx->nBlockAlign=pwfx->nChannels*pwfx->wBitsPerSample/8;
pwfx->nAvgBytesPerSec=pwfx->nSamplesPerSec*pwfx->nBlockAlign;
wave_in_test_deviceIn(device,pwfx,WAVE_FORMAT_2M08,0, &capsA);
if (device != WAVE_MAPPER) {
wave_in_test_deviceIn(device,pwfx,WAVE_FORMAT_2M08,
WAVE_FORMAT_DIRECT, &capsA);
if (device != WAVE_MAPPER)
wave_in_test_deviceIn(device,pwfx,WAVE_FORMAT_2M08,
WAVE_MAPPED, &capsA);
}
}
VirtualFree(twoPages, 2 * dwPageSize, MEM_RELEASE);
}
......
......@@ -303,7 +303,7 @@ static const char * wave_out_caps(DWORD dwSupport)
#undef ADD_FLAG
}
static const char * wave_time_format(UINT type)
const char * wave_time_format(UINT type)
{
static char msg[32];
#define TIME_FORMAT(f) case f: return #f
......@@ -373,6 +373,34 @@ const char * get_format_str(WORD format)
return msg;
}
DWORD bytes_to_samples(DWORD bytes, LPWAVEFORMATEX pwfx)
{
return bytes / pwfx->nBlockAlign;
}
DWORD bytes_to_ms(DWORD bytes, LPWAVEFORMATEX pwfx)
{
return bytes_to_samples(bytes, pwfx) * 1000 / pwfx->nSamplesPerSec;
}
DWORD time_to_bytes(LPMMTIME mmtime, LPWAVEFORMATEX pwfx)
{
if (mmtime->wType == TIME_BYTES)
return mmtime->u.cb;
else if (mmtime->wType == TIME_SAMPLES)
return mmtime->u.sample * pwfx->nBlockAlign;
else if (mmtime->wType == TIME_MS)
return mmtime->u.ms * pwfx->nAvgBytesPerSec / 1000;
else if (mmtime->wType == TIME_SMPTE)
return ((mmtime->u.smpte.hour * 60.0 * 60.0) +
(mmtime->u.smpte.min * 60.0) +
(mmtime->u.smpte.sec) +
(mmtime->u.smpte.frame / 30.0)) * pwfx->nAvgBytesPerSec;
trace("FIXME: time_to_bytes() type not supported\n");
return -1;
}
static void check_position(int device, HWAVEOUT wout, DWORD bytes,
LPWAVEFORMATEX pwfx )
{
......@@ -380,6 +408,7 @@ static void check_position(int device, HWAVEOUT wout, DWORD bytes,
DWORD samples;
double duration;
MMRESULT rc;
DWORD returned;
samples=bytes/(pwfx->wBitsPerSample/8*pwfx->nChannels);
duration=((double)samples)/pwfx->nSamplesPerSec;
......@@ -388,60 +417,69 @@ static void check_position(int device, HWAVEOUT wout, DWORD bytes,
rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
ok(rc==MMSYSERR_NOERROR,
"waveOutGetPosition(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
if (mmtime.wType == TIME_BYTES)
ok(mmtime.u.cb==bytes,
"waveOutGetPosition(%s): returned %ld bytes, should be %ld\n",
dev_name(device),mmtime.u.cb, bytes);
else
if (mmtime.wType != TIME_BYTES && winetest_debug > 1)
trace("waveOutGetPosition(%s): TIME_BYTES not supported, returned %s\n",
dev_name(device),wave_time_format(mmtime.wType));
returned = time_to_bytes(&mmtime, pwfx);
ok(returned == bytes, "waveOutGetPosition(%s): returned %ld bytes, "
"should be %ld\n", dev_name(device), returned, bytes);
mmtime.wType = TIME_SAMPLES;
rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
ok(rc==MMSYSERR_NOERROR,
"waveOutGetPosition(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
if (mmtime.wType == TIME_SAMPLES)
ok(mmtime.u.sample==samples,
"waveOutGetPosition(%s): returned %ld samples, should be %ld\n",
dev_name(device), mmtime.u.sample, samples);
else
if (mmtime.wType != TIME_SAMPLES && winetest_debug > 1)
trace("waveOutGetPosition(%s): TIME_SAMPLES not supported, "
"returned %s\n",dev_name(device),wave_time_format(mmtime.wType));
returned = time_to_bytes(&mmtime, pwfx);
ok(returned == bytes, "waveOutGetPosition(%s): returned %ld samples, "
"should be %ld\n", dev_name(device), bytes_to_samples(returned, pwfx),
bytes_to_samples(bytes, pwfx));
mmtime.wType = TIME_MS;
rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
ok(rc==MMSYSERR_NOERROR,
"waveOutGetPosition(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
if (mmtime.wType == TIME_MS)
ok(mmtime.u.ms==floor(duration*1000.0),
"waveOutGetPosition(%s): returned %ld ms, should be %ld\n",
dev_name(device), mmtime.u.ms, (long)floor(duration*1000.0));
else
if (mmtime.wType != TIME_MS && winetest_debug > 1)
trace("waveOutGetPosition(%s): TIME_MS not supported, returned %s\n",
dev_name(device),wave_time_format(mmtime.wType));
dev_name(device), wave_time_format(mmtime.wType));
returned = time_to_bytes(&mmtime, pwfx);
ok(returned == bytes, "waveOutGetPosition(%s): returned %ld ms, "
"should be %ld\n", dev_name(device), bytes_to_ms(returned, pwfx),
bytes_to_ms(bytes, pwfx));
mmtime.wType = TIME_SMPTE;
rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
ok(rc==MMSYSERR_NOERROR,
"waveOutGetPosition(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
if (mmtime.wType == TIME_SMPTE)
{
BYTE frames=(BYTE)ceil(fmod(duration*mmtime.u.smpte.fps, mmtime.u.smpte.fps));
ok(mmtime.u.smpte.hour==(BYTE)(floor(duration/(60*60))) &&
mmtime.u.smpte.min==(BYTE)(fmod(floor(duration/60), 60)) &&
mmtime.u.smpte.sec==(BYTE)(fmod(duration,60)) &&
mmtime.u.smpte.frame==frames,
"waveOutGetPosition(%s): returned %d:%d:%d %d, "
"should be %d:%d:%d %d\n", dev_name(device), mmtime.u.smpte.hour,
mmtime.u.smpte.min, mmtime.u.smpte.sec, mmtime.u.smpte.frame,
(BYTE)(floor(duration/(60*60))),
(BYTE)(fmod(floor(duration/60), 60)),
(BYTE)(fmod(duration,60)),
frames);
}
else
if (mmtime.wType != TIME_SMPTE && winetest_debug > 1)
trace("waveOutGetPosition(%s): TIME_SMPTE not supported, returned %s\n",
dev_name(device),wave_time_format(mmtime.wType));
returned = time_to_bytes(&mmtime, pwfx);
ok(returned == bytes, "waveOutGetPosition(%s): SMPTE test failed\n",
dev_name(device));
mmtime.wType = TIME_MIDI;
rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
ok(rc==MMSYSERR_NOERROR,
"waveOutGetPosition(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
if (mmtime.wType != TIME_MIDI && winetest_debug > 1)
trace("waveOutGetPosition(%s): TIME_MIDI not supported, returned %s\n",
dev_name(device),wave_time_format(mmtime.wType));
returned = time_to_bytes(&mmtime, pwfx);
ok(returned == bytes, "waveOutGetPosition(%s): MIDI test failed\n",
dev_name(device));
mmtime.wType = TIME_TICKS;
rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
ok(rc==MMSYSERR_NOERROR,
"waveOutGetPosition(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
if (mmtime.wType != TIME_TICKS && winetest_debug > 1)
trace("waveOutGetPosition(%s): TIME_TICKS not supported, returned %s\n",
dev_name(device),wave_time_format(mmtime.wType));
returned = time_to_bytes(&mmtime, pwfx);
ok(returned == bytes, "waveOutGetPosition(%s): TICKS test failed\n",
dev_name(device));
}
static void wave_out_test_deviceOut(int device, double duration,
......
......@@ -72,3 +72,7 @@ extern const char* wave_open_flags(DWORD);
extern const char* mmsys_error(MMRESULT);
extern const char* wave_out_error(MMRESULT);
extern const char* get_format_str(WORD format);
extern const char* wave_time_format(UINT type);
extern DWORD bytes_to_samples(DWORD bytes, LPWAVEFORMATEX pwfx);
extern DWORD bytes_to_ms(DWORD bytes, LPWAVEFORMATEX pwfx);
extern DWORD time_to_bytes(LPMMTIME mmtime, LPWAVEFORMATEX pwfx);
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