From 2fa39bdf7af68402eed827e61c8be4f8475c29ab Mon Sep 17 00:00:00 2001 From: fundamental Date: Fri, 2 Oct 2009 17:20:47 -0400 Subject: [PATCH] =?UTF-8?q?OSS:=20Added=20failsafe=20based=20upon=20J=E9r?= =?UTF-8?q?=E9mie=20Andr=E9i=20patch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See Also: https://sf.net/tracker/index.php?func=detail&aid=1781574&group_id=62934&atid=502312 (cherry picked from commit 42a066a7d7e3c9631bde7187269acd7e9234ccf6) --- plugins/zynaddsubfx/AUTHORS.txt | 2 +- plugins/zynaddsubfx/ChangeLog | 3 +- .../zynaddsubfx/src/Output/OSSaudiooutput.cpp | 28 ++++++++++++++++++- .../zynaddsubfx/src/Output/OSSaudiooutput.h | 2 ++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/plugins/zynaddsubfx/AUTHORS.txt b/plugins/zynaddsubfx/AUTHORS.txt index 33cddf36b..3018c29a0 100644 --- a/plugins/zynaddsubfx/AUTHORS.txt +++ b/plugins/zynaddsubfx/AUTHORS.txt @@ -11,7 +11,7 @@ Contributors: Daniel Clemente (with a workaround of X11 repeated key bug) Emmanuel Saracco (fix for JACK output) Achim Settelmeier (QUERTZ keyboard layout for virtual keyboard) - Jérémie Andréi (AZERTY keyboard layout, Array index fix) + Jérémie Andréi (AZERTY keyboard layout, Array index fix, OSS failsafe) Alexis Ballier (const char* <-> string mismatch, NULLMidi prototype fix) Tobias Doerffel (static vs instance variables alteration) James Morris (Memory leaks in FLTK GUI) diff --git a/plugins/zynaddsubfx/ChangeLog b/plugins/zynaddsubfx/ChangeLog index ed744b4b6..a652196a4 100644 --- a/plugins/zynaddsubfx/ChangeLog +++ b/plugins/zynaddsubfx/ChangeLog @@ -941,5 +941,6 @@ - Corrected the ADsynth unison LFO rounding function - Made Unison based on Bandwidth (in cents) parameter - +02 Oct 2009 (Mark McCurry) + - Added OSS failsafe by Jérémie Andréi diff --git a/plugins/zynaddsubfx/src/Output/OSSaudiooutput.cpp b/plugins/zynaddsubfx/src/Output/OSSaudiooutput.cpp index d10d32c96..893387d05 100644 --- a/plugins/zynaddsubfx/src/Output/OSSaudiooutput.cpp +++ b/plugins/zynaddsubfx/src/Output/OSSaudiooutput.cpp @@ -42,6 +42,8 @@ OSSaudiooutput::OSSaudiooutput() snd_stereo=1;//stereo snd_format=AFMT_S16_LE; snd_samplerate=SAMPLE_RATE; + playing_until.tv_sec=0; + playing_until.tv_usec=0; smps=new short int[SOUND_BUFFER_SIZE*2]; for (i=0;i 10000) //Don't sleep() less than 10ms. + //This will add latency... + usleep(remaining-10000); + if(remaining < 0) + cerr << "WARNING - too late" << endl; + } + playing_until.tv_usec += SOUND_BUFFER_SIZE*1000000/SAMPLE_RATE; + if(remaining < 0) + playing_until.tv_usec -= remaining; + playing_until.tv_sec += playing_until.tv_usec/1000000; + playing_until.tv_usec %= 1000000; + return; + } + for (i=0;i #include "../globals.h" class OSSaudiooutput @@ -40,6 +41,7 @@ private: int snd_stereo; int snd_format; int snd_samplerate; + struct timeval playing_until; short int *smps;//Samples to be sent to soundcard };