[ros-diffs] [silverblade] 34587: Starting again (existing code backed-up and will be used as a reference for the new re-write).

silverblade at svn.reactos.org silverblade at svn.reactos.org
Sat Jul 19 13:02:19 CEST 2008


Author: silverblade
Date: Sat Jul 19 06:02:19 2008
New Revision: 34587

URL: http://svn.reactos.org/svn/reactos?rev=34587&view=rev
Log:
Starting again (existing code backed-up and will be used as a reference for
the new re-write).


Removed:
    branches/silverblade-audio/lib/drivers/sound/mmebuddy/auxiliary/
    branches/silverblade-audio/lib/drivers/sound/mmebuddy/capabilities.c
    branches/silverblade-audio/lib/drivers/sound/mmebuddy/devices.c
    branches/silverblade-audio/lib/drivers/sound/mmebuddy/instances.c
    branches/silverblade-audio/lib/drivers/sound/mmebuddy/kernel.c
    branches/silverblade-audio/lib/drivers/sound/mmebuddy/midi/
    branches/silverblade-audio/lib/drivers/sound/mmebuddy/mixer/
    branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/
    branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmebuddy.rbuild
    branches/silverblade-audio/lib/drivers/sound/mmebuddy/nt4.c
    branches/silverblade-audio/lib/drivers/sound/mmebuddy/thread.c
    branches/silverblade-audio/lib/drivers/sound/mmebuddy/utility.c
    branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/

Removed: branches/silverblade-audio/lib/drivers/sound/mmebuddy/capabilities.c
URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/sound/mmebuddy/capabilities.c?rev=34586&view=auto
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/capabilities.c [iso-8859-1] (original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/capabilities.c (removed)
@@ -1,109 +1,0 @@
-/*
- * PROJECT:     ReactOS Sound System "MME Buddy" Library
- * LICENSE:     GPL - See COPYING in the top level directory
- * FILE:        lib/sound/mmebuddy/capabilities.c
- *
- * PURPOSE:     Queries sound devices for their capabilities.
- *
- * PROGRAMMERS: Andrew Greenwood (silverblade at reactos.org)
-*/
-
-#include <windows.h>
-#include <mmsystem.h>
-#include <ntddk.h>      /* needed for ioctl stuff */
-#include <ntddsnd.h>
-
-#include <mmebuddy.h>
-
-MMRESULT
-GetSoundDeviceCapabilities(
-    IN  PSOUND_DEVICE SoundDevice,
-    OUT PUNIVERSAL_CAPS Capabilities)
-{
-    VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) );
-    VALIDATE_MMSYS_PARAMETER( Capabilities );
-
-    return SoundDevice->Functions.GetCapabilities(SoundDevice, Capabilities);
-}
-
-MMRESULT
-DefaultGetSoundDeviceCapabilities(
-    IN  PSOUND_DEVICE SoundDevice,
-    OUT PUNIVERSAL_CAPS Capabilities)
-{
-    HANDLE Handle;
-    PVOID RawCapsPtr = NULL;
-    ULONG CapsSize = 0;
-    DWORD Ioctl;
-    MMRESULT Result;
-    DWORD BytesReturned;
-
-    VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) );
-    VALIDATE_MMSYS_PARAMETER( Capabilities );
-
-    ZeroMemory(Capabilities, sizeof(UNIVERSAL_CAPS));
-
-    /* Select appropriate IOCTL and capabilities structure */
-    switch ( SoundDevice->DeviceType )
-    {
-        case WAVE_OUT_DEVICE_TYPE :
-            Ioctl = IOCTL_WAVE_GET_CAPABILITIES;
-            RawCapsPtr = (PVOID) &Capabilities->WaveOut;
-            CapsSize = sizeof(WAVEOUTCAPS);
-            break;
-
-        case WAVE_IN_DEVICE_TYPE :
-            Ioctl = IOCTL_WAVE_GET_CAPABILITIES;
-            RawCapsPtr = (PVOID) &Capabilities->WaveIn;
-            CapsSize = sizeof(WAVEINCAPS);
-            break;
-
-        case MIDI_OUT_DEVICE_TYPE :
-            Ioctl = IOCTL_MIDI_GET_CAPABILITIES;
-            RawCapsPtr = (PVOID) &Capabilities->MidiOut;
-            CapsSize = sizeof(MIDIOUTCAPS);
-            break;
-
-        case MIDI_IN_DEVICE_TYPE :
-            Ioctl = IOCTL_MIDI_GET_CAPABILITIES;
-            RawCapsPtr = (PVOID) &Capabilities->MidiIn;
-            CapsSize = sizeof(MIDIINCAPS);
-            break;
-
-        case MIXER_DEVICE_TYPE :
-            /* TODO */
-            /*Ioctl = IOCTL_MIX_GET_CAPABILITIES;*/
-            return MMSYSERR_NOTSUPPORTED;
-
-        case AUX_DEVICE_TYPE :
-            /* TODO */
-            Ioctl = IOCTL_AUX_GET_CAPABILITIES;
-            return MMSYSERR_NOTSUPPORTED;
-
-        default :
-            return MMSYSERR_NOTSUPPORTED;
-    }
-
-    Result = OpenKernelSoundDevice(SoundDevice,
-                                   GENERIC_READ,
-                                   &Handle);
-
-    if ( Result != MMSYSERR_NOERROR )
-    {
-        Result = TranslateInternalMmResult(Result);
-        return Result;
-    }
-
-    /* Call the driver */
-    Result = RetrieveFromDeviceHandle(
-        Handle,
-        Ioctl,
-        (LPVOID) RawCapsPtr,
-        CapsSize,
-        &BytesReturned,
-        NULL);
-
-    CloseKernelSoundDevice(Handle);
-
-    return Result;
-}

