OSDN Git Service

Merge branch 'feature/#36529_SlimDXからSharpDXへの移行' into develop
[dtxmania/dtxmania.git] / SlimDXc_Jun2010(VC++2008) / source / xaudio2 / SourceVoice.cpp
diff --git a/SlimDXc_Jun2010(VC++2008)/source/xaudio2/SourceVoice.cpp b/SlimDXc_Jun2010(VC++2008)/source/xaudio2/SourceVoice.cpp
deleted file mode 100644 (file)
index 96dadf4..0000000
+++ /dev/null
@@ -1,267 +0,0 @@
-#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
-\r
-#include <xaudio2.h>\r
-#include <vcclr.h>\r
-\r
-#include "../VersionConfig.h"\r
-#include "../ComObject.h"\r
-#include "../DataStream.h"\r
-#include "../multimedia/WaveFormat.h"\r
-#include "../multimedia/WaveFormatExtensible.h"\r
-\r
-#include "XAudio2Exception.h"\r
-\r
-#include "XAudio2.h"\r
-#include "SourceVoice.h"\r
-\r
-using namespace System;\r
-using namespace SlimDX::Multimedia;\r
-\r
-namespace SlimDX\r
-{\r
-namespace XAudio2\r
-{\r
-       SourceVoice::SourceVoice( XAudio2^ device, WaveFormat^ sourceFormat, VoiceFlags flags, float maximumFrequencyRatio )\r
-       {\r
-               IXAudio2SourceVoice *pointer;\r
-               auto_array<WAVEFORMATEX> format = WaveFormat::ToUnmanaged( sourceFormat );\r
-\r
-               // Manual Allocation: cleaned up in the destructor / finalizer\r
-               callback = new VoiceCallbackShim( this );\r
-\r
-               HRESULT hr = device->InternalPointer->CreateSourceVoice( &pointer, format.get(), static_cast<UINT32>( flags ), maximumFrequencyRatio, callback );\r
-\r
-               if( RECORD_XAUDIO2( hr ).IsFailure )\r
-                       throw gcnew XAudio2Exception( Result::Last );\r
-\r
-               InternalPointer = pointer;\r
-       }\r
-\r
-       SourceVoice::SourceVoice( XAudio2^ device, WaveFormat^ sourceFormat, VoiceFlags flags )\r
-       {\r
-               IXAudio2SourceVoice *pointer;\r
-               auto_array<WAVEFORMATEX> format = WaveFormat::ToUnmanaged( sourceFormat );\r
-\r
-               // Manual Allocation: cleaned up in the destructor / finalizer\r
-               callback = new VoiceCallbackShim( this );\r
-\r
-               HRESULT hr = device->InternalPointer->CreateSourceVoice( &pointer, format.get(), static_cast<UINT32>( flags ), XAUDIO2_DEFAULT_FREQ_RATIO, callback );\r
-\r
-               if( RECORD_XAUDIO2( hr ).IsFailure )\r
-                       throw gcnew XAudio2Exception( Result::Last );\r
-\r
-               InternalPointer = pointer;\r
-       }\r
-\r
-       SourceVoice::SourceVoice( XAudio2^ device, WaveFormat^ sourceFormat )\r
-       {\r
-               IXAudio2SourceVoice *pointer;\r
-               auto_array<WAVEFORMATEX> format = WaveFormat::ToUnmanaged( sourceFormat );\r
-\r
-               // Manual Allocation: cleaned up in the destructor / finalizer\r
-               callback = new VoiceCallbackShim( this );\r
-\r
-               HRESULT hr = device->InternalPointer->CreateSourceVoice( &pointer, format.get(), 0, XAUDIO2_DEFAULT_FREQ_RATIO, callback );\r
-\r
-               if( RECORD_XAUDIO2( hr ).IsFailure )\r
-                       throw gcnew XAudio2Exception( Result::Last );\r
-\r
-               InternalPointer = pointer;\r
-       }\r
-\r
-       SourceVoice::~SourceVoice()\r
-       {\r
-               if( InternalPointer != NULL )\r
-                       InternalPointer->DestroyVoice();\r
-               InternalPointer = NULL;\r
-\r
-               if( callback != NULL )\r
-                       delete callback;\r
-               callback = NULL;\r
-       }\r
-\r
-       void SourceVoice::OnBufferEnd( ContextEventArgs^ e )\r
-       {\r
-               if( &SourceVoice::BufferEnd != nullptr )\r
-                       BufferEnd( this, e );\r
-       }\r
-\r
-       void SourceVoice::OnBufferStart( ContextEventArgs^ e )\r
-       {\r
-               if( &SourceVoice::BufferStart != nullptr )\r
-                       BufferStart( this, e );\r
-       }\r
-\r
-       void SourceVoice::OnLoopEnd( ContextEventArgs^ e )\r
-       {\r
-               if( &SourceVoice::LoopEnd != nullptr )\r
-                       LoopEnd( this, e );\r
-       }\r
-\r
-       void SourceVoice::OnStreamEnd( EventArgs^ e )\r
-       {\r
-               if( &SourceVoice::StreamEnd != nullptr )\r
-                       StreamEnd( this, e );\r
-       }\r
-\r
-       void SourceVoice::OnVoiceError( ErrorEventArgs^ e )\r
-       {\r
-               if( &SourceVoice::VoiceError != nullptr )\r
-                       VoiceError( this, e );\r
-       }\r
-\r
-       void SourceVoice::OnVoiceProcessingPassEnd( EventArgs^ e )\r
-       {\r
-               if( &SourceVoice::VoiceProcessingPassEnd != nullptr )\r
-                       VoiceProcessingPassEnd( this, e );\r
-       }\r
-\r
-       void SourceVoice::OnVoiceProcessingPassStart( int bytesRequired )\r
-       {\r
-               if( &SourceVoice::VoiceProcessingPassStart != nullptr )\r
-                       VoiceProcessingPassStart( this, gcnew StartProcessingEventArgs( bytesRequired )  );\r
-       }\r
-\r
-       Result SourceVoice::Discontinuity()\r
-       {\r
-               HRESULT hr = SourcePointer->Discontinuity();\r
-               return RECORD_XAUDIO2( hr );\r
-       }\r
-\r
-       Result SourceVoice::FlushSourceBuffers()\r
-       {\r
-               HRESULT hr = SourcePointer->FlushSourceBuffers();\r
-               return RECORD_XAUDIO2( hr );\r
-       }\r
-\r
-       Result SourceVoice::ExitLoop()\r
-       {\r
-               HRESULT hr = SourcePointer->ExitLoop();\r
-               return RECORD_XAUDIO2( hr );\r
-       }\r
-\r
-       Result SourceVoice::ExitLoop( int operationSet )\r
-       {\r
-               HRESULT hr = SourcePointer->ExitLoop( operationSet );\r
-               return RECORD_XAUDIO2( hr );\r
-       }\r
-\r
-       Result SourceVoice::Start()\r
-       {\r
-               HRESULT hr = SourcePointer->Start( 0 );\r
-               return RECORD_XAUDIO2( hr );\r
-       }\r
-\r
-       Result SourceVoice::Start( PlayFlags flags )\r
-       {\r
-               HRESULT hr = SourcePointer->Start( static_cast<UINT32>( flags ) );\r
-               return RECORD_XAUDIO2( hr );\r
-       }\r
-\r
-       Result SourceVoice::Start( PlayFlags flags, int operationSet )\r
-       {\r
-               HRESULT hr = SourcePointer->Start( static_cast<UINT32>( flags ), operationSet );\r
-               return RECORD_XAUDIO2( hr );\r
-       }\r
-\r
-       Result SourceVoice::Stop()\r
-       {\r
-               HRESULT hr = SourcePointer->Stop( 0 );\r
-               return RECORD_XAUDIO2( hr );\r
-       }\r
-\r
-       Result SourceVoice::Stop( PlayFlags flags )\r
-       {\r
-               HRESULT hr = SourcePointer->Stop( static_cast<UINT32>( flags ) );\r
-               return RECORD_XAUDIO2( hr );\r
-       }\r
-\r
-       Result SourceVoice::Stop( PlayFlags flags, int operationSet )\r
-       {\r
-               HRESULT hr = SourcePointer->Stop( static_cast<UINT32>( flags ), operationSet );\r
-               return RECORD_XAUDIO2( hr );\r
-       }\r
-\r
-       Result SourceVoice::SubmitSourceBuffer( AudioBuffer^ buffer )\r
-       {\r
-               XAUDIO2_BUFFER input = buffer->ToUnmanaged();\r
-\r
-               HRESULT hr = SourcePointer->SubmitSourceBuffer( &input );\r
-               return RECORD_XAUDIO2( hr );\r
-       }\r
-\r
-       Result SourceVoice::SubmitSourceBuffer( AudioBuffer^ buffer, array<int>^ decodedPacketCumulativeBytes )\r
-       {\r
-               XAUDIO2_BUFFER input = buffer->ToUnmanaged();\r
-               pin_ptr<int> pinnedData = &decodedPacketCumulativeBytes[0];\r
-\r
-               XAUDIO2_BUFFER_WMA wma;\r
-               wma.PacketCount = decodedPacketCumulativeBytes->Length;\r
-#if SLIMDX_XAUDIO2_VERSION < 23\r
-               wma.pDecodedPacketCumulativeBytes = reinterpret_cast<const UINT32*>( pinnedData );\r
-#else\r
-               wma.pDecodedPacketCumulativeBytes = reinterpret_cast<UINT32*>( pinnedData );\r
-#endif\r
-\r
-               HRESULT hr = SourcePointer->SubmitSourceBuffer( &input, &wma );\r
-               return RECORD_XAUDIO2( hr );\r
-       }\r
-\r
-#if SLIMDX_XAUDIO2_VERSION >= 24\r
-       Result SourceVoice::SetSourceSampleRate( int sampleRate ) \r
-       {\r
-               HRESULT hr = SourcePointer->SetSourceSampleRate( sampleRate );\r
-               return RECORD_XAUDIO2( hr );\r
-       }\r
-#endif\r
-\r
-       VoiceState SourceVoice::State::get()\r
-       {\r
-               XAUDIO2_VOICE_STATE state;\r
-\r
-               SourcePointer->GetState( &state );\r
-\r
-               VoiceState result;\r
-               result.Context = IntPtr( state.pCurrentBufferContext );\r
-               result.BuffersQueued = state.BuffersQueued;\r
-               result.SamplesPlayed = static_cast<Int64>( state.SamplesPlayed );\r
-\r
-               return result;\r
-       }\r
-\r
-       float SourceVoice::FrequencyRatio::get()\r
-       {\r
-               float result;\r
-               SourcePointer->GetFrequencyRatio( &result );\r
-\r
-               return result;\r
-       }\r
-\r
-       void SourceVoice::FrequencyRatio::set( float value )\r
-       {\r
-               HRESULT hr = SourcePointer->SetFrequencyRatio( value );\r
-               RECORD_XAUDIO2( hr );\r
-       }\r
-}\r
-}
\ No newline at end of file