ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

VOID CompleteWaveHeader ( IN PSOUND_DEVICE_INSTANCE  SoundDeviceInstance,
IN PWAVEHDR  Header 
)

Definition at line 274 of file header.c.

Referenced by CompleteIO(), and StopStreamingInSoundThread().

{
    PWAVEHDR PrevHdr = NULL, CurrHdr = NULL;
    PWAVEHDR_EXTENSION Extension;
    PSOUND_DEVICE SoundDevice;
    MMDEVICE_TYPE DeviceType;
    MMRESULT Result;

    SND_TRACE(L"BUFFER COMPLETE :)\n");

    // TODO: Set header flags?
    // TODO: Call client
    // TODO: Streaming

    //DoWaveStreaming(SoundDeviceInstance);

    Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
    SND_ASSERT( MMSUCCESS(Result) );
    Result = GetSoundDeviceType(SoundDevice, &DeviceType);
    SND_ASSERT( MMSUCCESS(Result) );

    Extension = (PWAVEHDR_EXTENSION)Header->reserved;
    SND_ASSERT( Extension );

    /* Remove the header from the queue, like so */
    if ( SoundDeviceInstance->HeadWaveHeader == Header )
    {
        SoundDeviceInstance->HeadWaveHeader = Header->lpNext;

        SND_TRACE(L"Dropping head node\n");

        /* If nothing after the head, then there is no tail */
        if ( Header->lpNext == NULL )
        {
            SND_TRACE(L"Dropping tail node\n");
            SoundDeviceInstance->TailWaveHeader = NULL;
        }
    }
    else
    {
        PrevHdr = NULL;
        CurrHdr = SoundDeviceInstance->HeadWaveHeader;

        SND_TRACE(L"Relinking nodes\n");

        while ( CurrHdr != Header )
        {
            PrevHdr = CurrHdr;
            CurrHdr = CurrHdr->lpNext;
            SND_ASSERT( CurrHdr );
        }

        SND_ASSERT( PrevHdr );

        PrevHdr->lpNext = CurrHdr->lpNext;

        /* If this is the tail node, update the tail */
        if ( Header->lpNext == NULL )
        {
            SND_TRACE(L"Updating tail node\n");
            SoundDeviceInstance->TailWaveHeader = PrevHdr;
        }
    }

    /* Make sure we're not using this as the current buffer any more, either! */
/*
    if ( SoundDeviceInstance->CurrentWaveHeader == Header )
    {
        SoundDeviceInstance->CurrentWaveHeader = Header->lpNext;
    }
*/

    DUMP_WAVEHDR_QUEUE(SoundDeviceInstance);

    SND_TRACE(L"Returning buffer to client...\n");

    /* Update the header */
    Header->dwFlags &= ~WHDR_INQUEUE;
    Header->dwFlags |= WHDR_DONE;

    if ( DeviceType == WAVE_IN_DEVICE_TYPE )
    {
        // FIXME: We won't be called on incomplete buffer!
        Header->dwBytesRecorded = Extension->BytesCompleted;
    }

    /* Safe to do this without thread protection, as we're done with the header */
    NotifyMmeClient(SoundDeviceInstance,
                    DeviceType == WAVE_OUT_DEVICE_TYPE ? WOM_DONE : WIM_DATA,
                    (DWORD_PTR)Header);
}

Generated on Sun May 27 2012 05:07:04 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.