OSDN Git Service

Updated FMOD Ex to version 4.44.08
authorLatif Khalifa <latifer@streamgrid.net>
Fri, 1 Mar 2013 08:00:49 +0000 (09:00 +0100)
committerLatif Khalifa <latifer@streamgrid.net>
Fri, 1 Mar 2013 08:00:49 +0000 (09:00 +0100)
12 files changed:
.gitignore
Radegast/Core/Media/MediaManager.cs
Radegast/Core/Media/Stream.cs
Radegast/assemblies/fmodex-dotnet.dll
Radegast/fmodex-dotnet.dll.config
Radegast/fmodex.dll
Radegast/libfmodex-4.26.07.dylib [deleted file]
Radegast/libfmodex-4.26.07.so [deleted file]
Radegast/libfmodex-4.44.08.dylib [new file with mode: 0644]
Radegast/libfmodex-4.44.08.so [new file with mode: 0755]
Radegast/libfmodex64-4.26.07.so [deleted file]
Radegast/libfmodex64-4.44.08.so [new file with mode: 0755]

index 7351d3d..676af95 100644 (file)
@@ -9,3 +9,4 @@ compile.bat
 *.bak
 *.resources
 *~
+*.userprefs
index 98f2821..c53f7ad 100644 (file)
@@ -206,6 +206,15 @@ namespace Radegast.Media
 
                     if (!audioOK)
                     {
+                        res = system.setOutput(FMOD.OUTPUTTYPE.PULSEAUDIO);
+                        if (res == RESULT.OK)
+                        {
+                            audioOK = true;
+                        }
+                    }
+
+                    if (!audioOK)
+                    {
                         res = system.setOutput(FMOD.OUTPUTTYPE.ALSA);
                         if (res == RESULT.OK)
                         {
@@ -240,10 +249,9 @@ namespace Radegast.Media
                 try
                 {
                     // Get the capabilities of the driver.
-                    int minfrequency = 0, maxfrequency = 0;
+                    int outputRate = 0;
                     FMODExec(system.getDriverCaps(0, ref caps,
-                        ref minfrequency,
-                        ref maxfrequency,
+                        ref outputRate,
                         ref speakermode));
                     // Set FMOD speaker mode to what the driver supports.
                    FMODExec(system.setSpeakerMode(speakermode));
@@ -280,7 +288,7 @@ namespace Radegast.Media
                 catch {}
                 
                 // Try to initialize with all those settings, and Max 32 channels.
-                FMOD.RESULT result = system.init(32, FMOD.INITFLAG.NORMAL, (IntPtr)null);
+                FMOD.RESULT result = system.init(32, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
                 if (result == FMOD.RESULT.ERR_OUTPUT_CREATEBUFFER)
                 {
                     // Can not handle surround sound - back to Stereo.
@@ -289,7 +297,7 @@ namespace Radegast.Media
                     // And init again.
                     FMODExec(system.init(
                         32,
-                        FMOD.INITFLAG.NORMAL,
+                        FMOD.INITFLAGS.NORMAL,
                         (IntPtr)null)
                     );
                 }
@@ -310,7 +318,7 @@ namespace Radegast.Media
             }
             catch (Exception ex)
             {
-                Logger.Log("Failed to initialize the sound system: ", Helpers.LogLevel.Warning, ex);
+                Logger.Log("Failed to initialize the sound system: " + ex.ToString(), Helpers.LogLevel.Warning);
             }
         }
 
index 577eee5..eb1f3f5 100644 (file)
@@ -28,7 +28,6 @@
 //
 // $Id: Sound.cs 502 2010-03-14 23:13:46Z latifer $
 //
-#define GET_STREAM_TAGS
 using System;
 using System.Runtime.InteropServices;
 using System.Threading;
@@ -61,14 +60,10 @@ namespace Radegast.Media
         /// <summary>
         /// Fired when a stream meta data is received
         /// </summary>
-#pragma warning disable 0067
         public event StreamInfoCallback OnStreamInfo;
-#pragma warning restore 0067
 
-#if GET_STREAM_TAGS
-        Timer tagTimer = null;
-        uint tagCheckInterval = 1000;
-#endif
+        Timer updateTimer = null;
+        uint updateIntervl = 500;
         /// <summary>
         /// Creates a new sound object
         /// </summary>
@@ -89,13 +84,11 @@ namespace Radegast.Media
 
         public void StopStream()
         {
-#if GET_STREAM_TAGS
-            if (tagTimer != null)
+            if (updateTimer != null)
             {
-                tagTimer.Dispose();
-                tagTimer = null;
+                updateTimer.Dispose();
+                updateTimer = null;
             }
-#endif
 
             if (channel != null)
             {
@@ -135,6 +128,9 @@ namespace Radegast.Media
                     try
                     {
                         FMODExec(
+                            system.setStreamBufferSize(4 * 128 * 128, TIMEUNIT.RAWBYTES));
+
+                        FMODExec(
                             system.createSound(url,
                             (MODE.HARDWARE | MODE._2D | MODE.CREATESTREAM),
                             ref extraInfo,
@@ -150,27 +146,21 @@ namespace Radegast.Media
                             ref channel), "Stream channel");
                         FMODExec(channel.setVolume(volume), "Stream volume");
 
-#if GET_STREAM_TAGS
-                        if (Environment.OSVersion.Platform != PlatformID.Unix)
+                        if (updateTimer == null)
                         {
-                            if (tagTimer == null)
-                            {
-                                tagTimer = new Timer(CheckTags);
-                            }
-                            tagTimer.Change(0, tagCheckInterval);
+                            updateTimer = new Timer(Update);
                         }
-#endif
+                        updateTimer.Change(0, updateIntervl);
                     }
                     catch (Exception ex)
                     {
-                        Logger.Log("Error playing stream: ", Helpers.LogLevel.Debug, ex);
+                        Logger.Log("Error playing stream: " + ex.ToString(), Helpers.LogLevel.Debug);
                     }
                 }));
         }
 
 
