ソースを参照

Added a GetPendingBytes method to the audio backend.

This will (eventually) make SDL_GetQueuedAudioSize() more accurate, and thus
reduce latency. Right now this isn't implemented anywhere, so we assume data
fed to the audio callback is consumed by the hardware and immediately played
to completion.
Ryan C. Gordon 11 年 前
コミット
e5d49c2033
2 ファイル変更9 行追加1 行削除
  1. 8 1
      src/audio/SDL_audio.c
  2. 1 0
      src/audio/SDL_sysaudio.h

+ 8 - 1
src/audio/SDL_audio.c

@@ -178,6 +178,12 @@ SDL_AudioPlayDevice_Default(_THIS)
 {                               /* no-op. */
 {                               /* no-op. */
 }
 }
 
 
+static int
+SDL_AudioGetPendingBytes_Default(_THIS)
+{
+    return 0;
+}
+
 static Uint8 *
 static Uint8 *
 SDL_AudioGetDeviceBuf_Default(_THIS)
 SDL_AudioGetDeviceBuf_Default(_THIS)
 {
 {
@@ -253,6 +259,7 @@ finalize_audio_entry_points(void)
     FILL_STUB(ThreadInit);
     FILL_STUB(ThreadInit);
     FILL_STUB(WaitDevice);
     FILL_STUB(WaitDevice);
     FILL_STUB(PlayDevice);
     FILL_STUB(PlayDevice);
+    FILL_STUB(GetPendingBytes);
     FILL_STUB(GetDeviceBuf);
     FILL_STUB(GetDeviceBuf);
     FILL_STUB(WaitDone);
     FILL_STUB(WaitDone);
     FILL_STUB(CloseDevice);
     FILL_STUB(CloseDevice);
@@ -471,7 +478,7 @@ SDL_GetQueuedAudioSize(SDL_AudioDeviceID devid)
     SDL_AudioDevice *device = get_audio_device(devid);
     SDL_AudioDevice *device = get_audio_device(devid);
     if (device) {
     if (device) {
         current_audio.impl.LockDevice(device);
         current_audio.impl.LockDevice(device);
-        retval = device->queued_bytes;
+        retval = device->queued_bytes + current_audio.impl.GetPendingBytes(device);
         current_audio.impl.UnlockDevice(device);
         current_audio.impl.UnlockDevice(device);
     }
     }
 
 

+ 1 - 0
src/audio/SDL_sysaudio.h

@@ -60,6 +60,7 @@ typedef struct SDL_AudioDriverImpl
     void (*ThreadInit) (_THIS); /* Called by audio thread at start */
     void (*ThreadInit) (_THIS); /* Called by audio thread at start */
     void (*WaitDevice) (_THIS);
     void (*WaitDevice) (_THIS);
     void (*PlayDevice) (_THIS);
     void (*PlayDevice) (_THIS);
+    int (*GetPendingBytes) (_THIS);
     Uint8 *(*GetDeviceBuf) (_THIS);
     Uint8 *(*GetDeviceBuf) (_THIS);
     void (*WaitDone) (_THIS);
     void (*WaitDone) (_THIS);
     void (*CloseDevice) (_THIS);
     void (*CloseDevice) (_THIS);