Author: janderwald
Date: Mon Mar 9 21:05:56 2009
New Revision: 39917
URL:
http://svn.reactos.org/svn/reactos?rev=39917&view=rev
Log:
- Disable message flood when playing audio files as it is very time critical and makes
audio stutter
- Free remaining irps and make sure that the dpc finished before stopping the audio
stream. This fixing stuttering when there are too few audio buffers available.
- Complete the IRPs when they are actually have played. This should make audio playback
position become more accurate and prevents application to feed in too much audio buffers
- VLC 0.9.8a can now playback audio files (no window is shown -> different issue)
Modified:
trunk/reactos/drivers/wdm/audio/backpln/portcls/dispatcher.c
trunk/reactos/drivers/wdm/audio/backpln/portcls/interfaces.h
trunk/reactos/drivers/wdm/audio/backpln/portcls/irpstream.c
trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c
trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c
trunk/reactos/drivers/wdm/audio/sysaudio/pin.c
trunk/reactos/include/reactos/libs/sound/mmebuddy.h
trunk/reactos/lib/drivers/sound/mmebuddy/mmebuddy.rbuild
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/dispatcher.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/dispatcher.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/dispatcher.c [iso-8859-1] Mon Mar 9
21:05:56 2009
@@ -216,7 +216,7 @@
PDEVICE_OBJECT DeviceObject)
{
IIrpTarget * IrpTarget;
- DPRINT1("Dispatch_fnFastWrite called DeviceObject %p Irp %p\n",
DeviceObject);
+ //DPRINT1("Dispatch_fnFastWrite called DeviceObject %p Irp %p\n",
DeviceObject);
IrpTarget = (IIrpTarget *)FileObject->FsContext2;
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/interfaces.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/interfaces.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/interfaces.h [iso-8859-1] Mon Mar 9
21:05:56 2009
@@ -214,6 +214,8 @@
STDMETHOD_(BOOL, MinimumDataAvailable)(THIS);
+ STDMETHOD_(BOOL, CancelBuffers)(THIS);
+
};
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/irpstream.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/irpstream.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/irpstream.c [iso-8859-1] Mon Mar 9
21:05:56 2009
@@ -85,7 +85,6 @@
DPRINT1("Freed %u Buffers / IRP Available Mappings %u\n", Count,
This->NumMappings);
}
-
NTSTATUS
NTAPI
IIrpQueue_fnQueryInterface(
@@ -170,7 +169,7 @@
Mapping->Irp = Irp;
Mapping->Next = NULL;
- DPRINT1("FirstMap %p LastMap %p NumMappings %u\n", This->FirstMap,
This->LastMap, This->NumMappings);
+ //DPRINT1("FirstMap %p LastMap %p NumMappings %u\n", This->FirstMap,
This->LastMap, This->NumMappings);
if (!This->FirstMap)
This->FirstMap = Mapping;
@@ -190,7 +189,7 @@
This->NumDataAvailable += Mapping->Header->DataUsed;
- DPRINT1("IIrpQueue_fnAddMapping NumMappings %u SizeOfMapping %lu
NumDataAvailable %lu\n", This->NumMappings, Mapping->Header->DataUsed,
This->NumDataAvailable);
+ DPRINT1("IIrpQueue_fnAddMapping NumMappings %u SizeOfMapping %lu
NumDataAvailable %lu Irp %p\n", This->NumMappings,
Mapping->Header->DataUsed, This->NumDataAvailable, Irp);
return STATUS_SUCCESS;
}
@@ -230,6 +229,9 @@
This->CurrentOffset = 0;
Mapping = This->FirstMap;
This->FirstMap = This->FirstMap->Next;
+
+ if (!This->FirstMap)
+ This->LastMap = NULL;
This->FreeCount++;
@@ -245,8 +247,7 @@
This->NumDataAvailable -= Mapping->Header->DataUsed;
- if ((This->FreeDataSize >
This->DataFormat->WaveFormatEx.nAvgBytesPerSec || This->FreeCount > 25)
&&
- This->DpcActive == FALSE)
+ if (This->FreeCount > 5 && This->DpcActive == FALSE)
{
Mapping = This->FreeMapHead;
This->FreeMapHead = NULL;
@@ -292,7 +293,34 @@
return Result;
}
-
+BOOL
+NTAPI
+IIrpQueue_fnCancelBuffers(
+ IN IIrpQueue *iface)
+{
+ PIRP_MAPPING Mapping;
+ IIrpQueueImpl * This = (IIrpQueueImpl*)iface;
+
+ if (This->DpcActive)
+ return FALSE;
+
+ ASSERT(This->FirstMap == NULL);
+ ASSERT(This->LastMap == NULL);
+
+ if (This->FreeMapHead == NULL)
+ {
+ ASSERT(This->FreeMapTail == NULL);
+ This->FreeMapTail = NULL;
+ return TRUE;
+ }
+
+ Mapping = This->FreeMapHead;
+ This->FreeMapHead = NULL;
+ This->FreeMapTail = NULL;
+ This->DpcActive = TRUE;
+ KeInsertQueueDpc(&This->Dpc, (PVOID)Mapping, NULL);
+ return FALSE;
+}
static IIrpQueueVtbl vt_IIrpQueue =
{
@@ -305,7 +333,8 @@
IIrpQueue_fnUpdateMapping,
IIrpQueue_fnNumMappings,
IIrpQueue_fnMinMappings,
- IIrpQueue_fnMinimumDataAvailable
+ IIrpQueue_fnMinimumDataAvailable,
+ IIrpQueue_fnCancelBuffers
};
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c [iso-8859-1]
(original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c [iso-8859-1] Mon Mar
9 21:05:56 2009
@@ -26,7 +26,6 @@
ULONG ActiveIrpBufferSize;
ULONG ActiveIrpOffset;
ULONG DelayedRequestInProgress;
- ULONG RetryCount;
ULONG FrameSize;
}IPortPinWaveCyclicImpl;
@@ -176,20 +175,19 @@
Status = This->IrpQueue->lpVtbl->GetMapping(This->IrpQueue, &Buffer,
&BufferSize);
if (!NT_SUCCESS(Status))
{
- This->RetryCount++;
- if (This->RetryCount > 30)
+ if (!This->IrpQueue->lpVtbl->CancelBuffers(This->IrpQueue))
{
- DPRINT1("Stopping %u\n",
This->IrpQueue->lpVtbl->NumMappings(This->IrpQueue));
- This->Stream->lpVtbl->SetState(This->Stream, KSSTATE_STOP);
- This->RetryCount = 0;
- This->State = KSSTATE_STOP;
+ /* there is an active dpc pending
+ * wait untill this dpc is done, in order to complete the remaining irps
+ */
return;
}
- DPRINT("IServiceSink_fnRequestService> Waiting for mapping\n");
- This->ServiceGroup->lpVtbl->RequestDelayedService(This->ServiceGroup,
-10000000L);
+ DPRINT1("Stopping %u\n",
This->IrpQueue->lpVtbl->NumMappings(This->IrpQueue));
+
+ This->Stream->lpVtbl->SetState(This->Stream, KSSTATE_PAUSE);
+ This->State = KSSTATE_PAUSE;
return;
}
- This->RetryCount = 0;
if (KeGetCurrentIrql() == DISPATCH_LEVEL)
return;
@@ -381,6 +379,7 @@
if (This->Stream)
{
+ This->IrpQueue->lpVtbl->CancelBuffers(This->IrpQueue);
This->Stream->lpVtbl->SetState(This->Stream,
KSSTATE_STOP);
This->State = KSSTATE_STOP;
@@ -653,13 +652,13 @@
PIRP Irp;
IPortPinWaveCyclicImpl * This = (IPortPinWaveCyclicImpl*)iface;
- DPRINT1("IPortPinWaveCyclic_fnFastWrite entered\n");
+ //DPRINT1("IPortPinWaveCyclic_fnFastWrite entered\n");
Packet = (PCONTEXT_WRITE)Buffer;
- //if (This->IrpQueue->lpVtbl->MinimumDataAvailable(This->IrpQueue))
- // Irp = Packet->Irp;
- //else
+ if (This->IrpQueue->lpVtbl->MinimumDataAvailable(This->IrpQueue))
+ Irp = Packet->Irp;
+ else
Irp = NULL;
Status = This->IrpQueue->lpVtbl->AddMapping(This->IrpQueue, Buffer,
Length, Irp);
@@ -678,7 +677,7 @@
if (!Irp)
{
- DPRINT1("Completing Irp %p\n", Packet->Irp);
+ //DPRINT1("Completing Irp %p\n", Packet->Irp);
Packet->Irp->IoStatus.Status = STATUS_SUCCESS;
Packet->Irp->IoStatus.Information = Packet->Header.DataUsed;
Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/w…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c [iso-8859-1] Mon Mar 9
21:05:56 2009
@@ -650,7 +650,7 @@
IoStack = IoGetCurrentIrpStackLocation(Irp);
- DPRINT1("WdmAudWrite entered\n");
+ //DPRINT("WdmAudWrite entered\n");
if (IoStack->Parameters.Write.Length < sizeof(WDMAUD_DEVICE_INFO))
{
@@ -670,7 +670,7 @@
}
- DPRINT1("DeviceInfo %p %p %p\n", DeviceInfo,
Irp->MdlAddress->StartVa, Irp->MdlAddress->MappedSystemVa);
+ //DPRINT("DeviceInfo %p %p %p\n", DeviceInfo,
Irp->MdlAddress->StartVa, Irp->MdlAddress->MappedSystemVa);
if (DeviceInfo->DeviceType < MIN_SOUND_DEVICE_TYPE || DeviceInfo->DeviceType
> MAX_SOUND_DEVICE_TYPE)
{
/* invalid parameter */
@@ -735,7 +735,5 @@
return IoStatusBlock.Status;
-
- //return SetIrpIoStatus(Irp, STATUS_SUCCESS, 0);
-}
-
+}
+
Modified: trunk/reactos/drivers/wdm/audio/sysaudio/pin.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/sysaudio…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/sysaudio/pin.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/sysaudio/pin.c [iso-8859-1] Mon Mar 9 21:05:56 2009
@@ -218,7 +218,8 @@
{
PDISPATCH_CONTEXT Context;
NTSTATUS Status;
- DPRINT1("Pin_fnFastWrite called DeviceObject %p Irp %p\n", DeviceObject);
+
+ //DPRINT1("Pin_fnFastWrite called DeviceObject %p Irp %p\n",
DeviceObject);
Context = (PDISPATCH_CONTEXT)FileObject->FsContext2;
Status = KsStreamIo(Context->FileObject, NULL, NULL, NULL, NULL, 0, IoStatus,
Buffer, Length, KSSTREAM_WRITE, KernelMode);
Modified: trunk/reactos/include/reactos/libs/sound/mmebuddy.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/sound…
==============================================================================
--- trunk/reactos/include/reactos/libs/sound/mmebuddy.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/libs/sound/mmebuddy.h [iso-8859-1] Mon Mar 9 21:05:56
2009
@@ -56,7 +56,7 @@
{ \
if ( ! ( condition ) ) \
{ \
- SND_ERR(L"ASSERT FAILED: %hS\n", #condition); \
+ SND_ERR(L"ASSERT FAILED: %hS File %hS Line %u\n", #condition,
__FILE__, __LINE__); \
POPUP(L"ASSERT FAILED: %hS\n", #condition); \
ExitProcess(1); \
} \
@@ -80,6 +80,7 @@
#define SND_WARN(...) do {} while ( 0 )
#define SND_TRACE(...) do {} while ( 0 )
#define SND_ASSERT(condition) do {} while ( 0 )
+ #define DUMP_WAVEHDR_QUEUE(condition) do {} while ( 0 )
#endif
/*
Modified: trunk/reactos/lib/drivers/sound/mmebuddy/mmebuddy.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmebuddy…
==============================================================================
--- trunk/reactos/lib/drivers/sound/mmebuddy/mmebuddy.rbuild [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/sound/mmebuddy/mmebuddy.rbuild [iso-8859-1] Mon Mar 9
21:05:56 2009
@@ -2,7 +2,7 @@
<!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd">
<module name="mmebuddy" type="staticlibrary"
allowwarnings="false" unicode="yes">
<include base="ReactOS">include/reactos/libs/sound</include>
- <define name="DEBUG_NT4">1</define>
+ <define name="NDEBUG">1</define>
<file>capabilities.c</file>
<file>devicelist.c</file>
<file>deviceinstance.c</file>