+++ /dev/null
-#include "stdafx.h"\r
-/*\r
-* Copyright (c) 2007-2010 SlimDX Group\r
-* \r
-* Permission is hereby granted, free of charge, to any person obtaining a copy\r
-* of this software and associated documentation files (the "Software"), to deal\r
-* in the Software without restriction, including without limitation the rights\r
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
-* copies of the Software, and to permit persons to whom the Software is\r
-* furnished to do so, subject to the following conditions:\r
-* \r
-* The above copyright notice and this permission notice shall be included in\r
-* all copies or substantial portions of the Software.\r
-* \r
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
-* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
-* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
-* THE SOFTWARE.\r
-*/\r
-#include <windows.h>\r
-#include <dsound.h>\r
-\r
-#include "../stack_array.h"\r
-#include "../ComObject.h"\r
-#include "../Utilities.h"\r
-\r
-#include "DirectSoundException.h"\r
-\r
-#include "SecondarySoundBuffer.h"\r
-\r
-using namespace System;\r
-using namespace System::Reflection;\r
-\r
-namespace SlimDX\r
-{\r
-namespace DirectSound\r
-{\r
- SecondarySoundBuffer::SecondarySoundBuffer( DirectSound^ dsound, SoundBufferDescription description )\r
- {\r
- IDirectSoundBuffer* buffer;\r
- DSBUFFERDESC nativeDesc = description.ToUnmanaged();\r
- \r
- HRESULT hr = dsound->InternalPointer->CreateSoundBuffer( &nativeDesc, &buffer, NULL );\r
-\r
- delete[] nativeDesc.lpwfxFormat;\r
-\r
- if( RECORD_DSOUND( hr ).IsFailure )\r
- throw gcnew DirectSoundException( Result::Last );\r
-\r
- IDirectSoundBuffer8* result;\r
- hr = buffer->QueryInterface( IID_IDirectSoundBuffer8, reinterpret_cast<void**>( &result ) );\r
- \r
- buffer->Release();\r
-\r
- if( RECORD_DSOUND( hr ).IsFailure )\r
- throw gcnew DirectSoundException( Result::Last );\r
-\r
- Construct( result );\r
- }\r
-\r
- array<SoundEffectResult>^ SecondarySoundBuffer::SetEffects( array<Guid>^ effects )\r
- {\r
- DWORD count = effects->Length;\r
- LPDWORD dwResults = NULL;\r
- LPDSEFFECTDESC dsEffects = NULL;\r
-\r
- stack_array<DWORD> outputs = stackalloc( DWORD, count );\r
- stack_array<DSEFFECTDESC> inputs = stackalloc( DSEFFECTDESC, count );\r
-\r
- if( effects != nullptr && count > 0 )\r
- {\r
- for( unsigned int i = 0; i < count; i++ )\r
- {\r
- DSEFFECTDESC desc;\r
- ZeroMemory( &desc, sizeof( DSEFFECTDESC ) );\r
- desc.dwSize = sizeof( DSEFFECTDESC );\r
- desc.guidDSFXClass = Utilities::ConvertManagedGuid( effects[i] );\r
-\r
- inputs[i] = desc;\r
- }\r
-\r
- dwResults = &outputs[0];\r
- dsEffects = &inputs[0];\r
- }\r
-\r
- HRESULT hr = InternalPointer->SetFX( count, dsEffects, dwResults );\r
- if( RECORD_DSOUND( hr ).IsFailure || count == 0 )\r
- return nullptr;\r
-\r
- array<SoundEffectResult>^ results = gcnew array<SoundEffectResult>( count );\r
-\r
- for( unsigned int i = 0; i < count; i++ )\r
- results[i] = static_cast<SoundEffectResult>( outputs[i] );\r
-\r
- return results;\r
- }\r
-\r
- generic<typename T>\r
- T SecondarySoundBuffer::GetEffect( int index )\r
- {\r
- GUID guid = Utilities::GetNativeGuidForType( T::typeid );\r
- void *resultPointer;\r
-\r
- HRESULT hr = InternalPointer->GetObjectInPath( GUID_All_Objects, index, guid, &resultPointer );\r
- if( RECORD_DSOUND( hr ).IsFailure )\r
- return T();\r
-\r
- MethodInfo^ method = T::typeid->GetMethod( "FromPointer", BindingFlags::Public | BindingFlags::Static );\r
- return safe_cast<T>( method->Invoke( nullptr, gcnew array<Object^> { IntPtr( resultPointer ) } ) );\r
- }\r
-}\r
-}
\ No newline at end of file