avstream minidriver

  • Thread starter Thread starter shlikewater
  • Start date Start date
S

shlikewater

Guest
Hello, I am a newer for driver development. I am developing an AVStream minidriver for USB audio device (win7 system).

Now, I can install my device (please refer to the device.png), but I cannot find my device in sound management (please refer to the sound.png). The following is the filter and pin description. Could you help us to check them. Thanks.


////////////filter///////////////////

const
GUID
CaptureFilterCategories[CAPTUREFILTERCATEGORIESCOUNT] = {
STATIC_KSCATEGORY_AUDIO,
STATIC_KSCATEGORY_RENDER,
STATIC_KSCATEGORY_CAPTURE
};

KSTOPOLOGY_CONNECTION CaptureConnections[] =
{
{KSFILTER_NODE, 0, KSFILTER_NODE, 1},
{KSFILTER_NODE, 2, KSFILTER_NODE, 3}
};

const
KSFILTER_DESCRIPTOR CaptureFilterDescriptor = {
&CaptureFilterDispatch, //Dispatch Table
NULL, //Automation Table
KSFILTER_DESCRIPTOR_VERSION, //SABINEASIOAUDIOVERION, //Version
0, //KSFILTER_FLAG_DISPATCH_LEVEL_PROCESSING, //Flags
&KSNAME_Filter, //Reference GUID
DEFINE_KSFILTER_PIN_DESCRIPTORS(CapturePinDescriptor), //Pin Descriptor
DEFINE_KSFILTER_CATEGORIES(CaptureFilterCategories), //Pin Categories
DEFINE_KSFILTER_NODE_DESCRIPTORS_NULL, //Node Descriptor
DEFINE_KSFILTER_DEFAULT_CONNECTIONS, //Connection
NULL //Component ID
};

const KSFILTER_DISPATCH CaptureFilterDispatch = {
CCaptureFilter::DispatchCreate, //Filter Create
NULL, //Filter Close
NULL, //CCaptureFilter::DispatchProcess, //Filter Process
NULL, //Filter Reset
};


/////////////////////Pin/////////////////////////////

//Input/Output Data Format
KSDATARANGE_AUDIO PinDataFormatRange = {
{
sizeof(KSDATARANGE_AUDIO), //Format Size
0, // Flags, this member is ignored
4, //SampleSize, this member is ignored
0, //Reserved
STATIC_KSDATAFORMAT_TYPE_AUDIO, //major format
STATIC_KSDATAFORMAT_SUBTYPE_PCM, //sub format
STATIC_KSDATAFORMAT_SPECIFIER_WAVEFORMATEX //specifer
},
2, //MaximumChannels;
16, //MinimumBitsPerSample;
16, //MaximumBitsPerSample;
48000, //MinimumSampleFrequency;
48000, //MaximumSampleFrequency;
};

const PKSDATARANGE PinDataFormatRanges[] = {
(PKSDATARANGE)&PinDataFormatRange
};

static const GUID PinSpkName = { 0xc05a32e6, 0x9f87, 0x48f2, { 0xad, 0x96, 0xeb, 0xe7, 0x17, 0x57, 0xc9, 0x50 } };

// {1E6D3688-AE69-4944-B696-24475A5940D5}
static const GUID PinMicName = { 0x1e6d3688, 0xae69, 0x4944, { 0xb6, 0x96, 0x24, 0x47, 0x5a, 0x59, 0x40, 0xd5 } };


//Automation Table
DEFINE_KSMETHOD_TABLE(CapturePinMethod)
{
//spk
DEFINE_KSMETHOD_ITEM
(
KSMETHOD_WRITEID, //Method Id, Specifies the identifier of this method within its method set.
KSMETHOD_TYPE_READ, //Flags, Indicates that parameters are expected to be read from
//the Data buffer of the handler. When buffered, data is copied
//to the system buffer. When in source mode, the data is probed and locked for IoReadAccess.
CCapturePin::AsioWriteDevice, //Method Handler, Pointer to a minidriver-supplied KStrMethodHandler callback routine.
sizeof(KSMETHOD), //MiniMethod, Specifies the minimum size of buffer required to specify the method completely. This size is at least sizeof(KSMETHOD) bytes.
BUFFERSIZE, //MiniData, Specifies the minimum size buffer required to specify the method data buffer. This buffer is used to read and/or write information related to the method.
NULL //Support Handler, specify a KStrSupportHandler that is used to determine support for the particular method item
),

//mic
DEFINE_KSMETHOD_ITEM
(
KSMETHOD_READID, //Method Id, Specifies the identifier of this method within its method set.
KSMETHOD_TYPE_WRITE, //Flags, Indicates that parameters are expected to be read from
//the Data buffer of the handler. When buffered, data is copied
//to the system buffer. When in source mode, the data is probed and locked for IoReadAccess.
CCapturePin::AsioReadDevice, //Method Handler, Pointer to a minidriver-supplied KStrMethodHandler callback routine.
sizeof(KSMETHOD), //MiniMethod, Specifies the minimum size of buffer required to specify the method completely. This size is at least sizeof(KSMETHOD) bytes.
BUFFERSIZE, //MiniData, Specifies the minimum size buffer required to specify the method data buffer. This buffer is used to read and/or write information related to the method.
NULL //Support Handler, specify a KStrSupportHandler that is used to determine support for the particular method item
),

//set device state
DEFINE_KSMETHOD_ITEM
(
KSMETHOD_SETSTATEID, //Method Id, Specifies the identifier of this method within its method set.
KSMETHOD_TYPE_READ, //Flags, Indicates that parameters are expected to be read from
//the Data buffer of the handler. When buffered, data is copied
//to the system buffer. When in source mode, the data is probed and locked for IoReadAccess.
CCapturePin::AsioSetDeviceState, //Method Handler, Pointer to a minidriver-supplied KStrMethodHandler callback routine.
sizeof(KSMETHOD), //MiniMethod, Specifies the minimum size of buffer required to specify the method completely. This size is at least sizeof(KSMETHOD) bytes.
BUFFERSIZE, //MiniData, Specifies the minimum size buffer required to specify the method data buffer. This buffer is used to read and/or write information related to the method.
NULL //Support Handler, specify a KStrSupportHandler that is used to determine support for the particular method item
)
};

