| 1 | /************************************************************************************ |
| 2 | Filename : ONSPProfiler.cs |
| 3 | Content : Use this to attach to the Oculus Audio Profiler tool |
| 4 | Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. |
| 5 | |
| 6 | Licensed under the Oculus SDK Version 3.5 (the "License"); |
| 7 | you may not use the Oculus SDK except in compliance with the License, |
| 8 | which is provided at the time of installation or download, or which |
| 9 | otherwise accompanies this software in either electronic or hard copy form. |
| 10 | |
| 11 | You may obtain a copy of the License at |
| 12 | |
| 13 | https://developer.oculus.com/licenses/sdk-3.5/ |
| 14 | |
| 15 | Unless required by applicable law or agreed to in writing, the Oculus SDK |
| 16 | distributed under the License is distributed on an "AS IS" BASIS, |
| 17 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | See the License for the specific language governing permissions and |
| 19 | limitations under the License. |
| 20 | ************************************************************************************/ |
| 21 | using System.Collections; |
| 22 | using System.Collections.Generic; |
| 23 | using System.Runtime.InteropServices; |
| 24 | using UnityEngine; |
| 25 | using UnityEngine.Networking; |
| 26 | |
| 27 | |
| 28 | public class ONSPProfiler : MonoBehaviour |
| 29 | { |
| 30 | public bool profilerEnabled = false; |
| 31 | const int DEFAULT_PORT = 2121; |
| 32 | public int port = DEFAULT_PORT; |
| 33 | |
| 34 | void Start() |
| 35 | { |
| 36 | Application.runInBackground = true; |
| 37 | } |
| 38 | |
| 39 | void Update() |
| 40 | { |
| 41 | if (port < 0 || port > 65535) |
| 42 | { |
| 43 | port = DEFAULT_PORT; |
| 44 | } |
| 45 | ONSP_SetProfilerPort(port); |
| 46 | ONSP_SetProfilerEnabled(profilerEnabled); |
| 47 | } |
| 48 | |
| 49 | // Import functions |
| 50 | public const string strONSPS = "AudioPluginOculusSpatializer"; |
| 51 | |
| 52 | [DllImport(strONSPS)] |
| 53 | private static extern int ONSP_SetProfilerEnabled(bool enabled); |
| 54 | [DllImport(strONSPS)] |
| 55 | private static extern int ONSP_SetProfilerPort(int port); |
| 56 | } |