Mercurial > sdl-ios-xcode
annotate src/loadso/beos/SDL_sysloadso.c @ 4216:5b99971a27b4 SDL-1.2
Fixed bug #698
Hans de Goede 2009-02-13 01:10:52 PST
Since the new "glitch free" version of pulseaudio (used in Fedora 10 amongst
others), the sound of SDL using apps (like a simple playmus call) has been
crackling.
While looking in to fixing this I noticed that the current pulseaudio code in
SDL uses pa_simple. However pa_simple uses a thread to pump pulseaudio events
and ipc, given that SDL already has its own thread for audio handling this is
clearly suboptimal, leading to unnecessary context switching IPC, etc. Also
pa_simple does not allow one to implement the WaitAudio() callback for SDL
audiodrivers properly.
Given that my work is mostly a rewrite (although some original pieces remain)
I'm attaching the new .c and .h file, as that is easier to review then the huge
diff.
Let me know if you also want the diff.
This new version has the following features:
-no longer use an additional thread next to the SDL sound thread
-do not crackle with glitch free audio
-when used with a newer pulse, which does glitch free audio, the total latency
is
the same as with the alsa driver
-proper WaitAudio() implementation, saving another mixlen worth of latency
-adds a WaitDone() implementation
This patch has been written in consultancy with Lennart Poetering (the
pulseaudio author) and has been reviewed by him for correct use of the pa API.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 21 Sep 2009 09:27:08 +0000 |
parents | a1b03ba2fcd0 |
children |
rev | line source |
---|---|
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
4159 | 3 Copyright (C) 1997-2009 Sam Lantinga |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
22 #include "SDL_config.h" |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
1635
92947e3a18db
Make sure code is only compiled if the appropriate subsystem is enabled
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
24 #ifdef SDL_LOADSO_BEOS |
92947e3a18db
Make sure code is only compiled if the appropriate subsystem is enabled
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
25 |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 /* System dependent library loading routines */ |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #include <stdio.h> |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 #include <be/kernel/image.h> |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 #include "SDL_loadso.h" |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 |
3894
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
34 void * |
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
35 SDL_LoadObject(const char *sofile) |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 { |
3894
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
37 void *handle = NULL; |
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
38 image_id library_id = load_add_on(sofile); |
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
39 if (library_id < 0) { |
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
40 SDL_SetError(strerror((int) library_id)); |
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
41 } else { |
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
42 handle = (void *) (library_id); |
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
43 } |
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
44 return (handle); |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 } |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 |
3894
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
47 void * |
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
48 SDL_LoadFunction(void *handle, const char *name) |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 { |
3894
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
50 void *sym = NULL; |
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
51 image_id library_id = (image_id) handle; |
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
52 status_t rc = get_image_symbol(library_id, name, B_SYMBOL_TYPE_TEXT, &sym); |
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
53 if (rc != B_NO_ERROR) { |
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
54 SDL_SetError(strerror(rc)); |
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
55 } |
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
56 return (sym); |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 } |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 |
3894
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
59 void |
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
60 SDL_UnloadObject(void *handle) |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 { |
3894
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
62 image_id library_id; |
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
63 if (handle != NULL) { |
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
64 library_id = (image_id) handle; |
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
65 unload_add_on(library_id); |
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
66 } |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 } |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 |
1635
92947e3a18db
Make sure code is only compiled if the appropriate subsystem is enabled
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
69 #endif /* SDL_LOADSO_BEOS */ |
3894
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
70 |
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
71 /* vi: set ts=4 sw=4 expandtab: */ |
5a20cffc7027
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
Ryan C. Gordon <icculus@icculus.org>
parents:
1635
diff
changeset
|
72 |