src/audio/SDL_sysaudio.h
changeset 9012 aa058c87737b
parent 8149 681eb46b8ac4
child 9031 e963a13a720c
     1.1 --- a/src/audio/SDL_sysaudio.h	Sat Jul 26 16:52:26 2014 -0700
     1.2 +++ b/src/audio/SDL_sysaudio.h	Tue Jul 22 21:41:49 2014 -0400
     1.3 @@ -33,6 +33,26 @@
     1.4  /* Used by audio targets during DetectDevices() */
     1.5  typedef void (*SDL_AddAudioDevice)(const char *name);
     1.6  
     1.7 +/* This is the size of a packet when using SDL_QueueAudio(). We allocate
     1.8 +   these as necessary and pool them, under the assumption that we'll
     1.9 +   eventually end up with a handful that keep recycling, meeting whatever
    1.10 +   the app needs. We keep packing data tightly as more arrives to avoid
    1.11 +   wasting space, and if we get a giant block of data, we'll split them
    1.12 +   into multiple packets behind the scenes. My expectation is that most
    1.13 +   apps will have 2-3 of these in the pool. 8k should cover most needs, but
    1.14 +   if this is crippling for some embedded system, we can #ifdef this.
    1.15 +   The system preallocates enough packets for 2 callbacks' worth of data. */
    1.16 +#define SDL_AUDIOBUFFERQUEUE_PACKETLEN (8 * 1024)
    1.17 +
    1.18 +/* Used by apps that queue audio instead of using the callback. */
    1.19 +typedef struct SDL_AudioBufferQueue
    1.20 +{
    1.21 +    Uint8 data[SDL_AUDIOBUFFERQUEUE_PACKETLEN];  /* packet data. */
    1.22 +    Uint32 datalen;  /* bytes currently in use in this packet. */
    1.23 +    Uint32 startpos;  /* bytes currently consumed in this packet. */
    1.24 +    struct SDL_AudioBufferQueue *next;  /* next item in linked list. */
    1.25 +} SDL_AudioBufferQueue;
    1.26 +
    1.27  typedef struct SDL_AudioDriverImpl
    1.28  {
    1.29      void (*DetectDevices) (int iscapture, SDL_AddAudioDevice addfn);
    1.30 @@ -119,6 +139,12 @@
    1.31      SDL_Thread *thread;
    1.32      SDL_threadID threadid;
    1.33  
    1.34 +    /* Queued buffers (if app not using callback). */
    1.35 +    SDL_AudioBufferQueue *buffer_queue_head; /* device fed from here. */
    1.36 +    SDL_AudioBufferQueue *buffer_queue_tail; /* queue fills to here. */
    1.37 +    SDL_AudioBufferQueue *buffer_queue_pool; /* these are unused packets. */
    1.38 +    Uint32 queued_bytes;  /* number of bytes of audio data in the queue. */
    1.39 +
    1.40      /* * * */
    1.41      /* Data private to this driver */
    1.42      struct SDL_PrivateAudioData *hidden;