mirror of
https://github.com/reactos/reactos.git
synced 2025-06-01 23:48:12 +00:00
[USBAUDIO]
- implement audio volume property handler svn path=/trunk/; revision=73042
This commit is contained in:
parent
3720040f9d
commit
1ac7d54efd
3 changed files with 81 additions and 65 deletions
|
@ -157,7 +157,6 @@ UsbAudioGetSetProperty(
|
|||
/* submit urb */
|
||||
Status = SubmitUrbSync(DeviceObject, Urb);
|
||||
|
||||
DPRINT1("UsbAudioGetSetProperty Status %x\n", Status);
|
||||
FreeFunction(Urb);
|
||||
return Status;
|
||||
}
|
||||
|
@ -215,12 +214,12 @@ FilterAudioMuteHandler(
|
|||
FeatureUnitDescriptor = (PUSB_AUDIO_CONTROL_FEATURE_UNIT_DESCRIPTOR)NodeContext->Descriptor;
|
||||
if (Property->NodeProperty.Property.Flags & KSPROPERTY_TYPE_GET)
|
||||
{
|
||||
Status = UsbAudioGetSetProperty(FilterContext->DeviceExtension->LowerDevice, 0x81, 0x100, FeatureUnitDescriptor->bUnitID << 8, Data, 1, USBD_TRANSFER_DIRECTION_IN);
|
||||
Status = UsbAudioGetSetProperty(FilterContext->DeviceExtension->LowerDevice, 0x81, 0x1 << 8, FeatureUnitDescriptor->bUnitID << 8, Data, 1, USBD_TRANSFER_DIRECTION_IN);
|
||||
Irp->IoStatus.Information = sizeof(BOOL);
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = UsbAudioGetSetProperty(FilterContext->DeviceExtension->LowerDevice, 0x01, 0x100, FeatureUnitDescriptor->bUnitID << 8, Data, 1, USBD_TRANSFER_DIRECTION_OUT);
|
||||
Status = UsbAudioGetSetProperty(FilterContext->DeviceExtension->LowerDevice, 0x01, 0x1 << 8, FeatureUnitDescriptor->bUnitID << 8, Data, 1, USBD_TRANSFER_DIRECTION_OUT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -234,8 +233,85 @@ FilterAudioVolumeHandler(
|
|||
IN PKSIDENTIFIER Request,
|
||||
IN OUT PVOID Data)
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
return STATUS_SUCCESS;
|
||||
PKSNODEPROPERTY_AUDIO_CHANNEL Property;
|
||||
PKSFILTER Filter;
|
||||
PFILTER_CONTEXT FilterContext;
|
||||
PNODE_CONTEXT NodeContext;
|
||||
PUSB_AUDIO_CONTROL_FEATURE_UNIT_DESCRIPTOR FeatureUnitDescriptor;
|
||||
PSHORT TransferBuffer;
|
||||
LONG Value;
|
||||
NTSTATUS Status = STATUS_INVALID_PARAMETER;
|
||||
|
||||
|
||||
/* get filter from irp */
|
||||
Filter = KsGetFilterFromIrp(Irp);
|
||||
|
||||
if (Filter)
|
||||
{
|
||||
/* get property */
|
||||
Property = (PKSNODEPROPERTY_AUDIO_CHANNEL)Request;
|
||||
|
||||
/* get filter context */
|
||||
FilterContext = (PFILTER_CONTEXT)Filter->Context;
|
||||
|
||||
TransferBuffer = AllocFunction(sizeof(USHORT) * 3);
|
||||
ASSERT(TransferBuffer);
|
||||
|
||||
Value = *(PLONG)Data;
|
||||
|
||||
/* search for node context */
|
||||
NodeContext = FindNodeContextWithNode(FilterContext->DeviceExtension->NodeContext, FilterContext->DeviceExtension->NodeContextCount, Property->NodeProperty.NodeId);
|
||||
if (NodeContext)
|
||||
{
|
||||
FeatureUnitDescriptor = (PUSB_AUDIO_CONTROL_FEATURE_UNIT_DESCRIPTOR)NodeContext->Descriptor;
|
||||
if (Property->NodeProperty.Property.Flags & KSPROPERTY_TYPE_GET)
|
||||
{
|
||||
Status = UsbAudioGetSetProperty(FilterContext->DeviceExtension->LowerDevice, 0x81, 0x2 << 8, FeatureUnitDescriptor->bUnitID << 8, &TransferBuffer[0], sizeof(USHORT), USBD_TRANSFER_DIRECTION_IN);
|
||||
Value = (LONG)TransferBuffer[0] * 256;
|
||||
|
||||
*(PLONG)Data = Value;
|
||||
Irp->IoStatus.Information = sizeof(BOOL);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* downscale value */
|
||||
Value /= 256;
|
||||
|
||||
/* get minimum value */
|
||||
UsbAudioGetSetProperty(FilterContext->DeviceExtension->LowerDevice, 0x82, 0x2 << 8, FeatureUnitDescriptor->bUnitID << 8, &TransferBuffer[0], sizeof(USHORT), USBD_TRANSFER_DIRECTION_IN);
|
||||
|
||||
/* get maximum value */
|
||||
UsbAudioGetSetProperty(FilterContext->DeviceExtension->LowerDevice, 0x83, 0x2 << 8, FeatureUnitDescriptor->bUnitID << 8, &TransferBuffer[1], sizeof(USHORT), USBD_TRANSFER_DIRECTION_IN);
|
||||
|
||||
if (TransferBuffer[0] > Value)
|
||||
{
|
||||
/* use minimum value */
|
||||
Value = TransferBuffer[0];
|
||||
}
|
||||
|
||||
if (TransferBuffer[1] < Value)
|
||||
{
|
||||
/* use maximum value */
|
||||
Value = TransferBuffer[1];
|
||||
}
|
||||
|
||||
/* store value */
|
||||
TransferBuffer[2] = Value;
|
||||
|
||||
/* set volume request */
|
||||
Status = UsbAudioGetSetProperty(FilterContext->DeviceExtension->LowerDevice, 0x01, 0x2 << 8, FeatureUnitDescriptor->bUnitID << 8, &TransferBuffer[2], sizeof(USHORT), USBD_TRANSFER_DIRECTION_OUT);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
/* store number of bytes transferred*/
|
||||
Irp->IoStatus.Information = sizeof(LONG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* free transfer buffer */
|
||||
FreeFunction(TransferBuffer);
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -90,61 +90,6 @@ UsbAudioAllocCaptureUrbIso(
|
|||
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
UsbAudioSetVolume(
|
||||
IN PKSPIN Pin)
|
||||
{
|
||||
PURB Urb;
|
||||
PUCHAR SampleRateBuffer;
|
||||
PPIN_CONTEXT PinContext;
|
||||
NTSTATUS Status;
|
||||
|
||||
/* allocate sample rate buffer */
|
||||
SampleRateBuffer = AllocFunction(sizeof(ULONG));
|
||||
if (!SampleRateBuffer)
|
||||
{
|
||||
/* no memory */
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
/* allocate urb */
|
||||
Urb = AllocFunction(sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST));
|
||||
if (!Urb)
|
||||
{
|
||||
/* no memory */
|
||||
FreeFunction(SampleRateBuffer);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
/* FIXME: determine controls and format urb */
|
||||
UsbBuildVendorRequest(Urb,
|
||||
URB_FUNCTION_CLASS_INTERFACE,
|
||||
sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST),
|
||||
USBD_TRANSFER_DIRECTION_OUT,
|
||||
0,
|
||||
0x01,
|
||||
0x200,
|
||||
0x300,
|
||||
SampleRateBuffer,
|
||||
NULL,
|
||||
2,
|
||||
NULL);
|
||||
|
||||
/* get pin context */
|
||||
PinContext = Pin->Context;
|
||||
|
||||
SampleRateBuffer[0] = 0xC2;
|
||||
SampleRateBuffer[1] = 0xFE;
|
||||
|
||||
/* submit urb */
|
||||
Status = SubmitUrbSync(PinContext->LowerDevice, Urb);
|
||||
|
||||
DPRINT1("UsbAudioSetVolume Pin %p Status %x\n", Pin, Status);
|
||||
FreeFunction(Urb);
|
||||
FreeFunction(SampleRateBuffer);
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
UsbAudioSetFormat(
|
||||
IN PKSPIN Pin)
|
||||
|
@ -643,9 +588,6 @@ USBAudioPinCreate(
|
|||
ASSERT(Status == STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
/* FIXME move to build filter topology*/
|
||||
UsbAudioSetVolume(Pin);
|
||||
|
||||
/* select streaming interface */
|
||||
Status = USBAudioSelectAudioStreamingInterface(PinContext, PinContext->DeviceExtension, PinContext->DeviceExtension->ConfigurationDescriptor);
|
||||
if (!NT_SUCCESS(Status))
|
||||
|
|
|
@ -62,8 +62,6 @@ DEFINE_KSPROPERTY_TABLE(TopologySet) {\
|
|||
DEFINE_KSPROPERTY_ITEM_AUDIO_MUTE(Handler)\
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include <pshpack1.h>
|
||||
|
||||
typedef struct
|
||||
|
|
Loading…
Reference in a new issue