Update of /cvsroot/audacity/audacity-src/src
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv8177

Modified Files:
        AudioIO.cpp AudioIO.h 
Log Message:
Update the playback VU at the end of the callback to provide reliable meter 
indications and avoid spurious clipping at start of playback caused by 
uninitialised memory.


Index: AudioIO.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/AudioIO.cpp,v
retrieving revision 1.192
retrieving revision 1.193
diff -u -d -r1.192 -r1.193
--- AudioIO.cpp 9 Jul 2008 23:34:42 -0000       1.192
+++ AudioIO.cpp 28 Oct 2008 22:21:45 -0000      1.193
@@ -2702,30 +2702,23 @@
    unsigned int i;
    int t;
 
-   // Send data to VU meters
-
-   // It's critical that we don't update the meters while
-   // StopStream is trying to stop PortAudio, otherwise it can
-   // lead to a freeze.  We use two variables to synchronize:
-   // mUpdatingMeters tells StopStream when the callback is about
-   // to enter the code where it might update the meters, and
-   // mUpdateMeters is how the rest of the code tells the callback
-   // when it is allowed to actually do the updating.  Note that
-   // mUpdatingMeters must be set first to avoid a race condition.
-   gAudioIO->mUpdatingMeters = true;
-   if (gAudioIO->mUpdateMeters) {
-
-      if (gAudioIO->mOutputMeter && 
-          !gAudioIO->mOutputMeter->IsMeterDisabled() &&
-          outputBuffer) {
-         gAudioIO->mOutputMeter->UpdateDisplay(numPlaybackChannels,
-                                               framesPerBuffer,
-                                               (float *)outputBuffer);
-      }
+   /* Send data to recording VU meter if applicable */
 
-      if (gAudioIO->mInputMeter &&
-          !gAudioIO->mInputMeter->IsMeterDisabled() &&
-          inputBuffer) {
+   if (gAudioIO->mInputMeter &&
+         !gAudioIO->mInputMeter->IsMeterDisabled() &&
+         inputBuffer) {
+      // get here if meters are actually live , and being updated
+      /* It's critical that we don't update the meters while StopStream is
+       * trying to stop PortAudio, otherwise it can lead to a freeze.  We use
+       * two variables to synchronize:
+       *   mUpdatingMeters tells StopStream when the callback is about to enter
+       *     the code where it might update the meters, and
+       *   mUpdateMeters is how the rest of the code tells the callback when it
+       *     is allowed to actually do the updating.
+       * Note that mUpdatingMeters must be set first to avoid a race condition.
+       */
+      gAudioIO->mUpdatingMeters = true;
+      if (gAudioIO->mUpdateMeters) {
          if (gAudioIO->mCaptureFormat == floatSample)
             gAudioIO->mInputMeter->UpdateDisplay(numCaptureChannels,
                                                  framesPerBuffer,
@@ -2739,8 +2732,9 @@
                                                  tempFloats);
          }
       }
-   }
-   gAudioIO->mUpdatingMeters = false;
+      gAudioIO->mUpdatingMeters = false;
+   }  // end recording VU meter update
+
 
    // Stop recording if 'silence' is detected
    if(gAudioIO->mPauseRec && inputBuffer) {
@@ -3075,6 +3069,28 @@
          }
       }
    }
+   /* Send data to playback VU meter if applicable */
+   if (gAudioIO->mOutputMeter && 
+      !gAudioIO->mOutputMeter->IsMeterDisabled() &&
+      outputBuffer) {
+      // Get here if playback meter is live 
+      /* It's critical that we don't update the meters while StopStream is
+       * trying to stop PortAudio, otherwise it can lead to a freeze.  We use
+       * two variables to synchronize:
+       *  mUpdatingMeters tells StopStream when the callback is about to enter
+       *    the code where it might update the meters, and 
+       *  mUpdateMeters is how the rest of the code tells the callback when it
+       *    is allowed to actually do the updating.
+       * Note that mUpdatingMeters must be set first to avoid a race condition.
+       */
+      gAudioIO->mUpdatingMeters = true;
+      if (gAudioIO->mUpdateMeters) {
+         gAudioIO->mOutputMeter->UpdateDisplay(numPlaybackChannels,
+                                               framesPerBuffer,
+                                               (float *)outputBuffer);
+      }
+      gAudioIO->mUpdatingMeters = false;
+   }  // end playback VU meter update
 
    return callbackReturn;
 }

Index: AudioIO.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/AudioIO.h,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- AudioIO.h   7 Jul 2008 18:13:43 -0000       1.60
+++ AudioIO.h   28 Oct 2008 22:21:45 -0000      1.61
@@ -425,6 +425,20 @@
    TimeTrack *mTimeTrack;
    
 #if USE_PORTAUDIO_V19
+   /** brief The function which is called from PortAudio's callback thread
+    * context to collect and deliver audio for / from the sound device.
+    *
+    * This covers recording, playback, and doing both simultaneously. It is
+    * also invoked to do monitoring and software playthrough. Note that dealing
+    * with the two buffers needs some care to ensure that the right things
+    * happen for all possible cases.
+    * @param inputBuffer Buffer of length framesPerBuffer containing samples
+    * from the sound card, or null if not capturing audio.
+    * @param outputBuffer Uninitialised buffer of length framesPerBuffer which
+    * will be sent to the sound card after the callback, or null if not playing
+    * audio back.
+    * @param framesPerBuffer The length of the playback and recording buffers
+    */
    friend int audacityAudioCallback(
                 const void *inputBuffer, void *outputBuffer,
                 unsigned long framesPerBuffer,


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to