Author: janderwald
Date: Sat Jan 2 02:52:12 2010
New Revision: 44872
URL:
http://svn.reactos.org/svn/reactos?rev=44872&view=rev
Log:
[MMIXER]
- Implement registering hardware events (volume / mute control changes)
- Fix a bug when querying a source mixer line. The wrong line id was passed which caused
the call to fail.
Modified:
trunk/reactos/lib/drivers/sound/mmixer/controls.c
trunk/reactos/lib/drivers/sound/mmixer/mixer.c
trunk/reactos/lib/drivers/sound/mmixer/mmixer.h
trunk/reactos/lib/drivers/sound/mmixer/priv.h
trunk/reactos/lib/drivers/sound/mmixer/sup.c
Modified: trunk/reactos/lib/drivers/sound/mmixer/controls.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmixer/c…
==============================================================================
--- trunk/reactos/lib/drivers/sound/mmixer/controls.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/sound/mmixer/controls.c [iso-8859-1] Sat Jan 2 02:52:12
2010
@@ -853,6 +853,7 @@
// initialize line list
InitializeListHead(&MixerInfo->LineList);
+ InitializeListHead(&MixerInfo->EventList);
// now allocate an array which will receive the indices of the pin
// which has a ADC / DAC nodetype in its path
@@ -1075,3 +1076,79 @@
// done
return Status;
}
+
+
+MIXER_STATUS
+MMixerAddEvent(
+ IN PMIXER_CONTEXT MixerContext,
+ IN OUT LPMIXER_INFO MixerInfo,
+ IN ULONG NodeId)
+{
+ KSE_NODE Property;
+ LPEVENT_ITEM EventData;
+ ULONG BytesReturned;
+ MIXER_STATUS Status;
+
+ EventData = (LPEVENT_ITEM)MixerContext->AllocEventData(sizeof(LIST_ENTRY));
+ if (!EventData)
+ {
+ // not enough memory
+ return MM_STATUS_NO_MEMORY;
+ }
+
+ /* setup request */
+ Property.Event.Set = KSEVENTSETID_AudioControlChange;
+ Property.Event.Flags = KSEVENT_TYPE_TOPOLOGY|KSEVENT_TYPE_ENABLE;
+ Property.Event.Id = KSEVENT_CONTROL_CHANGE;
+
+ Property.NodeId = NodeId;
+ Property.Reserved = 0;
+
+ Status = MixerContext->Control(MixerInfo->hMixer, IOCTL_KS_ENABLE_EVENT,
(PVOID)&Property, sizeof(KSP_NODE), (PVOID)EventData, sizeof(KSEVENTDATA),
&BytesReturned);
+ if (Status != MM_STATUS_SUCCESS)
+ {
+ // failed to add event
+ MixerContext->FreeEventData(EventData);
+ return Status;
+ }
+
+ //store event
+ InsertTailList(&MixerInfo->EventList, &EventData->Entry);
+ return Status;
+}
+
+MIXER_STATUS
+MMixerAddEvents(
+ IN PMIXER_CONTEXT MixerContext,
+ IN OUT LPMIXER_INFO MixerInfo)
+{
+ PKSMULTIPLE_ITEM NodeTypes;
+ ULONG Index;
+ MIXER_STATUS Status;
+ LPGUID Guid;
+
+ // get filter node types
+ Status = MMixerGetFilterTopologyProperty(MixerContext, MixerInfo->hMixer,
KSPROPERTY_TOPOLOGY_NODES, &NodeTypes);
+
+ if (Status != MM_STATUS_SUCCESS)
+ {
+ // failed
+ return Status;
+ }
+
+ for(Index = 0; Index < NodeTypes->Count; Index++)
+ {
+ Guid = MMixerGetNodeType(NodeTypes, Index);
+ if (IsEqualGUID(&KSNODETYPE_VOLUME, Guid) ||
IsEqualGUID(&KSNODETYPE_MUTE, Guid))
+ {
+ //add an event for volume / mute controls
+ //TODO: extra control types
+ MMixerAddEvent(MixerContext, MixerInfo, Index);
+ }
+ }
+
+ // free node types
+ MixerContext->Free(NodeTypes);
+
+ return MM_STATUS_SUCCESS;
+}
Modified: trunk/reactos/lib/drivers/sound/mmixer/mixer.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmixer/m…
==============================================================================
--- trunk/reactos/lib/drivers/sound/mmixer/mixer.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/sound/mmixer/mixer.c [iso-8859-1] Sat Jan 2 02:52:12 2010
@@ -100,6 +100,9 @@
// FIXME
// handle event notification
+ Status = MMixerAddEvents(MixerContext, MixerInfo);
+
+
// store result
*MixerHandle = (HANDLE)MixerInfo;
@@ -163,7 +166,7 @@
return MM_STATUS_INVALID_PARAMETER;
}
- MixerLineSrc = MMixerGetSourceMixerLineByLineId(MixerInfo,
MixerLine->dwSource);
+ MixerLineSrc = MMixerGetSourceMixerLineByLineId(MixerInfo, MixerLine->dwSource
* 0x10000);
if (MixerLineSrc)
{
DPRINT("Line %u Name %S\n", MixerLineSrc->Line.dwSource,
MixerLineSrc->Line.szName);
@@ -422,7 +425,8 @@
return MM_STATUS_INVALID_PARAMETER;
}
- if (!MixerContext->Alloc || !MixerContext->Control || !MixerContext->Free ||
!MixerContext->Open ||
+ if (!MixerContext->Alloc || !MixerContext->Control || !MixerContext->Free ||
!MixerContext->Open ||
+ !MixerContext->AllocEventData || !MixerContext->FreeEventData ||
!MixerContext->Close || !MixerContext->OpenKey ||
!MixerContext->QueryKeyValue || !MixerContext->CloseKey)
{
// invalid parameter
Modified: trunk/reactos/lib/drivers/sound/mmixer/mmixer.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmixer/m…
==============================================================================
--- trunk/reactos/lib/drivers/sound/mmixer/mmixer.h [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/sound/mmixer/mmixer.h [iso-8859-1] Sat Jan 2 02:52:12 2010
@@ -69,6 +69,12 @@
IN ULONG DesiredAccess,
OUT PHANDLE OutKey);
+typedef PVOID (*PMIXER_ALLOC_EVENT_DATA)(
+ IN ULONG ExtraBytes);
+
+typedef VOID (*PMIXER_FREE_EVENT_DATA)(
+ IN PVOID EventData);
+
typedef struct
{
ULONG SizeOfStruct;
@@ -83,6 +89,8 @@
PMIXER_OPEN_KEY OpenKey;
PMIXER_QUERY_KEY_VALUE QueryKeyValue;
PMIXER_CLOSEKEY CloseKey;
+ PMIXER_ALLOC_EVENT_DATA AllocEventData;
+ PMIXER_FREE_EVENT_DATA FreeEventData;
}MIXER_CONTEXT, *PMIXER_CONTEXT;
MIXER_STATUS
Modified: trunk/reactos/lib/drivers/sound/mmixer/priv.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmixer/p…
==============================================================================
--- trunk/reactos/lib/drivers/sound/mmixer/priv.h [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/sound/mmixer/priv.h [iso-8859-1] Sat Jan 2 02:52:12 2010
@@ -15,8 +15,14 @@
#include "mmixer.h"
#include <stdio.h>
-
+#define YDEBUG
#include <debug.h>
+
+typedef struct
+{
+ KSEVENTDATA EventData;
+ LIST_ENTRY Entry;
+}EVENT_ITEM, *LPEVENT_ITEM;
typedef struct
{
@@ -25,6 +31,7 @@
HANDLE hMixer;
LIST_ENTRY LineList;
ULONG ControlId;
+ LIST_ENTRY EventList;
}MIXER_INFO, *LPMIXER_INFO;
typedef struct
@@ -268,4 +275,9 @@
IN ULONG bWaveIn,
IN ULONG PinId);
+MIXER_STATUS
+MMixerAddEvents(
+ IN PMIXER_CONTEXT MixerContext,
+ IN OUT LPMIXER_INFO MixerInfo);
+
#endif
Modified: trunk/reactos/lib/drivers/sound/mmixer/sup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmixer/s…
==============================================================================
--- trunk/reactos/lib/drivers/sound/mmixer/sup.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/sound/mmixer/sup.c [iso-8859-1] Sat Jan 2 02:52:12 2010
@@ -29,6 +29,7 @@
const GUID KSPROPSETID_Pin = {0x8C134960L, 0x51AD, 0x11CF, {0x87,
0x8A, 0x94, 0xF8, 0x01, 0xC1, 0x00, 0x00}};
const GUID KSPROPSETID_General = {0x1464EDA5L, 0x6A8F, 0x11D1, {0x9A,
0xA7, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
const GUID KSPROPSETID_Topology = {0x720D4AC0L, 0x7533, 0x11D0, {0xA5,
0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
+const GUID KSEVENTSETID_AudioControlChange = {0xE85E9698L, 0xFA2F, 0x11D1, {0x95,
0xBD, 0x00, 0xC0, 0x4F, 0xB9, 0x25, 0xD3}};
MIXER_STATUS
MMixerVerifyContext(
@@ -37,7 +38,8 @@
if (MixerContext->SizeOfStruct != sizeof(MIXER_CONTEXT))
return MM_STATUS_INVALID_PARAMETER;
- if (!MixerContext->Alloc || !MixerContext->Control || !MixerContext->Free ||
!MixerContext->Open ||
+ if (!MixerContext->Alloc || !MixerContext->Control || !MixerContext->Free ||
!MixerContext->Open ||
+ !MixerContext->AllocEventData || !MixerContext->FreeEventData ||
!MixerContext->Close || !MixerContext->OpenKey ||
!MixerContext->QueryKeyValue || !MixerContext->CloseKey)
return MM_STATUS_INVALID_PARAMETER;
@@ -129,7 +131,7 @@
while(Entry != &MixerInfo->LineList)
{
MixerLineSrc = (LPMIXERLINE_EXT)CONTAINING_RECORD(Entry, MIXERLINE_EXT, Entry);
- DPRINT("dwLineID %x dwLineID %x\n", MixerLineSrc->Line.dwLineID,
dwLineID);
+ DPRINT("dwLineID %x dwLineID %x MixerLineSrc %p\n",
MixerLineSrc->Line.dwLineID, dwLineID, MixerLineSrc);
if (MixerLineSrc->Line.dwLineID == dwLineID)
return MixerLineSrc;