Mercurial > sdl-ios-xcode
annotate src/audio/disk/SDL_diskaudio.c @ 5067:61d53410eb41
Fixed bug #859
CREATE_SUBDIRS helps a lot if browsing HTML documentation in a file browser.
ALWAYS_DETAILED_SEC makes sure everything has at least the automatic
documentation like function prototype and source references.
STRIP_FROM_PATH allows you to include only the relevant portions of the files'
paths, cleaning up both the file list and directory tree, though you need to
change the path listed here to match wherever you put SDL.
ALIASES avoids some warnings generated by
C:\source\svn.libsdl.org\trunk\SDL\src\joystick\darwin\10.3.9-FIX\IOHIDLib.h.
It seems Apple uses a few commands which are not normally supported by Doxygen.
BUILTIN_STL_SUPPORT adds support for parsing code which makes use of the
standard template library. There isn't a lot of C++ in SDL (some in bwindow at
least), but this still seems like a good idea.
TYPEDEF_HIDES_STRUCT means that for code like this:
typedef struct A {int B;} C;
C is documented as a structure containing B instead of a typedef mapped to A.
EXTRACT_ALL, EXTRACT_PRIVATE, EXTRACT_STATIC, EXTRACT_LOCAL_METHODS,
EXTRACT_ANON_NSPACES and INTERNAL_DOCS make sure that _everything_ is
documented.
CASE_SENSE_NAMES = NO avoids potential conflicts when building documentation on
case insensitive file systems like NTFS and FAT32.
WARN_NO_PARAMDOC lets you know when you have documented some, but not all, of
the parameters of a function. This is useful when you're working on adding
such documentation since it makes partially documented functions easier to
spot.
WARN_LOGFILE writes warnings to a seperate file instead of mixing them in with
stdout. When not running in quiet mode, these warnings can be hard to spot
without this flag.
I added *.h.in and *.h.default to FILE_PATTERNS to generate documentation for
config.h.in and config.h.default.
RECURSIVE tells doxygen to look not only in the input directory, but also in
subfolders.
EXCLUDE avoids documenting things like test programs, examples and templates
which need to be documented separately.
I've used EXCLUDE_PATTERNS to exclude non-source subdirectories that often find
their way into source folders (such as obj or .svn).
EXAMPLE_PATH lists directories doxygen will search to find included example
code. So far, SDL doesn't really use this feature, but I've listed some likely
locations.
SOURCE_BROWSER adds syntax highlighted source code to the HTML output.
USE_HTAGS is nice, but not available on Windows.
INLINE_SOURCES adds the body of a function to it's documentation so you can
quickly see exactly what it does.
ALPHABETICAL_INDEX generates an alphabetical list of all structures, functions,
etc., which makes it much easier to find what you're looking for.
IGNORE_PREFIX skips the SDL_ prefix when deciding which index page to place an
item on so you don't have everything show up under "S".
HTML_DYNAMIC_SECTIONS hides the includes/included by diagrams by default and
adds JavaScript to allow the user to show and hide them by clicking a link.
ENUM_VALUES_PER_LINE = 1 makes enums easier to read by placing each value on
it's own line.
GENERATE_TREEVIEW produces a two frame index page with a navigation tree on the
left.
I have LaTeX and man pages turned off to speed up doxygen, you may want to turn
them back on yourself.
I added _WIN32=1 to PREDEFINED to cause SDL to output documentation related to
Win32 builds of SDL. Normally, doxygen gets confused since there are multiple
definitions for various structures and formats that vary by platform. Without
this doxygen can produce broken documentation or, if you're lucky, output
documentation only for the dummy drivers, which isn't very useful. You need to
pick a platform.
GENERATE_TAGFILE produces a file which can be used to link other doxygen
documentation to the SDL documentation.
CLASS_DIAGRAMS turns on class diagrams even when dot is not available.
HAVE_DOT tells doxygen to try to use dot to generate diagrams.
TEMPLATE_RELATIONS and INCLUDE_GRAPH add additional diagrams to the
documentation.
DOT_MULTI_TARGETS speeds up dot.
OUTPUT_DIRECTORY, INPUT and other paths reflect the fact that this Doxyfile is
intended to process src as well as include and is being run from a separate
subdirectory. Doxygen produces several temporary files while it's running and
if interrupted, can leave those files behind. It's easier to clean up if there
aren't a hundred or so files in the same folder. I typically run doxygen in
SDL/doxy and set the output directory to '.'. Since doxygen puts it's output
in subfolders by type, this keeps things pretty well organised. You could use
'../doc' instead and get the same results.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 21 Jan 2011 12:57:01 -0800 |
parents | 4160ba33b597 |
children | b530ef003506 |
rev | line source |
---|---|
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1 /* |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
3697 | 3 Copyright (C) 1997-2010 Sam Lantinga |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
4 |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
9 |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
13 Lesser General Public License for more details. |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
18 |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
19 Sam Lantinga |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
86
diff
changeset
|
20 slouken@libsdl.org |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
21 |
1594
c439dad53df8
Updated my email address.
Ryan C. Gordon <icculus@icculus.org>
parents:
1539
diff
changeset
|
22 This file written by Ryan C. Gordon (icculus@icculus.org) |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
23 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
24 #include "SDL_config.h" |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
25 |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
26 /* Output raw audio data to a file. */ |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
27 |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
28 #if HAVE_STDIO_H |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
29 #include <stdio.h> |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
30 #endif |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
31 |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
32 #include "SDL_rwops.h" |
1358
c71e05b4dc2e
More header massaging... works great on Windows. ;-)
Sam Lantinga <slouken@libsdl.org>
parents:
1341
diff
changeset
|
33 #include "SDL_timer.h" |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
34 #include "SDL_audio.h" |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
35 #include "../SDL_audiomem.h" |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
36 #include "../SDL_audio_c.h" |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
37 #include "SDL_diskaudio.h" |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
38 |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
39 /* The tag name used by DISK audio */ |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
40 #define DISKAUD_DRIVER_NAME "disk" |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
41 |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
42 /* environment variables and defaults. */ |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
43 #define DISKENVR_OUTFILE "SDL_DISKAUDIOFILE" |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
44 #define DISKDEFAULT_OUTFILE "sdlaudio.raw" |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
45 #define DISKENVR_WRITEDELAY "SDL_DISKAUDIODELAY" |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
46 #define DISKDEFAULT_WRITEDELAY 150 |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
47 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
48 static const char * |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
49 DISKAUD_GetOutputFilename(const char *devname) |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
50 { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
51 if (devname == NULL) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
52 devname = SDL_getenv(DISKENVR_OUTFILE); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
53 if (devname == NULL) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
54 devname = DISKDEFAULT_OUTFILE; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
55 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
56 } |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
57 return devname; |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
58 } |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
59 |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
60 /* This function waits until it is possible to write a full sound buffer */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
61 static void |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
62 DISKAUD_WaitDevice(_THIS) |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
63 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
64 SDL_Delay(this->hidden->write_delay); |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
65 } |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
66 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
67 static void |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
68 DISKAUD_PlayDevice(_THIS) |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
69 { |
3253
5d7ef5970073
Fixed issues building 64-bit Windows binary
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
70 size_t written; |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
71 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
72 /* Write the audio data */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
73 written = SDL_RWwrite(this->hidden->output, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
74 this->hidden->mixbuf, 1, this->hidden->mixlen); |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
75 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
76 /* If we couldn't write, assume fatal error for now */ |
3253
5d7ef5970073
Fixed issues building 64-bit Windows binary
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
77 if (written != this->hidden->mixlen) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
78 this->enabled = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
79 } |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
80 #ifdef DEBUG_AUDIO |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
81 fprintf(stderr, "Wrote %d bytes of audio data\n", written); |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
82 #endif |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
83 } |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
84 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
85 static Uint8 * |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
86 DISKAUD_GetDeviceBuf(_THIS) |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
87 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
88 return (this->hidden->mixbuf); |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
89 } |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
90 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
91 static void |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
92 DISKAUD_CloseDevice(_THIS) |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
93 { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
94 if (this->hidden != NULL) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
95 if (this->hidden->mixbuf != NULL) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
96 SDL_FreeAudioMem(this->hidden->mixbuf); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
97 this->hidden->mixbuf = NULL; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
98 } |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
99 if (this->hidden->output != NULL) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
100 SDL_RWclose(this->hidden->output); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
101 this->hidden->output = NULL; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
102 } |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
103 SDL_free(this->hidden); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
104 this->hidden = NULL; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
105 } |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
106 } |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
107 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
108 static int |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
109 DISKAUD_OpenDevice(_THIS, const char *devname, int iscapture) |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
110 { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
111 const char *envr = SDL_getenv(DISKENVR_WRITEDELAY); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
112 const char *fname = DISKAUD_GetOutputFilename(devname); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
113 |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
114 this->hidden = (struct SDL_PrivateAudioData *) |
2060 | 115 SDL_malloc(sizeof(*this->hidden)); |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
116 if (this->hidden == NULL) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
117 SDL_OutOfMemory(); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
118 return 0; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
119 } |
2060 | 120 SDL_memset(this->hidden, 0, sizeof(*this->hidden)); |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
121 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
122 /* Open the audio device */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
123 this->hidden->output = SDL_RWFromFile(fname, "wb"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
124 if (this->hidden->output == NULL) { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
125 DISKAUD_CloseDevice(this); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
126 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
127 } |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
128 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
129 /* Allocate mixing buffer */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
130 this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
131 if (this->hidden->mixbuf == NULL) { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
132 DISKAUD_CloseDevice(this); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
133 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
134 } |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
135 SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
136 |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
137 this->hidden->mixlen = this->spec.size; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
138 this->hidden->write_delay = |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
139 (envr) ? SDL_atoi(envr) : DISKDEFAULT_WRITEDELAY; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
140 |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
141 #if HAVE_STDIO_H |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
142 fprintf(stderr, |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
143 "WARNING: You are using the SDL disk writer audio driver!\n" |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
144 " Writing to file [%s].\n", fname); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
145 #endif |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
146 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
147 /* We're ready to rock and roll. :-) */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
148 return 1; |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
149 } |
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
150 |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
151 static int |
2060 | 152 DISKAUD_Init(SDL_AudioDriverImpl * impl) |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
153 { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
154 /* Set the function pointers */ |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
155 impl->OpenDevice = DISKAUD_OpenDevice; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
156 impl->WaitDevice = DISKAUD_WaitDevice; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
157 impl->PlayDevice = DISKAUD_PlayDevice; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
158 impl->GetDeviceBuf = DISKAUD_GetDeviceBuf; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
159 impl->CloseDevice = DISKAUD_CloseDevice; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
160 |
3699
4160ba33b597
Removed test for "driver is valid, but doesn't see any audio devices."
Ryan C. Gordon <icculus@icculus.org>
parents:
3697
diff
changeset
|
161 return 1; /* this audio target is available. */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
162 } |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
163 |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
164 AudioBootStrap DISKAUD_bootstrap = { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
165 DISKAUD_DRIVER_NAME, "direct-to-disk audio", DISKAUD_Init, 1 |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
166 }; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
167 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1594
diff
changeset
|
168 /* vi: set ts=4 sw=4 expandtab: */ |