comparison src/audio/SDL_sysaudio.h @ 3784:37c9c4590689 SDL-ryan-multiple-audio-device

First batch of heavy lifting on supporting multiple audio devices at once. This has a long way to go yet, most of the drivers aren't updated for the new interfaces, and it's still got some obvious bugs, FIXMEs, and wistlist items. Don't use yet.
author Ryan C. Gordon <icculus@icculus.org>
date Sun, 01 Oct 2006 05:24:03 +0000
parents c121d94672cb
children 8d74a4721ca9
comparison
equal deleted inserted replaced
3783:dc3870a3f30d 3784:37c9c4590689
27 #include "SDL_mutex.h" 27 #include "SDL_mutex.h"
28 #include "SDL_thread.h" 28 #include "SDL_thread.h"
29 29
30 /* The SDL audio driver */ 30 /* The SDL audio driver */
31 typedef struct SDL_AudioDevice SDL_AudioDevice; 31 typedef struct SDL_AudioDevice SDL_AudioDevice;
32 #define _THIS SDL_AudioDevice *_this
32 33
33 /* Define the SDL audio driver structure */ 34 /* !!! FIXME: rename these from "Audio" to "Device" ... */
34 #define _THIS SDL_AudioDevice *_this 35 typedef struct SDL_AudioDriverImpl
35 #ifndef _STATUS 36 {
36 #define _STATUS SDL_status *status 37 int (*OpenAudio) (_THIS, const char *devname, int iscapture);
37 #endif 38 void (*ThreadInit) (_THIS); /* Called by audio thread at start */
38 struct SDL_AudioDevice 39 void (*WaitAudio) (_THIS);
40 void (*PlayAudio) (_THIS);
41 Uint8 *(*GetAudioBuf) (_THIS);
42 void (*WaitDone) (_THIS);
43 void (*CloseAudio) (_THIS);
44 void (*LockAudio) (_THIS);
45 void (*UnlockAudio) (_THIS);
46 } SDL_AudioDriverImpl;
47
48 typedef struct SDL_AudioDriver
39 { 49 {
40 /* * * */ 50 /* * * */
41 /* The name of this audio driver */ 51 /* The name of this audio driver */
42 const char *name; 52 const char *name;
43 53
44 /* * * */ 54 /* * * */
45 /* The description of this audio driver */ 55 /* The description of this audio driver */
46 const char *desc; 56 const char *desc;
47 57
58 SDL_AudioDriverImpl impl;
59 } SDL_AudioDriver;
60
61
62 /* Define the SDL audio driver structure */
63 struct SDL_AudioDevice
64 {
48 /* * * */ 65 /* * * */
49 /* Public driver functions */ 66 /* Lowlevel audio implementation */
50 int (*OpenAudio) (_THIS, SDL_AudioSpec * spec); 67 const SDL_AudioDriver *driver;
51 void (*ThreadInit) (_THIS); /* Called by audio thread at start */
52 void (*WaitAudio) (_THIS);
53 void (*PlayAudio) (_THIS);
54 Uint8 *(*GetAudioBuf) (_THIS);
55 void (*WaitDone) (_THIS);
56 void (*CloseAudio) (_THIS);
57
58 /* * * */
59 /* Lock / Unlock functions added for the Mac port */
60 void (*LockAudio) (_THIS);
61 void (*UnlockAudio) (_THIS);
62 68
63 /* * * */ 69 /* * * */
64 /* Data common to all devices */ 70 /* Data common to all devices */
65 71
66 /* The current audio specification (shared with audio thread) */ 72 /* The current audio specification (shared with audio thread) */
97 typedef struct AudioBootStrap 103 typedef struct AudioBootStrap
98 { 104 {
99 const char *name; 105 const char *name;
100 const char *desc; 106 const char *desc;
101 int (*available) (void); 107 int (*available) (void);
102 SDL_AudioDevice *(*create) (int devindex); 108 int (*init) (SDL_AudioDriverImpl *impl);
103 } AudioBootStrap; 109 } AudioBootStrap;
104 110
105 #if SDL_AUDIO_DRIVER_BSD 111 #if SDL_AUDIO_DRIVER_BSD
106 extern AudioBootStrap BSD_AUDIO_bootstrap; 112 extern AudioBootStrap BSD_AUDIO_bootstrap;
107 #endif 113 #endif
172 #endif 178 #endif
173 #if SDL_AUDIO_DRIVER_DART 179 #if SDL_AUDIO_DRIVER_DART
174 extern AudioBootStrap DART_bootstrap; 180 extern AudioBootStrap DART_bootstrap;
175 #endif 181 #endif
176 182
177 /* This is the current audio device */
178 extern SDL_AudioDevice *current_audio;
179
180 #endif /* _SDL_sysaudio_h */ 183 #endif /* _SDL_sysaudio_h */
181 /* vi: set ts=4 sw=4 expandtab: */ 184 /* vi: set ts=4 sw=4 expandtab: */