src/audio/SDL_sysaudio.h
author Holmes Futrell <hfutrell@umail.ucsb.edu>
Mon, 18 Aug 2008 19:39:08 +0000
branchgsoc2008_iphone
changeset 2467 058e1f140ff3
parent 2060 866052b01ee5
child 2665 f39a056aec8b
child 2716 f8f68f47285a
permissions -rw-r--r--
Fixed problem where creating the view passed NULL as the context for setting current context ... needed to actually pass the context.
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@1312
     3
    Copyright (C) 1997-2006 Sam Lantinga
slouken@0
     4
slouken@1336
     5
    This library is SDL_free software; you can redistribute it and/or
slouken@1312
     6
    modify it under the terms of the GNU Lesser General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@1312
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1312
    13
    Lesser General Public License for more details.
slouken@0
    14
slouken@1312
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1312
    16
    License along with this library; if not, write to the Free Software
slouken@1312
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@252
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@1402
    22
#include "SDL_config.h"
slouken@0
    23
slouken@0
    24
#ifndef _SDL_sysaudio_h
slouken@0
    25
#define _SDL_sysaudio_h
slouken@0
    26
slouken@0
    27
#include "SDL_mutex.h"
slouken@0
    28
#include "SDL_thread.h"
slouken@0
    29
slouken@0
    30
/* The SDL audio driver */
slouken@0
    31
typedef struct SDL_AudioDevice SDL_AudioDevice;
icculus@2049
    32
#define _THIS	SDL_AudioDevice *_this
slouken@0
    33
icculus@2049
    34
typedef struct SDL_AudioDriverImpl
icculus@2049
    35
{
slouken@2060
    36
    int (*DetectDevices) (int iscapture);
slouken@2060
    37
    const char *(*GetDeviceName) (int index, int iscapture);
icculus@2049
    38
    int (*OpenDevice) (_THIS, const char *devname, int iscapture);
icculus@2049
    39
    void (*ThreadInit) (_THIS); /* Called by audio thread at start */
icculus@2049
    40
    void (*WaitDevice) (_THIS);
icculus@2049
    41
    void (*PlayDevice) (_THIS);
icculus@2049
    42
    Uint8 *(*GetDeviceBuf) (_THIS);
icculus@2049
    43
    void (*WaitDone) (_THIS);
icculus@2049
    44
    void (*CloseDevice) (_THIS);
icculus@2049
    45
    void (*LockDevice) (_THIS);
icculus@2049
    46
    void (*UnlockDevice) (_THIS);
icculus@2049
    47
    void (*Deinitialize) (void);
icculus@2049
    48
icculus@2049
    49
    /* Some flags to push duplicate code into the core and reduce #ifdefs. */
icculus@2049
    50
    int ProvidesOwnCallbackThread:1;
icculus@2049
    51
    int SkipMixerLock:1;
icculus@2049
    52
    int HasCaptureSupport:1;
icculus@2049
    53
    int OnlyHasDefaultOutputDevice:1;
icculus@2049
    54
    int OnlyHasDefaultInputDevice:1;
icculus@2049
    55
} SDL_AudioDriverImpl;
icculus@2049
    56
icculus@2049
    57
icculus@2049
    58
typedef struct SDL_AudioDriver
slouken@1895
    59
{
slouken@1895
    60
    /* * * */
slouken@1895
    61
    /* The name of this audio driver */
slouken@1895
    62
    const char *name;
slouken@0
    63
slouken@1895
    64
    /* * * */
slouken@1895
    65
    /* The description of this audio driver */
slouken@1895
    66
    const char *desc;
slouken@0
    67
icculus@2049
    68
    SDL_AudioDriverImpl impl;
icculus@2049
    69
} SDL_AudioDriver;
slouken@0
    70
slouken@322
    71
icculus@2049
    72
/* Define the SDL audio driver structure */
icculus@2049
    73
struct SDL_AudioDevice
icculus@2049
    74
{
slouken@1895
    75
    /* * * */
slouken@1895
    76
    /* Data common to all devices */
slouken@0
    77
slouken@1895
    78
    /* The current audio specification (shared with audio thread) */
slouken@1895
    79
    SDL_AudioSpec spec;
slouken@0
    80
slouken@1895
    81
    /* An audio conversion block for audio format emulation */
slouken@1895
    82
    SDL_AudioCVT convert;
slouken@0
    83
slouken@1895
    84
    /* Current state flags */
icculus@2049
    85
    int iscapture;
slouken@1895
    86
    int enabled;
slouken@1895
    87
    int paused;
slouken@1895
    88
    int opened;
slouken@0
    89
slouken@1895
    90
    /* Fake audio buffer for when the audio hardware is busy */
slouken@1895
    91
    Uint8 *fake_stream;
slouken@0
    92
slouken@1895
    93
    /* A semaphore for locking the mixing buffers */
slouken@1895
    94
    SDL_mutex *mixer_lock;
slouken@0
    95
slouken@1895
    96
    /* A thread to feed the audio device */
slouken@1895
    97
    SDL_Thread *thread;
slouken@1895
    98
    Uint32 threadid;
slouken@0
    99
slouken@1895
   100
    /* * * */
slouken@1895
   101
    /* Data private to this driver */
slouken@1895
   102
    struct SDL_PrivateAudioData *hidden;
slouken@0
   103
};
slouken@0
   104
#undef _THIS
slouken@0
   105
slouken@1895
   106
typedef struct AudioBootStrap
slouken@1895
   107
{
slouken@1895
   108
    const char *name;
slouken@1895
   109
    const char *desc;
slouken@2060
   110
    int (*init) (SDL_AudioDriverImpl * impl);
slouken@2060
   111
    int demand_only:1;          /* 1==request explicitly, or it won't be available. */
slouken@0
   112
} AudioBootStrap;
slouken@0
   113
icculus@2049
   114
#endif /* _SDL_sysaudio_h */
slouken@0
   115
slouken@1895
   116
/* vi: set ts=4 sw=4 expandtab: */