[mupen64plus-audio-sdl] 101/163: Imported Upstream version 1.99.5+4+761b386e52de

Sven Eckelmann ecsv-guest at moszumanska.debian.org
Thu Nov 26 05:53:24 UTC 2015


This is an automated email from the git hooks/post-receive script.

ecsv-guest pushed a commit to branch armhf_test
in repository mupen64plus-audio-sdl.

commit f146d36910aebaf51f0a5da11ae07052a3e4c58a
Author: Sven Eckelmann <sven at narfation.org>
Date:   Tue Sep 11 09:07:23 2012 +0200

    Imported Upstream version 1.99.5+4+761b386e52de
---
 RELEASE                                     |   7 ++
 projects/msvc8/mupen64plus-audio-sdl.vcproj |   4 -
 projects/unix/Makefile                      |   5 +
 src/main.c                                  | 152 +++++++++-------------------
 src/osal_preproc.h                          |  32 ------
 src/volume.c                                |  10 +-
 6 files changed, 64 insertions(+), 146 deletions(-)

diff --git a/RELEASE b/RELEASE
index fea921f..fe1a388 100644
--- a/RELEASE
+++ b/RELEASE
@@ -1,6 +1,13 @@
 SDL Audio plugin for Mupen64Plus
 ---------------------------------
 
+Mupen64Plus-audio-sdl - LATEST REVISION
+---------------------------------------
+ - Bugfix: Don't assume OSS is installed in all linux systems.
+ - Bugfix: Some combinations of VolumeSetLevel and VolumeMute caused VolumeGetString to return "Mute" when not muted
+ - Make SDL volume handling the default, since OSS is no longer included in the kernel.
+ - Minor refactoring of volume handling code.
+
 Mupen64Plus-audio-sdl v1.99.5 - March 10, 2012
 --------------------------------------------------
  - added version number to SDL-audio plugin config parameters, to support future changes
diff --git a/projects/msvc8/mupen64plus-audio-sdl.vcproj b/projects/msvc8/mupen64plus-audio-sdl.vcproj
index 6a6d9db..7757871 100644
--- a/projects/msvc8/mupen64plus-audio-sdl.vcproj
+++ b/projects/msvc8/mupen64plus-audio-sdl.vcproj
@@ -202,10 +202,6 @@
 				RelativePath="..\..\src\osal_dynamiclib.h"
 				>
 			</File>
-			<File
-				RelativePath="..\..\src\osal_preproc.h"
-				>
-			</File>
 		</Filter>
 	</Files>
 	<Globals>
diff --git a/projects/unix/Makefile b/projects/unix/Makefile
index ccf93cb..7f270da 100644
--- a/projects/unix/Makefile
+++ b/projects/unix/Makefile
@@ -178,6 +178,11 @@ else
   $(warning No libsamplerate development libraries found.  Mupen64plus-sdl-audio will be built without Best Quality SINC resampler.)
 endif
 
+# test for the presence of OSS
+ifneq ($(wildcard /dev/mixer),)
+  CFLAGS += -DHAS_OSS_SUPPORT
+endif
+
 # set mupen64plus core API header path
 ifneq ("$(APIDIR)","")
   CFLAGS += "-I$(APIDIR)"
diff --git a/src/main.c b/src/main.c
index 3fb99fc..0f8bce5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -42,7 +42,6 @@
 #include "main.h"
 #include "volume.h"
 #include "osal_dynamiclib.h"