Removed: branches/silverblade-audio/lib/drivers/sound/mmebuddy/devices.c
URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/sound/mmebuddy/devices.c?rev=34586&view=auto
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/devices.c [iso-8859-1] (original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/devices.c (removed)
@@ -1,542 +1,0 @@
-/*
- * PROJECT:     ReactOS Sound System "MME Buddy" Library
- * LICENSE:     GPL - See COPYING in the top level directory
- * FILE:        lib/sound/mmebuddy/devices.c
- *
- * PURPOSE:     Manages lists of sound devices.
- *
- * PROGRAMMERS: Andrew Greenwood (silverblade at reactos.org)
-*/
-
-/*
-    TODO:
-        The removal of devices from the list needs to be separated from
-        the destruction of the device structure.
-*/
-
-#include <windows.h>
-#include <ntddsnd.h>
-
-#include <mmebuddy.h>
-
-/* Device Lists */
-ULONG SoundDeviceTotals[SOUND_DEVICE_TYPES];
-PSOUND_DEVICE SoundDeviceLists[SOUND_DEVICE_TYPES];
-
-#define DEVICE_TYPE_TO_INDEX(device_type) \
-    ( device_type - MIN_SOUND_DEVICE_TYPE )
-
-
-ULONG
-GetSoundDeviceCount(
-    IN  UCHAR DeviceType)
-{
-    ULONG Count;
-    TRACE_ENTRY();
-
-    if ( ! VALID_SOUND_DEVICE_TYPE(DeviceType) )
-    {
-        TRACE_EXIT(0);
-        return 0;
-    }
-
-    Count = SoundDeviceTotals[DeviceType - MIN_SOUND_DEVICE_TYPE];
-
-    TRACE_EXIT(Count);
-    return Count;
-}
-
-
-VOID
-InitSoundDeviceFunctionTable(
-    IN  PSOUND_DEVICE Device,
-    IN  PMMFUNCTION_TABLE SourceFunctionTable)
-{
-    TRACE_ENTRY();
-
-    Device->Functions.Constructor = DefaultInstanceConstructor;
-    Device->Functions.Destructor = DefaultInstanceDestructor;
-
-    Device->Functions.GetCapabilities = DefaultGetSoundDeviceCapabilities;
-
-    /* Wave device specific */
-    Device->Functions.QueryWaveFormat = DefaultQueryWaveDeviceFormatSupport;
-    Device->Functions.SetWaveFormat = DefaultSetWaveDeviceFormat;
-
-    Device->Functions.GetWaveDeviceState = DefaultGetWaveDeviceState;
-    Device->Functions.PauseWaveDevice = DefaultPauseWaveDevice;
-    Device->Functions.RestartWaveDevice = DefaultRestartWaveDevice;
-    Device->Functions.ResetWaveDevice = DefaultResetWaveDevice;
-    Device->Functions.BreakWaveDeviceLoop = DefaultBreakWaveDeviceLoop;
-
-    if ( ! SourceFunctionTable )
-    {
-        TRACE_EXIT(0);
-        return;
-    }
-
-    /* If we get here, the function table is being over-ridden */
-
-    if ( SourceFunctionTable->Constructor )
-    {
-        Device->Functions.Constructor =
-            SourceFunctionTable->Constructor;
-    }
-
-    if ( SourceFunctionTable->Destructor )
-    {
-        Device->Functions.Destructor =
-            SourceFunctionTable->Destructor;
-    }
-
-    if ( SourceFunctionTable->GetCapabilities )
-    {
-        Device->Functions.GetCapabilities =
-            SourceFunctionTable->GetCapabilities;
-    }
-
-    if ( SourceFunctionTable->QueryWaveFormat )
-    {
-        Device->Functions.QueryWaveFormat =
-            SourceFunctionTable->QueryWaveFormat;
-    }
-
-    if ( SourceFunctionTable->SetWaveFormat )
-    {
-        Device->Functions.SetWaveFormat =
-            SourceFunctionTable->SetWaveFormat;
-    }
-
-    if ( SourceFunctionTable->GetWaveDeviceState )
-    {
-        Device->Functions.GetWaveDeviceState =
-            SourceFunctionTable->GetWaveDeviceState;
-    }
-
-    if ( SourceFunctionTable->PauseWaveDevice )
-    {
-        Device->Functions.PauseWaveDevice =
-            SourceFunctionTable->PauseWaveDevice;
-    }
-
-    if ( SourceFunctionTable->RestartWaveDevice )
-    {
-        Device->Functions.RestartWaveDevice =
-            SourceFunctionTable->RestartWaveDevice;
-    }
-
-    if ( SourceFunctionTable->ResetWaveDevice )
-    {
-        Device->Functions.ResetWaveDevice =
-            SourceFunctionTable->ResetWaveDevice;
-    }
-
-    if ( SourceFunctionTable->BreakWaveDeviceLoop )
-    {
-        Device->Functions.BreakWaveDeviceLoop =
-            SourceFunctionTable->BreakWaveDeviceLoop;
-    }
-
-    TRACE_EXIT(0);
-}
-
-
-BOOLEAN
-AddSoundDevice(
-    IN  UCHAR DeviceType,
-    IN  LPWSTR DevicePath,
-    IN  PMMFUNCTION_TABLE FunctionTable)
-{
-    PSOUND_DEVICE NewDevice;
-    UCHAR TypeIndex;
-
-    TRACE_ENTRY();
-
-    TRACE_("Adding a sound device to list %d\n", DeviceType);
-
-    if ( ! VALID_SOUND_DEVICE_TYPE(DeviceType) )
-    {
-        TRACE_EXIT(FALSE);
-        return FALSE;
-    }
-
-    TypeIndex = DeviceType - MIN_SOUND_DEVICE_TYPE;
-
-    NewDevice = AllocateMemoryFor(SOUND_DEVICE);
-/*
-    NewDevice = (PSOUND_DEVICE)
-        HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SOUND_DEVICE));
-*/
-
-    if ( ! NewDevice )
-    {
-        TRACE_EXIT(FALSE);
-        return FALSE;
-    }
-
-    NewDevice->Next = NULL;
-    NewDevice->FirstInstance = NULL;
-    NewDevice->DeviceType = DeviceType;
-
-    NewDevice->DevicePath = AllocateWideString(wcslen(DevicePath));
-/*
-    NewDevice->DevicePath = (LPWSTR)
-        HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, DevicePathSize);
-*/
-
-    if ( ! NewDevice->DevicePath )
-    {
-        FreeMemory(NewDevice);
-        /*HeapFree(GetProcessHeap(), 0, NewDevice);*/
-        TRACE_EXIT(FALSE);
-        return FALSE;
-    }
-
-    CopyWideString(NewDevice->DevicePath, DevicePath);
-    /*CopyMemory(NewDevice->DevicePath, DevicePath, DevicePathSize);*/
-
-    /* Set up function table */
-    InitSoundDeviceFunctionTable(NewDevice, FunctionTable);
-
-    /* Start or add to list */
-    if ( ! SoundDeviceLists[TypeIndex] )
-    {
-        TRACE_("Starting device list\n");
-        SoundDeviceLists[TypeIndex] = NewDevice;
-    }
-    else
-    {
-        PSOUND_DEVICE CurrentDevice = SoundDeviceLists[TypeIndex];
-
-        TRACE_("Adding to device list\n");
-
-        while ( CurrentDevice != NULL )
-        {
-            if ( ! CurrentDevice->Next )
-            {
-                CurrentDevice->Next = NewDevice;
-                break;
-            }
-
-            CurrentDevice = CurrentDevice->Next;
-        }
-    }
-
-    ++ SoundDeviceTotals[TypeIndex];
-    TRACE_("Now %d devices of type %d\n", (int) SoundDeviceTotals[TypeIndex], DeviceType);
-
-    TRACE_EXIT(TRUE);
-    return TRUE;
-}
-
-
-MMRESULT
-RemoveSoundDevice(
-    IN  PSOUND_DEVICE SoundDevice)
-{
-    ULONG TypeIndex;
-    BOOLEAN Done = FALSE;
-    PSOUND_DEVICE CurrentDevice = NULL;
-    PSOUND_DEVICE PreviousDevice = NULL;
-
-    /*TRACE_("Removing a sound device from list %d\n", DeviceType);*/
-    TRACE_ENTRY();
-
-    VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) );
-
-    TypeIndex = SoundDevice->DeviceType - MIN_SOUND_DEVICE_TYPE;
-
-    /* Clean up any instances */
-    if ( SoundDevice->FirstInstance != NULL )
-    {
-        TRACE_("About to destroy all instances of this sound device\n");
-        DestroyAllInstancesOfSoundDevice(SoundDevice);
-    }
-
-    if ( SoundDeviceLists[TypeIndex] == SoundDevice )
-    {
-        TRACE_("Removing head of list\n");
-        SoundDeviceLists[TypeIndex] = SoundDevice->Next;
-        Done = TRUE;
-    }
-    else
-    {
-        /* Remove from list */
-        CurrentDevice = SoundDeviceLists[TypeIndex];
-        PreviousDevice = NULL;
-
-        TRACE_("Removing from list\n");
-
-        while ( CurrentDevice )
-        {
-            if ( CurrentDevice == SoundDevice )
-            {
-                ASSERT(PreviousDevice != NULL);
-                PreviousDevice->Next = CurrentDevice->Next;
-                Done = TRUE;
-
-                break;
-            }
-
-            PreviousDevice = CurrentDevice;
-            CurrentDevice = CurrentDevice->Next;
-        }
-    }
-
-    ASSERT(Done);
-
-    TRACE_("Freeing path at %p\n", SoundDevice->DevicePath);
-    /* Free the memory associated with the device info */
-    FreeMemory(SoundDevice->DevicePath);
-
-    TRACE_("Freeing struct\n");
-    FreeMemory(SoundDevice);
-
-    TRACE_EXIT(MMSYSERR_NOERROR);
-    return MMSYSERR_NOERROR;;
-}
-
-
-MMRESULT
-RemoveSoundDevices(
-    IN  UCHAR DeviceType)
-{
-    MMRESULT Result;
-    PSOUND_DEVICE CurrentDevice;
-
-    TRACE_ENTRY();
-
-    TRACE_("Emptying device list for device type %d\n", DeviceType);
-
-    VALIDATE_MMSYS_PARAMETER( VALID_SOUND_DEVICE_TYPE(DeviceType) );
-
-    /*
-        Clean out the device list. This works by repeatedly removing the
-        first entry.
-    */
-    while ( (CurrentDevice =
-             SoundDeviceLists[DeviceType - MIN_SOUND_DEVICE_TYPE]) )
-    {
-        Result = RemoveSoundDevice(CurrentDevice);
-        ASSERT(Result == MMSYSERR_NOERROR);
-    }
-
-    /* Reset the list content and item count */
-    SoundDeviceLists[DeviceType - MIN_SOUND_DEVICE_TYPE] = NULL;
-    SoundDeviceTotals[DeviceType - MIN_SOUND_DEVICE_TYPE] = 0;
-
-    TRACE_EXIT(MMSYSERR_NOERROR);
-    return MMSYSERR_NOERROR;
-}
-
-
-VOID
-RemoveAllSoundDevices()
-{
-    ULONG i;
-    TRACE_ENTRY();
-
-    TRACE_("RemoveAllSoundDevices\n");
-
-    for ( i = MIN_SOUND_DEVICE_TYPE; i <= MAX_SOUND_DEVICE_TYPE; ++ i )
-    {
-        RemoveSoundDevices(i);
-    }
-
-    TRACE_EXIT(0);
-}
-
-BOOLEAN
-IsValidSoundDevice(
-    IN  PSOUND_DEVICE SoundDevice)
-{
-    UCHAR DeviceType;
-    PSOUND_DEVICE CurrentDevice;
-
-    /* TRACE_ENTRY(); */
-
-    if ( ! SoundDevice )
-    {
-        TRACE_EXIT(FALSE);
-        return FALSE;
-    }
-
-    for ( DeviceType = MIN_SOUND_DEVICE_TYPE;
-          DeviceType <= MAX_SOUND_DEVICE_TYPE;
-          ++DeviceType )
-    {
-        CurrentDevice = SoundDeviceLists[DEVICE_TYPE_TO_INDEX(DeviceType)];
-
-        while ( CurrentDevice )
-        {
-            if ( CurrentDevice == SoundDevice )
-            {
-                /* TRACE_EXIT(TRUE); */
-                return TRUE;
-            }
-
-            CurrentDevice = CurrentDevice->Next;
-        }
-    }
-
-    /* Not found in list */
-    TRACE_EXIT(FALSE);
-    return FALSE;
-}
-
-
-MMRESULT
-GetSoundDevice(
-    IN  UCHAR DeviceType,
-    IN  ULONG DeviceIndex,
-    OUT PSOUND_DEVICE* Device)
-{
-    ULONG Count = 0;
-    PSOUND_DEVICE CurrentDevice = NULL;
-
-    TRACE_ENTRY();
-
-    VALIDATE_MMSYS_PARAMETER( VALID_SOUND_DEVICE_TYPE(DeviceType) );
-    VALIDATE_MMSYS_PARAMETER( Device );
-
-    if ( DeviceIndex >= SoundDeviceTotals[DeviceType - MIN_SOUND_DEVICE_TYPE] )
-    {
-        TRACE_EXIT(MMSYSERR_BADDEVICEID);
-        return MMSYSERR_BADDEVICEID;
-    }
-
-    /*
-        We know by now that a device at the index should exist
-        so just loop around until we reach that index.
-    */
-
-    CurrentDevice = SoundDeviceLists[DeviceType - MIN_SOUND_DEVICE_TYPE];
-
-    for ( Count = 0; Count <= DeviceIndex; ++ Count )
-    {
-        *Device = CurrentDevice;
-        CurrentDevice = CurrentDevice->Next;
-    }
-
-    TRACE_EXIT(MMSYSERR_NOERROR);
-    return MMSYSERR_NOERROR;
-}
-
-
-MMRESULT
-GetSoundDevicePath(
-    IN  PSOUND_DEVICE SoundDevice,
-    OUT LPWSTR* DevicePath)
-{
-    TRACE_ENTRY();
-
-    VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) );
-    VALIDATE_MMSYS_PARAMETER( DevicePath );
-
-    MessageBox(0, SoundDevice->DevicePath, L"Foo", MB_TASKMODAL | MB_OK);
-    *DevicePath = SoundDevice->DevicePath;
-
-    TRACE_EXIT(MMSYSERR_NOERROR);
-    return MMSYSERR_NOERROR;
-}
-
-
-MMRESULT
-GetSoundDeviceType(
-    IN  PSOUND_DEVICE SoundDevice,
-    OUT PUCHAR DeviceType)
-{
-    TRACE_ENTRY();
-
-    VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) );
-    VALIDATE_MMSYS_PARAMETER( DeviceType );
-
-    *DeviceType = SoundDevice->DeviceType;
-
-    TRACE_EXIT(MMSYSERR_NOERROR);
-    return MMSYSERR_NOERROR;
-}
-
-MMRESULT
-GetSoundDeviceFunctionTable(
-    IN  PSOUND_DEVICE SoundDevice,
-    OUT PMMFUNCTION_TABLE* FunctionTable)
-{
-    TRACE_ENTRY();
-
-    VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) );
-    VALIDATE_MMSYS_PARAMETER( FunctionTable );
-
-    *FunctionTable = &SoundDevice->Functions;
-
-    TRACE_EXIT(MMSYSERR_NOERROR);
-    return MMSYSERR_NOERROR;
-}
-
-
-#include <ntddk.h>      /* How do I avoid this? */
-
-/* Should these go somewhere else? */
-
-MMRESULT
-DefaultInstanceConstructor(
-    IN  struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance)
-{
-    PSOUND_DEVICE SoundDevice;
-    UCHAR DeviceType;
-    DWORD AccessRights = GENERIC_READ;
-    MMRESULT Result;
-
-    TRACE_ENTRY();
-
-    ASSERT(SoundDeviceInstance != NULL);
-    GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
-    ASSERT(SoundDevice != NULL);
-
-    /* If this fails, we have an internal error somewhere */
-    Result = GetSoundDeviceType(SoundDevice, &DeviceType);
-    ASSERT(Result == MMSYSERR_NOERROR);
-    if ( Result != MMSYSERR_NOERROR )
-    {
-        Result = TranslateInternalMmResult(Result);
-        TRACE_EXIT(Result);
-        return Result;
-    }
-
-    if ( DeviceType == WAVE_OUT_DEVICE_TYPE )
-        AccessRights |= GENERIC_WRITE;
-
-    Result = OpenKernelSoundDevice(SoundDevice,
-                                   AccessRights,
-                                   &SoundDeviceInstance->Handle);
-
-    if ( Result != MMSYSERR_NOERROR )
-    {
-        Result = TranslateInternalMmResult(Result);
-        TRACE_EXIT(MMSYSERR_NOERROR);
-        return Result;
-    }
-
-    TRACE_EXIT(MMSYSERR_NOERROR);
-    return MMSYSERR_NOERROR;
-}
-
-
-VOID
-DefaultInstanceDestructor(
-    IN  struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance)
-{
-    PSOUND_DEVICE SoundDevice;
-    MMRESULT Result;
-
-    TRACE_ENTRY();
-
-    ASSERT(SoundDeviceInstance);
-    GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
-    ASSERT(SoundDevice);
-
-    Result = CloseKernelSoundDevice(SoundDevice);
-    ASSERT(Result == MMSYSERR_NOERROR);
-
-    TRACE_EXIT(0);
-}

