src/audio/SDL_sysaudio.h
changeset 9394 bb28e5281770
parent 9393 ed79a66e57e5
child 9397 d72d2aa46341
     1.1 --- a/src/audio/SDL_sysaudio.h	Mon Mar 16 02:11:39 2015 -0400
     1.2 +++ b/src/audio/SDL_sysaudio.h	Wed Mar 18 02:01:17 2015 -0400
     1.3 @@ -30,16 +30,20 @@
     1.4  typedef struct SDL_AudioDevice SDL_AudioDevice;
     1.5  #define _THIS   SDL_AudioDevice *_this
     1.6  
     1.7 -/* Used by audio targets during DetectDevices() */
     1.8 -typedef int (*SDL_AddAudioDevice)(const char *name);
     1.9 +/* Audio targets should call this as devices are added to the system (such as
    1.10 +   a USB headset being plugged in), and should also be called for
    1.11 +   for every device found during DetectDevices(). */
    1.12 +extern void SDL_AddAudioDevice(const int iscapture, const char *name, void *handle);
    1.13  
    1.14 -/* Audio targets should call this as devices are hotplugged. Don't call
    1.15 -   during DetectDevices(), this is for hotplugging a device later. */
    1.16 -extern void SDL_AudioDeviceConnected(const int iscapture, const char *name);
    1.17 +/* Audio targets should call this as devices are removed, so SDL can update
    1.18 +   its list of available devices. */
    1.19 +extern void SDL_RemoveAudioDevice(void *handle);
    1.20  
    1.21 -/* Audio targets should call this as devices are unplugged.
    1.22 -  (device) can be NULL if an unopened device is lost. */
    1.23 -extern void SDL_AudioDeviceDisconnected(const int iscapture, SDL_AudioDevice *device);
    1.24 +/* Audio targets should call this if an opened audio device is lost while
    1.25 +   being used. This can happen due to i/o errors, or a device being unplugged,
    1.26 +   etc. If the device is totally gone, please also call SDL_RemoveAudioDevice()
    1.27 +   as appropriate so SDL's list of devices is accurate. */
    1.28 +extern void SDL_OpenedAudioDeviceDisconnected(SDL_AudioDevice *device);
    1.29  
    1.30  
    1.31  /* This is the size of a packet when using SDL_QueueAudio(). We allocate
    1.32 @@ -64,8 +68,8 @@
    1.33  
    1.34  typedef struct SDL_AudioDriverImpl
    1.35  {
    1.36 -    void (*DetectDevices) (int iscapture, SDL_AddAudioDevice addfn);
    1.37 -    int (*OpenDevice) (_THIS, const char *devname, int iscapture);
    1.38 +    void (*DetectDevices) (void);
    1.39 +    int (*OpenDevice) (_THIS, void *handle, const char *devname, int iscapture);
    1.40      void (*ThreadInit) (_THIS); /* Called by audio thread at start */
    1.41      void (*WaitDevice) (_THIS);
    1.42      void (*PlayDevice) (_THIS);
    1.43 @@ -75,6 +79,7 @@
    1.44      void (*CloseDevice) (_THIS);
    1.45      void (*LockDevice) (_THIS);
    1.46      void (*UnlockDevice) (_THIS);
    1.47 +    void (*FreeDeviceHandle) (void *handle);  /**< SDL is done with handle from SDL_AddAudioDevice() */
    1.48      void (*Deinitialize) (void);
    1.49  
    1.50      /* !!! FIXME: add pause(), so we can optimize instead of mixing silence. */
    1.51 @@ -86,9 +91,18 @@
    1.52      int HasCaptureSupport;
    1.53      int OnlyHasDefaultOutputDevice;
    1.54      int OnlyHasDefaultInputDevice;
    1.55 +    int AllowsArbitraryDeviceNames;
    1.56  } SDL_AudioDriverImpl;
    1.57  
    1.58  
    1.59 +typedef struct SDL_AudioDeviceItem
    1.60 +{
    1.61 +    void *handle;
    1.62 +    struct SDL_AudioDeviceItem *next;
    1.63 +    char name[];
    1.64 +} SDL_AudioDeviceItem;
    1.65 +
    1.66 +
    1.67  typedef struct SDL_AudioDriver
    1.68  {
    1.69      /* * * */
    1.70 @@ -102,16 +116,13 @@
    1.71      SDL_AudioDriverImpl impl;
    1.72  
    1.73      /* A mutex for device detection */
    1.74 -    SDL_mutex *detection_lock;
    1.75 -
    1.76 -    SDL_bool need_capture_device_redetect;
    1.77 -    SDL_bool need_output_device_redetect;
    1.78 -
    1.79 -    char **outputDevices;
    1.80 +    SDL_mutex *detectionLock;
    1.81 +    SDL_bool captureDevicesRemoved;
    1.82 +    SDL_bool outputDevicesRemoved;
    1.83      int outputDeviceCount;
    1.84 -
    1.85 -    char **inputDevices;
    1.86      int inputDeviceCount;
    1.87 +    SDL_AudioDeviceItem *outputDevices;
    1.88 +    SDL_AudioDeviceItem *inputDevices;
    1.89  } SDL_AudioDriver;
    1.90  
    1.91