DEFINE_KSMETHOD_SET_TABLE(CapturePinAutoMethod)
{
DEFINE_KSMETHOD_SET
(
&KSMETHODSETID_ASIO, //Set, Specifies a GUID the identifies the kernel streaming method set.
SIZEOF_ARRAY(CapturePinMethod), //MethodCount
CapturePinMethod, //MethodItem
0, //FastIoCount, Reserved for system use. Do not use.
NULL //FastIoTable, Reserved for system use. Do not use.
)
};

DEFINE_KSAUTOMATION_TABLE(CapturePinAutoTable)
{
DEFINE_KSAUTOMATION_PROPERTIES_NULL,
DEFINE_KSAUTOMATION_METHODS(CapturePinAutoMethod),
DEFINE_KSAUTOMATION_EVENTS_NULL
};

const KSPIN_DESCRIPTOR_EX CapturePinDescriptor[CAPTUREPINDESCRIPTORCOUNT] = {
//Audio Render Pin Output, spk
{
&CapturePinDispatch, //Dispatch Table
NULL, //&CapturePinAutoTable, //Automation Table
//KSPIN_DESCRIPTOR
{
DEFINE_KSPIN_DEFAULT_INTERFACES, //Interfaces (NULL, 0 == default)
DEFINE_KSPIN_DEFAULT_MEDIUMS, //Mediums size (NULL, 0 == default)
SIZEOF_ARRAY(PinDataFormatRanges), //Range count
PinDataFormatRanges, //Ranges
KSPIN_DATAFLOW_IN, //Dataflow
KSPIN_COMMUNICATION_BOTH, //Communication
&KSCATEGORY_AUDIO, //KSCATEGORY_AUDIO, //&KSNODETYPE_SPEAKER, //&KSCATEGORY_RENDER, //Category
&KSNODETYPE_SPEAKER, //&PinSpkName, //Name
0 //Reserved
},
//Flags
/*KSPIN_FLAG_FRAMES_NOT_REQUIRED_FOR_PROCESSING |
KSPIN_FLAG_DO_NOT_INITIATE_PROCESSING |
KSPIN_FLAG_PROCESS_IN_RUN_STATE_ONLY |
KSPIN_FLAG_FIXED_FORMAT,*/
KSPIN_FLAG_USE_STANDARD_TRANSPORT |
KSPIN_FLAG_FIXED_FORMAT |
KSPIN_FLAG_RENDERER,
1, //Instances possible
1, //Instances necessary
&PinAllocatorFraming, //Allocator Framing
reinterpret_cast<PFNKSINTERSECTHANDLEREX>
(CCapturePin::IntersectHandler)
},

//Audio Capture Pin Input, mic
{
&CapturePinDispatch, //Dispatch Table
NULL, //Automation Table
//KSPIN_DESCRIPTOR
{
DEFINE_KSPIN_DEFAULT_INTERFACES, //Interfaces (NULL, 0 == default)
DEFINE_KSPIN_DEFAULT_MEDIUMS, //Mediums size (NULL, 0 == default)
SIZEOF_ARRAY(PinDataFormatRanges), //Range count
PinDataFormatRanges, //Ranges
KSPIN_DATAFLOW_OUT, //Dataflow
KSPIN_COMMUNICATION_BOTH, //Communication
&KSCATEGORY_AUDIO, //Category
&KSAUDFNAME_RECORDING_CONTROL, //&PinMicName, //Name
0 //Reserved
},
//Flags
/*KSPIN_FLAG_FRAMES_NOT_REQUIRED_FOR_PROCESSING |
KSPIN_FLAG_DO_NOT_INITIATE_PROCESSING |
KSPIN_FLAG_PROCESS_IN_RUN_STATE_ONLY |
KSPIN_FLAG_FIXED_FORMAT,*/
KSPIN_FLAG_USE_STANDARD_TRANSPORT |
KSPIN_FLAG_FIXED_FORMAT,
1, //Instances possible
1, //Instances necessary
&PinAllocatorFraming, //Allocator Framing
reinterpret_cast<PFNKSINTERSECTHANDLEREX>
(CCapturePin::IntersectHandler)
}
};

DECLARE_SIMPLE_FRAMING_EX(
PinAllocatorFraming, //Name
STATIC_KSMEMORY_TYPE_KERNEL_NONPAGED, //Memory type
//Flags
KSALLOCATOR_REQUIREMENTF_SYSTEM_MEMORY |
KSALLOCATOR_REQUIREMENTF_PREFERENCES_ONLY,
2, //Frames
0, //Alignment
2 * PAGE_SIZE, //MinFrameSize
2 * PAGE_SIZE //MaxFrameSize
);

const KSPIN_DISPATCH CapturePinDispatch = {
CCapturePin::DispatchCreate, //Pin Create
NULL, //Pin Close
CCapturePin::DispatchProcess, //Pin Process
NULL, //Pin Reset
CCapturePin::DispatchSetDataFormat, //Pin Set Data Format
CCapturePin::DispatchSetDeviceState, //Pin Set Device State
NULL, //Pin Connect
NULL, //Pin Disconnect
NULL, //Clock Dispatch
NULL //Allocator Dispatch
};


Best Regards,

Shlikewater

Continue reading...
 
Back
Top