Removed: branches/silverblade-audio/lib/drivers/sound/mmebuddy/instances.c
URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/sound/mmebuddy/instances.c?rev=34586&view=auto
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/instances.c [iso-8859-1] (original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/instances.c (removed)
@@ -1,333 +1,0 @@
-/*
- * PROJECT:     ReactOS Sound System "MME Buddy" Library
- * LICENSE:     GPL - See COPYING in the top level directory
- * FILE:        lib/sound/mmebuddy/instances.c
- *
- * PURPOSE:     Handles construction/destruction of sound device instances,
- *              along with tracking of existing instances.
- *
- * PROGRAMMERS: Andrew Greenwood (silverblade at reactos.org)
-*/
-
-#include <windows.h>
-#include <ntddsnd.h>
-
-#include <mmebuddy.h>
-
-/*
-    Init / New / Delete handlers
-*/
-
-VOID
-InitSoundDeviceInstance(
-    IN  PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
-{
-    /* Initialise */
-    SoundDeviceInstance->Next = NULL;
-    SoundDeviceInstance->Device = NULL;
-    /* TODO: WinMM callback entry */
-}
-
-PSOUND_DEVICE_INSTANCE
-AllocateSoundDeviceInstance()
-{
-    PSOUND_DEVICE_INSTANCE ptr;
-    ptr = AllocateMemoryFor(SOUND_DEVICE_INSTANCE);
-
-    if ( ! ptr )
-        return NULL;
-
-    InitSoundDeviceInstance(ptr);
-
-    return ptr;
-}
-
-VOID
-FreeSoundDeviceInstance(
-    IN  PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
-{
-    FreeMemory(SoundDeviceInstance);
-}
-
-
-/*
-    List management
-*/
-
-VOID
-ListSoundDeviceInstance(
-    IN  PSOUND_DEVICE SoundDevice,
-    IN  PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
-{
-    MMRESULT Result;
-    PSOUND_DEVICE_INSTANCE CurrentInstance = NULL;
-
-    TRACE_ENTRY();
-
-    ASSERT(SoundDevice != NULL);
-    ASSERT(SoundDeviceInstance != NULL);
-    ASSERT(SoundDeviceInstance->Device == NULL);
-
-    SoundDeviceInstance->Device = SoundDevice;
-
-    if ( IS_WAVE_DEVICE_TYPE(SoundDevice->DeviceType) )
-    {
-        Result = InitWaveStreamData(SoundDeviceInstance);
-        ASSERT(Result == MMSYSERR_NOERROR);
-    }
-    else if ( IS_MIDI_DEVICE_TYPE(SoundDevice->DeviceType) )
-    {
-        /* TODO ... */
-        ASSERT(FALSE);
-    }
-    else if ( IS_MIXER_DEVICE_TYPE(SoundDevice->DeviceType) )
-    {
-        /* TODO ... */
-        ASSERT(FALSE);
-    }
-    else if ( IS_AUX_DEVICE_TYPE(SoundDevice->DeviceType) )
-    {
-        /* TODO ... */
-        ASSERT(FALSE);
-    }
-    else
-    {
-        /* What kind of device do we have, then?!?! */
-        ASSERT(FALSE);
-    }
-
-    /* Search for an appropriate place in the list to put this instance */
-    if ( ! SoundDevice->FirstInstance )
-    {
-        /* This is going to be the first instance */
-        SoundDevice->FirstInstance = SoundDeviceInstance;
-    }
-    else
-    {
-        /* There is already one or more instances */
-        CurrentInstance = SoundDevice->FirstInstance;
-
-        while ( CurrentInstance )
-        {
-            if ( ! CurrentInstance->Next )
-            {
-                /* Add to the end and get outta here */
-                CurrentInstance->Next = SoundDeviceInstance;
-                break;
-            }
-
-            CurrentInstance = CurrentInstance->Next;
-        }
-    }
-
-    TRACE_EXIT(0);
-}
-
-VOID
-UnlistSoundDeviceInstance(
-    IN  PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
-{
-    PSOUND_DEVICE SoundDevice;
-    PSOUND_DEVICE_INSTANCE CurrentInstance;
-
-    TRACE_ENTRY();
-
-    ASSERT(SoundDeviceInstance != NULL);
-    ASSERT(SoundDeviceInstance->Device != NULL);
-
-    SoundDevice = SoundDeviceInstance->Device;
-
-    if ( SoundDevice->FirstInstance == SoundDeviceInstance )
-    {
-        /* Removing the first instance */
-        SoundDevice->FirstInstance = NULL;
-    }
-    else
-    {
-        /* Removing an instance beyond the first */
-        CurrentInstance = SoundDevice->FirstInstance;
-
-        /* If we hit the end of the list, evidently there's a bug */
-        while ( CurrentInstance->Next != SoundDeviceInstance )
-        {
-            CurrentInstance = CurrentInstance->Next;
-            ASSERT(CurrentInstance != NULL);
-        }
-
-        /* This is actually the one before the one we want to remove */
-        CurrentInstance->Next = SoundDeviceInstance->Next;
-    }
-
-    TRACE_EXIT(0);
-}
-
-
-/*
-    Public routines
-*/
-
-MMRESULT
-CreateSoundDeviceInstance(
-    IN  PSOUND_DEVICE SoundDevice,
-    OUT PSOUND_DEVICE_INSTANCE* SoundDeviceInstance)
-{
-    PSOUND_DEVICE_INSTANCE CreatedInstance = NULL;
-    MMRESULT Result;
-
-    TRACE_ENTRY();
-
-    TRACE_("Creating instance of PSOUND_DEVICE %p\n", SoundDevice);
-
-    VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) );
-    VALIDATE_MMSYS_PARAMETER( SoundDeviceInstance );
-
-    CreatedInstance = AllocateSoundDeviceInstance();
-
-    if ( ! CreatedInstance )
-    {
-        TRACE_EXIT(MMSYSERR_NOMEM);
-        return MMSYSERR_NOMEM;
-    }
-
-    /* Add the new instance to the device's instance list */
-    ListSoundDeviceInstance(SoundDevice, CreatedInstance);
-
-    /* Consult the custom construction function */
-    Result = SoundDevice->Functions.Constructor(CreatedInstance);
-    if ( Result != MMSYSERR_NOERROR )
-    {
-        ERR_("Custom ctor returned failure - unlisting");
-        UnlistSoundDeviceInstance(CreatedInstance);
-        TRACE_("Freeing");
-        FreeSoundDeviceInstance(CreatedInstance);
-        CreatedInstance = NULL;
-        //DestroySoundDeviceInstance(CreatedInstance);
-
-        Result = TranslateInternalMmResult(Result);
-    }
-
-    /* Fill the output parameter with this */
-    *SoundDeviceInstance = CreatedInstance;
-
-    TRACE_EXIT(Result);
-
-    return Result;
-}
-
-MMRESULT
-GetSoundDeviceFromInstance(
-    IN  PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
-    OUT PSOUND_DEVICE* SoundDevice)
-{
-    ASSERT(SoundDeviceInstance);
-    ASSERT(SoundDevice);
-
-    TRACE_ENTRY();
-
-    VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
-    VALIDATE_MMSYS_PARAMETER( SoundDevice );
-
-    *SoundDevice = SoundDeviceInstance->Device;
-
-    TRACE_EXIT(MMSYSERR_NOERROR);
-    return MMSYSERR_NOERROR;
-}
-
-MMRESULT
-DestroySoundDeviceInstance(
-    IN  PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
-{
-    PSOUND_DEVICE SoundDevice = NULL;
-
-    TRACE_ENTRY();
-
-    VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
-
-    SoundDevice = SoundDeviceInstance->Device;
-
-    /* TODO - Perform cleanup, stop playback etc. */
-
-    /* Call the custom destructor */
-    SoundDevice->Functions.Destructor(SoundDeviceInstance);
-
-    /* Remove the isntance from the device's instance list */
-    UnlistSoundDeviceInstance(SoundDeviceInstance);
-
-    /* Kill it! */
-    FreeSoundDeviceInstance(SoundDeviceInstance);
-    /*HeapFree(GetProcessHeap(), 0, Instance);*/
-
-    TRACE_EXIT(MMSYSERR_NOERROR);
-    return MMSYSERR_NOERROR;
-}
-
-MMRESULT
-DestroyAllInstancesOfSoundDevice(
-    IN  PSOUND_DEVICE SoundDevice)
-{
-    PSOUND_DEVICE_INSTANCE CurrentInstance = NULL;
-    MMRESULT Result;
-
-    TRACE_ENTRY();
-
-    VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) );
-
-    /* Just munch away at the first item repeatedly */
-    while ( (CurrentInstance = SoundDevice->FirstInstance) )
-    {
-        Result = DestroySoundDeviceInstance(CurrentInstance);
-        ASSERT(Result == MMSYSERR_NOERROR);
-    }
-
-    TRACE_EXIT(MMSYSERR_NOERROR);
-    return MMSYSERR_NOERROR;
-}
-
-BOOLEAN
-IsValidSoundDeviceInstance(
-    IN  PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
-{
-    /* TRACE_ENTRY(); */
-
-    if ( ! SoundDeviceInstance )
-    {
-        TRACE_EXIT(FALSE);
-        return FALSE;
-    }
-
-    /* Now what? */
-    return TRUE;
-
-    /* TRACE_EXIT(12345678); */
-
-   TRACE_EXIT(FALSE);
-    return ( FALSE );
-}
-
-MMRESULT
-GetSoundDeviceTypeFromInstance(
-    IN  PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
-    OUT PUCHAR DeviceType)
-{
-    MMRESULT Result;
-    PSOUND_DEVICE SoundDevice;
-
-    TRACE_ENTRY();
-
-    VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
-    VALIDATE_MMSYS_PARAMETER( DeviceType );
-
-    Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
-
-    if ( Result != MMSYSERR_NOERROR )
-    {
-        TRACE_EXIT(Result);
-        return Result;
-    }
-
-    Result = GetSoundDeviceType(SoundDevice, DeviceType);
-    Result = TranslateInternalMmResult(Result);
-
-    TRACE_EXIT(Result);
-    return Result;
-}

Removed: branches/silverblade-audio/lib/drivers/sound/mmebuddy/kernel.c
URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/sound/mmebuddy/kernel.c?rev=34586&view=auto
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/kernel.c [iso-8859-1] (original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/kernel.c (removed)
@@ -1,303 +1,0 @@
-/*
- * PROJECT:     ReactOS Sound System "MME Buddy" Library
- * LICENSE:     GPL - See COPYING in the top level directory
- * FILE:        lib/sound/mmebuddy/kernel.c
- *
- * PURPOSE:     Routines assisting with device I/O between user-mode and
- *              kernel-mode.
- *
- * PROGRAMMERS: Andrew Greenwood (silverblade at reactos.org)
-*/
-
-#include <windows.h>
-#include <mmsystem.h>
-#include <ntddsnd.h>
-
-#include <mmebuddy.h>
-
-
-MMRESULT
-OpenKernelSoundDeviceByName(
-    PWSTR DeviceName,
-    DWORD AccessRights,
-    PHANDLE Handle)
-{
-    DWORD OpenFlags = 0;
-
-    VALIDATE_MMSYS_PARAMETER( Handle );
-    VALIDATE_MMSYS_PARAMETER( DeviceName );
-
-    if ( AccessRights != GENERIC_READ )
-    {
-        OpenFlags = FILE_FLAG_OVERLAPPED;
-    }
-
-    /*TRACE_("Attempting to open '%ws'\n", DeviceName);*/
-
-    *Handle = CreateFile(DeviceName,
-                         AccessRights,
-                         FILE_SHARE_WRITE,
-                         NULL,
-                         OPEN_EXISTING,
-                         OpenFlags,
-                         NULL);
-
-    if ( *Handle == INVALID_HANDLE_VALUE )
-    {
-        ERR_("Failed to open\n");
-        return Win32ErrorToMmResult(GetLastError());
-    }
-
-    return MMSYSERR_NOERROR;
-}
-
-MMRESULT
-OpenKernelSoundDevice(
-    PSOUND_DEVICE SoundDevice,
-    DWORD AccessRights,
-    PHANDLE Handle)
-{
-    MMRESULT Result;
-
-    VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) );
-    VALIDATE_MMSYS_PARAMETER( Handle );
-
-    Result = OpenKernelSoundDeviceByName(SoundDevice->DevicePath,
-                                         AccessRights,
-                                         Handle);
-
-    Result = TranslateInternalMmResult(Result);
-    return Result;
-}
-
-MMRESULT
-CloseKernelSoundDevice(
-    HANDLE Handle)
-{
-    if ( Handle == INVALID_HANDLE_VALUE )
-        return MMSYSERR_INVALPARAM;
-
-    CloseHandle(Handle);
-
-    return MMSYSERR_NOERROR;
-}
-
-MMRESULT
-PerformDeviceIo(
-    IN  HANDLE Handle,
-    IN  DWORD IoControlCode,
-    IN  LPVOID InBuffer,
-    IN  DWORD InBufferSize,
-    OUT LPVOID OutBuffer,
-    IN  DWORD OutBufferSize,
-    OUT LPDWORD BytesReturned,
-    IN  LPOVERLAPPED Overlapped)
-{
-    BOOLEAN IoResult = FALSE;
-
-    VALIDATE_MMSYS_PARAMETER( Handle != INVALID_HANDLE_VALUE );
-
-    /*MessageBox(0, L"Doing IO", L"Info", MB_OK | MB_TASKMODAL);*/
-
-    TRACE_("IoCtl on handle %d - in %p (%d), out %p (%d)\n",
-            (int) Handle, InBuffer, (int) InBufferSize, OutBuffer,
-            (int) OutBufferSize);
-
-    IoResult = DeviceIoControl(
-        Handle,
-        IoControlCode,
-        InBuffer,
-        InBufferSize,
-        OutBuffer,
-        OutBufferSize,
-        BytesReturned,
-        Overlapped);
-
-
-    if ( ! IoResult )
-    {
-        TRACE_("IoCtl result %d\n", (int) GetLastError());
-        return Win32ErrorToMmResult(GetLastError());
-    }
-
-    return MMSYSERR_NOERROR;
-}
-
-MMRESULT
-RetrieveFromDeviceHandle(
-    IN  HANDLE Handle,
-    IN  DWORD IoControlCode,
-    OUT LPVOID OutBuffer,
-    IN  DWORD OutBufferSize,
-    OUT LPDWORD BytesReturned,
-    IN  LPOVERLAPPED Overlapped)
-{
-    return PerformDeviceIo(Handle,
-                           IoControlCode,
-                           NULL,
-                           0,
-                           OutBuffer,
-                           OutBufferSize,
-                           BytesReturned,
-                           Overlapped);
-}
-
-MMRESULT
-SendToDeviceHandle(
-    IN  HANDLE Handle,
-    IN  DWORD IoControlCode,
-    IN  LPVOID InBuffer,
-    IN  DWORD InBufferSize,
-    OUT LPDWORD BytesReturned,
-    IN  LPOVERLAPPED Overlapped)
-{
-    return PerformDeviceIo(Handle,
-                           IoControlCode,
-                           InBuffer,
-                           InBufferSize,
-                           NULL,
-                           0,
-                           BytesReturned,
-                           Overlapped);
-}
-
-MMRESULT
-PerformSoundDeviceIo(
-    IN  PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
-    IN  DWORD IoControlCode,
-    IN  LPVOID InBuffer,
-    IN  DWORD InBufferSize,
-    OUT LPVOID OutBuffer,
-    IN  DWORD OutBufferSize,
-    OUT LPDWORD BytesTransferred)
-{
-    /*
-        NOTE: This will always do overlapped I/O, which we wait for.
-    */
-
-    OVERLAPPED Overlapped;
-    BOOLEAN IoResult;
-    MMRESULT Result;
-    DWORD Transferred;
-
-    if ( ! IsValidSoundDeviceInstance(SoundDeviceInstance) )
-        return MMSYSERR_INVALPARAM;
-
-    if ( SoundDeviceInstance->Handle == INVALID_HANDLE_VALUE )
-        return MMSYSERR_ERROR;
-
-    ZeroMemory(&Overlapped, sizeof(OVERLAPPED));
-
-    /* This event is used for announcing the I/O operation completed */
-    Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
-
-    if ( Overlapped.hEvent == INVALID_HANDLE_VALUE )
-        return Win32ErrorToMmResult(GetLastError());
-
-    TRACE_("** Overlapped at %p\n", &Overlapped);
-
-    Result = PerformDeviceIo(SoundDeviceInstance->Handle,
-                             IoControlCode,
-                             InBuffer,
-                             InBufferSize,
-                             OutBuffer,
-                             OutBufferSize,
-                             NULL,
-                             &Overlapped);
-
-    if ( Result != MMSYSERR_NOERROR )
-    {
-        return Result;
-    }
-
-    /* Wait for I/O completion */
-    IoResult = GetOverlappedResult(SoundDeviceInstance->Handle,
-                                   &Overlapped,
-                                   &Transferred,
-                                   TRUE);
-
-    CloseHandle(Overlapped.hEvent);
-
-    if ( ! IoResult )
-    {
-        return Win32ErrorToMmResult(GetLastError());
-    }
-
-    if ( BytesTransferred )
-    {
-        *BytesTransferred = Transferred;
-    }
-
-    return Result;
-}
-
-MMRESULT
-RetrieveFromSoundDevice(
-    IN  PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
-    IN  DWORD IoControlCode,
-    OUT LPVOID OutBuffer,
-    IN  DWORD OutBufferSize,
-    OUT LPDWORD BytesReturned)
-{
-    return PerformSoundDeviceIo(SoundDeviceInstance,
-                                IoControlCode,
-                                NULL,
-                                0,
-                                OutBuffer,
-                                OutBufferSize,
-                                BytesReturned);
-}
-
-MMRESULT
-SendToSoundDevice(
-    IN  PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
-    IN  DWORD IoControlCode,
-    IN  LPVOID InBuffer,
-    IN  DWORD InBufferSize,
-    OUT LPDWORD BytesReturned)
-{
-    return PerformSoundDeviceIo(SoundDeviceInstance,
-                                IoControlCode,
-                                InBuffer,
-                                InBufferSize,
-                                NULL,
-                                0,
-                                BytesReturned);
-}
-
-
-/* TODO: move somewhere else */
-MMRESULT
-WriteSoundDeviceBuffer(
-    IN  PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
-    IN  LPVOID Buffer,
-    IN  DWORD BufferSize,
-    IN  LPOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine,
-    IN  LPOVERLAPPED Overlapped)
-{
-    VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
-    VALIDATE_MMSYS_PARAMETER( Buffer );
-    VALIDATE_MMSYS_PARAMETER( BufferSize > 0 );
-    
-    /*wsprintf(msg, L"Writing to handle %x", SoundDeviceInstance->Device->Handle);*/
-    /*SOUND_DEBUG(msg);*/
-
-    TRACE_("WriteFileEx(%p, %p, %d, %p, %p)\n", 
-           SoundDeviceInstance->Handle,
-           Buffer,
-           (int) BufferSize,
-           Overlapped,
-           CompletionRoutine);
-
-    if ( ! WriteFileEx(SoundDeviceInstance->Handle,
-                       Buffer,
-                       BufferSize,
-                       Overlapped,
-                       CompletionRoutine) )
-    {
-        ERR_("WriteFileEx -- Win32 Error %d", (int) GetLastError());
-        return Win32ErrorToMmResult(GetLastError());
-    }
-
-    return MMSYSERR_NOERROR;
-}

Removed: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmebuddy.rbuild
URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmebuddy.rbuild?rev=34586&view=auto
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmebuddy.rbuild [iso-8859-1] (original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmebuddy.rbuild (removed)
@@ -1,33 +1,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd">
-<module name="mmebuddy" type="staticlibrary" allowwarnings="false" unicode="yes">
-    <include base="ReactOS">include/reactos/libs/sound</include>
-    <file>kernel.c</file>
-    <file>nt4.c</file>
-    <file>devices.c</file>
-    <file>instances.c</file>
-    <file>capabilities.c</file>
-    <file>thread.c</file>
-    <file>utility.c</file>
-    <directory name="mme">
-        <file>DriverProc.c</file>
-        <file>callback.c</file>
-    </directory>
-    <directory name="wave">
-        <file>wodMessage.c</file>
-        <file>widMessage.c</file>
-        <file>format.c</file>
-        <file>streaming.c</file>
-        <file>streamcontrol.c</file>
-    </directory>
-    <directory name="midi">
-        <file>modMessage.c</file>
-        <file>midMessage.c</file>
-    </directory>
-    <directory name="mixer">
-        <file>mxdMessage.c</file>
-    </directory>
-    <directory name="auxiliary">
-        <file>auxMessage.c</file>
-    </directory>
-</module>

Removed: branches/silverblade-audio/lib/drivers/sound/mmebuddy/nt4.c
URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/sound/mmebuddy/nt4.c?rev=34586&view=auto
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/nt4.c [iso-8859-1] (original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/nt4.c (removed)
@@ -1,325 +1,0 @@
-/*
- * PROJECT:     ReactOS Sound System "MME Buddy" Library
- * LICENSE:     GPL - See COPYING in the top level directory
- * FILE:        lib/sound/mmebuddy/nt4.c
- *
- * PURPOSE:     Assists in locating Windows NT4 compatible sound devices,
- *              which mostly use the same device naming convention and/or
- *              store their created device names within their service key
- *              within the registry.
- *
- * PROGRAMMERS: Andrew Greenwood (silverblade at reactos.org)
-*/
-
-#include <windows.h>
-#include <mmsystem.h>
-#include <ntddsnd.h>
-
-#include <mmebuddy.h>
-
-/*
-    Open the parameters key of a sound driver.
-    NT4 only.
-*/
-MMRESULT
-OpenSoundDriverParametersRegKey(
-    IN  LPWSTR ServiceName,
-    OUT PHKEY KeyHandle)
-{
-    ULONG KeyLength;
-    PWCHAR ParametersKeyName;
-
-    VALIDATE_MMSYS_PARAMETER( ServiceName );
-    VALIDATE_MMSYS_PARAMETER( KeyHandle );
-
-    /* Work out how long the string will be */
-    KeyLength = wcslen(REG_SERVICES_KEY_NAME_U) + 1
-              + wcslen(ServiceName) + 1
-              + wcslen(REG_PARAMETERS_KEY_NAME_U);
-
-    /* Allocate memory for the string */
-    ParametersKeyName = AllocateWideString(KeyLength);
-
-    if ( ! ParametersKeyName )
-        return MMSYSERR_NOMEM;
-
-    /* Construct the registry path */
-    wsprintf(ParametersKeyName,
-             L"%s\\%s\\%s",
-             REG_SERVICES_KEY_NAME_U,
-             ServiceName,
-             REG_PARAMETERS_KEY_NAME_U);
-
-    MessageBox(0, ParametersKeyName, L"Parameters key is...", MB_OK | MB_TASKMODAL);
-
-    /* Perform the open */
-    if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE,
-                      ParametersKeyName,
-                      0,
-                      KEY_READ,
-                      KeyHandle) != ERROR_SUCCESS )
-    {
-        /* Couldn't open the key */
-        FreeMemory(ParametersKeyName);
-        return MMSYSERR_ERROR;
-    }
-
-    FreeMemory(ParametersKeyName);
-
-    return MMSYSERR_NOERROR;
-}
-
-/*
-    Open one of the Device sub-keys belonging to the sound driver.
-    NT4 only.
-*/
-MMRESULT
-OpenSoundDeviceRegKey(
-    IN  LPWSTR ServiceName,
-    IN  DWORD DeviceIndex,
-    OUT PHKEY KeyHandle)
-{
-    DWORD PathLength;
-    PWCHAR RegPath;
-
-    VALIDATE_MMSYS_PARAMETER( ServiceName );
-    VALIDATE_MMSYS_PARAMETER( KeyHandle );
-
-    /*
-        Work out the space required to hold the path:
-
-        HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
-            sndblst\
-                Parameters\
-                    Device123\
-    */
-    PathLength = wcslen(REG_SERVICES_KEY_NAME_U) + 1
-               + wcslen(ServiceName) + 1
-               + wcslen(REG_PARAMETERS_KEY_NAME_U) + 1
-               + wcslen(REG_DEVICE_KEY_NAME_U)
-               + GetDigitCount(DeviceIndex);
-
-    /* Allocate storage for the string */
-    RegPath = AllocateWideString(PathLength);
-
-    if ( ! RegPath )
-    {
-        return MMSYSERR_NOMEM;
-    }
-
-    /* Write the path */
-    wsprintf(RegPath,
-             L"%ls\\%ls\\%ls\\%ls%d",
-             REG_SERVICES_KEY_NAME_U,
-             ServiceName,
-             REG_PARAMETERS_KEY_NAME_U,
-             REG_DEVICE_KEY_NAME_U,
-             DeviceIndex);
-
-    MessageBox(0, RegPath, L"Opening registry path", MB_OK | MB_TASKMODAL);
-
-    /* Perform the open */
-    if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE,
-                      RegPath,
-                      0,
-                      KEY_READ,
-                      KeyHandle) != ERROR_SUCCESS )
-    {
-        /* Couldn't open the key */
-        FreeMemory(RegPath);
-        return MMSYSERR_ERROR;
-    }
-
-    FreeMemory(RegPath);
-
-    return MMSYSERR_NOERROR;
-}
-
-/*
-    This is the "nice" way to discover audio devices in NT4 - go into the
-    service registry key and enumerate the Parameters\Device*\Devices
-    values. The value names represent the device name, whereas the data
-    assigned to them identifies the type of device.
-*/
-MMRESULT
-EnumerateNt4ServiceSoundDevices(
-    IN  LPWSTR ServiceName,
-    IN  UCHAR DeviceType,
-    IN  SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc)
-{
-    HKEY Key;
-    DWORD KeyIndex = 0;
-
-    VALIDATE_MMSYS_PARAMETER( ServiceName );
-
-    /* Device type zero means "all" */
-    VALIDATE_MMSYS_PARAMETER( VALID_SOUND_DEVICE_TYPE(DeviceType) ||
-                              DeviceType == 0 );
-
-    MessageBox(0, ServiceName, L"Looking for devices", MB_OK | MB_TASKMODAL);
-
-    while ( OpenSoundDeviceRegKey(ServiceName, KeyIndex, &Key) == MMSYSERR_NOERROR )
-    {
-        HKEY DevicesKey;
-        DWORD ValueType = REG_NONE, ValueIndex = 0;
-        DWORD MaxNameLength = 0, ValueNameLength = 0;
-        PWSTR DevicePath = NULL, ValueName = NULL;
-        DWORD ValueDataLength = sizeof(DWORD);
-        DWORD ValueData;
-
-        if ( RegOpenKeyEx(Key,
-                          REG_DEVICES_KEY_NAME_U,
-                          0,
-                          KEY_READ,
-                          &DevicesKey) == ERROR_SUCCESS )
-        {
-            /* Find out how much memory is needed for the key name */
-            if ( RegQueryInfoKey(DevicesKey,
-                                 NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                                 &MaxNameLength,
-                                 NULL, NULL, NULL) != ERROR_SUCCESS )
-            {
-                RegCloseKey(DevicesKey);
-                RegCloseKey(Key);
-
-                return MMSYSERR_ERROR;
-            }
-
-            DevicePath = AllocateWideString(MaxNameLength +
-                                            strlen("\\\\.\\"));
-
-            /* Check that the memory allocation was successful */
-            if ( ! DevicePath )
-            {
-                /* There's no point in going further */
-                RegCloseKey(DevicesKey);
-                RegCloseKey(Key);
-
-                return MMSYSERR_NOMEM;
-            }
-
-            /* Insert the device path prefix */
-            wsprintf(DevicePath, L"\\\\.\\");
-
-            /* The offset of the string following this prefix */
-            ValueName = DevicePath + strlen("\\\\.\\");
-
-            /* Copy this so that it may be overwritten - include NULL */
-            ValueNameLength = MaxNameLength + sizeof(WCHAR);
-
-            while ( RegEnumValue(DevicesKey,
-                                 ValueIndex,
-                                 ValueName,
-                                 &ValueNameLength,
-                                 NULL,
-                                 &ValueType,
-                                 (LPBYTE) &ValueData,
-                                 &ValueDataLength) == ERROR_SUCCESS )
-            {
-                /* Device types are stored as DWORDs */
-                if ( ( ValueType == REG_DWORD ) &&
-                     ( ValueDataLength == sizeof(DWORD) ) )
-                {
-                    if ( ( DeviceType == 0 ) ||
-                         ( DeviceType == ValueData ) )
-                    {
-                        SoundDeviceDetectedProc(
-                            ValueData,
-                            DevicePath,
-                            INVALID_HANDLE_VALUE);
-                    }
-                }
-
-                /* Reset variables for the next iteration */
-                ValueNameLength = MaxNameLength + sizeof(WCHAR);
-                ZeroMemory(ValueName, (MaxNameLength+1)*sizeof(WCHAR));
-                /*ZeroWideString(ValueName);*/
-                ValueDataLength = sizeof(DWORD);
-                ValueData = 0;
-                ValueType = REG_NONE;
-
-                ++ ValueIndex;
-            }
-
-            FreeMemory(DevicePath);
-
-            RegCloseKey(DevicesKey);
-        }
-
-        ++ KeyIndex;
-
-        RegCloseKey(Key);
-    }
-
-    return MMSYSERR_NOERROR;
-}
-
-/*
-    Brute-force device detection, using a base device name (eg: \\.\WaveOut).
-
-    This will add the device number as a suffix to the end of the string and
-    attempt to open the device based on that name. On success, it will
-    increment the device number and repeat this process.
-
-    When it runs out of devices, it will give up.
-*/
-MMRESULT
-DetectNt4SoundDevices(
-    IN  UCHAR DeviceType,
-    IN  PWSTR BaseDeviceName,
-    IN  SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc)
-{
-    ULONG DeviceNameLength = 0;
-    PWSTR DeviceName = NULL;
-    ULONG Index = 0, Count = 0;
-    HANDLE DeviceHandle;
-    BOOLEAN DoSearch = TRUE;
-
-    TRACE_("Detecting NT4 style sound devices of type %d\n", DeviceType);
-
-    VALIDATE_MMSYS_PARAMETER( VALID_SOUND_DEVICE_TYPE(DeviceType) );
-
-    DeviceNameLength = wcslen(BaseDeviceName);
-    /* Consider the length of the number */
-    DeviceNameLength += GetDigitCount(Index);
-
-    DeviceName = AllocateWideString(DeviceNameLength);
-
-    if ( ! DeviceName )
-    {
-        return MMSYSERR_NOMEM;
-    }
-
-    while ( DoSearch )
-    {
-        /* Nothing like a nice clean device name */
-        ZeroWideString(DeviceName);
-        wsprintf(DeviceName, L"%ls%d", BaseDeviceName, Index);
-
-        if ( OpenKernelSoundDeviceByName(DeviceName,
-                                         GENERIC_READ,
-                                         &DeviceHandle) == MMSYSERR_NOERROR )
-        {
-            //DPRINT("Found device %d\n", Index);
-            MessageBox(0, DeviceName, L"Opened device", MB_OK | MB_TASKMODAL);
-
-            /* Notify the callback function */
-            if ( SoundDeviceDetectedProc(DeviceType, DeviceName, DeviceHandle) )
-            {
-                ++ Count;
-            }
-
-            CloseHandle(DeviceHandle);
-
-            ++ Index;
-        }
-        else
-        {
-            DoSearch = FALSE;
-        }
-    }
-
-    FreeMemory(DeviceName);
-
-    return MMSYSERR_NOERROR;
-}

