2001-04-26 16:45:43 +00:00
|
|
|
/*
|
|
|
|
SDL - Simple DirectMedia Layer
|
2011-02-11 22:37:15 -08:00
|
|
|
Copyright (C) 1997-2011 Sam Lantinga
|
2001-04-26 16:45:43 +00:00
|
|
|
|
2006-02-07 06:59:48 +00:00
|
|
|
This library is SDL_free software; you can redistribute it and/or
|
2006-02-01 06:32:25 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
2001-04-26 16:45:43 +00:00
|
|
|
License as published by the Free Software Foundation; either
|
2006-02-01 06:32:25 +00:00
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
2001-04-26 16:45:43 +00:00
|
|
|
|
|
|
|
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
|
2006-02-01 06:32:25 +00:00
|
|
|
Lesser General Public License for more details.
|
2001-04-26 16:45:43 +00:00
|
|
|
|
2006-02-01 06:32:25 +00:00
|
|
|
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
|
2001-04-26 16:45:43 +00:00
|
|
|
|
|
|
|
Sam Lantinga
|
2001-12-14 12:38:15 +00:00
|
|
|
slouken@libsdl.org
|
2001-04-26 16:45:43 +00:00
|
|
|
*/
|
2006-02-21 08:46:50 +00:00
|
|
|
#include "SDL_config.h"
|
2001-04-26 16:45:43 +00:00
|
|
|
|
|
|
|
#ifndef _SDL_sysaudio_h
|
|
|
|
#define _SDL_sysaudio_h
|
|
|
|
|
|
|
|
#include "SDL_mutex.h"
|
|
|
|
#include "SDL_thread.h"
|
|
|
|
|
|
|
|
/* The SDL audio driver */
|
|
|
|
typedef struct SDL_AudioDevice SDL_AudioDevice;
|
|
|
|
#define _THIS SDL_AudioDevice *_this
|
2006-10-17 09:15:21 +00:00
|
|
|
|
|
|
|
typedef struct SDL_AudioDriverImpl
|
|
|
|
{
|
2006-10-28 16:48:03 +00:00
|
|
|
int (*DetectDevices) (int iscapture);
|
|
|
|
const char *(*GetDeviceName) (int index, int iscapture);
|
2006-10-17 09:15:21 +00:00
|
|
|
int (*OpenDevice) (_THIS, const char *devname, int iscapture);
|
|
|
|
void (*ThreadInit) (_THIS); /* Called by audio thread at start */
|
|
|
|
void (*WaitDevice) (_THIS);
|
|
|
|
void (*PlayDevice) (_THIS);
|
|
|
|
Uint8 *(*GetDeviceBuf) (_THIS);
|
|
|
|
void (*WaitDone) (_THIS);
|
|
|
|
void (*CloseDevice) (_THIS);
|
|
|
|
void (*LockDevice) (_THIS);
|
|
|
|
void (*UnlockDevice) (_THIS);
|
|
|
|
void (*Deinitialize) (void);
|
|
|
|
|
|
|
|
/* Some flags to push duplicate code into the core and reduce #ifdefs. */
|
|
|
|
int ProvidesOwnCallbackThread:1;
|
|
|
|
int SkipMixerLock:1;
|
|
|
|
int HasCaptureSupport:1;
|
|
|
|
int OnlyHasDefaultOutputDevice:1;
|
|
|
|
int OnlyHasDefaultInputDevice:1;
|
|
|
|
} SDL_AudioDriverImpl;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct SDL_AudioDriver
|
2006-07-10 21:04:37 +00:00
|
|
|
{
|
|
|
|
/* * * */
|
|
|
|
/* The name of this audio driver */
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
/* * * */
|
|
|
|
/* The description of this audio driver */
|
|
|
|
const char *desc;
|
|
|
|
|
2006-10-17 09:15:21 +00:00
|
|
|
SDL_AudioDriverImpl impl;
|
|
|
|
} SDL_AudioDriver;
|
2006-07-10 21:04:37 +00:00
|
|
|
|
|
|
|
|
2008-08-25 15:08:59 +00:00
|
|
|
/* Streamer */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
Uint8 *buffer;
|
|
|
|
int max_len; /* the maximum length in bytes */
|
|
|
|
int read_pos, write_pos; /* the position of the write and read heads in bytes */
|
|
|
|
} SDL_AudioStreamer;
|
|
|
|
|
|
|
|
|
2006-10-17 09:15:21 +00:00
|
|
|
/* Define the SDL audio driver structure */
|
|
|
|
struct SDL_AudioDevice
|
|
|
|
{
|
2006-07-10 21:04:37 +00:00
|
|
|
/* * * */
|
|
|
|
/* Data common to all devices */
|
|
|
|
|
|
|
|
/* The current audio specification (shared with audio thread) */
|
|
|
|
SDL_AudioSpec spec;
|
|
|
|
|
|
|
|
/* An audio conversion block for audio format emulation */
|
|
|
|
SDL_AudioCVT convert;
|
|
|
|
|
2008-08-25 15:08:59 +00:00
|
|
|
/* The streamer, if sample rate conversion necessitates it */
|
|
|
|
int use_streamer;
|
|
|
|
SDL_AudioStreamer streamer;
|
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
/* Current state flags */
|
2006-10-17 09:15:21 +00:00
|
|
|
int iscapture;
|
2006-07-10 21:04:37 +00:00
|
|
|
int enabled;
|
|
|
|
int paused;
|
|
|
|
int opened;
|
|
|
|
|
|
|
|
/* Fake audio buffer for when the audio hardware is busy */
|
|
|
|
Uint8 *fake_stream;
|
|
|
|
|
|
|
|
/* A semaphore for locking the mixing buffers */
|
|
|
|
SDL_mutex *mixer_lock;
|
|
|
|
|
|
|
|
/* A thread to feed the audio device */
|
|
|
|
SDL_Thread *thread;
|
2009-12-16 04:48:11 +00:00
|
|
|
SDL_threadID threadid;
|
2006-07-10 21:04:37 +00:00
|
|
|
|
|
|
|
/* * * */
|
|
|
|
/* Data private to this driver */
|
|
|
|
struct SDL_PrivateAudioData *hidden;
|
2001-04-26 16:45:43 +00:00
|
|
|
};
|
|
|
|
#undef _THIS
|
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
typedef struct AudioBootStrap
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
const char *desc;
|
2006-10-28 16:48:03 +00:00
|
|
|
int (*init) (SDL_AudioDriverImpl * impl);
|
|
|
|
int demand_only:1; /* 1==request explicitly, or it won't be available. */
|
2001-04-26 16:45:43 +00:00
|
|
|
} AudioBootStrap;
|
|
|
|
|
|
|
|
#endif /* _SDL_sysaudio_h */
|
2006-10-17 09:15:21 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
/* vi: set ts=4 sw=4 expandtab: */
|