-#if GET_STREAM_TAGS
-        private void CheckTags(object sender)
+        private void Update(object sender)
         {
             if (sound == null) return;
 
@@ -178,15 +168,37 @@ namespace Radegast.Media
             {
                 try
                 {
+                    FMODExec(system.update());
+
                     TAG tag = new TAG();
-                    while (sound.getTag(null, -1, ref tag) == RESULT.OK)
+                    int numTags = 0;
+                    int numTagsUpdated = 0;
+
+                    var res = sound.getNumTags(ref numTags, ref numTagsUpdated);
+
+                    if (res == RESULT.OK && numTagsUpdated > 0)
                     {
-                        if (tag.datatype != TAGDATATYPE.STRING) continue;
+                        for (int i=0; i < numTags; i++)
+                        {
+                            if (sound.getTag(null, i, ref tag) != RESULT.OK)
+                            {
+                                continue;
+                            }
 
-                        // Tell listeners about the Stream tag.  This can be
-                        // displayed to the user.
-                        if (OnStreamInfo != null)
-                            OnStreamInfo(this, new StreamInfoArgs(tag.name.ToLower(), Marshal.PtrToStringAnsi(tag.data)));
+                            if (tag.type == TAGTYPE.FMOD && tag.name == "Sample Rate Change")
+                            {
+                                float newfreq = (float)Marshal.PtrToStructure(tag.data, typeof(float));
+                                Logger.DebugLog("New stream frequency: " + newfreq.ToString("F" + 0));
+                                channel.setFrequency(newfreq);
+                            }
+
+                            if (tag.datatype != TAGDATATYPE.STRING) continue;
+
+                            // Tell listeners about the Stream tag.  This can be
+                            // displayed to the user.
+                            if (OnStreamInfo != null)
+                                OnStreamInfo(this, new StreamInfoArgs(tag.name.ToLower(), Marshal.PtrToStringAnsi(tag.data)));
+                        }
                     }
                 }
                 catch (Exception ex)
@@ -195,6 +207,5 @@ namespace Radegast.Media
                 }
             }));
         }
-#endif
     }
 }
index 6acb43a..9c43270 100644 (file)
Binary files a/Radegast/assemblies/fmodex-dotnet.dll and b/Radegast/assemblies/fmodex-dotnet.dll differ
index 7f34c05..387a074 100644 (file)
@@ -2,8 +2,8 @@
 <!-- $Id$ -->\r
 <configuration>\r
   <dllmap dll="fmodex">\r
-    <dllentry os="!windows,osx" cpu="x86" dll="libfmodex-4.26.07" />\r
-    <dllentry os="!windows,osx" cpu="x86-64,ia64" dll="libfmodex64-4.26.07" />\r
-    <dllentry os="osx" dll="libfmodex-4.26.07.dylib" />\r
+    <dllentry os="!windows,osx" cpu="x86" dll="libfmodex-4.44.08" />\r
+    <dllentry os="!windows,osx" cpu="x86-64,ia64" dll="libfmodex64-4.44.08" />\r
+    <dllentry os="osx" dll="libfmodex-4.44.08.dylib" />\r
   </dllmap>\r
 </configuration>\r
index d90cad1..01c719b 100644 (file)
Binary files a/Radegast/fmodex.dll and b/Radegast/fmodex.dll differ
diff --git a/Radegast/libfmodex-4.26.07.dylib b/Radegast/libfmodex-4.26.07.dylib
deleted file mode 100644 (file)
index 10019cd..0000000
Binary files a/Radegast/libfmodex-4.26.07.dylib and /dev/null differ
diff --git a/Radegast/libfmodex-4.26.07.so b/Radegast/libfmodex-4.26.07.so
deleted file mode 100644 (file)
index e7da664..0000000
Binary files a/Radegast/libfmodex-4.26.07.so and /dev/null differ
diff --git a/Radegast/libfmodex-4.44.08.dylib b/Radegast/libfmodex-4.44.08.dylib
new file mode 100644 (file)
index 0000000..e5797af
Binary files /dev/null and b/Radegast/libfmodex-4.44.08.dylib differ
diff --git a/Radegast/libfmodex-4.44.08.so b/Radegast/libfmodex-4.44.08.so
new file mode 100755 (executable)
index 0000000..11e2be6
Binary files /dev/null and b/Radegast/libfmodex-4.44.08.so differ
diff --git a/Radegast/libfmodex64-4.26.07.so b/Radegast/libfmodex64-4.26.07.so
deleted file mode 100644 (file)
index a1be95a..0000000
Binary files a/Radegast/libfmodex64-4.26.07.so and /dev/null differ
diff --git a/Radegast/libfmodex64-4.44.08.so b/Radegast/libfmodex64-4.44.08.so
new file mode 100755 (executable)
index 0000000..65e355d
Binary files /dev/null and b/Radegast/libfmodex64-4.44.08.so differ