ohaudio: Reduce latency.

Fixes #16801.
This commit is contained in:
Ryan C. Gordon
2026-11-23 12:50:49 -05:00
parent 84eaa25639
commit 5cd603e41a
2 changed files with 2 additions and 13 deletions
+1 -13
View File
@@ -397,19 +397,7 @@ static bool BuildOHAudioStream(SDL_AudioDevice *device)
ctx.OH_AudioStreamBuilder_SetSampleFormat(builder, format);
ctx.OH_AudioStreamBuilder_SetSamplingRate(builder, device->spec.freq);
ctx.OH_AudioStreamBuilder_SetChannelCount(builder, device->spec.channels);
#if 0 // !!! FIXME: maybe we don't mess with this. (this is from the AAudio backend.)
int32_t sample_frames;
if (SDL_GetHint(SDL_HINT_AUDIO_DEVICE_SAMPLE_FRAMES)) {
sample_frames = device->sample_frames;
} else {
// Use 20 ms for the default audio buffer size
sample_frames = (device->spec.freq / 50);
}
ctx.AAudioStreamBuilder_setBufferCapacityInFrames(builder, 2 * sample_frames); // AAudio requires that the buffer capacity is at least
ctx.AAudioStreamBuilder_setFramesPerDataCallback(builder, sample_frames); // twice the size of the data callback buffer size
#endif
ctx.OH_AudioStreamBuilder_SetFrameSizeInCallback(builder, device->sample_frames);
ctx.OH_AudioStreamBuilder_SetLatencyMode(builder, AUDIOSTREAM_LATENCY_MODE_FAST);
ctx.OH_AudioStreamBuilder_SetChannelLayout(builder, sdl_layout_map[device->spec.channels-1]);
+1
View File
@@ -40,6 +40,7 @@ SDL_PROC(OH_AudioStream_Result, OH_AudioStreamBuilder_SetRendererWriteDataCallba
SDL_PROC(OH_AudioStream_Result, OH_AudioStreamBuilder_SetRendererErrorCallback, (OH_AudioStreamBuilder* builder, OH_AudioRenderer_OnErrorCallback callback, void* userData))
SDL_PROC(OH_AudioStream_Result, OH_AudioStreamBuilder_SetCapturerReadDataCallback, (OH_AudioStreamBuilder* builder, OH_AudioCapturer_OnReadDataCallback callback, void* userData))
SDL_PROC(OH_AudioStream_Result, OH_AudioStreamBuilder_SetCapturerErrorCallback, (OH_AudioStreamBuilder* builder, OH_AudioCapturer_OnErrorCallback callback, void* userData))
SDL_PROC(OH_AudioStream_Result, OH_AudioStreamBuilder_SetFrameSizeInCallback, (OH_AudioStreamBuilder* builder, int32_t frameSize))
SDL_PROC(OH_AudioStream_Result, OH_AudioRenderer_Release, (OH_AudioRenderer* renderer))
SDL_PROC(OH_AudioStream_Result, OH_AudioRenderer_Start, (OH_AudioRenderer* renderer))
SDL_PROC(OH_AudioStream_Result, OH_AudioRenderer_Pause, (OH_AudioRenderer* renderer))