-#include "osal_preproc.h"
 
 /* Default start-time size of primary buffer (in equivalent output samples).
    This is the buffer where audio is loaded after it's extracted from n64's memory.
@@ -111,15 +110,16 @@ static unsigned int SecondaryBufferSize = SECONDARY_BUFFER_SIZE;
 // Resample or not
 static unsigned char Resample = 1;
 // volume to scale the audio by, range of 0..100
+// if muted, this holds the volume when not muted
 static int VolPercent = 80;
 // how much percent to increment/decrement volume by
 static int VolDelta = 5;
 // the actual volume passed into SDL, range of 0..SDL_MIX_MAXVOLUME
 static int VolSDL = SDL_MIX_MAXVOLUME;
-// stores the previous volume when it is muted
-static int VolMutedSave = -1;
+// Muted or not
+static int VolIsMuted = 0;
 //which type of volume control to use
-static int VolumeControlType = VOLUME_TYPE_OSS;
+static int VolumeControlType = VOLUME_TYPE_SDL;
 
 static int OutputFreq;
 
@@ -260,7 +260,7 @@ EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle, void *Con
     ConfigSetDefaultInt(l_ConfigAudio, "PRIMARY_BUFFER_TARGET", PRIMARY_BUFFER_TARGET, "Fullness level target for Primary audio buffer, in equivalent output samples");
     ConfigSetDefaultInt(l_ConfigAudio, "SECONDARY_BUFFER_SIZE", SECONDARY_BUFFER_SIZE, "Size of secondary buffer in output samples. This is SDL's hardware buffer.");
     ConfigSetDefaultInt(l_ConfigAudio, "RESAMPLE",              1,                     "Audio resampling algorithm.  1 = unfiltered, 2 = SINC resampling (Best Quality, requires libsamplerate)");
-    ConfigSetDefaultInt(l_ConfigAudio, "VOLUME_CONTROL_TYPE",   VOLUME_TYPE_OSS,       "Volume control type: 1 = SDL (only affects Mupen64Plus output)  2 = OSS mixer (adjusts master PC volume)");
+    ConfigSetDefaultInt(l_ConfigAudio, "VOLUME_CONTROL_TYPE",   VOLUME_TYPE_SDL,       "Volume control type: 1 = SDL (only affects Mupen64Plus output)  2 = OSS mixer (adjusts master PC volume)");
     ConfigSetDefaultInt(l_ConfigAudio, "VOLUME_ADJUST",         5,                     "Percentage change each time the volume is increased or decreased");
     ConfigSetDefaultInt(l_ConfigAudio, "VOLUME_DEFAULT",        80,                    "Default volume when a game is started.  Only used if VOLUME_CONTROL_TYPE is 1");
 
@@ -350,7 +350,7 @@ EXPORT void CALL AiLenChanged( void )
         return;
 
     LenReg = *AudioInfo.AI_LEN_REG;
-    p = (unsigned char*)(AudioInfo.RDRAM + (*AudioInfo.AI_DRAM_ADDR_REG & 0xFFFFFF));
+    p = AudioInfo.RDRAM + (*AudioInfo.AI_DRAM_ADDR_REG & 0xFFFFFF);
 
     if (buffer_pos + LenReg < primaryBufferBytes)
     {
@@ -788,120 +788,71 @@ static void ReadConfig(void)
     VolPercent = ConfigGetParamInt(l_ConfigAudio, "VOLUME_DEFAULT");
 }
 
-EXPORT void CALL VolumeMute(void)
-{
-    if (!l_PluginInit)
-        return;
-
-    if (VolMutedSave > -1)
-    {
-        //unmute
-        VolPercent = VolMutedSave;
-        VolMutedSave = -1;
-#if defined(HAS_OSS_SUPPORT)
-        if (VolumeControlType == VOLUME_TYPE_OSS)
-        {
-            //OSS mixer volume
-            volSet(VolPercent);
-        }
-        else
-#endif
-        {
-            VolSDL = SDL_MIX_MAXVOLUME * VolPercent / 100;
-        }
-    } 
-    else
-    {
-        //mute
-        VolMutedSave = VolPercent;
-        VolPercent = 0;
-#if defined(HAS_OSS_SUPPORT)
-        if (VolumeControlType == VOLUME_TYPE_OSS)
-        {
-            //OSS mixer volume
-            volSet(0);
-        }
-        else
-#endif
-        {
-            VolSDL = 0;
-        }
-    }
-}
-
-EXPORT void CALL VolumeUp(void)
+// Returns the most recent ummuted volume level.
+static int VolumeGetUnmutedLevel(void)
 {
-    if (!l_PluginInit)
-        return;
-
-    //if muted, unmute first
-    if (VolMutedSave > -1)
-        VolumeMute();
-
 #if defined(HAS_OSS_SUPPORT)
     // reload volume if we're using OSS
-    if (VolumeControlType == VOLUME_TYPE_OSS)
+    if (!VolIsMuted && VolumeControlType == VOLUME_TYPE_OSS)
     {
-        VolPercent = volGet();
+        return volGet();
     }
 #endif
 
-    // adjust volume variable
-    VolPercent += VolDelta;
-    if (VolPercent > 100)
-        VolPercent = 100;
+    return VolPercent;
+}
+
+// Sets the volume level based on the contents of VolPercent and VolIsMuted
+static void VolumeCommit(void)
+{
+    int levelToCommit = VolIsMuted ? 0 : VolPercent;
 
 #if defined(HAS_OSS_SUPPORT)
     if (VolumeControlType == VOLUME_TYPE_OSS)
     {
         //OSS mixer volume
-        volSet(VolPercent);
+        volSet(levelToCommit);
     }
     else
 #endif
     {
-        VolSDL = SDL_MIX_MAXVOLUME * VolPercent / 100;
+        VolSDL = SDL_MIX_MAXVOLUME * levelToCommit / 100;
     }
 }
 
-EXPORT void CALL VolumeDown(void)
+EXPORT void CALL VolumeMute(void)
 {
     if (!l_PluginInit)
         return;
 
-    //if muted, unmute first
-    if (VolMutedSave > -1)
-        VolumeMute();
+    // Store the volume level in order to restore it later
+    if (!VolIsMuted)
+        VolPercent = VolumeGetUnmutedLevel();
 
-#if defined(HAS_OSS_SUPPORT)
-    // reload volume if we're using OSS
-    if (VolumeControlType == VOLUME_TYPE_OSS)
-    {
-        VolPercent = volGet();
-    }
-#endif
+    // Toogle mute
+    VolIsMuted = !VolIsMuted;
+    VolumeCommit();
+}
 
-    // adjust volume variable
-    VolPercent -= VolDelta;
-    if (VolPercent < 0)
-        VolPercent = 0;
+EXPORT void CALL VolumeUp(void)
+{
+    if (!l_PluginInit)
+        return;
 
-#if defined(HAS_OSS_SUPPORT)
-    if (VolumeControlType == VOLUME_TYPE_OSS)
-    {
-        //OSS mixer volume
-        volSet(VolPercent);
-    }
-    else
-#endif
-    {
-        VolSDL = SDL_MIX_MAXVOLUME * VolPercent / 100;
-    }
+    VolumeSetLevel(VolumeGetUnmutedLevel() + VolDelta);
+}
+
+EXPORT void CALL VolumeDown(void)
+{
+    if (!l_PluginInit)
+        return;
+
+    VolumeSetLevel(VolumeGetUnmutedLevel() - VolDelta);
 }
 
 EXPORT int CALL VolumeGetLevel(void)
 {
-    return VolPercent;
+    return VolIsMuted ? 0 : VolumeGetUnmutedLevel();
 }
 
 EXPORT void CALL VolumeSetLevel(int level)
@@ -909,6 +860,9 @@ EXPORT void CALL VolumeSetLevel(int level)
     if (!l_PluginInit)
         return;
 
+    //if muted, unmute first
+    VolIsMuted = 0;
+
     // adjust volume 
     VolPercent = level;
     if (VolPercent < 0)
@@ -916,24 +870,14 @@ EXPORT void CALL VolumeSetLevel(int level)
     else if (VolPercent > 100)
         VolPercent = 100;
 
-#if defined(HAS_OSS_SUPPORT)
-    if (VolumeControlType == VOLUME_TYPE_OSS)
-    {
-        //OSS mixer volume
-        volSet(VolPercent);
-    }
-    else
-#endif
-    {
-        VolSDL = SDL_MIX_MAXVOLUME * VolPercent / 100;
-    }
+    VolumeCommit();
 }
 
-static char VolumeString[32];
-
 EXPORT const char * CALL VolumeGetString(void)
 {
-    if (VolMutedSave > -1)
+    static char VolumeString[32];
+
+    if (VolIsMuted)
     {
         strcpy(VolumeString, "Mute");
     }
diff --git a/src/osal_preproc.h b/src/osal_preproc.h
deleted file mode 100644
index a2e334e..0000000
--- a/src/osal_preproc.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *   Mupen64plus - osal_preproc.h                                          *
- *   Mupen64Plus homepage: http://code.google.com/p/mupen64plus/           *
- *   Copyright (C) 2009 Richard Goedeken                                   *
- *   Copyright (C) 2002 Hacktarux                                          *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/* this header file is for system-dependent #defines, #includes, and typedefs */
-
-#if !defined(OSAL_PREPROC_H)
-#define OSAL_PREPROC_H
-
-#if defined(__linux__)
-  #define HAS_OSS_SUPPORT
-#endif
-
-#endif // OSAL_PREPROC_H
diff --git a/src/volume.c b/src/volume.c
index d172561..1c6e25c 100644
--- a/src/volume.c
+++ b/src/volume.c
@@ -20,8 +20,6 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
-#include "osal_preproc.h"
-
 #if defined(HAS_OSS_SUPPORT)
 
 /* Sound volume functions. */
@@ -46,7 +44,7 @@ void volSet(int percent)
 
     if(mixerfd < 0)
     {
-        perror("/dev/mixer: ");
+        perror("/dev/mixer");
         return;
     }
 
@@ -58,7 +56,7 @@ void volSet(int percent)
     vol = (percent << 8) + percent; // set both left/right channels to same vol
     ret = ioctl(mixerfd, MIXER_WRITE(SOUND_MIXER_PCM), &vol);
     if(ret < 0)
-        perror("Setting PCM volume: ");
+        perror("Setting PCM volume");
 
     close(mixerfd);
 }
@@ -74,13 +72,13 @@ int volGet(void)
 
     if(mixerfd < 0)
     {
-        perror("/dev/mixer: ");
+        perror("/dev/mixer");
         return 0;
     }
 
     ret = ioctl(mixerfd, MIXER_READ(SOUND_MIXER_PCM), &vol);
     if(ret < 0)
-        perror("Reading PCM volume: ");
+        perror("Reading PCM volume");
 
     close(mixerfd);
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/mupen64plus-audio-sdl.git



More information about the Pkg-games-commits mailing list