annotate src/video/windib/SDL_gapidibvideo.h @ 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 3b7fc3416601
children
rev   line source
4162
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 Copyright (C) 1997-2009 Sam Lantinga
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Lesser General Public License for more details.
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 #include "SDL_config.h"
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 #ifndef _SDL_gapidibvideo_h
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 #define _SDL_gapidibvideo_h
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 #define WIN32_LEAN_AND_MEAN
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 #include <windows.h>
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 /* Hidden "this" pointer for the video functions */
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 #define _THIS SDL_VideoDevice *this
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 /* typedef these to be able to define pointers, but still force everybody who
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 * wants to access them to include the corresponding header */
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 typedef struct GapiInfo GapiInfo;
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 typedef struct DibInfo DibInfo;
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 /* for PDA */
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 typedef enum
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 {
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 SDL_ORIENTATION_UP,
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 SDL_ORIENTATION_DOWN,
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 SDL_ORIENTATION_LEFT,
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 SDL_ORIENTATION_RIGHT
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 } SDL_ScreenOrientation;
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 /* Private display data shared by gapi and windib*/
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 struct SDL_PrivateVideoData {
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 int supportRotation; /* for Pocket PC devices */
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 DWORD origRotation; /* for Pocket PC devices */
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 GapiInfo* gapiInfo;
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 DibInfo* dibInfo;
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 };
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55
3b7fc3416601 GAPI fixes from Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 #endif