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

dsound.c
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:       See COPYING in the top level directory
00003  * PROJECT:         ReactOS Configuration of network devices
00004  * FILE:            dll/directx/dsound_new/dsound.c
00005  * PURPOSE:         Handles DSound initialization
00006  *
00007  * PROGRAMMERS:     Johannes Anderwald (janderwald@reactos.org)
00008  */
00009 
00010 #include "precomp.h"
00011 
00012 HINSTANCE dsound_hInstance;
00013 LPFILTERINFO RootInfo = NULL;
00014 
00015 static INTERFACE_TABLE InterfaceTable[] =
00016 {
00017     {
00018         &CLSID_DirectSoundPrivate,
00019         NewKsPropertySet
00020     },
00021     {
00022         &CLSID_DirectSoundCapture,
00023         NewDirectSoundCapture
00024     },
00025     {
00026         &CLSID_DirectSoundCapture8,
00027         NewDirectSoundCapture
00028     },
00029     {
00030         &CLSID_DirectSound,
00031         NewDirectSound
00032     },
00033     {
00034         &CLSID_DirectSound8,
00035         NewDirectSound
00036     },
00037     {
00038         NULL,
00039         NULL
00040     }
00041 };
00042 
00043 
00044 HRESULT
00045 WINAPI
00046 DllCanUnloadNow()
00047 {
00048     return S_FALSE;
00049 }
00050 
00051 HRESULT
00052 WINAPI
00053 GetDeviceID(LPCGUID pGuidSrc, LPGUID pGuidDest)
00054 {
00055     ULONG DeviceID = ULONG_MAX, Flags;
00056     MMRESULT Result;
00057     LPFILTERINFO Filter;
00058 
00059     if (!pGuidSrc || !pGuidDest)
00060     {
00061         /* invalid param */
00062         return DSERR_INVALIDPARAM;
00063     }
00064 
00065     /* sanity check */
00066     ASSERT(!IsEqualGUID(pGuidSrc, &GUID_NULL));
00067 
00068     if (IsEqualGUID(&DSDEVID_DefaultPlayback, pGuidSrc) ||
00069         IsEqualGUID(&DSDEVID_DefaultVoicePlayback, pGuidSrc))
00070     {
00071         Result = waveOutMessage(UlongToHandle(WAVE_MAPPER), DRVM_MAPPER_PREFERRED_GET, (DWORD_PTR)&DeviceID, (DWORD_PTR)&Flags);
00072         if (Result != MMSYSERR_NOERROR || DeviceID == ULONG_MAX)
00073         {
00074             /* hack */
00075             DPRINT1("Failed to get DRVM_MAPPER_PREFERRED_GET, using device 0\n");
00076             DeviceID = 0;
00077         }
00078 
00079         if (!FindDeviceByMappedId(DeviceID, &Filter, TRUE))
00080         {
00081             /* device not found */
00082             return DSERR_INVALIDPARAM;
00083         }
00084 
00085         /* copy device guid */
00086         RtlMoveMemory(pGuidDest, &Filter->DeviceGuid[1], sizeof(GUID));
00087         return DS_OK;
00088     }
00089     else if (IsEqualGUID(&DSDEVID_DefaultCapture, pGuidSrc) ||
00090              IsEqualGUID(&DSDEVID_DefaultVoiceCapture, pGuidSrc))
00091     {
00092         Result = waveInMessage(UlongToHandle(WAVE_MAPPER), DRVM_MAPPER_PREFERRED_GET, (DWORD_PTR)&DeviceID, (DWORD_PTR)&Flags);
00093         if (Result != MMSYSERR_NOERROR || DeviceID == ULONG_MAX)
00094         {
00095             /* hack */
00096             DPRINT1("Failed to get DRVM_MAPPER_PREFERRED_GET, for record using device 0\n");
00097             DeviceID = 0;
00098         }
00099 
00100         if (!FindDeviceByMappedId(DeviceID, &Filter, FALSE))
00101         {
00102             /* device not found */
00103             return DSERR_INVALIDPARAM;
00104         }
00105 
00106         /* copy device guid */
00107         RtlMoveMemory(pGuidDest, &Filter->DeviceGuid[0], sizeof(GUID));
00108         return DS_OK;
00109     }
00110 
00111     if (!FindDeviceByGuid(pGuidSrc, &Filter))
00112     {
00113         /* unknown guid */
00114         return DSERR_INVALIDPARAM;
00115     }
00116 
00117     /* done */
00118     return DS_OK;
00119 }
00120 
00121 
00122 HRESULT
00123 WINAPI
00124 DllGetClassObject(
00125   REFCLSID rclsid,
00126   REFIID riid,
00127   LPVOID* ppv)
00128 {
00129     LPOLESTR pStr, pStr2;
00130     UINT i;
00131     HRESULT hres = E_OUTOFMEMORY;
00132     IClassFactory * pcf = NULL; 
00133 
00134     if (!ppv)
00135         return E_INVALIDARG;
00136 
00137     *ppv = NULL;
00138 
00139     for (i = 0; InterfaceTable[i].riid; i++) 
00140     {
00141         if (IsEqualIID(InterfaceTable[i].riid, rclsid)) 
00142         {
00143             pcf = IClassFactory_fnConstructor(InterfaceTable[i].lpfnCI, NULL, NULL);
00144             break;
00145         }
00146     }
00147 
00148     if (!pcf) 
00149     {
00150         StringFromIID(rclsid, &pStr);
00151         StringFromIID(riid, &pStr2);
00152         DPRINT("No Class Available for %ws IID %ws\n", pStr, pStr2);
00153         CoTaskMemFree(pStr);
00154         CoTaskMemFree(pStr2);
00155         //ASSERT(0);
00156         return CLASS_E_CLASSNOTAVAILABLE;
00157     }
00158 
00159     hres = IClassFactory_QueryInterface(pcf, riid, ppv);
00160     IClassFactory_Release(pcf);
00161 
00162     return hres;
00163 }
00164 
00165 
00166 
00167 BOOL
00168 WINAPI
00169 DllMain(
00170     HINSTANCE hInstDLL,
00171     DWORD fdwReason,
00172     LPVOID lpvReserved)
00173 {
00174     switch (fdwReason)
00175     {
00176         case DLL_PROCESS_ATTACH:
00177             dsound_hInstance = hInstDLL;
00178 #if 1
00179             DPRINT("NumDevs %u\n", waveOutGetNumDevs());
00180             if (EnumAudioDeviceInterfaces(&RootInfo) != S_OK)
00181             {
00182                 DPRINT("EnumAudioDeviceInterfaces failed\n");
00183                 RootInfo = NULL;
00184             }
00185 DPRINT1("EnumAudioDeviceInterfaces %p %u\n", RootInfo, waveOutGetNumDevs());
00186 #endif
00187             DisableThreadLibraryCalls(dsound_hInstance);
00188             break;
00189     default:
00190         break;
00191     }
00192 
00193     return TRUE;
00194 }
00195 

Generated on Thu May 24 2012 04:21:50 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.