Removed: branches/silverblade-audio/lib/drivers/sound/mmebuddy/thread.c
URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/sound/mmebuddy/thread.c?rev=34586&view=auto
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/thread.c [iso-8859-1] (original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/thread.c (removed)
@@ -1,395 +1,0 @@
-/*
- * PROJECT:     ReactOS Sound System "MME Buddy" Library
- * LICENSE:     GPL - See COPYING in the top level directory
- * FILE:        lib/sound/mmebuddy/thread.c
- *
- * PURPOSE:     Manages a thread to assist with the streaming of sound data.
- *
- * PROGRAMMERS: Andrew Greenwood (silverblade at reactos.org)
-*/
-
-#include <windows.h>
-#include <mmsystem.h>
-
-#include <mmebuddy.h>
-
-static BOOLEAN ThreadRunning = FALSE;
-static HANDLE SoundThread = INVALID_HANDLE_VALUE;
-static HANDLE ReadyEvent = INVALID_HANDLE_VALUE;
-static HANDLE RequestEvent = INVALID_HANDLE_VALUE;
-static HANDLE DoneEvent = INVALID_HANDLE_VALUE;
-
-static SOUND_THREAD_REQUEST CurrentRequest =
-{
-    NULL,
-    NULL,
-    NULL,
-    MMSYSERR_NOERROR
-};
-
-static SOUND_THREAD_COMPLETED_IO* CompletedIoListHead = NULL;
-static SOUND_THREAD_COMPLETED_IO* CompletedIoListTail = NULL;
-
-
-VOID
-CleanupThreadEvents();
-
-VOID CALLBACK
-CompleteSoundThreadIo(
-    IN  DWORD dwErrorCode,
-    IN  DWORD dwNumberOfBytesTransferred,
-    IN  LPOVERLAPPED lpOverlapped)
-{
-    PSOUND_THREAD_COMPLETED_IO CompletionData;
-    PSOUND_THREAD_OVERLAPPED SoundOverlapped;
-
-    TRACE_("** I/O has completed\n");
-    TRACE_("** Returned overlapped at %p\n", lpOverlapped);
-
-    SoundOverlapped = (PSOUND_THREAD_OVERLAPPED) lpOverlapped;
-    ASSERT(SoundOverlapped);
-
-    CompletionData = SoundOverlapped->CompletionData;
-    ASSERT(CompletionData);
-
-    CompletionData->BytesTransferred = dwNumberOfBytesTransferred;
-
-    /* Is this the first completion? */
-    if ( ! CompletedIoListHead )
-    {
-        TRACE_("First completion - making new head and tail\n");
-        /* This is the first completion */
-        ASSERT(! CompletedIoListTail);
-
-        CompletionData->Previous = NULL;
-        CompletionData->Next = NULL;
-
-        CompletedIoListHead = CompletionData;
-        CompletedIoListTail = CompletionData;
-    }
-    else
-    {
-        TRACE_("Not the first completion - making new tail\n");
-        ASSERT(CompletionData);
-        /* This is not the first completion */
-        CompletionData->Previous = CompletedIoListTail;
-        CompletionData->Next = NULL;
-
-        /* Completion data gets made the new tail */
-        ASSERT(CompletedIoListTail);
-        CompletedIoListTail->Next = CompletionData;
-        CompletedIoListTail = CompletionData;
-    }
-
-    /* We keep the completion data, but no longer need this: */
-    FreeMemory(SoundOverlapped);
-
-    TRACE_("** Leaving completion routine\n");
-}
-
-MMRESULT
-OverlappedSoundDeviceIo(
-    IN  PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
-    IN  PVOID Buffer,
-    IN  DWORD BufferSize,
-    IN  SOUND_THREAD_IO_COMPLETION_HANDLER IoCompletionHandler,
-    IN  PVOID CompletionParameter OPTIONAL)
-{
-    PSOUND_THREAD_OVERLAPPED Overlapped;
-
-    VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
-    VALIDATE_MMSYS_PARAMETER( Buffer );
-    VALIDATE_MMSYS_PARAMETER( BufferSize > 0 );
-    VALIDATE_MMSYS_PARAMETER( IoCompletionHandler );
-
-    /* Allocate memory for the overlapped I/O structure (auto-zeroed) */
-    Overlapped = AllocateMemoryFor(SOUND_THREAD_OVERLAPPED);
-
-    if ( ! Overlapped )
-        return MMSYSERR_NOMEM;
-
-    /* We also need memory for the completion data (auto-zeroed) */
-    Overlapped->CompletionData = AllocateMemoryFor(SOUND_THREAD_COMPLETED_IO);
-
-    if ( ! Overlapped->CompletionData )
-    {
-        FreeMemory(Overlapped);
-        return MMSYSERR_NOMEM;
-    }
-
-    /* Information to be passed to the completion routine */
-    Overlapped->CompletionData->SoundDeviceInstance = SoundDeviceInstance;
-    Overlapped->CompletionData->CompletionHandler = IoCompletionHandler;
-    Overlapped->CompletionData->Parameter = CompletionParameter;
-    Overlapped->CompletionData->BytesTransferred = 0;
-
-    TRACE_("Performing overlapped I/O\n");
-    return WriteSoundDeviceBuffer(SoundDeviceInstance,
-                                  Buffer,
-                                  BufferSize,
-                                  CompleteSoundThreadIo,
-                                  (LPOVERLAPPED) Overlapped);
-}
-
-MMRESULT
-ProcessThreadExitRequest(
-    IN  PSOUND_DEVICE_INSTANCE SoundDeviceInstance OPTIONAL,
-    IN  PVOID Parameter OPTIONAL)
-{
-    TRACE_("ProcessThreadExitRequest called\n");
-    ThreadRunning = FALSE;
-    return MMSYSERR_NOERROR;
-}
-
-DWORD WINAPI
-SoundThreadProc(
-    IN  LPVOID lpParameter OPTIONAL)
-{
-    ThreadRunning = TRUE;
-
-    /* We're ready to do work */
-    SetEvent(ReadyEvent);
-
-    TRACE_("SoundThreadProc entered\n");
-
-    while ( ThreadRunning )
-    {
-        DWORD WaitResult;
-
-        /* Wait for a request, or an I/O completion */
-        WaitResult = WaitForSingleObjectEx(RequestEvent, INFINITE, TRUE);
-        TRACE_("Came out of waiting\n");
-
-        if ( WaitResult == WAIT_OBJECT_0 )
-        {
-            /* Process the request */
-
-            TRACE_("Processing request\n");
-
-            ASSERT(CurrentRequest.RequestHandler);
-            if ( CurrentRequest.RequestHandler )
-            {
-                TRACE_("Calling function %p\n", CurrentRequest.RequestHandler);
-                CurrentRequest.ReturnValue = CurrentRequest.RequestHandler(
-                    CurrentRequest.SoundDeviceInstance,
-                    CurrentRequest.Parameter);
-            }
-            else
-            {
-                CurrentRequest.ReturnValue = MMSYSERR_ERROR;
-            }
-
-            /* Announce completion of the request */
-            SetEvent(DoneEvent);
-            /* Accept new requests */
-            SetEvent(ReadyEvent);
-        }
-        else if ( WaitResult == WAIT_IO_COMPLETION )
-        {
-            PSOUND_THREAD_COMPLETED_IO CurrentCompletion;
-
-            /* Process the I/O Completion */
-            TRACE_("Returned from I/O completion APC\n");
-
-            CurrentCompletion = CompletedIoListHead;
-            ASSERT(CurrentCompletion);
-
-            TRACE_("Beginning enumeration of completions\n");
-            while ( CurrentCompletion )
-            {
-                PSOUND_THREAD_COMPLETED_IO PreviousCompletion;
-
-                TRACE_("Calling completion handler\n");
-                /* Call the completion handler */
-                CurrentCompletion->CompletionHandler(
-                    CurrentCompletion->SoundDeviceInstance,
-                    CurrentCompletion->Parameter,
-                    CurrentCompletion->BytesTransferred);
-
-                TRACE_("Advancing to next completion\n");
-                /* Get the next completion but destroy the previous */
-                PreviousCompletion = CurrentCompletion;
-                CurrentCompletion = CurrentCompletion->Next;
-                /*CompletedIoListHead = CurrentCompletion;*/
-
-                FreeMemory(PreviousCompletion);
-            }
-
-            /* Nothing in the completion queue/list now */
-            CompletedIoListHead = NULL;
-            CompletedIoListTail = NULL;
-            TRACE_("Ended enumeration of completions\n");
-        }
-        else
-        {
-            /* Shouldn't happen! */
-            ASSERT(FALSE);
-        }
-    }
-
-    TRACE_("THREAD: Exiting\n");
-
-    ExitThread(0);
-    return 0;
-}
-
-MMRESULT
-CreateThreadEvents()
-{
-    ReadyEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
-
-    if ( ReadyEvent == INVALID_HANDLE_VALUE )
-    {
-        CleanupThreadEvents();
-        return MMSYSERR_NOMEM;
-    }
-
-    RequestEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
-
-    if ( RequestEvent == INVALID_HANDLE_VALUE )
-    {
-        CleanupThreadEvents();
-        return MMSYSERR_NOMEM;
-    }
-
-    DoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
-
-    if ( DoneEvent == INVALID_HANDLE_VALUE )
-    {
-        CleanupThreadEvents();
-        return MMSYSERR_NOMEM;
-    }
-
-    return MMSYSERR_NOERROR;
-}
-
-VOID
-CleanupThreadEvents()
-{
-    if ( ReadyEvent != INVALID_HANDLE_VALUE )
-    {
-        CloseHandle(ReadyEvent);
-        ReadyEvent = INVALID_HANDLE_VALUE;
-    }
-
-    if ( RequestEvent != INVALID_HANDLE_VALUE )
-    {
-        CloseHandle(RequestEvent);
-        RequestEvent = INVALID_HANDLE_VALUE;
-    }
-
-    if ( DoneEvent != INVALID_HANDLE_VALUE )
-    {
-        CloseHandle(DoneEvent);
-        DoneEvent = INVALID_HANDLE_VALUE;
-    }
-}
-
-MMRESULT
-StartSoundThread()
-{
-    MMRESULT Result;
-
-    /* Create the thread events */
-    Result = CreateThreadEvents();
-
-    if ( Result != MMSYSERR_NOERROR )
-    {
-        return Result;
-    }
-
-    /* Create the thread */
-    SoundThread = CreateThread(NULL,
-                               0,
-                               &SoundThreadProc,
-                               (LPVOID) NULL,   /* Parameter */
-                               CREATE_SUSPENDED,
-                               NULL);
-
-    if ( SoundThread == INVALID_HANDLE_VALUE )
-    {
-        CleanupThreadEvents();
-        return Win32ErrorToMmResult(GetLastError());
-    }
-
-    TRACE_("Starting sound thread\n");
-
-    /* We're all set to go, so let's start the thread up */
-    if ( ResumeThread(SoundThread) == -1 )
-    {
-        CloseHandle(SoundThread);
-        SoundThread = INVALID_HANDLE_VALUE;
-        CleanupThreadEvents();
-        ERR_("Error %d\n", (int) GetLastError());
-        return Win32ErrorToMmResult(GetLastError());
-    }
-
-    return MMSYSERR_NOERROR;
-}
-
-MMRESULT
-CallUsingSoundThread(
-    IN  PSOUND_DEVICE_INSTANCE SoundDeviceInstance OPTIONAL,
-    IN  SOUND_THREAD_REQUEST_HANDLER RequestHandler,
-    IN  PVOID Parameter OPTIONAL)
-{
-    VALIDATE_MMSYS_PARAMETER( RequestHandler );
-
-    ASSERT(SoundThread != INVALID_HANDLE_VALUE);
-    if ( SoundThread == INVALID_HANDLE_VALUE )
-    {
-        return MMSYSERR_ERROR;
-    }
-
-    TRACE_("Waiting for ready event\n");
-    /* Wait for the sound thread to be ready for a request */
-    WaitForSingleObject(ReadyEvent, INFINITE);
-
-    /* Fill in the information about the request */
-    CurrentRequest.SoundDeviceInstance = SoundDeviceInstance;
-    CurrentRequest.RequestHandler = RequestHandler;
-    CurrentRequest.Parameter = Parameter;
-    CurrentRequest.ReturnValue = MMSYSERR_ERROR;
-
-    /* Tell the sound thread there is a request waiting */
-    SetEvent(RequestEvent);
-
-    TRACE_("Waiting for done event\n");
-    /* Wait for our request to be dealt with */
-    WaitForSingleObject(DoneEvent, INFINITE);
-
-    return CurrentRequest.ReturnValue;
-}
-
-MMRESULT
-StopSoundThread()
-{
-    MMRESULT Result;
-
-    ASSERT(SoundThread != INVALID_HANDLE_VALUE);
-    if ( SoundThread == INVALID_HANDLE_VALUE )
-    {
-        return MMSYSERR_ERROR;
-    }
-
-    TRACE_("Calling thread shutdown function\n");
-
-    Result = CallUsingSoundThread(NULL,
-                                  ProcessThreadExitRequest,
-                                  NULL);
-
-    /* Our request didn't get processed? */
-    ASSERT(Result == MMSYSERR_NOERROR);
-    if ( Result != MMSYSERR_NOERROR )
-        return Result;
-
-    WaitForSingleObject(SoundThread, INFINITE);
-
-    TRACE_("Sound thread has quit\n");
-
-    /* Clean up */
-    CloseHandle(SoundThread);
-    CleanupThreadEvents();
-
-    return MMSYSERR_NOERROR;
-}

Removed: branches/silverblade-audio/lib/drivers/sound/mmebuddy/utility.c
URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/sound/mmebuddy/utility.c?rev=34586&view=auto
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/utility.c [iso-8859-1] (original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/utility.c (removed)
@@ -1,266 +1,0 @@
-/*
- * PROJECT:     ReactOS Sound System "MME Buddy" Library
- * LICENSE:     GPL - See COPYING in the top level directory
- * FILE:        lib/sound/mmebuddy/utility.c
- *
- * PURPOSE:     Provides utility functions used by the library.
- *
- * PROGRAMMERS: Andrew Greenwood (silverblade at reactos.org)
-*/
-
-#include <windows.h>
-#include <mmsystem.h>
-
-#include <mmebuddy.h>
-
-/*
-    Memory
-*/
-
-static HANDLE ProcessHeapHandle = INVALID_HANDLE_VALUE;
-static DWORD CurrentAllocations = 0;
-
-/* Makes the entry-points safe */
-static HANDLE BigMmLock = NULL;
-
-#if 0
-typedef struct _ALLOCATION
-{
-    DWORD Tag;
-    DWORD Size;
-} ALLOCATION;
-
-PVOID
-AllocateTaggedMemory(
-    IN  DWORD Tag,
-    IN  DWORD Size)
-{
-    PVOID Pointer = NULL;
-
-    Size += sizeof(ALLOCATION);
-
-    if ( ProcessHeapHandle == INVALID_HANDLE_VALUE )
-        ProcessHeapHandle = GetProcessHeap();
-
-    Pointer = HeapAlloc(ProcessHeapHandle, HEAP_ZERO_MEMORY, Size);
-
-    if ( ! Pointer )
-        return NULL;
-
-    /* Store the tag and size */
-    ((ALLOCATION*)Pointer)->Tag = Tag;
-    ((ALLOCATION*)Pointer)->Size = Size;
-
-    ++ CurrentAllocations;
-
-    return ((PCHAR)Pointer) + sizeof(ALLOCATION);
-}
-
-VOID
-FreeTaggedMemory(
-    IN  DWORD Tag,
-    IN  PVOID Pointer)
-{
-    ALLOCATION* AllocationInfo;
-
-    ASSERT(ProcessHeapHandle != INVALID_HANDLE_VALUE);
-    ASSERT(Pointer);
-
-    AllocationInfo = (ALLOCATION*)((PCHAR)Pointer - sizeof(ALLOCATION));
-
-    ASSERT( AllocationInfo->Tag == Tag );
-
-    ZeroMemory(AllocationInfo, AllocationInfo->Size + sizeof(ALLOCATION));
-    HeapFree(ProcessHeapHandle, 0, AllocationInfo);
-
-    -- CurrentAllocations;
-}
-#endif
-
-PVOID
-AllocateTaggedMemory(
-    IN  DWORD Tag,
-    IN  DWORD Size)
-{
-    PVOID Pointer = NULL;
-
-    if ( ProcessHeapHandle == INVALID_HANDLE_VALUE )
-        ProcessHeapHandle = GetProcessHeap();
-
-    Pointer = HeapAlloc(ProcessHeapHandle, HEAP_ZERO_MEMORY, Size);
-
-    if ( ! Pointer )
-        return NULL;
-
-    ++ CurrentAllocations;
-
-    return Pointer;
-}
-
-VOID
-FreeTaggedMemory(
-    IN  DWORD Tag,
-    IN  PVOID Pointer)
-{
-    ASSERT(ProcessHeapHandle != INVALID_HANDLE_VALUE);
-    ASSERT(Pointer);
-
-    HeapFree(ProcessHeapHandle, 0, Pointer);
-
-    -- CurrentAllocations;
-}
-
-DWORD
-GetMemoryAllocations()
-{
-    return CurrentAllocations;
-}
-
-
-/*
-    Other
-*/
-
-ULONG
-GetDigitCount(
-    ULONG Number)
-{
-    ULONG Value = Number;
-    ULONG Digits = 1;
-
-    while ( Value > 9 )
-    {
-        Value /= 10;
-        ++ Digits;
-    }
-
-    return Digits;
-}
-
-
-
-/*
-    Result codes
-*/
-
-MMRESULT
-Win32ErrorToMmResult(UINT error_code)
-{
-    switch ( error_code )
-    {
-        case NO_ERROR :
-        case ERROR_IO_PENDING :
-            return MMSYSERR_NOERROR;
-
-        case ERROR_BUSY :
-            return MMSYSERR_ALLOCATED;
-
-        case ERROR_NOT_SUPPORTED :
-        case ERROR_INVALID_FUNCTION :
-            return MMSYSERR_NOTSUPPORTED;
-
-        case ERROR_NOT_ENOUGH_MEMORY :
-            return MMSYSERR_NOMEM;
-
-        case ERROR_ACCESS_DENIED :
-            return MMSYSERR_BADDEVICEID;
-
-        case ERROR_INSUFFICIENT_BUFFER :
-            return MMSYSERR_INVALPARAM;
-    };
-
-    /* If all else fails, it's just a plain old error */
-
-    return MMSYSERR_ERROR;
-}
-
-/*
-    If a function invokes another function, this aids in translating the result
-    code so that it is applicable in the context of the original caller. For
-    example, specifying that an invalid parameter was passed probably does not
-    make much sense if the parameter wasn't passed by the original caller!
-
-    However, things like MMSYSERR_NOMEM make sense to return to the caller.
-
-    This could potentially highlight internal logic problems.
-*/
-MMRESULT
-TranslateInternalMmResult(MMRESULT Result)
-{
-    switch ( Result )
-    {
-        case MMSYSERR_INVALPARAM :
-        case MMSYSERR_INVALFLAG :
-        {
-            ERR_("MMRESULT from an internal routine failed with error %d\n",
-                 (int) Result);
-
-            return MMSYSERR_ERROR;
-        }
-    }
-
-    return Result;
-}
-
-
-
-/*
-    Entrypoint mutex management
-*/
-
-MMRESULT
-InitEntrypointMutex()
-{
-    BigMmLock = CreateMutex(NULL, FALSE, NULL);
-
-    if ( BigMmLock == NULL )
-    {
-        return Win32ErrorToMmResult(GetLastError());
-    }
-
-    return MMSYSERR_NOERROR;
-}
-
-VOID
-CleanupEntrypointMutex()
-{
-    if ( BigMmLock )
-    {
-        CloseHandle(BigMmLock);
-    }
-}
-
-VOID
-AcquireEntrypointMutex()
-{
-    ASSERT(BigMmLock);
-    WaitForSingleObject(BigMmLock, INFINITE);
-}
-
-VOID
-ReleaseEntrypointMutex()
-{
-    ASSERT(BigMmLock);
-    ReleaseMutex(BigMmLock);
-}
-
-
-/*
-    MME Buddy init/cleanup
-    NOTE: We don't do thread start/stop here...
-*/
-
-BOOLEAN
-InitMmeBuddyLib()
-{
-    if ( InitEntrypointMutex() != MMSYSERR_NOERROR )
-        return FALSE;
-
-    return TRUE;
-}
-
-VOID
-CleanupMmeBuddyLib()
-{
-    ReleaseEntrypointMutex();
-}



More information about the Ros-diffs mailing list