mirror of
https://github.com/reactos/reactos.git
synced 2024-11-18 21:13:52 +00:00
[0.4.7][WDMAUD.DRV][MMIXER] Improve AC97 driver from rapps by defining USE_MMIXER_LIB
By taking alternative code-paths in WdmAud and bypassing Sysaudio. This is a squashed backport of: 0.4.15-dev-791-g6d7ebc2048
the USE_MMIXER_LIB which gives the best results when paired with those 2 previous patches: 0.4.15-dev-765-gb8e936a57b
CORE-17214 (#3148) wdmaud-racecondition-fix and 0.4.15-dev-796-ga27f0debca
CORE-17276 winmm:mixer-testbot-crash-fix Defining USE_MMIXER_LIB will fix/improve: - the test execution times of "GCCLin_x86 on Test VBox" will be dramatically improve (iirc by ~10-15min) - CORE-8726/CORE-9986/CORE-16564 AC97 driver from rapps will work in the same session that the driver is installed, not a single reboot is needed anymore - CORE-13202 Unhandled exception from wdmaud.drv when recording sound in Scratch 1.4 leads to app-crash (gets fixed even for older builds that did not receive 0.4.15-dev-2794-g81f8bce
yet) - CORE-13488 A deadlock in "DiabloII" character selection screen and "The Lion King II" - CORE-9981 "DosBox + Commander Keen6" almost 100% fixed, DosBox + Commander Keen6 properly plays music instead of garbled output, same improvement for "ScummVM 2.0 with Monkey Island 2" The playback is not yet *entirely* perfect, still a few hiccups now and then, but by orders of magnitude better than before. Most of the above mentioned issues were a regression of SVN r44721 ==4b9731d0db
Defining USE_MMIXER_LIB will also have some negative aspects: - CORE-17277 crash of dsound:duplex on "GCCLin_x86 on Test VBox" gets unhidden on the bot, but was proven to be broken even beforehand already. The driver beforehand was just not found and the tests were skipped therefore. - CORE-17278 crash of dsound:capture on "GCCLin_x86 on Test VBox" gets unhidden on the bot, but was proven to be broken even beforehand already. The driver beforehand was just not found and the tests were skipped therefore. - CORE-17744 Fox Audio Player 0.10.2 can not longer play an mp3 file with 22kHz, WMM audio output - It may also have a negative impact for CORE-17285 "Realtek HD Audio" but Oleg Dubinsky accepted to tolerate that and aims to approach it differently. We resolved that as WontFix therefore.
This commit is contained in:
parent
a4f921f21e
commit
6903ddbe4c
3 changed files with 49 additions and 45 deletions
|
@ -12,19 +12,14 @@
|
|||
#include <winreg.h>
|
||||
#include <setupapi.h>
|
||||
#include <mmixer.h>
|
||||
#define NTOS_MODE_USER
|
||||
#include <ndk/rtlfuncs.h>
|
||||
#include <ndk/iofuncs.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
#include <mmebuddy_debug.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
KSSTREAM_HEADER Header;
|
||||
HANDLE hDevice;
|
||||
PSOUND_OVERLAPPED Overlap;
|
||||
LPOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine;
|
||||
DWORD IoCtl;
|
||||
}IO_PACKET, *LPIO_PACKET;
|
||||
|
||||
BOOL MMixerLibraryInitialized = FALSE;
|
||||
|
||||
|
@ -456,7 +451,7 @@ WdmAudGetControlDetails(
|
|||
|
||||
MMRESULT
|
||||
WdmAudGetWaveOutCapabilities(
|
||||
IN ULONG DeviceId,
|
||||
IN ULONG DeviceId,
|
||||
LPWAVEOUTCAPSW Capabilities)
|
||||
{
|
||||
if (MMixerWaveOutCapabilities(&MixerContext, DeviceId, Capabilities) == MM_STATUS_SUCCESS)
|
||||
|
@ -468,7 +463,7 @@ WdmAudGetWaveOutCapabilities(
|
|||
|
||||
MMRESULT
|
||||
WdmAudGetWaveInCapabilities(
|
||||
IN ULONG DeviceId,
|
||||
IN ULONG DeviceId,
|
||||
LPWAVEINCAPSW Capabilities)
|
||||
{
|
||||
if (MMixerWaveInCapabilities(&MixerContext, DeviceId, Capabilities) == MM_STATUS_SUCCESS)
|
||||
|
@ -785,27 +780,25 @@ WdmAudGetWavePositionByMMixer(
|
|||
return MMSYSERR_NOTSUPPORTED;
|
||||
}
|
||||
|
||||
DWORD
|
||||
WINAPI
|
||||
IoStreamingThread(
|
||||
LPVOID lpParameter)
|
||||
static
|
||||
VOID WINAPI
|
||||
CommitWaveBufferApc(PVOID ApcContext,
|
||||
PIO_STATUS_BLOCK IoStatusBlock,
|
||||
ULONG Reserved)
|
||||
{
|
||||
DWORD Length;
|
||||
//MMRESULT Result;
|
||||
LPIO_PACKET Packet = (LPIO_PACKET)lpParameter;
|
||||
DWORD dwErrorCode;
|
||||
PSOUND_OVERLAPPED Overlap;
|
||||
KSSTREAM_HEADER* lpHeader;
|
||||
|
||||
/*Result = */ SyncOverlappedDeviceIoControl(Packet->hDevice,
|
||||
Packet->IoCtl,
|
||||
NULL,
|
||||
0,
|
||||
&Packet->Header,
|
||||
sizeof(KSSTREAM_HEADER),
|
||||
&Length);
|
||||
dwErrorCode = RtlNtStatusToDosError(IoStatusBlock->Status);
|
||||
Overlap = (PSOUND_OVERLAPPED)IoStatusBlock;
|
||||
lpHeader = Overlap->CompletionContext;
|
||||
|
||||
Packet->CompletionRoutine(ERROR_SUCCESS, Packet->Header.DataUsed, (LPOVERLAPPED)Packet->Overlap);
|
||||
/* Call mmebuddy overlap routine */
|
||||
Overlap->OriginalCompletionRoutine(dwErrorCode,
|
||||
lpHeader->DataUsed, &Overlap->Standard);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, Packet);
|
||||
return 0;
|
||||
HeapFree(GetProcessHeap(), 0, lpHeader);
|
||||
}
|
||||
|
||||
MMRESULT
|
||||
|
@ -819,8 +812,9 @@ WdmAudCommitWaveBufferByMMixer(
|
|||
PSOUND_DEVICE SoundDevice;
|
||||
MMDEVICE_TYPE DeviceType;
|
||||
MMRESULT Result;
|
||||
LPIO_PACKET Packet;
|
||||
HANDLE hThread;
|
||||
ULONG IoCtl;
|
||||
KSSTREAM_HEADER* lpHeader;
|
||||
NTSTATUS Status;
|
||||
|
||||
Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
|
||||
|
||||
|
@ -832,37 +826,44 @@ WdmAudCommitWaveBufferByMMixer(
|
|||
Result = GetSoundDeviceType(SoundDevice, &DeviceType);
|
||||
SND_ASSERT( Result == MMSYSERR_NOERROR );
|
||||
|
||||
Packet = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IO_PACKET));
|
||||
if ( ! Packet )
|
||||
lpHeader = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(KSSTREAM_HEADER));
|
||||
if ( ! lpHeader )
|
||||
{
|
||||
/* no memory */
|
||||
return MMSYSERR_NOMEM;
|
||||
}
|
||||
|
||||
/* setup stream packet */
|
||||
Packet->Header.Size = sizeof(KSSTREAM_HEADER);
|
||||
Packet->Header.PresentationTime.Numerator = 1;
|
||||
Packet->Header.PresentationTime.Denominator = 1;
|
||||
Packet->Header.Data = OffsetPtr;
|
||||
Packet->Header.FrameExtent = Length;
|
||||
Packet->hDevice = SoundDeviceInstance->Handle;
|
||||
Packet->Overlap = Overlap;
|
||||
Packet->CompletionRoutine = CompletionRoutine;
|
||||
Packet->IoCtl = (DeviceType == WAVE_OUT_DEVICE_TYPE ? IOCTL_KS_WRITE_STREAM : IOCTL_KS_READ_STREAM);
|
||||
lpHeader->Size = sizeof(KSSTREAM_HEADER);
|
||||
lpHeader->PresentationTime.Numerator = 1;
|
||||
lpHeader->PresentationTime.Denominator = 1;
|
||||
lpHeader->Data = OffsetPtr;
|
||||
lpHeader->FrameExtent = Length;
|
||||
Overlap->CompletionContext = lpHeader;
|
||||
Overlap->OriginalCompletionRoutine = CompletionRoutine;
|
||||
IoCtl = (DeviceType == WAVE_OUT_DEVICE_TYPE ? IOCTL_KS_WRITE_STREAM : IOCTL_KS_READ_STREAM);
|
||||
|
||||
if (DeviceType == WAVE_OUT_DEVICE_TYPE)
|
||||
{
|
||||
Packet->Header.DataUsed = Length;
|
||||
lpHeader->DataUsed = Length;
|
||||
}
|
||||
|
||||
hThread = CreateThread(NULL, 0, IoStreamingThread, (LPVOID)Packet, 0, NULL);
|
||||
if (hThread == NULL)
|
||||
Status = NtDeviceIoControlFile(SoundDeviceInstance->Handle,
|
||||
NULL,
|
||||
CommitWaveBufferApc,
|
||||
NULL,
|
||||
(PIO_STATUS_BLOCK)Overlap,
|
||||
IoCtl,
|
||||
NULL,
|
||||
0,
|
||||
lpHeader,
|
||||
sizeof(KSSTREAM_HEADER));
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* error */
|
||||
return MMSYSERR_ERROR;
|
||||
}
|
||||
|
||||
CloseHandle(hThread);
|
||||
|
||||
return MMSYSERR_NOERROR;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <debug.h>
|
||||
#include <mmebuddy_debug.h>
|
||||
|
||||
#define USE_MMIXER_LIB
|
||||
#ifndef USE_MMIXER_LIB
|
||||
#define FUNC_NAME(x) x##ByLegacy
|
||||
#else
|
||||
|
|
|
@ -690,6 +690,8 @@ MMixerSetGetVolumeControlDetails(
|
|||
|
||||
/* get input */
|
||||
Input = (LPMIXERCONTROLDETAILS_UNSIGNED)MixerControlDetails->paDetails;
|
||||
if (!Input)
|
||||
return MM_STATUS_UNSUCCESSFUL; /* to prevent dereferencing NULL */
|
||||
|
||||
if (bSet)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue