Author: silverblade Date: Sun Jul 6 09:30:40 2008 New Revision: 34332
URL: http://svn.reactos.org/svn/reactos?rev=34332&view=rev Log: Started work on the user-mode Sound Blaster component. Like mmdrv, this is currently created as an executable to make initial testing easier. Fixed bug in EnumerateNt4ServiceSoundDevices where *all* device types were being sent to the detection callback (made this an optional feature instead). Moved original test code from MME-Buddy into MMDrv (don't want it for sndblst)
Added: branches/silverblade-audio/dll/win32/mmdrv/testing.c - copied, changed from r34328, branches/silverblade-audio/lib/drivers/sound/mmebuddy/testing.c branches/silverblade-audio/dll/win32/sndblst/ branches/silverblade-audio/dll/win32/sndblst/sndblst.c (with props) branches/silverblade-audio/dll/win32/sndblst/sndblst.def (with props) branches/silverblade-audio/dll/win32/sndblst/sndblst.rbuild (with props) Removed: branches/silverblade-audio/lib/drivers/sound/mmebuddy/testing.c Modified: branches/silverblade-audio/dll/win32/mmdrv/mmdrv.rbuild branches/silverblade-audio/dll/win32/win32.rbuild branches/silverblade-audio/lib/drivers/sound/mmebuddy/devices.c branches/silverblade-audio/lib/drivers/sound/mmebuddy/instances.c branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmebuddy.rbuild branches/silverblade-audio/lib/drivers/sound/mmebuddy/nt4.c
Modified: branches/silverblade-audio/dll/win32/mmdrv/mmdrv.rbuild URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/dll/win32/mmdr... ============================================================================== --- branches/silverblade-audio/dll/win32/mmdrv/mmdrv.rbuild [iso-8859-1] (original) +++ branches/silverblade-audio/dll/win32/mmdrv/mmdrv.rbuild [iso-8859-1] Sun Jul 6 09:30:40 2008 @@ -11,4 +11,5 @@ <library>winmm</library> <library>advapi32</library> <file>entry.c</file> + <file>testing.c</file> </module>
Copied: branches/silverblade-audio/dll/win32/mmdrv/testing.c (from r34328, branches/silverblade-audio/lib/drivers/sound/mmebuddy/testing.c) URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/dll/win32/mmdr... ============================================================================== --- branches/silverblade-audio/lib/drivers/sound/mmebuddy/testing.c [iso-8859-1] (original) +++ branches/silverblade-audio/dll/win32/mmdrv/testing.c [iso-8859-1] Sun Jul 6 09:30:40 2008 @@ -10,6 +10,7 @@
History: 4 July 2008 - Created + 6 July 2008 - Moved from mmebuddy to mmdrv */
#include <windows.h>
Added: branches/silverblade-audio/dll/win32/sndblst/sndblst.c URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/dll/win32/sndb... ============================================================================== --- branches/silverblade-audio/dll/win32/sndblst/sndblst.c (added) +++ branches/silverblade-audio/dll/win32/sndblst/sndblst.c [iso-8859-1] Sun Jul 6 09:30:40 2008 @@ -1,0 +1,75 @@ +/* + ReactOS Sound System + Sound Blaster MME Driver + + Purpose: + MME driver entry-point + + Author: + Andrew Greenwood (silverblade@reactos.org) + + History: + 6 July 2008 - Created +*/ + +#include <windows.h> +#include <ntddsnd.h> +#include <mmddk.h> +#include <mmebuddy.h> +#include <debug.h> + + +BOOLEAN FoundDevice( + UCHAR DeviceType, + PWSTR DevicePath, + HANDLE Handle) +{ + /* Nothing particularly special required... */ + return ( AddSoundDevice(DeviceType, DevicePath) == MMSYSERR_NOERROR ); +} + + +APIENTRY LONG +DriverProc( + DWORD driver_id, + HANDLE driver_handle, + UINT message, + LONG parameter1, + LONG parameter2) +{ + switch ( message ) + { + case DRV_LOAD : + SOUND_DEBUG(L"DRV_LOAD"); + + EnumerateNt4ServiceSoundDevices(L"sndblst", + WAVE_OUT_DEVICE_TYPE, + FoundDevice); + + return 1L; + + case DRV_FREE : + SOUND_DEBUG(L"DRV_FREE"); + return 1L; + + default : + return DefaultDriverProc(driver_id, + driver_handle, + message, + parameter1, + parameter2); + } +} + +int APIENTRY wWinMain( + HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPWSTR lpCmdLine, + int nCmdShow) +{ + DriverProc(0, 0, DRV_LOAD, 0, 0); + + SOUND_DEBUG_HEX(wodMessage(0, WODM_GETNUMDEVS, 0, 0, 0)); + + return 0; +}
Propchange: branches/silverblade-audio/dll/win32/sndblst/sndblst.c ------------------------------------------------------------------------------ svn:eol-style = native
Added: branches/silverblade-audio/dll/win32/sndblst/sndblst.def URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/dll/win32/sndb... ============================================================================== --- branches/silverblade-audio/dll/win32/sndblst/sndblst.def (added) +++ branches/silverblade-audio/dll/win32/sndblst/sndblst.def [iso-8859-1] Sun Jul 6 09:30:40 2008 @@ -1,0 +1,15 @@ +; $Id: sndblst.def 34299 2008-07-05 02:43:17Z silverblade $ +; +; sndblst.def +; +; ReactOS Operating System +; +LIBRARY sndblst.dll +EXPORTS +DriverProc@20 +;widMessage@20 +wodMessage@20 +;midMessage@20 +;modMessage@20 +;mxdMessage@20 +;auxMessage@20
Propchange: branches/silverblade-audio/dll/win32/sndblst/sndblst.def ------------------------------------------------------------------------------ svn:eol-style = native
Added: branches/silverblade-audio/dll/win32/sndblst/sndblst.rbuild URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/dll/win32/sndb... ============================================================================== --- branches/silverblade-audio/dll/win32/sndblst/sndblst.rbuild (added) +++ branches/silverblade-audio/dll/win32/sndblst/sndblst.rbuild [iso-8859-1] Sun Jul 6 09:30:40 2008 @@ -1,0 +1,15 @@ +<!-- Temporarily compiling as a CUI app for testing purposes */ +<!--module name="mmdrv" type="win32dll" baseaddress="${BASEADDRESS_MMDRV}" installbase="system32" installname="mmdrv.dll" unicode="yes"--> +<module name="sndblst" type="win32cui" installbase="system32" installname="sndblst.exe" unicode="yes"> + <!--importlibrary definition="mmdrv.def" /--> + <include base="ReactOS">include/reactos/libs/sound</include> + <include base="sndblst">.</include> + <!--define name="NDEBUG" /--> + <library>mmebuddy</library> + <library>ntdll</library> + <library>kernel32</library> + <library>user32</library> + <library>winmm</library> + <library>advapi32</library> + <file>sndblst.c</file> +</module>
Propchange: branches/silverblade-audio/dll/win32/sndblst/sndblst.rbuild ------------------------------------------------------------------------------ svn:eol-style = native
Modified: branches/silverblade-audio/dll/win32/win32.rbuild URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/dll/win32/win3... ============================================================================== --- branches/silverblade-audio/dll/win32/win32.rbuild [iso-8859-1] (original) +++ branches/silverblade-audio/dll/win32/win32.rbuild [iso-8859-1] Sun Jul 6 09:30:40 2008 @@ -292,6 +292,9 @@ <directory name="smdll"> <xi:include href="smdll/smdll.rbuild" /> </directory> +<directory name="sndblst"> + <xi:include href="sndblst/sndblst.rbuild" /> +</directory> <directory name="snmpapi"> <xi:include href="snmpapi/snmpapi.rbuild" /> </directory>
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/devices.c URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/so... ============================================================================== --- branches/silverblade-audio/lib/drivers/sound/mmebuddy/devices.c [iso-8859-1] (original) +++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/devices.c [iso-8859-1] Sun Jul 6 09:30:40 2008 @@ -11,6 +11,7 @@ History: 4 July 2008 - Created 5 July 2008 - Implemented format support + 6 July 2008 - Added default instance constructor/destructor */
@@ -39,109 +40,6 @@ }
return SoundDeviceTotals[DeviceType - MIN_SOUND_DEVICE_TYPE]; -} - - -MMRESULT -GetSoundDevice( - IN UCHAR DeviceType, - IN ULONG DeviceIndex, - OUT PSOUND_DEVICE* Device) -{ - ULONG Count = 0; - PSOUND_DEVICE CurrentDevice = NULL; - - if ( ! VALID_SOUND_DEVICE_TYPE(DeviceType) ) - return MMSYSERR_INVALPARAM; - - if ( DeviceIndex >= SoundDeviceTotals[DeviceType - MIN_SOUND_DEVICE_TYPE] ) - return MMSYSERR_INVALPARAM; - - if ( ! Device ) - return MMSYSERR_INVALPARAM; - - /* - We know by now that a device at the index should exist - so just loop around until we reach that index. - */ - - CurrentDevice = SoundDeviceLists[DeviceType - MIN_SOUND_DEVICE_TYPE]; - - for ( Count = 0; Count <= DeviceIndex; ++ Count ) - { - *Device = CurrentDevice; - CurrentDevice = CurrentDevice->Next; - } - - return MMSYSERR_NOERROR; -} - - -MMRESULT -GetSoundDevicePath( - IN PSOUND_DEVICE SoundDevice, - OUT LPWSTR* DevicePath) -{ - if ( ! SoundDevice ) - return MMSYSERR_INVALPARAM; - - if ( ! DevicePath ) - return MMSYSERR_INVALPARAM; - - MessageBox(0, SoundDevice->DevicePath, L"Foo", MB_TASKMODAL | MB_OK); - *DevicePath = SoundDevice->DevicePath; - - return MMSYSERR_NOERROR; -} - - -VOID -RemoveAllSoundDevices() -{ - ULONG i; - - DPRINT("Emptying all device lists\n"); - - for ( i = 0; i < SOUND_DEVICE_TYPES; ++ i ) - { - RemoveSoundDevices(i); - } -} - - -BOOLEAN -RemoveSoundDevices( - IN UCHAR DeviceType) -{ - PSOUND_DEVICE CurrentDevice; - PSOUND_DEVICE NextDevice; - - DPRINT("Emptying device list for device type %d\n", DeviceType); - - if ( ! VALID_SOUND_DEVICE_TYPE(DeviceType) ) - { - DPRINT("Invalid device type - %d\n", DeviceType); - return FALSE; - } - - /* Clean out the device list */ - CurrentDevice = SoundDeviceLists[DeviceType - MIN_SOUND_DEVICE_TYPE]; - - while ( CurrentDevice ) - { - /* Save the next device pointer so we can reference it later */ - NextDevice = CurrentDevice->Next; - - FreeMemory(CurrentDevice); - /*HeapFree(GetProcessHeap(), 0, CurrentDevice);*/ - CurrentDevice = NextDevice; - } - - /* Reset the list content and item count */ - SoundDeviceLists[DeviceType - MIN_SOUND_DEVICE_TYPE] = NULL; - SoundDeviceTotals[DeviceType - MIN_SOUND_DEVICE_TYPE] = 0; - - return TRUE; }
@@ -312,6 +210,109 @@ }
+BOOLEAN +RemoveSoundDevices( + IN UCHAR DeviceType) +{ + PSOUND_DEVICE CurrentDevice; + PSOUND_DEVICE NextDevice; + + DPRINT("Emptying device list for device type %d\n", DeviceType); + + if ( ! VALID_SOUND_DEVICE_TYPE(DeviceType) ) + { + DPRINT("Invalid device type - %d\n", DeviceType); + return FALSE; + } + + /* Clean out the device list */ + CurrentDevice = SoundDeviceLists[DeviceType - MIN_SOUND_DEVICE_TYPE]; + + while ( CurrentDevice ) + { + /* Save the next device pointer so we can reference it later */ + NextDevice = CurrentDevice->Next; + + FreeMemory(CurrentDevice); + /*HeapFree(GetProcessHeap(), 0, CurrentDevice);*/ + CurrentDevice = NextDevice; + } + + /* Reset the list content and item count */ + SoundDeviceLists[DeviceType - MIN_SOUND_DEVICE_TYPE] = NULL; + SoundDeviceTotals[DeviceType - MIN_SOUND_DEVICE_TYPE] = 0; + + return TRUE; +} + + +VOID +RemoveAllSoundDevices() +{ + ULONG i; + + DPRINT("Emptying all device lists\n"); + + for ( i = 0; i < SOUND_DEVICE_TYPES; ++ i ) + { + RemoveSoundDevices(i); + } +} + + +MMRESULT +GetSoundDevice( + IN UCHAR DeviceType, + IN ULONG DeviceIndex, + OUT PSOUND_DEVICE* Device) +{ + ULONG Count = 0; + PSOUND_DEVICE CurrentDevice = NULL; + + if ( ! VALID_SOUND_DEVICE_TYPE(DeviceType) ) + return MMSYSERR_INVALPARAM; + + if ( DeviceIndex >= SoundDeviceTotals[DeviceType - MIN_SOUND_DEVICE_TYPE] ) + return MMSYSERR_INVALPARAM; + + if ( ! Device ) + return MMSYSERR_INVALPARAM; + + /* + We know by now that a device at the index should exist + so just loop around until we reach that index. + */ + + CurrentDevice = SoundDeviceLists[DeviceType - MIN_SOUND_DEVICE_TYPE]; + + for ( Count = 0; Count <= DeviceIndex; ++ Count ) + { + *Device = CurrentDevice; + CurrentDevice = CurrentDevice->Next; + } + + return MMSYSERR_NOERROR; +} + + +MMRESULT +GetSoundDevicePath( + IN PSOUND_DEVICE SoundDevice, + OUT LPWSTR* DevicePath) +{ + if ( ! SoundDevice ) + return MMSYSERR_INVALPARAM; + + if ( ! DevicePath ) + return MMSYSERR_INVALPARAM; + + MessageBox(0, SoundDevice->DevicePath, L"Foo", MB_TASKMODAL | MB_OK); + *DevicePath = SoundDevice->DevicePath; + + return MMSYSERR_NOERROR; +} + + MMRESULT GetSoundDeviceType( IN PSOUND_DEVICE Device, @@ -558,7 +559,6 @@ PSOUND_DEVICE SoundDevice; MMRESULT Result;
- /* TODO: Close device */ SOUND_DEBUG(L"Default instance dtor");
SOUND_ASSERT(SoundDeviceInstance);
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/instances.c URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/so... ============================================================================== --- branches/silverblade-audio/lib/drivers/sound/mmebuddy/instances.c [iso-8859-1] (original) +++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/instances.c [iso-8859-1] Sun Jul 6 09:30:40 2008 @@ -10,6 +10,7 @@
History: 4 July 2008 - Created + 6 July 2008 - Re-structured */
#include <windows.h>
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmebuddy.rbuild URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/so... ============================================================================== --- branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmebuddy.rbuild [iso-8859-1] (original) +++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmebuddy.rbuild [iso-8859-1] Sun Jul 6 09:30:40 2008 @@ -8,7 +8,6 @@ <file>nt4.c</file> <file>utility.c</file> <file>thread.c</file> - <file>testing.c</file> <directory name="mme"> <file>DriverProc.c</file> <file>wodMessage.c</file>
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/nt4.c URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/so... ============================================================================== --- branches/silverblade-audio/lib/drivers/sound/mmebuddy/nt4.c [iso-8859-1] (original) +++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/nt4.c [iso-8859-1] Sun Jul 6 09:30:40 2008 @@ -232,10 +232,14 @@ if ( ( ValueType == REG_DWORD ) && ( ValueDataLength == sizeof(DWORD) ) ) { - SoundDeviceDetectedProc( - DeviceType, - DevicePath, - INVALID_HANDLE_VALUE); + if ( ( DeviceType == 0 ) || + ( DeviceType == ValueData ) ) + { + SoundDeviceDetectedProc( + ValueData, + DevicePath, + INVALID_HANDLE_VALUE); + } }
/* Reset variables for the next iteration */
Removed: branches/silverblade-audio/lib/drivers/sound/mmebuddy/testing.c URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/so... ============================================================================== --- branches/silverblade-audio/lib/drivers/sound/mmebuddy/testing.c [iso-8859-1] (original) +++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/testing.c (removed) @@ -1,365 +1,0 @@ -/* - ReactOS Sound System - MME Driver Helper - - Purpose: - Hax - - Author: - Andrew Greenwood (silverblade@reactos.org) - - History: - 4 July 2008 - Created -*/ - -#include <windows.h> -#include <mmsystem.h> -#include <mmddk.h> -#include <ntddsnd.h> -#include <debug.h> - -#include <ntddk.h> -#include <mmebuddy.h> - - - -/* - **** TESTING CODE ONLY **** -*/ - -PSOUND_DEVICE Device; -PSOUND_DEVICE_INSTANCE Instance; -WAVEHDR waveheader; -WORD JunkBuffer[65536]; - - -#define IDS_WAVEOUT_PNAME 0x68 - - - -BOOLEAN TestCallback( - UCHAR DeviceType, - PWSTR DevicePath, - HANDLE Handle) -{ -/* MessageBox(0, DevicePath, L"CALLBACK", MB_OK | MB_TASKMODAL);*/ - - AddSoundDevice(DeviceType, DevicePath); - - return TRUE; -} - - -VOID -TestDeviceDetection() -{ - ULONG WaveInCount, WaveOutCount; - ULONG MidiInCount, MidiOutCount; - ULONG MixerCount, AuxCount; - WCHAR Message[1024]; - - DetectNt4SoundDevices(WAVE_IN_DEVICE_TYPE, - L"\\.\SBWaveIn", - TestCallback); - - DetectNt4SoundDevices(WAVE_OUT_DEVICE_TYPE, - L"\\.\SBWaveOut", - TestCallback); - - DetectNt4SoundDevices(MIDI_IN_DEVICE_TYPE, - L"\\.\MidiIn", - TestCallback); - - DetectNt4SoundDevices(MIDI_OUT_DEVICE_TYPE, - L"\\.\MidiOut", - TestCallback); - - DetectNt4SoundDevices(MIXER_DEVICE_TYPE, - L"\\.\SBMixer", - TestCallback); - - DetectNt4SoundDevices(AUX_DEVICE_TYPE, - L"\\.\SBAux", - TestCallback); - - WaveInCount = GetSoundDeviceCount(WAVE_IN_DEVICE_TYPE); - WaveOutCount = GetSoundDeviceCount(WAVE_OUT_DEVICE_TYPE); - MidiInCount = GetSoundDeviceCount(MIDI_IN_DEVICE_TYPE); - MidiOutCount = GetSoundDeviceCount(MIDI_OUT_DEVICE_TYPE); - MixerCount = GetSoundDeviceCount(MIXER_DEVICE_TYPE); - AuxCount = GetSoundDeviceCount(AUX_DEVICE_TYPE); - - wsprintf(Message, L"Found devices:\n- %d wave inputs\n- %d wave outputs\n- %d midi inputs\n- %d midi outputs\n- %d mixers\n- %d aux devices", - WaveInCount, WaveOutCount, - MidiInCount, MidiOutCount, - MixerCount, AuxCount); - - MessageBox(0, Message, L"Result", MB_OK | MB_TASKMODAL); -} - -APIENTRY VOID -TestGetCaps() -{ - UNIVERSAL_CAPS Caps; - WCHAR DevInfo[1024]; - PSOUND_DEVICE Device; - MMRESULT Result; - - AddSoundDevice(WAVE_OUT_DEVICE_TYPE, L"\\.\SBWaveOut0"); - Result = GetSoundDevice(WAVE_OUT_DEVICE_TYPE, 0, &Device); - - if ( Result != MMSYSERR_NOERROR ) - { - MessageBox(0, L"Fail 1", L"Fail", MB_OK | MB_TASKMODAL); - return; - } - - Result = GetSoundDeviceCapabilities(Device, &Caps); - if ( Result != MMSYSERR_NOERROR ) - { - MessageBox(0, L"Fail 2", L"Fail", MB_OK | MB_TASKMODAL); - return; - } - - wsprintf(DevInfo, L"Device name: %hS\nManufacturer ID: %d\nProduct ID: %d\nDriver version: %x\nChannels: %d", Caps.WaveOut.szPname, Caps.WaveOut.wMid, Caps.WaveOut.wPid, Caps.WaveOut.vDriverVersion, Caps.WaveOut.wChannels); - - MessageBox(0, DevInfo, L"Device caps", MB_OK | MB_TASKMODAL); -} - - -VOID -TestFormatQuery() -{ - WCHAR msg[1024]; - PSOUND_DEVICE Device; - MMRESULT Result; - WAVEFORMATEX fmt; - - AddSoundDevice(WAVE_OUT_DEVICE_TYPE, L"\\.\SBWaveOut0"); - Result = GetSoundDevice(WAVE_OUT_DEVICE_TYPE, 0, &Device); - - if ( Result != MMSYSERR_NOERROR ) - { - MessageBox(0, L"Fail 1", L"Fail", MB_OK | MB_TASKMODAL); - return; - } - - /* Request a valid format */ - fmt.wFormatTag = WAVE_FORMAT_PCM; - fmt.nChannels = 1; - fmt.nSamplesPerSec = 22050; - fmt.wBitsPerSample = 16; - fmt.nBlockAlign = fmt.nChannels * (fmt.wBitsPerSample / 8); - fmt.nAvgBytesPerSec = fmt.nSamplesPerSec * fmt.nBlockAlign; - fmt.cbSize = 0; - - Result = QueryWaveDeviceFormatSupport(Device, &fmt, sizeof(WAVEFORMATEX)); - - wsprintf(msg, L"Format support query result: %d", Result); - MessageBox(0, msg, L"Result", MB_OK | MB_TASKMODAL); - - /* Send it some garbage */ - fmt.nChannels = 6969; - - Result = QueryWaveDeviceFormatSupport(Device, &fmt, sizeof(WAVEFORMATEX)); - - wsprintf(msg, L"Format support query result: %d", Result); - MessageBox(0, msg, L"Result", MB_OK | MB_TASKMODAL); -} - - -VOID CALLBACK -OverlappedCallback( - IN DWORD dwErrorCode, - IN DWORD dwNumberOfBytesTransferred, - IN LPOVERLAPPED lpOverlapped) -{ - MessageBox(0, L"Job done!", L"File IO Callback", MB_OK | MB_TASKMODAL); -} - - -VOID -TestPlaybackHackingly() -{ - WCHAR msg[1024]; - MMRESULT Result; - WAVEFORMATEX fmt; - ULONG i; - - for ( i = 0; i < 65536; ++ i ) - JunkBuffer[i] = rand(); - - AddSoundDevice(WAVE_OUT_DEVICE_TYPE, L"\\.\SBWaveOut0"); - Result = GetSoundDevice(WAVE_OUT_DEVICE_TYPE, 0, &Device); - - if ( Result != MMSYSERR_NOERROR ) - { - MessageBox(0, L"Fail 1", L"Fail", MB_OK | MB_TASKMODAL); - return; - } - -/* Result = OpenKernelSoundDevice(Device, GENERIC_READ | GENERIC_WRITE); - if ( Result != MMSYSERR_NOERROR ) - { - MessageBox(0, L"Fail open", L"Fail", MB_OK | MB_TASKMODAL); - return; - } - wsprintf(msg, L"Opened handle %x", Device->Handle); - MessageBox(0, msg, L"Result", MB_OK | MB_TASKMODAL); -*/ - - Result = CreateSoundDeviceInstance(Device, &Instance); - if ( Result != MMSYSERR_NOERROR ) - { - MessageBox(0, L"Fail 2", L"Fail 2", MB_OK | MB_TASKMODAL); - return; - } - - /* Request a valid format */ - fmt.wFormatTag = WAVE_FORMAT_PCM; - fmt.nChannels = 1; - fmt.nSamplesPerSec = 22050; - fmt.wBitsPerSample = 16; - fmt.nBlockAlign = fmt.nChannels * (fmt.wBitsPerSample / 8); - fmt.nAvgBytesPerSec = fmt.nSamplesPerSec * fmt.nBlockAlign; - fmt.cbSize = 0; - - Result = SetWaveDeviceFormat(Instance, &fmt, sizeof(WAVEFORMATEX)); - - wsprintf(msg, L"Format support set result: %d\nClick to play!", Result); - MessageBox(0, msg, L"Result", MB_OK | MB_TASKMODAL); - - //SOUND_DEBUG_HEX(Instance->Device->Handle); - - Result = StartWaveThread(Instance); - if ( Result != MMSYSERR_NOERROR ) - { - MessageBox(0, L"Failed to start thread", L"Fail 3", MB_OK | MB_TASKMODAL); - return; - } - - //SOUND_DEBUG_HEX(Instance->Device->Handle); - - waveheader.lpData = (PVOID) JunkBuffer; - waveheader.dwBufferLength = 65536; - waveheader.dwFlags = WHDR_PREPARED; - - Result = QueueWaveDeviceBuffer(Instance, &waveheader); -// CallSoundThread(Instance, WAVEREQUEST_QUEUE_BUFFER, &waveheader); -/* - Result = WriteSoundDeviceBuffer(Instance, - JunkBuffer, 65535, OverlappedCallback); -*/ - wsprintf(msg, L"Play result: %d", Result); - MessageBox(0, msg, L"Result", MB_OK | MB_TASKMODAL); - - StopWaveThread(Instance); - DestroySoundDeviceInstance(Instance); -} - - -APIENTRY VOID -TestDevEnum() -{ - EnumerateNt4ServiceSoundDevices( - L"sndblst", - WAVE_OUT_DEVICE_TYPE, - TestCallback); -} - - -MMRESULT -TestThreadCallback( - IN struct _SOUND_DEVICE_INSTANCE* Instance, - IN DWORD RequestId, - IN PVOID Data) -{ - MessageBox(0, L"Thread Request Callback", L"Woot", MB_OK | MB_TASKMODAL); - - return MMSYSERR_NOERROR; -} - - -WINAPI VOID -TestThreading() -{ - MMRESULT Result; - PSOUND_DEVICE Device; - PSOUND_DEVICE_INSTANCE Instance; - - AddSoundDevice(WAVE_OUT_DEVICE_TYPE, L"\\.\SBWaveOut0"); - Result = GetSoundDevice(WAVE_OUT_DEVICE_TYPE, 0, &Device); - if ( Result != MMSYSERR_NOERROR ) - { - MessageBox(0, L"Fail 1", L"Fail 1", MB_OK | MB_TASKMODAL); - return; - } - - Result = CreateSoundDeviceInstance(Device, &Instance); - if ( Result != MMSYSERR_NOERROR ) - { - MessageBox(0, L"Fail 2", L"Fail 2", MB_OK | MB_TASKMODAL); - return; - } - - Result = StartWaveThread(Instance); - if ( Result != MMSYSERR_NOERROR ) - { - MessageBox(0, L"Fail 3", L"Fail 3", MB_OK | MB_TASKMODAL); - return; - } - - MessageBox(0, L"Click to send a request", L"Bai", MB_OK | MB_TASKMODAL); - CallSoundThread(Instance, 69, NULL); - - MessageBox(0, L"Click to kill thread", L"Bai", MB_OK | MB_TASKMODAL); - - StopWaveThread(Instance); -} - - -VOID -wodTest() -{ - //MMRESULT Result; - DWORD NumWaveOuts; - WAVEOUTCAPS Caps; - MMRESULT Result; - WCHAR String[1024]; - - /* Report the number of wave output devices */ - NumWaveOuts = wodMessage(0, WODM_GETNUMDEVS, 0, 0, 0); - SOUND_DEBUG_HEX(NumWaveOuts); - - if ( NumWaveOuts < 1 ) - { - SOUND_DEBUG(L"Nothing to do as no waveout devices!"); - return; - } - - Result = wodMessage(0, WODM_GETDEVCAPS, 0, - (DWORD) &Caps, sizeof(WAVEOUTCAPS)); - - wsprintf(String, L"Device name: %hS\nManufacturer ID: %d\nProduct ID: %d\nDriver version: %x\nChannels: %d", Caps.szPname, Caps.wMid, Caps.wPid, Caps.vDriverVersion, Caps.wChannels); - - MessageBox(0, String, L"Device caps", MB_OK | MB_TASKMODAL); -} - - -int APIENTRY wWinMain( - HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPWSTR lpCmdLine, - int nCmdShow) -{ -// TestDeviceDetection(); -// wodTest(); -// TestFormatQuery(); - TestPlaybackHackingly(); -// TestDevEnum(); -/* - TestThreading(); -*/ - MessageBox(0, L"Le end", L"Bai", MB_OK | MB_TASKMODAL); - return 0; -}