static public int UnloadAudioData(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif UnityEngine.AudioClip self = (UnityEngine.AudioClip)checkSelf(l); var ret = self.UnloadAudioData(); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
static public int UnloadAudioData(IntPtr l) { try { UnityEngine.AudioClip self = (UnityEngine.AudioClip)checkSelf(l); var ret = self.UnloadAudioData(); pushValue(l, ret); return(1); } catch (Exception e) { return(error(l, e)); } }
static int QPYX_UnloadAudioData_YXQP(IntPtr L_YXQP) { try { ToLua.CheckArgsCount(L_YXQP, 1); UnityEngine.AudioClip QPYX_obj_YXQP = (UnityEngine.AudioClip)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.AudioClip)); bool QPYX_o_YXQP = QPYX_obj_YXQP.UnloadAudioData(); LuaDLL.lua_pushboolean(L_YXQP, QPYX_o_YXQP); return(1); } catch (Exception e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP)); } }
static int UnloadAudioData(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); UnityEngine.AudioClip obj = (UnityEngine.AudioClip)ToLua.CheckObject(L, 1, typeof(UnityEngine.AudioClip)); bool o = obj.UnloadAudioData(); LuaDLL.lua_pushboolean(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int UnloadAudioData(IntPtr L) { #if UNITY_EDITOR ToluaProfiler.AddCallRecord("UnityEngine.AudioClip.UnloadAudioData"); #endif try { ToLua.CheckArgsCount(L, 1); UnityEngine.AudioClip obj = (UnityEngine.AudioClip)ToLua.CheckObject(L, 1, typeof(UnityEngine.AudioClip)); bool o = obj.UnloadAudioData(); LuaDLL.lua_pushboolean(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
/*! \cond PRIVATE */ #if UNITY_5 public static void UnloadNonPreloadedAudioData(AudioClip clip) { if (clip != null && !clip.preloadAudioData) { clip.UnloadAudioData(); // restore memory } }
public AudioClip StartImport(string mPath) { MPGImport.mpg123_init(); handle_mpg = MPGImport.mpg123_new(null, errPtr); try { x = MPGImport.mpg123_open(handle_mpg, mPath); MPGImport.mpg123_getformat(handle_mpg, out rate, out channels, out encoding); intRate = rate.ToInt32(); intChannels = channels.ToInt32(); intEncoding = encoding.ToInt32(); MPGImport.mpg123_id3(handle_mpg, out id3v1, out id3v2); MPGImport.mpg123_format_none(handle_mpg); MPGImport.mpg123_format(handle_mpg, intRate, intChannels, 208); Debug.Log("Getting ID3 info"); MPGImport.mpg123_id3v1 v1 = (MPGImport.mpg123_id3v1)Marshal.PtrToStructure(id3v1, typeof(MPGImport.mpg123_id3v1)); FrameSize = MPGImport.mpg123_outblock(handle_mpg); byte[] Buffer = new byte[FrameSize]; lengthSamples = MPGImport.mpg123_length(handle_mpg); myClip = AudioClip.Create(new String(v1.title), lengthSamples, intChannels, intRate, false); int importIndex = 0; while (0 == MPGImport.mpg123_read(handle_mpg, Buffer, FrameSize, out done)) { float[] fArray; fArray = ByteToFloat(Buffer); float offset = (importIndex * fArray.Length) / 2; if (offset > lengthSamples) { Debug.LogWarning("[STED] MP3 file " + mPath + " is of an unexpected length and was truncated."); break; // File was reported as shorter than it is. Salvage what we have and return. } myClip.SetData(fArray, (int)offset); importIndex++; } } catch (Exception ex) { // Attempt to dump any used memory before continuing. // TODO: Still holds onto memory when repeatedy failing. myClip.UnloadAudioData(); myClip = null; throw ex; } finally { MPGImport.mpg123_close(handle_mpg); } return myClip; }