SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401938
This commit is contained in:
parent
91a32b77a2
commit
0f030a1802
686 changed files with 117556 additions and 98661 deletions
1
.indent.pro
vendored
Normal file
1
.indent.pro
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
-i4 -nut -nsc -br -ce -cdw -npcs
|
Binary file not shown.
|
@ -55,6 +55,7 @@ SRCS = \
|
|||
src/video/dummy/SDL_nullevents.c \
|
||||
src/video/dummy/SDL_nullmouse.c \
|
||||
src/video/dummy/SDL_nullvideo.c \
|
||||
src/video/glsdl/SDL_glsdl.c \
|
||||
src/video/SDL_blit.c \
|
||||
src/video/SDL_blit_0.c \
|
||||
src/video/SDL_blit_1.c \
|
||||
|
|
23
Makefile.in
23
Makefile.in
|
@ -167,6 +167,29 @@ dist $(distfile):
|
|||
rpm: $(distfile)
|
||||
rpmbuild -ta $?
|
||||
|
||||
# Run indent on the source to standardize coding style
|
||||
indent:
|
||||
@echo "Running indent... modified files:"
|
||||
@cd $(srcdir) && \
|
||||
find . \( \
|
||||
-name '*.h' -o \
|
||||
-name '*.c' -o \
|
||||
-name '*.cc' \) \
|
||||
-print | \
|
||||
while read file; do \
|
||||
indent "$$file" -o "$$file.indent"; \
|
||||
if cmp "$$file" "$$file.indent" >/dev/null; then \
|
||||
rm -f "$$file.indent"; \
|
||||
else \
|
||||
echo "$$file"; \
|
||||
mv -f "$$file.indent" "$$file"; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
# Run indent and then commit modified files
|
||||
commit: indent
|
||||
svn commit
|
||||
|
||||
# Create a SVN snapshot that people can run update on
|
||||
snapshot:
|
||||
svn co svn://libsdl.org/trunk/SDL
|
||||
|
|
16
README.OS2
16
README.OS2
|
@ -3,7 +3,7 @@
|
|||
SDL on OS/2
|
||||
===========
|
||||
|
||||
Last updated on May. 17, 2006.
|
||||
Last updated on May. 1, 2006.
|
||||
|
||||
|
||||
1. How to compile?
|
||||
|
@ -13,6 +13,8 @@ To compile this, you'll need the followings installed:
|
|||
- The OS/2 Developer's Toolkit
|
||||
- The OpenWatcom compiler
|
||||
(http://www.openwatcom.org)
|
||||
- The FSLib library
|
||||
(ftp://ftp.netlabs.org/pub/SDL)
|
||||
|
||||
First of all, you have to unzip the Watcom-OS2.zip file. This will result in a
|
||||
file called "makefile" and a file called "setvars.cmd" in this folder (and some
|
||||
|
@ -30,7 +32,7 @@ is full of printf()'s, so if something goes wrong, its output can help a lot
|
|||
for debugging.
|
||||
|
||||
Then run "wmake".
|
||||
This should create the SDL12.DLL and the corresponding SDL12.LIB file here.
|
||||
This should create the SDL.DLL and the corresponding SDL.LIB file here.
|
||||
|
||||
To test applications, it's a good idea to use the 'debug' build of SDL, and
|
||||
redirect the standard output and standard error output to files, to see what
|
||||
|
@ -46,8 +48,8 @@ wmake
|
|||
2. How to compile the testapps?
|
||||
-------------------------------
|
||||
|
||||
Once you have SDL12.DLL compiled, navigate into the 'test' folder, copy in
|
||||
there the newly built SDL12.DLL, and copy in there FSLib.DLL.
|
||||
Once you have SDL.DLL compiled, navigate into the 'test' folder, copy in there
|
||||
the newly built SDL.DLL, and copy in there FSLib.DLL.
|
||||
|
||||
Then run "wmake" in there to compile some of the testapps.
|
||||
|
||||
|
@ -189,10 +191,6 @@ please, be our guest and contact us!
|
|||
10. Changelog of the OS/2 port
|
||||
------------------------------
|
||||
|
||||
Version 1.2.10 - 2006-05-17 - Doodle
|
||||
- Small modifications for v1.2.10 release
|
||||
- Changed DLL name to include version info (currently SDL12.dll)
|
||||
|
||||
Version 1.2 - 2006-05-01 - Doodle
|
||||
- Modified makefile system to have only one makefile
|
||||
- Included FSLib headers, DLL and LIB file
|
||||
|
@ -218,7 +216,7 @@ Version 1.2.7 - 2005-12-22 - Doodle
|
|||
SET SDL_USE_PROPORTIONAL_WINDOW=1
|
||||
dosbox.exe
|
||||
)
|
||||
or, if you have the HOME environment variable set, then SDL12.DLL will
|
||||
or, if you have the HOME environment variable set, then SDL.DLL will
|
||||
create a file in that directory called .sdl.proportionals, and you can
|
||||
put there the name of executable files that will be automatically made
|
||||
proportional.
|
||||
|
|
3
TODO
3
TODO
|
@ -2,6 +2,9 @@
|
|||
Wish list for the 1.3 development branch:
|
||||
http://bugzilla.libsdl.org/
|
||||
|
||||
* Add a way to register custom events
|
||||
* Add internal support for adding video modes and refresh rates
|
||||
* Support querying and setting refresh rate with video modes
|
||||
* Add mousewheel events (new unified event architecture?)
|
||||
* DirectInput joystick support needs to be implemented
|
||||
* Be able to enumerate and select available audio and video drivers
|
||||
|
|
1
UNDER_CONSTRUCTION.txt
Normal file
1
UNDER_CONSTRUCTION.txt
Normal file
|
@ -0,0 +1 @@
|
|||
WARNING: This code is under construction, may not build, and is unstable!
|
BIN
VisualC.zip
BIN
VisualC.zip
Binary file not shown.
BIN
Watcom-OS2.zip
BIN
Watcom-OS2.zip
Binary file not shown.
10
WhatsNew
10
WhatsNew
|
@ -1,7 +1,11 @@
|
|||
|
||||
This is a list of API changes in SDL's version history.
|
||||
|
||||
Version 1.0:
|
||||
1.3.0:
|
||||
Added SDL_GetNumVideoDrivers() and SDL_GetVideoDriver().
|
||||
Replaced SDL_VideoDriverName() with SDL_GetCurrentVideoDriver()
|
||||
Added SDL_GetNumAudioDrivers() and SDL_GetAudioDriver().
|
||||
Replaced SDL_AudioDriverName() with SDL_GetCurrentAudioDriver()
|
||||
|
||||
1.2.10:
|
||||
If SDL_OpenAudio() is passed zero for the desired format
|
||||
|
@ -416,8 +420,6 @@ Version 1.0:
|
|||
1.0.0:
|
||||
New public release
|
||||
|
||||
Version 0.11:
|
||||
|
||||
0.11.5:
|
||||
A new function SDL_GetVideoSurface() has been added, and returns
|
||||
a pointer to the current display surface.
|
||||
|
@ -436,8 +438,6 @@ Version 0.11:
|
|||
installing fatal signal handlers on operating systems that support
|
||||
them.
|
||||
|
||||
Version 0.9:
|
||||
|
||||
0.9.15:
|
||||
SDL_CreateColorCursor() has been removed. Color cursors should
|
||||
be implemented as sprites, blitted by the application when the
|
||||
|
|
76
configure.in
76
configure.in
|
@ -15,10 +15,10 @@ dnl Set various version strings - taken gratefully from the GTk sources
|
|||
# set SDL_BINARY_AGE and SDL_INTERFACE_AGE to 0.
|
||||
#
|
||||
SDL_MAJOR_VERSION=1
|
||||
SDL_MINOR_VERSION=2
|
||||
SDL_MICRO_VERSION=11
|
||||
SDL_MINOR_VERSION=3
|
||||
SDL_MICRO_VERSION=0
|
||||
SDL_INTERFACE_AGE=0
|
||||
SDL_BINARY_AGE=11
|
||||
SDL_BINARY_AGE=0
|
||||
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
|
||||
|
||||
AC_SUBST(SDL_MAJOR_VERSION)
|
||||
|
@ -1533,6 +1533,20 @@ CheckMacGL()
|
|||
fi
|
||||
}
|
||||
|
||||
dnl Find glSDL
|
||||
CheckglSDL()
|
||||
{
|
||||
AC_ARG_ENABLE(video-glsdl,
|
||||
[ --enable-video-glsdl use glSDL video driver [default=yes]],
|
||||
, enable_video_glsdl=yes)
|
||||
AC_MSG_CHECKING(for glSDL support)
|
||||
AC_MSG_RESULT($video_opengl)
|
||||
if test x$video_opengl = xyes -a x$enable_video_glsdl = xyes; then
|
||||
AC_DEFINE(SDL_VIDEO_DRIVER_GLSDL)
|
||||
SOURCES="$SOURCES $srcdir/src/video/glsdl/*.c"
|
||||
fi
|
||||
}
|
||||
|
||||
dnl Check for Mesa offscreen rendering
|
||||
CheckAtariOSMesa()
|
||||
{
|
||||
|
@ -1847,13 +1861,6 @@ AC_HELP_STRING([--enable-stdio-redirect], [Redirect STDIO to files on Win32 [[de
|
|||
if test x$enable_stdio_redirect != xyes; then
|
||||
EXTRA_CFLAGS="$EXTRA_CFLAGS -DNO_STDIO_REDIRECT"
|
||||
fi
|
||||
|
||||
if test x$enable_video = xyes; then
|
||||
AC_DEFINE(SDL_VIDEO_DRIVER_WINDIB)
|
||||
SOURCES="$SOURCES $srcdir/src/video/wincommon/*.c"
|
||||
SOURCES="$SOURCES $srcdir/src/video/windib/*.c"
|
||||
have_video=yes
|
||||
fi
|
||||
}
|
||||
|
||||
dnl Find the DirectX includes and libraries
|
||||
|
@ -1863,18 +1870,9 @@ CheckDIRECTX()
|
|||
AC_HELP_STRING([--enable-directx], [use DirectX for Win32 audio/video [[default=yes]]]),
|
||||
, enable_directx=yes)
|
||||
if test x$enable_directx = xyes; then
|
||||
have_directx=no
|
||||
AC_CHECK_HEADER(ddraw.h, have_ddraw=yes)
|
||||
AC_CHECK_HEADER(d3d9.h, have_d3d=yes)
|
||||
AC_CHECK_HEADER(dsound.h, have_dsound=yes)
|
||||
AC_CHECK_HEADER(dinput.h, use_dinput=yes)
|
||||
if test x$have_ddraw = xyes -a x$have_dsound = xyes -a x$use_dinput = xyes; then
|
||||
have_directx=yes
|
||||
fi
|
||||
if test x$enable_video = xyes -a x$have_directx = xyes; then
|
||||
AC_DEFINE(SDL_VIDEO_DRIVER_DDRAW)
|
||||
SOURCES="$SOURCES $srcdir/src/video/windx5/*.c"
|
||||
have_video=yes
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -2155,6 +2153,7 @@ case "$host" in
|
|||
CheckQtopia
|
||||
CheckPicoGUI
|
||||
CheckOpenGLX11
|
||||
CheckglSDL
|
||||
CheckInputEvents
|
||||
CheckTslib
|
||||
CheckUSBHID
|
||||
|
@ -2253,6 +2252,7 @@ case "$host" in
|
|||
CheckPHOTON
|
||||
CheckX11
|
||||
CheckOpenGLX11
|
||||
CheckglSDL
|
||||
CheckPTHREAD
|
||||
# Set up files for the audio library
|
||||
if test x$enable_audio = xyes; then
|
||||
|
@ -2290,13 +2290,32 @@ case "$host" in
|
|||
CheckDummyAudio
|
||||
CheckWIN32
|
||||
CheckWIN32GL
|
||||
CheckglSDL
|
||||
CheckDIRECTX
|
||||
CheckNASM
|
||||
# Set up files for the video library
|
||||
if test x$enable_video = xyes; then
|
||||
AC_DEFINE(SDL_VIDEO_DRIVER_WIN32)
|
||||
SOURCES="$SOURCES $srcdir/src/video/win32/*.c"
|
||||
have_video=yes
|
||||
AC_ARG_ENABLE(render-gdi,
|
||||
AC_HELP_STRING([--enable-render-gdi], [enable the GDI render driver [[default=yes]]]),
|
||||
, enable_render_gdi=yes)
|
||||
if test x$enable_render_gdi = xyes; then
|
||||
AC_DEFINE(SDL_VIDEO_RENDER_GDI)
|
||||
fi
|
||||
AC_ARG_ENABLE(render-d3d,
|
||||
AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[default=yes]]]),
|
||||
, enable_render_d3d=yes)
|
||||
if test x$enable_render_d3d = xyes -a x$have_d3d = xyes; then
|
||||
AC_DEFINE(SDL_VIDEO_RENDER_D3D)
|
||||
fi
|
||||
fi
|
||||
# Set up files for the audio library
|
||||
if test x$enable_audio = xyes; then
|
||||
AC_DEFINE(SDL_AUDIO_DRIVER_WAVEOUT)
|
||||
SOURCES="$SOURCES $srcdir/src/audio/windib/*.c"
|
||||
if test x$have_directx = xyes; then
|
||||
if test x$have_dsound = xyes; then
|
||||
AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND)
|
||||
SOURCES="$SOURCES $srcdir/src/audio/windx5/*.c"
|
||||
fi
|
||||
|
@ -2304,8 +2323,13 @@ case "$host" in
|
|||
fi
|
||||
# Set up files for the joystick library
|
||||
if test x$enable_joystick = xyes; then
|
||||
if test x$have_dinput = xyes; then
|
||||
AC_DEFINE(SDL_JOYSTICK_DINPUT)
|
||||
SOURCES="$SOURCES $srcdir/src/joystick/win32/SDL_dxjoystick.c"
|
||||
else
|
||||
AC_DEFINE(SDL_JOYSTICK_WINMM)
|
||||
SOURCES="$SOURCES $srcdir/src/joystick/win32/*.c"
|
||||
SOURCES="$SOURCES $srcdir/src/joystick/win32/SDL_mmjoystick.c"
|
||||
fi
|
||||
have_joystick=yes
|
||||
fi
|
||||
# Set up files for the cdrom library
|
||||
|
@ -2336,10 +2360,7 @@ case "$host" in
|
|||
have_loadso=yes
|
||||
fi
|
||||
# Set up the system libraries we need
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lwinmm"
|
||||
if test x$have_directx = xyes; then
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldxguid"
|
||||
fi
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lmsimg32 -lwinmm"
|
||||
# The Win32 platform requires special setup
|
||||
SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
|
||||
SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
|
||||
|
@ -2354,6 +2375,7 @@ case "$host" in
|
|||
CheckNASM
|
||||
CheckBWINDOW
|
||||
CheckBeGL
|
||||
CheckglSDL
|
||||
# Set up files for the audio library
|
||||
if test x$enable_audio = xyes; then
|
||||
AC_DEFINE(SDL_AUDIO_DRIVER_BAUDIO)
|
||||
|
@ -2435,6 +2457,7 @@ case "$host" in
|
|||
CheckX11
|
||||
CheckMacGL
|
||||
CheckOpenGLX11
|
||||
CheckglSDL
|
||||
CheckPTHREAD
|
||||
CheckAltivec
|
||||
|
||||
|
@ -2496,6 +2519,7 @@ case "$host" in
|
|||
CheckAtariAudio
|
||||
CheckAtariLdg
|
||||
CheckAtariOSMesa
|
||||
CheckglSDL
|
||||
CheckPTH
|
||||
# Set up files for the audio library
|
||||
if test x$enable_threads = xyes -a x$enable_pth = xyes; then
|
||||
|
|
58
docs.html
58
docs.html
|
@ -14,64 +14,6 @@ The latest stable release may be found on the
|
|||
|
||||
<H2> <A HREF="docs/index.html">API Documentation</A> </H2>
|
||||
|
||||
<H2> SDL 1.2.11 Release Notes </H2>
|
||||
<P>
|
||||
SDL 1.2.11 is a minor bug fix release.
|
||||
</P>
|
||||
|
||||
<H3> Unix Notes </H3>
|
||||
|
||||
<BLOCKQUOTE>
|
||||
<P>
|
||||
Dynamic X11 loading is only enabled with gcc 4 supporting -fvisibility=hidden. This fixes crashes related to symbol collisions, and allows building on Solaris and IRIX.
|
||||
</P>
|
||||
<P>
|
||||
Fixed building SDL with Xinerama disabled.
|
||||
</P>
|
||||
<P>
|
||||
Fixed DRI OpenGL library loading, using RTLD_GLOBAL in dlopen().
|
||||
</P>
|
||||
<P>
|
||||
Added pkgconfig configuration support.
|
||||
</P>
|
||||
</BLOCKQUOTE>
|
||||
|
||||
<H3> Windows Notes </H3>
|
||||
|
||||
<BLOCKQUOTE>
|
||||
<P>
|
||||
Setting SDL_GL_SWAP_CONTROL now works with Windows OpenGL.
|
||||
</P>
|
||||
<P>
|
||||
The Win32 window positioning code works properly for windows with menus.
|
||||
</P>
|
||||
<P>
|
||||
DirectSound audio quality has been improved on certain sound cards.
|
||||
</P>
|
||||
<P>
|
||||
Fixed 5.1 audio channel ordering on Windows and Mac OS X.
|
||||
</P>
|
||||
<P>
|
||||
Plugged a couple of minor memory leaks in the windib video driver.
|
||||
</P>
|
||||
<P>
|
||||
Fixed type collision with stdint.h when building with gcc on Win32.
|
||||
</P>
|
||||
<P>
|
||||
Fixed building with the Digital Mars Compiler on Win32.
|
||||
</P>
|
||||
</BLOCKQUOTE>
|
||||
|
||||
<H3> Mac OS X Notes </H3>
|
||||
|
||||
<BLOCKQUOTE>
|
||||
<P>
|
||||
The Quartz video driver supports 32x32 cursors on Mac OS X 10.3 and above.
|
||||
</P>
|
||||
</BLOCKQUOTE>
|
||||
|
||||
<IMG SRC="docs/images/rainbow.gif" ALT="[separator]" WIDTH="100%">
|
||||
|
||||
<H2> SDL 1.2.10 Release Notes </H2>
|
||||
<P>
|
||||
SDL 1.2.10 is a major release, featuring a revamp of the build system and many API improvements and bug fixes.
|
||||
|
|
|
@ -20,7 +20,56 @@
|
|||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* Main include header for the SDL library */
|
||||
/**
|
||||
* \file SDL.h
|
||||
*
|
||||
* Main include header for the SDL library
|
||||
*/
|
||||
/**
|
||||
* \mainpage Simple DirectMedia Layer (SDL)
|
||||
|
||||
http://www.libsdl.org/
|
||||
|
||||
* \section intro_sec Introduction
|
||||
|
||||
This is the Simple DirectMedia Layer, a general API that provides low
|
||||
level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL,
|
||||
and 2D framebuffer across multiple platforms.
|
||||
|
||||
The current version supports Linux, Windows, Windows CE, BeOS, MacOS,
|
||||
Mac OS X, FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, IRIX, and QNX.
|
||||
The code contains support for AmigaOS, Dreamcast, Atari, AIX, OSF/Tru64,
|
||||
RISC OS, SymbianOS, and OS/2, but these are not officially supported.
|
||||
|
||||
SDL is written in C, but works with C++ natively, and has bindings to
|
||||
several other languages, including Ada, C#, Eiffel, Erlang, Euphoria,
|
||||
Guile, Haskell, Java, Lisp, Lua, ML, Objective C, Pascal, Perl, PHP,
|
||||
Pike, Pliant, Python, Ruby, and Smalltalk.
|
||||
|
||||
This library is distributed under GNU LGPL version 2, which can be
|
||||
found in the file "COPYING". This license allows you to use SDL
|
||||
freely in commercial programs as long as you link with the dynamic
|
||||
library.
|
||||
|
||||
The best way to learn how to use SDL is to check out the header files in
|
||||
the "include" subdirectory and the programs in the "test" subdirectory.
|
||||
The header files and test programs are well commented and always up to date.
|
||||
More documentation is available in HTML format in "docs/index.html", and
|
||||
a documentation wiki is available online at:
|
||||
http://www.libsdl.org/cgi/docwiki.cgi
|
||||
|
||||
The test programs in the "test" subdirectory are in the public domain.
|
||||
|
||||
Frequently asked questions are answered online:
|
||||
http://www.libsdl.org/faq.php
|
||||
|
||||
If you need help with the library, or just want to discuss SDL related
|
||||
issues, you can join the developers mailing list:
|
||||
http://www.libsdl.org/mailing-list.php
|
||||
|
||||
Enjoy!
|
||||
Sam Lantinga (slouken@libsdl.org)
|
||||
*/
|
||||
|
||||
#ifndef _SDL_H
|
||||
#define _SDL_H
|
||||
|
@ -40,11 +89,14 @@
|
|||
#include "SDL_timer.h"
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_version.h"
|
||||
#include "SDL_compat.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* As of version 0.5, SDL is loaded dynamically into the application */
|
||||
|
@ -87,8 +139,12 @@ extern DECLSPEC void SDLCALL SDL_Quit(void);
|
|||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_H */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* Include file for SDL application focus event handling */
|
||||
|
||||
#ifndef _SDL_active_h
|
||||
#define _SDL_active_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* The available application states */
|
||||
#define SDL_APPMOUSEFOCUS 0x01 /* The app has mouse coverage */
|
||||
#define SDL_APPINPUTFOCUS 0x02 /* The app has input focus */
|
||||
#define SDL_APPACTIVE 0x04 /* The application is active */
|
||||
|
||||
/* Function prototypes */
|
||||
/*
|
||||
* This function returns the current state of the application, which is a
|
||||
* bitwise combination of SDL_APPMOUSEFOCUS, SDL_APPINPUTFOCUS, and
|
||||
* SDL_APPACTIVE. If SDL_APPACTIVE is set, then the user is able to
|
||||
* see your application, otherwise it has been iconified or disabled.
|
||||
*/
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_active_h */
|
|
@ -20,7 +20,11 @@
|
|||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* Access to the raw audio mixing buffer for the SDL library */
|
||||
/**
|
||||
* \file SDL_audio.h
|
||||
*
|
||||
* Access to the raw audio mixing buffer for the SDL library
|
||||
*/
|
||||
|
||||
#ifndef _SDL_audio_h
|
||||
#define _SDL_audio_h
|
||||
|
@ -35,11 +39,14 @@
|
|||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* The calculated values in this structure are calculated by SDL_OpenAudio() */
|
||||
typedef struct SDL_AudioSpec {
|
||||
typedef struct SDL_AudioSpec
|
||||
{
|
||||
int freq; /* DSP frequency -- samples per second */
|
||||
Uint16 format; /* Audio data format */
|
||||
Uint8 channels; /* Number of channels: 1 mono, 2 stereo */
|
||||
|
@ -78,7 +85,8 @@ typedef struct SDL_AudioSpec {
|
|||
|
||||
|
||||
/* A structure to hold a set of audio conversion filters and buffers */
|
||||
typedef struct SDL_AudioCVT {
|
||||
typedef struct SDL_AudioCVT
|
||||
{
|
||||
int needed; /* Set to 1 if conversion possible */
|
||||
Uint16 src_format; /* Source audio format */
|
||||
Uint16 dst_format; /* Target audio format */
|
||||
|
@ -95,6 +103,12 @@ typedef struct SDL_AudioCVT {
|
|||
|
||||
/* Function prototypes */
|
||||
|
||||
/* These functions return the list of built in video drivers, in the
|
||||
* order that they are normally initialized by default.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void);
|
||||
extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index);
|
||||
|
||||
/* These functions are used internally, and should not be used unless you
|
||||
* have a specific need to specify the audio driver you want to use.
|
||||
* You should normally use SDL_Init() or SDL_InitSubSystem().
|
||||
|
@ -102,11 +116,10 @@ typedef struct SDL_AudioCVT {
|
|||
extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name);
|
||||
extern DECLSPEC void SDLCALL SDL_AudioQuit(void);
|
||||
|
||||
/* This function fills the given character buffer with the name of the
|
||||
* current audio driver, and returns a pointer to it if the audio driver has
|
||||
* been initialized. It returns NULL if no driver has been initialized.
|
||||
/* This function returns the name of the current audio driver, or NULL
|
||||
* if no driver has been initialized.
|
||||
*/
|
||||
extern DECLSPEC char * SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen);
|
||||
extern DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver(void);
|
||||
|
||||
/*
|
||||
* This function opens the audio device with the desired parameters, and
|
||||
|
@ -149,12 +162,14 @@ extern DECLSPEC char * SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen);
|
|||
* may modify the requested size of the audio buffer, you should allocate
|
||||
* any local mixing buffers after you open the audio device.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained);
|
||||
extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec * desired,
|
||||
SDL_AudioSpec * obtained);
|
||||
|
||||
/*
|
||||
* Get the current audio state:
|
||||
*/
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
SDL_AUDIO_STOPPED = 0,
|
||||
SDL_AUDIO_PLAYING,
|
||||
SDL_AUDIO_PAUSED
|
||||
|
@ -187,7 +202,11 @@ extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on);
|
|||
* wave file cannot be opened, uses an unknown data format, or is
|
||||
* corrupt. Currently raw and MS-ADPCM WAVE files are supported.
|
||||
*/
|
||||
extern DECLSPEC SDL_AudioSpec * SDLCALL SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len);
|
||||
extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src,
|
||||
int freesrc,
|
||||
SDL_AudioSpec * spec,
|
||||
Uint8 ** audio_buf,
|
||||
Uint32 * audio_len);
|
||||
|
||||
/* Compatibility convenience function -- loads a WAV from a file */
|
||||
#define SDL_LoadWAV(file, spec, audio_buf, audio_len) \
|
||||
|
@ -206,8 +225,12 @@ extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 *audio_buf);
|
|||
* This function returns 0, or -1 if there was an error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
|
||||
Uint16 src_format, Uint8 src_channels, int src_rate,
|
||||
Uint16 dst_format, Uint8 dst_channels, int dst_rate);
|
||||
Uint16 src_format,
|
||||
Uint8 src_channels,
|
||||
int src_rate,
|
||||
Uint16 dst_format,
|
||||
Uint8 dst_channels,
|
||||
int dst_rate);
|
||||
|
||||
/* Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(),
|
||||
* created an audio buffer cvt->buf, and filled it with cvt->len bytes of
|
||||
|
@ -227,7 +250,8 @@ extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT *cvt);
|
|||
* This is provided for convenience -- you can mix your own audio data.
|
||||
*/
|
||||
#define SDL_MIX_MAXVOLUME 128
|
||||
extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 *dst, const Uint8 *src, Uint32 len, int volume);
|
||||
extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 * dst, const Uint8 * src,
|
||||
Uint32 len, int volume);
|
||||
|
||||
/*
|
||||
* The lock manipulated by these functions protects the callback function.
|
||||
|
@ -246,8 +270,12 @@ extern DECLSPEC void SDLCALL SDL_CloseAudio(void);
|
|||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_audio_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -20,7 +20,11 @@
|
|||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* This is the CD-audio control API for Simple DirectMedia Layer */
|
||||
/**
|
||||
* \file SDL_cdrom.h
|
||||
*
|
||||
* This is the CD-audio control API for Simple DirectMedia Layer
|
||||
*/
|
||||
|
||||
#ifndef _SDL_cdrom_h
|
||||
#define _SDL_cdrom_h
|
||||
|
@ -31,7 +35,9 @@
|
|||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* In order to use these functions, SDL_Init() must have been called
|
||||
|
@ -47,7 +53,8 @@ extern "C" {
|
|||
#define SDL_DATA_TRACK 0x04
|
||||
|
||||
/* The possible states which a CD-ROM drive can be in. */
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
CD_TRAYEMPTY,
|
||||
CD_STOPPED,
|
||||
CD_PLAYING,
|
||||
|
@ -58,7 +65,8 @@ typedef enum {
|
|||
/* Given a status, returns true if there's a disk in the drive */
|
||||
#define CD_INDRIVE(status) ((int)(status) > 0)
|
||||
|
||||
typedef struct SDL_CDtrack {
|
||||
typedef struct SDL_CDtrack
|
||||
{
|
||||
Uint8 id; /* Track number */
|
||||
Uint8 type; /* Data or audio track */
|
||||
Uint16 unused;
|
||||
|
@ -67,7 +75,8 @@ typedef struct SDL_CDtrack {
|
|||
} SDL_CDtrack;
|
||||
|
||||
/* This structure is only current as of the last call to SDL_CDStatus() */
|
||||
typedef struct SDL_CD {
|
||||
typedef struct SDL_CD
|
||||
{
|
||||
int id; /* Private drive identifier */
|
||||
CDstatus status; /* Current drive status */
|
||||
|
||||
|
@ -139,7 +148,9 @@ extern DECLSPEC CDstatus SDLCALL SDL_CDStatus(SDL_CD *cdrom);
|
|||
This function returns 0, or -1 if there was an error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_CDPlayTracks(SDL_CD * cdrom,
|
||||
int start_track, int start_frame, int ntracks, int nframes);
|
||||
int start_track,
|
||||
int start_frame, int ntracks,
|
||||
int nframes);
|
||||
|
||||
/* Play the given CD starting at 'start' frame for 'length' frames.
|
||||
It returns 0, or -1 if there was an error.
|
||||
|
@ -164,8 +175,12 @@ extern DECLSPEC void SDLCALL SDL_CDClose(SDL_CD *cdrom);
|
|||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_video_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
186
include/SDL_compat.h
Normal file
186
include/SDL_compat.h
Normal file
|
@ -0,0 +1,186 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* This file contains functions for backwards compatibility with SDL 1.2 */
|
||||
|
||||
#ifndef _SDL_compat_h
|
||||
#define _SDL_compat_h
|
||||
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_version.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
#define SDL_SWSURFACE 0x00000000
|
||||
#define SDL_ANYFORMAT 0x00100000
|
||||
#define SDL_HWPALETTE 0x00200000
|
||||
#define SDL_DOUBLEBUF 0x00400000
|
||||
#define SDL_FULLSCREEN 0x00800000
|
||||
#define SDL_RESIZABLE 0x01000000
|
||||
#define SDL_NOFRAME 0x02000000
|
||||
#define SDL_OPENGL 0x04000000
|
||||
#define SDL_ASYNCBLIT 0x08000000 /* Not used */
|
||||
#define SDL_HWACCEL 0x08000000 /* Not used */
|
||||
|
||||
#define SDL_APPMOUSEFOCUS 0x01
|
||||
#define SDL_APPINPUTFOCUS 0x02
|
||||
#define SDL_APPACTIVE 0x04
|
||||
|
||||
#define SDL_LOGPAL 0x01
|
||||
#define SDL_PHYSPAL 0x02
|
||||
|
||||
#define SDL_ACTIVEEVENT SDL_EVENT_RESERVED1
|
||||
#define SDL_VIDEORESIZE SDL_EVENT_RESERVED2
|
||||
#define SDL_VIDEOEXPOSE SDL_EVENT_RESERVED3
|
||||
#define SDL_ACTIVEEVENTMASK SDL_EVENTMASK(SDL_ACTIVEEVENT)
|
||||
#define SDL_VIDEORESIZEMASK SDL_EVENTMASK(SDL_VIDEORESIZE)
|
||||
#define SDL_VIDEOEXPOSEMASK SDL_EVENTMASK(SDL_VIDEOEXPOSE)
|
||||
|
||||
#define SDL_BUTTON_WHEELUP 4
|
||||
#define SDL_BUTTON_WHEELDOWN 5
|
||||
|
||||
typedef struct SDL_VideoInfo
|
||||
{
|
||||
Uint32 hw_available:1;
|
||||
Uint32 wm_available:1;
|
||||
Uint32 UnusedBits1:6;
|
||||
Uint32 UnusedBits2:1;
|
||||
Uint32 blit_hw:1;
|
||||
Uint32 blit_hw_CC:1;
|
||||
Uint32 blit_hw_A:1;
|
||||
Uint32 blit_sw:1;
|
||||
Uint32 blit_sw_CC:1;
|
||||
Uint32 blit_sw_A:1;
|
||||
Uint32 blit_fill:1;
|
||||
Uint32 UnusedBits3:16;
|
||||
Uint32 video_mem;
|
||||
|
||||
SDL_PixelFormat *vfmt;
|
||||
} SDL_VideoInfo;
|
||||
|
||||
/* The most common video overlay formats.
|
||||
For an explanation of these pixel formats, see:
|
||||
http://www.webartz.com/fourcc/indexyuv.htm
|
||||
|
||||
For information on the relationship between color spaces, see:
|
||||
http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html
|
||||
*/
|
||||
#define SDL_YV12_OVERLAY 0x32315659 /* Planar mode: Y + V + U (3 planes) */
|
||||
#define SDL_IYUV_OVERLAY 0x56555949 /* Planar mode: Y + U + V (3 planes) */
|
||||
#define SDL_YUY2_OVERLAY 0x32595559 /* Packed mode: Y0+U0+Y1+V0 (1 plane) */
|
||||
#define SDL_UYVY_OVERLAY 0x59565955 /* Packed mode: U0+Y0+V0+Y1 (1 plane) */
|
||||
#define SDL_YVYU_OVERLAY 0x55595659 /* Packed mode: Y0+V0+Y1+U0 (1 plane) */
|
||||
|
||||
/* The YUV hardware video overlay */
|
||||
typedef struct SDL_Overlay
|
||||
{
|
||||
Uint32 format; /* Read-only */
|
||||
int w, h; /* Read-only */
|
||||
int planes; /* Read-only */
|
||||
Uint16 *pitches; /* Read-only */
|
||||
Uint8 **pixels; /* Read-write */
|
||||
|
||||
/* Hardware-specific surface info */
|
||||
struct private_yuvhwfuncs *hwfuncs;
|
||||
struct private_yuvhwdata *hwdata;
|
||||
|
||||
/* Special flags */
|
||||
Uint32 hw_overlay:1; /* Flag: This overlay hardware accelerated? */
|
||||
Uint32 UnusedBits:31;
|
||||
} SDL_Overlay;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SDL_GRAB_QUERY = -1,
|
||||
SDL_GRAB_OFF = 0,
|
||||
SDL_GRAB_ON = 1
|
||||
} SDL_GrabMode;
|
||||
|
||||
struct SDL_SysWMinfo;
|
||||
|
||||
#define SDL_SetModuleHandle(x)
|
||||
#define SDL_AllocSurface SDL_CreateRGBSurface
|
||||
|
||||
extern DECLSPEC const SDL_version *SDLCALL SDL_Linked_Version(void);
|
||||
extern DECLSPEC char *SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen);
|
||||
extern DECLSPEC char *SDLCALL SDL_VideoDriverName(char *namebuf, int maxlen);
|
||||
extern DECLSPEC const SDL_VideoInfo *SDLCALL SDL_GetVideoInfo(void);
|
||||
extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width, int height, int bpp,
|
||||
Uint32 flags);
|
||||
extern DECLSPEC SDL_Rect **SDLCALL SDL_ListModes(SDL_PixelFormat * format,
|
||||
Uint32 flags);
|
||||
extern DECLSPEC SDL_Surface *SDLCALL SDL_SetVideoMode(int width, int height,
|
||||
int bpp, Uint32 flags);
|
||||
extern DECLSPEC SDL_Surface *SDLCALL SDL_GetVideoSurface(void);
|
||||
extern DECLSPEC void SDLCALL SDL_UpdateRects(SDL_Surface * screen,
|
||||
int numrects, SDL_Rect * rects);
|
||||
extern DECLSPEC void SDLCALL SDL_UpdateRect(SDL_Surface * screen, Sint32 x,
|
||||
Sint32 y, Uint32 w, Uint32 h);
|
||||
extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface * screen);
|
||||
extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormat(SDL_Surface * surface);
|
||||
extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormatAlpha(SDL_Surface *
|
||||
surface);
|
||||
extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title,
|
||||
const char *icon);
|
||||
extern DECLSPEC void SDLCALL SDL_WM_GetCaption(char **title, char **icon);
|
||||
extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask);
|
||||
extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void);
|
||||
extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen(SDL_Surface * surface);
|
||||
extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode);
|
||||
extern DECLSPEC int SDLCALL SDL_SetPalette(SDL_Surface * surface, int flags,
|
||||
const SDL_Color * colors,
|
||||
int firstcolor, int ncolors);
|
||||
extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface * surface,
|
||||
const SDL_Color * colors,
|
||||
int firstcolor, int ncolors);
|
||||
extern DECLSPEC int SDLCALL SDL_GetWMInfo(struct SDL_SysWMinfo *info);
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void);
|
||||
extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y);
|
||||
extern DECLSPEC SDL_Overlay *SDLCALL SDL_CreateYUVOverlay(int width,
|
||||
int height,
|
||||
Uint32 format,
|
||||
SDL_Surface *
|
||||
display);
|
||||
extern DECLSPEC int SDLCALL SDL_LockYUVOverlay(SDL_Overlay * overlay);
|
||||
extern DECLSPEC void SDLCALL SDL_UnlockYUVOverlay(SDL_Overlay * overlay);
|
||||
extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay * overlay,
|
||||
SDL_Rect * dstrect);
|
||||
extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay * overlay);
|
||||
extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_compat_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -198,6 +198,7 @@
|
|||
#undef SDL_JOYSTICK_AMIGA
|
||||
#undef SDL_JOYSTICK_BEOS
|
||||
#undef SDL_JOYSTICK_DC
|
||||
#undef SDL_JOYSTICK_DINPUT
|
||||
#undef SDL_JOYSTICK_DUMMY
|
||||
#undef SDL_JOYSTICK_IOKIT
|
||||
#undef SDL_JOYSTICK_LINUX
|
||||
|
@ -252,7 +253,6 @@
|
|||
#undef SDL_VIDEO_DRIVER_BWINDOW
|
||||
#undef SDL_VIDEO_DRIVER_CYBERGRAPHICS
|
||||
#undef SDL_VIDEO_DRIVER_DC
|
||||
#undef SDL_VIDEO_DRIVER_DDRAW
|
||||
#undef SDL_VIDEO_DRIVER_DGA
|
||||
#undef SDL_VIDEO_DRIVER_DIRECTFB
|
||||
#undef SDL_VIDEO_DRIVER_DRAWSPROCKET
|
||||
|
@ -262,6 +262,7 @@
|
|||
#undef SDL_VIDEO_DRIVER_GAPI
|
||||
#undef SDL_VIDEO_DRIVER_GEM
|
||||
#undef SDL_VIDEO_DRIVER_GGI
|
||||
#undef SDL_VIDEO_DRIVER_GLSDL
|
||||
#undef SDL_VIDEO_DRIVER_IPOD
|
||||
#undef SDL_VIDEO_DRIVER_NANOX
|
||||
#undef SDL_VIDEO_DRIVER_OS2FS
|
||||
|
@ -274,7 +275,7 @@
|
|||
#undef SDL_VIDEO_DRIVER_SVGALIB
|
||||
#undef SDL_VIDEO_DRIVER_TOOLBOX
|
||||
#undef SDL_VIDEO_DRIVER_VGL
|
||||
#undef SDL_VIDEO_DRIVER_WINDIB
|
||||
#undef SDL_VIDEO_DRIVER_WIN32
|
||||
#undef SDL_VIDEO_DRIVER_WSCONS
|
||||
#undef SDL_VIDEO_DRIVER_X11
|
||||
#undef SDL_VIDEO_DRIVER_X11_DGAMOUSE
|
||||
|
@ -290,6 +291,10 @@
|
|||
#undef SDL_VIDEO_DRIVER_X11_XV
|
||||
#undef SDL_VIDEO_DRIVER_XBIOS
|
||||
|
||||
#undef SDL_VIDEO_RENDER_D3D
|
||||
#undef SDL_VIDEO_RENDER_GDI
|
||||
#undef SDL_VIDEO_RENDER_OGL
|
||||
|
||||
/* Enable OpenGL support */
|
||||
#undef SDL_VIDEO_OPENGL
|
||||
#undef SDL_VIDEO_OPENGL_GLX
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
/* Enable various video drivers */
|
||||
#define SDL_VIDEO_DRIVER_CYBERGRAPHICS 1
|
||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
||||
#define SDL_VIDEO_DRIVER_GLSDL 1
|
||||
|
||||
/* Enable OpenGL support */
|
||||
#define SDL_VIDEO_OPENGL 1
|
||||
|
|
|
@ -102,5 +102,6 @@ typedef unsigned long uintptr_t;
|
|||
/* Enable various video drivers */
|
||||
#define SDL_VIDEO_DRIVER_DC 1
|
||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
||||
#define SDL_VIDEO_DRIVER_GLSDL 1
|
||||
|
||||
#endif /* _SDL_config_dreamcast_h */
|
||||
|
|
|
@ -104,6 +104,7 @@ typedef unsigned long uintptr_t;
|
|||
/* Enable various video drivers */
|
||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
||||
#define SDL_VIDEO_DRIVER_DRAWSPROCKET 1
|
||||
#define SDL_VIDEO_DRIVER_GLSDL 1
|
||||
#define SDL_VIDEO_DRIVER_TOOLBOX 1
|
||||
|
||||
/* Enable OpenGL support */
|
||||
|
|
|
@ -150,19 +150,17 @@ typedef unsigned int uintptr_t;
|
|||
#endif
|
||||
|
||||
/* Enable various video drivers */
|
||||
#ifdef _WIN32_WCE
|
||||
#define SDL_VIDEO_DRIVER_GAPI 1
|
||||
#endif
|
||||
#ifndef _WIN32_WCE
|
||||
#define SDL_VIDEO_DRIVER_DDRAW 1
|
||||
#endif
|
||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
||||
#define SDL_VIDEO_DRIVER_WINDIB 1
|
||||
#define SDL_VIDEO_DRIVER_WIN32 1
|
||||
|
||||
#define SDL_VIDEO_RENDER_D3D 1
|
||||
#define SDL_VIDEO_RENDER_GDI 1
|
||||
|
||||
/* Enable OpenGL support */
|
||||
#ifndef _WIN32_WCE
|
||||
#define SDL_VIDEO_OPENGL 1
|
||||
#define SDL_VIDEO_OPENGL_WGL 1
|
||||
#define SDL_VIDEO_RENDER_OGL 1
|
||||
#endif
|
||||
|
||||
/* Enable assembly routines (Win64 doesn't have inline asm) */
|
||||
|
|
|
@ -19,4 +19,3 @@
|
|||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
|
|
|
@ -20,8 +20,11 @@
|
|||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
/* CPU feature detection for SDL */
|
||||
/**
|
||||
* \file SDL_cpuinfo.h
|
||||
*
|
||||
* CPU feature detection for SDL
|
||||
*/
|
||||
|
||||
#ifndef _SDL_cpuinfo_h
|
||||
#define _SDL_cpuinfo_h
|
||||
|
@ -31,7 +34,9 @@
|
|||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* This function returns true if the CPU has the RDTSC instruction
|
||||
|
@ -68,8 +73,12 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void);
|
|||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_cpuinfo_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -20,7 +20,11 @@
|
|||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* Functions for reading and writing endian-specific values */
|
||||
/**
|
||||
* \file SDL_endian.h
|
||||
*
|
||||
* Functions for reading and writing endian-specific values
|
||||
*/
|
||||
|
||||
#ifndef _SDL_endian_h
|
||||
#define _SDL_endian_h
|
||||
|
@ -47,7 +51,9 @@
|
|||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* Use inline functions for compilers that support them, and static
|
||||
|
@ -57,19 +63,22 @@ extern "C" {
|
|||
*/
|
||||
#if defined(__GNUC__) && defined(__i386__) && \
|
||||
!(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */)
|
||||
static __inline__ Uint16 SDL_Swap16(Uint16 x)
|
||||
static __inline__ Uint16
|
||||
SDL_Swap16(Uint16 x)
|
||||
{
|
||||
__asm__("xchgb %b0,%h0": "=q"(x):"0"(x));
|
||||
return x;
|
||||
}
|
||||
#elif defined(__GNUC__) && defined(__x86_64__)
|
||||
static __inline__ Uint16 SDL_Swap16(Uint16 x)
|
||||
static __inline__ Uint16
|
||||
SDL_Swap16(Uint16 x)
|
||||
{
|
||||
__asm__("xchgb %b0,%h0": "=Q"(x):"0"(x));
|
||||
return x;
|
||||
}
|
||||
#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
|
||||
static __inline__ Uint16 SDL_Swap16(Uint16 x)
|
||||
static __inline__ Uint16
|
||||
SDL_Swap16(Uint16 x)
|
||||
{
|
||||
Uint16 result;
|
||||
|
||||
|
@ -77,31 +86,37 @@ static __inline__ Uint16 SDL_Swap16(Uint16 x)
|
|||
return result;
|
||||
}
|
||||
#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__))
|
||||
static __inline__ Uint16 SDL_Swap16(Uint16 x)
|
||||
static __inline__ Uint16
|
||||
SDL_Swap16(Uint16 x)
|
||||
{
|
||||
__asm__("rorw #8,%0": "=d"(x): "0"(x):"cc");
|
||||
return x;
|
||||
}
|
||||
#else
|
||||
static __inline__ Uint16 SDL_Swap16(Uint16 x) {
|
||||
static __inline__ Uint16
|
||||
SDL_Swap16(Uint16 x)
|
||||
{
|
||||
return ((x << 8) | (x >> 8));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && defined(__i386__)
|
||||
static __inline__ Uint32 SDL_Swap32(Uint32 x)
|
||||
static __inline__ Uint32
|
||||
SDL_Swap32(Uint32 x)
|
||||
{
|
||||
__asm__("bswap %0": "=r"(x):"0"(x));
|
||||
return x;
|
||||
}
|
||||
#elif defined(__GNUC__) && defined(__x86_64__)
|
||||
static __inline__ Uint32 SDL_Swap32(Uint32 x)
|
||||
static __inline__ Uint32
|
||||
SDL_Swap32(Uint32 x)
|
||||
{
|
||||
__asm__("bswapl %0": "=r"(x):"0"(x));
|
||||
return x;
|
||||
}
|
||||
#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
|
||||
static __inline__ Uint32 SDL_Swap32(Uint32 x)
|
||||
static __inline__ Uint32
|
||||
SDL_Swap32(Uint32 x)
|
||||
{
|
||||
Uint32 result;
|
||||
|
||||
|
@ -111,39 +126,50 @@ static __inline__ Uint32 SDL_Swap32(Uint32 x)
|
|||
return result;
|
||||
}
|
||||
#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__))
|
||||
static __inline__ Uint32 SDL_Swap32(Uint32 x)
|
||||
static __inline__ Uint32
|
||||
SDL_Swap32(Uint32 x)
|
||||
{
|
||||
__asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0": "=d"(x): "0"(x):"cc");
|
||||
return x;
|
||||
}
|
||||
#else
|
||||
static __inline__ Uint32 SDL_Swap32(Uint32 x) {
|
||||
return((x<<24)|((x<<8)&0x00FF0000)|((x>>8)&0x0000FF00)|(x>>24));
|
||||
static __inline__ Uint32
|
||||
SDL_Swap32(Uint32 x)
|
||||
{
|
||||
return ((x << 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) |
|
||||
(x >> 24));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDL_HAS_64BIT_TYPE
|
||||
#if defined(__GNUC__) && defined(__i386__)
|
||||
static __inline__ Uint64 SDL_Swap64(Uint64 x)
|
||||
static __inline__ Uint64
|
||||
SDL_Swap64(Uint64 x)
|
||||
{
|
||||
union {
|
||||
struct { Uint32 a,b; } s;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
Uint32 a, b;
|
||||
} s;
|
||||
Uint64 u;
|
||||
} v;
|
||||
v.u = x;
|
||||
__asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1"
|
||||
: "=r" (v.s.a), "=r" (v.s.b)
|
||||
: "0" (v.s.a), "1" (v.s.b));
|
||||
__asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1": "=r"(v.s.a), "=r"(v.s.b):"0"(v.s.a),
|
||||
"1"(v.s.
|
||||
b));
|
||||
return v.u;
|
||||
}
|
||||
#elif defined(__GNUC__) && defined(__x86_64__)
|
||||
static __inline__ Uint64 SDL_Swap64(Uint64 x)
|
||||
static __inline__ Uint64
|
||||
SDL_Swap64(Uint64 x)
|
||||
{
|
||||
__asm__("bswapq %0": "=r"(x):"0"(x));
|
||||
return x;
|
||||
}
|
||||
#else
|
||||
static __inline__ Uint64 SDL_Swap64(Uint64 x)
|
||||
static __inline__ Uint64
|
||||
SDL_Swap64(Uint64 x)
|
||||
{
|
||||
Uint32 hi, lo;
|
||||
|
||||
|
@ -185,8 +211,12 @@ static __inline__ Uint64 SDL_Swap64(Uint64 x)
|
|||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_endian_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -20,7 +20,10 @@
|
|||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* Simple error message routines for SDL */
|
||||
/**
|
||||
* \file SDL_error.h
|
||||
* Simple error message routines for SDL
|
||||
*/
|
||||
|
||||
#ifndef _SDL_error_h
|
||||
#define _SDL_error_h
|
||||
|
@ -30,7 +33,9 @@
|
|||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* Public functions */
|
||||
|
@ -41,7 +46,8 @@ extern DECLSPEC void SDLCALL SDL_ClearError(void);
|
|||
/* Private error message function - used internally */
|
||||
#define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM)
|
||||
#define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED)
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
SDL_ENOMEM,
|
||||
SDL_EFREAD,
|
||||
SDL_EFWRITE,
|
||||
|
@ -54,8 +60,12 @@ extern DECLSPEC void SDLCALL SDL_Error(SDL_errorcode code);
|
|||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_error_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -20,14 +20,18 @@
|
|||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* Include file for SDL event handling */
|
||||
/**
|
||||
* \file SDL_events.h
|
||||
*
|
||||
* Include file for SDL event handling
|
||||
*/
|
||||
|
||||
#ifndef _SDL_events_h
|
||||
#define _SDL_events_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_active.h"
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_keyboard.h"
|
||||
#include "SDL_mouse.h"
|
||||
#include "SDL_joystick.h"
|
||||
|
@ -36,39 +40,41 @@
|
|||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* General keyboard/mouse state definitions */
|
||||
#define SDL_RELEASED 0
|
||||
#define SDL_PRESSED 1
|
||||
|
||||
/* Event enumerations */
|
||||
typedef enum {
|
||||
SDL_NOEVENT = 0, /* Unused (do not remove) */
|
||||
SDL_ACTIVEEVENT, /* Application loses/gains visibility */
|
||||
SDL_KEYDOWN, /* Keys pressed */
|
||||
SDL_KEYUP, /* Keys released */
|
||||
SDL_MOUSEMOTION, /* Mouse moved */
|
||||
SDL_MOUSEBUTTONDOWN, /* Mouse button pressed */
|
||||
SDL_MOUSEBUTTONUP, /* Mouse button released */
|
||||
SDL_JOYAXISMOTION, /* Joystick axis motion */
|
||||
SDL_JOYBALLMOTION, /* Joystick trackball motion */
|
||||
SDL_JOYHATMOTION, /* Joystick hat position change */
|
||||
SDL_JOYBUTTONDOWN, /* Joystick button pressed */
|
||||
SDL_JOYBUTTONUP, /* Joystick button released */
|
||||
SDL_QUIT, /* User-requested quit */
|
||||
SDL_SYSWMEVENT, /* System specific event */
|
||||
SDL_EVENT_RESERVEDA, /* Reserved for future use.. */
|
||||
SDL_EVENT_RESERVEDB, /* Reserved for future use.. */
|
||||
SDL_VIDEORESIZE, /* User resized video mode */
|
||||
SDL_VIDEOEXPOSE, /* Screen needs to be redrawn */
|
||||
SDL_EVENT_RESERVED2, /* Reserved for future use.. */
|
||||
SDL_EVENT_RESERVED3, /* Reserved for future use.. */
|
||||
SDL_EVENT_RESERVED4, /* Reserved for future use.. */
|
||||
SDL_EVENT_RESERVED5, /* Reserved for future use.. */
|
||||
SDL_EVENT_RESERVED6, /* Reserved for future use.. */
|
||||
SDL_EVENT_RESERVED7, /* Reserved for future use.. */
|
||||
/**
|
||||
* \enum SDL_EventType
|
||||
*
|
||||
* \brief The types of events that can be delivered
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_NOEVENT = 0, /**< Unused (do not remove) */
|
||||
SDL_WINDOWEVENT, /**< Window state change */
|
||||
SDL_KEYDOWN, /**< Keys pressed */
|
||||
SDL_KEYUP, /**< Keys released */
|
||||
SDL_TEXTINPUT, /**< Keyboard text input */
|
||||
SDL_MOUSEMOTION, /**< Mouse moved */
|
||||
SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */
|
||||
SDL_MOUSEBUTTONUP, /**< Mouse button released */
|
||||
SDL_MOUSEWHEEL, /**< Mouse wheel motion */
|
||||
SDL_JOYAXISMOTION, /**< Joystick axis motion */
|
||||
SDL_JOYBALLMOTION, /**< Joystick trackball motion */
|
||||
SDL_JOYHATMOTION, /**< Joystick hat position change */
|
||||
SDL_JOYBUTTONDOWN, /**< Joystick button pressed */
|
||||
SDL_JOYBUTTONUP, /**< Joystick button released */
|
||||
SDL_QUIT, /**< User-requested quit */
|
||||
SDL_SYSWMEVENT, /**< System specific event */
|
||||
SDL_EVENT_RESERVED1, /**< Reserved for future use... */
|
||||
SDL_EVENT_RESERVED2, /**< Reserved for future use... */
|
||||
SDL_EVENT_RESERVED3, /**< Reserved for future use... */
|
||||
/* Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use */
|
||||
SDL_USEREVENT = 24,
|
||||
/* This last event is only for bounding internal arrays
|
||||
|
@ -77,20 +83,25 @@ typedef enum {
|
|||
SDL_NUMEVENTS = 32
|
||||
} SDL_EventType;
|
||||
|
||||
/* Predefined event masks */
|
||||
/**
|
||||
* \enum SDL_EventMask
|
||||
*
|
||||
* \brief Predefined event masks
|
||||
*/
|
||||
#define SDL_EVENTMASK(X) (1<<(X))
|
||||
typedef enum {
|
||||
SDL_ACTIVEEVENTMASK = SDL_EVENTMASK(SDL_ACTIVEEVENT),
|
||||
typedef enum
|
||||
{
|
||||
SDL_WINDOWEVENTMASK = SDL_EVENTMASK(SDL_WINDOWEVENT),
|
||||
SDL_KEYDOWNMASK = SDL_EVENTMASK(SDL_KEYDOWN),
|
||||
SDL_KEYUPMASK = SDL_EVENTMASK(SDL_KEYUP),
|
||||
SDL_KEYEVENTMASK = SDL_EVENTMASK(SDL_KEYDOWN)|
|
||||
SDL_EVENTMASK(SDL_KEYUP),
|
||||
SDL_KEYEVENTMASK = SDL_EVENTMASK(SDL_KEYDOWN) | SDL_EVENTMASK(SDL_KEYUP),
|
||||
SDL_TEXTINPUTMASK = SDL_EVENTMASK(SDL_TEXTINPUT),
|
||||
SDL_MOUSEMOTIONMASK = SDL_EVENTMASK(SDL_MOUSEMOTION),
|
||||
SDL_MOUSEBUTTONDOWNMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN),
|
||||
SDL_MOUSEBUTTONUPMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONUP),
|
||||
SDL_MOUSEWHEELMASK = SDL_EVENTMASK(SDL_MOUSEWHEEL),
|
||||
SDL_MOUSEEVENTMASK = SDL_EVENTMASK(SDL_MOUSEMOTION) |
|
||||
SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN)|
|
||||
SDL_EVENTMASK(SDL_MOUSEBUTTONUP),
|
||||
SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN) | SDL_EVENTMASK(SDL_MOUSEBUTTONUP),
|
||||
SDL_JOYAXISMOTIONMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION),
|
||||
SDL_JOYBALLMOTIONMASK = SDL_EVENTMASK(SDL_JOYBALLMOTION),
|
||||
SDL_JOYHATMOTIONMASK = SDL_EVENTMASK(SDL_JOYHATMOTION),
|
||||
|
@ -99,72 +110,137 @@ typedef enum {
|
|||
SDL_JOYEVENTMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION) |
|
||||
SDL_EVENTMASK(SDL_JOYBALLMOTION) |
|
||||
SDL_EVENTMASK(SDL_JOYHATMOTION) |
|
||||
SDL_EVENTMASK(SDL_JOYBUTTONDOWN)|
|
||||
SDL_EVENTMASK(SDL_JOYBUTTONUP),
|
||||
SDL_VIDEORESIZEMASK = SDL_EVENTMASK(SDL_VIDEORESIZE),
|
||||
SDL_VIDEOEXPOSEMASK = SDL_EVENTMASK(SDL_VIDEOEXPOSE),
|
||||
SDL_EVENTMASK(SDL_JOYBUTTONDOWN) | SDL_EVENTMASK(SDL_JOYBUTTONUP),
|
||||
SDL_QUITMASK = SDL_EVENTMASK(SDL_QUIT),
|
||||
SDL_SYSWMEVENTMASK = SDL_EVENTMASK(SDL_SYSWMEVENT)
|
||||
} SDL_EventMask;
|
||||
#define SDL_ALLEVENTS 0xFFFFFFFF
|
||||
|
||||
/* Application visibility event structure */
|
||||
typedef struct SDL_ActiveEvent {
|
||||
Uint8 type; /* SDL_ACTIVEEVENT */
|
||||
Uint8 gain; /* Whether given states were gained or lost (1/0) */
|
||||
Uint8 state; /* A mask of the focus states */
|
||||
} SDL_ActiveEvent;
|
||||
/**
|
||||
* \struct SDL_WindowEvent
|
||||
*
|
||||
* \brief Window state change event data
|
||||
*/
|
||||
typedef struct SDL_WindowEvent
|
||||
{
|
||||
Uint8 type; /**< SDL_WINDOWEVENT */
|
||||
Uint8 event; /**< SDL_WindowEventID */
|
||||
int data1; /**< event dependent data */
|
||||
int data2; /**< event dependent data */
|
||||
SDL_WindowID windowID; /**< The associated window */
|
||||
} SDL_WindowEvent;
|
||||
|
||||
/* Keyboard event structure */
|
||||
typedef struct SDL_KeyboardEvent {
|
||||
Uint8 type; /* SDL_KEYDOWN or SDL_KEYUP */
|
||||
Uint8 which; /* The keyboard device index */
|
||||
Uint8 state; /* SDL_PRESSED or SDL_RELEASED */
|
||||
SDL_keysym keysym;
|
||||
/**
|
||||
* \struct SDL_KeyboardEvent
|
||||
*
|
||||
* \brief Keyboard button event structure
|
||||
*/
|
||||
typedef struct SDL_KeyboardEvent
|
||||
{
|
||||
Uint8 type; /**< SDL_KEYDOWN or SDL_KEYUP */
|
||||
Uint8 which; /**< The keyboard device index */
|
||||
Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
|
||||
SDL_keysym keysym; /**< The key that was pressed or released */
|
||||
SDL_WindowID windowID; /**< The window with keyboard focus, if any */
|
||||
} SDL_KeyboardEvent;
|
||||
|
||||
/* Mouse motion event structure */
|
||||
typedef struct SDL_MouseMotionEvent {
|
||||
Uint8 type; /* SDL_MOUSEMOTION */
|
||||
Uint8 which; /* The mouse device index */
|
||||
Uint8 state; /* The current button state */
|
||||
Uint16 x, y; /* The X/Y coordinates of the mouse */
|
||||
Sint16 xrel; /* The relative motion in the X direction */
|
||||
Sint16 yrel; /* The relative motion in the Y direction */
|
||||
/**
|
||||
* \struct SDL_TextInputEvent
|
||||
*
|
||||
* \brief Keyboard text input event structure
|
||||
*/
|
||||
typedef struct SDL_TextInputEvent
|
||||
{
|
||||
Uint8 type; /**< SDL_TEXTINPUT */
|
||||
Uint8 which; /**< The keyboard device index */
|
||||
char text[32]; /**< The input text */
|
||||
SDL_WindowID windowID; /**< The window with keyboard focus, if any */
|
||||
} SDL_TextInputEvent;
|
||||
|
||||
/**
|
||||
* \struct SDL_MouseMotionEvent
|
||||
*
|
||||
* \brief Mouse motion event structure
|
||||
*/
|
||||
typedef struct SDL_MouseMotionEvent
|
||||
{
|
||||
Uint8 type; /**< SDL_MOUSEMOTION */
|
||||
Uint8 which; /**< The mouse device index */
|
||||
Uint8 state; /**< The current button state */
|
||||
int x; /**< X coordinate, relative to window */
|
||||
int y; /**< Y coordinate, relative to window */
|
||||
int xrel; /**< The relative motion in the X direction */
|
||||
int yrel; /**< The relative motion in the Y direction */
|
||||
SDL_WindowID windowID; /**< The window with mouse focus, if any */
|
||||
} SDL_MouseMotionEvent;
|
||||
|
||||
/* Mouse button event structure */
|
||||
typedef struct SDL_MouseButtonEvent {
|
||||
Uint8 type; /* SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */
|
||||
Uint8 which; /* The mouse device index */
|
||||
Uint8 button; /* The mouse button index */
|
||||
Uint8 state; /* SDL_PRESSED or SDL_RELEASED */
|
||||
Uint16 x, y; /* The X/Y coordinates of the mouse at press time */
|
||||
/**
|
||||
* \struct SDL_MouseButtonEvent
|
||||
*
|
||||
* \brief Mouse button event structure
|
||||
*/
|
||||
typedef struct SDL_MouseButtonEvent
|
||||
{
|
||||
Uint8 type; /**< SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */
|
||||
Uint8 which; /**< The mouse device index */
|
||||
Uint8 button; /**< The mouse button index */
|
||||
Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
|
||||
int x; /**< X coordinate, relative to window */
|
||||
int y; /**< Y coordinate, relative to window */
|
||||
SDL_WindowID windowID; /**< The window with mouse focus, if any */
|
||||
} SDL_MouseButtonEvent;
|
||||
|
||||
/* Joystick axis motion event structure */
|
||||
typedef struct SDL_JoyAxisEvent {
|
||||
Uint8 type; /* SDL_JOYAXISMOTION */
|
||||
Uint8 which; /* The joystick device index */
|
||||
Uint8 axis; /* The joystick axis index */
|
||||
Sint16 value; /* The axis value (range: -32768 to 32767) */
|
||||
/**
|
||||
* \struct SDL_MouseWheelEvent
|
||||
*
|
||||
* \brief Mouse wheel event structure
|
||||
*/
|
||||
typedef struct SDL_MouseWheelEvent
|
||||
{
|
||||
Uint8 type; /**< SDL_MOUSEWHEEL */
|
||||
Uint8 which; /**< The mouse device index */
|
||||
int motion; /**< The direction and distance scrolled */
|
||||
SDL_WindowID windowID; /**< The window with mouse focus, if any */
|
||||
} SDL_MouseWheelEvent;
|
||||
|
||||
/**
|
||||
* \struct SDL_JoyAxisEvent
|
||||
*
|
||||
* \brief Joystick axis motion event structure
|
||||
*/
|
||||
typedef struct SDL_JoyAxisEvent
|
||||
{
|
||||
Uint8 type; /**< SDL_JOYAXISMOTION */
|
||||
Uint8 which; /**< The joystick device index */
|
||||
Uint8 axis; /**< The joystick axis index */
|
||||
int value; /**< The axis value (range: -32768 to 32767) */
|
||||
} SDL_JoyAxisEvent;
|
||||
|
||||
/* Joystick trackball motion event structure */
|
||||
typedef struct SDL_JoyBallEvent {
|
||||
Uint8 type; /* SDL_JOYBALLMOTION */
|
||||
Uint8 which; /* The joystick device index */
|
||||
Uint8 ball; /* The joystick trackball index */
|
||||
Sint16 xrel; /* The relative motion in the X direction */
|
||||
Sint16 yrel; /* The relative motion in the Y direction */
|
||||
/**
|
||||
* \struct SDL_JoyBallEvent
|
||||
*
|
||||
* \brief Joystick trackball motion event structure
|
||||
*/
|
||||
typedef struct SDL_JoyBallEvent
|
||||
{
|
||||
Uint8 type; /**< SDL_JOYBALLMOTION */
|
||||
Uint8 which; /**< The joystick device index */
|
||||
Uint8 ball; /**< The joystick trackball index */
|
||||
int xrel; /**< The relative motion in the X direction */
|
||||
int yrel; /**< The relative motion in the Y direction */
|
||||
} SDL_JoyBallEvent;
|
||||
|
||||
/* Joystick hat position change event structure */
|
||||
typedef struct SDL_JoyHatEvent {
|
||||
Uint8 type; /* SDL_JOYHATMOTION */
|
||||
Uint8 which; /* The joystick device index */
|
||||
Uint8 hat; /* The joystick hat index */
|
||||
Uint8 value; /* The hat position value:
|
||||
/**
|
||||
* \struct SDL_JoyHatEvent
|
||||
*
|
||||
* \brief Joystick hat position change event structure
|
||||
*/
|
||||
typedef struct SDL_JoyHatEvent
|
||||
{
|
||||
Uint8 type; /**< SDL_JOYHATMOTION */
|
||||
Uint8 which; /**< The joystick device index */
|
||||
Uint8 hat; /**< The joystick hat index */
|
||||
Uint8 value; /**< The hat position value:
|
||||
SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP
|
||||
SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT
|
||||
SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN
|
||||
|
@ -172,66 +248,96 @@ typedef struct SDL_JoyHatEvent {
|
|||
*/
|
||||
} SDL_JoyHatEvent;
|
||||
|
||||
/* Joystick button event structure */
|
||||
typedef struct SDL_JoyButtonEvent {
|
||||
Uint8 type; /* SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP */
|
||||
Uint8 which; /* The joystick device index */
|
||||
Uint8 button; /* The joystick button index */
|
||||
Uint8 state; /* SDL_PRESSED or SDL_RELEASED */
|
||||
/**
|
||||
* \struct SDL_JoyButtonEvent
|
||||
*
|
||||
* \brief Joystick button event structure
|
||||
*/
|
||||
typedef struct SDL_JoyButtonEvent
|
||||
{
|
||||
Uint8 type; /**< SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP */
|
||||
Uint8 which; /**< The joystick device index */
|
||||
Uint8 button; /**< The joystick button index */
|
||||
Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
|
||||
} SDL_JoyButtonEvent;
|
||||
|
||||
/* The "window resized" event
|
||||
When you get this event, you are responsible for setting a new video
|
||||
mode with the new width and height.
|
||||
/**
|
||||
* \struct SDL_QuitEvent
|
||||
*
|
||||
* \brief The "quit requested" event
|
||||
*/
|
||||
typedef struct SDL_ResizeEvent {
|
||||
Uint8 type; /* SDL_VIDEORESIZE */
|
||||
int w; /* New width */
|
||||
int h; /* New height */
|
||||
} SDL_ResizeEvent;
|
||||
|
||||
/* The "screen redraw" event */
|
||||
typedef struct SDL_ExposeEvent {
|
||||
Uint8 type; /* SDL_VIDEOEXPOSE */
|
||||
} SDL_ExposeEvent;
|
||||
|
||||
/* The "quit requested" event */
|
||||
typedef struct SDL_QuitEvent {
|
||||
Uint8 type; /* SDL_QUIT */
|
||||
typedef struct SDL_QuitEvent
|
||||
{
|
||||
Uint8 type; /**< SDL_QUIT */
|
||||
} SDL_QuitEvent;
|
||||
|
||||
/* A user-defined event type */
|
||||
typedef struct SDL_UserEvent {
|
||||
Uint8 type; /* SDL_USEREVENT through SDL_NUMEVENTS-1 */
|
||||
int code; /* User defined event code */
|
||||
void *data1; /* User defined data pointer */
|
||||
void *data2; /* User defined data pointer */
|
||||
/**
|
||||
* \struct SDL_UserEvent
|
||||
*
|
||||
* \brief A user-defined event type
|
||||
*/
|
||||
typedef struct SDL_UserEvent
|
||||
{
|
||||
Uint8 type; /**< SDL_USEREVENT through SDL_NUMEVENTS-1 */
|
||||
int code; /**< User defined event code */
|
||||
void *data1; /**< User defined data pointer */
|
||||
void *data2; /**< User defined data pointer */
|
||||
} SDL_UserEvent;
|
||||
|
||||
/* If you want to use this event, you should include SDL_syswm.h */
|
||||
/**
|
||||
* \struct SDL_SysWMEvent
|
||||
*
|
||||
* \brief A video driver dependent system event
|
||||
*
|
||||
* \note If you want to use this event, you should include SDL_syswm.h
|
||||
*/
|
||||
struct SDL_SysWMmsg;
|
||||
typedef struct SDL_SysWMmsg SDL_SysWMmsg;
|
||||
typedef struct SDL_SysWMEvent {
|
||||
Uint8 type;
|
||||
SDL_SysWMmsg *msg;
|
||||
typedef struct SDL_SysWMEvent
|
||||
{
|
||||
Uint8 type; /**< SDL_SYSWMEVENT */
|
||||
SDL_SysWMmsg *msg; /**< driver dependent data, defined in SDL_syswm.h */
|
||||
} SDL_SysWMEvent;
|
||||
|
||||
/* General event structure */
|
||||
typedef union SDL_Event {
|
||||
/* Typedefs for backwards compatibility */
|
||||
typedef struct SDL_ActiveEvent
|
||||
{
|
||||
Uint8 type;
|
||||
Uint8 gain;
|
||||
Uint8 state;
|
||||
} SDL_ActiveEvent;
|
||||
typedef struct SDL_ResizeEvent
|
||||
{
|
||||
Uint8 type;
|
||||
int w;
|
||||
int h;
|
||||
} SDL_ResizeEvent;
|
||||
|
||||
/**
|
||||
* \union SDL_Event
|
||||
*
|
||||
* \brief General event structure
|
||||
*/
|
||||
typedef union SDL_Event
|
||||
{
|
||||
Uint8 type; /**< Event type, shared with all events */
|
||||
SDL_WindowEvent window; /**< Window event data */
|
||||
SDL_KeyboardEvent key; /**< Keyboard event data */
|
||||
SDL_TextInputEvent text; /**< Text input event data */
|
||||
SDL_MouseMotionEvent motion; /**< Mouse motion event data */
|
||||
SDL_MouseButtonEvent button; /**< Mouse button event data */
|
||||
SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */
|
||||
SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */
|
||||
SDL_JoyBallEvent jball; /**< Joystick ball event data */
|
||||
SDL_JoyHatEvent jhat; /**< Joystick hat event data */
|
||||
SDL_JoyButtonEvent jbutton; /**< Joystick button event data */
|
||||
SDL_QuitEvent quit; /**< Quit request event data */
|
||||
SDL_UserEvent user; /**< Custom event data */
|
||||
SDL_SysWMEvent syswm; /**< System dependent window event data */
|
||||
|
||||
/* Temporarily here for backwards compatibility */
|
||||
SDL_ActiveEvent active;
|
||||
SDL_KeyboardEvent key;
|
||||
SDL_MouseMotionEvent motion;
|
||||
SDL_MouseButtonEvent button;
|
||||
SDL_JoyAxisEvent jaxis;
|
||||
SDL_JoyBallEvent jball;
|
||||
SDL_JoyHatEvent jhat;
|
||||
SDL_JoyButtonEvent jbutton;
|
||||
SDL_ResizeEvent resize;
|
||||
SDL_ExposeEvent expose;
|
||||
SDL_QuitEvent quit;
|
||||
SDL_UserEvent user;
|
||||
SDL_SysWMEvent syswm;
|
||||
} SDL_Event;
|
||||
|
||||
|
||||
|
@ -255,14 +361,20 @@ extern DECLSPEC void SDLCALL SDL_PumpEvents(void);
|
|||
This function returns the number of events actually stored, or -1
|
||||
if there was an error. This function is thread-safe.
|
||||
*/
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
SDL_ADDEVENT,
|
||||
SDL_PEEKEVENT,
|
||||
SDL_GETEVENT
|
||||
} SDL_eventaction;
|
||||
/* */
|
||||
extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
|
||||
SDL_eventaction action, Uint32 mask);
|
||||
SDL_eventaction action,
|
||||
Uint32 mask);
|
||||
|
||||
/* Checks to see if certain event types are in the event queue.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 mask);
|
||||
|
||||
/* Polls for currently pending events, and returns 1 if there are any pending
|
||||
events, or 0 if there are none available. If 'event' is not NULL, the next
|
||||
|
@ -277,8 +389,8 @@ extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event *event);
|
|||
extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event);
|
||||
|
||||
/* Add an event to the event queue.
|
||||
This function returns 0 on success, or -1 if the event queue was full
|
||||
or there was some other error.
|
||||
This function returns 1 on success, 0 if the event was filtered,
|
||||
or -1 if the event queue was full or there was some other error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event);
|
||||
|
||||
|
@ -288,7 +400,7 @@ extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event *event);
|
|||
|
||||
The filter is protypted as:
|
||||
*/
|
||||
typedef int (SDLCALL *SDL_EventFilter)(const SDL_Event *event);
|
||||
typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
|
||||
/*
|
||||
If the filter returns 1, then the event will be added to the internal queue.
|
||||
If it returns 0, then the event will be dropped from the queue, but the
|
||||
|
@ -305,13 +417,22 @@ typedef int (SDLCALL *SDL_EventFilter)(const SDL_Event *event);
|
|||
If the quit event is generated by an interrupt signal, it will bypass the
|
||||
internal queue and be delivered to the application at the next event poll.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter);
|
||||
extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter,
|
||||
void *userdata);
|
||||
|
||||
/*
|
||||
Return the current event filter - can be used to "chain" filters.
|
||||
If there is no event filter set, this function returns NULL.
|
||||
If there is no event filter set, this function returns SDL_FALSE.
|
||||
*/
|
||||
extern DECLSPEC SDL_EventFilter SDLCALL SDL_GetEventFilter(void);
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter,
|
||||
void **userdata);
|
||||
|
||||
/*
|
||||
Run the filter function on the current event queue, removing any
|
||||
events for which the filter returns 0.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter,
|
||||
void *userdata);
|
||||
|
||||
/*
|
||||
This function allows you to set the state of processing certain events.
|
||||
|
@ -330,8 +451,12 @@ extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint8 type, int state);
|
|||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_events_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -20,7 +20,11 @@
|
|||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* Include file for SDL joystick event handling */
|
||||
/**
|
||||
* \file SDL_joystick.h
|
||||
*
|
||||
* Include file for SDL joystick event handling
|
||||
*/
|
||||
|
||||
#ifndef _SDL_joystick_h
|
||||
#define _SDL_joystick_h
|
||||
|
@ -31,7 +35,9 @@
|
|||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* In order to use these functions, SDL_Init() must have been called
|
||||
|
@ -119,7 +125,8 @@ extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state);
|
|||
* The state is a value ranging from -32768 to 32767.
|
||||
* The axis indices start at index 0.
|
||||
*/
|
||||
extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis);
|
||||
extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick,
|
||||
int axis);
|
||||
|
||||
/*
|
||||
* Get the current state of a POV hat on a joystick
|
||||
|
@ -137,20 +144,23 @@ extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick, int a
|
|||
/*
|
||||
* The hat indices start at index 0.
|
||||
*/
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick, int hat);
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick * joystick,
|
||||
int hat);
|
||||
|
||||
/*
|
||||
* Get the ball axis change since the last poll
|
||||
* This returns 0, or -1 if you passed it invalid parameters.
|
||||
* The ball indices start at index 0.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy);
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick * joystick,
|
||||
int ball, int *dx, int *dy);
|
||||
|
||||
/*
|
||||
* Get the current state of a button on a joystick
|
||||
* The button indices start at index 0.
|
||||
*/
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick *joystick, int button);
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick,
|
||||
int button);
|
||||
|
||||
/*
|
||||
* Close a joystick previously opened with SDL_JoystickOpen()
|
||||
|
@ -160,8 +170,12 @@ extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick *joystick);
|
|||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_joystick_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -20,7 +20,11 @@
|
|||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* Include file for SDL keyboard event handling */
|
||||
/**
|
||||
* \file SDL_keyboard.h
|
||||
*
|
||||
* Include file for SDL keyboard event handling
|
||||
*/
|
||||
|
||||
#ifndef _SDL_keyboard_h
|
||||
#define _SDL_keyboard_h
|
||||
|
@ -32,90 +36,133 @@
|
|||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* Keysym structure
|
||||
- The scancode is hardware dependent, and should not be used by general
|
||||
applications. If no hardware scancode is available, it will be 0.
|
||||
|
||||
- The 'unicode' translated character is only available when character
|
||||
translation is enabled by the SDL_EnableUNICODE() API. If non-zero,
|
||||
this is a UNICODE character corresponding to the keypress. If the
|
||||
high 9 bits of the character are 0, then this maps to the equivalent
|
||||
ASCII character:
|
||||
char ch;
|
||||
if ( (keysym.unicode & 0xFF80) == 0 ) {
|
||||
ch = keysym.unicode & 0x7F;
|
||||
} else {
|
||||
An international character..
|
||||
}
|
||||
/**
|
||||
* \struct SDL_keysym
|
||||
*
|
||||
* \brief The SDL keysym structure, used in key events.
|
||||
*/
|
||||
typedef struct SDL_keysym {
|
||||
Uint8 scancode; /* hardware specific scancode */
|
||||
SDLKey sym; /* SDL virtual keysym */
|
||||
SDLMod mod; /* current key modifiers */
|
||||
Uint16 unicode; /* translated character */
|
||||
typedef struct SDL_keysym
|
||||
{
|
||||
Uint8 scancode; /**< keyboard specific scancode */
|
||||
Uint8 padding[3]; /**< alignment padding */
|
||||
Uint16 sym; /**< SDL virtual keysym */
|
||||
Uint16 mod; /**< current key modifiers */
|
||||
Uint32 unicode; /**< OBSOLETE, use SDL_TextInputEvent instead */
|
||||
} SDL_keysym;
|
||||
|
||||
/* This is the mask which refers to all hotkey bindings */
|
||||
#define SDL_ALL_HOTKEYS 0xFFFFFFFF
|
||||
|
||||
/* Function prototypes */
|
||||
/*
|
||||
* Enable/Disable UNICODE translation of keyboard input.
|
||||
* This translation has some overhead, so translation defaults off.
|
||||
* If 'enable' is 1, translation is enabled.
|
||||
* If 'enable' is 0, translation is disabled.
|
||||
* If 'enable' is -1, the translation state is not changed.
|
||||
* It returns the previous state of keyboard translation.
|
||||
|
||||
/**
|
||||
* \fn int SDL_GetNumKeyboards(void)
|
||||
*
|
||||
* \brief Get the number of keyboard input devices available.
|
||||
*
|
||||
* \sa SDL_SelectKeyboard()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetNumKeyboards(void);
|
||||
|
||||
/**
|
||||
* \fn int SDL_SelectKeyboard(int index)
|
||||
*
|
||||
* \brief Set the index of the currently selected keyboard.
|
||||
*
|
||||
* \return The index of the previously selected keyboard.
|
||||
*
|
||||
* \note You can query the currently selected keyboard by passing an index of -1.
|
||||
*
|
||||
* \sa SDL_GetNumKeyboards()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SelectKeyboard(int index);
|
||||
|
||||
/**
|
||||
* \fn int SDL_EnableUNICODE(int enable)
|
||||
*
|
||||
* \brief Enable/Disable UNICODE translation of keyboard input.
|
||||
*
|
||||
* \param enable 1 to enable translation, 0 to disable translation, -1 to query translation
|
||||
*
|
||||
* \return The previous state of keyboard translation
|
||||
*
|
||||
* \note This translation has some overhead, so translation defaults off.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
|
||||
|
||||
/*
|
||||
* Enable/Disable keyboard repeat. Keyboard repeat defaults to off.
|
||||
* 'delay' is the initial delay in ms between the time when a key is
|
||||
* pressed, and keyboard repeat begins.
|
||||
* 'interval' is the time in ms between keyboard repeat events.
|
||||
/**
|
||||
* \fn int SDL_EnableKeyRepeat(int delay, int interval)
|
||||
*
|
||||
* \brief Enable keyboard repeat for the selected keyboard.
|
||||
*
|
||||
* \param delay The initial delay in milliseconds between the time when a
|
||||
* key is pressed and keyboard repeat begins. Setting a delay
|
||||
* of 0 will disable keyboard repeat.
|
||||
* \param interval The time in milliseconds between keyboard repeat events.
|
||||
*
|
||||
* \return 0 on success, or -1 if there was an error.
|
||||
*
|
||||
* \note Keyboard repeat defaults to off.
|
||||
*/
|
||||
#define SDL_DEFAULT_REPEAT_DELAY 500
|
||||
#define SDL_DEFAULT_REPEAT_INTERVAL 30
|
||||
/*
|
||||
* If 'delay' is set to 0, keyboard repeat is disabled.
|
||||
*/
|
||||
/**/
|
||||
extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
|
||||
|
||||
/**
|
||||
* \fn void SDL_GetKeyRepeat(int *delay, int *interval)
|
||||
*
|
||||
* \brief Get the current keyboard repeat setting for the selected keyboard.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
|
||||
|
||||
/*
|
||||
* Get a snapshot of the current state of the keyboard.
|
||||
* Returns an array of keystates, indexed by the SDLK_* syms.
|
||||
* Used:
|
||||
/**
|
||||
* \fn Uint8 *SDL_GetKeyState(int *numkeys)
|
||||
*
|
||||
* \brief Get a snapshot of the current state of the selected keyboard.
|
||||
*
|
||||
* \return An array of keystates, indexed by the SDLK_* syms.
|
||||
*
|
||||
* Example:
|
||||
* Uint8 *keystate = SDL_GetKeyState(NULL);
|
||||
* if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed.
|
||||
*/
|
||||
extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyState(int *numkeys);
|
||||
|
||||
/*
|
||||
* Get the current key modifier state
|
||||
/**
|
||||
* \fn SDLMod SDL_GetModState(void)
|
||||
*
|
||||
* \brief Get the current key modifier state for the selected keyboard.
|
||||
*/
|
||||
extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void);
|
||||
|
||||
/*
|
||||
* Set the current key modifier state
|
||||
* This does not change the keyboard state, only the key modifier flags.
|
||||
/**
|
||||
* \fn void SDL_SetModState(SDLMod modstate)
|
||||
*
|
||||
* \brief Set the current key modifier state for the selected keyboard.
|
||||
*
|
||||
* \note This does not change the keyboard state, only the key modifier flags.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate);
|
||||
|
||||
/*
|
||||
* Get the name of an SDL virtual keysym
|
||||
/**
|
||||
* \fn const char *SDL_GetKeyName(SDLKey key)
|
||||
*
|
||||
* \brief Get the name of an SDL virtual keysym
|
||||
*/
|
||||
extern DECLSPEC char * SDLCALL SDL_GetKeyName(SDLKey key);
|
||||
extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDLKey key);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_keyboard_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -20,16 +20,25 @@
|
|||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_keysym.h
|
||||
*/
|
||||
|
||||
#ifndef _SDL_keysym_h
|
||||
#define _SDL_keysym_h
|
||||
|
||||
/* What we really want is a mapping of every raw key on the keyboard.
|
||||
To support international keyboards, we use the range 0xA1 - 0xFF
|
||||
as international virtual keycodes. We'll follow in the footsteps of X11...
|
||||
The names of the keys
|
||||
/**
|
||||
* \enum SDLKey
|
||||
*
|
||||
* \brief The SDL virtual key representation
|
||||
*
|
||||
* The SDLKey represents the unmodified character printed on the key
|
||||
* for the current keyboard layout. The first 255 characters are used
|
||||
* unchanged from Latin-1, e.g. a key with 'a' on it will have the value "a".
|
||||
* The rest of the keys are named below, and fall into the range above 255.
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
/* The keyboard syms have been cleverly chosen to map to ASCII */
|
||||
SDLK_UNKNOWN = 0,
|
||||
SDLK_FIRST = 0,
|
||||
|
@ -109,104 +118,6 @@ typedef enum {
|
|||
SDLK_DELETE = 127,
|
||||
/* End of ASCII mapped keysyms */
|
||||
|
||||
/* International keyboard syms */
|
||||
SDLK_WORLD_0 = 160, /* 0xA0 */
|
||||
SDLK_WORLD_1 = 161,
|
||||
SDLK_WORLD_2 = 162,
|
||||
SDLK_WORLD_3 = 163,
|
||||
SDLK_WORLD_4 = 164,
|
||||
SDLK_WORLD_5 = 165,
|
||||
SDLK_WORLD_6 = 166,
|
||||
SDLK_WORLD_7 = 167,
|
||||
SDLK_WORLD_8 = 168,
|
||||
SDLK_WORLD_9 = 169,
|
||||
SDLK_WORLD_10 = 170,
|
||||
SDLK_WORLD_11 = 171,
|
||||
SDLK_WORLD_12 = 172,
|
||||
SDLK_WORLD_13 = 173,
|
||||
SDLK_WORLD_14 = 174,
|
||||
SDLK_WORLD_15 = 175,
|
||||
SDLK_WORLD_16 = 176,
|
||||
SDLK_WORLD_17 = 177,
|
||||
SDLK_WORLD_18 = 178,
|
||||
SDLK_WORLD_19 = 179,
|
||||
SDLK_WORLD_20 = 180,
|
||||
SDLK_WORLD_21 = 181,
|
||||
SDLK_WORLD_22 = 182,
|
||||
SDLK_WORLD_23 = 183,
|
||||
SDLK_WORLD_24 = 184,
|
||||
SDLK_WORLD_25 = 185,
|
||||
SDLK_WORLD_26 = 186,
|
||||
SDLK_WORLD_27 = 187,
|
||||
SDLK_WORLD_28 = 188,
|
||||
SDLK_WORLD_29 = 189,
|
||||
SDLK_WORLD_30 = 190,
|
||||
SDLK_WORLD_31 = 191,
|
||||
SDLK_WORLD_32 = 192,
|
||||
SDLK_WORLD_33 = 193,
|
||||
SDLK_WORLD_34 = 194,
|
||||
SDLK_WORLD_35 = 195,
|
||||
SDLK_WORLD_36 = 196,
|
||||
SDLK_WORLD_37 = 197,
|
||||
SDLK_WORLD_38 = 198,
|
||||
SDLK_WORLD_39 = 199,
|
||||
SDLK_WORLD_40 = 200,
|
||||
SDLK_WORLD_41 = 201,
|
||||
SDLK_WORLD_42 = 202,
|
||||
SDLK_WORLD_43 = 203,
|
||||
SDLK_WORLD_44 = 204,
|
||||
SDLK_WORLD_45 = 205,
|
||||
SDLK_WORLD_46 = 206,
|
||||
SDLK_WORLD_47 = 207,
|
||||
SDLK_WORLD_48 = 208,
|
||||
SDLK_WORLD_49 = 209,
|
||||
SDLK_WORLD_50 = 210,
|
||||
SDLK_WORLD_51 = 211,
|
||||
SDLK_WORLD_52 = 212,
|
||||
SDLK_WORLD_53 = 213,
|
||||
SDLK_WORLD_54 = 214,
|
||||
SDLK_WORLD_55 = 215,
|
||||
SDLK_WORLD_56 = 216,
|
||||
SDLK_WORLD_57 = 217,
|
||||
SDLK_WORLD_58 = 218,
|
||||
SDLK_WORLD_59 = 219,
|
||||
SDLK_WORLD_60 = 220,
|
||||
SDLK_WORLD_61 = 221,
|
||||
SDLK_WORLD_62 = 222,
|
||||
SDLK_WORLD_63 = 223,
|
||||
SDLK_WORLD_64 = 224,
|
||||
SDLK_WORLD_65 = 225,
|
||||
SDLK_WORLD_66 = 226,
|
||||
SDLK_WORLD_67 = 227,
|
||||
SDLK_WORLD_68 = 228,
|
||||
SDLK_WORLD_69 = 229,
|
||||
SDLK_WORLD_70 = 230,
|
||||
SDLK_WORLD_71 = 231,
|
||||
SDLK_WORLD_72 = 232,
|
||||
SDLK_WORLD_73 = 233,
|
||||
SDLK_WORLD_74 = 234,
|
||||
SDLK_WORLD_75 = 235,
|
||||
SDLK_WORLD_76 = 236,
|
||||
SDLK_WORLD_77 = 237,
|
||||
SDLK_WORLD_78 = 238,
|
||||
SDLK_WORLD_79 = 239,
|
||||
SDLK_WORLD_80 = 240,
|
||||
SDLK_WORLD_81 = 241,
|
||||
SDLK_WORLD_82 = 242,
|
||||
SDLK_WORLD_83 = 243,
|
||||
SDLK_WORLD_84 = 244,
|
||||
SDLK_WORLD_85 = 245,
|
||||
SDLK_WORLD_86 = 246,
|
||||
SDLK_WORLD_87 = 247,
|
||||
SDLK_WORLD_88 = 248,
|
||||
SDLK_WORLD_89 = 249,
|
||||
SDLK_WORLD_90 = 250,
|
||||
SDLK_WORLD_91 = 251,
|
||||
SDLK_WORLD_92 = 252,
|
||||
SDLK_WORLD_93 = 253,
|
||||
SDLK_WORLD_94 = 254,
|
||||
SDLK_WORLD_95 = 255, /* 0xFF */
|
||||
|
||||
/* Numeric keypad */
|
||||
SDLK_KP0 = 256,
|
||||
SDLK_KP1 = 257,
|
||||
|
@ -266,10 +177,10 @@ typedef enum {
|
|||
SDLK_LALT = 308,
|
||||
SDLK_RMETA = 309,
|
||||
SDLK_LMETA = 310,
|
||||
SDLK_LSUPER = 311, /* Left "Windows" key */
|
||||
SDLK_RSUPER = 312, /* Right "Windows" key */
|
||||
SDLK_MODE = 313, /* "Alt Gr" key */
|
||||
SDLK_COMPOSE = 314, /* Multi-key compose key */
|
||||
SDLK_LSUPER = 311, /**< Left "Windows" key */
|
||||
SDLK_RSUPER = 312, /**< Right "Windows" key */
|
||||
SDLK_MODE = 313, /**< "Alt Gr" key */
|
||||
SDLK_COMPOSE = 314, /**< Multi-key compose key */
|
||||
|
||||
/* Miscellaneous function keys */
|
||||
SDLK_HELP = 315,
|
||||
|
@ -277,17 +188,22 @@ typedef enum {
|
|||
SDLK_SYSREQ = 317,
|
||||
SDLK_BREAK = 318,
|
||||
SDLK_MENU = 319,
|
||||
SDLK_POWER = 320, /* Power Macintosh power key */
|
||||
SDLK_EURO = 321, /* Some european keyboards */
|
||||
SDLK_UNDO = 322, /* Atari keyboard has Undo */
|
||||
SDLK_POWER = 320, /**< Power Macintosh power key */
|
||||
SDLK_EURO = 321, /**< Some european keyboards */
|
||||
SDLK_UNDO = 322, /**< Atari keyboard has Undo */
|
||||
|
||||
/* Add any other keys here */
|
||||
|
||||
SDLK_LAST
|
||||
} SDLKey;
|
||||
|
||||
/* Enumeration of valid key mods (possibly OR'd together) */
|
||||
typedef enum {
|
||||
/**
|
||||
* \enum SDLMod
|
||||
*
|
||||
* \brief Enumeration of valid key mods (possibly OR'd together)
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
KMOD_NONE = 0x0000,
|
||||
KMOD_LSHIFT = 0x0001,
|
||||
KMOD_RSHIFT = 0x0002,
|
||||
|
|
|
@ -20,24 +20,25 @@
|
|||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
/* System dependent library loading routines */
|
||||
|
||||
/* Some things to keep in mind:
|
||||
- These functions only work on C function names. Other languages may
|
||||
have name mangling and intrinsic language support that varies from
|
||||
compiler to compiler.
|
||||
- Make sure you declare your function pointers with the same calling
|
||||
convention as the actual library function. Your code will crash
|
||||
mysteriously if you do not do this.
|
||||
- Avoid namespace collisions. If you load a symbol from the library,
|
||||
it is not defined whether or not it goes into the global symbol
|
||||
namespace for the application. If it does and it conflicts with
|
||||
symbols in your code or other shared libraries, you will not get
|
||||
the results you expect. :)
|
||||
/**
|
||||
* \file SDL_loadso.h
|
||||
*
|
||||
* System dependent library loading routines
|
||||
*
|
||||
* Some things to keep in mind:
|
||||
* - These functions only work on C function names. Other languages may
|
||||
* have name mangling and intrinsic language support that varies from
|
||||
* compiler to compiler.
|
||||
* - Make sure you declare your function pointers with the same calling
|
||||
* convention as the actual library function. Your code will crash
|
||||
* mysteriously if you do not do this.
|
||||
* - Avoid namespace collisions. If you load a symbol from the library,
|
||||
* it is not defined whether or not it goes into the global symbol
|
||||
* namespace for the application. If it does and it conflicts with
|
||||
* symbols in your code or other shared libraries, you will not get
|
||||
* the results you expect. :)
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _SDL_loadso_h
|
||||
#define _SDL_loadso_h
|
||||
|
||||
|
@ -47,7 +48,9 @@
|
|||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* This function dynamically loads a shared object and returns a pointer
|
||||
|
@ -60,15 +63,20 @@ extern DECLSPEC void * SDLCALL SDL_LoadObject(const char *sofile);
|
|||
* named function in the shared object and returns it. This address
|
||||
* is no longer valid after calling SDL_UnloadObject().
|
||||
*/
|
||||
extern DECLSPEC void * SDLCALL SDL_LoadFunction(void *handle, const char *name);
|
||||
extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle,
|
||||
const char *name);
|
||||
|
||||
/* Unload a shared object from memory */
|
||||
extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_loadso_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -58,17 +58,20 @@ extern C_LINKAGE int SDL_main(int argc, char *argv[]);
|
|||
|
||||
#include "begin_code.h"
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* This should be called from your WinMain() function, if any */
|
||||
extern DECLSPEC void SDLCALL SDL_SetModuleHandle(void *hInst);
|
||||
/* This can also be called, but is no longer necessary */
|
||||
extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst);
|
||||
/* This can also be called, but is no longer necessary (SDL_Quit calls it) */
|
||||
/* This can be called to set the application class at startup */
|
||||
extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style,
|
||||
void *hInst);
|
||||
extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
#endif
|
||||
|
@ -78,7 +81,9 @@ extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
|
|||
|
||||
#include "begin_code.h"
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* Forward declaration so we don't need to include QuickDraw.h */
|
||||
|
@ -88,7 +93,9 @@ struct QDGlobals;
|
|||
extern DECLSPEC void SDLCALL SDL_InitQuickDraw(struct QDGlobals *the_qd);
|
||||
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
#endif
|
||||
|
@ -96,3 +103,5 @@ extern DECLSPEC void SDLCALL SDL_InitQuickDraw(struct QDGlobals *the_qd);
|
|||
#endif /* Need to redefine main()? */
|
||||
|
||||
#endif /* _SDL_main_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -20,7 +20,11 @@
|
|||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* Include file for SDL mouse event handling */
|
||||
/**
|
||||
* \file SDL_mouse.h
|
||||
*
|
||||
* Include file for SDL mouse event handling
|
||||
*/
|
||||
|
||||
#ifndef _SDL_mouse_h
|
||||
#define _SDL_mouse_h
|
||||
|
@ -32,43 +36,116 @@
|
|||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
typedef struct WMcursor WMcursor; /* Implementation dependent */
|
||||
typedef struct SDL_Cursor {
|
||||
SDL_Rect area; /* The area of the mouse cursor */
|
||||
Sint16 hot_x, hot_y; /* The "tip" of the cursor */
|
||||
Uint8 *data; /* B/W cursor data */
|
||||
Uint8 *mask; /* B/W cursor mask */
|
||||
Uint8 *save[2]; /* Place to save cursor area */
|
||||
WMcursor *wm_cursor; /* Window-manager cursor */
|
||||
} SDL_Cursor;
|
||||
typedef struct SDL_Cursor SDL_Cursor; /* Implementation dependent */
|
||||
|
||||
/* Function prototypes */
|
||||
/*
|
||||
* Retrieve the current state of the mouse.
|
||||
|
||||
/**
|
||||
* \fn int SDL_GetNumMice(void)
|
||||
*
|
||||
* \brief Get the number of mouse input devices available.
|
||||
*
|
||||
* \sa SDL_SelectMouse()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetNumMice(void);
|
||||
|
||||
/**
|
||||
* \fn int SDL_SelectMouse(int index)
|
||||
*
|
||||
* \brief Set the index of the currently selected mouse.
|
||||
*
|
||||
* \return The index of the previously selected mouse.
|
||||
*
|
||||
* \note You can query the currently selected mouse by passing an index of -1.
|
||||
*
|
||||
* \sa SDL_GetNumMice()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SelectMouse(int index);
|
||||
|
||||
/**
|
||||
* \fn SDL_WindowID SDL_GetMouseFocusWindow(void)
|
||||
*
|
||||
* \brief Get the window which currently has focus for the currently selected mouse.
|
||||
*/
|
||||
extern DECLSPEC SDL_WindowID SDLCALL SDL_GetMouseFocusWindow(void);
|
||||
|
||||
/**
|
||||
* \fn int SDL_SetRelativeMouseMode(SDL_bool enabled)
|
||||
*
|
||||
* \brief Set relative mouse mode for the currently selected mouse.
|
||||
*
|
||||
* \param enabled Whether or not to enable relative mode
|
||||
*
|
||||
* \return 0 on success, or -1 if relative mode is not supported.
|
||||
*
|
||||
* While the mouse is in relative mode, the cursor is hidden, and the
|
||||
* driver will try to report continuous motion in the current window.
|
||||
* Only relative motion events will be delivered, the mouse position
|
||||
* will not change.
|
||||
*
|
||||
* \note This function will flush any pending mouse motion.
|
||||
*
|
||||
* \sa SDL_GetRelativeMouseMode()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled);
|
||||
|
||||
/**
|
||||
* \fn SDL_bool SDL_GetRelativeMouseMode()
|
||||
*
|
||||
* \brief Query whether relative mouse mode is enabled for the currently selected mouse.
|
||||
*
|
||||
* \sa SDL_SetRelativeMouseMode()
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode();
|
||||
|
||||
/**
|
||||
* \fn Uint8 SDL_GetMouseState(int *x, int *y)
|
||||
*
|
||||
* \brief Retrieve the current state of the currently selected mouse.
|
||||
*
|
||||
* The current button state is returned as a button bitmask, which can
|
||||
* be tested using the SDL_BUTTON(X) macros, and x and y are set to the
|
||||
* current mouse cursor position. You can pass NULL for either x or y.
|
||||
* mouse cursor position relative to the focus window for the currently
|
||||
* selected mouse. You can pass NULL for either x or y.
|
||||
*/
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y);
|
||||
|
||||
/*
|
||||
* Retrieve the current state of the mouse.
|
||||
/**
|
||||
* \fn Uint8 SDL_GetRelativeMouseState(int *x, int *y)
|
||||
*
|
||||
* \brief Retrieve the state of the currently selected mouse.
|
||||
*
|
||||
* The current button state is returned as a button bitmask, which can
|
||||
* be tested using the SDL_BUTTON(X) macros, and x and y are set to the
|
||||
* mouse deltas since the last call to SDL_GetRelativeMouseState().
|
||||
*/
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
|
||||
|
||||
/*
|
||||
* Set the position of the mouse cursor (generates a mouse motion event)
|
||||
/**
|
||||
* \fn void SDL_WarpMouseInWindow(SDL_WindowID windowID, int x, int y)
|
||||
*
|
||||
* \brief Moves the currently selected mouse to the given position within the window.
|
||||
*
|
||||
* \param windowID The window to move the mouse into, or 0 for the current mouse focus
|
||||
* \param x The x coordinate within the window
|
||||
* \param y The y coordinate within the window
|
||||
*
|
||||
* \note This function generates a mouse motion event
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y);
|
||||
extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_WindowID windowID,
|
||||
int x, int y);
|
||||
|
||||
/*
|
||||
* Create a cursor using the specified data and mask (in MSB format).
|
||||
/**
|
||||
* \fn SDL_Cursor *SDL_CreateCursor (const Uint8 * data, const Uint8 * mask, int w, int h, int hot_x, int hot_y)
|
||||
*
|
||||
* \brief Create a cursor for the currently selected mouse, using the
|
||||
* specified bitmap data and mask (in MSB format).
|
||||
*
|
||||
* The cursor width must be a multiple of 8 bits.
|
||||
*
|
||||
* The cursor is created in black and white according to the following:
|
||||
|
@ -78,34 +155,46 @@ extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y);
|
|||
* 0 0 Transparent
|
||||
* 1 0 Inverted color if possible, black if not.
|
||||
*
|
||||
* Cursors created with this function must be freed with SDL_FreeCursor().
|
||||
* \sa SDL_FreeCursor()
|
||||
*/
|
||||
extern DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor
|
||||
(Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
|
||||
extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data,
|
||||
const Uint8 * mask,
|
||||
int w, int h, int hot_x,
|
||||
int hot_y);
|
||||
|
||||
/*
|
||||
* Set the currently active cursor to the specified one.
|
||||
* If the cursor is currently visible, the change will be immediately
|
||||
* represented on the display.
|
||||
/**
|
||||
* \fn void SDL_SetCursor(SDL_Cursor * cursor)
|
||||
*
|
||||
* \brief Set the active cursor for the currently selected mouse.
|
||||
*
|
||||
* \note The cursor must have been created for the selected mouse.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor);
|
||||
|
||||
/*
|
||||
* Returns the currently active cursor.
|
||||
/**
|
||||
* \fn SDL_Cursor *SDL_GetCursor(void)
|
||||
*
|
||||
* \brief Return the active cursor for the currently selected mouse.
|
||||
*/
|
||||
extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void);
|
||||
|
||||
/*
|
||||
* Deallocates a cursor created with SDL_CreateCursor().
|
||||
/**
|
||||
* \fn void SDL_FreeCursor(SDL_Cursor * cursor)
|
||||
*
|
||||
* \brief Frees a cursor created with SDL_CreateCursor().
|
||||
*
|
||||
* \sa SDL_CreateCursor()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor);
|
||||
|
||||
/*
|
||||
* Toggle whether or not the cursor is shown on the screen.
|
||||
* The cursor start off displayed, but can be turned off.
|
||||
* SDL_ShowCursor() returns 1 if the cursor was being displayed
|
||||
* before the call, or 0 if it was not. You can query the current
|
||||
* state by passing a 'toggle' value of -1.
|
||||
/**
|
||||
* \fn int SDL_ShowCursor(int toggle)
|
||||
*
|
||||
* \brief Toggle whether or not the cursor is shown for the currently selected mouse.
|
||||
*
|
||||
* \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current state.
|
||||
*
|
||||
* \return 1 if the cursor is shown, or 0 if the cursor is hidden.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
|
||||
|
||||
|
@ -113,15 +202,11 @@ extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
|
|||
Button 1: Left mouse button
|
||||
Button 2: Middle mouse button
|
||||
Button 3: Right mouse button
|
||||
Button 4: Mouse wheel up (may also be a real button)
|
||||
Button 5: Mouse wheel down (may also be a real button)
|
||||
*/
|
||||
#define SDL_BUTTON(X) (1 << ((X)-1))
|
||||
#define SDL_BUTTON_LEFT 1
|
||||
#define SDL_BUTTON_MIDDLE 2
|
||||
#define SDL_BUTTON_RIGHT 3
|
||||
#define SDL_BUTTON_WHEELUP 4
|
||||
#define SDL_BUTTON_WHEELDOWN 5
|
||||
#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT)
|
||||
#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE)
|
||||
#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT)
|
||||
|
@ -129,8 +214,12 @@ extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
|
|||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_mouse_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -23,9 +23,10 @@
|
|||
#ifndef _SDL_mutex_h
|
||||
#define _SDL_mutex_h
|
||||
|
||||
/* Functions to provide thread synchronization primitives
|
||||
|
||||
These are independent of the other SDL routines.
|
||||
/**
|
||||
* \file SDL_mutex.h
|
||||
*
|
||||
* Functions to provide thread synchronization primitives
|
||||
*/
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
@ -34,7 +35,9 @@
|
|||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* Synchronization functions which can time out return this value
|
||||
|
@ -151,12 +154,17 @@ extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond *cond, SDL_mutex *mut);
|
|||
On some platforms this function is implemented by looping with a delay
|
||||
of 1 ms, and so should be avoided if possible.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms);
|
||||
extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond * cond,
|
||||
SDL_mutex * mutex, Uint32 ms);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_mutex_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -48,12 +48,14 @@
|
|||
#undef __glext_h_
|
||||
#endif
|
||||
|
||||
/* This file taken from "GLext.h" from the Jeff Molofee OpenGL tutorials.
|
||||
It is included here because glext.h is not available on some systems.
|
||||
/* This file is included because glext.h is not available on some systems.
|
||||
If you don't want this version included, simply define "NO_SDL_GLEXT"
|
||||
The latest version is available from:
|
||||
http://oss.sgi.com/projects/ogl-sample/registry/
|
||||
*/
|
||||
#ifndef NO_SDL_GLEXT
|
||||
#if !defined(__glext_h_) && !defined(GL_GLEXT_LEGACY)
|
||||
#if !defined(NO_SDL_GLEXT) && !defined(GL_GLEXT_LEGACY)
|
||||
/* *INDENT-OFF* */
|
||||
#ifndef __glext_h_
|
||||
#define __glext_h_
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -6548,4 +6550,5 @@ typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid
|
|||
#endif
|
||||
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
#endif /* NO_SDL_GLEXT */
|
||||
|
|
348
include/SDL_pixels.h
Normal file
348
include/SDL_pixels.h
Normal file
|
@ -0,0 +1,348 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_pixels.h
|
||||
*
|
||||
* Header for the enumerated pixel format definitions
|
||||
*/
|
||||
|
||||
#ifndef _SDL_pixels_h
|
||||
#define _SDL_pixels_h
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
enum
|
||||
{ /* Pixel type */
|
||||
SDL_PixelType_Unknown,
|
||||
SDL_PixelType_Index1,
|
||||
SDL_PixelType_Index4,
|
||||
SDL_PixelType_Index8,
|
||||
SDL_PixelType_Packed8,
|
||||
SDL_PixelType_Packed16,
|
||||
SDL_PixelType_Packed32,
|
||||
SDL_PixelType_ArrayU8,
|
||||
SDL_PixelType_ArrayU16,
|
||||
SDL_PixelType_ArrayU32,
|
||||
SDL_PixelType_ArrayF16,
|
||||
SDL_PixelType_ArrayF32,
|
||||
};
|
||||
|
||||
enum
|
||||
{ /* bitmap pixel order, high bit -> low bit */
|
||||
SDL_BitmapOrder_None,
|
||||
SDL_BitmapOrder_4321,
|
||||
SDL_BitmapOrder_1234,
|
||||
};
|
||||
enum
|
||||
{ /* packed component order, high bit -> low bit */
|
||||
SDL_PackedOrder_None,
|
||||
SDL_PackedOrder_XRGB,
|
||||
SDL_PackedOrder_RGBX,
|
||||
SDL_PackedOrder_ARGB,
|
||||
SDL_PackedOrder_RGBA,
|
||||
SDL_PackedOrder_XBGR,
|
||||
SDL_PackedOrder_BGRX,
|
||||
SDL_PackedOrder_ABGR,
|
||||
SDL_PackedOrder_BGRA,
|
||||
};
|
||||
enum
|
||||
{ /* array component order, low byte -> high byte */
|
||||
SDL_ArrayOrder_None,
|
||||
SDL_ArrayOrder_RGB,
|
||||
SDL_ArrayOrder_RGBA,
|
||||
SDL_ArrayOrder_ARGB,
|
||||
SDL_ArrayOrder_BGR,
|
||||
SDL_ArrayOrder_BGRA,
|
||||
SDL_ArrayOrder_ABGR,
|
||||
};
|
||||
|
||||
enum
|
||||
{ /* Packed component layout */
|
||||
SDL_PackedLayout_None,
|
||||
SDL_PackedLayout_332,
|
||||
SDL_PackedLayout_4444,
|
||||
SDL_PackedLayout_1555,
|
||||
SDL_PackedLayout_5551,
|
||||
SDL_PackedLayout_565,
|
||||
SDL_PackedLayout_8888,
|
||||
SDL_PackedLayout_2101010,
|
||||
SDL_PackedLayout_1010102,
|
||||
};
|
||||
|
||||
#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) \
|
||||
((A) | ((B) << 8) | ((C) << 16) | ((D) << 24))
|
||||
|
||||
#define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \
|
||||
((1 << 31) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
|
||||
((bits) << 8) | ((bytes) << 0))
|
||||
|
||||
#define SDL_PIXELTYPE(X) (((X) >> 24) & 0x0F)
|
||||
#define SDL_PIXELORDER(X) (((X) >> 20) & 0x0F)
|
||||
#define SDL_PIXELLAYOUT(X) (((X) >> 16) & 0x0F)
|
||||
#define SDL_BITSPERPIXEL(X) (((X) >> 8) & 0xFF)
|
||||
#define SDL_BYTESPERPIXEL(X) (((X) >> 0) & 0xFF)
|
||||
|
||||
#define SDL_ISPIXELFORMAT_INDEXED(format) \
|
||||
((SDL_PIXELTYPE(format) == SDL_PixelType_Index1) || \
|
||||
(SDL_PIXELTYPE(format) == SDL_PixelType_Index4) || \
|
||||
(SDL_PIXELTYPE(format) == SDL_PixelType_Index8))
|
||||
|
||||
#define SDL_ISPIXELFORMAT_FOURCC(format) \
|
||||
((format) && !((format) & 0x80000000))
|
||||
|
||||
enum
|
||||
{
|
||||
SDL_PixelFormat_Unknown,
|
||||
SDL_PixelFormat_Index1LSB =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Index1, SDL_BitmapOrder_1234, 0,
|
||||
1, 0),
|
||||
SDL_PixelFormat_Index1MSB =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Index1, SDL_BitmapOrder_4321, 0,
|
||||
1, 0),
|
||||
SDL_PixelFormat_Index4LSB =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Index4, SDL_BitmapOrder_1234, 0,
|
||||
2, 0),
|
||||
SDL_PixelFormat_Index4MSB =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Index4, SDL_BitmapOrder_4321, 0,
|
||||
2, 0),
|
||||
SDL_PixelFormat_Index8 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Index8, 0, 0, 8, 1),
|
||||
SDL_PixelFormat_RGB332 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed8, SDL_PackedOrder_XRGB,
|
||||
SDL_PackedLayout_332, 8, 1),
|
||||
SDL_PixelFormat_RGB444 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed16, SDL_PackedOrder_XRGB,
|
||||
SDL_PackedLayout_4444, 12, 2),
|
||||
SDL_PixelFormat_RGB555 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed16, SDL_PackedOrder_XRGB,
|
||||
SDL_PackedLayout_1555, 15, 2),
|
||||
SDL_PixelFormat_ARGB4444 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed16, SDL_PackedOrder_ARGB,
|
||||
SDL_PackedLayout_4444, 16, 2),
|
||||
SDL_PixelFormat_ARGB1555 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed16, SDL_PackedOrder_ARGB,
|
||||
SDL_PackedLayout_1555, 16, 2),
|
||||
SDL_PixelFormat_RGB565 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed16, SDL_PackedOrder_XRGB,
|
||||
SDL_PackedLayout_565, 16, 2),
|
||||
SDL_PixelFormat_RGB24 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PixelType_ArrayU8, SDL_ArrayOrder_RGB, 0,
|
||||
24, 3),
|
||||
SDL_PixelFormat_BGR24 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PixelType_ArrayU8, SDL_ArrayOrder_BGR, 0,
|
||||
24, 3),
|
||||
SDL_PixelFormat_RGB888 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed32, SDL_PackedOrder_XRGB,
|
||||
SDL_PackedLayout_8888, 24, 4),
|
||||
SDL_PixelFormat_BGR888 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed32, SDL_PackedOrder_XBGR,
|
||||
SDL_PackedLayout_8888, 24, 4),
|
||||
SDL_PixelFormat_ARGB8888 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed32, SDL_PackedOrder_ARGB,
|
||||
SDL_PackedLayout_8888, 32, 4),
|
||||
SDL_PixelFormat_RGBA8888 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed32, SDL_PackedOrder_RGBA,
|
||||
SDL_PackedLayout_8888, 32, 4),
|
||||
SDL_PixelFormat_ABGR8888 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed32, SDL_PackedOrder_ABGR,
|
||||
SDL_PackedLayout_8888, 32, 4),
|
||||
SDL_PixelFormat_BGRA8888 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed32, SDL_PackedOrder_BGRA,
|
||||
SDL_PackedLayout_8888, 32, 4),
|
||||
SDL_PixelFormat_ARGB2101010 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed32, SDL_PackedOrder_ARGB,
|
||||
SDL_PackedLayout_2101010, 32, 4),
|
||||
|
||||
SDL_PixelFormat_YV12 = /* Planar mode: Y + V + U (3 planes) */
|
||||
SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'),
|
||||
SDL_PixelFormat_IYUV = /* Planar mode: Y + U + V (3 planes) */
|
||||
SDL_DEFINE_PIXELFOURCC('I', 'Y', 'U', 'V'),
|
||||
SDL_PixelFormat_YUY2 = /* Packed mode: Y0+U0+Y1+V0 (1 plane) */
|
||||
SDL_DEFINE_PIXELFOURCC('Y', 'U', 'Y', '2'),
|
||||
SDL_PixelFormat_UYVY = /* Packed mode: U0+Y0+V0+Y1 (1 plane) */
|
||||
SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'),
|
||||
SDL_PixelFormat_YVYU = /* Packed mode: Y0+V0+Y1+U0 (1 plane) */
|
||||
SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U'),
|
||||
};
|
||||
|
||||
typedef struct SDL_Color
|
||||
{
|
||||
Uint8 r;
|
||||
Uint8 g;
|
||||
Uint8 b;
|
||||
Uint8 unused;
|
||||
} SDL_Color;
|
||||
#define SDL_Colour SDL_Color
|
||||
|
||||
typedef struct SDL_Palette SDL_Palette;
|
||||
typedef int (*SDL_PaletteChangedFunc) (void *userdata, SDL_Palette * palette);
|
||||
|
||||
typedef struct SDL_PaletteWatch
|
||||
{
|
||||
SDL_PaletteChangedFunc callback;
|
||||
void *userdata;
|
||||
struct SDL_PaletteWatch *next;
|
||||
} SDL_PaletteWatch;
|
||||
|
||||
struct SDL_Palette
|
||||
{
|
||||
int ncolors;
|
||||
SDL_Color *colors;
|
||||
|
||||
int refcount;
|
||||
SDL_PaletteWatch *watch;
|
||||
};
|
||||
|
||||
/* Everything in the pixel format structure is read-only */
|
||||
typedef struct SDL_PixelFormat
|
||||
{
|
||||
SDL_Palette *palette;
|
||||
Uint8 BitsPerPixel;
|
||||
Uint8 BytesPerPixel;
|
||||
Uint8 Rloss;
|
||||
Uint8 Gloss;
|
||||
Uint8 Bloss;
|
||||
Uint8 Aloss;
|
||||
Uint8 Rshift;
|
||||
Uint8 Gshift;
|
||||
Uint8 Bshift;
|
||||
Uint8 Ashift;
|
||||
Uint32 Rmask;
|
||||
Uint32 Gmask;
|
||||
Uint32 Bmask;
|
||||
Uint32 Amask;
|
||||
|
||||
/* RGB color key information */
|
||||
Uint32 colorkey;
|
||||
/* Alpha value information (per-surface alpha) */
|
||||
Uint8 alpha;
|
||||
} SDL_PixelFormat;
|
||||
|
||||
/**
|
||||
* \fn SDL_bool SDL_PixelFormatEnumToMasks(Uint32 format, int *bpp, Uint32 * Rmask, Uint32 * Gmask, Uint32 * Bmask, Uint32 * Amask)
|
||||
*
|
||||
* \brief Convert one of the enumerated pixel formats to a bpp and RGBA masks.
|
||||
*
|
||||
* \return SDL_TRUE, or SDL_FALSE if the conversion wasn't possible.
|
||||
*
|
||||
* \sa SDL_MasksToPixelFormatEnum()
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format,
|
||||
int *bpp,
|
||||
Uint32 * Rmask,
|
||||
Uint32 * Gmask,
|
||||
Uint32 * Bmask,
|
||||
Uint32 * Amask);
|
||||
|
||||
/**
|
||||
* \fn Uint32 SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
|
||||
*
|
||||
* \brief Convert a bpp and RGBA masks to an enumerated pixel format.
|
||||
*
|
||||
* \return The pixel format, or SDL_PixelFormat_Unknown if the conversion wasn't possible.
|
||||
*
|
||||
* \sa SDL_PixelFormatEnumToMasks()
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp,
|
||||
Uint32 Rmask,
|
||||
Uint32 Gmask,
|
||||
Uint32 Bmask,
|
||||
Uint32 Amask);
|
||||
|
||||
/**
|
||||
* \fn SDL_Palette *SDL_AllocPalette(int ncolors)
|
||||
*
|
||||
* \brief Create a palette structure with the specified number of color entries.
|
||||
*
|
||||
* \return A new palette, or NULL if there wasn't enough memory
|
||||
*
|
||||
* \note The palette entries are initialized to white.
|
||||
*
|
||||
* \sa SDL_FreePalette()
|
||||
*/
|
||||
extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors);
|
||||
|
||||
/**
|
||||
* \fn int SDL_AddPaletteWatch(SDL_Palette *palette, SDL_PaletteChangedFunc callback, void *userdata)
|
||||
*
|
||||
* \brief Add a callback function which is called when the palette changes.
|
||||
*
|
||||
* \sa SDL_DelPaletteWatch()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_AddPaletteWatch(SDL_Palette * palette,
|
||||
SDL_PaletteChangedFunc
|
||||
callback, void *userdata);
|
||||
|
||||
/**
|
||||
* \fn void SDL_DelPaletteWatch(SDL_Palette *palette, SDL_PaletteChangedFunc callback, void *userdata)
|
||||
*
|
||||
* \brief Remove a callback function previously added with SDL_AddPaletteWatch()
|
||||
*
|
||||
* \sa SDL_AddPaletteWatch()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_DelPaletteWatch(SDL_Palette * palette,
|
||||
SDL_PaletteChangedFunc
|
||||
callback, void *userdata);
|
||||
|
||||
/**
|
||||
* \fn int SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Colors *colors, int firstcolor, int numcolors)
|
||||
*
|
||||
* \brief Set a range of colors in a palette.
|
||||
*
|
||||
* \param palette The palette to modify
|
||||
* \param colors An array of colors to copy into the palette
|
||||
* \param firstcolor The index of the first palette entry to modify
|
||||
* \param ncolors The number of entries to modify
|
||||
*
|
||||
* \return 0 on success, or -1 if not all of the colors could be set
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette,
|
||||
const SDL_Color * colors,
|
||||
int firstcolor, int ncolors);
|
||||
|
||||
/**
|
||||
* \fn void SDL_FreePalette(SDL_Palette *palette)
|
||||
*
|
||||
* \brief Free a palette created with SDL_AllocPalette()
|
||||
*
|
||||
* \sa SDL_AllocPalette()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_pixels_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -20,7 +20,11 @@
|
|||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* Include file for SDL quit event handling */
|
||||
/**
|
||||
* \file SDL_quit.h
|
||||
*
|
||||
* Include file for SDL quit event handling
|
||||
*/
|
||||
|
||||
#ifndef _SDL_quit_h
|
||||
#define _SDL_quit_h
|
||||
|
|
|
@ -20,8 +20,11 @@
|
|||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* This file provides a general interface for SDL to read and write
|
||||
data sources. It can easily be extended to files, memory, etc.
|
||||
/**
|
||||
* \file SDL_rwops.h
|
||||
*
|
||||
* This file provides a general interface for SDL to read and write
|
||||
* data sources. It can easily be extended to files, memory, etc.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_rwops_h
|
||||
|
@ -33,12 +36,15 @@
|
|||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* This is the read/write operation structure -- very basic */
|
||||
|
||||
typedef struct SDL_RWops {
|
||||
typedef struct SDL_RWops
|
||||
{
|
||||
/* Seek to 'offset' relative to whence, one of stdio's whence values:
|
||||
SEEK_SET, SEEK_CUR, SEEK_END
|
||||
Returns the final offset in the data source.
|
||||
|
@ -49,37 +55,44 @@ typedef struct SDL_RWops {
|
|||
source to the area pointed at by 'ptr'.
|
||||
Returns the number of objects read, or -1 if the read failed.
|
||||
*/
|
||||
int (SDLCALL *read)(struct SDL_RWops *context, void *ptr, int size, int maxnum);
|
||||
int (SDLCALL * read) (struct SDL_RWops * context, void *ptr, int size,
|
||||
int maxnum);
|
||||
|
||||
/* Write exactly 'num' objects each of size 'objsize' from the area
|
||||
pointed at by 'ptr' to data source.
|
||||
Returns 'num', or -1 if the write failed.
|
||||
*/
|
||||
int (SDLCALL *write)(struct SDL_RWops *context, const void *ptr, int size, int num);
|
||||
int (SDLCALL * write) (struct SDL_RWops * context, const void *ptr,
|
||||
int size, int num);
|
||||
|
||||
/* Close and free an allocated SDL_FSops structure */
|
||||
int (SDLCALL * close) (struct SDL_RWops * context);
|
||||
|
||||
Uint32 type;
|
||||
union {
|
||||
union
|
||||
{
|
||||
#ifdef __WIN32__
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
int append;
|
||||
void *h;
|
||||
} win32io;
|
||||
#endif
|
||||
#ifdef HAVE_STDIO_H
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
int autoclose;
|
||||
FILE *fp;
|
||||
} stdio;
|
||||
#endif
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
Uint8 *base;
|
||||
Uint8 *here;
|
||||
Uint8 *stop;
|
||||
} mem;
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
void *data1;
|
||||
} unknown;
|
||||
} hidden;
|
||||
|
@ -89,14 +102,16 @@ typedef struct SDL_RWops {
|
|||
|
||||
/* Functions to create SDL_RWops structures from various data sources */
|
||||
|
||||
extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFile(const char *file, const char *mode);
|
||||
extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file,
|
||||
const char *mode);
|
||||
|
||||
#ifdef HAVE_STDIO_H
|
||||
extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(FILE * fp, int autoclose);
|
||||
#endif
|
||||
|
||||
extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, int size);
|
||||
extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromConstMem(const void *mem, int size);
|
||||
extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem(const void *mem,
|
||||
int size);
|
||||
|
||||
extern DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW(void);
|
||||
extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area);
|
||||
|
@ -132,8 +147,12 @@ extern DECLSPEC int SDLCALL SDL_WriteBE64(SDL_RWops *dst, Uint64 value);
|
|||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_rwops_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -20,7 +20,11 @@
|
|||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* This is a general header that includes C language support */
|
||||
/**
|
||||
* \file SDL_stdinc.h
|
||||
*
|
||||
* This is a general header that includes C language support
|
||||
*/
|
||||
|
||||
#ifndef _SDL_stdinc_h
|
||||
#define _SDL_stdinc_h
|
||||
|
@ -77,33 +81,66 @@
|
|||
#define SDL_TABLESIZE(table) SDL_arraysize(table)
|
||||
|
||||
/* Basic data types */
|
||||
typedef enum SDL_bool {
|
||||
typedef enum SDL_bool
|
||||
{
|
||||
SDL_FALSE = 0,
|
||||
SDL_TRUE = 1
|
||||
} SDL_bool;
|
||||
|
||||
/**
|
||||
* \typedef Sint8
|
||||
* \brief A signed 8-bit integer type.
|
||||
*/
|
||||
typedef int8_t Sint8;
|
||||
/**
|
||||
* \typedef Uint8
|
||||
* \brief An unsigned 8-bit integer type.
|
||||
*/
|
||||
typedef uint8_t Uint8;
|
||||
/**
|
||||
* \typedef Sint16
|
||||
* \brief A signed 16-bit integer type.
|
||||
*/
|
||||
typedef int16_t Sint16;
|
||||
/**
|
||||
* \typedef Uint16
|
||||
* \brief An unsigned 16-bit integer type.
|
||||
*/
|
||||
typedef uint16_t Uint16;
|
||||
/**
|
||||
* \typedef Sint32
|
||||
* \brief A signed 32-bit integer type.
|
||||
*/
|
||||
typedef int32_t Sint32;
|
||||
/**
|
||||
* \typedef Uint32
|
||||
* \brief An unsigned 32-bit integer type.
|
||||
*/
|
||||
typedef uint32_t Uint32;
|
||||
|
||||
#ifdef SDL_HAS_64BIT_TYPE
|
||||
/**
|
||||
* \typedef Sint64
|
||||
* \brief A signed 64-bit integer type.
|
||||
* \warning On platforms without any sort of 64-bit datatype, this is equivalent to Sint32!
|
||||
*/
|
||||
typedef int64_t Sint64;
|
||||
/**
|
||||
* \typedef Uint64
|
||||
* \brief An unsigned 64-bit integer type.
|
||||
* \warning On platforms without any sort of 64-bit datatype, this is equivalent to Uint32!
|
||||
*/
|
||||
typedef uint64_t Uint64;
|
||||
#else
|
||||
/* This is really just a hack to prevent the compiler from complaining */
|
||||
typedef struct {
|
||||
Uint32 hi;
|
||||
Uint32 lo;
|
||||
} Uint64, Sint64;
|
||||
typdef Sint32 Sint64;
|
||||
typdef Uint32 Uint32;
|
||||
#endif
|
||||
|
||||
/* Make sure the types really have the right sizes */
|
||||
#define SDL_COMPILE_TIME_ASSERT(name, x) \
|
||||
typedef int SDL_dummy_ ## name[(x) * 2 - 1]
|
||||
|
||||
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
|
||||
SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);
|
||||
SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1);
|
||||
SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2);
|
||||
|
@ -112,6 +149,7 @@ SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4);
|
|||
SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4);
|
||||
SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8);
|
||||
SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
|
||||
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
|
||||
|
||||
/* Check to make sure enums are the size of ints, for structure packing.
|
||||
For both Watcom C/C++ and Borland C/C++ the compiler option that makes
|
||||
|
@ -123,17 +161,21 @@ SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
|
|||
#pragma enumsalwaysint on
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
|
||||
typedef enum
|
||||
{
|
||||
DUMMY_ENUM_VALUE
|
||||
} SDL_DUMMY_ENUM;
|
||||
|
||||
SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int));
|
||||
|
||||
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MALLOC
|
||||
|
@ -204,7 +246,8 @@ extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
|
|||
#define SDL_qsort qsort
|
||||
#else
|
||||
extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size,
|
||||
int (*compare)(const void *, const void *));
|
||||
int (*compare) (const void *,
|
||||
const void *));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ABS
|
||||
|
@ -233,6 +276,8 @@ extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size,
|
|||
#else
|
||||
extern DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len);
|
||||
#endif
|
||||
#define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x)))
|
||||
#define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x)))
|
||||
|
||||
#if defined(__GNUC__) && defined(i386)
|
||||
#define SDL_memset4(dst, val, len) \
|
||||
|
@ -288,7 +333,8 @@ do { \
|
|||
#elif defined(HAVE_BCOPY)
|
||||
#define SDL_memcpy(d, s, n) bcopy((s), (d), (n))
|
||||
#else
|
||||
extern DECLSPEC void * SDLCALL SDL_memcpy(void *dst, const void *src, size_t len);
|
||||
extern DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src,
|
||||
size_t len);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -335,7 +381,8 @@ do { \
|
|||
} while(0)
|
||||
#endif
|
||||
#ifndef SDL_revcpy
|
||||
extern DECLSPEC void * SDLCALL SDL_revcpy(void *dst, const void *src, size_t len);
|
||||
extern DECLSPEC void *SDLCALL SDL_revcpy(void *dst, const void *src,
|
||||
size_t len);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MEMMOVE
|
||||
|
@ -356,7 +403,8 @@ do { \
|
|||
#ifdef HAVE_MEMCMP
|
||||
#define SDL_memcmp memcmp
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len);
|
||||
extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2,
|
||||
size_t len);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRLEN
|
||||
|
@ -368,13 +416,15 @@ extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string);
|
|||
#ifdef HAVE_STRLCPY
|
||||
#define SDL_strlcpy strlcpy
|
||||
#else
|
||||
extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src, size_t maxlen);
|
||||
extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src,
|
||||
size_t maxlen);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRLCAT
|
||||
#define SDL_strlcat strlcat
|
||||
#else
|
||||
extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src, size_t maxlen);
|
||||
extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src,
|
||||
size_t maxlen);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRDUP
|
||||
|
@ -420,7 +470,8 @@ extern DECLSPEC char * SDLCALL SDL_strrchr(const char *string, int c);
|
|||
#ifdef HAVE_STRSTR
|
||||
#define SDL_strstr strstr
|
||||
#else
|
||||
extern DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *needle);
|
||||
extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack,
|
||||
const char *needle);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ITOA
|
||||
|
@ -444,19 +495,22 @@ extern DECLSPEC char * SDLCALL SDL_ltoa(long value, char *string, int radix);
|
|||
#ifdef HAVE__ULTOA
|
||||
#define SDL_ultoa _ultoa
|
||||
#else
|
||||
extern DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *string, int radix);
|
||||
extern DECLSPEC char *SDLCALL SDL_ultoa(unsigned long value, char *string,
|
||||
int radix);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRTOL
|
||||
#define SDL_strtol strtol
|
||||
#else
|
||||
extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, int base);
|
||||
extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp,
|
||||
int base);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRTOUL
|
||||
#define SDL_strtoul strtoul
|
||||
#else
|
||||
extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string, char **endp, int base);
|
||||
extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string,
|
||||
char **endp, int base);
|
||||
#endif
|
||||
|
||||
#ifdef SDL_HAS_64BIT_TYPE
|
||||
|
@ -464,25 +518,29 @@ extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string, char **end
|
|||
#ifdef HAVE__I64TOA
|
||||
#define SDL_lltoa _i64toa
|
||||
#else
|
||||
extern DECLSPEC char* SDLCALL SDL_lltoa(Sint64 value, char *string, int radix);
|
||||
extern DECLSPEC char *SDLCALL SDL_lltoa(Sint64 value, char *string,
|
||||
int radix);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__UI64TOA
|
||||
#define SDL_ulltoa _ui64toa
|
||||
#else
|
||||
extern DECLSPEC char* SDLCALL SDL_ulltoa(Uint64 value, char *string, int radix);
|
||||
extern DECLSPEC char *SDLCALL SDL_ulltoa(Uint64 value, char *string,
|
||||
int radix);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRTOLL
|
||||
#define SDL_strtoll strtoll
|
||||
#else
|
||||
extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, int base);
|
||||
extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp,
|
||||
int base);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRTOULL
|
||||
#define SDL_strtoull strtoull
|
||||
#else
|
||||
extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp, int base);
|
||||
extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp,
|
||||
int base);
|
||||
#endif
|
||||
|
||||
#endif /* SDL_HAS_64BIT_TYPE */
|
||||
|
@ -514,7 +572,8 @@ extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2);
|
|||
#ifdef HAVE_STRNCMP
|
||||
#define SDL_strncmp strncmp
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen);
|
||||
extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2,
|
||||
size_t maxlen);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRCASECMP
|
||||
|
@ -522,7 +581,8 @@ extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size
|
|||
#elif defined(HAVE__STRICMP)
|
||||
#define SDL_strcasecmp _stricmp
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2);
|
||||
extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1,
|
||||
const char *str2);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRNCASECMP
|
||||
|
@ -530,25 +590,29 @@ extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2);
|
|||
#elif defined(HAVE__STRNICMP)
|
||||
#define SDL_strncasecmp _strnicmp
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen);
|
||||
extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1,
|
||||
const char *str2, size_t maxlen);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SSCANF
|
||||
#define SDL_sscanf sscanf
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...);
|
||||
extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt,
|
||||
...);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SNPRINTF
|
||||
#define SDL_snprintf snprintf
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...);
|
||||
extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen,
|
||||
const char *fmt, ...);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_VSNPRINTF
|
||||
#define SDL_vsnprintf vsnprintf
|
||||
#else
|
||||
extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap);
|
||||
extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen,
|
||||
const char *fmt, va_list ap);
|
||||
#endif
|
||||
|
||||
/* The SDL implementation of iconv() returns these error codes */
|
||||
|
@ -561,17 +625,25 @@ extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char
|
|||
#define SDL_iconv_t iconv_t
|
||||
#define SDL_iconv_open iconv_open
|
||||
#define SDL_iconv_close iconv_close
|
||||
extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
|
||||
extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, char **inbuf,
|
||||
size_t * inbytesleft, char **outbuf,
|
||||
size_t * outbytesleft);
|
||||
#else
|
||||
typedef struct _SDL_iconv_t *SDL_iconv_t;
|
||||
extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode, const char *fromcode);
|
||||
extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode,
|
||||
const char *fromcode);
|
||||
extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd);
|
||||
extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
|
||||
extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, char **inbuf,
|
||||
size_t * inbytesleft, char **outbuf,
|
||||
size_t * outbytesleft);
|
||||
#endif
|
||||
/* This function converts a string between encodings in one pass, returning a
|
||||
string that must be freed with SDL_free() or NULL on error.
|
||||
*/
|
||||
extern DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode, const char *fromcode, char *inbuf, size_t inbytesleft);
|
||||
extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode,
|
||||
const char *fromcode,
|
||||
char *inbuf,
|
||||
size_t inbytesleft);
|
||||
#define SDL_iconv_utf8_ascii(S) SDL_iconv_string("ASCII", "UTF-8", S, SDL_strlen(S)+1)
|
||||
#define SDL_iconv_utf8_latin1(S) SDL_iconv_string("LATIN1", "UTF-8", S, SDL_strlen(S)+1)
|
||||
#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)
|
||||
|
@ -579,8 +651,12 @@ extern DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode, const char *
|
|||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_stdinc_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -20,19 +20,26 @@
|
|||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* Include file for SDL custom system window manager hooks */
|
||||
/**
|
||||
* \file SDL_syswm.h
|
||||
*
|
||||
* Include file for SDL custom system window manager hooks
|
||||
*/
|
||||
|
||||
#ifndef _SDL_syswm_h
|
||||
#define _SDL_syswm_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_version.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* Your application has access to a special type of event 'SDL_SYSWMEVENT',
|
||||
|
@ -42,7 +49,6 @@ extern "C" {
|
|||
*/
|
||||
#ifdef SDL_PROTOTYPES_ONLY
|
||||
struct SDL_SysWMinfo;
|
||||
typedef struct SDL_SysWMinfo SDL_SysWMinfo;
|
||||
#else
|
||||
|
||||
/* This is the structure for custom window manager events */
|
||||
|
@ -61,15 +67,18 @@ typedef struct SDL_SysWMinfo SDL_SysWMinfo;
|
|||
#endif
|
||||
|
||||
/* These are the various supported subsystems under UNIX */
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
SDL_SYSWM_X11
|
||||
} SDL_SYSWM_TYPE;
|
||||
|
||||
/* The UNIX custom event structure */
|
||||
struct SDL_SysWMmsg {
|
||||
struct SDL_SysWMmsg
|
||||
{
|
||||
SDL_version version;
|
||||
SDL_SYSWM_TYPE subsystem;
|
||||
union {
|
||||
union
|
||||
{
|
||||
XEvent xevent;
|
||||
} event;
|
||||
};
|
||||
|
@ -78,11 +87,14 @@ struct SDL_SysWMmsg {
|
|||
When this structure is returned, it holds information about which
|
||||
low level system it is using, and will be one of SDL_SYSWM_TYPE.
|
||||
*/
|
||||
typedef struct SDL_SysWMinfo {
|
||||
struct SDL_SysWMinfo
|
||||
{
|
||||
SDL_version version;
|
||||
SDL_SYSWM_TYPE subsystem;
|
||||
union {
|
||||
struct {
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
Display *display; /* The X11 display */
|
||||
Window window; /* The X11 display window */
|
||||
/* These locking functions should be called around
|
||||
|
@ -98,29 +110,32 @@ typedef struct SDL_SysWMinfo {
|
|||
Window wmwindow; /* The X11 managed input window */
|
||||
} x11;
|
||||
} info;
|
||||
} SDL_SysWMinfo;
|
||||
};
|
||||
|
||||
#elif defined(SDL_VIDEO_DRIVER_NANOX)
|
||||
#include <microwin/nano-X.h>
|
||||
|
||||
/* The generic custom event structure */
|
||||
struct SDL_SysWMmsg {
|
||||
struct SDL_SysWMmsg
|
||||
{
|
||||
SDL_version version;
|
||||
int data;
|
||||
};
|
||||
|
||||
/* The windows custom window manager information structure */
|
||||
typedef struct SDL_SysWMinfo {
|
||||
struct SDL_SysWMinfo
|
||||
{
|
||||
SDL_version version;
|
||||
GR_WINDOW_ID window; /* The display window */
|
||||
} SDL_SysWMinfo;
|
||||
};
|
||||
|
||||
#elif defined(SDL_VIDEO_DRIVER_WINDIB) || defined(SDL_VIDEO_DRIVER_DDRAW) || defined(SDL_VIDEO_DRIVER_GAPI)
|
||||
#elif defined(SDL_VIDEO_DRIVER_WIN32)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
/* The windows custom event structure */
|
||||
struct SDL_SysWMmsg {
|
||||
struct SDL_SysWMmsg
|
||||
{
|
||||
SDL_version version;
|
||||
HWND hwnd; /* The window for the message */
|
||||
UINT msg; /* The type of message */
|
||||
|
@ -129,82 +144,102 @@ struct SDL_SysWMmsg {
|
|||
};
|
||||
|
||||
/* The windows custom window manager information structure */
|
||||
typedef struct SDL_SysWMinfo {
|
||||
struct SDL_SysWMinfo
|
||||
{
|
||||
SDL_version version;
|
||||
HWND window; /* The Win32 display window */
|
||||
HGLRC hglrc; /* The OpenGL context, if any */
|
||||
} SDL_SysWMinfo;
|
||||
};
|
||||
|
||||
#elif defined(SDL_VIDEO_DRIVER_RISCOS)
|
||||
|
||||
/* RISC OS custom event structure */
|
||||
struct SDL_SysWMmsg {
|
||||
struct SDL_SysWMmsg
|
||||
{
|
||||
SDL_version version;
|
||||
int eventCode; /* The window for the message */
|
||||
int pollBlock[64];
|
||||
};
|
||||
|
||||
/* The RISC OS custom window manager information structure */
|
||||
typedef struct SDL_SysWMinfo {
|
||||
struct SDL_SysWMinfo
|
||||
{
|
||||
SDL_version version;
|
||||
int wimpVersion; /* Wimp version running under */
|
||||
int taskHandle; /* The RISC OS task handle */
|
||||
int window; /* The RISC OS display window */
|
||||
} SDL_SysWMinfo;
|
||||
};
|
||||
|
||||
#elif defined(SDL_VIDEO_DRIVER_PHOTON)
|
||||
#include <sys/neutrino.h>
|
||||
#include <Ph.h>
|
||||
|
||||
/* The QNX custom event structure */
|
||||
struct SDL_SysWMmsg {
|
||||
struct SDL_SysWMmsg
|
||||
{
|
||||
SDL_version version;
|
||||
int data;
|
||||
};
|
||||
|
||||
/* The QNX custom window manager information structure */
|
||||
typedef struct SDL_SysWMinfo {
|
||||
struct SDL_SysWMinfo
|
||||
{
|
||||
SDL_version version;
|
||||
int data;
|
||||
} SDL_SysWMinfo;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
/* The generic custom event structure */
|
||||
struct SDL_SysWMmsg {
|
||||
struct SDL_SysWMmsg
|
||||
{
|
||||
SDL_version version;
|
||||
int data;
|
||||
};
|
||||
|
||||
/* The generic custom window manager information structure */
|
||||
typedef struct SDL_SysWMinfo {
|
||||
struct SDL_SysWMinfo
|
||||
{
|
||||
SDL_version version;
|
||||
int data;
|
||||
} SDL_SysWMinfo;
|
||||
};
|
||||
|
||||
#endif /* video driver type */
|
||||
|
||||
#endif /* SDL_PROTOTYPES_ONLY */
|
||||
|
||||
typedef struct SDL_SysWMinfo SDL_SysWMinfo;
|
||||
|
||||
/* Function prototypes */
|
||||
/*
|
||||
* This function gives you custom hooks into the window manager information.
|
||||
* It fills the structure pointed to by 'info' with custom information and
|
||||
* returns 1 if the function is implemented. If it's not implemented, or
|
||||
* the version member of the 'info' structure is invalid, it returns 0.
|
||||
/**
|
||||
* \fn SDL_bool SDL_GetWindowWMInfo (SDL_WindowID windowID, SDL_SysWMinfo * info)
|
||||
*
|
||||
* \brief This function allows access to driver-dependent window information.
|
||||
*
|
||||
* \param windowID The window about which information is being requested
|
||||
* \param info This structure must be initialized with the SDL version, and is then filled in with information about the given window.
|
||||
*
|
||||
* \return SDL_TRUE if the function is implemented and the version member of the 'info' struct is valid, SDL_FALSE otherwise.
|
||||
*
|
||||
* You typically use this function like this:
|
||||
* \code
|
||||
* SDL_SysWMInfo info;
|
||||
* SDL_VERSION(&info.version);
|
||||
* if ( SDL_GetWMInfo(&info) ) { ... }
|
||||
* if ( SDL_GetWindowWMInfo(&info) ) { ... }
|
||||
* \endcode
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetWMInfo(SDL_SysWMinfo *info);
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_WindowID windowID,
|
||||
SDL_SysWMinfo * info);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_syswm_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -23,9 +23,10 @@
|
|||
#ifndef _SDL_thread_h
|
||||
#define _SDL_thread_h
|
||||
|
||||
/* Header for the SDL thread management routines
|
||||
|
||||
These are independent of the other SDL routines.
|
||||
/**
|
||||
* \file SDL_thread.h
|
||||
*
|
||||
* Header for the SDL thread management routines
|
||||
*/
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
@ -37,7 +38,9 @@
|
|||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* The SDL thread structure, defined in SDL_thread.c */
|
||||
|
@ -65,21 +68,35 @@ typedef struct SDL_Thread SDL_Thread;
|
|||
#endif
|
||||
|
||||
#ifdef __OS2__
|
||||
typedef int (*pfnSDL_CurrentBeginThread)(void (*func)(void *), void *, unsigned, void *arg);
|
||||
typedef int (*pfnSDL_CurrentBeginThread) (void (*func) (void *), void *,
|
||||
unsigned, void *arg);
|
||||
typedef void (*pfnSDL_CurrentEndThread) (void);
|
||||
#elif __GNUC__
|
||||
typedef unsigned long (__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned,
|
||||
unsigned (__stdcall *func)(void *), void *arg,
|
||||
unsigned, unsigned *threadID);
|
||||
unsigned
|
||||
(__stdcall *
|
||||
func) (void *),
|
||||
void *arg,
|
||||
unsigned,
|
||||
unsigned
|
||||
*threadID);
|
||||
typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code);
|
||||
#else
|
||||
typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned,
|
||||
unsigned (__stdcall *func)(void *), void *arg,
|
||||
unsigned, unsigned *threadID);
|
||||
unsigned (__stdcall *
|
||||
func) (void
|
||||
*),
|
||||
void *arg, unsigned,
|
||||
unsigned *threadID);
|
||||
typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code);
|
||||
#endif
|
||||
|
||||
extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread);
|
||||
extern DECLSPEC SDL_Thread *SDLCALL SDL_CreateThread(int (*fn) (void *),
|
||||
void *data,
|
||||
pfnSDL_CurrentBeginThread
|
||||
pfnBeginThread,
|
||||
pfnSDL_CurrentEndThread
|
||||
pfnEndThread);
|
||||
|
||||
#ifdef __OS2__
|
||||
#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthread, _endthread)
|
||||
|
@ -89,7 +106,8 @@ extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *),
|
|||
#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthreadex, _endthreadex)
|
||||
#endif
|
||||
#else
|
||||
extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data);
|
||||
extern DECLSPEC SDL_Thread *SDLCALL
|
||||
SDL_CreateThread(int (SDLCALL * fn) (void *), void *data);
|
||||
#endif
|
||||
|
||||
/* Get the 32-bit thread identifier for the current thread */
|
||||
|
@ -112,8 +130,12 @@ extern DECLSPEC void SDLCALL SDL_KillThread(SDL_Thread *thread);
|
|||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_thread_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -23,7 +23,11 @@
|
|||
#ifndef _SDL_timer_h
|
||||
#define _SDL_timer_h
|
||||
|
||||
/* Header for the SDL time management routines */
|
||||
/**
|
||||
* \file SDL_timer.h
|
||||
*
|
||||
* Header for the SDL time management routines
|
||||
*/
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
|
@ -31,7 +35,9 @@
|
|||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* This is the OS scheduler timeslice, in milliseconds */
|
||||
|
@ -79,7 +85,8 @@ typedef Uint32 (SDLCALL *SDL_TimerCallback)(Uint32 interval);
|
|||
*
|
||||
* This function returns 0 if successful, or -1 if there was an error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval, SDL_TimerCallback callback);
|
||||
extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval,
|
||||
SDL_TimerCallback callback);
|
||||
|
||||
/* New timer API, supports multiple timers
|
||||
* Written by Stephane Peter <megastep@lokigames.com>
|
||||
|
@ -99,7 +106,9 @@ typedef struct _SDL_TimerID *SDL_TimerID;
|
|||
/* Add a new timer to the pool of timers already running.
|
||||
Returns a timer ID, or NULL when an error occurs.
|
||||
*/
|
||||
extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param);
|
||||
extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval,
|
||||
SDL_NewTimerCallback
|
||||
callback, void *param);
|
||||
|
||||
/* Remove one of the multiple timers knowing its ID.
|
||||
* Returns a boolean value indicating success.
|
||||
|
@ -108,8 +117,12 @@ extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID t);
|
|||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_timer_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -20,7 +20,11 @@
|
|||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/* This header defines the current SDL version */
|
||||
/**
|
||||
* \file SDL_version.h
|
||||
*
|
||||
* This header defines the current SDL version
|
||||
*/
|
||||
|
||||
#ifndef _SDL_version_h
|
||||
#define _SDL_version_h
|
||||
|
@ -30,29 +34,58 @@
|
|||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \struct SDL_version
|
||||
* \brief Information the version of SDL in use.
|
||||
*
|
||||
* Represents the library's version as three levels: major revision
|
||||
* (increments with massive changes, additions, and enhancements),
|
||||
* minor revision (increments with backwards-compatible changes to the
|
||||
* major revision), and patchlevel (increments with fixes to the minor
|
||||
* revision).
|
||||
*
|
||||
* \sa SDL_VERSION
|
||||
* \sa SDL_GetVersion
|
||||
*/
|
||||
typedef struct SDL_version
|
||||
{
|
||||
Uint8 major; /**< major version */
|
||||
Uint8 minor; /**< minor version */
|
||||
Uint8 patch; /**< update version */
|
||||
} SDL_version;
|
||||
|
||||
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
|
||||
*/
|
||||
#define SDL_MAJOR_VERSION 1
|
||||
#define SDL_MINOR_VERSION 2
|
||||
#define SDL_PATCHLEVEL 11
|
||||
#define SDL_MINOR_VERSION 3
|
||||
#define SDL_PATCHLEVEL 0
|
||||
|
||||
typedef struct SDL_version {
|
||||
Uint8 major;
|
||||
Uint8 minor;
|
||||
Uint8 patch;
|
||||
} SDL_version;
|
||||
|
||||
/* This macro can be used to fill a version structure with the compile-time
|
||||
* version of the SDL library.
|
||||
/**
|
||||
* \def SDL_VERSION(x)
|
||||
* \brief Macro to determine SDL version program was compiled against.
|
||||
*
|
||||
* This macro fills in a SDL_version structure with the version of the
|
||||
* library you compiled against. This is determined by what header the
|
||||
* compiler uses. Note that if you dynamically linked the library, you might
|
||||
* have a slightly newer or older version at runtime. That version can be
|
||||
* determined with SDL_GetVersion(), which, unlike SDL_VERSION,
|
||||
* is not a macro.
|
||||
*
|
||||
* \param x A pointer to a SDL_version struct to initialize.
|
||||
*
|
||||
* \sa SDL_version
|
||||
* \sa SDL_GetVersion
|
||||
*/
|
||||
#define SDL_VERSION(X) \
|
||||
#define SDL_VERSION(x) \
|
||||
{ \
|
||||
(X)->major = SDL_MAJOR_VERSION; \
|
||||
(X)->minor = SDL_MINOR_VERSION; \
|
||||
(X)->patch = SDL_PATCHLEVEL; \
|
||||
(x)->major = SDL_MAJOR_VERSION; \
|
||||
(x)->minor = SDL_MINOR_VERSION; \
|
||||
(x)->patch = SDL_PATCHLEVEL; \
|
||||
}
|
||||
|
||||
/* This macro turns the version numbers into a numeric value:
|
||||
|
@ -70,16 +103,42 @@ typedef struct SDL_version {
|
|||
#define SDL_VERSION_ATLEAST(X, Y, Z) \
|
||||
(SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
|
||||
|
||||
/* This function gets the version of the dynamically linked SDL library.
|
||||
it should NOT be used to fill a version structure, instead you should
|
||||
use the SDL_Version() macro.
|
||||
/**
|
||||
* \fn void SDL_GetVersion(SDL_version *ver)
|
||||
* \brief Get the version of SDL that is linked against your program.
|
||||
*
|
||||
* If you are using a shared library (DLL) version of SDL, then it is
|
||||
* possible that it will be different than the version you compiled against.
|
||||
*
|
||||
* This is a real function; the macro SDL_VERSION tells you what version
|
||||
* of SDL you compiled against:
|
||||
*
|
||||
* \code
|
||||
* SDL_version compiled;
|
||||
* SDL_version linked;
|
||||
*
|
||||
* SDL_VERSION(&compiled);
|
||||
* SDL_GetVersion(&linked);
|
||||
* printf("We compiled against SDL version %d.%d.%d ...\n",
|
||||
* compiled.major, compiled.minor, compiled.patch);
|
||||
* printf("But we linked against SDL version %d.%d.%d.\n",
|
||||
* linked.major, linked.minor, linked.patch);
|
||||
* \endcode
|
||||
*
|
||||
* This function may be called safely at any time, even before SDL_Init().
|
||||
*
|
||||
* \sa SDL_VERSION
|
||||
*/
|
||||
extern DECLSPEC const SDL_version * SDLCALL SDL_Linked_Version(void);
|
||||
extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_version_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
1673
include/SDL_video.h
1673
include/SDL_video.h
File diff suppressed because it is too large
Load diff
|
@ -38,4 +38,3 @@
|
|||
#pragma pack(pop)
|
||||
#endif
|
||||
#endif /* Compiler needs structure packing set */
|
||||
|
||||
|
|
1229
include/doxyfile
Normal file
1229
include/doxyfile
Normal file
File diff suppressed because it is too large
Load diff
|
@ -16,7 +16,7 @@ fi
|
|||
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
-*=*) optarg=`echo "$1" | LC_ALL="C" sed 's/[-_a-zA-Z0-9]*=//'` ;;
|
||||
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
|
||||
*) optarg= ;;
|
||||
esac
|
||||
|
||||
|
|
81
src/SDL.c
81
src/SDL.c
|
@ -48,10 +48,6 @@ extern int SDL_TimerInit(void);
|
|||
extern void SDL_TimerQuit(void);
|
||||
#endif
|
||||
|
||||
/* The current SDL version */
|
||||
static SDL_version version =
|
||||
{ SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL };
|
||||
|
||||
/* The initialized subsystems */
|
||||
static Uint32 SDL_initialized = 0;
|
||||
static Uint32 ticks_started = 0;
|
||||
|
@ -60,7 +56,8 @@ static Uint32 ticks_started = 0;
|
|||
int surfaces_allocated = 0;
|
||||
#endif
|
||||
|
||||
int SDL_InitSubSystem(Uint32 flags)
|
||||
int
|
||||
SDL_InitSubSystem(Uint32 flags)
|
||||
{
|
||||
#if !SDL_VIDEO_DISABLED
|
||||
/* Initialize the video/event subsystem */
|
||||
|
@ -114,8 +111,7 @@ int SDL_InitSubSystem(Uint32 flags)
|
|||
|
||||
#if !SDL_JOYSTICK_DISABLED
|
||||
/* Initialize the joystick subsystem */
|
||||
if ( (flags & SDL_INIT_JOYSTICK) &&
|
||||
!(SDL_initialized & SDL_INIT_JOYSTICK) ) {
|
||||
if ((flags & SDL_INIT_JOYSTICK) && !(SDL_initialized & SDL_INIT_JOYSTICK)) {
|
||||
if (SDL_JoystickInit() < 0) {
|
||||
return (-1);
|
||||
}
|
||||
|
@ -145,7 +141,8 @@ int SDL_InitSubSystem(Uint32 flags)
|
|||
return (0);
|
||||
}
|
||||
|
||||
int SDL_Init(Uint32 flags)
|
||||
int
|
||||
SDL_Init(Uint32 flags)
|
||||
{
|
||||
#if !SDL_THREADS_DISABLED && SDL_THREAD_PTH
|
||||
if (!pth_init()) {
|
||||
|
@ -168,7 +165,8 @@ int SDL_Init(Uint32 flags)
|
|||
return (0);
|
||||
}
|
||||
|
||||
void SDL_QuitSubSystem(Uint32 flags)
|
||||
void
|
||||
SDL_QuitSubSystem(Uint32 flags)
|
||||
{
|
||||
/* Shut down requested initialized subsystems */
|
||||
#if !SDL_CDROM_DISABLED
|
||||
|
@ -203,7 +201,8 @@ void SDL_QuitSubSystem(Uint32 flags)
|
|||
#endif
|
||||
}
|
||||
|
||||
Uint32 SDL_WasInit(Uint32 flags)
|
||||
Uint32
|
||||
SDL_WasInit(Uint32 flags)
|
||||
{
|
||||
if (!flags) {
|
||||
flags = SDL_INIT_EVERYTHING;
|
||||
|
@ -211,17 +210,20 @@ Uint32 SDL_WasInit(Uint32 flags)
|
|||
return (SDL_initialized & flags);
|
||||
}
|
||||
|
||||
void SDL_Quit(void)
|
||||
void
|
||||
SDL_Quit(void)
|
||||
{
|
||||
/* Quit all subsystems */
|
||||
#ifdef DEBUG_BUILD
|
||||
printf("[SDL_Quit] : Enter! Calling QuitSubSystem()\n"); fflush(stdout);
|
||||
printf("[SDL_Quit] : Enter! Calling QuitSubSystem()\n");
|
||||
fflush(stdout);
|
||||
#endif
|
||||
SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
|
||||
|
||||
#ifdef CHECK_LEAKS
|
||||
#ifdef DEBUG_BUILD
|
||||
printf("[SDL_Quit] : CHECK_LEAKS\n"); fflush(stdout);
|
||||
printf("[SDL_Quit] : CHECK_LEAKS\n");
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
/* Print the number of surfaces not freed */
|
||||
|
@ -231,7 +233,8 @@ void SDL_Quit(void)
|
|||
}
|
||||
#endif
|
||||
#ifdef DEBUG_BUILD
|
||||
printf("[SDL_Quit] : SDL_UninstallParachute()\n"); fflush(stdout);
|
||||
printf("[SDL_Quit] : SDL_UninstallParachute()\n");
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
/* Uninstall any parachute signal handlers */
|
||||
|
@ -241,15 +244,17 @@ void SDL_Quit(void)
|
|||
pth_kill();
|
||||
#endif
|
||||
#ifdef DEBUG_BUILD
|
||||
printf("[SDL_Quit] : Returning!\n"); fflush(stdout);
|
||||
printf("[SDL_Quit] : Returning!\n");
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/* Return the library version number */
|
||||
const SDL_version * SDL_Linked_Version(void)
|
||||
/* Get the library version number */
|
||||
void
|
||||
SDL_GetVersion(SDL_version * ver)
|
||||
{
|
||||
return(&version);
|
||||
SDL_VERSION(ver);
|
||||
}
|
||||
|
||||
#if defined(__OS2__)
|
||||
|
@ -261,10 +266,10 @@ const SDL_version * SDL_Linked_Version(void)
|
|||
#include <os2.h>
|
||||
|
||||
/* Exception handler to prevent the Audio thread hanging, making a zombie process! */
|
||||
ULONG _System SDL_Main_ExceptionHandler(PEXCEPTIONREPORTRECORD pERepRec,
|
||||
ULONG _System
|
||||
SDL_Main_ExceptionHandler(PEXCEPTIONREPORTRECORD pERepRec,
|
||||
PEXCEPTIONREGISTRATIONRECORD pERegRec,
|
||||
PCONTEXTRECORD pCtxRec,
|
||||
PVOID p)
|
||||
PCONTEXTRECORD pCtxRec, PVOID p)
|
||||
{
|
||||
if (pERepRec->fHandlerFlags & EH_EXIT_UNWIND)
|
||||
return XCPT_CONTINUE_SEARCH;
|
||||
|
@ -274,16 +279,14 @@ ULONG _System SDL_Main_ExceptionHandler(PEXCEPTIONREPORTRECORD pERepRec,
|
|||
return XCPT_CONTINUE_SEARCH;
|
||||
|
||||
/* Do cleanup at every fatal exception! */
|
||||
if (((pERepRec->ExceptionNum & XCPT_SEVERITY_CODE) == XCPT_FATAL_EXCEPTION) &&
|
||||
(pERepRec->ExceptionNum != XCPT_BREAKPOINT) &&
|
||||
(pERepRec->ExceptionNum != XCPT_SINGLE_STEP)
|
||||
)
|
||||
{
|
||||
if (SDL_initialized & SDL_INIT_AUDIO)
|
||||
{
|
||||
if (((pERepRec->ExceptionNum & XCPT_SEVERITY_CODE) ==
|
||||
XCPT_FATAL_EXCEPTION) && (pERepRec->ExceptionNum != XCPT_BREAKPOINT)
|
||||
&& (pERepRec->ExceptionNum != XCPT_SINGLE_STEP)) {
|
||||
if (SDL_initialized & SDL_INIT_AUDIO) {
|
||||
/* This removes the zombie audio thread in case of emergency. */
|
||||
#ifdef DEBUG_BUILD
|
||||
printf("[SDL_Main_ExceptionHandler] : Calling SDL_CloseAudio()!\n");
|
||||
printf
|
||||
("[SDL_Main_ExceptionHandler] : Calling SDL_CloseAudio()!\n");
|
||||
#endif
|
||||
SDL_CloseAudio();
|
||||
}
|
||||
|
@ -292,20 +295,20 @@ ULONG _System SDL_Main_ExceptionHandler(PEXCEPTIONREPORTRECORD pERepRec,
|
|||
}
|
||||
|
||||
|
||||
EXCEPTIONREGISTRATIONRECORD SDL_Main_xcpthand = {0, SDL_Main_ExceptionHandler};
|
||||
EXCEPTIONREGISTRATIONRECORD SDL_Main_xcpthand =
|
||||
{ 0, SDL_Main_ExceptionHandler };
|
||||
|
||||
/* The main DLL entry for DLL Initialization and Uninitialization: */
|
||||
unsigned _System LibMain(unsigned hmod, unsigned termination)
|
||||
{
|
||||
if (termination)
|
||||
unsigned _System
|
||||
LibMain(unsigned hmod, unsigned termination)
|
||||
{
|
||||
if (termination) {
|
||||
#ifdef DEBUG_BUILD
|
||||
/* printf("[SDL DLL Unintialization] : Removing exception handler\n"); */
|
||||
#endif
|
||||
DosUnsetExceptionHandler(&SDL_Main_xcpthand);
|
||||
return 1;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
#ifdef DEBUG_BUILD
|
||||
/* Make stdout and stderr unbuffered! */
|
||||
setbuf(stdout, NULL);
|
||||
|
@ -330,9 +333,9 @@ unsigned _System LibMain(unsigned hmod, unsigned termination)
|
|||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
BOOL APIENTRY _DllMainCRTStartup( HANDLE hModule,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID lpReserved )
|
||||
BOOL APIENTRY
|
||||
_DllMainCRTStartup(HANDLE hModule,
|
||||
DWORD ul_reason_for_call, LPVOID lpReserved)
|
||||
{
|
||||
switch (ul_reason_for_call) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
|
@ -346,3 +349,5 @@ BOOL APIENTRY _DllMainCRTStartup( HANDLE hModule,
|
|||
#endif /* building DLL with Watcom C */
|
||||
|
||||
#endif /* OS/2 elif __WIN32__ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
1415
src/SDL_compat.c
Normal file
1415
src/SDL_compat.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -39,7 +39,8 @@ extern SDL_error *SDL_GetErrBuf(void);
|
|||
|
||||
/* Private functions */
|
||||
|
||||
static const char *SDL_LookupString(const char *key)
|
||||
static const char *
|
||||
SDL_LookupString(const char *key)
|
||||
{
|
||||
/* FIXME: Add code to lookup key in language string hash-table */
|
||||
return key;
|
||||
|
@ -47,7 +48,8 @@ static const char *SDL_LookupString(const char *key)
|
|||
|
||||
/* Public functions */
|
||||
|
||||
void SDL_SetError (const char *fmt, ...)
|
||||
void
|
||||
SDL_SetError(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
SDL_error *error;
|
||||
|
@ -75,16 +77,13 @@ void SDL_SetError (const char *fmt, ...)
|
|||
case 'o':
|
||||
case 'x':
|
||||
case 'X':
|
||||
error->args[error->argc++].value_i =
|
||||
va_arg(ap, int);
|
||||
error->args[error->argc++].value_i = va_arg(ap, int);
|
||||
break;
|
||||
case 'f':
|
||||
error->args[error->argc++].value_f =
|
||||
va_arg(ap, double);
|
||||
error->args[error->argc++].value_f = va_arg(ap, double);
|
||||
break;
|
||||
case 'p':
|
||||
error->args[error->argc++].value_ptr =
|
||||
va_arg(ap, void *);
|
||||
error->args[error->argc++].value_ptr = va_arg(ap, void *);
|
||||
break;
|
||||
case 's':
|
||||
{
|
||||
|
@ -92,7 +91,8 @@ void SDL_SetError (const char *fmt, ...)
|
|||
const char *str = va_arg(ap, const char *);
|
||||
if (str == NULL)
|
||||
str = "(null)";
|
||||
SDL_strlcpy((char *)error->args[i].buf, str, ERR_MAX_STRLEN);
|
||||
SDL_strlcpy((char *) error->args[i].buf, str,
|
||||
ERR_MAX_STRLEN);
|
||||
error->argc++;
|
||||
}
|
||||
break;
|
||||
|
@ -115,12 +115,14 @@ void SDL_SetError (const char *fmt, ...)
|
|||
/* This function has a bit more overhead than most error functions
|
||||
so that it supports internationalization and thread-safe errors.
|
||||
*/
|
||||
char *SDL_GetErrorMsg(char *errstr, unsigned int maxlen)
|
||||
char *
|
||||
SDL_GetErrorMsg(char *errstr, unsigned int maxlen)
|
||||
{
|
||||
SDL_error *error;
|
||||
|
||||
/* Clear the error string */
|
||||
*errstr = '\0'; --maxlen;
|
||||
*errstr = '\0';
|
||||
--maxlen;
|
||||
|
||||
/* Get the thread-safe error, and print it out */
|
||||
error = SDL_GetErrBuf();
|
||||
|
@ -136,7 +138,8 @@ char *SDL_GetErrorMsg(char *errstr, unsigned int maxlen)
|
|||
if (*fmt == '%') {
|
||||
char tmp[32], *spot = tmp;
|
||||
*spot++ = *fmt++;
|
||||
while ( (*fmt == '.' || (*fmt >= '0' && *fmt <= '9')) && spot < (tmp+SDL_arraysize(tmp)-2) ) {
|
||||
while ((*fmt == '.' || (*fmt >= '0' && *fmt <= '9'))
|
||||
&& spot < (tmp + SDL_arraysize(tmp) - 2)) {
|
||||
*spot++ = *fmt++;
|
||||
}
|
||||
*spot++ = *fmt++;
|
||||
|
@ -153,22 +156,31 @@ char *SDL_GetErrorMsg(char *errstr, unsigned int maxlen)
|
|||
case 'o':
|
||||
case 'x':
|
||||
case 'X':
|
||||
len = SDL_snprintf(msg, maxlen, tmp, error->args[argi++].value_i);
|
||||
len =
|
||||
SDL_snprintf(msg, maxlen, tmp,
|
||||
error->args[argi++].value_i);
|
||||
msg += len;
|
||||
maxlen -= len;
|
||||
break;
|
||||
case 'f':
|
||||
len = SDL_snprintf(msg, maxlen, tmp, error->args[argi++].value_f);
|
||||
len =
|
||||
SDL_snprintf(msg, maxlen, tmp,
|
||||
error->args[argi++].value_f);
|
||||
msg += len;
|
||||
maxlen -= len;
|
||||
break;
|
||||
case 'p':
|
||||
len = SDL_snprintf(msg, maxlen, tmp, error->args[argi++].value_ptr);
|
||||
len =
|
||||
SDL_snprintf(msg, maxlen, tmp,
|
||||
error->args[argi++].value_ptr);
|
||||
msg += len;
|
||||
maxlen -= len;
|
||||
break;
|
||||
case 's':
|
||||
len = SDL_snprintf(msg, maxlen, tmp, SDL_LookupString(error->args[argi++].buf));
|
||||
len =
|
||||
SDL_snprintf(msg, maxlen, tmp,
|
||||
SDL_LookupString(error->
|
||||
args[argi++].buf));
|
||||
msg += len;
|
||||
maxlen -= len;
|
||||
break;
|
||||
|
@ -184,14 +196,16 @@ char *SDL_GetErrorMsg(char *errstr, unsigned int maxlen)
|
|||
}
|
||||
|
||||
/* Available for backwards compatibility */
|
||||
char *SDL_GetError (void)
|
||||
char *
|
||||
SDL_GetError(void)
|
||||
{
|
||||
static char errmsg[SDL_ERRBUFIZE];
|
||||
|
||||
return ((char *) SDL_GetErrorMsg(errmsg, SDL_ERRBUFIZE));
|
||||
}
|
||||
|
||||
void SDL_ClearError(void)
|
||||
void
|
||||
SDL_ClearError(void)
|
||||
{
|
||||
SDL_error *error;
|
||||
|
||||
|
@ -200,7 +214,8 @@ void SDL_ClearError(void)
|
|||
}
|
||||
|
||||
/* Very common errors go here */
|
||||
void SDL_Error(SDL_errorcode code)
|
||||
void
|
||||
SDL_Error(SDL_errorcode code)
|
||||
{
|
||||
switch (code) {
|
||||
case SDL_ENOMEM:
|
||||
|
@ -222,7 +237,8 @@ void SDL_Error(SDL_errorcode code)
|
|||
}
|
||||
|
||||
#ifdef TEST_ERROR
|
||||
int main(int argc, char *argv[])
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char buffer[BUFSIZ + 1];
|
||||
|
||||
|
@ -236,3 +252,4 @@ int main(int argc, char *argv[])
|
|||
exit(0);
|
||||
}
|
||||
#endif
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
#define ERR_MAX_STRLEN 128
|
||||
#define ERR_MAX_ARGS 5
|
||||
|
||||
typedef struct SDL_error {
|
||||
typedef struct SDL_error
|
||||
{
|
||||
/* This is a numeric value corresponding to the current error */
|
||||
int error;
|
||||
|
||||
|
@ -44,7 +45,8 @@ typedef struct SDL_error {
|
|||
|
||||
/* These are the arguments for the error functions */
|
||||
int argc;
|
||||
union {
|
||||
union
|
||||
{
|
||||
void *value_ptr;
|
||||
#if 0 /* What is a character anyway? (UNICODE issues) */
|
||||
unsigned char value_c;
|
||||
|
@ -56,3 +58,4 @@ typedef struct SDL_error {
|
|||
} SDL_error;
|
||||
|
||||
#endif /* _SDL_error_c_h */
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -35,7 +35,8 @@
|
|||
the program crashes.
|
||||
*/
|
||||
|
||||
static void SDL_Parachute(int sig)
|
||||
static void
|
||||
SDL_Parachute(int sig)
|
||||
{
|
||||
signal(sig, SIG_DFL);
|
||||
SDL_Quit();
|
||||
|
@ -56,7 +57,8 @@ static int SDL_fatal_signals[] = {
|
|||
0
|
||||
};
|
||||
|
||||
void SDL_InstallParachute(void)
|
||||
void
|
||||
SDL_InstallParachute(void)
|
||||
{
|
||||
/* Set a handler for any fatal signal not already handled */
|
||||
int i;
|
||||
|
@ -91,7 +93,8 @@ void SDL_InstallParachute(void)
|
|||
return;
|
||||
}
|
||||
|
||||
void SDL_UninstallParachute(void)
|
||||
void
|
||||
SDL_UninstallParachute(void)
|
||||
{
|
||||
/* Remove a handler for any fatal signal handled */
|
||||
int i;
|
||||
|
@ -121,14 +124,17 @@ void SDL_UninstallParachute(void)
|
|||
|
||||
/* No signals on this platform, nothing to do.. */
|
||||
|
||||
void SDL_InstallParachute(void)
|
||||
void
|
||||
SDL_InstallParachute(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void SDL_UninstallParachute(void)
|
||||
void
|
||||
SDL_UninstallParachute(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* HAVE_SIGNAL_H */
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -25,4 +25,4 @@
|
|||
|
||||
extern void SDL_InstallParachute(void);
|
||||
extern void SDL_UninstallParachute(void);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -120,7 +120,8 @@ static int audio_configured = 0;
|
|||
#endif
|
||||
|
||||
/* The general mixing thread function */
|
||||
int SDLCALL SDL_RunAudio(void *audiop)
|
||||
int SDLCALL
|
||||
SDL_RunAudio(void *audiop)
|
||||
{
|
||||
SDL_AudioDevice *audio = (SDL_AudioDevice *) audiop;
|
||||
Uint8 *stream;
|
||||
|
@ -136,8 +137,7 @@ int SDLCALL SDL_RunAudio(void *audiop)
|
|||
D(bug("Task audio started audio struct:<%lx>...\n", audiop));
|
||||
|
||||
D(bug("Before Openaudio..."));
|
||||
if(audio->OpenAudio(audio, &audio->spec)==-1)
|
||||
{
|
||||
if (audio->OpenAudio(audio, &audio->spec) == -1) {
|
||||
D(bug("Open audio failed...\n"));
|
||||
return (-1);
|
||||
}
|
||||
|
@ -183,17 +183,18 @@ int SDLCALL SDL_RunAudio(void *audiop)
|
|||
/* Increase the priority of this thread to make sure that
|
||||
the audio will be continuous all the time! */
|
||||
#ifdef USE_DOSSETPRIORITY
|
||||
if (SDL_getenv("SDL_USE_TIMECRITICAL_AUDIO"))
|
||||
{
|
||||
if (SDL_getenv("SDL_USE_TIMECRITICAL_AUDIO")) {
|
||||
#ifdef DEBUG_BUILD
|
||||
printf("[SDL_RunAudio] : Setting priority to TimeCritical+0! (TID%d)\n", SDL_ThreadID());
|
||||
printf
|
||||
("[SDL_RunAudio] : Setting priority to TimeCritical+0! (TID%d)\n",
|
||||
SDL_ThreadID());
|
||||
#endif
|
||||
DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
#ifdef DEBUG_BUILD
|
||||
printf("[SDL_RunAudio] : Setting priority to ForegroundServer+0! (TID%d)\n", SDL_ThreadID());
|
||||
printf
|
||||
("[SDL_RunAudio] : Setting priority to ForegroundServer+0! (TID%d)\n",
|
||||
SDL_ThreadID());
|
||||
#endif
|
||||
DosSetPriority(PRTYS_THREAD, PRTYC_FOREGROUNDSERVER, 0, 0);
|
||||
}
|
||||
|
@ -231,8 +232,7 @@ int SDLCALL SDL_RunAudio(void *audiop)
|
|||
if (stream == NULL) {
|
||||
stream = audio->fake_stream;
|
||||
}
|
||||
SDL_memcpy(stream, audio->convert.buf,
|
||||
audio->convert.len_cvt);
|
||||
SDL_memcpy(stream, audio->convert.buf, audio->convert.len_cvt);
|
||||
}
|
||||
|
||||
/* Ready current buffer for play and change current buffer */
|
||||
|
@ -252,7 +252,6 @@ int SDLCALL SDL_RunAudio(void *audiop)
|
|||
if (audio->WaitDone) {
|
||||
audio->WaitDone(audio);
|
||||
}
|
||||
|
||||
#if SDL_AUDIO_DRIVER_AHI
|
||||
D(bug("WaitAudio...Done\n"));
|
||||
|
||||
|
@ -269,7 +268,8 @@ int SDLCALL SDL_RunAudio(void *audiop)
|
|||
return (0);
|
||||
}
|
||||
|
||||
static void SDL_LockAudio_Default(SDL_AudioDevice *audio)
|
||||
static void
|
||||
SDL_LockAudio_Default(SDL_AudioDevice * audio)
|
||||
{
|
||||
if (audio->thread && (SDL_ThreadID() == audio->threadid)) {
|
||||
return;
|
||||
|
@ -277,7 +277,8 @@ static void SDL_LockAudio_Default(SDL_AudioDevice *audio)
|
|||
SDL_mutexP(audio->mixer_lock);
|
||||
}
|
||||
|
||||
static void SDL_UnlockAudio_Default(SDL_AudioDevice *audio)
|
||||
static void
|
||||
SDL_UnlockAudio_Default(SDL_AudioDevice * audio)
|
||||
{
|
||||
if (audio->thread && (SDL_ThreadID() == audio->threadid)) {
|
||||
return;
|
||||
|
@ -285,7 +286,8 @@ static void SDL_UnlockAudio_Default(SDL_AudioDevice *audio)
|
|||
SDL_mutexV(audio->mixer_lock);
|
||||
}
|
||||
|
||||
static Uint16 SDL_ParseAudioFormat(const char *string)
|
||||
static Uint16
|
||||
SDL_ParseAudioFormat(const char *string)
|
||||
{
|
||||
Uint16 format = 0;
|
||||
|
||||
|
@ -330,7 +332,23 @@ static Uint16 SDL_ParseAudioFormat(const char *string)
|
|||
return format;
|
||||
}
|
||||
|
||||
int SDL_AudioInit(const char *driver_name)
|
||||
int
|
||||
SDL_GetNumAudioDrivers(void)
|
||||
{
|
||||
return (SDL_arraysize(bootstrap) - 1);
|
||||
}
|
||||
|
||||
const char *
|
||||
SDL_GetAudioDriver(int index)
|
||||
{
|
||||
if (index >= 0 && index < SDL_GetNumAudioDrivers()) {
|
||||
return (bootstrap[index]->name);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
int
|
||||
SDL_AudioInit(const char *driver_name)
|
||||
{
|
||||
SDL_AudioDevice *audio;
|
||||
int i = 0, idx;
|
||||
|
@ -385,8 +403,8 @@ int SDL_AudioInit(const char *driver_name)
|
|||
SDL_strlen(bootstrap[i]->name)) == 0) {
|
||||
if (bootstrap[i]->available()) {
|
||||
audio = bootstrap[i]->create(idx);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -400,7 +418,11 @@ int SDL_AudioInit(const char *driver_name)
|
|||
}
|
||||
}
|
||||
if (audio == NULL) {
|
||||
if (driver_name) {
|
||||
SDL_SetError("%s not available", driver_name);
|
||||
} else {
|
||||
SDL_SetError("No available audio device");
|
||||
}
|
||||
#if 0 /* Don't fail SDL_Init() if audio isn't available.
|
||||
SDL_OpenAudio() will handle it at that point. *sigh*
|
||||
*/
|
||||
|
@ -419,16 +441,20 @@ int SDL_AudioInit(const char *driver_name)
|
|||
return (0);
|
||||
}
|
||||
|
||||
char *SDL_AudioDriverName(char *namebuf, int maxlen)
|
||||
/*
|
||||
* Get the current audio driver name
|
||||
*/
|
||||
const char *
|
||||
SDL_GetCurrentAudioDriver()
|
||||
{
|
||||
if ( current_audio != NULL ) {
|
||||
SDL_strlcpy(namebuf, current_audio->name, maxlen);
|
||||
return(namebuf);
|
||||
if (current_audio) {
|
||||
return current_audio->name;
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
|
||||
int
|
||||
SDL_OpenAudio(SDL_AudioSpec * desired, SDL_AudioSpec * obtained)
|
||||
{
|
||||
SDL_AudioDevice *audio;
|
||||
const char *env;
|
||||
|
@ -507,7 +533,6 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
|
|||
SDL_SetError("SDL_OpenAudio() passed a NULL callback");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
#if defined(__MACOS__) || (defined(__RISCOS__) && SDL_THREADS_DISABLED)
|
||||
/* FIXME: Need to implement PPC interrupt asm for SDL_LockAudio() */
|
||||
#else
|
||||
|
@ -592,8 +617,9 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
|
|||
}
|
||||
if (audio->convert.needed) {
|
||||
audio->convert.len = desired->size;
|
||||
audio->convert.buf =(Uint8 *)SDL_AllocAudioMem(
|
||||
audio->convert.len*audio->convert.len_mult);
|
||||
audio->convert.buf =
|
||||
(Uint8 *) SDL_AllocAudioMem(audio->convert.len *
|
||||
audio->convert.len_mult);
|
||||
if (audio->convert.buf == NULL) {
|
||||
SDL_CloseAudio();
|
||||
SDL_OutOfMemory();
|
||||
|
@ -601,7 +627,6 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if !SDL_AUDIO_DRIVER_AHI
|
||||
/* Start the audio thread if necessary */
|
||||
switch (audio->opened) {
|
||||
|
@ -633,7 +658,8 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
|
|||
return (0);
|
||||
}
|
||||
|
||||
SDL_audiostatus SDL_GetAudioStatus(void)
|
||||
SDL_audiostatus
|
||||
SDL_GetAudioStatus(void)
|
||||
{
|
||||
SDL_AudioDevice *audio = current_audio;
|
||||
SDL_audiostatus status;
|
||||
|
@ -649,7 +675,8 @@ SDL_audiostatus SDL_GetAudioStatus(void)
|
|||
return (status);
|
||||
}
|
||||
|
||||
void SDL_PauseAudio (int pause_on)
|
||||
void
|
||||
SDL_PauseAudio(int pause_on)
|
||||
{
|
||||
SDL_AudioDevice *audio = current_audio;
|
||||
|
||||
|
@ -658,7 +685,8 @@ void SDL_PauseAudio (int pause_on)
|
|||
}
|
||||
}
|
||||
|
||||
void SDL_LockAudio (void)
|
||||
void
|
||||
SDL_LockAudio(void)
|
||||
{
|
||||
SDL_AudioDevice *audio = current_audio;
|
||||
|
||||
|
@ -668,7 +696,8 @@ void SDL_LockAudio (void)
|
|||
}
|
||||
}
|
||||
|
||||
void SDL_UnlockAudio (void)
|
||||
void
|
||||
SDL_UnlockAudio(void)
|
||||
{
|
||||
SDL_AudioDevice *audio = current_audio;
|
||||
|
||||
|
@ -678,12 +707,14 @@ void SDL_UnlockAudio (void)
|
|||
}
|
||||
}
|
||||
|
||||
void SDL_CloseAudio (void)
|
||||
void
|
||||
SDL_CloseAudio(void)
|
||||
{
|
||||
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
||||
}
|
||||
|
||||
void SDL_AudioQuit(void)
|
||||
void
|
||||
SDL_AudioQuit(void)
|
||||
{
|
||||
SDL_AudioDevice *audio = current_audio;
|
||||
|
||||
|
@ -718,15 +749,22 @@ void SDL_AudioQuit(void)
|
|||
static int format_idx;
|
||||
static int format_idx_sub;
|
||||
static Uint16 format_list[NUM_FORMATS][NUM_FORMATS] = {
|
||||
{ AUDIO_U8, AUDIO_S8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB },
|
||||
{ AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB },
|
||||
{ AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_U8, AUDIO_S8 },
|
||||
{ AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_U8, AUDIO_S8 },
|
||||
{ AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U8, AUDIO_S8 },
|
||||
{ AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U8, AUDIO_S8 },
|
||||
{AUDIO_U8, AUDIO_S8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB,
|
||||
AUDIO_U16MSB},
|
||||
{AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB,
|
||||
AUDIO_U16MSB},
|
||||
{AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_U8,
|
||||
AUDIO_S8},
|
||||
{AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_U8,
|
||||
AUDIO_S8},
|
||||
{AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U8,
|
||||
AUDIO_S8},
|
||||
{AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U8,
|
||||
AUDIO_S8},
|
||||
};
|
||||
|
||||
Uint16 SDL_FirstAudioFormat(Uint16 format)
|
||||
Uint16
|
||||
SDL_FirstAudioFormat(Uint16 format)
|
||||
{
|
||||
for (format_idx = 0; format_idx < NUM_FORMATS; ++format_idx) {
|
||||
if (format_list[format_idx][0] == format) {
|
||||
|
@ -737,7 +775,8 @@ Uint16 SDL_FirstAudioFormat(Uint16 format)
|
|||
return (SDL_NextAudioFormat());
|
||||
}
|
||||
|
||||
Uint16 SDL_NextAudioFormat(void)
|
||||
Uint16
|
||||
SDL_NextAudioFormat(void)
|
||||
{
|
||||
if ((format_idx == NUM_FORMATS) || (format_idx_sub == NUM_FORMATS)) {
|
||||
return (0);
|
||||
|
@ -745,7 +784,8 @@ Uint16 SDL_NextAudioFormat(void)
|
|||
return (format_list[format_idx][format_idx_sub++]);
|
||||
}
|
||||
|
||||
void SDL_CalculateAudioSpec(SDL_AudioSpec *spec)
|
||||
void
|
||||
SDL_CalculateAudioSpec(SDL_AudioSpec * spec)
|
||||
{
|
||||
switch (spec->format) {
|
||||
case AUDIO_U8:
|
||||
|
@ -759,3 +799,5 @@ void SDL_CalculateAudioSpec(SDL_AudioSpec *spec)
|
|||
spec->size *= spec->channels;
|
||||
spec->size *= spec->samples;
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -32,3 +32,4 @@ extern void SDL_CalculateAudioSpec(SDL_AudioSpec *spec);
|
|||
|
||||
/* The actual mixing thread function */
|
||||
extern int SDLCALL SDL_RunAudio(void *audiop);
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -27,7 +27,8 @@
|
|||
|
||||
|
||||
/* Effectively mix right and left channels into a single channel */
|
||||
void SDLCALL SDL_ConvertMono(SDL_AudioCVT *cvt, Uint16 format)
|
||||
void SDLCALL
|
||||
SDL_ConvertMono(SDL_AudioCVT * cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
Sint32 sample;
|
||||
|
@ -37,7 +38,8 @@ void SDLCALL SDL_ConvertMono(SDL_AudioCVT *cvt, Uint16 format)
|
|||
#endif
|
||||
switch (format & 0x8018) {
|
||||
|
||||
case AUDIO_U8: {
|
||||
case AUDIO_U8:
|
||||
{
|
||||
Uint8 *src, *dst;
|
||||
|
||||
src = cvt->buf;
|
||||
|
@ -55,7 +57,8 @@ void SDLCALL SDL_ConvertMono(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S8: {
|
||||
case AUDIO_S8:
|
||||
{
|
||||
Sint8 *src, *dst;
|
||||
|
||||
src = (Sint8 *) cvt->buf;
|
||||
|
@ -64,8 +67,7 @@ void SDLCALL SDL_ConvertMono(SDL_AudioCVT *cvt, Uint16 format)
|
|||
sample = src[0] + src[1];
|
||||
if (sample > 127) {
|
||||
*dst = 127;
|
||||
} else
|
||||
if ( sample < -128 ) {
|
||||
} else if (sample < -128) {
|
||||
*dst = -128;
|
||||
} else {
|
||||
*dst = (Sint8) sample;
|
||||
|
@ -76,7 +78,8 @@ void SDLCALL SDL_ConvertMono(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
break;
|
||||
|
||||
case AUDIO_U16: {
|
||||
case AUDIO_U16:
|
||||
{
|
||||
Uint8 *src, *dst;
|
||||
|
||||
src = cvt->buf;
|
||||
|
@ -115,7 +118,8 @@ void SDLCALL SDL_ConvertMono(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S16: {
|
||||
case AUDIO_S16:
|
||||
{
|
||||
Uint8 *src, *dst;
|
||||
|
||||
src = cvt->buf;
|
||||
|
@ -127,8 +131,7 @@ void SDLCALL SDL_ConvertMono(SDL_AudioCVT *cvt, Uint16 format)
|
|||
if (sample > 32767) {
|
||||
dst[0] = 0x7F;
|
||||
dst[1] = 0xFF;
|
||||
} else
|
||||
if ( sample < -32768 ) {
|
||||
} else if (sample < -32768) {
|
||||
dst[0] = 0x80;
|
||||
dst[1] = 0x00;
|
||||
} else {
|
||||
|
@ -146,8 +149,7 @@ void SDLCALL SDL_ConvertMono(SDL_AudioCVT *cvt, Uint16 format)
|
|||
if (sample > 32767) {
|
||||
dst[1] = 0x7F;
|
||||
dst[0] = 0xFF;
|
||||
} else
|
||||
if ( sample < -32768 ) {
|
||||
} else if (sample < -32768) {
|
||||
dst[1] = 0x80;
|
||||
dst[0] = 0x00;
|
||||
} else {
|
||||
|
@ -169,7 +171,8 @@ void SDLCALL SDL_ConvertMono(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
|
||||
/* Discard top 4 channels */
|
||||
void SDLCALL SDL_ConvertStrip(SDL_AudioCVT *cvt, Uint16 format)
|
||||
void SDLCALL
|
||||
SDL_ConvertStrip(SDL_AudioCVT * cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
Sint32 lsample, rsample;
|
||||
|
@ -179,7 +182,8 @@ void SDLCALL SDL_ConvertStrip(SDL_AudioCVT *cvt, Uint16 format)
|
|||
#endif
|
||||
switch (format & 0x8018) {
|
||||
|
||||
case AUDIO_U8: {
|
||||
case AUDIO_U8:
|
||||
{
|
||||
Uint8 *src, *dst;
|
||||
|
||||
src = cvt->buf;
|
||||
|
@ -193,7 +197,8 @@ void SDLCALL SDL_ConvertStrip(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S8: {
|
||||
case AUDIO_S8:
|
||||
{
|
||||
Sint8 *src, *dst;
|
||||
|
||||
src = (Sint8 *) cvt->buf;
|
||||
|
@ -207,7 +212,8 @@ void SDLCALL SDL_ConvertStrip(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
break;
|
||||
|
||||
case AUDIO_U16: {
|
||||
case AUDIO_U16:
|
||||
{
|
||||
Uint8 *src, *dst;
|
||||
|
||||
src = cvt->buf;
|
||||
|
@ -242,7 +248,8 @@ void SDLCALL SDL_ConvertStrip(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S16: {
|
||||
case AUDIO_S16:
|
||||
{
|
||||
Uint8 *src, *dst;
|
||||
|
||||
src = cvt->buf;
|
||||
|
@ -285,7 +292,8 @@ void SDLCALL SDL_ConvertStrip(SDL_AudioCVT *cvt, Uint16 format)
|
|||
|
||||
|
||||
/* Discard top 2 channels of 6 */
|
||||
void SDLCALL SDL_ConvertStrip_2(SDL_AudioCVT *cvt, Uint16 format)
|
||||
void SDLCALL
|
||||
SDL_ConvertStrip_2(SDL_AudioCVT * cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
Sint32 lsample, rsample;
|
||||
|
@ -295,7 +303,8 @@ void SDLCALL SDL_ConvertStrip_2(SDL_AudioCVT *cvt, Uint16 format)
|
|||
#endif
|
||||
switch (format & 0x8018) {
|
||||
|
||||
case AUDIO_U8: {
|
||||
case AUDIO_U8:
|
||||
{
|
||||
Uint8 *src, *dst;
|
||||
|
||||
src = cvt->buf;
|
||||
|
@ -309,7 +318,8 @@ void SDLCALL SDL_ConvertStrip_2(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S8: {
|
||||
case AUDIO_S8:
|
||||
{
|
||||
Sint8 *src, *dst;
|
||||
|
||||
src = (Sint8 *) cvt->buf;
|
||||
|
@ -323,7 +333,8 @@ void SDLCALL SDL_ConvertStrip_2(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
break;
|
||||
|
||||
case AUDIO_U16: {
|
||||
case AUDIO_U16:
|
||||
{
|
||||
Uint8 *src, *dst;
|
||||
|
||||
src = cvt->buf;
|
||||
|
@ -358,7 +369,8 @@ void SDLCALL SDL_ConvertStrip_2(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S16: {
|
||||
case AUDIO_S16:
|
||||
{
|
||||
Uint8 *src, *dst;
|
||||
|
||||
src = cvt->buf;
|
||||
|
@ -400,7 +412,8 @@ void SDLCALL SDL_ConvertStrip_2(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
|
||||
/* Duplicate a mono channel to both stereo channels */
|
||||
void SDLCALL SDL_ConvertStereo(SDL_AudioCVT *cvt, Uint16 format)
|
||||
void SDLCALL
|
||||
SDL_ConvertStereo(SDL_AudioCVT * cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -438,7 +451,8 @@ void SDLCALL SDL_ConvertStereo(SDL_AudioCVT *cvt, Uint16 format)
|
|||
|
||||
|
||||
/* Duplicate a stereo channel to a pseudo-5.1 stream */
|
||||
void SDLCALL SDL_ConvertSurround(SDL_AudioCVT *cvt, Uint16 format)
|
||||
void SDLCALL
|
||||
SDL_ConvertSurround(SDL_AudioCVT * cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -447,7 +461,8 @@ void SDLCALL SDL_ConvertSurround(SDL_AudioCVT *cvt, Uint16 format)
|
|||
#endif
|
||||
switch (format & 0x8018) {
|
||||
|
||||
case AUDIO_U8: {
|
||||
case AUDIO_U8:
|
||||
{
|
||||
Uint8 *src, *dst, lf, rf, ce;
|
||||
|
||||
src = (Uint8 *) (cvt->buf + cvt->len_cvt);
|
||||
|
@ -468,7 +483,8 @@ void SDLCALL SDL_ConvertSurround(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S8: {
|
||||
case AUDIO_S8:
|
||||
{
|
||||
Sint8 *src, *dst, lf, rf, ce;
|
||||
|
||||
src = (Sint8 *) cvt->buf + cvt->len_cvt;
|
||||
|
@ -489,7 +505,8 @@ void SDLCALL SDL_ConvertSurround(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
break;
|
||||
|
||||
case AUDIO_U16: {
|
||||
case AUDIO_U16:
|
||||
{
|
||||
Uint8 *src, *dst;
|
||||
Uint16 lf, rf, ce, lr, rr;
|
||||
|
||||
|
@ -548,7 +565,8 @@ void SDLCALL SDL_ConvertSurround(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S16: {
|
||||
case AUDIO_S16:
|
||||
{
|
||||
Uint8 *src, *dst;
|
||||
Sint16 lf, rf, ce, lr, rr;
|
||||
|
||||
|
@ -615,7 +633,8 @@ void SDLCALL SDL_ConvertSurround(SDL_AudioCVT *cvt, Uint16 format)
|
|||
|
||||
|
||||
/* Duplicate a stereo channel to a pseudo-4.0 stream */
|
||||
void SDLCALL SDL_ConvertSurround_4(SDL_AudioCVT *cvt, Uint16 format)
|
||||
void SDLCALL
|
||||
SDL_ConvertSurround_4(SDL_AudioCVT * cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -624,7 +643,8 @@ void SDLCALL SDL_ConvertSurround_4(SDL_AudioCVT *cvt, Uint16 format)
|
|||
#endif
|
||||
switch (format & 0x8018) {
|
||||
|
||||
case AUDIO_U8: {
|
||||
case AUDIO_U8:
|
||||
{
|
||||
Uint8 *src, *dst, lf, rf, ce;
|
||||
|
||||
src = (Uint8 *) (cvt->buf + cvt->len_cvt);
|
||||
|
@ -643,7 +663,8 @@ void SDLCALL SDL_ConvertSurround_4(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S8: {
|
||||
case AUDIO_S8:
|
||||
{
|
||||
Sint8 *src, *dst, lf, rf, ce;
|
||||
|
||||
src = (Sint8 *) cvt->buf + cvt->len_cvt;
|
||||
|
@ -662,7 +683,8 @@ void SDLCALL SDL_ConvertSurround_4(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
break;
|
||||
|
||||
case AUDIO_U16: {
|
||||
case AUDIO_U16:
|
||||
{
|
||||
Uint8 *src, *dst;
|
||||
Uint16 lf, rf, ce, lr, rr;
|
||||
|
||||
|
@ -711,7 +733,8 @@ void SDLCALL SDL_ConvertSurround_4(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S16: {
|
||||
case AUDIO_S16:
|
||||
{
|
||||
Uint8 *src, *dst;
|
||||
Sint16 lf, rf, ce, lr, rr;
|
||||
|
||||
|
@ -768,7 +791,8 @@ void SDLCALL SDL_ConvertSurround_4(SDL_AudioCVT *cvt, Uint16 format)
|
|||
|
||||
|
||||
/* Convert 8-bit to 16-bit - LSB */
|
||||
void SDLCALL SDL_Convert16LSB(SDL_AudioCVT *cvt, Uint16 format)
|
||||
void SDLCALL
|
||||
SDL_Convert16LSB(SDL_AudioCVT * cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
Uint8 *src, *dst;
|
||||
|
@ -790,8 +814,10 @@ void SDLCALL SDL_Convert16LSB(SDL_AudioCVT *cvt, Uint16 format)
|
|||
cvt->filters[cvt->filter_index] (cvt, format);
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert 8-bit to 16-bit - MSB */
|
||||
void SDLCALL SDL_Convert16MSB(SDL_AudioCVT *cvt, Uint16 format)
|
||||
void SDLCALL
|
||||
SDL_Convert16MSB(SDL_AudioCVT * cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
Uint8 *src, *dst;
|
||||
|
@ -815,7 +841,8 @@ void SDLCALL SDL_Convert16MSB(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
|
||||
/* Convert 16-bit to 8-bit */
|
||||
void SDLCALL SDL_Convert8(SDL_AudioCVT *cvt, Uint16 format)
|
||||
void SDLCALL
|
||||
SDL_Convert8(SDL_AudioCVT * cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
Uint8 *src, *dst;
|
||||
|
@ -841,7 +868,8 @@ void SDLCALL SDL_Convert8(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
|
||||
/* Toggle signed/unsigned */
|
||||
void SDLCALL SDL_ConvertSign(SDL_AudioCVT *cvt, Uint16 format)
|
||||
void SDLCALL
|
||||
SDL_ConvertSign(SDL_AudioCVT * cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
Uint8 *data;
|
||||
|
@ -870,7 +898,8 @@ void SDLCALL SDL_ConvertSign(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
|
||||
/* Toggle endianness */
|
||||
void SDLCALL SDL_ConvertEndian(SDL_AudioCVT *cvt, Uint16 format)
|
||||
void SDLCALL
|
||||
SDL_ConvertEndian(SDL_AudioCVT * cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
Uint8 *data, tmp;
|
||||
|
@ -892,7 +921,8 @@ void SDLCALL SDL_ConvertEndian(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
|
||||
/* Convert rate up by multiple of 2 */
|
||||
void SDLCALL SDL_RateMUL2(SDL_AudioCVT *cvt, Uint16 format)
|
||||
void SDLCALL
|
||||
SDL_RateMUL2(SDL_AudioCVT * cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
Uint8 *src, *dst;
|
||||
|
@ -930,7 +960,8 @@ void SDLCALL SDL_RateMUL2(SDL_AudioCVT *cvt, Uint16 format)
|
|||
|
||||
|
||||
/* Convert rate up by multiple of 2, for stereo */
|
||||
void SDLCALL SDL_RateMUL2_c2(SDL_AudioCVT *cvt, Uint16 format)
|
||||
void SDLCALL
|
||||
SDL_RateMUL2_c2(SDL_AudioCVT * cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
Uint8 *src, *dst;
|
||||
|
@ -973,7 +1004,8 @@ void SDLCALL SDL_RateMUL2_c2(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
|
||||
/* Convert rate up by multiple of 2, for quad */
|
||||
void SDLCALL SDL_RateMUL2_c4(SDL_AudioCVT *cvt, Uint16 format)
|
||||
void SDLCALL
|
||||
SDL_RateMUL2_c4(SDL_AudioCVT * cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
Uint8 *src, *dst;
|
||||
|
@ -1029,7 +1061,8 @@ void SDLCALL SDL_RateMUL2_c4(SDL_AudioCVT *cvt, Uint16 format)
|
|||
|
||||
|
||||
/* Convert rate up by multiple of 2, for 5.1 */
|
||||
void SDLCALL SDL_RateMUL2_c6(SDL_AudioCVT *cvt, Uint16 format)
|
||||
void SDLCALL
|
||||
SDL_RateMUL2_c6(SDL_AudioCVT * cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
Uint8 *src, *dst;
|
||||
|
@ -1096,7 +1129,8 @@ void SDLCALL SDL_RateMUL2_c6(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
|
||||
/* Convert rate down by multiple of 2 */
|
||||
void SDLCALL SDL_RateDIV2(SDL_AudioCVT *cvt, Uint16 format)
|
||||
void SDLCALL
|
||||
SDL_RateDIV2(SDL_AudioCVT * cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
Uint8 *src, *dst;
|
||||
|
@ -1131,7 +1165,8 @@ void SDLCALL SDL_RateDIV2(SDL_AudioCVT *cvt, Uint16 format)
|
|||
|
||||
|
||||
/* Convert rate down by multiple of 2, for stereo */
|
||||
void SDLCALL SDL_RateDIV2_c2(SDL_AudioCVT *cvt, Uint16 format)
|
||||
void SDLCALL
|
||||
SDL_RateDIV2_c2(SDL_AudioCVT * cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
Uint8 *src, *dst;
|
||||
|
@ -1169,7 +1204,8 @@ void SDLCALL SDL_RateDIV2_c2(SDL_AudioCVT *cvt, Uint16 format)
|
|||
|
||||
|
||||
/* Convert rate down by multiple of 2, for quad */
|
||||
void SDLCALL SDL_RateDIV2_c4(SDL_AudioCVT *cvt, Uint16 format)
|
||||
void SDLCALL
|
||||
SDL_RateDIV2_c4(SDL_AudioCVT * cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
Uint8 *src, *dst;
|
||||
|
@ -1212,7 +1248,8 @@ void SDLCALL SDL_RateDIV2_c4(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
|
||||
/* Convert rate down by multiple of 2, for 5.1 */
|
||||
void SDLCALL SDL_RateDIV2_c6(SDL_AudioCVT *cvt, Uint16 format)
|
||||
void SDLCALL
|
||||
SDL_RateDIV2_c6(SDL_AudioCVT * cvt, Uint16 format)
|
||||
{
|
||||
int i;
|
||||
Uint8 *src, *dst;
|
||||
|
@ -1261,7 +1298,8 @@ void SDLCALL SDL_RateDIV2_c6(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
|
||||
/* Very slow rate conversion routine */
|
||||
void SDLCALL SDL_RateSLOW(SDL_AudioCVT *cvt, Uint16 format)
|
||||
void SDLCALL
|
||||
SDL_RateSLOW(SDL_AudioCVT * cvt, Uint16 format)
|
||||
{
|
||||
double ipos;
|
||||
int i, clen;
|
||||
|
@ -1272,7 +1310,8 @@ void SDLCALL SDL_RateSLOW(SDL_AudioCVT *cvt, Uint16 format)
|
|||
clen = (int) ((double) cvt->len_cvt / cvt->rate_incr);
|
||||
if (cvt->rate_incr > 1.0) {
|
||||
switch (format & 0xFF) {
|
||||
case 8: {
|
||||
case 8:
|
||||
{
|
||||
Uint8 *output;
|
||||
|
||||
output = cvt->buf;
|
||||
|
@ -1285,7 +1324,8 @@ void SDLCALL SDL_RateSLOW(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
break;
|
||||
|
||||
case 16: {
|
||||
case 16:
|
||||
{
|
||||
Uint16 *output;
|
||||
|
||||
clen &= ~1;
|
||||
|
@ -1301,7 +1341,8 @@ void SDLCALL SDL_RateSLOW(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
} else {
|
||||
switch (format & 0xFF) {
|
||||
case 8: {
|
||||
case 8:
|
||||
{
|
||||
Uint8 *output;
|
||||
|
||||
output = cvt->buf + clen;
|
||||
|
@ -1314,7 +1355,8 @@ void SDLCALL SDL_RateSLOW(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
break;
|
||||
|
||||
case 16: {
|
||||
case 16:
|
||||
{
|
||||
Uint16 *output;
|
||||
|
||||
clen &= ~1;
|
||||
|
@ -1335,7 +1377,8 @@ void SDLCALL SDL_RateSLOW(SDL_AudioCVT *cvt, Uint16 format)
|
|||
}
|
||||
}
|
||||
|
||||
int SDL_ConvertAudio(SDL_AudioCVT *cvt)
|
||||
int
|
||||
SDL_ConvertAudio(SDL_AudioCVT * cvt)
|
||||
{
|
||||
/* Make sure there's data to convert */
|
||||
if (cvt->buf == NULL) {
|
||||
|
@ -1359,7 +1402,8 @@ int SDL_ConvertAudio(SDL_AudioCVT *cvt)
|
|||
audio filter is set up.
|
||||
*/
|
||||
|
||||
int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
||||
int
|
||||
SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
|
||||
Uint16 src_format, Uint8 src_channels, int src_rate,
|
||||
Uint16 dst_format, Uint8 dst_channels, int dst_rate)
|
||||
{
|
||||
|
@ -1387,19 +1431,16 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
|||
if ((src_format & 0xFF) != (dst_format & 0xFF)) {
|
||||
switch (dst_format & 0x10FF) {
|
||||
case AUDIO_U8:
|
||||
cvt->filters[cvt->filter_index++] =
|
||||
SDL_Convert8;
|
||||
cvt->filters[cvt->filter_index++] = SDL_Convert8;
|
||||
cvt->len_ratio /= 2;
|
||||
break;
|
||||
case AUDIO_U16LSB:
|
||||
cvt->filters[cvt->filter_index++] =
|
||||
SDL_Convert16LSB;
|
||||
cvt->filters[cvt->filter_index++] = SDL_Convert16LSB;
|
||||
cvt->len_mult *= 2;
|
||||
cvt->len_ratio *= 2;
|
||||
break;
|
||||
case AUDIO_U16MSB:
|
||||
cvt->filters[cvt->filter_index++] =
|
||||
SDL_Convert16MSB;
|
||||
cvt->filters[cvt->filter_index++] = SDL_Convert16MSB;
|
||||
cvt->len_mult *= 2;
|
||||
cvt->len_ratio *= 2;
|
||||
break;
|
||||
|
@ -1409,46 +1450,36 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
|||
/* Last filter: Mono/Stereo conversion */
|
||||
if (src_channels != dst_channels) {
|
||||
if ((src_channels == 1) && (dst_channels > 1)) {
|
||||
cvt->filters[cvt->filter_index++] =
|
||||
SDL_ConvertStereo;
|
||||
cvt->filters[cvt->filter_index++] = SDL_ConvertStereo;
|
||||
cvt->len_mult *= 2;
|
||||
src_channels = 2;
|
||||
cvt->len_ratio *= 2;
|
||||
}
|
||||
if ( (src_channels == 2) &&
|
||||
(dst_channels == 6) ) {
|
||||
cvt->filters[cvt->filter_index++] =
|
||||
SDL_ConvertSurround;
|
||||
if ((src_channels == 2) && (dst_channels == 6)) {
|
||||
cvt->filters[cvt->filter_index++] = SDL_ConvertSurround;
|
||||
src_channels = 6;
|
||||
cvt->len_mult *= 3;
|
||||
cvt->len_ratio *= 3;
|
||||
}
|
||||
if ( (src_channels == 2) &&
|
||||
(dst_channels == 4) ) {
|
||||
cvt->filters[cvt->filter_index++] =
|
||||
SDL_ConvertSurround_4;
|
||||
if ((src_channels == 2) && (dst_channels == 4)) {
|
||||
cvt->filters[cvt->filter_index++] = SDL_ConvertSurround_4;
|
||||
src_channels = 4;
|
||||
cvt->len_mult *= 2;
|
||||
cvt->len_ratio *= 2;
|
||||
}
|
||||
while ((src_channels * 2) <= dst_channels) {
|
||||
cvt->filters[cvt->filter_index++] =
|
||||
SDL_ConvertStereo;
|
||||
cvt->filters[cvt->filter_index++] = SDL_ConvertStereo;
|
||||
cvt->len_mult *= 2;
|
||||
src_channels *= 2;
|
||||
cvt->len_ratio *= 2;
|
||||
}
|
||||
if ( (src_channels == 6) &&
|
||||
(dst_channels <= 2) ) {
|
||||
cvt->filters[cvt->filter_index++] =
|
||||
SDL_ConvertStrip;
|
||||
if ((src_channels == 6) && (dst_channels <= 2)) {
|
||||
cvt->filters[cvt->filter_index++] = SDL_ConvertStrip;
|
||||
src_channels = 2;
|
||||
cvt->len_ratio /= 3;
|
||||
}
|
||||
if ( (src_channels == 6) &&
|
||||
(dst_channels == 4) ) {
|
||||
cvt->filters[cvt->filter_index++] =
|
||||
SDL_ConvertStrip_2;
|
||||
if ((src_channels == 6) && (dst_channels == 4)) {
|
||||
cvt->filters[cvt->filter_index++] = SDL_ConvertStrip_2;
|
||||
src_channels = 4;
|
||||
cvt->len_ratio /= 2;
|
||||
}
|
||||
|
@ -1458,8 +1489,7 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
|||
*/
|
||||
while (((src_channels % 2) == 0) &&
|
||||
((src_channels / 2) >= dst_channels)) {
|
||||
cvt->filters[cvt->filter_index++] =
|
||||
SDL_ConvertMono;
|
||||
cvt->filters[cvt->filter_index++] = SDL_ConvertMono;
|
||||
src_channels /= 2;
|
||||
cvt->len_ratio /= 2;
|
||||
}
|
||||
|
@ -1480,11 +1510,20 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
|||
hi_rate = src_rate;
|
||||
lo_rate = dst_rate;
|
||||
switch (src_channels) {
|
||||
case 1: rate_cvt = SDL_RateDIV2; break;
|
||||
case 2: rate_cvt = SDL_RateDIV2_c2; break;
|
||||
case 4: rate_cvt = SDL_RateDIV2_c4; break;
|
||||
case 6: rate_cvt = SDL_RateDIV2_c6; break;
|
||||
default: return -1;
|
||||
case 1:
|
||||
rate_cvt = SDL_RateDIV2;
|
||||
break;
|
||||
case 2:
|
||||
rate_cvt = SDL_RateDIV2_c2;
|
||||
break;
|
||||
case 4:
|
||||
rate_cvt = SDL_RateDIV2_c4;
|
||||
break;
|
||||
case 6:
|
||||
rate_cvt = SDL_RateDIV2_c6;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
len_mult = 1;
|
||||
len_ratio = 0.5;
|
||||
|
@ -1492,11 +1531,20 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
|||
hi_rate = dst_rate;
|
||||
lo_rate = src_rate;
|
||||
switch (src_channels) {
|
||||
case 1: rate_cvt = SDL_RateMUL2; break;
|
||||
case 2: rate_cvt = SDL_RateMUL2_c2; break;
|
||||
case 4: rate_cvt = SDL_RateMUL2_c4; break;
|
||||
case 6: rate_cvt = SDL_RateMUL2_c6; break;
|
||||
default: return -1;
|
||||
case 1:
|
||||
rate_cvt = SDL_RateMUL2;
|
||||
break;
|
||||
case 2:
|
||||
rate_cvt = SDL_RateMUL2_c2;
|
||||
break;
|
||||
case 4:
|
||||
rate_cvt = SDL_RateMUL2_c4;
|
||||
break;
|
||||
case 6:
|
||||
rate_cvt = SDL_RateMUL2_c6;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
len_mult = 2;
|
||||
len_ratio = 2.0;
|
||||
|
@ -1543,3 +1591,5 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
|||
}
|
||||
return (cvt->needed);
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -47,7 +47,8 @@
|
|||
#endif
|
||||
|
||||
|
||||
int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic)
|
||||
int
|
||||
SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic)
|
||||
{
|
||||
const char *audiodev;
|
||||
int audio_fd;
|
||||
|
@ -62,8 +63,9 @@ int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic)
|
|||
struct stat sb;
|
||||
|
||||
/* Added support for /dev/sound/\* in Linux 2.4 */
|
||||
if ( ((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) &&
|
||||
((stat(_PATH_DEV_DSP24, &sb) == 0) && S_ISCHR(sb.st_mode)) ) {
|
||||
if (((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode))
|
||||
&& ((stat(_PATH_DEV_DSP24, &sb) == 0)
|
||||
&& S_ISCHR(sb.st_mode))) {
|
||||
audiodev = _PATH_DEV_DSP24;
|
||||
} else {
|
||||
audiodev = _PATH_DEV_DSP;
|
||||
|
@ -86,7 +88,8 @@ int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic)
|
|||
exists = 1;
|
||||
audio_fd = open(audiopath, flags, 0);
|
||||
}
|
||||
} while ( exists && (audio_fd < 0) );
|
||||
}
|
||||
while (exists && (audio_fd < 0));
|
||||
audiodev = audiopath;
|
||||
}
|
||||
if (path != NULL) {
|
||||
|
@ -110,8 +113,7 @@ int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic)
|
|||
#define _PATH_DEV_DSP "/dev/%caud%c/%c"
|
||||
#endif
|
||||
|
||||
char devsettings[][3] =
|
||||
{
|
||||
char devsettings[][3] = {
|
||||
{'p', '0', '1'}, {'p', '0', '2'}, {'p', '0', '3'}, {'p', '0', '4'},
|
||||
{'p', '1', '1'}, {'p', '1', '2'}, {'p', '1', '3'}, {'p', '1', '4'},
|
||||
{'p', '2', '1'}, {'p', '2', '2'}, {'p', '2', '3'}, {'p', '2', '4'},
|
||||
|
@ -123,7 +125,8 @@ char devsettings[][3] =
|
|||
{'\0', '\0', '\0'}
|
||||
};
|
||||
|
||||
static int OpenUserDefinedDevice(char *path, int maxlen, int flags)
|
||||
static int
|
||||
OpenUserDefinedDevice(char *path, int maxlen, int flags)
|
||||
{
|
||||
const char *audiodev;
|
||||
int audio_fd;
|
||||
|
@ -143,7 +146,8 @@ static int OpenUserDefinedDevice(char *path, int maxlen, int flags)
|
|||
return audio_fd;
|
||||
}
|
||||
|
||||
int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic)
|
||||
int
|
||||
SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic)
|
||||
{
|
||||
struct stat sb;
|
||||
int audio_fd;
|
||||
|
@ -160,8 +164,7 @@ int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic)
|
|||
SDL_snprintf(audiopath, SDL_arraysize(audiopath),
|
||||
_PATH_DEV_DSP,
|
||||
devsettings[cycle][0],
|
||||
devsettings[cycle][1],
|
||||
devsettings[cycle][2]);
|
||||
devsettings[cycle][1], devsettings[cycle][2]);
|
||||
|
||||
if (stat(audiopath, &sb) == 0) {
|
||||
audio_fd = open(audiopath, flags, 0);
|
||||
|
@ -177,3 +180,4 @@ int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic)
|
|||
}
|
||||
|
||||
#endif /* Audio driver selection */
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -23,4 +23,4 @@
|
|||
|
||||
/* Open the audio device, storing the pathname in 'path' */
|
||||
extern int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -23,3 +23,4 @@
|
|||
|
||||
#define SDL_AllocAudioMem SDL_malloc
|
||||
#define SDL_FreeAudioMem SDL_free
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -35,8 +35,7 @@
|
|||
* the value to avoid overflow. (used with permission from ARDI)
|
||||
* Changed to use 0xFE instead of 0xFF for better sound quality.
|
||||
*/
|
||||
static const Uint8 mix8[] =
|
||||
{
|
||||
static const Uint8 mix8[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
@ -90,7 +89,8 @@ static const Uint8 mix8[] =
|
|||
#define ADJUST_VOLUME(s, v) (s = (s*v)/SDL_MIX_MAXVOLUME)
|
||||
#define ADJUST_VOLUME_U8(s, v) (s = (((s-128)*v)/SDL_MIX_MAXVOLUME)+128)
|
||||
|
||||
void SDL_MixAudio (Uint8 *dst, const Uint8 *src, Uint32 len, int volume)
|
||||
void
|
||||
SDL_MixAudio(Uint8 * dst, const Uint8 * src, Uint32 len, int volume)
|
||||
{
|
||||
Uint16 format;
|
||||
|
||||
|
@ -110,9 +110,12 @@ void SDL_MixAudio (Uint8 *dst, const Uint8 *src, Uint32 len, int volume)
|
|||
}
|
||||
switch (format) {
|
||||
|
||||
case AUDIO_U8: {
|
||||
case AUDIO_U8:
|
||||
{
|
||||
#if defined(__GNUC__) && defined(__M68000__) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
SDL_MixAudio_m68k_U8((char*)dst,(char*)src,(unsigned long)len,(long)volume,(char *)mix8);
|
||||
SDL_MixAudio_m68k_U8((char *) dst, (char *) src,
|
||||
(unsigned long) len, (long) volume,
|
||||
(char *) mix8);
|
||||
#else
|
||||
Uint8 src_sample;
|
||||
|
||||
|
@ -127,22 +130,22 @@ void SDL_MixAudio (Uint8 *dst, const Uint8 *src, Uint32 len, int volume)
|
|||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S8: {
|
||||
case AUDIO_S8:
|
||||
{
|
||||
#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
if (SDL_HasMMX())
|
||||
{
|
||||
SDL_MixAudio_MMX_S8((char*)dst,(char*)src,(unsigned int)len,(int)volume);
|
||||
}
|
||||
else
|
||||
if (SDL_HasMMX()) {
|
||||
SDL_MixAudio_MMX_S8((char *) dst, (char *) src,
|
||||
(unsigned int) len, (int) volume);
|
||||
} else
|
||||
#elif ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
if (SDL_HasMMX())
|
||||
{
|
||||
SDL_MixAudio_MMX_S8_VC((char*)dst,(char*)src,(unsigned int)len,(int)volume);
|
||||
}
|
||||
else
|
||||
if (SDL_HasMMX()) {
|
||||
SDL_MixAudio_MMX_S8_VC((char *) dst, (char *) src,
|
||||
(unsigned int) len, (int) volume);
|
||||
} else
|
||||
#endif
|
||||
#if defined(__GNUC__) && defined(__M68000__) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
SDL_MixAudio_m68k_S8((char*)dst,(char*)src,(unsigned long)len,(long)volume);
|
||||
SDL_MixAudio_m68k_S8((char *) dst, (char *) src,
|
||||
(unsigned long) len, (long) volume);
|
||||
#else
|
||||
{
|
||||
Sint8 *dst8, *src8;
|
||||
|
@ -159,8 +162,7 @@ void SDL_MixAudio (Uint8 *dst, const Uint8 *src, Uint32 len, int volume)
|
|||
dst_sample = *dst8 + src_sample;
|
||||
if (dst_sample > max_audioval) {
|
||||
*dst8 = max_audioval;
|
||||
} else
|
||||
if ( dst_sample < min_audioval ) {
|
||||
} else if (dst_sample < min_audioval) {
|
||||
*dst8 = min_audioval;
|
||||
} else {
|
||||
*dst8 = dst_sample;
|
||||
|
@ -173,22 +175,22 @@ void SDL_MixAudio (Uint8 *dst, const Uint8 *src, Uint32 len, int volume)
|
|||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S16LSB: {
|
||||
case AUDIO_S16LSB:
|
||||
{
|
||||
#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
if (SDL_HasMMX())
|
||||
{
|
||||
SDL_MixAudio_MMX_S16((char*)dst,(char*)src,(unsigned int)len,(int)volume);
|
||||
}
|
||||
else
|
||||
if (SDL_HasMMX()) {
|
||||
SDL_MixAudio_MMX_S16((char *) dst, (char *) src,
|
||||
(unsigned int) len, (int) volume);
|
||||
} else
|
||||
#elif ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
if (SDL_HasMMX())
|
||||
{
|
||||
SDL_MixAudio_MMX_S16_VC((char*)dst,(char*)src,(unsigned int)len,(int)volume);
|
||||
}
|
||||
else
|
||||
if (SDL_HasMMX()) {
|
||||
SDL_MixAudio_MMX_S16_VC((char *) dst, (char *) src,
|
||||
(unsigned int) len, (int) volume);
|
||||
} else
|
||||
#endif
|
||||
#if defined(__GNUC__) && defined(__M68000__) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
SDL_MixAudio_m68k_S16LSB((short*)dst,(short*)src,(unsigned long)len,(long)volume);
|
||||
SDL_MixAudio_m68k_S16LSB((short *) dst, (short *) src,
|
||||
(unsigned long) len, (long) volume);
|
||||
#else
|
||||
{
|
||||
Sint16 src1, src2;
|
||||
|
@ -205,8 +207,7 @@ void SDL_MixAudio (Uint8 *dst, const Uint8 *src, Uint32 len, int volume)
|
|||
dst_sample = src1 + src2;
|
||||
if (dst_sample > max_audioval) {
|
||||
dst_sample = max_audioval;
|
||||
} else
|
||||
if ( dst_sample < min_audioval ) {
|
||||
} else if (dst_sample < min_audioval) {
|
||||
dst_sample = min_audioval;
|
||||
}
|
||||
dst[0] = dst_sample & 0xFF;
|
||||
|
@ -219,9 +220,11 @@ void SDL_MixAudio (Uint8 *dst, const Uint8 *src, Uint32 len, int volume)
|
|||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S16MSB: {
|
||||
case AUDIO_S16MSB:
|
||||
{
|
||||
#if defined(__GNUC__) && defined(__M68000__) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
SDL_MixAudio_m68k_S16MSB((short*)dst,(short*)src,(unsigned long)len,(long)volume);
|
||||
SDL_MixAudio_m68k_S16MSB((short *) dst, (short *) src,
|
||||
(unsigned long) len, (long) volume);
|
||||
#else
|
||||
Sint16 src1, src2;
|
||||
int dst_sample;
|
||||
|
@ -237,8 +240,7 @@ void SDL_MixAudio (Uint8 *dst, const Uint8 *src, Uint32 len, int volume)
|
|||
dst_sample = src1 + src2;
|
||||
if (dst_sample > max_audioval) {
|
||||
dst_sample = max_audioval;
|
||||
} else
|
||||
if ( dst_sample < min_audioval ) {
|
||||
} else if (dst_sample < min_audioval) {
|
||||
dst_sample = min_audioval;
|
||||
}
|
||||
dst[1] = dst_sample & 0xFF;
|
||||
|
@ -256,3 +258,4 @@ void SDL_MixAudio (Uint8 *dst, const Uint8 *src, Uint32 len, int volume)
|
|||
}
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -36,100 +36,50 @@
|
|||
***********************************************/
|
||||
|
||||
#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
void SDL_MixAudio_MMX_S16(char* dst,char* src,unsigned int size,int volume)
|
||||
void
|
||||
SDL_MixAudio_MMX_S16(char *dst, char *src, unsigned int size, int volume)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
|
||||
" movl %3,%%eax\n" /* eax = volume */
|
||||
|
||||
__asm__ __volatile__(" movl %3,%%eax\n" /* eax = volume */
|
||||
" movl %2,%%edx\n" /* edx = size */
|
||||
|
||||
" shrl $4,%%edx\n" /* process 16 bytes per iteration = 8 samples */
|
||||
|
||||
" jz .endS16\n"
|
||||
|
||||
" pxor %%mm0,%%mm0\n"
|
||||
|
||||
" movd %%eax,%%mm0\n"
|
||||
" movq %%mm0,%%mm1\n"
|
||||
" psllq $16,%%mm0\n"
|
||||
" por %%mm1,%%mm0\n"
|
||||
" psllq $16,%%mm0\n"
|
||||
" por %%mm1,%%mm0\n"
|
||||
" psllq $16,%%mm0\n"
|
||||
" por %%mm1,%%mm0\n" /* mm0 = vol|vol|vol|vol */
|
||||
|
||||
".align 8\n"
|
||||
" .mixloopS16:\n"
|
||||
|
||||
" movq (%1),%%mm1\n" /* mm1 = a|b|c|d */
|
||||
|
||||
" jz .endS16\n" " pxor %%mm0,%%mm0\n" " movd %%eax,%%mm0\n" " movq %%mm0,%%mm1\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" /* mm0 = vol|vol|vol|vol */
|
||||
".align 8\n" " .mixloopS16:\n" " movq (%1),%%mm1\n" /* mm1 = a|b|c|d */
|
||||
" movq %%mm1,%%mm2\n" /* mm2 = a|b|c|d */
|
||||
|
||||
" movq 8(%1),%%mm4\n" /* mm4 = e|f|g|h */
|
||||
|
||||
/* pré charger le buffer dst dans mm7 */
|
||||
" movq (%0),%%mm7\n" /* mm7 = dst[0] */
|
||||
|
||||
/* multiplier par le volume */
|
||||
" pmullw %%mm0,%%mm1\n" /* mm1 = l(a*v)|l(b*v)|l(c*v)|l(d*v) */
|
||||
|
||||
" pmulhw %%mm0,%%mm2\n" /* mm2 = h(a*v)|h(b*v)|h(c*v)|h(d*v) */
|
||||
" movq %%mm4,%%mm5\n" /* mm5 = e|f|g|h */
|
||||
|
||||
" pmullw %%mm0,%%mm4\n" /* mm4 = l(e*v)|l(f*v)|l(g*v)|l(h*v) */
|
||||
|
||||
" pmulhw %%mm0,%%mm5\n" /* mm5 = h(e*v)|h(f*v)|h(g*v)|h(h*v) */
|
||||
" movq %%mm1,%%mm3\n" /* mm3 = l(a*v)|l(b*v)|l(c*v)|l(d*v) */
|
||||
|
||||
" punpckhwd %%mm2,%%mm1\n" /* mm1 = a*v|b*v */
|
||||
|
||||
" movq %%mm4,%%mm6\n" /* mm6 = l(e*v)|l(f*v)|l(g*v)|l(h*v) */
|
||||
" punpcklwd %%mm2,%%mm3\n" /* mm3 = c*v|d*v */
|
||||
|
||||
" punpckhwd %%mm5,%%mm4\n" /* mm4 = e*f|f*v */
|
||||
|
||||
" punpcklwd %%mm5,%%mm6\n" /* mm6 = g*v|h*v */
|
||||
|
||||
/* pré charger le buffer dst dans mm5 */
|
||||
" movq 8(%0),%%mm5\n" /* mm5 = dst[1] */
|
||||
|
||||
/* diviser par 128 */
|
||||
" psrad $7,%%mm1\n" /* mm1 = a*v/128|b*v/128 , 128 = SDL_MIX_MAXVOLUME */
|
||||
" add $16,%1\n"
|
||||
|
||||
" psrad $7,%%mm3\n" /* mm3 = c*v/128|d*v/128 */
|
||||
|
||||
" add $16,%1\n" " psrad $7,%%mm3\n" /* mm3 = c*v/128|d*v/128 */
|
||||
" psrad $7,%%mm4\n" /* mm4 = e*v/128|f*v/128 */
|
||||
|
||||
/* mm1 = le sample avec le volume modifié */
|
||||
" packssdw %%mm1,%%mm3\n" /* mm3 = s(a*v|b*v|c*v|d*v) */
|
||||
|
||||
" psrad $7,%%mm6\n" /* mm6= g*v/128|h*v/128 */
|
||||
" paddsw %%mm7,%%mm3\n" /* mm3 = adjust_volume(src)+dst */
|
||||
|
||||
/* mm4 = le sample avec le volume modifié */
|
||||
" packssdw %%mm4,%%mm6\n" /* mm6 = s(e*v|f*v|g*v|h*v) */
|
||||
" movq %%mm3,(%0)\n"
|
||||
|
||||
" paddsw %%mm5,%%mm6\n" /* mm6 = adjust_volume(src)+dst */
|
||||
|
||||
" movq %%mm3,(%0)\n" " paddsw %%mm5,%%mm6\n" /* mm6 = adjust_volume(src)+dst */
|
||||
" movq %%mm6,8(%0)\n"
|
||||
|
||||
" add $16,%0\n"
|
||||
|
||||
" dec %%edx\n"
|
||||
|
||||
" jnz .mixloopS16\n"
|
||||
|
||||
" emms\n"
|
||||
|
||||
".endS16:\n"
|
||||
:
|
||||
: "r" (dst), "r"(src),"m"(size),
|
||||
"m"(volume)
|
||||
: "eax","edx","memory"
|
||||
);
|
||||
".endS16:\n"::"r"(dst), "r"(src),
|
||||
"m"(size), "m"(volume):"eax", "edx", "memory");
|
||||
}
|
||||
|
||||
|
||||
|
@ -138,69 +88,33 @@ void SDL_MixAudio_MMX_S16(char* dst,char* src,unsigned int size,int volume)
|
|||
/* Mixing for 8 bit signed buffers */
|
||||
/*////////////////////////////////////////////// */
|
||||
|
||||
void SDL_MixAudio_MMX_S8(char* dst,char* src,unsigned int size,int volume)
|
||||
void
|
||||
SDL_MixAudio_MMX_S8(char *dst, char *src, unsigned int size, int volume)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
|
||||
" movl %3,%%eax\n" /* eax = volume */
|
||||
|
||||
" movd %%eax,%%mm0\n"
|
||||
" movq %%mm0,%%mm1\n"
|
||||
" psllq $16,%%mm0\n"
|
||||
" por %%mm1,%%mm0\n"
|
||||
" psllq $16,%%mm0\n"
|
||||
" por %%mm1,%%mm0\n"
|
||||
" psllq $16,%%mm0\n"
|
||||
" por %%mm1,%%mm0\n"
|
||||
|
||||
" movl %2,%%edx\n" /* edx = size */
|
||||
__asm__ __volatile__(" movl %3,%%eax\n" /* eax = volume */
|
||||
" movd %%eax,%%mm0\n" " movq %%mm0,%%mm1\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " movl %2,%%edx\n" /* edx = size */
|
||||
" shr $3,%%edx\n" /* process 8 bytes per iteration = 8 samples */
|
||||
|
||||
" cmp $0,%%edx\n"
|
||||
" je .endS8\n"
|
||||
|
||||
".align 8\n"
|
||||
" .mixloopS8:\n"
|
||||
|
||||
" pxor %%mm2,%%mm2\n" /* mm2 = 0 */
|
||||
" cmp $0,%%edx\n" " je .endS8\n" ".align 8\n" " .mixloopS8:\n" " pxor %%mm2,%%mm2\n" /* mm2 = 0 */
|
||||
" movq (%1),%%mm1\n" /* mm1 = a|b|c|d|e|f|g|h */
|
||||
|
||||
" movq %%mm1,%%mm3\n" /* mm3 = a|b|c|d|e|f|g|h */
|
||||
|
||||
/* on va faire le "sign extension" en faisant un cmp avec 0 qui retourne 1 si <0, 0 si >0 */
|
||||
" pcmpgtb %%mm1,%%mm2\n" /* mm2 = 11111111|00000000|00000000.... */
|
||||
|
||||
" punpckhbw %%mm2,%%mm1\n" /* mm1 = 0|a|0|b|0|c|0|d */
|
||||
|
||||
" punpcklbw %%mm2,%%mm3\n" /* mm3 = 0|e|0|f|0|g|0|h */
|
||||
" movq (%0),%%mm2\n" /* mm2 = destination */
|
||||
|
||||
" pmullw %%mm0,%%mm1\n" /* mm1 = v*a|v*b|v*c|v*d */
|
||||
" add $8,%1\n"
|
||||
|
||||
" pmullw %%mm0,%%mm3\n" /* mm3 = v*e|v*f|v*g|v*h */
|
||||
" add $8,%1\n" " pmullw %%mm0,%%mm3\n" /* mm3 = v*e|v*f|v*g|v*h */
|
||||
" psraw $7,%%mm1\n" /* mm1 = v*a/128|v*b/128|v*c/128|v*d/128 */
|
||||
|
||||
" psraw $7,%%mm3\n" /* mm3 = v*e/128|v*f/128|v*g/128|v*h/128 */
|
||||
|
||||
" packsswb %%mm1,%%mm3\n" /* mm1 = v*a/128|v*b/128|v*c/128|v*d/128|v*e/128|v*f/128|v*g/128|v*h/128 */
|
||||
|
||||
" paddsb %%mm2,%%mm3\n" /* add to destination buffer */
|
||||
|
||||
" movq %%mm3,(%0)\n" /* store back to ram */
|
||||
" add $8,%0\n"
|
||||
|
||||
" dec %%edx\n"
|
||||
|
||||
" jnz .mixloopS8\n"
|
||||
|
||||
".endS8:\n"
|
||||
" emms\n"
|
||||
:
|
||||
: "r" (dst), "r"(src),"m"(size),
|
||||
"m"(volume)
|
||||
: "eax","edx","memory"
|
||||
);
|
||||
" emms\n"::"r"(dst), "r"(src), "m"(size),
|
||||
"m"(volume):"eax", "edx", "memory");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -12,4 +12,4 @@
|
|||
void SDL_MixAudio_MMX_S16(char *, char *, unsigned int, int);
|
||||
void SDL_MixAudio_MMX_S8(char *, char *, unsigned int, int);
|
||||
#endif
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -37,8 +37,10 @@
|
|||
// Mixing for 16 bit signed buffers
|
||||
////////////////////////////////////////////////
|
||||
|
||||
void SDL_MixAudio_MMX_S16_VC(char* dst,char* src,unsigned int nSize,int volume)
|
||||
void
|
||||
SDL_MixAudio_MMX_S16_VC(char *dst, char *src, unsigned int nSize, int volume)
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
__asm
|
||||
{
|
||||
|
||||
|
@ -111,15 +113,17 @@ ends16:
|
|||
pop esi
|
||||
pop edi
|
||||
}
|
||||
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// Mixing for 8 bit signed buffers
|
||||
////////////////////////////////////////////////
|
||||
|
||||
void SDL_MixAudio_MMX_S8_VC(char* dst,char* src,unsigned int nSize,int volume)
|
||||
void
|
||||
SDL_MixAudio_MMX_S8_VC(char *dst, char *src, unsigned int nSize, int volume)
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
_asm
|
||||
{
|
||||
|
||||
|
@ -176,6 +180,9 @@ endS8:
|
|||
pop esi
|
||||
pop edi
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
#endif /* SDL_ASSEMBLY_ROUTINES */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -34,3 +34,4 @@
|
|||
void SDL_MixAudio_MMX_S16_VC(char *, char *, unsigned int, int);
|
||||
void SDL_MixAudio_MMX_S8_VC(char *, char *, unsigned int, int);
|
||||
#endif
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -28,184 +28,113 @@
|
|||
*/
|
||||
|
||||
#if defined(__M68000__) && defined(__GNUC__)
|
||||
void SDL_MixAudio_m68k_U8(char* dst, char* src, long len, long volume, char* mix8)
|
||||
void
|
||||
SDL_MixAudio_m68k_U8(char *dst, char *src, long len, long volume, char *mix8)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
|
||||
"tstl %2\n"
|
||||
" beqs stoploop_u8\n"
|
||||
"mixloop_u8:\n"
|
||||
|
||||
__asm__ __volatile__("tstl %2\n" " beqs stoploop_u8\n" "mixloop_u8:\n"
|
||||
/* Mix a sample */
|
||||
|
||||
" moveq #0,%%d0\n"
|
||||
" moveq #0,%%d1\n"
|
||||
|
||||
" moveb %1@+,%%d0\n" /* d0 = *src++ */
|
||||
" moveq #0,%%d0\n" " moveq #0,%%d1\n" " moveb %1@+,%%d0\n" /* d0 = *src++ */
|
||||
" sub #128,%%d0\n" /* d0 -= 128 */
|
||||
" muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
|
||||
" moveb %0@,%%d1\n" /* d1 = *dst */
|
||||
" asr #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
|
||||
" add #128,%%d0\n" /* d0 += 128 */
|
||||
|
||||
" add %%d1,%%d0\n"
|
||||
|
||||
" moveb %4@(%%d0:w),%0@+\n"
|
||||
|
||||
/* Loop till done */
|
||||
|
||||
" subql #1,%2\n"
|
||||
" bhis mixloop_u8\n"
|
||||
"stoploop_u8:\n"
|
||||
|
||||
: /* no return value */
|
||||
" subql #1,%2\n" " bhis mixloop_u8\n" "stoploop_u8:\n": /* no return value */
|
||||
: /* input */
|
||||
"a"(dst), "a"(src), "d"(len), "d"(volume), "a"(mix8)
|
||||
: /* clobbered registers */
|
||||
"d0", "d1", "cc", "memory"
|
||||
);
|
||||
"a"(dst), "a"(src), "d"(len), "d"(volume), "a"(mix8): /* clobbered registers */
|
||||
"d0", "d1", "cc", "memory");
|
||||
}
|
||||
|
||||
void SDL_MixAudio_m68k_S8(char* dst, char* src, long len, long volume)
|
||||
void
|
||||
SDL_MixAudio_m68k_S8(char *dst, char *src, long len, long volume)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
|
||||
"tstl %2\n"
|
||||
__asm__ __volatile__("tstl %2\n"
|
||||
" beqs stoploop_s8\n"
|
||||
" moveq #-128,%%d2\n"
|
||||
" moveq #127,%%d3\n"
|
||||
"mixloop_s8:\n"
|
||||
|
||||
" moveq #127,%%d3\n" "mixloop_s8:\n"
|
||||
/* Mix a sample */
|
||||
|
||||
" moveq #0,%%d0\n"
|
||||
" moveq #0,%%d1\n"
|
||||
|
||||
" moveb %1@+,%%d0\n" /* d0 = *src++ */
|
||||
" moveq #0,%%d0\n" " moveq #0,%%d1\n" " moveb %1@+,%%d0\n" /* d0 = *src++ */
|
||||
" muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
|
||||
" moveb %0@,%%d1\n" /* d1 = *dst */
|
||||
" asr #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
|
||||
|
||||
" add %%d1,%%d0\n"
|
||||
|
||||
" cmp %%d2,%%d0\n"
|
||||
" bges lower_limit_s8\n"
|
||||
" move %%d2,%%d0\n"
|
||||
"lower_limit_s8:\n"
|
||||
|
||||
" cmp %%d3,%%d0\n"
|
||||
" bles upper_limit_s8\n"
|
||||
" move %%d3,%%d0\n"
|
||||
"upper_limit_s8:\n"
|
||||
" moveb %%d0,%0@+\n"
|
||||
|
||||
"upper_limit_s8:\n" " moveb %%d0,%0@+\n"
|
||||
/* Loop till done */
|
||||
|
||||
" subql #1,%2\n"
|
||||
" bhis mixloop_s8\n"
|
||||
"stoploop_s8:\n"
|
||||
|
||||
: /* no return value */
|
||||
" subql #1,%2\n" " bhis mixloop_s8\n" "stoploop_s8:\n": /* no return value */
|
||||
: /* input */
|
||||
"a"(dst), "a"(src), "d"(len), "d"(volume)
|
||||
: /* clobbered registers */
|
||||
"d0", "d1", "d2", "d3", "cc", "memory"
|
||||
);
|
||||
"a"(dst), "a"(src), "d"(len), "d"(volume): /* clobbered registers */
|
||||
"d0", "d1", "d2", "d3", "cc", "memory");
|
||||
}
|
||||
|
||||
void SDL_MixAudio_m68k_S16MSB(short* dst, short* src, long len, long volume)
|
||||
void
|
||||
SDL_MixAudio_m68k_S16MSB(short *dst, short *src, long len, long volume)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
|
||||
"tstl %2\n"
|
||||
__asm__ __volatile__("tstl %2\n"
|
||||
" beqs stoploop_s16msb\n"
|
||||
" movel #-32768,%%d2\n"
|
||||
" movel #32767,%%d3\n"
|
||||
" lsrl #1,%2\n"
|
||||
"mixloop_s16msb:\n"
|
||||
|
||||
" lsrl #1,%2\n" "mixloop_s16msb:\n"
|
||||
/* Mix a sample */
|
||||
|
||||
" move %1@+,%%d0\n" /* d0 = *src++ */
|
||||
" muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
|
||||
" move %0@,%%d1\n" /* d1 = *dst */
|
||||
" extl %%d1\n" /* extend d1 to 32 bits */
|
||||
" asrl #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
|
||||
|
||||
" addl %%d1,%%d0\n"
|
||||
|
||||
" cmpl %%d2,%%d0\n"
|
||||
" bges lower_limit_s16msb\n"
|
||||
" move %%d2,%%d0\n"
|
||||
"lower_limit_s16msb:\n"
|
||||
|
||||
" cmpl %%d3,%%d0\n"
|
||||
" bles upper_limit_s16msb\n"
|
||||
" move %%d3,%%d0\n"
|
||||
"upper_limit_s16msb:\n"
|
||||
" move %%d0,%0@+\n"
|
||||
|
||||
"upper_limit_s16msb:\n" " move %%d0,%0@+\n"
|
||||
/* Loop till done */
|
||||
|
||||
" subql #1,%2\n"
|
||||
" bhis mixloop_s16msb\n"
|
||||
"stoploop_s16msb:\n"
|
||||
|
||||
: /* no return value */
|
||||
" subql #1,%2\n" " bhis mixloop_s16msb\n" "stoploop_s16msb:\n": /* no return value */
|
||||
: /* input */
|
||||
"a"(dst), "a"(src), "d"(len), "d"(volume)
|
||||
: /* clobbered registers */
|
||||
"d0", "d1", "d2", "d3", "cc", "memory"
|
||||
);
|
||||
"a"(dst), "a"(src), "d"(len), "d"(volume): /* clobbered registers */
|
||||
"d0", "d1", "d2", "d3", "cc", "memory");
|
||||
}
|
||||
|
||||
void SDL_MixAudio_m68k_S16LSB(short* dst, short* src, long len, long volume)
|
||||
void
|
||||
SDL_MixAudio_m68k_S16LSB(short *dst, short *src, long len, long volume)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
|
||||
"tstl %2\n"
|
||||
__asm__ __volatile__("tstl %2\n"
|
||||
" beqs stoploop_s16lsb\n"
|
||||
" movel #-32768,%%d2\n"
|
||||
" movel #32767,%%d3\n"
|
||||
" lsrl #1,%2\n"
|
||||
"mixloop_s16lsb:\n"
|
||||
|
||||
" lsrl #1,%2\n" "mixloop_s16lsb:\n"
|
||||
/* Mix a sample */
|
||||
|
||||
" move %1@+,%%d0\n" /* d0 = *src++ */
|
||||
" rorw #8,%%d0\n"
|
||||
" muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
|
||||
" rorw #8,%%d0\n" " muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
|
||||
" move %0@,%%d1\n" /* d1 = *dst */
|
||||
" rorw #8,%%d1\n"
|
||||
" extl %%d1\n" /* extend d1 to 32 bits */
|
||||
" rorw #8,%%d1\n" " extl %%d1\n" /* extend d1 to 32 bits */
|
||||
" asrl #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
|
||||
|
||||
" addl %%d1,%%d0\n"
|
||||
|
||||
" cmpl %%d2,%%d0\n"
|
||||
" bges lower_limit_s16lsb\n"
|
||||
" move %%d2,%%d0\n"
|
||||
"lower_limit_s16lsb:\n"
|
||||
|
||||
" cmpl %%d3,%%d0\n"
|
||||
" bles upper_limit_s16lsb\n"
|
||||
" move %%d3,%%d0\n"
|
||||
"upper_limit_s16lsb:\n"
|
||||
" rorw #8,%%d0\n"
|
||||
" move %%d0,%0@+\n"
|
||||
|
||||
" rorw #8,%%d0\n" " move %%d0,%0@+\n"
|
||||
/* Loop till done */
|
||||
|
||||
" subql #1,%2\n"
|
||||
" bhis mixloop_s16lsb\n"
|
||||
"stoploop_s16lsb:\n"
|
||||
|
||||
: /* no return value */
|
||||
" subql #1,%2\n" " bhis mixloop_s16lsb\n" "stoploop_s16lsb:\n": /* no return value */
|
||||
: /* input */
|
||||
"a"(dst), "a"(src), "d"(len), "d"(volume)
|
||||
: /* clobbered registers */
|
||||
"d0", "d1", "d2", "d3", "cc", "memory"
|
||||
);
|
||||
"a"(dst), "a"(src), "d"(len), "d"(volume): /* clobbered registers */
|
||||
"d0", "d1", "d2", "d3", "cc", "memory");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -28,9 +28,11 @@
|
|||
*/
|
||||
|
||||
#if defined(__M68000__) && defined(__GNUC__)
|
||||
void SDL_MixAudio_m68k_U8(char* dst,char* src, long len, long volume, char* mix8);
|
||||
void SDL_MixAudio_m68k_U8(char *dst, char *src, long len, long volume,
|
||||
char *mix8);
|
||||
void SDL_MixAudio_m68k_S8(char *dst, char *src, long len, long volume);
|
||||
|
||||
void SDL_MixAudio_m68k_S16MSB(short *dst, short *src, long len, long volume);
|
||||
void SDL_MixAudio_m68k_S16LSB(short *dst, short *src, long len, long volume);
|
||||
#endif
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -35,7 +35,8 @@ typedef struct SDL_AudioDevice SDL_AudioDevice;
|
|||
#ifndef _STATUS
|
||||
#define _STATUS SDL_status *status
|
||||
#endif
|
||||
struct SDL_AudioDevice {
|
||||
struct SDL_AudioDevice
|
||||
{
|
||||
/* * * */
|
||||
/* The name of this audio driver */
|
||||
const char *name;
|
||||
|
@ -93,7 +94,8 @@ struct SDL_AudioDevice {
|
|||
};
|
||||
#undef _THIS
|
||||
|
||||
typedef struct AudioBootStrap {
|
||||
typedef struct AudioBootStrap
|
||||
{
|
||||
const char *name;
|
||||
const char *desc;
|
||||
int (*available) (void);
|
||||
|
@ -176,3 +178,4 @@ extern AudioBootStrap DART_bootstrap;
|
|||
extern SDL_AudioDevice *current_audio;
|
||||
|
||||
#endif /* _SDL_sysaudio_h */
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -29,13 +29,15 @@
|
|||
|
||||
static int ReadChunk(SDL_RWops * src, Chunk * chunk);
|
||||
|
||||
struct MS_ADPCM_decodestate {
|
||||
struct MS_ADPCM_decodestate
|
||||
{
|
||||
Uint8 hPredictor;
|
||||
Uint16 iDelta;
|
||||
Sint16 iSamp1;
|
||||
Sint16 iSamp2;
|
||||
};
|
||||
static struct MS_ADPCM_decoder {
|
||||
static struct MS_ADPCM_decoder
|
||||
{
|
||||
WaveFMT wavefmt;
|
||||
Uint16 wSamplesPerBlock;
|
||||
Uint16 wNumCoef;
|
||||
|
@ -44,7 +46,8 @@ static struct MS_ADPCM_decoder {
|
|||
struct MS_ADPCM_decodestate state[2];
|
||||
} MS_ADPCM_state;
|
||||
|
||||
static int InitMS_ADPCM(WaveFMT *format)
|
||||
static int
|
||||
InitMS_ADPCM(WaveFMT * format)
|
||||
{
|
||||
Uint8 *rogue_feel;
|
||||
Uint16 extra_info;
|
||||
|
@ -80,7 +83,8 @@ static int InitMS_ADPCM(WaveFMT *format)
|
|||
return (0);
|
||||
}
|
||||
|
||||
static Sint32 MS_ADPCM_nibble(struct MS_ADPCM_decodestate *state,
|
||||
static Sint32
|
||||
MS_ADPCM_nibble(struct MS_ADPCM_decodestate *state,
|
||||
Uint8 nybble, Sint16 * coeff)
|
||||
{
|
||||
const Sint32 max_audioval = ((1 << (16 - 1)) - 1);
|
||||
|
@ -100,8 +104,7 @@ static Sint32 MS_ADPCM_nibble(struct MS_ADPCM_decodestate *state,
|
|||
}
|
||||
if (new_sample < min_audioval) {
|
||||
new_sample = min_audioval;
|
||||
} else
|
||||
if ( new_sample > max_audioval ) {
|
||||
} else if (new_sample > max_audioval) {
|
||||
new_sample = max_audioval;
|
||||
}
|
||||
delta = ((Sint32) state->iDelta * adaptive[nybble]) / 256;
|
||||
|
@ -114,7 +117,8 @@ static Sint32 MS_ADPCM_nibble(struct MS_ADPCM_decodestate *state,
|
|||
return (new_sample);
|
||||
}
|
||||
|
||||
static int MS_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
|
||||
static int
|
||||
MS_ADPCM_decode(Uint8 ** audio_buf, Uint32 * audio_len)
|
||||
{
|
||||
struct MS_ADPCM_decodestate *state[2];
|
||||
Uint8 *freeable, *encoded, *decoded;
|
||||
|
@ -213,18 +217,21 @@ static int MS_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
|
|||
return (0);
|
||||
}
|
||||
|
||||
struct IMA_ADPCM_decodestate {
|
||||
struct IMA_ADPCM_decodestate
|
||||
{
|
||||
Sint32 sample;
|
||||
Sint8 index;
|
||||
};
|
||||
static struct IMA_ADPCM_decoder {
|
||||
static struct IMA_ADPCM_decoder
|
||||
{
|
||||
WaveFMT wavefmt;
|
||||
Uint16 wSamplesPerBlock;
|
||||
/* * * */
|
||||
struct IMA_ADPCM_decodestate state[2];
|
||||
} IMA_ADPCM_state;
|
||||
|
||||
static int InitIMA_ADPCM(WaveFMT *format)
|
||||
static int
|
||||
InitIMA_ADPCM(WaveFMT * format)
|
||||
{
|
||||
Uint8 *rogue_feel;
|
||||
Uint16 extra_info;
|
||||
|
@ -246,7 +253,8 @@ static int InitIMA_ADPCM(WaveFMT *format)
|
|||
return (0);
|
||||
}
|
||||
|
||||
static Sint32 IMA_ADPCM_nibble(struct IMA_ADPCM_decodestate *state,Uint8 nybble)
|
||||
static Sint32
|
||||
IMA_ADPCM_nibble(struct IMA_ADPCM_decodestate *state, Uint8 nybble)
|
||||
{
|
||||
const Sint32 max_audioval = ((1 << (16 - 1)) - 1);
|
||||
const Sint32 min_audioval = -(1 << (16 - 1));
|
||||
|
@ -271,34 +279,38 @@ static Sint32 IMA_ADPCM_nibble(struct IMA_ADPCM_decodestate *state,Uint8 nybble)
|
|||
/* Compute difference and new sample value */
|
||||
step = step_table[state->index];
|
||||
delta = step >> 3;
|
||||
if ( nybble & 0x04 ) delta += step;
|
||||
if ( nybble & 0x02 ) delta += (step >> 1);
|
||||
if ( nybble & 0x01 ) delta += (step >> 2);
|
||||
if ( nybble & 0x08 ) delta = -delta;
|
||||
if (nybble & 0x04)
|
||||
delta += step;
|
||||
if (nybble & 0x02)
|
||||
delta += (step >> 1);
|
||||
if (nybble & 0x01)
|
||||
delta += (step >> 2);
|
||||
if (nybble & 0x08)
|
||||
delta = -delta;
|
||||
state->sample += delta;
|
||||
|
||||
/* Update index value */
|
||||
state->index += index_table[nybble];
|
||||
if (state->index > 88) {
|
||||
state->index = 88;
|
||||
} else
|
||||
if ( state->index < 0 ) {
|
||||
} else if (state->index < 0) {
|
||||
state->index = 0;
|
||||
}
|
||||
|
||||
/* Clamp output sample */
|
||||
if (state->sample > max_audioval) {
|
||||
state->sample = max_audioval;
|
||||
} else
|
||||
if ( state->sample < min_audioval ) {
|
||||
} else if (state->sample < min_audioval) {
|
||||
state->sample = min_audioval;
|
||||
}
|
||||
return (state->sample);
|
||||
}
|
||||
|
||||
/* Fill the decode buffer with a channel block of data (8 samples) */
|
||||
static void Fill_IMA_ADPCM_block(Uint8 *decoded, Uint8 *encoded,
|
||||
int channel, int numchannels, struct IMA_ADPCM_decodestate *state)
|
||||
static void
|
||||
Fill_IMA_ADPCM_block(Uint8 * decoded, Uint8 * encoded,
|
||||
int channel, int numchannels,
|
||||
struct IMA_ADPCM_decodestate *state)
|
||||
{
|
||||
int i;
|
||||
Sint8 nybble;
|
||||
|
@ -324,7 +336,8 @@ static void Fill_IMA_ADPCM_block(Uint8 *decoded, Uint8 *encoded,
|
|||
}
|
||||
}
|
||||
|
||||
static int IMA_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
|
||||
static int
|
||||
IMA_ADPCM_decode(Uint8 ** audio_buf, Uint32 * audio_len)
|
||||
{
|
||||
struct IMA_ADPCM_decodestate *state;
|
||||
Uint8 *freeable, *encoded, *decoded;
|
||||
|
@ -393,7 +406,8 @@ static int IMA_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
|
|||
return (0);
|
||||
}
|
||||
|
||||
SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc,
|
||||
SDL_AudioSpec *
|
||||
SDL_LoadWAV_RW(SDL_RWops * src, int freesrc,
|
||||
SDL_AudioSpec * spec, Uint8 ** audio_buf, Uint32 * audio_len)
|
||||
{
|
||||
int was_error;
|
||||
|
@ -448,7 +462,8 @@ SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc,
|
|||
}
|
||||
/* 2 Uint32's for chunk header+len, plus the lenread */
|
||||
headerDiff += lenread + 2 * sizeof(Uint32);
|
||||
} while ( (chunk.magic == FACT) || (chunk.magic == LIST) );
|
||||
}
|
||||
while ((chunk.magic == FACT) || (chunk.magic == LIST));
|
||||
|
||||
/* Decode the audio data format */
|
||||
format = (WaveFMT *) chunk.data;
|
||||
|
@ -530,8 +545,10 @@ SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc,
|
|||
}
|
||||
*audio_len = lenread;
|
||||
*audio_buf = chunk.data;
|
||||
if(chunk.magic != DATA) headerDiff += lenread + 2 * sizeof(Uint32);
|
||||
} while ( chunk.magic != DATA );
|
||||
if (chunk.magic != DATA)
|
||||
headerDiff += lenread + 2 * sizeof(Uint32);
|
||||
}
|
||||
while (chunk.magic != DATA);
|
||||
headerDiff += 2 * sizeof(Uint32); /* for the data chunk and len */
|
||||
|
||||
if (MS_ADPCM_encoded) {
|
||||
|
@ -572,14 +589,16 @@ done:
|
|||
/* Since the WAV memory is allocated in the shared library, it must also
|
||||
be freed here. (Necessary under Win32, VC++)
|
||||
*/
|
||||
void SDL_FreeWAV(Uint8 *audio_buf)
|
||||
void
|
||||
SDL_FreeWAV(Uint8 * audio_buf)
|
||||
{
|
||||
if (audio_buf != NULL) {
|
||||
SDL_free(audio_buf);
|
||||
}
|
||||
}
|
||||
|
||||
static int ReadChunk(SDL_RWops *src, Chunk *chunk)
|
||||
static int
|
||||
ReadChunk(SDL_RWops * src, Chunk * chunk)
|
||||
{
|
||||
chunk->magic = SDL_ReadLE32(src);
|
||||
chunk->length = SDL_ReadLE32(src);
|
||||
|
@ -595,3 +614,5 @@ static int ReadChunk(SDL_RWops *src, Chunk *chunk)
|
|||
}
|
||||
return (chunk->length);
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -40,7 +40,8 @@
|
|||
#define WAVE_STEREO 2
|
||||
|
||||
/* Normally, these three chunks come consecutively in a WAVE file */
|
||||
typedef struct WaveFMT {
|
||||
typedef struct WaveFMT
|
||||
{
|
||||
/* Not saved in the chunk we read:
|
||||
Uint32 FMTchunk;
|
||||
Uint32 fmtlen;
|
||||
|
@ -54,9 +55,10 @@ typedef struct WaveFMT {
|
|||
} WaveFMT;
|
||||
|
||||
/* The general chunk found in the WAVE file */
|
||||
typedef struct Chunk {
|
||||
typedef struct Chunk
|
||||
{
|
||||
Uint32 magic;
|
||||
Uint32 length;
|
||||
Uint8 *data;
|
||||
} Chunk;
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -60,70 +60,138 @@ static const char *alsa_library = SDL_AUDIO_DRIVER_ALSA_DYNAMIC;
|
|||
static void *alsa_handle = NULL;
|
||||
static int alsa_loaded = 0;
|
||||
|
||||
static int (*SDL_snd_pcm_open)(snd_pcm_t **pcm, const char *name, snd_pcm_stream_t stream, int mode);
|
||||
static int (*SDL_NAME(snd_pcm_open))(snd_pcm_t **pcm, const char *name, snd_pcm_stream_t stream, int mode);
|
||||
static int (*SDL_snd_pcm_open) (snd_pcm_t ** pcm, const char *name,
|
||||
snd_pcm_stream_t stream, int mode);
|
||||
static int (*SDL_NAME(snd_pcm_open)) (snd_pcm_t ** pcm, const char *name,
|
||||
snd_pcm_stream_t stream, int mode);
|
||||
static int (*SDL_NAME(snd_pcm_close)) (snd_pcm_t * pcm);
|
||||
static snd_pcm_sframes_t (*SDL_NAME(snd_pcm_writei))(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size);
|
||||
static snd_pcm_sframes_t(*SDL_NAME(snd_pcm_writei)) (snd_pcm_t * pcm,
|
||||
const void *buffer,
|
||||
snd_pcm_uframes_t size);
|
||||
static int (*SDL_NAME(snd_pcm_resume)) (snd_pcm_t * pcm);
|
||||
static int (*SDL_NAME(snd_pcm_prepare)) (snd_pcm_t * pcm);
|
||||
static int (*SDL_NAME(snd_pcm_drain)) (snd_pcm_t * pcm);
|
||||
static const char *(*SDL_NAME(snd_strerror)) (int errnum);
|
||||
static size_t(*SDL_NAME(snd_pcm_hw_params_sizeof)) (void);
|
||||
static size_t(*SDL_NAME(snd_pcm_sw_params_sizeof)) (void);
|
||||
static int (*SDL_NAME(snd_pcm_hw_params_any))(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
|
||||
static int (*SDL_NAME(snd_pcm_hw_params_set_access))(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t access);
|
||||
static int (*SDL_NAME(snd_pcm_hw_params_set_format))(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t val);
|
||||
static int (*SDL_NAME(snd_pcm_hw_params_set_channels))(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
|
||||
static int (*SDL_NAME(snd_pcm_hw_params_get_channels))(const snd_pcm_hw_params_t *params);
|
||||
static unsigned int (*SDL_NAME(snd_pcm_hw_params_set_rate_near))(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int *dir);
|
||||
static snd_pcm_uframes_t (*SDL_NAME(snd_pcm_hw_params_set_period_size_near))(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val, int *dir);
|
||||
static snd_pcm_sframes_t (*SDL_NAME(snd_pcm_hw_params_get_period_size))(const snd_pcm_hw_params_t *params);
|
||||
static unsigned int (*SDL_NAME(snd_pcm_hw_params_set_periods_near))(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int *dir);
|
||||
static int (*SDL_NAME(snd_pcm_hw_params_get_periods))(snd_pcm_hw_params_t *params);
|
||||
static int (*SDL_NAME(snd_pcm_hw_params))(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
|
||||
static int (*SDL_NAME(snd_pcm_hw_params_any)) (snd_pcm_t * pcm,
|
||||
snd_pcm_hw_params_t * params);
|
||||
static int (*SDL_NAME(snd_pcm_hw_params_set_access)) (snd_pcm_t * pcm,
|
||||
snd_pcm_hw_params_t *
|
||||
params,
|
||||
snd_pcm_access_t
|
||||
access);
|
||||
static int (*SDL_NAME(snd_pcm_hw_params_set_format)) (snd_pcm_t * pcm,
|
||||
snd_pcm_hw_params_t *
|
||||
params,
|
||||
snd_pcm_format_t val);
|
||||
static int (*SDL_NAME(snd_pcm_hw_params_set_channels)) (snd_pcm_t * pcm,
|
||||
snd_pcm_hw_params_t *
|
||||
params,
|
||||
unsigned int val);
|
||||
static int (*SDL_NAME(snd_pcm_hw_params_get_channels)) (const
|
||||
snd_pcm_hw_params_t *
|
||||
params);
|
||||
static unsigned int
|
||||
(*SDL_NAME(snd_pcm_hw_params_set_rate_near)) (snd_pcm_t *
|
||||
pcm,
|
||||
snd_pcm_hw_params_t
|
||||
* params,
|
||||
unsigned int val, int *dir);
|
||||
static snd_pcm_uframes_t
|
||||
(*SDL_NAME(snd_pcm_hw_params_set_period_size_near)) (snd_pcm_t * pcm,
|
||||
snd_pcm_hw_params_t
|
||||
* params,
|
||||
snd_pcm_uframes_t
|
||||
val, int *dir);
|
||||
static snd_pcm_sframes_t
|
||||
(*SDL_NAME(snd_pcm_hw_params_get_period_size)) (const
|
||||
snd_pcm_hw_params_t
|
||||
* params);
|
||||
static unsigned int
|
||||
(*SDL_NAME(snd_pcm_hw_params_set_periods_near)) (snd_pcm_t * pcm,
|
||||
snd_pcm_hw_params_t
|
||||
* params,
|
||||
unsigned int val,
|
||||
int *dir);
|
||||
static int (*SDL_NAME(snd_pcm_hw_params_get_periods)) (snd_pcm_hw_params_t *
|
||||
params);
|
||||
static int (*SDL_NAME(snd_pcm_hw_params)) (snd_pcm_t * pcm,
|
||||
snd_pcm_hw_params_t * params);
|
||||
/*
|
||||
*/
|
||||
static int (*SDL_NAME(snd_pcm_sw_params_current))(snd_pcm_t *pcm, snd_pcm_sw_params_t *swparams);
|
||||
static int (*SDL_NAME(snd_pcm_sw_params_set_start_threshold))(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
|
||||
static int (*SDL_NAME(snd_pcm_sw_params_set_avail_min))(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
|
||||
static int (*SDL_NAME(snd_pcm_sw_params))(snd_pcm_t *pcm, snd_pcm_sw_params_t *params);
|
||||
static int (*SDL_NAME(snd_pcm_sw_params_current)) (snd_pcm_t * pcm,
|
||||
snd_pcm_sw_params_t *
|
||||
swparams);
|
||||
static int (*SDL_NAME(snd_pcm_sw_params_set_start_threshold)) (snd_pcm_t *
|
||||
pcm,
|
||||
snd_pcm_sw_params_t
|
||||
* params,
|
||||
snd_pcm_uframes_t
|
||||
val);
|
||||
static int (*SDL_NAME(snd_pcm_sw_params_set_avail_min)) (snd_pcm_t * pcm,
|
||||
snd_pcm_sw_params_t
|
||||
* params,
|
||||
snd_pcm_uframes_t
|
||||
val);
|
||||
static int (*SDL_NAME(snd_pcm_sw_params)) (snd_pcm_t * pcm,
|
||||
snd_pcm_sw_params_t * params);
|
||||
static int (*SDL_NAME(snd_pcm_nonblock)) (snd_pcm_t * pcm, int nonblock);
|
||||
#define snd_pcm_hw_params_sizeof SDL_NAME(snd_pcm_hw_params_sizeof)
|
||||
#define snd_pcm_sw_params_sizeof SDL_NAME(snd_pcm_sw_params_sizeof)
|
||||
|
||||
/* cast funcs to char* first, to please GCC's strict aliasing rules. */
|
||||
static struct {
|
||||
static struct
|
||||
{
|
||||
const char *name;
|
||||
void **func;
|
||||
} alsa_functions[] = {
|
||||
{ "snd_pcm_open", (void**)(char*)&SDL_NAME(snd_pcm_open) },
|
||||
{ "snd_pcm_close", (void**)(char*)&SDL_NAME(snd_pcm_close) },
|
||||
{ "snd_pcm_writei", (void**)(char*)&SDL_NAME(snd_pcm_writei) },
|
||||
{ "snd_pcm_resume", (void**)(char*)&SDL_NAME(snd_pcm_resume) },
|
||||
{ "snd_pcm_prepare", (void**)(char*)&SDL_NAME(snd_pcm_prepare) },
|
||||
{ "snd_pcm_drain", (void**)(char*)&SDL_NAME(snd_pcm_drain) },
|
||||
{ "snd_strerror", (void**)(char*)&SDL_NAME(snd_strerror) },
|
||||
{ "snd_pcm_hw_params_sizeof", (void**)(char*)&SDL_NAME(snd_pcm_hw_params_sizeof) },
|
||||
{ "snd_pcm_sw_params_sizeof", (void**)(char*)&SDL_NAME(snd_pcm_sw_params_sizeof) },
|
||||
{ "snd_pcm_hw_params_any", (void**)(char*)&SDL_NAME(snd_pcm_hw_params_any) },
|
||||
{ "snd_pcm_hw_params_set_access", (void**)(char*)&SDL_NAME(snd_pcm_hw_params_set_access) },
|
||||
{ "snd_pcm_hw_params_set_format", (void**)(char*)&SDL_NAME(snd_pcm_hw_params_set_format) },
|
||||
{ "snd_pcm_hw_params_set_channels", (void**)(char*)&SDL_NAME(snd_pcm_hw_params_set_channels) },
|
||||
{ "snd_pcm_hw_params_get_channels", (void**)(char*)&SDL_NAME(snd_pcm_hw_params_get_channels) },
|
||||
{ "snd_pcm_hw_params_set_rate_near", (void**)(char*)&SDL_NAME(snd_pcm_hw_params_set_rate_near) },
|
||||
{ "snd_pcm_hw_params_set_period_size_near", (void**)(char*)&SDL_NAME(snd_pcm_hw_params_set_period_size_near) },
|
||||
{ "snd_pcm_hw_params_get_period_size", (void**)(char*)&SDL_NAME(snd_pcm_hw_params_get_period_size) },
|
||||
{ "snd_pcm_hw_params_set_periods_near", (void**)(char*)&SDL_NAME(snd_pcm_hw_params_set_periods_near) },
|
||||
{ "snd_pcm_hw_params_get_periods", (void**)(char*)&SDL_NAME(snd_pcm_hw_params_get_periods) },
|
||||
{ "snd_pcm_hw_params", (void**)(char*)&SDL_NAME(snd_pcm_hw_params) },
|
||||
{ "snd_pcm_sw_params_current", (void**)(char*)&SDL_NAME(snd_pcm_sw_params_current) },
|
||||
{ "snd_pcm_sw_params_set_start_threshold", (void**)(char*)&SDL_NAME(snd_pcm_sw_params_set_start_threshold) },
|
||||
{ "snd_pcm_sw_params_set_avail_min", (void**)(char*)&SDL_NAME(snd_pcm_sw_params_set_avail_min) },
|
||||
{ "snd_pcm_sw_params", (void**)(char*)&SDL_NAME(snd_pcm_sw_params) },
|
||||
{ "snd_pcm_nonblock", (void**)(char*)&SDL_NAME(snd_pcm_nonblock) },
|
||||
};
|
||||
{
|
||||
"snd_pcm_open", (void **) (char *) &SDL_NAME(snd_pcm_open)}, {
|
||||
"snd_pcm_close", (void **) (char *) &SDL_NAME(snd_pcm_close)}, {
|
||||
"snd_pcm_writei", (void **) (char *) &SDL_NAME(snd_pcm_writei)}, {
|
||||
"snd_pcm_resume", (void **) (char *) &SDL_NAME(snd_pcm_resume)}, {
|
||||
"snd_pcm_prepare", (void **) (char *) &SDL_NAME(snd_pcm_prepare)}, {
|
||||
"snd_pcm_drain", (void **) (char *) &SDL_NAME(snd_pcm_drain)}, {
|
||||
"snd_strerror", (void **) (char *) &SDL_NAME(snd_strerror)}, {
|
||||
"snd_pcm_hw_params_sizeof",
|
||||
(void **) (char *) &SDL_NAME(snd_pcm_hw_params_sizeof)}, {
|
||||
"snd_pcm_sw_params_sizeof",
|
||||
(void **) (char *) &SDL_NAME(snd_pcm_sw_params_sizeof)}, {
|
||||
"snd_pcm_hw_params_any",
|
||||
(void **) (char *) &SDL_NAME(snd_pcm_hw_params_any)}, {
|
||||
"snd_pcm_hw_params_set_access",
|
||||
(void **) (char *) &SDL_NAME(snd_pcm_hw_params_set_access)}, {
|
||||
"snd_pcm_hw_params_set_format",
|
||||
(void **) (char *) &SDL_NAME(snd_pcm_hw_params_set_format)}, {
|
||||
"snd_pcm_hw_params_set_channels",
|
||||
(void **) (char *) &SDL_NAME(snd_pcm_hw_params_set_channels)}, {
|
||||
"snd_pcm_hw_params_get_channels",
|
||||
(void **) (char *) &SDL_NAME(snd_pcm_hw_params_get_channels)}, {
|
||||
"snd_pcm_hw_params_set_rate_near",
|
||||
(void **) (char *) &SDL_NAME(snd_pcm_hw_params_set_rate_near)}, {
|
||||
"snd_pcm_hw_params_set_period_size_near", (void **) (char *)
|
||||
&SDL_NAME(snd_pcm_hw_params_set_period_size_near)}, {
|
||||
"snd_pcm_hw_params_get_period_size",
|
||||
(void **) (char *) &SDL_NAME(snd_pcm_hw_params_get_period_size)},
|
||||
{
|
||||
"snd_pcm_hw_params_set_periods_near", (void **) (char *)
|
||||
&SDL_NAME(snd_pcm_hw_params_set_periods_near)}, {
|
||||
"snd_pcm_hw_params_get_periods",
|
||||
(void **) (char *) &SDL_NAME(snd_pcm_hw_params_get_periods)}, {
|
||||
"snd_pcm_hw_params", (void **) (char *) &SDL_NAME(snd_pcm_hw_params)}, {
|
||||
"snd_pcm_sw_params_current",
|
||||
(void **) (char *) &SDL_NAME(snd_pcm_sw_params_current)}, {
|
||||
"snd_pcm_sw_params_set_start_threshold", (void **) (char *)
|
||||
&SDL_NAME(snd_pcm_sw_params_set_start_threshold)}, {
|
||||
"snd_pcm_sw_params_set_avail_min",
|
||||
(void **) (char *) &SDL_NAME(snd_pcm_sw_params_set_avail_min)}, {
|
||||
"snd_pcm_sw_params", (void **) (char *) &SDL_NAME(snd_pcm_sw_params)}, {
|
||||
"snd_pcm_nonblock", (void **) (char *) &SDL_NAME(snd_pcm_nonblock)},};
|
||||
|
||||
static void UnloadALSALibrary(void) {
|
||||
static void
|
||||
UnloadALSALibrary(void)
|
||||
{
|
||||
if (alsa_loaded) {
|
||||
/* SDL_UnloadObject(alsa_handle);*/
|
||||
dlclose(alsa_handle);
|
||||
|
@ -132,7 +200,9 @@ static void UnloadALSALibrary(void) {
|
|||
}
|
||||
}
|
||||
|
||||
static int LoadALSALibrary(void) {
|
||||
static int
|
||||
LoadALSALibrary(void)
|
||||
{
|
||||
int i, retval = -1;
|
||||
|
||||
/* alsa_handle = SDL_LoadObject(alsa_library);*/
|
||||
|
@ -143,10 +213,12 @@ static int LoadALSALibrary(void) {
|
|||
for (i = 0; i < SDL_arraysize(alsa_functions); i++) {
|
||||
/* *alsa_functions[i].func = SDL_LoadFunction(alsa_handle,alsa_functions[i].name);*/
|
||||
#if HAVE_DLVSYM
|
||||
*alsa_functions[i].func = dlvsym(alsa_handle,alsa_functions[i].name,"ALSA_0.9");
|
||||
*alsa_functions[i].func =
|
||||
dlvsym(alsa_handle, alsa_functions[i].name, "ALSA_0.9");
|
||||
if (!*alsa_functions[i].func)
|
||||
#endif
|
||||
*alsa_functions[i].func = dlsym(alsa_handle,alsa_functions[i].name);
|
||||
*alsa_functions[i].func =
|
||||
dlsym(alsa_handle, alsa_functions[i].name);
|
||||
if (!*alsa_functions[i].func) {
|
||||
retval = -1;
|
||||
UnloadALSALibrary();
|
||||
|
@ -159,32 +231,41 @@ static int LoadALSALibrary(void) {
|
|||
|
||||
#else
|
||||
|
||||
static void UnloadALSALibrary(void) {
|
||||
static void
|
||||
UnloadALSALibrary(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static int LoadALSALibrary(void) {
|
||||
static int
|
||||
LoadALSALibrary(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* SDL_AUDIO_DRIVER_ALSA_DYNAMIC */
|
||||
|
||||
static const char *get_audio_device(int channels)
|
||||
static const char *
|
||||
get_audio_device(int channels)
|
||||
{
|
||||
const char *device;
|
||||
|
||||
device = SDL_getenv("AUDIODEV"); /* Is there a standard variable name? */
|
||||
if (device == NULL) {
|
||||
if (channels == 6) device = "surround51";
|
||||
else if (channels == 4) device = "surround40";
|
||||
else device = DEFAULT_DEVICE;
|
||||
if (channels == 6)
|
||||
device = "surround51";
|
||||
else if (channels == 4)
|
||||
device = "surround40";
|
||||
else
|
||||
device = DEFAULT_DEVICE;
|
||||
}
|
||||
return device;
|
||||
}
|
||||
|
||||
/* Audio driver bootstrap functions */
|
||||
|
||||
static int Audio_Available(void)
|
||||
static int
|
||||
Audio_Available(void)
|
||||
{
|
||||
int available;
|
||||
int status;
|
||||
|
@ -194,7 +275,9 @@ static int Audio_Available(void)
|
|||
if (LoadALSALibrary() < 0) {
|
||||
return available;
|
||||
}
|
||||
status = SDL_NAME(snd_pcm_open)(&handle, get_audio_device(2), SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
|
||||
status =
|
||||
SDL_NAME(snd_pcm_open) (&handle, get_audio_device(2),
|
||||
SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
|
||||
if (status >= 0) {
|
||||
available = 1;
|
||||
SDL_NAME(snd_pcm_close) (handle);
|
||||
|
@ -203,14 +286,16 @@ static int Audio_Available(void)
|
|||
return (available);
|
||||
}
|
||||
|
||||
static void Audio_DeleteDevice(SDL_AudioDevice *device)
|
||||
static void
|
||||
Audio_DeleteDevice(SDL_AudioDevice * device)
|
||||
{
|
||||
SDL_free(device->hidden);
|
||||
SDL_free(device);
|
||||
UnloadALSALibrary();
|
||||
}
|
||||
|
||||
static SDL_AudioDevice *Audio_CreateDevice(int devindex)
|
||||
static SDL_AudioDevice *
|
||||
Audio_CreateDevice(int devindex)
|
||||
{
|
||||
SDL_AudioDevice *this;
|
||||
|
||||
|
@ -249,10 +334,12 @@ AudioBootStrap ALSA_bootstrap = {
|
|||
};
|
||||
|
||||
/* This function waits until it is possible to write a full sound buffer */
|
||||
static void ALSA_WaitAudio(_THIS)
|
||||
static void
|
||||
ALSA_WaitAudio(_THIS)
|
||||
{
|
||||
/* Check to see if the thread-parent process is still alive */
|
||||
{ static int cnt = 0;
|
||||
{
|
||||
static int cnt = 0;
|
||||
/* Note that this only works with thread implementations
|
||||
that use a different process id for each thread.
|
||||
*/
|
||||
|
@ -280,10 +367,26 @@ static void ALSA_WaitAudio(_THIS)
|
|||
tmp = ptr[3]; ptr[3] = ptr[5]; ptr[5] = tmp; \
|
||||
}
|
||||
|
||||
static __inline__ void swizzle_alsa_channels_6_64bit(_THIS) { SWIZ6(Uint64); }
|
||||
static __inline__ void swizzle_alsa_channels_6_32bit(_THIS) { SWIZ6(Uint32); }
|
||||
static __inline__ void swizzle_alsa_channels_6_16bit(_THIS) { SWIZ6(Uint16); }
|
||||
static __inline__ void swizzle_alsa_channels_6_8bit(_THIS) { SWIZ6(Uint8); }
|
||||
static __inline__ void
|
||||
swizzle_alsa_channels_6_64bit(_THIS)
|
||||
{
|
||||
SWIZ6(Uint64);
|
||||
}
|
||||
static __inline__ void
|
||||
swizzle_alsa_channels_6_32bit(_THIS)
|
||||
{
|
||||
SWIZ6(Uint32);
|
||||
}
|
||||
static __inline__ void
|
||||
swizzle_alsa_channels_6_16bit(_THIS)
|
||||
{
|
||||
SWIZ6(Uint16);
|
||||
}
|
||||
static __inline__ void
|
||||
swizzle_alsa_channels_6_8bit(_THIS)
|
||||
{
|
||||
SWIZ6(Uint8);
|
||||
}
|
||||
|
||||
#undef SWIZ6
|
||||
|
||||
|
@ -292,7 +395,8 @@ static __inline__ void swizzle_alsa_channels_6_8bit(_THIS) { SWIZ6(Uint8); }
|
|||
* Called right before feeding this->mixbuf to the hardware. Swizzle channels
|
||||
* from Windows/Mac order to the format alsalib will want.
|
||||
*/
|
||||
static __inline__ void swizzle_alsa_channels(_THIS)
|
||||
static __inline__ void
|
||||
swizzle_alsa_channels(_THIS)
|
||||
{
|
||||
if (this->spec.channels == 6) {
|
||||
const Uint16 fmtsize = (this->spec.format & 0xFF); /* bits/channel. */
|
||||
|
@ -310,7 +414,8 @@ static __inline__ void swizzle_alsa_channels(_THIS)
|
|||
}
|
||||
|
||||
|
||||
static void ALSA_PlayAudio(_THIS)
|
||||
static void
|
||||
ALSA_PlayAudio(_THIS)
|
||||
{
|
||||
int status;
|
||||
int sample_len;
|
||||
|
@ -322,7 +427,8 @@ static void ALSA_PlayAudio(_THIS)
|
|||
sample_buf = (signed short *) mixbuf;
|
||||
|
||||
while (sample_len > 0) {
|
||||
status = SDL_NAME(snd_pcm_writei)(pcm_handle, sample_buf, sample_len);
|
||||
status =
|
||||
SDL_NAME(snd_pcm_writei) (pcm_handle, sample_buf, sample_len);
|
||||
if (status < 0) {
|
||||
if (status == -EAGAIN) {
|
||||
SDL_Delay(1);
|
||||
|
@ -349,12 +455,14 @@ static void ALSA_PlayAudio(_THIS)
|
|||
}
|
||||
}
|
||||
|
||||
static Uint8 *ALSA_GetAudioBuf(_THIS)
|
||||
static Uint8 *
|
||||
ALSA_GetAudioBuf(_THIS)
|
||||
{
|
||||
return (mixbuf);
|
||||
}
|
||||
|
||||
static void ALSA_CloseAudio(_THIS)
|
||||
static void
|
||||
ALSA_CloseAudio(_THIS)
|
||||
{
|
||||
if (mixbuf != NULL) {
|
||||
SDL_FreeAudioMem(mixbuf);
|
||||
|
@ -367,7 +475,8 @@ static void ALSA_CloseAudio(_THIS)
|
|||
}
|
||||
}
|
||||
|
||||
static int ALSA_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
||||
static int
|
||||
ALSA_OpenAudio(_THIS, SDL_AudioSpec * spec)
|
||||
{
|
||||
int status;
|
||||
snd_pcm_hw_params_t *hwparams;
|
||||
|
@ -378,10 +487,14 @@ static int ALSA_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
|
||||
/* Open the audio device */
|
||||
/* Name of device should depend on # channels in spec */
|
||||
status = SDL_NAME(snd_pcm_open)(&pcm_handle, get_audio_device(spec->channels), SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
|
||||
status =
|
||||
SDL_NAME(snd_pcm_open) (&pcm_handle,
|
||||
get_audio_device(spec->channels),
|
||||
SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
|
||||
|
||||
if (status < 0) {
|
||||
SDL_SetError("Couldn't open audio device: %s", SDL_NAME(snd_strerror)(status));
|
||||
SDL_SetError("Couldn't open audio device: %s",
|
||||
SDL_NAME(snd_strerror) (status));
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
@ -389,15 +502,19 @@ static int ALSA_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
snd_pcm_hw_params_alloca(&hwparams);
|
||||
status = SDL_NAME(snd_pcm_hw_params_any) (pcm_handle, hwparams);
|
||||
if (status < 0) {
|
||||
SDL_SetError("Couldn't get hardware config: %s", SDL_NAME(snd_strerror)(status));
|
||||
SDL_SetError("Couldn't get hardware config: %s",
|
||||
SDL_NAME(snd_strerror) (status));
|
||||
ALSA_CloseAudio(this);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* SDL only uses interleaved sample output */
|
||||
status = SDL_NAME(snd_pcm_hw_params_set_access)(pcm_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED);
|
||||
status =
|
||||
SDL_NAME(snd_pcm_hw_params_set_access) (pcm_handle, hwparams,
|
||||
SND_PCM_ACCESS_RW_INTERLEAVED);
|
||||
if (status < 0) {
|
||||
SDL_SetError("Couldn't set interleaved access: %s", SDL_NAME(snd_strerror)(status));
|
||||
SDL_SetError("Couldn't set interleaved access: %s",
|
||||
SDL_NAME(snd_strerror) (status));
|
||||
ALSA_CloseAudio(this);
|
||||
return (-1);
|
||||
}
|
||||
|
@ -430,7 +547,9 @@ static int ALSA_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
break;
|
||||
}
|
||||
if (format != 0) {
|
||||
status = SDL_NAME(snd_pcm_hw_params_set_format)(pcm_handle, hwparams, format);
|
||||
status =
|
||||
SDL_NAME(snd_pcm_hw_params_set_format) (pcm_handle,
|
||||
hwparams, format);
|
||||
}
|
||||
if (status < 0) {
|
||||
test_format = SDL_NextAudioFormat();
|
||||
|
@ -444,7 +563,9 @@ static int ALSA_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
spec->format = test_format;
|
||||
|
||||
/* Set the number of channels */
|
||||
status = SDL_NAME(snd_pcm_hw_params_set_channels)(pcm_handle, hwparams, spec->channels);
|
||||
status =
|
||||
SDL_NAME(snd_pcm_hw_params_set_channels) (pcm_handle, hwparams,
|
||||
spec->channels);
|
||||
if (status < 0) {
|
||||
status = SDL_NAME(snd_pcm_hw_params_get_channels) (hwparams);
|
||||
if ((status <= 0) || (status > 2)) {
|
||||
|
@ -456,9 +577,12 @@ static int ALSA_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
}
|
||||
|
||||
/* Set the audio rate */
|
||||
status = SDL_NAME(snd_pcm_hw_params_set_rate_near)(pcm_handle, hwparams, spec->freq, NULL);
|
||||
status =
|
||||
SDL_NAME(snd_pcm_hw_params_set_rate_near) (pcm_handle, hwparams,
|
||||
spec->freq, NULL);
|
||||
if (status < 0) {
|
||||
SDL_SetError("Couldn't set audio frequency: %s", SDL_NAME(snd_strerror)(status));
|
||||
SDL_SetError("Couldn't set audio frequency: %s",
|
||||
SDL_NAME(snd_strerror) (status));
|
||||
ALSA_CloseAudio(this);
|
||||
return (-1);
|
||||
}
|
||||
|
@ -466,14 +590,19 @@ static int ALSA_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
|
||||
/* Set the buffer size, in samples */
|
||||
frames = spec->samples;
|
||||
frames = SDL_NAME(snd_pcm_hw_params_set_period_size_near)(pcm_handle, hwparams, frames, NULL);
|
||||
frames =
|
||||
SDL_NAME(snd_pcm_hw_params_set_period_size_near) (pcm_handle,
|
||||
hwparams, frames,
|
||||
NULL);
|
||||
spec->samples = frames;
|
||||
SDL_NAME(snd_pcm_hw_params_set_periods_near)(pcm_handle, hwparams, 2, NULL);
|
||||
SDL_NAME(snd_pcm_hw_params_set_periods_near) (pcm_handle, hwparams, 2,
|
||||
NULL);
|
||||
|
||||
/* "set" the hardware with the desired parameters */
|
||||
status = SDL_NAME(snd_pcm_hw_params) (pcm_handle, hwparams);
|
||||
if (status < 0) {
|
||||
SDL_SetError("Couldn't set hardware audio parameters: %s", SDL_NAME(snd_strerror)(status));
|
||||
SDL_SetError("Couldn't set hardware audio parameters: %s",
|
||||
SDL_NAME(snd_strerror) (status));
|
||||
ALSA_CloseAudio(this);
|
||||
return (-1);
|
||||
}
|
||||
|
@ -492,25 +621,33 @@ static int ALSA_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
snd_pcm_sw_params_alloca(&swparams);
|
||||
status = SDL_NAME(snd_pcm_sw_params_current) (pcm_handle, swparams);
|
||||
if (status < 0) {
|
||||
SDL_SetError("Couldn't get software config: %s", SDL_NAME(snd_strerror)(status));
|
||||
SDL_SetError("Couldn't get software config: %s",
|
||||
SDL_NAME(snd_strerror) (status));
|
||||
ALSA_CloseAudio(this);
|
||||
return (-1);
|
||||
}
|
||||
status = SDL_NAME(snd_pcm_sw_params_set_start_threshold)(pcm_handle, swparams, 0);
|
||||
status =
|
||||
SDL_NAME(snd_pcm_sw_params_set_start_threshold) (pcm_handle,
|
||||
swparams, 0);
|
||||
if (status < 0) {
|
||||
SDL_SetError("Couldn't set start threshold: %s", SDL_NAME(snd_strerror)(status));
|
||||
SDL_SetError("Couldn't set start threshold: %s",
|
||||
SDL_NAME(snd_strerror) (status));
|
||||
ALSA_CloseAudio(this);
|
||||
return (-1);
|
||||
}
|
||||
status = SDL_NAME(snd_pcm_sw_params_set_avail_min)(pcm_handle, swparams, frames);
|
||||
status =
|
||||
SDL_NAME(snd_pcm_sw_params_set_avail_min) (pcm_handle, swparams,
|
||||
frames);
|
||||
if (status < 0) {
|
||||
SDL_SetError("Couldn't set avail min: %s", SDL_NAME(snd_strerror)(status));
|
||||
SDL_SetError("Couldn't set avail min: %s",
|
||||
SDL_NAME(snd_strerror) (status));
|
||||
ALSA_CloseAudio(this);
|
||||
return (-1);
|
||||
}
|
||||
status = SDL_NAME(snd_pcm_sw_params) (pcm_handle, swparams);
|
||||
if (status < 0) {
|
||||
SDL_SetError("Couldn't set software audio parameters: %s", SDL_NAME(snd_strerror)(status));
|
||||
SDL_SetError("Couldn't set software audio parameters: %s",
|
||||
SDL_NAME(snd_strerror) (status));
|
||||
ALSA_CloseAudio(this);
|
||||
return (-1);
|
||||
}
|
||||
|
@ -536,3 +673,5 @@ static int ALSA_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
/* We're ready to rock and roll. :-) */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -33,7 +33,8 @@
|
|||
/* Hidden "this" pointer for the video functions */
|
||||
#define _THIS SDL_AudioDevice *this
|
||||
|
||||
struct SDL_PrivateAudioData {
|
||||
struct SDL_PrivateAudioData
|
||||
{
|
||||
/* The audio device handle */
|
||||
snd_pcm_t *pcm_handle;
|
||||
|
||||
|
@ -52,3 +53,4 @@ struct SDL_PrivateAudioData {
|
|||
#define mixlen (this->hidden->mixlen)
|
||||
|
||||
#endif /* _ALSA_PCM_audio_h */
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -44,20 +44,21 @@ static void AHI_CloseAudio(_THIS);
|
|||
|
||||
/* Audio driver bootstrap functions */
|
||||
|
||||
static int Audio_Available(void)
|
||||
static int
|
||||
Audio_Available(void)
|
||||
{
|
||||
int ok = 0;
|
||||
struct MsgPort *p;
|
||||
struct AHIRequest *req;
|
||||
|
||||
if(p=CreateMsgPort())
|
||||
{
|
||||
if(req=(struct AHIRequest *)CreateIORequest(p,sizeof(struct AHIRequest)))
|
||||
{
|
||||
if (p = CreateMsgPort()) {
|
||||
if (req =
|
||||
(struct AHIRequest *) CreateIORequest(p,
|
||||
sizeof(struct
|
||||
AHIRequest))) {
|
||||
req->ahir_Version = 4;
|
||||
|
||||
if(!OpenDevice(AHINAME,0,(struct IORequest *)req,NULL))
|
||||
{
|
||||
if (!OpenDevice(AHINAME, 0, (struct IORequest *) req, NULL)) {
|
||||
D(bug("AHI available.\n"));
|
||||
ok = 1;
|
||||
CloseDevice((struct IORequest *) req);
|
||||
|
@ -71,13 +72,15 @@ static int Audio_Available(void)
|
|||
return ok;
|
||||
}
|
||||
|
||||
static void Audio_DeleteDevice(SDL_AudioDevice *device)
|
||||
static void
|
||||
Audio_DeleteDevice(SDL_AudioDevice * device)
|
||||
{
|
||||
SDL_free(device->hidden);
|
||||
SDL_free(device);
|
||||
}
|
||||
|
||||
static SDL_AudioDevice *Audio_CreateDevice(int devindex)
|
||||
static SDL_AudioDevice *
|
||||
Audio_CreateDevice(int devindex)
|
||||
{
|
||||
SDL_AudioDevice *this;
|
||||
|
||||
|
@ -118,16 +121,17 @@ AudioBootStrap AHI_bootstrap = {
|
|||
};
|
||||
|
||||
|
||||
void static AHI_WaitAudio(_THIS)
|
||||
{
|
||||
if(!CheckIO((struct IORequest *)audio_req[current_buffer]))
|
||||
void static
|
||||
AHI_WaitAudio(_THIS)
|
||||
{
|
||||
if (!CheckIO((struct IORequest *) audio_req[current_buffer])) {
|
||||
WaitIO((struct IORequest *) audio_req[current_buffer]);
|
||||
// AbortIO((struct IORequest *)audio_req[current_buffer]);
|
||||
}
|
||||
}
|
||||
|
||||
static void AHI_PlayAudio(_THIS)
|
||||
static void
|
||||
AHI_PlayAudio(_THIS)
|
||||
{
|
||||
if (playing > 1)
|
||||
WaitIO((struct IORequest *) audio_req[current_buffer]);
|
||||
|
@ -142,7 +146,8 @@ static void AHI_PlayAudio(_THIS)
|
|||
audio_req[current_buffer]->ahir_Volume = 0x10000;
|
||||
audio_req[current_buffer]->ahir_Type = this->hidden->type;
|
||||
audio_req[current_buffer]->ahir_Position = 0x8000;
|
||||
audio_req[current_buffer] -> ahir_Link = (playing>0 ? audio_req[current_buffer^1] : NULL);
|
||||
audio_req[current_buffer]->ahir_Link =
|
||||
(playing > 0 ? audio_req[current_buffer ^ 1] : NULL);
|
||||
|
||||
SendIO((struct IORequest *) audio_req[current_buffer]);
|
||||
current_buffer ^= 1;
|
||||
|
@ -150,21 +155,21 @@ static void AHI_PlayAudio(_THIS)
|
|||
playing++;
|
||||
}
|
||||
|
||||
static Uint8 *AHI_GetAudioBuf(_THIS)
|
||||
static Uint8 *
|
||||
AHI_GetAudioBuf(_THIS)
|
||||
{
|
||||
return (mixbuf[current_buffer]);
|
||||
}
|
||||
|
||||
static void AHI_CloseAudio(_THIS)
|
||||
static void
|
||||
AHI_CloseAudio(_THIS)
|
||||
{
|
||||
D(bug("Closing audio...\n"));
|
||||
|
||||
playing = 0;
|
||||
|
||||
if(audio_req[0])
|
||||
{
|
||||
if(audio_req[1])
|
||||
{
|
||||
if (audio_req[0]) {
|
||||
if (audio_req[1]) {
|
||||
D(bug("Break req[1]...\n"));
|
||||
|
||||
AbortIO((struct IORequest *) audio_req[1]);
|
||||
|
@ -176,8 +181,7 @@ static void AHI_CloseAudio(_THIS)
|
|||
AbortIO((struct IORequest *) audio_req[0]);
|
||||
WaitIO((struct IORequest *) audio_req[0]);
|
||||
|
||||
if(audio_req[1])
|
||||
{
|
||||
if (audio_req[1]) {
|
||||
D(bug("Break AGAIN req[1]...\n"));
|
||||
AbortIO((struct IORequest *) audio_req[1]);
|
||||
WaitIO((struct IORequest *) audio_req[1]);
|
||||
|
@ -218,7 +222,8 @@ static void AHI_CloseAudio(_THIS)
|
|||
D(bug("...done!\n"));
|
||||
}
|
||||
|
||||
static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
||||
static int
|
||||
AHI_OpenAudio(_THIS, SDL_AudioSpec * spec)
|
||||
{
|
||||
// int width;
|
||||
|
||||
|
@ -227,7 +232,8 @@ static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
/* Determine the audio parameters from the AudioSpec */
|
||||
switch (spec->format & 0xFF) {
|
||||
|
||||
case 8: { /* Signed 8 bit audio data */
|
||||
case 8:
|
||||
{ /* Signed 8 bit audio data */
|
||||
D(bug("Samples a 8 bit...\n"));
|
||||
spec->format = AUDIO_S8;
|
||||
this->hidden->bytespersample = 1;
|
||||
|
@ -238,7 +244,8 @@ static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
}
|
||||
break;
|
||||
|
||||
case 16: { /* Signed 16 bit audio data */
|
||||
case 16:
|
||||
{ /* Signed 16 bit audio data */
|
||||
D(bug("Samples a 16 bit...\n"));
|
||||
spec->format = AUDIO_S16MSB;
|
||||
this->hidden->bytespersample = 2;
|
||||
|
@ -249,14 +256,14 @@ static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
}
|
||||
break;
|
||||
|
||||
default: {
|
||||
default:
|
||||
{
|
||||
SDL_SetError("Unsupported audio format");
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
if(spec->channels!=1 && spec->channels!=2)
|
||||
{
|
||||
if (spec->channels != 1 && spec->channels != 2) {
|
||||
D(bug("Wrong channel number!\n"));
|
||||
SDL_SetError("Channel number non supported");
|
||||
return -1;
|
||||
|
@ -268,16 +275,17 @@ static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
|
||||
D(bug("Before CreateMsgPort\n"));
|
||||
|
||||
if(!(audio_port=CreateMsgPort()))
|
||||
{
|
||||
if (!(audio_port = CreateMsgPort())) {
|
||||
SDL_SetError("Unable to create a MsgPort");
|
||||
return -1;
|
||||
}
|
||||
|
||||
D(bug("Before CreateIORequest\n"));
|
||||
|
||||
if(!(audio_req[0]=(struct AHIRequest *)CreateIORequest(audio_port,sizeof(struct AHIRequest))))
|
||||
{
|
||||
if (!
|
||||
(audio_req[0] =
|
||||
(struct AHIRequest *) CreateIORequest(audio_port,
|
||||
sizeof(struct AHIRequest)))) {
|
||||
SDL_SetError("Unable to create an AHIRequest");
|
||||
DeleteMsgPort(audio_port);
|
||||
return -1;
|
||||
|
@ -285,8 +293,7 @@ static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
|
||||
audio_req[0]->ahir_Version = 4;
|
||||
|
||||
if(OpenDevice(AHINAME,0,(struct IORequest *)audio_req[0],NULL))
|
||||
{
|
||||
if (OpenDevice(AHINAME, 0, (struct IORequest *) audio_req[0], NULL)) {
|
||||
SDL_SetError("Unable to open AHI device!\n");
|
||||
DeleteIORequest((struct IORequest *) audio_req[0]);
|
||||
DeleteMsgPort(audio_port);
|
||||
|
@ -307,8 +314,7 @@ static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
|
||||
D(bug("Before audio_req allocation\n"));
|
||||
|
||||
if(!(audio_req[1]=mymalloc(sizeof(struct AHIRequest))))
|
||||
{
|
||||
if (!(audio_req[1] = mymalloc(sizeof(struct AHIRequest)))) {
|
||||
SDL_OutOfMemory();
|
||||
return (-1);
|
||||
}
|
||||
|
@ -330,8 +336,13 @@ static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
current_buffer = 0;
|
||||
playing = 0;
|
||||
|
||||
D(bug("AHI opened: freq:%ld mixbuf:%lx/%lx buflen:%ld bits:%ld channels:%ld\n",spec->freq,mixbuf[0],mixbuf[1],spec->size,this->hidden->bytespersample*8,spec->channels));
|
||||
D(bug
|
||||
("AHI opened: freq:%ld mixbuf:%lx/%lx buflen:%ld bits:%ld channels:%ld\n",
|
||||
spec->freq, mixbuf[0], mixbuf[1], spec->size,
|
||||
this->hidden->bytespersample * 8, spec->channels));
|
||||
|
||||
/* We're ready to rock and roll. :-) */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -40,7 +40,8 @@
|
|||
/* Hidden "this" pointer for the audio functions */
|
||||
#define _THIS SDL_AudioDevice *this
|
||||
|
||||
struct SDL_PrivateAudioData {
|
||||
struct SDL_PrivateAudioData
|
||||
{
|
||||
/* The handle for the audio device */
|
||||
struct AHIRequest *audio_req[2];
|
||||
struct MsgPort *audio_port;
|
||||
|
@ -58,3 +59,4 @@ struct SDL_PrivateAudioData {
|
|||
#define playing (this->hidden->playing)
|
||||
|
||||
#endif /* _SDL_ahiaudio_h */
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -55,26 +55,33 @@ static int arts_loaded = 0;
|
|||
|
||||
static int (*SDL_NAME(arts_init)) (void);
|
||||
static void (*SDL_NAME(arts_free)) (void);
|
||||
static arts_stream_t (*SDL_NAME(arts_play_stream))(int rate, int bits, int channels, const char *name);
|
||||
static int (*SDL_NAME(arts_stream_set))(arts_stream_t s, arts_parameter_t param, int value);
|
||||
static int (*SDL_NAME(arts_stream_get))(arts_stream_t s, arts_parameter_t param);
|
||||
static int (*SDL_NAME(arts_write))(arts_stream_t s, const void *buffer, int count);
|
||||
static arts_stream_t(*SDL_NAME(arts_play_stream)) (int rate, int bits,
|
||||
int channels,
|
||||
const char *name);
|
||||
static int (*SDL_NAME(arts_stream_set)) (arts_stream_t s,
|
||||
arts_parameter_t param, int value);
|
||||
static int (*SDL_NAME(arts_stream_get)) (arts_stream_t s,
|
||||
arts_parameter_t param);
|
||||
static int (*SDL_NAME(arts_write)) (arts_stream_t s, const void *buffer,
|
||||
int count);
|
||||
static void (*SDL_NAME(arts_close_stream)) (arts_stream_t s);
|
||||
|
||||
static struct {
|
||||
static struct
|
||||
{
|
||||
const char *name;
|
||||
void **func;
|
||||
} arts_functions[] = {
|
||||
{ "arts_init", (void **)&SDL_NAME(arts_init) },
|
||||
{ "arts_free", (void **)&SDL_NAME(arts_free) },
|
||||
{ "arts_play_stream", (void **)&SDL_NAME(arts_play_stream) },
|
||||
{ "arts_stream_set", (void **)&SDL_NAME(arts_stream_set) },
|
||||
{ "arts_stream_get", (void **)&SDL_NAME(arts_stream_get) },
|
||||
{ "arts_write", (void **)&SDL_NAME(arts_write) },
|
||||
{ "arts_close_stream", (void **)&SDL_NAME(arts_close_stream) },
|
||||
};
|
||||
{
|
||||
"arts_init", (void **) &SDL_NAME(arts_init)}, {
|
||||
"arts_free", (void **) &SDL_NAME(arts_free)}, {
|
||||
"arts_play_stream", (void **) &SDL_NAME(arts_play_stream)}, {
|
||||
"arts_stream_set", (void **) &SDL_NAME(arts_stream_set)}, {
|
||||
"arts_stream_get", (void **) &SDL_NAME(arts_stream_get)}, {
|
||||
"arts_write", (void **) &SDL_NAME(arts_write)}, {
|
||||
"arts_close_stream", (void **) &SDL_NAME(arts_close_stream)},};
|
||||
|
||||
static void UnloadARTSLibrary()
|
||||
static void
|
||||
UnloadARTSLibrary()
|
||||
{
|
||||
if (arts_loaded) {
|
||||
SDL_UnloadObject(arts_handle);
|
||||
|
@ -83,7 +90,8 @@ static void UnloadARTSLibrary()
|
|||
}
|
||||
}
|
||||
|
||||
static int LoadARTSLibrary(void)
|
||||
static int
|
||||
LoadARTSLibrary(void)
|
||||
{
|
||||
int i, retval = -1;
|
||||
|
||||
|
@ -92,7 +100,8 @@ static int LoadARTSLibrary(void)
|
|||
arts_loaded = 1;
|
||||
retval = 0;
|
||||
for (i = 0; i < SDL_arraysize(arts_functions); ++i) {
|
||||
*arts_functions[i].func = SDL_LoadFunction(arts_handle, arts_functions[i].name);
|
||||
*arts_functions[i].func =
|
||||
SDL_LoadFunction(arts_handle, arts_functions[i].name);
|
||||
if (!*arts_functions[i].func) {
|
||||
retval = -1;
|
||||
UnloadARTSLibrary();
|
||||
|
@ -105,12 +114,14 @@ static int LoadARTSLibrary(void)
|
|||
|
||||
#else
|
||||
|
||||
static void UnloadARTSLibrary()
|
||||
static void
|
||||
UnloadARTSLibrary()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static int LoadARTSLibrary(void)
|
||||
static int
|
||||
LoadARTSLibrary(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -119,7 +130,8 @@ static int LoadARTSLibrary(void)
|
|||
|
||||
/* Audio driver bootstrap functions */
|
||||
|
||||
static int Audio_Available(void)
|
||||
static int
|
||||
Audio_Available(void)
|
||||
{
|
||||
int available = 0;
|
||||
|
||||
|
@ -142,14 +154,16 @@ static int Audio_Available(void)
|
|||
return available;
|
||||
}
|
||||
|
||||
static void Audio_DeleteDevice(SDL_AudioDevice *device)
|
||||
static void
|
||||
Audio_DeleteDevice(SDL_AudioDevice * device)
|
||||
{
|
||||
SDL_free(device->hidden);
|
||||
SDL_free(device);
|
||||
UnloadARTSLibrary();
|
||||
}
|
||||
|
||||
static SDL_AudioDevice *Audio_CreateDevice(int devindex)
|
||||
static SDL_AudioDevice *
|
||||
Audio_CreateDevice(int devindex)
|
||||
{
|
||||
SDL_AudioDevice *this;
|
||||
|
||||
|
@ -189,12 +203,14 @@ AudioBootStrap ARTS_bootstrap = {
|
|||
};
|
||||
|
||||
/* This function waits until it is possible to write a full sound buffer */
|
||||
static void ARTS_WaitAudio(_THIS)
|
||||
static void
|
||||
ARTS_WaitAudio(_THIS)
|
||||
{
|
||||
Sint32 ticks;
|
||||
|
||||
/* Check to see if the thread-parent process is still alive */
|
||||
{ static int cnt = 0;
|
||||
{
|
||||
static int cnt = 0;
|
||||
/* Note that this only works with thread implementations
|
||||
that use a different process id for each thread.
|
||||
*/
|
||||
|
@ -212,7 +228,8 @@ static void ARTS_WaitAudio(_THIS)
|
|||
}
|
||||
}
|
||||
|
||||
static void ARTS_PlayAudio(_THIS)
|
||||
static void
|
||||
ARTS_PlayAudio(_THIS)
|
||||
{
|
||||
int written;
|
||||
|
||||
|
@ -233,12 +250,14 @@ static void ARTS_PlayAudio(_THIS)
|
|||
#endif
|
||||
}
|
||||
|
||||
static Uint8 *ARTS_GetAudioBuf(_THIS)
|
||||
static Uint8 *
|
||||
ARTS_GetAudioBuf(_THIS)
|
||||
{
|
||||
return (mixbuf);
|
||||
}
|
||||
|
||||
static void ARTS_CloseAudio(_THIS)
|
||||
static void
|
||||
ARTS_CloseAudio(_THIS)
|
||||
{
|
||||
if (mixbuf != NULL) {
|
||||
SDL_FreeAudioMem(mixbuf);
|
||||
|
@ -251,7 +270,8 @@ static void ARTS_CloseAudio(_THIS)
|
|||
SDL_NAME(arts_free) ();
|
||||
}
|
||||
|
||||
static int ARTS_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
||||
static int
|
||||
ARTS_OpenAudio(_THIS, SDL_AudioSpec * spec)
|
||||
{
|
||||
int bits, frag_spec;
|
||||
Uint16 test_format, format;
|
||||
|
@ -296,7 +316,8 @@ static int ARTS_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
SDL_SetError("Unable to initialize ARTS");
|
||||
return (-1);
|
||||
}
|
||||
stream = SDL_NAME(arts_play_stream)(spec->freq, bits, spec->channels, "SDL");
|
||||
stream =
|
||||
SDL_NAME(arts_play_stream) (spec->freq, bits, spec->channels, "SDL");
|
||||
|
||||
/* Calculate the final parameters for this audio specification */
|
||||
SDL_CalculateAudioSpec(spec);
|
||||
|
@ -312,7 +333,8 @@ static int ARTS_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
#ifdef ARTS_P_PACKET_SETTINGS
|
||||
SDL_NAME(arts_stream_set) (stream, ARTS_P_PACKET_SETTINGS, frag_spec);
|
||||
#else
|
||||
SDL_NAME(arts_stream_set)(stream, ARTS_P_PACKET_SIZE, frag_spec&0xffff);
|
||||
SDL_NAME(arts_stream_set) (stream, ARTS_P_PACKET_SIZE,
|
||||
frag_spec & 0xffff);
|
||||
SDL_NAME(arts_stream_set) (stream, ARTS_P_PACKET_COUNT, frag_spec >> 16);
|
||||
#endif
|
||||
spec->size = SDL_NAME(arts_stream_get) (stream, ARTS_P_PACKET_SIZE);
|
||||
|
@ -331,3 +353,5 @@ static int ARTS_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
/* We're ready to rock and roll. :-) */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
/* Hidden "this" pointer for the video functions */
|
||||
#define _THIS SDL_AudioDevice *this
|
||||
|
||||
struct SDL_PrivateAudioData {
|
||||
struct SDL_PrivateAudioData
|
||||
{
|
||||
/* The stream descriptor for the audio device */
|
||||
arts_stream_t stream;
|
||||
|
||||
|
@ -57,4 +58,4 @@ struct SDL_PrivateAudioData {
|
|||
#define next_frame (this->hidden->next_frame)
|
||||
|
||||
#endif /* _SDL_artscaudio_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -27,7 +27,8 @@
|
|||
|
||||
#include "../../main/beos/SDL_BeApp.h"
|
||||
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
|
||||
#include "SDL_audio.h"
|
||||
#include "../SDL_audio_c.h"
|
||||
|
@ -110,10 +111,12 @@ static void FillSound(void *device, void *stream, size_t len,
|
|||
if (audio->convert.needed) {
|
||||
SDL_mutexP(audio->mixer_lock);
|
||||
(*audio->spec.callback) (audio->spec.userdata,
|
||||
(Uint8 *)audio->convert.buf,audio->convert.len);
|
||||
(Uint8 *) audio->convert.buf,
|
||||
audio->convert.len);
|
||||
SDL_mutexV(audio->mixer_lock);
|
||||
SDL_ConvertAudio(&audio->convert);
|
||||
SDL_memcpy(stream,audio->convert.buf,audio->convert.len_cvt);
|
||||
SDL_memcpy(stream, audio->convert.buf,
|
||||
audio->convert.len_cvt);
|
||||
} else {
|
||||
SDL_mutexP(audio->mixer_lock);
|
||||
(*audio->spec.callback) (audio->spec.userdata,
|
||||
|
@ -188,7 +191,8 @@ int BE_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
SDL_CalculateAudioSpec(spec);
|
||||
|
||||
/* Subscribe to the audio stream (creates a new thread) */
|
||||
{ sigset_t omask;
|
||||
{
|
||||
sigset_t omask;
|
||||
SDL_MaskSignals(&omask);
|
||||
audio_obj = new BSoundPlayer(&format, "SDL Audio", FillSound,
|
||||
NULL, _this);
|
||||
|
@ -206,3 +210,5 @@ int BE_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
}
|
||||
|
||||
}; /* Extern C */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
/* Hidden "this" pointer for the video functions */
|
||||
#define _THIS SDL_AudioDevice *_this
|
||||
|
||||
struct SDL_PrivateAudioData {
|
||||
struct SDL_PrivateAudioData
|
||||
{
|
||||
BSoundPlayer *audio_obj;
|
||||
};
|
||||
|
||||
|
@ -37,3 +38,4 @@ struct SDL_PrivateAudioData {
|
|||
#define audio_obj (_this->hidden->audio_obj)
|
||||
|
||||
#endif /* _SDL_lowaudio_h */
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -101,8 +101,8 @@ Audio_DeleteDevice(SDL_AudioDevice *device)
|
|||
SDL_free(device);
|
||||
}
|
||||
|
||||
static SDL_AudioDevice
|
||||
*Audio_CreateDevice(int devindex)
|
||||
static SDL_AudioDevice *
|
||||
Audio_CreateDevice(int devindex)
|
||||
{
|
||||
SDL_AudioDevice *this;
|
||||
|
||||
|
@ -110,12 +110,13 @@ static SDL_AudioDevice
|
|||
this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice));
|
||||
if (this) {
|
||||
SDL_memset(this, 0, (sizeof *this));
|
||||
this->hidden =
|
||||
(struct SDL_PrivateAudioData*)SDL_malloc((sizeof *this->hidden));
|
||||
this->hidden = (struct SDL_PrivateAudioData *)
|
||||
SDL_malloc((sizeof *this->hidden));
|
||||
}
|
||||
if ((this == NULL) || (this->hidden == NULL)) {
|
||||
SDL_OutOfMemory();
|
||||
if(this) SDL_free(this);
|
||||
if (this)
|
||||
SDL_free(this);
|
||||
return (0);
|
||||
}
|
||||
SDL_memset(this->hidden, 0, (sizeof *this->hidden));
|
||||
|
@ -196,17 +197,18 @@ OBSD_PlayAudio(_THIS)
|
|||
written = write(audio_fd, &mixbuf[p], mixlen - p);
|
||||
if (written > 0)
|
||||
p += written;
|
||||
if (written == -1 && errno != 0 && errno != EAGAIN && errno != EINTR)
|
||||
{
|
||||
if (written == -1 && errno != 0 && errno != EAGAIN && errno != EINTR) {
|
||||
/* Non recoverable error has occurred. It should be reported!!! */
|
||||
perror("audio");
|
||||
break;
|
||||
}
|
||||
|
||||
if ( p < written || ((written < 0) && ((errno == 0) || (errno == EAGAIN))) ) {
|
||||
if (p < written
|
||||
|| ((written < 0) && ((errno == 0) || (errno == EAGAIN)))) {
|
||||
SDL_Delay(1); /* Let a little CPU time go by */
|
||||
}
|
||||
} while ( p < written );
|
||||
}
|
||||
while (p < written);
|
||||
|
||||
/* If timer synchronization is enabled, set the next write frame */
|
||||
if (frame_ticks) {
|
||||
|
@ -222,8 +224,8 @@ OBSD_PlayAudio(_THIS)
|
|||
#endif
|
||||
}
|
||||
|
||||
static Uint8
|
||||
*OBSD_GetAudioBuf(_THIS)
|
||||
static Uint8 *
|
||||
OBSD_GetAudioBuf(_THIS)
|
||||
{
|
||||
return (mixbuf);
|
||||
}
|
||||
|
@ -267,18 +269,46 @@ OBSD_Status(_THIS)
|
|||
"waiting : %s\n"
|
||||
"active : %s\n"
|
||||
"",
|
||||
info.play.buffer_size,
|
||||
info.play.sample_rate,
|
||||
info.play.channels,
|
||||
info.play.precision,
|
||||
info.play.encoding,
|
||||
info.play.seek,
|
||||
info.play.samples,
|
||||
info.play.eof,
|
||||
info.play.pause ? "yes" : "no",
|
||||
info.play.error ? "yes" : "no",
|
||||
info.play.waiting ? "yes" : "no",
|
||||
info.play.active ? "yes": "no");
|
||||
info.
|
||||
play.
|
||||
buffer_size,
|
||||
info.
|
||||
play.
|
||||
sample_rate,
|
||||
info.
|
||||
play.
|
||||
channels,
|
||||
info.
|
||||
play.
|
||||
precision,
|
||||
info.
|
||||
play.
|
||||
encoding,
|
||||
info.
|
||||
play.
|
||||
seek,
|
||||
info.
|
||||
play.
|
||||
samples,
|
||||
info.
|
||||
play.
|
||||
eof,
|
||||
info.
|
||||
play.
|
||||
pause
|
||||
?
|
||||
"yes"
|
||||
:
|
||||
"no",
|
||||
info.
|
||||
play.
|
||||
error
|
||||
?
|
||||
"yes"
|
||||
:
|
||||
"no",
|
||||
info.
|
||||
play.waiting ? "yes" : "no", info.play.active ? "yes" : "no");
|
||||
|
||||
fprintf(stderr, "\n"
|
||||
"[audio info]\n"
|
||||
|
@ -293,8 +323,7 @@ OBSD_Status(_THIS)
|
|||
info.hiwat, info.lowat,
|
||||
(info.mode == AUMODE_PLAY) ? "PLAY"
|
||||
: (info.mode = AUMODE_RECORD) ? "RECORD"
|
||||
: (info.mode == AUMODE_PLAY_ALL ? "PLAY_ALL"
|
||||
: "?"));
|
||||
: (info.mode == AUMODE_PLAY_ALL ? "PLAY_ALL" : "?"));
|
||||
}
|
||||
#endif /* DEBUG_AUDIO */
|
||||
|
||||
|
@ -331,8 +360,7 @@ OBSD_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
mixbuf = NULL;
|
||||
AUDIO_INITINFO(&info);
|
||||
for (format = SDL_FirstAudioFormat(spec->format);
|
||||
format; format = SDL_NextAudioFormat())
|
||||
{
|
||||
format; format = SDL_NextAudioFormat()) {
|
||||
switch (format) {
|
||||
case AUDIO_U8:
|
||||
info.play.encoding = AUDIO_ENCODING_ULINEAR;
|
||||
|
@ -402,3 +430,5 @@ OBSD_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
/* We're ready to rock and roll. :-) */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -56,3 +56,4 @@ struct SDL_PrivateAudioData
|
|||
#define next_frame (this->hidden->next_frame)
|
||||
|
||||
#endif /* _SDL_openbsdaudio_h */
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
#define BUFFER_EMPTY 0
|
||||
#define BUFFER_USED 1
|
||||
|
||||
typedef struct _tMixBufferDesc {
|
||||
typedef struct _tMixBufferDesc
|
||||
{
|
||||
int iBufferUsage; // BUFFER_EMPTY or BUFFER_USED
|
||||
SDL_AudioDevice *pSDLAudioDevice;
|
||||
} tMixBufferDesc, *pMixBufferDesc;
|
||||
|
@ -44,28 +45,25 @@ typedef struct _tMixBufferDesc {
|
|||
// This function is called by DART, when an event occures, like end of
|
||||
// playback of a buffer, etc...
|
||||
//---------------------------------------------------------------------
|
||||
LONG APIENTRY DARTEventFunc(ULONG ulStatus,
|
||||
PMCI_MIX_BUFFER pBuffer,
|
||||
ULONG ulFlags)
|
||||
LONG APIENTRY
|
||||
DARTEventFunc(ULONG ulStatus, PMCI_MIX_BUFFER pBuffer, ULONG ulFlags)
|
||||
{
|
||||
if (ulFlags && MIX_WRITE_COMPLETE)
|
||||
{ // Playback of buffer completed!
|
||||
if (ulFlags && MIX_WRITE_COMPLETE) { // Playback of buffer completed!
|
||||
|
||||
// Get pointer to buffer description
|
||||
pMixBufferDesc pBufDesc;
|
||||
|
||||
if (pBuffer)
|
||||
{
|
||||
if (pBuffer) {
|
||||
pBufDesc = (pMixBufferDesc) (*pBuffer).ulUserParm;
|
||||
|
||||
if (pBufDesc)
|
||||
{
|
||||
if (pBufDesc) {
|
||||
SDL_AudioDevice *pSDLAudioDevice = pBufDesc->pSDLAudioDevice;
|
||||
// Set the buffer to be empty
|
||||
pBufDesc->iBufferUsage = BUFFER_EMPTY;
|
||||
// And notify DART feeder thread that it will have to work a bit.
|
||||
if (pSDLAudioDevice)
|
||||
DosPostEventSem(pSDLAudioDevice->hidden->hevAudioBufferPlayed);
|
||||
DosPostEventSem(pSDLAudioDevice->hidden->
|
||||
hevAudioBufferPlayed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +71,8 @@ LONG APIENTRY DARTEventFunc(ULONG ulStatus,
|
|||
}
|
||||
|
||||
|
||||
int DART_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
||||
int
|
||||
DART_OpenAudio(_THIS, SDL_AudioSpec * spec)
|
||||
{
|
||||
MCI_AMP_OPEN_PARMS AmpOpenParms;
|
||||
MCI_GENERIC_PARMS GenericParms;
|
||||
|
@ -91,14 +90,14 @@ int DART_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
// First thing is to try to open a given DART device!
|
||||
SDL_memset(&AmpOpenParms, 0, sizeof(MCI_AMP_OPEN_PARMS));
|
||||
// pszDeviceType should contain the device type in low word, and device ordinal in high word!
|
||||
AmpOpenParms.pszDeviceType = (PSZ) (MCI_DEVTYPE_AUDIO_AMPMIX | (iDeviceOrd << 16));
|
||||
AmpOpenParms.pszDeviceType =
|
||||
(PSZ) (MCI_DEVTYPE_AUDIO_AMPMIX | (iDeviceOrd << 16));
|
||||
|
||||
iOpenMode = MCI_WAIT | MCI_OPEN_TYPE_ID;
|
||||
if (bOpenShared) iOpenMode |= MCI_OPEN_SHAREABLE;
|
||||
if (bOpenShared)
|
||||
iOpenMode |= MCI_OPEN_SHAREABLE;
|
||||
|
||||
rc = mciSendCommand( 0, MCI_OPEN,
|
||||
iOpenMode,
|
||||
(PVOID) &AmpOpenParms, 0);
|
||||
rc = mciSendCommand(0, MCI_OPEN, iOpenMode, (PVOID) & AmpOpenParms, 0);
|
||||
if (rc != MCIERR_SUCCESS) // No audio available??
|
||||
return (-1);
|
||||
// Save the device ID we got from DART!
|
||||
|
@ -106,8 +105,7 @@ int DART_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
iDeviceOrd = AmpOpenParms.usDeviceID;
|
||||
|
||||
// Determine the audio parameters from the AudioSpec
|
||||
switch ( spec->format & 0xFF )
|
||||
{
|
||||
switch (spec->format & 0xFF) {
|
||||
case 8:
|
||||
/* Unsigned 8 bit audio data */
|
||||
spec->format = AUDIO_U8;
|
||||
|
@ -133,7 +131,8 @@ int DART_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
iBufSize = spec->size;
|
||||
|
||||
// Now query this device if it supports the given freq/bits/channels!
|
||||
SDL_memset(&(_this->hidden->MixSetupParms), 0, sizeof(MCI_MIXSETUP_PARMS));
|
||||
SDL_memset(&(_this->hidden->MixSetupParms), 0,
|
||||
sizeof(MCI_MIXSETUP_PARMS));
|
||||
_this->hidden->MixSetupParms.ulBitsPerSample = iBits;
|
||||
_this->hidden->MixSetupParms.ulFormatTag = MCI_WAVE_FORMAT_PCM;
|
||||
_this->hidden->MixSetupParms.ulSamplesPerSec = iFreq;
|
||||
|
@ -144,8 +143,7 @@ int DART_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
rc = mciSendCommand(iDeviceOrd, MCI_MIXSETUP,
|
||||
MCI_WAIT | MCI_MIXSETUP_QUERYMODE,
|
||||
&(_this->hidden->MixSetupParms), 0);
|
||||
if (rc!=MCIERR_SUCCESS)
|
||||
{ // The device cannot handle this format!
|
||||
if (rc != MCIERR_SUCCESS) { // The device cannot handle this format!
|
||||
// Close DART, and exit with error code!
|
||||
mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0);
|
||||
SDL_SetError("Audio device doesn't support requested audio format");
|
||||
|
@ -155,8 +153,7 @@ int DART_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
rc = mciSendCommand(iDeviceOrd, MCI_MIXSETUP,
|
||||
MCI_WAIT | MCI_MIXSETUP_INIT,
|
||||
&(_this->hidden->MixSetupParms), 0);
|
||||
if (rc!=MCIERR_SUCCESS)
|
||||
{ // The device could not be opened!
|
||||
if (rc != MCIERR_SUCCESS) { // The device could not be opened!
|
||||
// Close DART, and exit with error code!
|
||||
mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0);
|
||||
SDL_SetError("Audio device could not be set up");
|
||||
|
@ -165,9 +162,9 @@ int DART_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
// Ok, the device is initialized.
|
||||
// Now we should allocate buffers. For this, we need a place where
|
||||
// the buffer descriptors will be:
|
||||
_this->hidden->pMixBuffers = (MCI_MIX_BUFFER *) SDL_malloc(sizeof(MCI_MIX_BUFFER)*iNumBufs);
|
||||
if (!(_this->hidden->pMixBuffers))
|
||||
{ // Not enough memory!
|
||||
_this->hidden->pMixBuffers =
|
||||
(MCI_MIX_BUFFER *) SDL_malloc(sizeof(MCI_MIX_BUFFER) * iNumBufs);
|
||||
if (!(_this->hidden->pMixBuffers)) { // Not enough memory!
|
||||
// Close DART, and exit with error code!
|
||||
mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0);
|
||||
SDL_SetError("Not enough memory for audio buffer descriptors");
|
||||
|
@ -182,10 +179,12 @@ int DART_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
rc = mciSendCommand(iDeviceOrd, MCI_BUFFER,
|
||||
MCI_WAIT | MCI_ALLOCATE_MEMORY,
|
||||
&(_this->hidden->BufferParms), 0);
|
||||
if ((rc!=MCIERR_SUCCESS) || (iNumBufs != _this->hidden->BufferParms.ulNumBuffers) || (_this->hidden->BufferParms.ulBufferSize==0))
|
||||
{ // Could not allocate memory!
|
||||
if ((rc != MCIERR_SUCCESS)
|
||||
|| (iNumBufs != _this->hidden->BufferParms.ulNumBuffers)
|
||||
|| (_this->hidden->BufferParms.ulBufferSize == 0)) { // Could not allocate memory!
|
||||
// Close DART, and exit with error code!
|
||||
SDL_free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL;
|
||||
SDL_free(_this->hidden->pMixBuffers);
|
||||
_this->hidden->pMixBuffers = NULL;
|
||||
mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0);
|
||||
SDL_SetError("DART could not allocate buffers");
|
||||
return (-1);
|
||||
|
@ -193,52 +192,65 @@ int DART_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
// Ok, we have all the buffers allocated, let's mark them!
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<iNumBufs; i++)
|
||||
{
|
||||
pMixBufferDesc pBufferDesc = (pMixBufferDesc) SDL_malloc(sizeof(tMixBufferDesc));;
|
||||
for (i = 0; i < iNumBufs; i++) {
|
||||
pMixBufferDesc pBufferDesc =
|
||||
(pMixBufferDesc) SDL_malloc(sizeof(tMixBufferDesc));;
|
||||
// Check if this buffer was really allocated by DART
|
||||
if ((!(_this->hidden->pMixBuffers[i].pBuffer)) || (!pBufferDesc))
|
||||
{ // Wrong buffer!
|
||||
if ((!(_this->hidden->pMixBuffers[i].pBuffer))
|
||||
|| (!pBufferDesc)) { // Wrong buffer!
|
||||
// Close DART, and exit with error code!
|
||||
// Free buffer descriptions
|
||||
{ int j;
|
||||
for (j=0; j<i; j++) SDL_free((void *)(_this->hidden->pMixBuffers[j].ulUserParm));
|
||||
{
|
||||
int j;
|
||||
for (j = 0; j < i; j++)
|
||||
SDL_free((void *) (_this->hidden->pMixBuffers[j].
|
||||
ulUserParm));
|
||||
}
|
||||
// and cleanup
|
||||
mciSendCommand(iDeviceOrd, MCI_BUFFER, MCI_WAIT | MCI_DEALLOCATE_MEMORY, &(_this->hidden->BufferParms), 0);
|
||||
SDL_free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL;
|
||||
mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0);
|
||||
mciSendCommand(iDeviceOrd, MCI_BUFFER,
|
||||
MCI_WAIT | MCI_DEALLOCATE_MEMORY,
|
||||
&(_this->hidden->BufferParms), 0);
|
||||
SDL_free(_this->hidden->pMixBuffers);
|
||||
_this->hidden->pMixBuffers = NULL;
|
||||
mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT,
|
||||
&GenericParms, 0);
|
||||
SDL_SetError("Error at internal buffer check");
|
||||
return (-1);
|
||||
}
|
||||
pBufferDesc->iBufferUsage = BUFFER_EMPTY;
|
||||
pBufferDesc->pSDLAudioDevice = _this;
|
||||
|
||||
_this->hidden->pMixBuffers[i].ulBufferLength = _this->hidden->BufferParms.ulBufferSize;
|
||||
_this->hidden->pMixBuffers[i].ulBufferLength =
|
||||
_this->hidden->BufferParms.ulBufferSize;
|
||||
_this->hidden->pMixBuffers[i].ulUserParm = (ULONG) pBufferDesc; // User parameter: Description of buffer
|
||||
_this->hidden->pMixBuffers[i].ulFlags = 0; // Some stuff should be flagged here for DART, like end of
|
||||
// audio data, but as we will continously send
|
||||
// audio data, there will be no end.:)
|
||||
SDL_memset(_this->hidden->pMixBuffers[i].pBuffer, iSilence, iBufSize);
|
||||
SDL_memset(_this->hidden->pMixBuffers[i].pBuffer, iSilence,
|
||||
iBufSize);
|
||||
}
|
||||
}
|
||||
_this->hidden->iNextFreeBuffer = 0;
|
||||
_this->hidden->iLastPlayedBuf = -1;
|
||||
// Create event semaphore
|
||||
if (DosCreateEventSem(NULL, &(_this->hidden->hevAudioBufferPlayed), 0, FALSE)!=NO_ERROR)
|
||||
if (DosCreateEventSem
|
||||
(NULL, &(_this->hidden->hevAudioBufferPlayed), 0, FALSE) != NO_ERROR)
|
||||
{
|
||||
// Could not create event semaphore!
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<iNumBufs; i++) SDL_free((void *)(_this->hidden->pMixBuffers[i].ulUserParm));
|
||||
for (i = 0; i < iNumBufs; i++)
|
||||
SDL_free((void *) (_this->hidden->pMixBuffers[i].ulUserParm));
|
||||
}
|
||||
mciSendCommand(iDeviceOrd, MCI_BUFFER, MCI_WAIT | MCI_DEALLOCATE_MEMORY, &(_this->hidden->BufferParms), 0);
|
||||
SDL_free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL;
|
||||
mciSendCommand(iDeviceOrd, MCI_BUFFER,
|
||||
MCI_WAIT | MCI_DEALLOCATE_MEMORY,
|
||||
&(_this->hidden->BufferParms), 0);
|
||||
SDL_free(_this->hidden->pMixBuffers);
|
||||
_this->hidden->pMixBuffers = NULL;
|
||||
mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0);
|
||||
SDL_SetError("Could not create event semaphore");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
// Store the new settings in global variables
|
||||
_this->hidden->iCurrDeviceOrd = iDeviceOrd;
|
||||
_this->hidden->iCurrFreq = iFreq;
|
||||
|
@ -252,13 +264,15 @@ int DART_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
|
||||
|
||||
|
||||
void DART_ThreadInit(_THIS)
|
||||
void
|
||||
DART_ThreadInit(_THIS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* This function waits until it is possible to write a full sound buffer */
|
||||
void DART_WaitAudio(_THIS)
|
||||
void
|
||||
DART_WaitAudio(_THIS)
|
||||
{
|
||||
int i;
|
||||
pMixBufferDesc pBufDesc;
|
||||
|
@ -266,8 +280,7 @@ void DART_WaitAudio(_THIS)
|
|||
|
||||
DosResetEventSem(_this->hidden->hevAudioBufferPlayed, &ulPostCount);
|
||||
// If there is already an empty buffer, then return now!
|
||||
for (i=0; i<_this->hidden->iCurrNumBufs; i++)
|
||||
{
|
||||
for (i = 0; i < _this->hidden->iCurrNumBufs; i++) {
|
||||
pBufDesc = (pMixBufferDesc) _this->hidden->pMixBuffers[i].ulUserParm;
|
||||
if (pBufDesc->iBufferUsage == BUFFER_EMPTY)
|
||||
return;
|
||||
|
@ -277,127 +290,141 @@ void DART_WaitAudio(_THIS)
|
|||
return;
|
||||
}
|
||||
|
||||
void DART_PlayAudio(_THIS)
|
||||
void
|
||||
DART_PlayAudio(_THIS)
|
||||
{
|
||||
int iFreeBuf = _this->hidden->iNextFreeBuffer;
|
||||
pMixBufferDesc pBufDesc;
|
||||
|
||||
pBufDesc = (pMixBufferDesc) _this->hidden->pMixBuffers[iFreeBuf].ulUserParm;
|
||||
pBufDesc =
|
||||
(pMixBufferDesc) _this->hidden->pMixBuffers[iFreeBuf].ulUserParm;
|
||||
pBufDesc->iBufferUsage = BUFFER_USED;
|
||||
// Send it to DART to be queued
|
||||
_this->hidden->MixSetupParms.pmixWrite(_this->hidden->MixSetupParms.ulMixHandle,
|
||||
&(_this->hidden->pMixBuffers[iFreeBuf]), 1);
|
||||
_this->hidden->MixSetupParms.pmixWrite(_this->hidden->MixSetupParms.
|
||||
ulMixHandle,
|
||||
&(_this->hidden->
|
||||
pMixBuffers[iFreeBuf]), 1);
|
||||
|
||||
_this->hidden->iLastPlayedBuf = iFreeBuf;
|
||||
iFreeBuf = (iFreeBuf + 1) % _this->hidden->iCurrNumBufs;
|
||||
_this->hidden->iNextFreeBuffer = iFreeBuf;
|
||||
}
|
||||
|
||||
Uint8 *DART_GetAudioBuf(_THIS)
|
||||
Uint8 *
|
||||
DART_GetAudioBuf(_THIS)
|
||||
{
|
||||
int iFreeBuf;
|
||||
Uint8 *pResult;
|
||||
pMixBufferDesc pBufDesc;
|
||||
|
||||
if (_this)
|
||||
{
|
||||
if (_this->hidden)
|
||||
{
|
||||
if (_this) {
|
||||
if (_this->hidden) {
|
||||
iFreeBuf = _this->hidden->iNextFreeBuffer;
|
||||
pBufDesc = (pMixBufferDesc) _this->hidden->pMixBuffers[iFreeBuf].ulUserParm;
|
||||
pBufDesc =
|
||||
(pMixBufferDesc) _this->hidden->pMixBuffers[iFreeBuf].
|
||||
ulUserParm;
|
||||
|
||||
if (pBufDesc)
|
||||
{
|
||||
if (pBufDesc->iBufferUsage == BUFFER_EMPTY)
|
||||
{
|
||||
if (pBufDesc) {
|
||||
if (pBufDesc->iBufferUsage == BUFFER_EMPTY) {
|
||||
pResult = _this->hidden->pMixBuffers[iFreeBuf].pBuffer;
|
||||
return pResult;
|
||||
}
|
||||
} else
|
||||
printf("[DART_GetAudioBuf] : ERROR! pBufDesc = %p\n", pBufDesc);
|
||||
printf("[DART_GetAudioBuf] : ERROR! pBufDesc = %p\n",
|
||||
pBufDesc);
|
||||
} else
|
||||
printf("[DART_GetAudioBuf] : ERROR! _this->hidden = %p\n", _this->hidden);
|
||||
printf("[DART_GetAudioBuf] : ERROR! _this->hidden = %p\n",
|
||||
_this->hidden);
|
||||
} else
|
||||
printf("[DART_GetAudioBuf] : ERROR! _this = %p\n", _this);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void DART_WaitDone(_THIS)
|
||||
void
|
||||
DART_WaitDone(_THIS)
|
||||
{
|
||||
pMixBufferDesc pBufDesc;
|
||||
ULONG ulPostCount;
|
||||
APIRET rc;
|
||||
|
||||
pBufDesc = (pMixBufferDesc) _this->hidden->pMixBuffers[_this->hidden->iLastPlayedBuf].ulUserParm;
|
||||
pBufDesc =
|
||||
(pMixBufferDesc) _this->hidden->pMixBuffers[_this->hidden->
|
||||
iLastPlayedBuf].
|
||||
ulUserParm;
|
||||
rc = NO_ERROR;
|
||||
while ((pBufDesc->iBufferUsage != BUFFER_EMPTY) && (rc==NO_ERROR))
|
||||
{
|
||||
while ((pBufDesc->iBufferUsage != BUFFER_EMPTY) && (rc == NO_ERROR)) {
|
||||
DosResetEventSem(_this->hidden->hevAudioBufferPlayed, &ulPostCount);
|
||||
rc = DosWaitEventSem(_this->hidden->hevAudioBufferPlayed, 1000); // 1 sec timeout! Important!
|
||||
}
|
||||
}
|
||||
|
||||
void DART_CloseAudio(_THIS)
|
||||
void
|
||||
DART_CloseAudio(_THIS)
|
||||
{
|
||||
MCI_GENERIC_PARMS GenericParms;
|
||||
int rc;
|
||||
|
||||
// Stop DART playback
|
||||
rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_STOP, MCI_WAIT, &GenericParms, 0);
|
||||
if (rc!=MCIERR_SUCCESS)
|
||||
{
|
||||
rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_STOP, MCI_WAIT,
|
||||
&GenericParms, 0);
|
||||
if (rc != MCIERR_SUCCESS) {
|
||||
#ifdef SFX_DEBUG_BUILD
|
||||
printf("Could not stop DART playback!\n");
|
||||
fflush(stdout);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Close event semaphore
|
||||
DosCloseEventSem(_this->hidden->hevAudioBufferPlayed);
|
||||
|
||||
// Free memory of buffer descriptions
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<_this->hidden->iCurrNumBufs; i++) SDL_free((void *)(_this->hidden->pMixBuffers[i].ulUserParm));
|
||||
for (i = 0; i < _this->hidden->iCurrNumBufs; i++)
|
||||
SDL_free((void *) (_this->hidden->pMixBuffers[i].ulUserParm));
|
||||
}
|
||||
|
||||
// Deallocate buffers
|
||||
rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_BUFFER, MCI_WAIT | MCI_DEALLOCATE_MEMORY, &(_this->hidden->BufferParms), 0);
|
||||
rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_BUFFER,
|
||||
MCI_WAIT | MCI_DEALLOCATE_MEMORY,
|
||||
&(_this->hidden->BufferParms), 0);
|
||||
|
||||
// Free bufferlist
|
||||
SDL_free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL;
|
||||
SDL_free(_this->hidden->pMixBuffers);
|
||||
_this->hidden->pMixBuffers = NULL;
|
||||
|
||||
// Close dart
|
||||
rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_CLOSE, MCI_WAIT, &(GenericParms), 0);
|
||||
rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_CLOSE, MCI_WAIT,
|
||||
&(GenericParms), 0);
|
||||
}
|
||||
|
||||
/* Audio driver bootstrap functions */
|
||||
|
||||
int Audio_Available(void)
|
||||
int
|
||||
Audio_Available(void)
|
||||
{
|
||||
return (1);
|
||||
}
|
||||
|
||||
void Audio_DeleteDevice(SDL_AudioDevice *device)
|
||||
void
|
||||
Audio_DeleteDevice(SDL_AudioDevice * device)
|
||||
{
|
||||
SDL_free(device->hidden);
|
||||
SDL_free(device);
|
||||
}
|
||||
|
||||
SDL_AudioDevice *Audio_CreateDevice(int devindex)
|
||||
SDL_AudioDevice *
|
||||
Audio_CreateDevice(int devindex)
|
||||
{
|
||||
SDL_AudioDevice *this;
|
||||
|
||||
/* Initialize all variables that we clean on shutdown */
|
||||
this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice));
|
||||
if ( this )
|
||||
{
|
||||
if (this) {
|
||||
SDL_memset(this, 0, (sizeof *this));
|
||||
this->hidden = (struct SDL_PrivateAudioData *)
|
||||
SDL_malloc((sizeof *this->hidden));
|
||||
}
|
||||
if ( (this == NULL) || (this->hidden == NULL) )
|
||||
{
|
||||
if ((this == NULL) || (this->hidden == NULL)) {
|
||||
SDL_OutOfMemory();
|
||||
if (this)
|
||||
SDL_free(this);
|
||||
|
@ -424,3 +451,4 @@ AudioBootStrap DART_bootstrap = {
|
|||
Audio_Available, Audio_CreateDevice
|
||||
};
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -61,3 +61,4 @@ struct SDL_PrivateAudioData
|
|||
};
|
||||
|
||||
#endif /* _SDL_lowaudio_h */
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -42,18 +42,21 @@ static Uint8 *DCAUD_GetAudioBuf(_THIS);
|
|||
static void DCAUD_CloseAudio(_THIS);
|
||||
|
||||
/* Audio driver bootstrap functions */
|
||||
static int DCAUD_Available(void)
|
||||
static int
|
||||
DCAUD_Available(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void DCAUD_DeleteDevice(SDL_AudioDevice *device)
|
||||
static void
|
||||
DCAUD_DeleteDevice(SDL_AudioDevice * device)
|
||||
{
|
||||
SDL_free(device->hidden);
|
||||
SDL_free(device);
|
||||
}
|
||||
|
||||
static SDL_AudioDevice *DCAUD_CreateDevice(int devindex)
|
||||
static SDL_AudioDevice *
|
||||
DCAUD_CreateDevice(int devindex)
|
||||
{
|
||||
SDL_AudioDevice *this;
|
||||
|
||||
|
@ -93,7 +96,8 @@ AudioBootStrap DCAUD_bootstrap = {
|
|||
};
|
||||
|
||||
/* This function waits until it is possible to write a full sound buffer */
|
||||
static void DCAUD_WaitAudio(_THIS)
|
||||
static void
|
||||
DCAUD_WaitAudio(_THIS)
|
||||
{
|
||||
if (this->hidden->playing) {
|
||||
/* wait */
|
||||
|
@ -105,7 +109,8 @@ static void DCAUD_WaitAudio(_THIS)
|
|||
|
||||
#define SPU_RAM_BASE 0xa0800000
|
||||
|
||||
static void spu_memload_stereo8(int leftpos,int rightpos,void *src0,size_t size)
|
||||
static void
|
||||
spu_memload_stereo8(int leftpos, int rightpos, void *src0, size_t size)
|
||||
{
|
||||
uint8 *src = src0;
|
||||
uint32 *left = (uint32 *) (leftpos + SPU_RAM_BASE);
|
||||
|
@ -127,7 +132,8 @@ static void spu_memload_stereo8(int leftpos,int rightpos,void *src0,size_t size)
|
|||
}
|
||||
}
|
||||
|
||||
static void spu_memload_stereo16(int leftpos,int rightpos,void *src0,size_t size)
|
||||
static void
|
||||
spu_memload_stereo16(int leftpos, int rightpos, void *src0, size_t size)
|
||||
{
|
||||
uint16 *src = src0;
|
||||
uint32 *left = (uint32 *) (leftpos + SPU_RAM_BASE);
|
||||
|
@ -145,7 +151,8 @@ static void spu_memload_stereo16(int leftpos,int rightpos,void *src0,size_t size
|
|||
}
|
||||
}
|
||||
|
||||
static void DCAUD_PlayAudio(_THIS)
|
||||
static void
|
||||
DCAUD_PlayAudio(_THIS)
|
||||
{
|
||||
SDL_AudioSpec *spec = &this->spec;
|
||||
unsigned int offset;
|
||||
|
@ -161,13 +168,18 @@ static void DCAUD_PlayAudio(_THIS)
|
|||
this->hidden->nextbuf ^= 1;
|
||||
/* Write the audio data, checking for EAGAIN on broken audio drivers */
|
||||
if (spec->channels == 1) {
|
||||
spu_memload(this->hidden->leftpos+offset,this->hidden->mixbuf,this->hidden->mixlen);
|
||||
spu_memload(this->hidden->leftpos + offset, this->hidden->mixbuf,
|
||||
this->hidden->mixlen);
|
||||
} else {
|
||||
offset /= 2;
|
||||
if ((this->spec.format & 255) == 8) {
|
||||
spu_memload_stereo8(this->hidden->leftpos+offset,this->hidden->rightpos+offset,this->hidden->mixbuf,this->hidden->mixlen);
|
||||
spu_memload_stereo8(this->hidden->leftpos + offset,
|
||||
this->hidden->rightpos + offset,
|
||||
this->hidden->mixbuf, this->hidden->mixlen);
|
||||
} else {
|
||||
spu_memload_stereo16(this->hidden->leftpos+offset,this->hidden->rightpos+offset,this->hidden->mixbuf,this->hidden->mixlen);
|
||||
spu_memload_stereo16(this->hidden->leftpos + offset,
|
||||
this->hidden->rightpos + offset,
|
||||
this->hidden->mixbuf, this->hidden->mixlen);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,34 +188,45 @@ static void DCAUD_PlayAudio(_THIS)
|
|||
this->hidden->playing = 1;
|
||||
mode = (spec->format == AUDIO_S8) ? SM_8BIT : SM_16BIT;
|
||||
if (spec->channels == 1) {
|
||||
aica_play(0,mode,this->hidden->leftpos,0,spec->samples*2,spec->freq,255,128,1);
|
||||
aica_play(0, mode, this->hidden->leftpos, 0,
|
||||
spec->samples * 2, spec->freq, 255, 128, 1);
|
||||
} else {
|
||||
aica_play(0,mode,this->hidden->leftpos ,0,spec->samples*2,spec->freq,255,0,1);
|
||||
aica_play(1,mode,this->hidden->rightpos,0,spec->samples*2,spec->freq,255,255,1);
|
||||
aica_play(0, mode, this->hidden->leftpos, 0,
|
||||
spec->samples * 2, spec->freq, 255, 0, 1);
|
||||
aica_play(1, mode, this->hidden->rightpos, 0,
|
||||
spec->samples * 2, spec->freq, 255, 255, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Uint8 *DCAUD_GetAudioBuf(_THIS)
|
||||
static Uint8 *
|
||||
DCAUD_GetAudioBuf(_THIS)
|
||||
{
|
||||
return (this->hidden->mixbuf);
|
||||
}
|
||||
|
||||
static void DCAUD_CloseAudio(_THIS)
|
||||
static void
|
||||
DCAUD_CloseAudio(_THIS)
|
||||
{
|
||||
aica_stop(0);
|
||||
if (this->spec.channels==2) aica_stop(1);
|
||||
if (this->spec.channels == 2)
|
||||
aica_stop(1);
|
||||
if (this->hidden->mixbuf != NULL) {
|
||||
SDL_FreeAudioMem(this->hidden->mixbuf);
|
||||
this->hidden->mixbuf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int DCAUD_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
||||
static int
|
||||
DCAUD_OpenAudio(_THIS, SDL_AudioSpec * spec)
|
||||
{
|
||||
switch (spec->format & 0xff) {
|
||||
case 8: spec->format = AUDIO_S8; break;
|
||||
case 16: spec->format = AUDIO_S16LSB; break;
|
||||
case 8:
|
||||
spec->format = AUDIO_S8;
|
||||
break;
|
||||
case 16:
|
||||
spec->format = AUDIO_S16LSB;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unsupported audio format");
|
||||
return (-1);
|
||||
|
@ -227,3 +250,5 @@ static int DCAUD_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
/* We're ready to rock and roll. :-) */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
/* Hidden "this" pointer for the video functions */
|
||||
#define _THIS SDL_AudioDevice *this
|
||||
|
||||
struct SDL_PrivateAudioData {
|
||||
struct SDL_PrivateAudioData
|
||||
{
|
||||
/* The file descriptor for the audio device */
|
||||
Uint8 *mixbuf;
|
||||
Uint32 mixlen;
|
||||
|
@ -39,3 +40,4 @@ struct SDL_PrivateAudioData {
|
|||
};
|
||||
|
||||
#endif /* _SDL_dcaudio_h */
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
#include <arch/irq.h>
|
||||
#include <dc/spu.h>
|
||||
|
||||
/* #define dc_snd_base ((volatile unsigned char *)0x00800000) */ /* arm side */
|
||||
#if 0
|
||||
#define dc_snd_base ((volatile unsigned char *)0x00800000) /* arm side */
|
||||
#endif
|
||||
#define dc_snd_base ((volatile unsigned char *)0xa0700000) /* dc side */
|
||||
|
||||
/* Some convienence macros */
|
||||
|
@ -39,7 +41,9 @@
|
|||
} while(0)
|
||||
|
||||
|
||||
void aica_init() {
|
||||
void
|
||||
aica_init()
|
||||
{
|
||||
int i, j, old = 0;
|
||||
|
||||
/* Initialize AICA channels */
|
||||
|
@ -48,7 +52,8 @@ void aica_init() {
|
|||
|
||||
for (i = 0; i < 64; i++) {
|
||||
for (j = 0; j < 0x80; j += 4) {
|
||||
if ((j&31)==0) g2_fifo_wait();
|
||||
if ((j & 31) == 0)
|
||||
g2_fifo_wait();
|
||||
CHNREG32(i, j) = 0;
|
||||
}
|
||||
g2_fifo_wait();
|
||||
|
@ -113,7 +118,9 @@ const static unsigned char logs[] = {
|
|||
#define AICA_VOL(x) (0xff - logs[128 + (((x) & 0xff) / 2)])
|
||||
//#define AICA_VOL(x) (0xff - logs[x&255])
|
||||
|
||||
static inline unsigned AICA_FREQ(unsigned freq) {
|
||||
static inline unsigned
|
||||
AICA_FREQ(unsigned freq)
|
||||
{
|
||||
unsigned long freq_lo, freq_base = 5644800;
|
||||
int freq_hi = 7;
|
||||
|
||||
|
@ -148,7 +155,10 @@ static inline unsigned AICA_FREQ(unsigned freq) {
|
|||
|
||||
This routine (and the similar ones) owe a lot to Marcus' sound example --
|
||||
I hadn't gotten quite this far into dissecting the individual regs yet. */
|
||||
void aica_play(int ch,int mode,unsigned long smpptr,int loopst,int loopend,int freq,int vol,int pan,int loopflag) {
|
||||
void
|
||||
aica_play(int ch, int mode, unsigned long smpptr, int loopst, int loopend,
|
||||
int freq, int vol, int pan, int loopflag)
|
||||
{
|
||||
/* int i;
|
||||
*/
|
||||
int val;
|
||||
|
@ -204,7 +214,8 @@ void aica_play(int ch,int mode,unsigned long smpptr,int loopst,int loopend,int f
|
|||
also set the bits to start playback here. */
|
||||
CHNREG32(ch, 4) = smpptr & 0xffff;
|
||||
val = 0xc000 | 0x0000 | (mode << 7) | (smpptr >> 16);
|
||||
if (loopflag) val|=0x200;
|
||||
if (loopflag)
|
||||
val |= 0x200;
|
||||
|
||||
CHNREG32(ch, 0) = val;
|
||||
|
||||
|
@ -216,7 +227,8 @@ void aica_play(int ch,int mode,unsigned long smpptr,int loopst,int loopend,int f
|
|||
|
||||
#if 0
|
||||
for (i = 0xff; i >= vol; i--) {
|
||||
if ((i&7)==0) g2_fifo_wait();
|
||||
if ((i & 7) == 0)
|
||||
g2_fifo_wait();
|
||||
CHNREG32(ch, 40) = 0x24 | (i << 8);;
|
||||
}
|
||||
|
||||
|
@ -225,8 +237,11 @@ void aica_play(int ch,int mode,unsigned long smpptr,int loopst,int loopend,int f
|
|||
}
|
||||
|
||||
/* Stop the sound on a given channel */
|
||||
void aica_stop(int ch) {
|
||||
g2_write_32(CHNREGADDR(ch, 0),(g2_read_32(CHNREGADDR(ch, 0)) & ~0x4000) | 0x8000);
|
||||
void
|
||||
aica_stop(int ch)
|
||||
{
|
||||
g2_write_32(CHNREGADDR(ch, 0),
|
||||
(g2_read_32(CHNREGADDR(ch, 0)) & ~0x4000) | 0x8000);
|
||||
g2_fifo_wait();
|
||||
}
|
||||
|
||||
|
@ -235,30 +250,43 @@ void aica_stop(int ch) {
|
|||
can do things like vibrato and panning effects. */
|
||||
|
||||
/* Set channel volume */
|
||||
void aica_vol(int ch,int vol) {
|
||||
void
|
||||
aica_vol(int ch, int vol)
|
||||
{
|
||||
// g2_write_8(CHNREGADDR(ch, 41),AICA_VOL(vol));
|
||||
g2_write_32(CHNREGADDR(ch, 40),(g2_read_32(CHNREGADDR(ch, 40))&0xffff00ff)|(AICA_VOL(vol)<<8) );
|
||||
g2_write_32(CHNREGADDR(ch, 40),
|
||||
(g2_read_32(CHNREGADDR(ch, 40)) & 0xffff00ff) |
|
||||
(AICA_VOL(vol) << 8));
|
||||
g2_fifo_wait();
|
||||
}
|
||||
|
||||
/* Set channel pan */
|
||||
void aica_pan(int ch,int pan) {
|
||||
void
|
||||
aica_pan(int ch, int pan)
|
||||
{
|
||||
// g2_write_8(CHNREGADDR(ch, 36),AICA_PAN(pan));
|
||||
g2_write_32(CHNREGADDR(ch, 36),(g2_read_32(CHNREGADDR(ch, 36))&0xffffff00)|(AICA_PAN(pan)) );
|
||||
g2_write_32(CHNREGADDR(ch, 36),
|
||||
(g2_read_32(CHNREGADDR(ch, 36)) & 0xffffff00) |
|
||||
(AICA_PAN(pan)));
|
||||
g2_fifo_wait();
|
||||
}
|
||||
|
||||
/* Set channel frequency */
|
||||
void aica_freq(int ch,int freq) {
|
||||
void
|
||||
aica_freq(int ch, int freq)
|
||||
{
|
||||
g2_write_32(CHNREGADDR(ch, 24), AICA_FREQ(freq));
|
||||
g2_fifo_wait();
|
||||
}
|
||||
|
||||
/* Get channel position */
|
||||
int aica_get_pos(int ch) {
|
||||
int
|
||||
aica_get_pos(int ch)
|
||||
{
|
||||
#if 1
|
||||
/* Observe channel ch */
|
||||
g2_write_32(SNDREGADDR(0x280c),(g2_read_32(SNDREGADDR(0x280c))&0xffff00ff) | (ch<<8));
|
||||
g2_write_32(SNDREGADDR(0x280c),
|
||||
(g2_read_32(SNDREGADDR(0x280c)) & 0xffff00ff) | (ch << 8));
|
||||
g2_fifo_wait();
|
||||
/* Update position counters */
|
||||
return g2_read_32(SNDREGADDR(0x2814)) & 0xffff;
|
||||
|
@ -269,3 +297,5 @@ int aica_get_pos(int ch) {
|
|||
return g2_read_32(SNDREGADDR(0x2814)) & 0xffff;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -30,7 +30,8 @@
|
|||
#define SM_16BIT 0
|
||||
#define SM_ADPCM 2
|
||||
|
||||
void aica_play(int ch,int mode,unsigned long smpptr,int looptst,int loopend,int freq,int vol,int pan,int loopflag);
|
||||
void aica_play(int ch, int mode, unsigned long smpptr, int looptst,
|
||||
int loopend, int freq, int vol, int pan, int loopflag);
|
||||
void aica_stop(int ch);
|
||||
void aica_vol(int ch, int vol);
|
||||
void aica_pan(int ch, int pan);
|
||||
|
@ -38,3 +39,4 @@ void aica_freq(int ch,int freq);
|
|||
int aica_get_pos(int ch);
|
||||
|
||||
#endif
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -53,14 +53,16 @@ static void DISKAUD_PlayAudio(_THIS);
|
|||
static Uint8 *DISKAUD_GetAudioBuf(_THIS);
|
||||
static void DISKAUD_CloseAudio(_THIS);
|
||||
|
||||
static const char *DISKAUD_GetOutputFilename(void)
|
||||
static const char *
|
||||
DISKAUD_GetOutputFilename(void)
|
||||
{
|
||||
const char *envr = SDL_getenv(DISKENVR_OUTFILE);
|
||||
return ((envr != NULL) ? envr : DISKDEFAULT_OUTFILE);
|
||||
}
|
||||
|
||||
/* Audio driver bootstrap functions */
|
||||
static int DISKAUD_Available(void)
|
||||
static int
|
||||
DISKAUD_Available(void)
|
||||
{
|
||||
const char *envr = SDL_getenv("SDL_AUDIODRIVER");
|
||||
if (envr && (SDL_strcmp(envr, DISKAUD_DRIVER_NAME) == 0)) {
|
||||
|
@ -69,13 +71,15 @@ static int DISKAUD_Available(void)
|
|||
return (0);
|
||||
}
|
||||
|
||||
static void DISKAUD_DeleteDevice(SDL_AudioDevice *device)
|
||||
static void
|
||||
DISKAUD_DeleteDevice(SDL_AudioDevice * device)
|
||||
{
|
||||
SDL_free(device->hidden);
|
||||
SDL_free(device);
|
||||
}
|
||||
|
||||
static SDL_AudioDevice *DISKAUD_CreateDevice(int devindex)
|
||||
static SDL_AudioDevice *
|
||||
DISKAUD_CreateDevice(int devindex)
|
||||
{
|
||||
SDL_AudioDevice *this;
|
||||
const char *envr;
|
||||
|
@ -97,7 +101,8 @@ static SDL_AudioDevice *DISKAUD_CreateDevice(int devindex)
|
|||
SDL_memset(this->hidden, 0, (sizeof *this->hidden));
|
||||
|
||||
envr = SDL_getenv(DISKENVR_WRITEDELAY);
|
||||
this->hidden->write_delay = (envr) ? SDL_atoi(envr) : DISKDEFAULT_WRITEDELAY;
|
||||
this->hidden->write_delay =
|
||||
(envr) ? SDL_atoi(envr) : DISKDEFAULT_WRITEDELAY;
|
||||
|
||||
/* Set the function pointers */
|
||||
this->OpenAudio = DISKAUD_OpenAudio;
|
||||
|
@ -117,19 +122,20 @@ AudioBootStrap DISKAUD_bootstrap = {
|
|||
};
|
||||
|
||||
/* This function waits until it is possible to write a full sound buffer */
|
||||
static void DISKAUD_WaitAudio(_THIS)
|
||||
static void
|
||||
DISKAUD_WaitAudio(_THIS)
|
||||
{
|
||||
SDL_Delay(this->hidden->write_delay);
|
||||
}
|
||||
|
||||
static void DISKAUD_PlayAudio(_THIS)
|
||||
static void
|
||||
DISKAUD_PlayAudio(_THIS)
|
||||
{
|
||||
int written;
|
||||
|
||||
/* Write the audio data */
|
||||
written = SDL_RWwrite(this->hidden->output,
|
||||
this->hidden->mixbuf, 1,
|
||||
this->hidden->mixlen);
|
||||
this->hidden->mixbuf, 1, this->hidden->mixlen);
|
||||
|
||||
/* If we couldn't write, assume fatal error for now */
|
||||
if ((Uint32) written != this->hidden->mixlen) {
|
||||
|
@ -140,12 +146,14 @@ static void DISKAUD_PlayAudio(_THIS)
|
|||
#endif
|
||||
}
|
||||
|
||||
static Uint8 *DISKAUD_GetAudioBuf(_THIS)
|
||||
static Uint8 *
|
||||
DISKAUD_GetAudioBuf(_THIS)
|
||||
{
|
||||
return (this->hidden->mixbuf);
|
||||
}
|
||||
|
||||
static void DISKAUD_CloseAudio(_THIS)
|
||||
static void
|
||||
DISKAUD_CloseAudio(_THIS)
|
||||
{
|
||||
if (this->hidden->mixbuf != NULL) {
|
||||
SDL_FreeAudioMem(this->hidden->mixbuf);
|
||||
|
@ -157,7 +165,8 @@ static void DISKAUD_CloseAudio(_THIS)
|
|||
}
|
||||
}
|
||||
|
||||
static int DISKAUD_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
||||
static int
|
||||
DISKAUD_OpenAudio(_THIS, SDL_AudioSpec * spec)
|
||||
{
|
||||
const char *fname = DISKAUD_GetOutputFilename();
|
||||
|
||||
|
@ -166,7 +175,6 @@ static int DISKAUD_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
if (this->hidden->output == NULL) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
#if HAVE_STDIO_H
|
||||
fprintf(stderr, "WARNING: You are using the SDL disk writer"
|
||||
" audio driver!\n Writing to file [%s].\n", fname);
|
||||
|
@ -184,3 +192,4 @@ static int DISKAUD_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
return (0);
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -30,7 +30,8 @@
|
|||
/* Hidden "this" pointer for the video functions */
|
||||
#define _THIS SDL_AudioDevice *this
|
||||
|
||||
struct SDL_PrivateAudioData {
|
||||
struct SDL_PrivateAudioData
|
||||
{
|
||||
/* The file descriptor for the audio device */
|
||||
SDL_RWops *output;
|
||||
Uint8 *mixbuf;
|
||||
|
@ -39,3 +40,4 @@ struct SDL_PrivateAudioData {
|
|||
};
|
||||
|
||||
#endif /* _SDL_diskaudio_h */
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -68,7 +68,8 @@ static void DMA_CloseAudio(_THIS);
|
|||
|
||||
/* Audio driver bootstrap functions */
|
||||
|
||||
static int Audio_Available(void)
|
||||
static int
|
||||
Audio_Available(void)
|
||||
{
|
||||
int available;
|
||||
int fd;
|
||||
|
@ -90,13 +91,15 @@ static int Audio_Available(void)
|
|||
return (available);
|
||||
}
|
||||
|
||||
static void Audio_DeleteDevice(SDL_AudioDevice *device)
|
||||
static void
|
||||
Audio_DeleteDevice(SDL_AudioDevice * device)
|
||||
{
|
||||
SDL_free(device->hidden);
|
||||
SDL_free(device);
|
||||
}
|
||||
|
||||
static SDL_AudioDevice *Audio_CreateDevice(int devindex)
|
||||
static SDL_AudioDevice *
|
||||
Audio_CreateDevice(int devindex)
|
||||
{
|
||||
SDL_AudioDevice *this;
|
||||
|
||||
|
@ -135,12 +138,14 @@ AudioBootStrap DMA_bootstrap = {
|
|||
};
|
||||
|
||||
/* This function waits until it is possible to write a full sound buffer */
|
||||
static void DMA_WaitAudio(_THIS)
|
||||
static void
|
||||
DMA_WaitAudio(_THIS)
|
||||
{
|
||||
fd_set fdset;
|
||||
|
||||
/* Check to see if the thread-parent process is still alive */
|
||||
{ static int cnt = 0;
|
||||
{
|
||||
static int cnt = 0;
|
||||
/* Note that this only works with thread implementations
|
||||
that use a different process id for each thread.
|
||||
*/
|
||||
|
@ -202,7 +207,8 @@ static void DMA_WaitAudio(_THIS)
|
|||
}
|
||||
}
|
||||
|
||||
static void DMA_PlayAudio(_THIS)
|
||||
static void
|
||||
DMA_PlayAudio(_THIS)
|
||||
{
|
||||
/* If timer synchronization is enabled, set the next write frame */
|
||||
if (frame_ticks) {
|
||||
|
@ -211,7 +217,8 @@ static void DMA_PlayAudio(_THIS)
|
|||
return;
|
||||
}
|
||||
|
||||
static Uint8 *DMA_GetAudioBuf(_THIS)
|
||||
static Uint8 *
|
||||
DMA_GetAudioBuf(_THIS)
|
||||
{
|
||||
count_info info;
|
||||
int playing;
|
||||
|
@ -224,7 +231,8 @@ static Uint8 *DMA_GetAudioBuf(_THIS)
|
|||
this->enabled = 0;
|
||||
return (NULL);
|
||||
}
|
||||
} while ( frame_ticks && (info.blocks < 1) );
|
||||
}
|
||||
while (frame_ticks && (info.blocks < 1));
|
||||
#ifdef DEBUG_AUDIO
|
||||
if (info.blocks > 1) {
|
||||
printf("Warning: audio underflow (%d frags)\n", info.blocks - 1);
|
||||
|
@ -235,7 +243,8 @@ static Uint8 *DMA_GetAudioBuf(_THIS)
|
|||
return (dma_buf + (filling * this->spec.size));
|
||||
}
|
||||
|
||||
static void DMA_CloseAudio(_THIS)
|
||||
static void
|
||||
DMA_CloseAudio(_THIS)
|
||||
{
|
||||
if (dma_buf != NULL) {
|
||||
munmap(dma_buf, dma_len);
|
||||
|
@ -247,7 +256,8 @@ static void DMA_CloseAudio(_THIS)
|
|||
}
|
||||
}
|
||||
|
||||
static int DMA_ReopenAudio(_THIS, const char *audiodev, int format, int stereo,
|
||||
static int
|
||||
DMA_ReopenAudio(_THIS, const char *audiodev, int format, int stereo,
|
||||
SDL_AudioSpec * spec)
|
||||
{
|
||||
int frag_spec;
|
||||
|
@ -279,8 +289,7 @@ static int DMA_ReopenAudio(_THIS, const char *audiodev, int format, int stereo,
|
|||
|
||||
/* Set the audio format */
|
||||
value = format;
|
||||
if ( (ioctl(audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) ||
|
||||
(value != format) ) {
|
||||
if ((ioctl(audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) || (value != format)) {
|
||||
SDL_SetError("Couldn't set audio format");
|
||||
return (-1);
|
||||
}
|
||||
|
@ -305,7 +314,8 @@ static int DMA_ReopenAudio(_THIS, const char *audiodev, int format, int stereo,
|
|||
return (0);
|
||||
}
|
||||
|
||||
static int DMA_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
||||
static int
|
||||
DMA_OpenAudio(_THIS, SDL_AudioSpec * spec)
|
||||
{
|
||||
char audiodev[1024];
|
||||
int format;
|
||||
|
@ -386,8 +396,7 @@ static int DMA_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
|
||||
/* Set the audio format */
|
||||
value = format;
|
||||
if ( (ioctl(audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) ||
|
||||
(value != format) ) {
|
||||
if ((ioctl(audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) || (value != format)) {
|
||||
SDL_SetError("Couldn't set audio format");
|
||||
return (-1);
|
||||
}
|
||||
|
@ -430,7 +439,8 @@ static int DMA_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
SDL_memset(dma_buf, spec->silence, dma_len);
|
||||
|
||||
/* Check to see if we need to use select() workaround */
|
||||
{ char *workaround;
|
||||
{
|
||||
char *workaround;
|
||||
workaround = SDL_getenv("SDL_DSP_NOSELECT");
|
||||
if (workaround) {
|
||||
frame_ticks = (float) (spec->samples * 1000) / spec->freq;
|
||||
|
@ -453,3 +463,5 @@ static int DMA_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
/* We're ready to rock and roll. :-) */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
/* Hidden "this" pointer for the video functions */
|
||||
#define _THIS SDL_AudioDevice *this
|
||||
|
||||
struct SDL_PrivateAudioData {
|
||||
struct SDL_PrivateAudioData
|
||||
{
|
||||
/* The file descriptor for the audio device */
|
||||
int audio_fd;
|
||||
|
||||
|
@ -57,3 +58,4 @@ struct SDL_PrivateAudioData {
|
|||
#define next_frame (this->hidden->next_frame)
|
||||
|
||||
#endif /* _SDL_dspaudio_h */
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -53,18 +53,21 @@ static void AL_CloseAudio(_THIS);
|
|||
|
||||
/* Audio driver bootstrap functions */
|
||||
|
||||
static int Audio_Available(void)
|
||||
static int
|
||||
Audio_Available(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void Audio_DeleteDevice(SDL_AudioDevice *device)
|
||||
static void
|
||||
Audio_DeleteDevice(SDL_AudioDevice * device)
|
||||
{
|
||||
SDL_free(device->hidden);
|
||||
SDL_free(device);
|
||||
}
|
||||
|
||||
static SDL_AudioDevice *Audio_CreateDevice(int devindex)
|
||||
static SDL_AudioDevice *
|
||||
Audio_CreateDevice(int devindex)
|
||||
{
|
||||
SDL_AudioDevice *this;
|
||||
|
||||
|
@ -102,7 +105,8 @@ AudioBootStrap DMEDIA_bootstrap = {
|
|||
};
|
||||
|
||||
|
||||
void static AL_WaitAudio(_THIS)
|
||||
void static
|
||||
AL_WaitAudio(_THIS)
|
||||
{
|
||||
Sint32 timeleft;
|
||||
|
||||
|
@ -113,7 +117,8 @@ void static AL_WaitAudio(_THIS)
|
|||
}
|
||||
}
|
||||
|
||||
static void AL_PlayAudio(_THIS)
|
||||
static void
|
||||
AL_PlayAudio(_THIS)
|
||||
{
|
||||
/* Write the audio data out */
|
||||
if (alWriteFrames(audio_port, mixbuf, this->spec.samples) < 0) {
|
||||
|
@ -122,12 +127,14 @@ static void AL_PlayAudio(_THIS)
|
|||
}
|
||||
}
|
||||
|
||||
static Uint8 *AL_GetAudioBuf(_THIS)
|
||||
static Uint8 *
|
||||
AL_GetAudioBuf(_THIS)
|
||||
{
|
||||
return (mixbuf);
|
||||
}
|
||||
|
||||
static void AL_CloseAudio(_THIS)
|
||||
static void
|
||||
AL_CloseAudio(_THIS)
|
||||
{
|
||||
if (mixbuf != NULL) {
|
||||
SDL_FreeAudioMem(mixbuf);
|
||||
|
@ -139,7 +146,8 @@ static void AL_CloseAudio(_THIS)
|
|||
}
|
||||
}
|
||||
|
||||
static int AL_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
||||
static int
|
||||
AL_OpenAudio(_THIS, SDL_AudioSpec * spec)
|
||||
{
|
||||
ALconfig audio_config;
|
||||
#ifdef OLD_IRIX_AUDIO
|
||||
|
@ -152,19 +160,22 @@ static int AL_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
/* Determine the audio parameters from the AudioSpec */
|
||||
switch (spec->format & 0xFF) {
|
||||
|
||||
case 8: { /* Signed 8 bit audio data */
|
||||
case 8:
|
||||
{ /* Signed 8 bit audio data */
|
||||
spec->format = AUDIO_S8;
|
||||
width = AL_SAMPLE_8;
|
||||
}
|
||||
break;
|
||||
|
||||
case 16: { /* Signed 16 bit audio data */
|
||||
case 16:
|
||||
{ /* Signed 16 bit audio data */
|
||||
spec->format = AUDIO_S16MSB;
|
||||
width = AL_SAMPLE_16;
|
||||
}
|
||||
break;
|
||||
|
||||
default: {
|
||||
default:
|
||||
{
|
||||
SDL_SetError("Unsupported audio format");
|
||||
return (-1);
|
||||
}
|
||||
|
@ -214,3 +225,5 @@ static int AL_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
/* We're ready to rock and roll. :-) */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
/* Hidden "this" pointer for the audio functions */
|
||||
#define _THIS SDL_AudioDevice *this
|
||||
|
||||
struct SDL_PrivateAudioData {
|
||||
struct SDL_PrivateAudioData
|
||||
{
|
||||
/* The handle for the audio device */
|
||||
ALport audio_port;
|
||||
|
||||
|
@ -43,3 +44,4 @@ struct SDL_PrivateAudioData {
|
|||
#define mixbuf (this->hidden->mixbuf)
|
||||
|
||||
#endif /* _SDL_lowaudio_h */
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -66,7 +66,8 @@ static void DSP_CloseAudio(_THIS);
|
|||
|
||||
/* Audio driver bootstrap functions */
|
||||
|
||||
static int Audio_Available(void)
|
||||
static int
|
||||
Audio_Available(void)
|
||||
{
|
||||
int fd;
|
||||
int available;
|
||||
|
@ -80,13 +81,15 @@ static int Audio_Available(void)
|
|||
return (available);
|
||||
}
|
||||
|
||||
static void Audio_DeleteDevice(SDL_AudioDevice *device)
|
||||
static void
|
||||
Audio_DeleteDevice(SDL_AudioDevice * device)
|
||||
{
|
||||
SDL_free(device->hidden);
|
||||
SDL_free(device);
|
||||
}
|
||||
|
||||
static SDL_AudioDevice *Audio_CreateDevice(int devindex)
|
||||
static SDL_AudioDevice *
|
||||
Audio_CreateDevice(int devindex)
|
||||
{
|
||||
SDL_AudioDevice *this;
|
||||
|
||||
|
@ -125,30 +128,32 @@ AudioBootStrap DSP_bootstrap = {
|
|||
};
|
||||
|
||||
/* This function waits until it is possible to write a full sound buffer */
|
||||
static void DSP_WaitAudio(_THIS)
|
||||
static void
|
||||
DSP_WaitAudio(_THIS)
|
||||
{
|
||||
/* Not needed at all since OSS handles waiting automagically */
|
||||
}
|
||||
|
||||
static void DSP_PlayAudio(_THIS)
|
||||
{
|
||||
if (write(audio_fd, mixbuf, mixlen)==-1)
|
||||
static void
|
||||
DSP_PlayAudio(_THIS)
|
||||
{
|
||||
if (write(audio_fd, mixbuf, mixlen) == -1) {
|
||||
perror("Audio write");
|
||||
this->enabled = 0;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_AUDIO
|
||||
fprintf(stderr, "Wrote %d bytes of audio data\n", mixlen);
|
||||
#endif
|
||||
}
|
||||
|
||||
static Uint8 *DSP_GetAudioBuf(_THIS)
|
||||
static Uint8 *
|
||||
DSP_GetAudioBuf(_THIS)
|
||||
{
|
||||
return (mixbuf);
|
||||
}
|
||||
|
||||
static void DSP_CloseAudio(_THIS)
|
||||
static void
|
||||
DSP_CloseAudio(_THIS)
|
||||
{
|
||||
if (mixbuf != NULL) {
|
||||
SDL_FreeAudioMem(mixbuf);
|
||||
|
@ -160,7 +165,8 @@ static void DSP_CloseAudio(_THIS)
|
|||
}
|
||||
}
|
||||
|
||||
static int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
||||
static int
|
||||
DSP_OpenAudio(_THIS, SDL_AudioSpec * spec)
|
||||
{
|
||||
char audiodev[1024];
|
||||
int format;
|
||||
|
@ -177,7 +183,8 @@ static int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
mixbuf = NULL;
|
||||
|
||||
/* Make the file descriptor use blocking writes with fcntl() */
|
||||
{ long flags;
|
||||
{
|
||||
long flags;
|
||||
flags = fcntl(audio_fd, F_GETFL);
|
||||
flags &= ~O_NONBLOCK;
|
||||
if (fcntl(audio_fd, F_SETFL, flags) < 0) {
|
||||
|
@ -256,8 +263,7 @@ static int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
|
||||
/* Set the audio format */
|
||||
value = format;
|
||||
if ( (ioctl(audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) ||
|
||||
(value != format) ) {
|
||||
if ((ioctl(audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) || (value != format)) {
|
||||
perror("SNDCTL_DSP_SETFMT");
|
||||
SDL_SetError("Couldn't set audio format");
|
||||
DSP_CloseAudio(this);
|
||||
|
@ -305,7 +311,8 @@ static int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
perror("SNDCTL_DSP_SETFRAGMENT");
|
||||
}
|
||||
#ifdef DEBUG_AUDIO
|
||||
{ audio_buf_info info;
|
||||
{
|
||||
audio_buf_info info;
|
||||
ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &info);
|
||||
fprintf(stderr, "fragments = %d\n", info.fragments);
|
||||
fprintf(stderr, "fragstotal = %d\n", info.fragstotal);
|
||||
|
@ -329,3 +336,5 @@ static int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
/* We're ready to rock and roll. :-) */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
/* Hidden "this" pointer for the video functions */
|
||||
#define _THIS SDL_AudioDevice *this
|
||||
|
||||
struct SDL_PrivateAudioData {
|
||||
struct SDL_PrivateAudioData
|
||||
{
|
||||
/* The file descriptor for the audio device */
|
||||
int audio_fd;
|
||||
|
||||
|
@ -51,3 +52,4 @@ struct SDL_PrivateAudioData {
|
|||
#define next_frame (this->hidden->next_frame)
|
||||
|
||||
#endif /* _SDL_dspaudio_h */
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -44,7 +44,8 @@ static Uint8 *DUMMYAUD_GetAudioBuf(_THIS);
|
|||
static void DUMMYAUD_CloseAudio(_THIS);
|
||||
|
||||
/* Audio driver bootstrap functions */
|
||||
static int DUMMYAUD_Available(void)
|
||||
static int
|
||||
DUMMYAUD_Available(void)
|
||||
{
|
||||
const char *envr = SDL_getenv("SDL_AUDIODRIVER");
|
||||
if (envr && (SDL_strcmp(envr, DUMMYAUD_DRIVER_NAME) == 0)) {
|
||||
|
@ -53,13 +54,15 @@ static int DUMMYAUD_Available(void)
|
|||
return (0);
|
||||
}
|
||||
|
||||
static void DUMMYAUD_DeleteDevice(SDL_AudioDevice *device)
|
||||
static void
|
||||
DUMMYAUD_DeleteDevice(SDL_AudioDevice * device)
|
||||
{
|
||||
SDL_free(device->hidden);
|
||||
SDL_free(device);
|
||||
}
|
||||
|
||||
static SDL_AudioDevice *DUMMYAUD_CreateDevice(int devindex)
|
||||
static SDL_AudioDevice *
|
||||
DUMMYAUD_CreateDevice(int devindex)
|
||||
{
|
||||
SDL_AudioDevice *this;
|
||||
|
||||
|
@ -97,7 +100,8 @@ AudioBootStrap DUMMYAUD_bootstrap = {
|
|||
};
|
||||
|
||||
/* This function waits until it is possible to write a full sound buffer */
|
||||
static void DUMMYAUD_WaitAudio(_THIS)
|
||||
static void
|
||||
DUMMYAUD_WaitAudio(_THIS)
|
||||
{
|
||||
/* Don't block on first calls to simulate initial fragment filling. */
|
||||
if (this->hidden->initial_calls)
|
||||
|
@ -106,17 +110,20 @@ static void DUMMYAUD_WaitAudio(_THIS)
|
|||
SDL_Delay(this->hidden->write_delay);
|
||||
}
|
||||
|
||||
static void DUMMYAUD_PlayAudio(_THIS)
|
||||
static void
|
||||
DUMMYAUD_PlayAudio(_THIS)
|
||||
{
|
||||
/* no-op...this is a null driver. */
|
||||
}
|
||||
|
||||
static Uint8 *DUMMYAUD_GetAudioBuf(_THIS)
|
||||
static Uint8 *
|
||||
DUMMYAUD_GetAudioBuf(_THIS)
|
||||
{
|
||||
return (this->hidden->mixbuf);
|
||||
}
|
||||
|
||||
static void DUMMYAUD_CloseAudio(_THIS)
|
||||
static void
|
||||
DUMMYAUD_CloseAudio(_THIS)
|
||||
{
|
||||
if (this->hidden->mixbuf != NULL) {
|
||||
SDL_FreeAudioMem(this->hidden->mixbuf);
|
||||
|
@ -124,7 +131,8 @@ static void DUMMYAUD_CloseAudio(_THIS)
|
|||
}
|
||||
}
|
||||
|
||||
static int DUMMYAUD_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
||||
static int
|
||||
DUMMYAUD_OpenAudio(_THIS, SDL_AudioSpec * spec)
|
||||
{
|
||||
float bytes_per_sec = 0.0f;
|
||||
|
||||
|
@ -154,3 +162,4 @@ static int DUMMYAUD_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
return (0);
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
/* Hidden "this" pointer for the video functions */
|
||||
#define _THIS SDL_AudioDevice *this
|
||||
|
||||
struct SDL_PrivateAudioData {
|
||||
struct SDL_PrivateAudioData
|
||||
{
|
||||
/* The file descriptor for the audio device */
|
||||
Uint8 *mixbuf;
|
||||
Uint32 mixlen;
|
||||
|
@ -38,3 +39,4 @@ struct SDL_PrivateAudioData {
|
|||
};
|
||||
|
||||
#endif /* _SDL_dummyaudio_h */
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -63,16 +63,18 @@ static int (*SDL_NAME(esd_open_sound))( const char *host );
|
|||
static int (*SDL_NAME(esd_close)) (int esd);
|
||||
static int (*SDL_NAME(esd_play_stream)) (esd_format_t format, int rate,
|
||||
const char *host, const char *name);
|
||||
static struct {
|
||||
static struct
|
||||
{
|
||||
const char *name;
|
||||
void **func;
|
||||
} esd_functions[] = {
|
||||
{ "esd_open_sound", (void **)&SDL_NAME(esd_open_sound) },
|
||||
{ "esd_close", (void **)&SDL_NAME(esd_close) },
|
||||
{ "esd_play_stream", (void **)&SDL_NAME(esd_play_stream) },
|
||||
};
|
||||
{
|
||||
"esd_open_sound", (void **) &SDL_NAME(esd_open_sound)}, {
|
||||
"esd_close", (void **) &SDL_NAME(esd_close)}, {
|
||||
"esd_play_stream", (void **) &SDL_NAME(esd_play_stream)},};
|
||||
|
||||
static void UnloadESDLibrary()
|
||||
static void
|
||||
UnloadESDLibrary()
|
||||
{
|
||||
if (esd_loaded) {
|
||||
SDL_UnloadObject(esd_handle);
|
||||
|
@ -81,7 +83,8 @@ static void UnloadESDLibrary()
|
|||
}
|
||||
}
|
||||
|
||||
static int LoadESDLibrary(void)
|
||||
static int
|
||||
LoadESDLibrary(void)
|
||||
{
|
||||
int i, retval = -1;
|
||||
|
||||
|
@ -90,7 +93,8 @@ static int LoadESDLibrary(void)
|
|||
esd_loaded = 1;
|
||||
retval = 0;
|
||||
for (i = 0; i < SDL_arraysize(esd_functions); ++i) {
|
||||
*esd_functions[i].func = SDL_LoadFunction(esd_handle, esd_functions[i].name);
|
||||
*esd_functions[i].func =
|
||||
SDL_LoadFunction(esd_handle, esd_functions[i].name);
|
||||
if (!*esd_functions[i].func) {
|
||||
retval = -1;
|
||||
UnloadESDLibrary();
|
||||
|
@ -103,12 +107,14 @@ static int LoadESDLibrary(void)
|
|||
|
||||
#else
|
||||
|
||||
static void UnloadESDLibrary()
|
||||
static void
|
||||
UnloadESDLibrary()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static int LoadESDLibrary(void)
|
||||
static int
|
||||
LoadESDLibrary(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -117,7 +123,8 @@ static int LoadESDLibrary(void)
|
|||
|
||||
/* Audio driver bootstrap functions */
|
||||
|
||||
static int Audio_Available(void)
|
||||
static int
|
||||
Audio_Available(void)
|
||||
{
|
||||
int connection;
|
||||
int available;
|
||||
|
@ -135,14 +142,16 @@ static int Audio_Available(void)
|
|||
return (available);
|
||||
}
|
||||
|
||||
static void Audio_DeleteDevice(SDL_AudioDevice *device)
|
||||
static void
|
||||
Audio_DeleteDevice(SDL_AudioDevice * device)
|
||||
{
|
||||
SDL_free(device->hidden);
|
||||
SDL_free(device);
|
||||
UnloadESDLibrary();
|
||||
}
|
||||
|
||||
static SDL_AudioDevice *Audio_CreateDevice(int devindex)
|
||||
static SDL_AudioDevice *
|
||||
Audio_CreateDevice(int devindex)
|
||||
{
|
||||
SDL_AudioDevice *this;
|
||||
|
||||
|
@ -182,12 +191,14 @@ AudioBootStrap ESD_bootstrap = {
|
|||
};
|
||||
|
||||
/* This function waits until it is possible to write a full sound buffer */
|
||||
static void ESD_WaitAudio(_THIS)
|
||||
static void
|
||||
ESD_WaitAudio(_THIS)
|
||||
{
|
||||
Sint32 ticks;
|
||||
|
||||
/* Check to see if the thread-parent process is still alive */
|
||||
{ static int cnt = 0;
|
||||
{
|
||||
static int cnt = 0;
|
||||
/* Note that this only works with thread implementations
|
||||
that use a different process id for each thread.
|
||||
*/
|
||||
|
@ -205,7 +216,8 @@ static void ESD_WaitAudio(_THIS)
|
|||
}
|
||||
}
|
||||
|
||||
static void ESD_PlayAudio(_THIS)
|
||||
static void
|
||||
ESD_PlayAudio(_THIS)
|
||||
{
|
||||
int written;
|
||||
|
||||
|
@ -215,7 +227,8 @@ static void ESD_PlayAudio(_THIS)
|
|||
if ((written < 0) && ((errno == 0) || (errno == EAGAIN))) {
|
||||
SDL_Delay(1); /* Let a little CPU time go by */
|
||||
}
|
||||
} while ( (written < 0) &&
|
||||
}
|
||||
while ((written < 0) &&
|
||||
((errno == 0) || (errno == EAGAIN) || (errno == EINTR)));
|
||||
|
||||
/* Set the next write frame */
|
||||
|
@ -227,12 +240,14 @@ static void ESD_PlayAudio(_THIS)
|
|||
}
|
||||
}
|
||||
|
||||
static Uint8 *ESD_GetAudioBuf(_THIS)
|
||||
static Uint8 *
|
||||
ESD_GetAudioBuf(_THIS)
|
||||
{
|
||||
return (mixbuf);
|
||||
}
|
||||
|
||||
static void ESD_CloseAudio(_THIS)
|
||||
static void
|
||||
ESD_CloseAudio(_THIS)
|
||||
{
|
||||
if (mixbuf != NULL) {
|
||||
SDL_FreeAudioMem(mixbuf);
|
||||
|
@ -245,7 +260,8 @@ static void ESD_CloseAudio(_THIS)
|
|||
}
|
||||
|
||||
/* Try to get the name of the program */
|
||||
static char *get_progname(void)
|
||||
static char *
|
||||
get_progname(void)
|
||||
{
|
||||
char *progname = NULL;
|
||||
#ifdef __LINUX__
|
||||
|
@ -269,7 +285,8 @@ static char *get_progname(void)
|
|||
return (progname);
|
||||
}
|
||||
|
||||
static int ESD_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
||||
static int
|
||||
ESD_OpenAudio(_THIS, SDL_AudioSpec * spec)
|
||||
{
|
||||
esd_format_t format;
|
||||
|
||||
|
@ -296,7 +313,8 @@ static int ESD_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
#endif
|
||||
|
||||
/* Open a connection to the ESD audio server */
|
||||
audio_fd = SDL_NAME(esd_play_stream)(format, spec->freq, NULL, get_progname());
|
||||
audio_fd =
|
||||
SDL_NAME(esd_play_stream) (format, spec->freq, NULL, get_progname());
|
||||
if (audio_fd < 0) {
|
||||
SDL_SetError("Couldn't open ESD connection");
|
||||
return (-1);
|
||||
|
@ -321,3 +339,5 @@ static int ESD_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
/* We're ready to rock and roll. :-) */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
/* Hidden "this" pointer for the video functions */
|
||||
#define _THIS SDL_AudioDevice *this
|
||||
|
||||
struct SDL_PrivateAudioData {
|
||||
struct SDL_PrivateAudioData
|
||||
{
|
||||
/* The file descriptor for the audio device */
|
||||
int audio_fd;
|
||||
|
||||
|
@ -55,3 +56,4 @@ struct SDL_PrivateAudioData {
|
|||
#define next_frame (this->hidden->next_frame)
|
||||
|
||||
#endif /* _SDL_esdaudio_h */
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -39,18 +39,21 @@ static void Core_CloseAudio(_THIS);
|
|||
|
||||
/* Audio driver bootstrap functions */
|
||||
|
||||
static int Audio_Available(void)
|
||||
static int
|
||||
Audio_Available(void)
|
||||
{
|
||||
return (1);
|
||||
}
|
||||
|
||||
static void Audio_DeleteDevice(SDL_AudioDevice *device)
|
||||
static void
|
||||
Audio_DeleteDevice(SDL_AudioDevice * device)
|
||||
{
|
||||
SDL_free(device->hidden);
|
||||
SDL_free(device);
|
||||
}
|
||||
|
||||
static SDL_AudioDevice *Audio_CreateDevice(int devindex)
|
||||
static SDL_AudioDevice *
|
||||
Audio_CreateDevice(int devindex)
|
||||
{
|
||||
SDL_AudioDevice *this;
|
||||
|
||||
|
@ -88,11 +91,11 @@ AudioBootStrap COREAUDIO_bootstrap = {
|
|||
};
|
||||
|
||||
/* The CoreAudio callback */
|
||||
static OSStatus audioCallback (void *inRefCon,
|
||||
static OSStatus
|
||||
audioCallback(void *inRefCon,
|
||||
AudioUnitRenderActionFlags inActionFlags,
|
||||
const AudioTimeStamp * inTimeStamp,
|
||||
UInt32 inBusNumber,
|
||||
AudioBuffer *ioData)
|
||||
UInt32 inBusNumber, AudioBuffer * ioData)
|
||||
{
|
||||
SDL_AudioDevice *this = (SDL_AudioDevice *) inRefCon;
|
||||
UInt32 remaining, len;
|
||||
|
@ -119,8 +122,7 @@ static OSStatus audioCallback (void *inRefCon,
|
|||
/* Generate the data */
|
||||
SDL_memset(buffer, this->spec.silence, bufferSize);
|
||||
SDL_mutexP(this->mixer_lock);
|
||||
(*this->spec.callback)(this->spec.userdata,
|
||||
buffer, bufferSize);
|
||||
(*this->spec.callback) (this->spec.userdata, buffer, bufferSize);
|
||||
SDL_mutexV(this->mixer_lock);
|
||||
bufferOffset = 0;
|
||||
}
|
||||
|
@ -138,22 +140,26 @@ static OSStatus audioCallback (void *inRefCon,
|
|||
}
|
||||
|
||||
/* Dummy functions -- we don't use thread-based audio */
|
||||
void Core_WaitAudio(_THIS)
|
||||
void
|
||||
Core_WaitAudio(_THIS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void Core_PlayAudio(_THIS)
|
||||
void
|
||||
Core_PlayAudio(_THIS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Uint8 *Core_GetAudioBuf(_THIS)
|
||||
Uint8 *
|
||||
Core_GetAudioBuf(_THIS)
|
||||
{
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
void Core_CloseAudio(_THIS)
|
||||
void
|
||||
Core_CloseAudio(_THIS)
|
||||
{
|
||||
OSStatus result;
|
||||
struct AudioUnitInputCallback callback;
|
||||
|
@ -171,11 +177,10 @@ void Core_CloseAudio(_THIS)
|
|||
result = AudioUnitSetProperty(outputAudioUnit,
|
||||
kAudioUnitProperty_SetInputCallback,
|
||||
kAudioUnitScope_Input,
|
||||
0,
|
||||
&callback,
|
||||
sizeof(callback));
|
||||
0, &callback, sizeof(callback));
|
||||
if (result != noErr) {
|
||||
SDL_SetError("Core_CloseAudio: AudioUnitSetProperty (kAudioUnitProperty_SetInputCallback)");
|
||||
SDL_SetError
|
||||
("Core_CloseAudio: AudioUnitSetProperty (kAudioUnitProperty_SetInputCallback)");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -195,7 +200,8 @@ void Core_CloseAudio(_THIS)
|
|||
}
|
||||
|
||||
|
||||
int Core_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
||||
int
|
||||
Core_OpenAudio(_THIS, SDL_AudioSpec * spec)
|
||||
{
|
||||
OSStatus result = noErr;
|
||||
Component comp;
|
||||
|
@ -216,8 +222,10 @@ int Core_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
requestedDesc.mFormatFlags |= kLinearPCMFormatFlagIsBigEndian;
|
||||
|
||||
requestedDesc.mFramesPerPacket = 1;
|
||||
requestedDesc.mBytesPerFrame = requestedDesc.mBitsPerChannel * requestedDesc.mChannelsPerFrame / 8;
|
||||
requestedDesc.mBytesPerPacket = requestedDesc.mBytesPerFrame * requestedDesc.mFramesPerPacket;
|
||||
requestedDesc.mBytesPerFrame =
|
||||
requestedDesc.mBitsPerChannel * requestedDesc.mChannelsPerFrame / 8;
|
||||
requestedDesc.mBytesPerPacket =
|
||||
requestedDesc.mBytesPerFrame * requestedDesc.mFramesPerPacket;
|
||||
|
||||
|
||||
/* Locate the default output audio unit */
|
||||
|
@ -229,37 +237,31 @@ int Core_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
|
||||
comp = FindNextComponent(NULL, &desc);
|
||||
if (comp == NULL) {
|
||||
SDL_SetError ("Failed to start CoreAudio: FindNextComponent returned NULL");
|
||||
SDL_SetError
|
||||
("Failed to start CoreAudio: FindNextComponent returned NULL");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Open & initialize the default output audio unit */
|
||||
result = OpenAComponent(comp, &outputAudioUnit);
|
||||
CHECK_RESULT("OpenAComponent")
|
||||
|
||||
result = AudioUnitInitialize(outputAudioUnit);
|
||||
CHECK_RESULT("AudioUnitInitialize")
|
||||
|
||||
/* Set the input format of the audio unit. */
|
||||
result = AudioUnitSetProperty(outputAudioUnit,
|
||||
kAudioUnitProperty_StreamFormat,
|
||||
kAudioUnitScope_Input,
|
||||
0,
|
||||
&requestedDesc,
|
||||
sizeof (requestedDesc));
|
||||
&requestedDesc, sizeof(requestedDesc));
|
||||
CHECK_RESULT("AudioUnitSetProperty (kAudioUnitProperty_StreamFormat)")
|
||||
|
||||
/* Set the audio callback */
|
||||
callback.inputProc = audioCallback;
|
||||
callback.inputProcRefCon = this;
|
||||
result = AudioUnitSetProperty(outputAudioUnit,
|
||||
kAudioUnitProperty_SetInputCallback,
|
||||
kAudioUnitScope_Input,
|
||||
0,
|
||||
&callback,
|
||||
sizeof(callback));
|
||||
0, &callback, sizeof(callback));
|
||||
CHECK_RESULT("AudioUnitSetProperty (kAudioUnitProperty_SetInputCallback)")
|
||||
|
||||
/* Calculate the final parameters for this audio specification */
|
||||
SDL_CalculateAudioSpec(spec);
|
||||
|
||||
|
@ -270,8 +272,8 @@ int Core_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
/* Finally, start processing of the audio unit */
|
||||
result = AudioOutputUnitStart(outputAudioUnit);
|
||||
CHECK_RESULT("AudioOutputUnitStart")
|
||||
|
||||
|
||||
/* We're running! */
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
/* Hidden "this" pointer for the video functions */
|
||||
#define _THIS SDL_AudioDevice *this
|
||||
|
||||
struct SDL_PrivateAudioData {
|
||||
struct SDL_PrivateAudioData
|
||||
{
|
||||
AudioUnit outputAudioUnit;
|
||||
void *buffer;
|
||||
UInt32 bufferOffset;
|
||||
|
@ -43,3 +44,4 @@ struct SDL_PrivateAudioData {
|
|||
#define bufferSize (this->hidden->bufferSize)
|
||||
|
||||
#endif /* _SDL_coreaudio_h */
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -55,18 +55,21 @@ static void Mac_UnlockAudio(_THIS);
|
|||
/* Audio driver bootstrap functions */
|
||||
|
||||
|
||||
static int Audio_Available(void)
|
||||
static int
|
||||
Audio_Available(void)
|
||||
{
|
||||
return (1);
|
||||
}
|
||||
|
||||
static void Audio_DeleteDevice(SDL_AudioDevice *device)
|
||||
static void
|
||||
Audio_DeleteDevice(SDL_AudioDevice * device)
|
||||
{
|
||||
SDL_free(device->hidden);
|
||||
SDL_free(device);
|
||||
}
|
||||
|
||||
static SDL_AudioDevice *Audio_CreateDevice(int devindex)
|
||||
static SDL_AudioDevice *
|
||||
Audio_CreateDevice(int devindex)
|
||||
{
|
||||
SDL_AudioDevice *this;
|
||||
|
||||
|
@ -118,7 +121,8 @@ static volatile UInt32 running = 0;
|
|||
static CmpSoundHeader header;
|
||||
static volatile Uint32 fill_me = 0;
|
||||
|
||||
static void mix_buffer(SDL_AudioDevice *audio, UInt8 *buffer)
|
||||
static void
|
||||
mix_buffer(SDL_AudioDevice * audio, UInt8 * buffer)
|
||||
{
|
||||
if (!audio->paused) {
|
||||
#ifdef __MACOSX__
|
||||
|
@ -126,14 +130,16 @@ static void mix_buffer(SDL_AudioDevice *audio, UInt8 *buffer)
|
|||
#endif
|
||||
if (audio->convert.needed) {
|
||||
audio->spec.callback(audio->spec.userdata,
|
||||
(Uint8 *)audio->convert.buf,audio->convert.len);
|
||||
(Uint8 *) audio->convert.buf,
|
||||
audio->convert.len);
|
||||
SDL_ConvertAudio(&audio->convert);
|
||||
if (audio->convert.len_cvt != audio->spec.size) {
|
||||
/* Uh oh... probably crashes here */ ;
|
||||
}
|
||||
SDL_memcpy(buffer, audio->convert.buf, audio->convert.len_cvt);
|
||||
} else {
|
||||
audio->spec.callback(audio->spec.userdata, buffer, audio->spec.size);
|
||||
audio->spec.callback(audio->spec.userdata, buffer,
|
||||
audio->spec.size);
|
||||
}
|
||||
#ifdef __MACOSX__
|
||||
SDL_mutexV(audio->mixer_lock);
|
||||
|
@ -143,12 +149,14 @@ static void mix_buffer(SDL_AudioDevice *audio, UInt8 *buffer)
|
|||
DecrementAtomic((SInt32 *) & need_to_mix);
|
||||
}
|
||||
|
||||
static void Mac_LockAudio(_THIS)
|
||||
static void
|
||||
Mac_LockAudio(_THIS)
|
||||
{
|
||||
IncrementAtomic((SInt32 *) & audio_is_locked);
|
||||
}
|
||||
|
||||
static void Mac_UnlockAudio(_THIS)
|
||||
static void
|
||||
Mac_UnlockAudio(_THIS)
|
||||
{
|
||||
SInt32 oldval;
|
||||
|
||||
|
@ -167,7 +175,9 @@ static void Mac_UnlockAudio(_THIS)
|
|||
}
|
||||
}
|
||||
|
||||
static void callBackProc (SndChannel *chan, SndCommand *cmd_passed ) {
|
||||
static void
|
||||
callBackProc(SndChannel * chan, SndCommand * cmd_passed)
|
||||
{
|
||||
UInt32 play_me;
|
||||
SndCommand cmd;
|
||||
SDL_AudioDevice *audio = (SDL_AudioDevice *) chan->userInfo;
|
||||
|
@ -208,7 +218,9 @@ static void callBackProc (SndChannel *chan, SndCommand *cmd_passed ) {
|
|||
}
|
||||
}
|
||||
|
||||
static int Mac_OpenAudio(_THIS, SDL_AudioSpec *spec) {
|
||||
static int
|
||||
Mac_OpenAudio(_THIS, SDL_AudioSpec * spec)
|
||||
{
|
||||
|
||||
SndCallBackUPP callback;
|
||||
int sample_bits;
|
||||
|
@ -294,7 +306,9 @@ static int Mac_OpenAudio(_THIS, SDL_AudioSpec *spec) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
static void Mac_CloseAudio(_THIS) {
|
||||
static void
|
||||
Mac_CloseAudio(_THIS)
|
||||
{
|
||||
|
||||
int i;
|
||||
|
||||
|
@ -315,12 +329,14 @@ static void Mac_CloseAudio(_THIS) {
|
|||
|
||||
#else /* !TARGET_API_MAC_CARBON && !USE_RYANS_SOUNDCODE */
|
||||
|
||||
static void Mac_LockAudio(_THIS)
|
||||
static void
|
||||
Mac_LockAudio(_THIS)
|
||||
{
|
||||
/* no-op. */
|
||||
}
|
||||
|
||||
static void Mac_UnlockAudio(_THIS)
|
||||
static void
|
||||
Mac_UnlockAudio(_THIS)
|
||||
{
|
||||
/* no-op. */
|
||||
}
|
||||
|
@ -330,8 +346,8 @@ static void Mac_UnlockAudio(_THIS)
|
|||
the buffers, so we'll zero it to silence and fill it with audio if
|
||||
we're not paused.
|
||||
*/
|
||||
static pascal
|
||||
void sndDoubleBackProc (SndChannelPtr chan, SndDoubleBufferPtr newbuf)
|
||||
static pascal void
|
||||
sndDoubleBackProc(SndChannelPtr chan, SndDoubleBufferPtr newbuf)
|
||||
{
|
||||
SDL_AudioDevice *audio = (SDL_AudioDevice *) newbuf->dbUserInfo[0];
|
||||
|
||||
|
@ -344,7 +360,8 @@ void sndDoubleBackProc (SndChannelPtr chan, SndDoubleBufferPtr newbuf)
|
|||
if (!audio->paused) {
|
||||
if (audio->convert.needed) {
|
||||
audio->spec.callback(audio->spec.userdata,
|
||||
(Uint8 *)audio->convert.buf,audio->convert.len);
|
||||
(Uint8 *) audio->convert.buf,
|
||||
audio->convert.len);
|
||||
SDL_ConvertAudio(&audio->convert);
|
||||
#if 0
|
||||
if (audio->convert.len_cvt != audio->spec.size) {
|
||||
|
@ -355,13 +372,15 @@ void sndDoubleBackProc (SndChannelPtr chan, SndDoubleBufferPtr newbuf)
|
|||
audio->convert.len_cvt);
|
||||
} else {
|
||||
audio->spec.callback(audio->spec.userdata,
|
||||
(Uint8 *)newbuf->dbSoundData, audio->spec.size);
|
||||
(Uint8 *) newbuf->dbSoundData,
|
||||
audio->spec.size);
|
||||
}
|
||||
}
|
||||
newbuf->dbFlags |= dbBufferReady;
|
||||
}
|
||||
|
||||
static int DoubleBufferAudio_Available(void)
|
||||
static int
|
||||
DoubleBufferAudio_Available(void)
|
||||
{
|
||||
int available;
|
||||
NumVersion sndversion;
|
||||
|
@ -385,7 +404,8 @@ static int DoubleBufferAudio_Available(void)
|
|||
return (available);
|
||||
}
|
||||
|
||||
static void Mac_CloseAudio(_THIS)
|
||||
static void
|
||||
Mac_CloseAudio(_THIS)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -402,7 +422,8 @@ static void Mac_CloseAudio(_THIS)
|
|||
}
|
||||
}
|
||||
|
||||
static int Mac_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
||||
static int
|
||||
Mac_OpenAudio(_THIS, SDL_AudioSpec * spec)
|
||||
{
|
||||
SndDoubleBufferHeader2 audio_dbh;
|
||||
int i;
|
||||
|
@ -493,4 +514,4 @@ static int Mac_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
|||
}
|
||||
|
||||
#endif /* TARGET_API_MAC_CARBON || USE_RYANS_SOUNDCODE */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue