[wdmaudiodev] Re: Data Event in AVStream

  • From: "Sam Tertzakian" <sam@xxxxxxxxxxx>
  • To: <wdmaudiodev@xxxxxxxxxxxxx>
  • Date: Sun, 20 Nov 2005 15:02:23 -0800

Hi, 

 

I have resolved this problem.

 

The correct way to get the data is in step 3 should be:

 

      KSQUERYBUFFER QueryBuffer;

            DWORD Dword;

      

Event.Flags = KSEVENT_TYPE_QUERYBUFFER;

      QueryBuffer.Event = Event;

      QueryBuffer.EventData = &EventData.EventData;

      QueryBuffer.Reserved = 0;

      BytesReturned = 0x0;

hr = m_pControl->KsEvent(

                        (PKSEVENT)&QueryBuffer,

                        sizeof( QueryBuffer ),

                        &Dword,

                        sizeof (Dword),

                        &BytesReturned

                  );

 

Essentially, the parameters of KsEvent() should be renamed to (inputbuffer,
inputbuffersize, outputbuffer, outputbuffersize). The it matches the call as
if made using KS_IOCTL_*. 

 

I think MSFT should update the docs.unless I am missing something, it is not
intuitive.

 

  _____  

From: wdmaudiodev-bounce@xxxxxxxxxxxxx
[mailto:wdmaudiodev-bounce@xxxxxxxxxxxxx] On Behalf Of Sam Tertzakian
Sent: Thursday, November 17, 2005 2:09 PM
To: wdmaudiodev@xxxxxxxxxxxxx
Subject: [wdmaudiodev] Data Event in AVStream

 

Hi, 

 

I am trying to use KSEVENT to get a "data event" from an AVStream driver
(not using KS_IOCTL_* directly).

 

By "data event", I mean, that the user mode program registers for event
notification and when the underlying AVStream driver signals the event, it
also sends data in a buffer.

 

The user mode program is able to receive notification of the event. But, it
is unable to get the associated data. Here is what I have:

 

In Kernel Mode:

 

1. Define the event:

 

    DEFINE_KSEVENT_ITEM

    (

            KSEVENT_XXXX,                             // Id

            sizeof( KSEVENTDATA ) + sizeof( ULONG ),  // DataInput (ULONG is
data to send)

            0,                                        // ExtraEntryData

            NULL,                                     // AddHandler

            NULL,                                     // RemoveHandler

            NULL                                      // SupportHandler

    )

 

2. Signal the event:

 

            ULONG Data=0x12345678;

      KsFilterGenerateEvents(

            pFilter,

            &KSEVENTSETID_XXXX,

            KSEVENT_XXXX,

            Sizeof( ULONG ),

            &Data,

            NULL,

            NULL

      );

 

In User Mode:

 

1. Register for the event:

      

typedef struct {

      KSEVENTDATA EventData;

      ULONG ExtraData;              // where data should go

} EVENTDATAEX, *PEVENTDATAEX;

 

      HANDLE EventHandle;

      KSEVENT Event;

      EVENTDATAEX EventData;

            

EventHandle = CreateEvent( NULL, FALSE, FALSE, NULL );

 

      Event.Set   = KSEVENTSETID_XXXX;

      Event.Id    = KSEVENT_XXXX;

      Event.Flags = KSEVENT_TYPE_ENABLEBUFFERED;

      EventData.EventData.NotificationType = KSEVENTF_EVENT_HANDLE;

      EventData.EventData.EventHandle.Event = EventHandle;

      EventData.EventData.EventHandle.Reserved [0] = 0;

      EventData.EventData.EventHandle.Reserved [1] = 0;

EventData.ExtraData = 0xAAAAAAAA;

 

      // Note: target data should go right after EventData.

      hr = m_pControl->KsEvent(

                              &Event,

                              sizeof (Event),

                              &EventData.EventData,

                              sizeof (EventData.EventData) + sizeof( ULONG
),

                              &BytesReturned

                        );

 

Hr = O_OK. If the size is not the sum in the 4th parameter, I get an error,
so I know that so far I am good.

 

2. Wait for event:

 

      EventRet = WaitForSingleObject( 

                        EventHandle, 

                        INFINITE 

                  );

      if ( EventRet == WAIT_OBJECT_0) {

                        

3. Try to get data:

 

Here I have tried several ways. I am putting one of them here:

 

Event.Flags = KSEVENT_TYPE_QUERYBUFFER;

      BytesReturned = 0x0;

hr = m_pControl->KsEvent(

                        &Event,

                        sizeof(Event),

                        &EventData.EventData,

                        sizeof (EventData.EventData) + sizeof( ULONG ),

                        &BytesReturned

                  );

 

Or:

      KSQUERYBUFFER QueryBuffer;

      

Event.Flags = KSEVENT_TYPE_QUERYBUFFER;

      QueryBuffer.Event = Event;

      QueryBuffer.EventData = &EventData.EventData;

      QueryBuffer.Reserved = 0;

      BytesReturned = 0x0;

hr = m_pControl->KsEvent(

                        &Event,

                        sizeof(Event),

                        &QueryBuffer,

                        sizeof( QueryBuffer ) + sizeof( ULONG ),

                        &BytesReturned

                  );

 

I have also verified that the data is not where it should be when the event
is signaled. I have tried not using EVENTBUFFERED and ENABLE instead but
there is no difference.

 

4. But I always get the error:

 

Hr = 0x800706F8 (The supplied user buffer is not valid for the requested
operation.)

 

Does anybody see what I am dong wrong? Is it possible that AVStream does not
support "Data Events"?

 

Thank you for your time.

 

Other related posts: