From 4e913061bb06dcae3acd967fb2999858a150899e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sat, 21 Jun 2008 13:13:21 +0000 Subject: [PATCH] Make the buffer latency less agressive for Haiku, this makes audio playback perfect in Haiku for me (HD Audio), while it adds a very noticable latency. On C-Media, the difference between "policy 4" and "policy 5" is 2048 versus 32768 bytes, which is 16 times the latency. I added a note on why the same policy on Haiku might give me troubles (C-Media versus HD Audio means 16 bits/sample versus 32 bits/sample) and if OSS does not double the buffer size then I can see where the trouble is comming from. I should probably figure out a more fine grained way of influencing the driver buffer size. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26062 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../opensound/OpenSoundDeviceEngine.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/add-ons/media/media-add-ons/opensound/OpenSoundDeviceEngine.cpp b/src/add-ons/media/media-add-ons/opensound/OpenSoundDeviceEngine.cpp index aaba206afb..7c4b9fb5b0 100644 --- a/src/add-ons/media/media-add-ons/opensound/OpenSoundDeviceEngine.cpp +++ b/src/add-ons/media/media-add-ons/opensound/OpenSoundDeviceEngine.cpp @@ -96,10 +96,21 @@ status_t OpenSoundDeviceEngine::Open(int mode) return EIO; } - // set latency policy = fragment size (4 means 2048 bytes driver buffer - // in my tests) - // XXX: BParameter? + // set latency policy = fragment size and total driver buffer size + // TODO: export this setting as a BParameter? + + // NOTE stippi: 4 means 2048 bytes driver buffer in my tests on a C-Media + // This latency is long enough for playback on BeOS. On Haiku, testing on + // HD Audio hardware, it is too short. However, I seem to remember the + // HD Audio supports 32 bit sample width (while C-Media supports "only" + // 16). If OSS uses the same 2048 bytes even for 32 bit/sample, then I + // could see how that would be asking too much, since that would + // effectively half the latency. +#ifdef HAIKU_TARGET_PLATFORM_HAIKU + v = 5; +#else v = 4; +#endif if (ioctl(fFD, SNDCTL_DSP_POLICY, &v, sizeof(int)) < 0) { if (errno != EIO && errno != EINVAL) { fInitCheckStatus = errno;