Author: janderwald
Date: Fri Dec 3 11:53:15 2010
New Revision: 49920
URL:
http://svn.reactos.org/svn/reactos?rev=49920&view=rev
Log:
[AUDIO-BRINGUP]
- Remove wdmaud test code
Modified:
branches/audio-bringup/drivers/wdm/audio/backpln/audio_test/audio_test.c
Modified: branches/audio-bringup/drivers/wdm/audio/backpln/audio_test/audio_test.c
URL:
http://svn.reactos.org/svn/reactos/branches/audio-bringup/drivers/wdm/audio…
==============================================================================
--- branches/audio-bringup/drivers/wdm/audio/backpln/audio_test/audio_test.c [iso-8859-1]
(original)
+++ branches/audio-bringup/drivers/wdm/audio/backpln/audio_test/audio_test.c [iso-8859-1]
Fri Dec 3 11:53:15 2010
@@ -11,8 +11,6 @@
#include <ndk/ntndk.h>
#include <ks.h>
#include <ksmedia.h>
-#include "interface.h"
-
#define _2pi 6.283185307179586476925286766559
@@ -251,161 +249,6 @@
__cdecl
main(int argc, char* argv[])
{
- ULONG Length;
- PSHORT SoundBuffer;
- ULONG i = 0;
- BOOL Status;
- OVERLAPPED Overlapped;
- DWORD BytesReturned;
- HANDLE hWdmAud;
- WDMAUD_DEVICE_INFO DeviceInfo;
-
TestKs();
return 0;
-
- hWdmAud = CreateFileW(L"\\\\.\\wdmaud",
- GENERIC_READ | GENERIC_WRITE,
- 0,
- NULL,
- OPEN_EXISTING,
- FILE_FLAG_OVERLAPPED,
- NULL);
- if (!hWdmAud)
- {
- printf("Failed to open wdmaud with %lx\n", GetLastError());
- return -1;
- }
-
- printf("WDMAUD: opened\n");
-
- /* clear device info */
- RtlZeroMemory(&DeviceInfo, sizeof(WDMAUD_DEVICE_INFO));
-
- ZeroMemory(&Overlapped, sizeof(OVERLAPPED));
- Overlapped.hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
-
- DeviceInfo.DeviceType = WAVE_OUT_DEVICE_TYPE;
-
-
- Status = DeviceIoControl(hWdmAud, IOCTL_GETNUMDEVS_TYPE, (LPVOID)&DeviceInfo,
sizeof(WDMAUD_DEVICE_INFO), (LPVOID)&DeviceInfo, sizeof(WDMAUD_DEVICE_INFO),
&BytesReturned, &Overlapped);
-
- if (!Status)
- {
- if (WaitForSingleObject(&Overlapped.hEvent, 5000) != WAIT_OBJECT_0)
- {
- printf("Failed to get num of wave out devices with %lx\n",
GetLastError());
- CloseHandle(hWdmAud);
- return -1;
- }
- }
-
- printf("WDMAUD: Num Devices %lu\n", DeviceInfo.DeviceCount);
-
- if (!DeviceInfo.DeviceCount)
- {
- CloseHandle(hWdmAud);
- return 0;
- }
-
- Status = DeviceIoControl(hWdmAud, IOCTL_GETCAPABILITIES, (LPVOID)&DeviceInfo,
sizeof(WDMAUD_DEVICE_INFO), (LPVOID)&DeviceInfo, sizeof(WDMAUD_DEVICE_INFO),
&BytesReturned, &Overlapped);
-
- if (!Status)
- {
- if (WaitForSingleObject(&Overlapped.hEvent, 5000) != WAIT_OBJECT_0)
- {
- printf("Failed to get iocaps %lx\n", GetLastError());
- }
- }
- printf("WDMAUD: Capabilites NumChannels %x dwFormats %lx\n",
DeviceInfo.u.WaveOutCaps.wChannels, DeviceInfo.u.WaveOutCaps.dwFormats);
-
- DeviceInfo.u.WaveFormatEx.cbSize = sizeof(WAVEFORMATEX);
- DeviceInfo.u.WaveFormatEx.wFormatTag = WAVE_FORMAT_PCM;
- DeviceInfo.u.WaveFormatEx.nChannels = 2;
- DeviceInfo.u.WaveFormatEx.nSamplesPerSec = 48000;
- DeviceInfo.u.WaveFormatEx.nBlockAlign = 4;
- DeviceInfo.u.WaveFormatEx.nAvgBytesPerSec = 48000 * 4;
- DeviceInfo.u.WaveFormatEx.wBitsPerSample = 16;
-
-
-
- Status = DeviceIoControl(hWdmAud, IOCTL_OPEN_WDMAUD, (LPVOID)&DeviceInfo,
sizeof(WDMAUD_DEVICE_INFO), &DeviceInfo, sizeof(WDMAUD_DEVICE_INFO),
&BytesReturned, &Overlapped);
- if (!Status)
- {
- if (WaitForSingleObject(&Overlapped.hEvent, 5000) != WAIT_OBJECT_0)
- {
- printf("Failed to open device with %lx\n", GetLastError());
- CloseHandle(hWdmAud);
- return -1;
- }
- }
-
- printf("WDMAUD: opened device\n");
-
- //
- // Allocate a buffer for 1 second
- //
- Length = 48000 * 4;
- SoundBuffer = (PSHORT)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, Length);
-
- //
- // Fill the buffer with a 500 Hz sine tone
- //
- while (i < Length / 2)
- {
- //
- // Generate the wave for each channel:
- // Amplitude * sin( Sample * Frequency * 2PI / SamplesPerSecond )
- //
- SoundBuffer[i] = 0x7FFF * sin(0.5 * (i - 1) * 500 * _2pi / 48000);
- i++;
- SoundBuffer[i] = 0x7FFF * sin((0.5 * i - 2) * 500 * _2pi / 48000);
- i++;
- }
-
- DeviceInfo.u.State = KSSTATE_RUN;
- Status = DeviceIoControl(hWdmAud, IOCTL_SETDEVICE_STATE, (LPVOID)&DeviceInfo,
sizeof(WDMAUD_DEVICE_INFO), &DeviceInfo, sizeof(WDMAUD_DEVICE_INFO),
&BytesReturned, &Overlapped);
- if (!Status)
- {
- if (WaitForSingleObject(&Overlapped.hEvent, 5000) != WAIT_OBJECT_0)
- {
- printf("Failed to set device into run state %lx\n",
GetLastError());
- CloseHandle(hWdmAud);
- return -1;
- }
- }
-
- //
- // Play our 1-second buffer
- //
- DeviceInfo.Header.Data = (PUCHAR)SoundBuffer;
- DeviceInfo.Header.DataUsed = DeviceInfo.Header.FrameExtent = Length;
- Status = DeviceIoControl(hWdmAud, IOCTL_WRITEDATA, (LPVOID)&DeviceInfo,
sizeof(WDMAUD_DEVICE_INFO), &DeviceInfo, sizeof(WDMAUD_DEVICE_INFO),
&BytesReturned, &Overlapped);
- if (!Status)
- {
- if (WaitForSingleObject(&Overlapped.hEvent, 5000) != WAIT_OBJECT_0)
- {
- printf("Failed to play buffer %lx\n", GetLastError());
- CloseHandle(hWdmAud);
- return -1;
- }
- }
-
- printf("WDMAUD: Played buffer\n");
-
- DeviceInfo.u.State = KSSTATE_STOP;
- Status = DeviceIoControl(hWdmAud, IOCTL_SETDEVICE_STATE, (LPVOID)&DeviceInfo,
sizeof(WDMAUD_DEVICE_INFO), &DeviceInfo, sizeof(WDMAUD_DEVICE_INFO),
&BytesReturned, &Overlapped);
- if (!Status)
- {
- if (WaitForSingleObject(&Overlapped.hEvent, 5000) != WAIT_OBJECT_0)
- {
- printf("Failed to set device into stop state %lx\n",
GetLastError());
- CloseHandle(hWdmAud);
- return -1;
- }
- }
- printf("WDMAUD: STOPPED\n");
- CloseHandle(&Overlapped.hEvent);
- CloseHandle(hWdmAud);
- printf("WDMAUD: COMPLETE\n");
- return 0;
}