2 * Copyright (c) 2007-2010 SlimDX Group
\r
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
\r
5 * of this software and associated documentation files (the "Software"), to deal
\r
6 * in the Software without restriction, including without limitation the rights
\r
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
8 * copies of the Software, and to permit persons to whom the Software is
\r
9 * furnished to do so, subject to the following conditions:
\r
11 * The above copyright notice and this permission notice shall be included in
\r
12 * all copies or substantial portions of the Software.
\r
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
\r
24 #include "../DataStream.h"
\r
26 #include "RuntimeParameters.h"
\r
28 using namespace System;
\r
34 XACT_RUNTIME_PARAMETERS RuntimeParameters::ToUnmanaged()
\r
36 XACT_RUNTIME_PARAMETERS results;
\r
37 memset(&results, 0, sizeof(XACT_RUNTIME_PARAMETERS));
\r
41 results.lookAheadTime = LookAheadTime;
\r
43 if (!String::IsNullOrEmpty(RendererId))
\r
45 pin_ptr<const wchar_t> pinnedId = PtrToStringChars(RendererId);
\r
46 results.pRendererID = new WCHAR[RendererId->Length];
\r
48 memcpy(results.pRendererID, pinnedId, sizeof(wchar_t) * RendererId->Length);
\r
51 if (AudioDevice != nullptr)
\r
52 results.pXAudio2 = AudioDevice->InternalPointer;
\r
53 if (MasteringVoice != nullptr)
\r
54 results.pMasteringVoice = reinterpret_cast<IXAudio2MasteringVoice*>(MasteringVoice->InternalPointer);
\r
56 if (SettingsBuffer != nullptr)
\r
58 int size = static_cast<int>(SettingsBuffer->Length - SettingsBuffer->Position);
\r
59 results.pGlobalSettingsBuffer = CoTaskMemAlloc(size);
\r
60 results.globalSettingsBufferSize = size;
\r
61 results.globalSettingsFlags = XACT_FLAG_ENGINE_CREATE_MANAGEDATA;
\r
63 DataStream^ ds = dynamic_cast<DataStream^>(SettingsBuffer);
\r
65 memcpy(results.pGlobalSettingsBuffer, ds->PositionPointer, size);
\r
68 array<Byte>^ buffer = gcnew array<Byte>(size);
\r
70 while (bytesRead < size)
\r
71 bytesRead += SettingsBuffer->Read(buffer, bytesRead, size - bytesRead);
\r
73 pin_ptr<Byte> pinnedBuffer = &buffer[0];
\r
74 memcpy(results.pGlobalSettingsBuffer, pinnedBuffer, size);
\r
80 delete[] results.pRendererID;
\r
81 CoTaskMemFree(results.pGlobalSettingsBuffer);
\r