putze 7

putze 7

--- src/lilypond/msr.h
+++ src/lilypond/msr.h
@@ -203,14 +203,16 @@
   A class is used to avoid passing arguments one by one
   to the various methods that need them.
 */
-class EXP msrOptions : public smartable {
+class EXP msrOptions : public smartable
+{
   public:

     static SMARTP<msrOptions> create ();

-  public:
+  protected:

     msrOptions();
+
     virtual ~msrOptions();

   public:
@@ -293,6 +295,16 @@
     // creation from MusicXML
     // ------------------------------------------------------

+  protected:
+
+     msrElement (
+      S_msrOptions& msrOpts,
+      int           inputLineNumber);
+
+    virtual ~msrElement();
+
+  public:
+
     // set and get
     // ------------------------------------------------------

@@ -315,17 +327,10 @@
     static indenter gIndenter;

   protected:
+
+    S_msrOptions   fMsrOptions;

-    S_msrOptions   fMsrOptions;
     int            fInputLineNumber;
-
-    msrElement (
-      S_msrOptions& msrOpts,
-      int           inputLineNumber);
-
-    virtual ~msrElement();
-
-  private:
 };
 typedef SMARTP<msrElement> S_msrElement;
 EXP ostream& operator<< (ostream& os, const S_msrElement& elt);
@@ -346,18 +351,13 @@
 //______________________________________________________________________________
 template <typename T> class EXP msrBrowser : public browser<T>
 {
-  protected:
-
-    basevisitor*  fVisitor;
-
-    virtual void enter (T& t) { t.acceptIn  (fVisitor); }
-    virtual void leave (T& t) { t.acceptOut (fVisitor); }
-
   public:

     msrBrowser (basevisitor* v) : fVisitor (v) {}

     virtual ~msrBrowser() {}
+
+  public:

     virtual void set (basevisitor* v) { fVisitor = v; }

@@ -368,6 +368,13 @@

       leave (t);
     }
+
+  protected:
+
+    basevisitor*  fVisitor;
+
+    virtual void enter (T& t) { t.acceptIn  (fVisitor); }
+    virtual void leave (T& t) { t.acceptOut (fVisitor); }
 };

 /*!
@@ -389,9 +396,9 @@

     msrMusicXMLNoteData ();

-    string   musicXMLTieKindAsString () const;
-
-    virtual void print (ostream& os);
+    string        musicXMLTieKindAsString () const;
+
+    virtual void  print (ostream& os);

   public:

@@ -443,98 +450,6 @@
     string fBeatUnit;
     int    fDots;
 };
-
-/*!
-\brief A msr note duration representation.
-
-  Musical notation duration is commonly represented as fractions.
-
-  Duration is a positive number specified in division units.
-
-  The divisions element indicates how many divisions per quarter note
-  are used to indicate a note's duration.
-  For example, if duration = 1 and divisions = 2, this is an eighth note duration.
-
-  While MusicXML durations are in in divisions per quarter note,
-  LilyPond durations are in whole notes, hence the "*4" multiplications
-
-  A note duration is represented by:
-    - a numerator (the number of beats)
-    - a denominator (the beat value)
-    - and optional dots.
-*/
-//______________________________________________________________________________
-/*
-class EXP msrDuration : public msrElement
-{
-  public:
-
-    // creation from MusicXML
-    // ------------------------------------------------------
-
-    static SMARTP<msrDuration> create (
-      S_msrOptions&          msrOpts,
-      int                    inputLineNumber,
-      int                    num,
-      int                    denom,
-      int                    dots,
-      string                 tupletMemberType);
-
-    msrDuration (
-      S_msrOptions&          msrOpts,
-      int                    inputLineNumber,
-      int                    num,
-      int                    denom,
-      int                    dots,
-      string                 tupletMemberType);
-
-    virtual ~msrDuration();
-
-    // set and get
-    // ------------------------------------------------------
-
-    void scaleNumByFraction (int num, int denom);
-
-    // services
-    // ------------------------------------------------------
-
-    msrDuration& operator= (const msrDuration& dur)
-      {
-        fNum=dur.fNum; fDenom=dur.fDenom; fDots=dur.fDots;
-        return *this;
-      }
-
-    bool operator!= (const msrDuration& dur) const
-      {
-        return
-          (fNum!=dur.fNum) || (fDenom!=dur.fDenom) || (fDots!=dur.fDots);
-      }
-
-    rational durationAsRational ();
-
-    string   durationAsMSRString ();
-
-    // visitors
-    // ------------------------------------------------------
-
-    virtual void acceptIn  (basevisitor* v);
-    virtual void acceptOut (basevisitor* v);
-
-    virtual void browseData (basevisitor* v);
-
-    virtual void print (ostream& os);
-
-  private:
-
-    int         fNum;
-    int         fDenom;
-    int         fDots;
-
-    string      fTupletMemberNoteType; // ??? JMI
-};
-typedef SMARTP<msrDuration> S_msrDuration;
-EXP ostream& operator<< (ostream& os, const S_msrDuration& elt);
-*/

 /*!
 \brief A msr beam representation.
@@ -559,25 +474,6 @@
       int           inputLineNumber,
       int           number,
       msrBeamKind   beamKind);
-
-    // set and get
-    // ------------------------------------------------------
-
-    msrBeamKind getBeamKind   () const { return fBeamKind; }
-    int         getBeamNumber () const { return fBeamNumber; }
-
-    // services
-    // ------------------------------------------------------
-
-    // visitors
-    // ------------------------------------------------------
-
-    virtual void acceptIn  (basevisitor* v);
-    virtual void acceptOut (basevisitor* v);
-
-    virtual void browseData (basevisitor* v);
-
-    virtual void print (ostream& os);

   protected:

@@ -589,6 +485,27 @@

     virtual ~msrBeam();

+  public:
+
+    // set and get
+    // ------------------------------------------------------
+
+    msrBeamKind getBeamKind   () const { return fBeamKind; }
+    int         getBeamNumber () const { return fBeamNumber; }
+
+    // services
+    // ------------------------------------------------------
+
+    // visitors
+    // ------------------------------------------------------
+
+    virtual void acceptIn  (basevisitor* v);
+    virtual void acceptOut (basevisitor* v);
+
+    virtual void browseData (basevisitor* v);
+
+    virtual void print (ostream& os);
+
   private:

     int         fBeamNumber;
@@ -617,26 +534,6 @@
       S_msrOptions&       msrOpts,
       int                 inputLineNumber,
       msrArticulationKind articulationKind);
-
-    // set and get
-    // ------------------------------------------------------
-
-    msrArticulationKind
-            getArticulationKind () const
-                { return fArticulationKind; }
-
-    // services
-    // ------------------------------------------------------
-
-    // visitors
-    // ------------------------------------------------------
-
-    virtual void acceptIn  (basevisitor* v);
-    virtual void acceptOut (basevisitor* v);
-
-    virtual void browseData (basevisitor* v);
-
-    virtual void print (ostream& os);

   protected:

@@ -647,6 +544,28 @@

     virtual ~msrArticulation();

+  public:
+
+    // set and get
+    // ------------------------------------------------------
+
+    msrArticulationKind
+            getArticulationKind () const
+                { return fArticulationKind; }
+
+    // services
+    // ------------------------------------------------------
+
+    // visitors
+    // ------------------------------------------------------
+
+    virtual void acceptIn  (basevisitor* v);
+    virtual void acceptOut (basevisitor* v);
+
+    virtual void browseData (basevisitor* v);
+
+    virtual void print (ostream& os);
+
   private:

     msrArticulationKind fArticulationKind;
@@ -674,6 +593,17 @@
       int           inputLineNumber,
       msrSlurKind   slurKind);

+  protected:
+
+    msrSlur (
+      S_msrOptions& msrOpts,
+      int           inputLineNumber,
+      msrSlurKind   slurKind);
+
+    virtual ~msrSlur();
+
+  public:
+
     // set and get
     // ------------------------------------------------------

@@ -694,14 +624,6 @@

     virtual void print (ostream& os);

-  protected:
-
-    msrSlur (
-      S_msrOptions& msrOpts,
-      int           inputLineNumber,
-      msrSlurKind   slurKind);
-    virtual ~msrSlur();
-
   private:

     msrSlurKind fSlurKind;
@@ -733,29 +655,6 @@
       int                    inputLineNumber,
       msrDynamicsKind           dynamicsKind);

-    // set and get
-    // ------------------------------------------------------
-
-    msrDynamicsKind
-              getDynamicsKind () const
-                  { return fDynamicsKind; }
-
-    string  dynamicsKindAsString ();
-    string  dynamicsKindAsLilypondString ();
-
-    // services
-    // ------------------------------------------------------
-
-    // visitors
-    // ------------------------------------------------------
-
-    virtual void acceptIn  (basevisitor* v);
-    virtual void acceptOut (basevisitor* v);
-
-    virtual void browseData (basevisitor* v);
-
-    virtual void print (ostream& os);
-
   protected:

     msrDynamics (
@@ -765,6 +664,31 @@

     virtual ~msrDynamics();

+  public:
+
+    // set and get
+    // ------------------------------------------------------
+
+    msrDynamicsKind
+              getDynamicsKind () const
+                  { return fDynamicsKind; }
+
+    string  dynamicsKindAsString ();
+    string  dynamicsKindAsLilypondString ();
+
+    // services
+    // ------------------------------------------------------
+
+    // visitors
+    // ------------------------------------------------------
+
+    virtual void acceptIn  (basevisitor* v);
+    virtual void acceptOut (basevisitor* v);
+
+    virtual void browseData (basevisitor* v);
+
+    virtual void print (ostream& os);
+
   private:

     msrDynamicsKind fDynamicsKind;
@@ -792,26 +716,6 @@
       S_msrOptions& msrOpts,
       int           inputLineNumber,
       msrWedgeKind  wedgeKind);
-
-    // set and get
-    // ------------------------------------------------------
-
-    msrWedgeKind getWedgeKind () const { return fWedgeKind; }
-
-    string  wedgeKindAsString ();
-
-    // services
-    // ------------------------------------------------------
-
-    // visitors
-    // ------------------------------------------------------
-
-    virtual void acceptIn  (basevisitor* v);
-    virtual void acceptOut (basevisitor* v);
-
-    virtual void browseData (basevisitor* v);
-
-    virtual void print (ostream& os);

   protected:

@@ -822,6 +726,28 @@

     virtual ~msrWedge();

+  public:
+
+    // set and get
+    // ------------------------------------------------------
+
+    msrWedgeKind getWedgeKind () const { return fWedgeKind; }
+
+    string  wedgeKindAsString ();
+
+    // services
+    // ------------------------------------------------------
+
+    // visitors
+    // ------------------------------------------------------
+
+    virtual void acceptIn  (basevisitor* v);
+    virtual void acceptOut (basevisitor* v);
+
+    virtual void browseData (basevisitor* v);
+
+    virtual void print (ostream& os);
+
   private:

     msrWedgeKind fWedgeKind;
@@ -880,6 +806,18 @@
         int           divisions,
         int           voiceNumber);

+  protected:
+
+    msrNote (
+        S_msrOptions&        msrOpts,
+        int                  inputLineNumber,
+        msrMusicXMLNoteData& musicXMLNoteData,
+        msrSlur::msrSlurKind slurKind);
+
+    virtual ~msrNote();
+
+  public:
+
     // set and get
     // ------------------------------------------------------

@@ -1011,9 +949,6 @@
                     int   noteQuatertonesFromA,
                     msrMusicXMLNoteData::msrMusicXMLAlteration
                           alteration);
-
-    static map<msrPitch, string>
-                  sDutchLilypondPitches;

     // tuplet members
     void          applyTupletMemberDisplayFactor (
@@ -1045,16 +980,12 @@

     virtual void print (ostream& os);

-  protected:
-
-    msrNote (
-        S_msrOptions&        msrOpts,
-        int                  inputLineNumber,
-        msrMusicXMLNoteData& musicXMLNoteData,
-        msrSlur::msrSlurKind slurKind);
-
-    virtual ~msrNote();
-
+  public:
+
+    // note pitches languages
+    static map<msrPitch, string>
+                  sDutchLilypondPitches;
+
   private:

     msrNoteKind               fNoteKind;
@@ -1101,6 +1032,17 @@
     // ------------------------------------------------------

     SMARTP<msrChord> createEmptyClone ();
+
+  protected:
+
+    msrChord (
+      S_msrOptions& msrOpts,
+      int           inputLineNumber,
+      int           chordDivisions);
+
+    virtual ~msrChord();
+
+  public:

     // set and get
     // ------------------------------------------------------
@@ -1171,15 +1113,6 @@

     virtual void print (ostream& os);

-  protected:
-
-    msrChord (
-      S_msrOptions& msrOpts,
-      int           inputLineNumber,
-      int           chordDivisions);
-
-    virtual ~msrChord();
-
   private:

     vector<S_msrNote>         fChordNotes;
@@ -1219,30 +1152,6 @@
       string        variableName,
       string        value);

-    // set and get
-    // ------------------------------------------------------
-
-    void      changeAssocValue (string value)
-                  { fVariableValue = value; }
-
-    string    getVariableName  () const
-                  { return fVariableName; };
-    string    getVariableValue () const
-                  { return fVariableValue; };
-
-    // services
-    // ------------------------------------------------------
-
-    // visitors
-    // ------------------------------------------------------
-
-    virtual void acceptIn  (basevisitor* v);
-    virtual void acceptOut (basevisitor* v);
-
-    virtual void browseData (basevisitor* v);
-
-    virtual void print (ostream& os);
-
   protected:

     msrVarValAssoc (
@@ -1253,6 +1162,32 @@

     virtual ~msrVarValAssoc();

+  public:
+
+    // set and get
+    // ------------------------------------------------------
+
+    void      changeAssocValue (string value)
+                  { fVariableValue = value; }
+
+    string    getVariableName  () const
+                  { return fVariableName; };
+    string    getVariableValue () const
+                  { return fVariableValue; };
+
+    // services
+    // ------------------------------------------------------
+
+    // visitors
+    // ------------------------------------------------------
+
+    virtual void acceptIn  (basevisitor* v);
+    virtual void acceptOut (basevisitor* v);
+
+    virtual void browseData (basevisitor* v);
+
+    virtual void print (ostream& os);
+
   private:

     string             fVariableName;
@@ -1278,95 +1213,6 @@
       S_msrOptions&  msrOpts,
       int            inputLineNumber);

-    // set and get
-    // ------------------------------------------------------
-
-    void        setWorkNumber (
-                  int    inputLineNumber,
-                  string val);
-
-    void        setWorkTitle (
-                  int    inputLineNumber,
-                  string val);
-
-    void        setMovementNumber (
-                  int    inputLineNumber,
-                  string vall);
-
-    void        setMovementTitle (
-                  int    inputLineNumber,
-                  string val);
-
-    void        addCreator (
-                  int    inputLineNumber,
-                  string type,
-                  string val);
-
-    void        setRights (
-                  int    inputLineNumber,
-                  string val);
-
-    void        addSoftware (
-                  int    inputLineNumber,
-                  string val);
-
-    void        setEncodingDate (
-                  int    inputLineNumber,
-                  string val);
-
-    void        setScoreInstrument (
-                  int    inputLineNumber,
-                  string val);
-
-    S_msrVarValAssoc
-                getWorkNumber () const
-                    { return fWorkNumber; }
-
-    S_msrVarValAssoc
-                getWorkTitle () const
-                    { return fWorkTitle; }
-
-    S_msrVarValAssoc
-                getMovementNumber () const
-                    { return fMovementNumber; }
-
-    S_msrVarValAssoc
-                getMovementTitle () const
-                    { return fMovementTitle; }
-
-    vector<S_msrVarValAssoc>
-                getCreators () const
-                    { return fCreators; };
-
-    S_msrVarValAssoc
-                getRights () const
-                    { return fRights; }
-
-    vector<S_msrVarValAssoc>
-                getSoftwares () const
-                    { return fSoftwares; };
-
-    S_msrVarValAssoc
-                getEncodingDate () const
-                    { return fEncodingDate; }
-
-    S_msrVarValAssoc
-                getScoreInstrument () const
-                    { return fScoreInstrument; }
-
-    // services
-    // ------------------------------------------------------
-
-    // visitors
-    // ------------------------------------------------------
-
-    virtual void acceptIn  (basevisitor* v);
-    virtual void acceptOut (basevisitor* v);
-
-    virtual void browseData (basevisitor* v);
-
-    virtual void print (ostream& os);
-
   protected:

     msrIdentification (
@@ -1375,6 +1221,97 @@

     virtual ~msrIdentification();

+  public:
+
+    // set and get
+    // ------------------------------------------------------
+
+    void        setWorkNumber (
+                  int    inputLineNumber,
+                  string val);
+
+    void        setWorkTitle (
+                  int    inputLineNumber,
+                  string val);
+
+    void        setMovementNumber (
+                  int    inputLineNumber,
+                  string vall);
+
+    void        setMovementTitle (
+                  int    inputLineNumber,
+                  string val);
+
+    void        addCreator (
+                  int    inputLineNumber,
+                  string type,
+                  string val);
+
+    void        setRights (
+                  int    inputLineNumber,
+                  string val);
+
+    void        addSoftware (
+                  int    inputLineNumber,
+                  string val);
+
+    void        setEncodingDate (
+                  int    inputLineNumber,
+                  string val);
+
+    void        setScoreInstrument (
+                  int    inputLineNumber,
+                  string val);
+
+    S_msrVarValAssoc
+                getWorkNumber () const
+                    { return fWorkNumber; }
+
+    S_msrVarValAssoc
+                getWorkTitle () const
+                    { return fWorkTitle; }
+
+    S_msrVarValAssoc
+                getMovementNumber () const
+                    { return fMovementNumber; }
+
+    S_msrVarValAssoc
+                getMovementTitle () const
+                    { return fMovementTitle; }
+
+    vector<S_msrVarValAssoc>
+                getCreators () const
+                    { return fCreators; };
+
+    S_msrVarValAssoc
+                getRights () const
+                    { return fRights; }
+
+    vector<S_msrVarValAssoc>
+                getSoftwares () const
+                    { return fSoftwares; };
+
+    S_msrVarValAssoc
+                getEncodingDate () const
+                    { return fEncodingDate; }
+
+    S_msrVarValAssoc
+                getScoreInstrument () const
+                    { return fScoreInstrument; }
+
+    // services
+    // ------------------------------------------------------
+
+    // visitors
+    // ------------------------------------------------------
+
+    virtual void acceptIn  (basevisitor* v);
+    virtual void acceptOut (basevisitor* v);
+
+    virtual void browseData (basevisitor* v);
+
+    virtual void print (ostream& os);
+
   private:

     S_msrVarValAssoc         fWorkNumber;
@@ -1408,6 +1345,16 @@
       S_msrOptions& msrOpts,
       int           inputLineNumber);

+  protected:
+
+    msrPageGeometry (
+      S_msrOptions& msrOpts,
+      int           inputLineNumber);
+
+    virtual ~msrPageGeometry();
+
+  public:
+
     // set and get
     // ------------------------------------------------------

@@ -1452,14 +1399,6 @@
     virtual void print (ostream& os);

-  protected:
-
-    msrPageGeometry (
-      S_msrOptions& msrOpts,
-      int           inputLineNumber);
-
-    virtual ~msrPageGeometry();
-
   private:

     // page height, margins and the like in centimeters are in centimeters
@@ -1496,6 +1435,16 @@
       S_msrOptions& msrOpts,
       int           inputLineNumber);

+  protected:
+
+    msrLayout (
+      S_msrOptions& msrOpts,
+      int           inputLineNumber);
+
+    virtual ~msrLayout();
+
+  public:
+
     // set and get
     // ------------------------------------------------------

@@ -1515,14 +1464,6 @@

     virtual void print (ostream& os);

-  protected:
-
-    msrLayout (
-      S_msrOptions& msrOpts,
-      int           inputLineNumber);
-
-    virtual ~msrLayout();
-
   private:

     vector<S_msrVarValAssoc> fVarValAssocs;
@@ -1551,25 +1492,6 @@
       int           inputLineNumber,
       string        contents,
       msrGapKind    gapKind = kNoGapAfterwards);
-
-    // set and get
-    // ------------------------------------------------------
-
-    string      getContents () const { return fContents; }
-    msrGapKind  getGapKind  () const { return fGapKind; }
-
-    // services
-    // ------------------------------------------------------
-
-    // visitors
-    // ------------------------------------------------------
-
-    virtual void acceptIn  (basevisitor* v);
-    virtual void acceptOut (basevisitor* v);
-
-    virtual void browseData (basevisitor* v);
-
-    virtual void print (ostream& os);

   protected:

@@ -1581,6 +1503,27 @@

     virtual ~msrComment();

+  public:
+
+    // set and get
+    // ------------------------------------------------------
+
+    string      getContents () const { return fContents; }
+    msrGapKind  getGapKind  () const { return fGapKind; }
+
+    // services
+    // ------------------------------------------------------
+
+    // visitors
+    // ------------------------------------------------------
+
+    virtual void acceptIn  (basevisitor* v);
+    virtual void acceptOut (basevisitor* v);
+
+    virtual void browseData (basevisitor* v);
+
+    virtual void print (ostream& os);
+
   private:

     string     fContents;
@@ -1606,25 +1549,6 @@
       S_msrOptions& msrOpts,
       int           inputLineNumber,
       int           nextBarNumber);
-
-    // set and get
-    // ------------------------------------------------------
-
-    int getNextBarNumber () const
-            { return fNextBarNumber; }
-
-    // services
-    // ------------------------------------------------------
-
-    // visitors
-    // ------------------------------------------------------
-
-    virtual void acceptIn  (basevisitor* v);
-    virtual void acceptOut (basevisitor* v);
-
-    virtual void browseData (basevisitor* v);
-
-    virtual void print (ostream& os);

   protected:

@@ -1635,6 +1559,27 @@

     virtual ~msrBreak();

+  public:
+
+    // set and get
+    // ------------------------------------------------------
+
+    int getNextBarNumber () const
+            { return fNextBarNumber; }
+
+    // services
+    // ------------------------------------------------------
+
+    // visitors
+    // ------------------------------------------------------
+
+    virtual void acceptIn  (basevisitor* v);
+    virtual void acceptOut (basevisitor* v);
+
+    virtual void browseData (basevisitor* v);
+
+    virtual void print (ostream& os);
+
   private:

     int fNextBarNumber;
@@ -1659,25 +1604,6 @@
       S_msrOptions& msrOpts,
       int           inputLineNumber,
       int           nextBarNumber);
-
-    // set and get
-    // ------------------------------------------------------
-
-    int getNextBarNumber () const
-            { return fNextBarNumber; }
-
-    // services
-    // ------------------------------------------------------
-
-    // visitors
-    // ------------------------------------------------------
-
-    virtual void acceptIn  (basevisitor* v);
-    virtual void acceptOut (basevisitor* v);
-
-    virtual void browseData (basevisitor* v);
-
-    virtual void print (ostream& os);

   protected:

@@ -1688,6 +1614,27 @@

     virtual ~msrBarCheck();

+  public:
+
+    // set and get
+    // ------------------------------------------------------
+
+    int getNextBarNumber () const
+            { return fNextBarNumber; }
+
+    // services
+    // ------------------------------------------------------
+
+    // visitors
+    // ------------------------------------------------------
+
+    virtual void acceptIn  (basevisitor* v);
+    virtual void acceptOut (basevisitor* v);
+
+    virtual void browseData (basevisitor* v);
+
+    virtual void print (ostream& os);
+
   private:

     int fNextBarNumber;
@@ -1712,25 +1659,6 @@
       S_msrOptions& msrOpts,
       int           inputLineNumber,
       int           nextBarNumber);
-
-    // set and get
-    // ------------------------------------------------------
-
-    int getNextBarNumber () const
-            { return fNextBarNumber; }
-
-    // services
-    // ------------------------------------------------------
-
-    // visitors
-    // ------------------------------------------------------
-
-    virtual void acceptIn  (basevisitor* v);
-    virtual void acceptOut (basevisitor* v);
-
-    virtual void browseData (basevisitor* v);
-
-    virtual void print (ostream& os);

   protected:

@@ -1741,6 +1669,27 @@

     virtual ~msrBarnumberCheck();

+  public:
+
+    // set and get
+    // ------------------------------------------------------
+
+    int getNextBarNumber () const
+            { return fNextBarNumber; }
+
+    // services
+    // ------------------------------------------------------
+
+    // visitors
+    // ------------------------------------------------------
+
+    virtual void acceptIn  (basevisitor* v);
+    virtual void acceptOut (basevisitor* v);
+
+    virtual void browseData (basevisitor* v);
+
+    virtual void print (ostream& os);
+
   private:

     int fNextBarNumber;
@@ -1776,6 +1725,20 @@
     enum msrTupletKind {
       kStartTuplet, kContinueTuplet, kStopTuplet,
       k_NoTuplet };
+
+  protected:
+
+    msrTuplet (
+      S_msrOptions& msrOpts,
+      int           inputLineNumber,
+      int           number,
+      int           actualNotes,
+      int           normalNotes,
+      S_msrNote     firstNote);
+
+    virtual ~msrTuplet();
+
+  public:

     // set and get
     // ------------------------------------------------------
@@ -1827,18 +1790,6 @@

     virtual void print (ostream& os);

-  protected:
-
-    msrTuplet (
-      S_msrOptions& msrOpts,
-      int           inputLineNumber,
-      int           number,
-      int           actualNotes,
-      int           normalNotes,
-      S_msrNote     firstNote);
-
-    virtual ~msrTuplet();
-
   private:

     int                  fTupletNumber;
@@ -1881,6 +1832,19 @@
       string       sign,
       int          line,
       int          octaveChange);
+
+  protected:
+
+    msrClef (
+      S_msrOptions& msrOpts,
+      int          inputLineNumber,
+      string       sign,
+      int          line,
+      int          octaveChange);
+
+    virtual ~msrClef();
+
+  public:

     // set and get
     // ------------------------------------------------------
@@ -1907,17 +1871,6 @@

     virtual void print (ostream& os);

-  protected:
-
-    msrClef (
-      S_msrOptions& msrOpts,
-      int          inputLineNumber,
-      string       sign,
-      int          line,
-      int          octaveChange);
-
-    virtual ~msrClef();
-
   private:

     string fSign;
@@ -1948,6 +1901,19 @@
       int           fifths,
       string        mode,
       int           cancel);
+
+  protected:
+
+    msrKey (
+      S_msrOptions& msrOpts,
+      int           inputLineNumber,
+      int           fifths,
+      string        mode,
+      int           cancel);
+
+    virtual ~msrKey();
+
+  public:

     // set and get
     // ------------------------------------------------------
@@ -1978,17 +1944,6 @@
     virtual void browseData (basevisitor* v);

     virtual void print (ostream& os);
-
-  protected:
-
-    msrKey (
-      S_msrOptions& msrOpts,
-      int           inputLineNumber,
-      int           fifths,
-      string        mode,
-      int           cancel);
-
-    virtual ~msrKey();

   private:

@@ -2020,6 +1975,18 @@
       int           inputLineNumber,
       int           beatsNumber,
       int           beatsValue);
+
+  protected:
+
+    msrTime (
+      S_msrOptions& msrOpts,
+      int           inputLineNumber,
+      int           beatsNumber,
+      int           beatsValue);
+
+    virtual ~msrTime();
+
+  public:

     // set and get
     // ------------------------------------------------------
@@ -2045,16 +2012,6 @@

     virtual void print (ostream& os);

-  protected:
-
-    msrTime (
-      S_msrOptions& msrOpts,
-      int           inputLineNumber,
-      int           beatsNumber,
-      int           beatsValue);
-
-    virtual ~msrTime();
-
   private:

     int      fBeatsNumber;
@@ -2083,30 +2040,6 @@
       int           inputLineNumber,
       int           tempoUnit,
       int           perMinute);
-
-    // set and get
-    // ------------------------------------------------------
-
-    int       getTempoUnit () const
-                  { return fTempoUnit; }
-
-    int       getPerMinute () const
-                  { return fPerMinute; }
-
-    // services
-    // ------------------------------------------------------
-
-    string    tempoAsString () const;
-
-    // visitors
-    // ------------------------------------------------------
-
-    virtual void acceptIn  (basevisitor* v);
-    virtual void acceptOut (basevisitor* v);
-
-    virtual void browseData (basevisitor* v);
-
-    virtual void print (ostream& os);

   protected:

@@ -2118,6 +2051,32 @@

     virtual ~msrTempo();

+  public:
+
+    // set and get
+    // ------------------------------------------------------
+
+    int       getTempoUnit () const
+                  { return fTempoUnit; }
+
+    int       getPerMinute () const
+                  { return fPerMinute; }
+
+    // services
+    // ------------------------------------------------------
+
+    string    tempoAsString () const;
+
+    // visitors
+    // ------------------------------------------------------
+
+    virtual void acceptIn  (basevisitor* v);
+    virtual void acceptOut (basevisitor* v);
+
+    virtual void browseData (basevisitor* v);
+
+    virtual void print (ostream& os);
+
   private:

     int  fTempoUnit;
@@ -2421,6 +2380,22 @@
       string                    endingMusicXMLNumber,
       msrBarlineRepeatDirection repeatDirection,
       msrBarlineRepeatWinged    repeatWinged);
+
+  protected:
+
+    msrBarline (
+      S_msrOptions&             msrOpts,
+      int                       inputLineNumber,
+      msrBarlineLocation        location,
+      msrBarlineStyle           style,
+      msrBarlineEndingType      endingType,
+      string                    endingMusicXMLNumber,
+      msrBarlineRepeatDirection repeatDirection,
+      msrBarlineRepeatWinged    repeatWinged);
+
+    virtual ~msrBarline();
+
+  public:

     // set and get
     // ------------------------------------------------------
@@ -2483,19 +2458,6 @@

     virtual void print (ostream& os);

-  protected:
-
-    msrBarline (
-      S_msrOptions&             msrOpts,
-      int                       inputLineNumber,
-      msrBarlineLocation        location,
-      msrBarlineStyle           style,
-      msrBarlineEndingType      endingType,
-      string                    endingMusicXMLNumber,
-      msrBarlineRepeatDirection repeatDirection,
-      msrBarlineRepeatWinged    repeatWinged);
-    virtual ~msrBarline();
-
   private:

     msrBarlineLocation          fLocation;
@@ -2532,6 +2494,16 @@

     SMARTP<msrVoicechunk> createEmptyClone ();

+  protected:
+
+    msrVoicechunk (
+      S_msrOptions& msrOpts,
+      int           inputLineNumber);
+
+    virtual ~msrVoicechunk();
+
+  public:
+
     // set and get
     // ------------------------------------------------------

@@ -2567,14 +2539,6 @@

     virtual void print (ostream& os);

-  protected:
-
-    msrVoicechunk (
-      S_msrOptions& msrOpts,
-      int           inputLineNumber);
-
-    virtual ~msrVoicechunk();
-
   private:

     list<S_msrElement>   fVoicechunkElements;
@@ -2611,6 +2575,20 @@

     SMARTP<msrRepeatending> createEmptyClone (
       S_msrRepeat clonedRepeat);
+
+  protected:
+
+    msrRepeatending (
+      S_msrOptions&       msrOpts,
+      int                 inputLineNumber,
+      string              repeatendingMusicXMLNumber, // may be "1, 2"
+      msrRepeatendingKind repeatendingKind,
+      S_msrVoicechunk     voicechunk,
+      S_msrRepeat         repeat);
+
+    virtual ~msrRepeatending();
+
+  public:

     // set and get
     // ------------------------------------------------------
@@ -2651,18 +2629,6 @@

     virtual void print (ostream& os);

-  protected:
-
-    msrRepeatending (
-      S_msrOptions&       msrOpts,
-      int                 inputLineNumber,
-      string              repeatendingMusicXMLNumber, // may be "1, 2"
-      msrRepeatendingKind repeatendingKind,
-      S_msrVoicechunk     voicechunk,
-      S_msrRepeat         repeat);
-
-    virtual ~msrRepeatending();
-
   private:

     string              fRepeatendingMusicXMLNumber; // may be "1, 2"
@@ -2700,39 +2666,6 @@

     SMARTP<msrRepeat> createEmptyClone (
       S_msrVoice clonedVoice);
-
-    // set and get
-    // ------------------------------------------------------
-
-    void      setRepeatCommonPart (
-                S_msrVoicechunk repeatCommonPart);
-
-    S_msrVoicechunk
-              getRepeatCommonPart () const
-                { return fRepeatCommonPart; }
-
-    vector<S_msrRepeatending>
-              getRepeatEndings () const
-                { return fRepeatEndings; }
-
-    S_msrVoice
-              getRepeatVoiceUplink () const
-                { return fRepeatVoiceUplink; }
-
-    // services
-    // ------------------------------------------------------
-
-    void      addRepeatending (S_msrRepeatending repeatending);
-
-    // visitors
-    // ------------------------------------------------------
-
-    virtual void acceptIn  (basevisitor* v);
-    virtual void acceptOut (basevisitor* v);
-
-    virtual void browseData (basevisitor* v);
-
-    virtual void print (ostream& os);

   protected:

@@ -2744,6 +2677,41 @@

     virtual ~msrRepeat();

+  public:
+
+    // set and get
+    // ------------------------------------------------------
+
+    void      setRepeatCommonPart (
+                S_msrVoicechunk repeatCommonPart);
+
+    S_msrVoicechunk
+              getRepeatCommonPart () const
+                { return fRepeatCommonPart; }
+
+    vector<S_msrRepeatending>
+              getRepeatEndings () const
+                { return fRepeatEndings; }
+
+    S_msrVoice
+              getRepeatVoiceUplink () const
+                { return fRepeatVoiceUplink; }
+
+    // services
+    // ------------------------------------------------------
+
+    void      addRepeatending (S_msrRepeatending repeatending);
+
+    // visitors
+    // ------------------------------------------------------
+
+    virtual void acceptIn  (basevisitor* v);
+    virtual void acceptOut (basevisitor* v);
+
+    virtual void browseData (basevisitor* v);
+
+    virtual void print (ostream& os);
+
   private:

     S_msrVoicechunk           fRepeatCommonPart;
@@ -2779,33 +2747,6 @@

     SMARTP<msrUpbeat> createEmptyClone (
       S_msrVoice clonedVoice);
-
-    // set and get
-    // ------------------------------------------------------
-
-//    void          setUpbeatDivisions (int divisions)
-//                      { fUpbeatDivisions = divisions; }
-
-    int           getUpbeatDivisions () const
-                      { return fUpbeatDivisions; }
-
-    string        getUpbeatDivisionsAsString () const;
-
-    S_msrVoice    getUpbeatVoiceUplink () const
-                      { return fUpbeatVoiceUplink; }
-
-    // services
-    // ------------------------------------------------------
-
-    // visitors
-    // ------------------------------------------------------
-
-    virtual void acceptIn  (basevisitor* v);
-    virtual void acceptOut (basevisitor* v);
-
-    virtual void browseData (basevisitor* v);
-
-    virtual void print (ostream& os);

   protected:

@@ -2817,6 +2758,35 @@

     virtual ~msrUpbeat();

+  public:
+
+    // set and get
+    // ------------------------------------------------------
+
+//    void          setUpbeatDivisions (int divisions)
+//                      { fUpbeatDivisions = divisions; }
+
+    int           getUpbeatDivisions () const
+                      { return fUpbeatDivisions; }
+
+    string        getUpbeatDivisionsAsString () const;
+
+    S_msrVoice    getUpbeatVoiceUplink () const
+                      { return fUpbeatVoiceUplink; }
+
+    // services
+    // ------------------------------------------------------
+
+    // visitors
+    // ------------------------------------------------------
+
+    virtual void acceptIn  (basevisitor* v);
+    virtual void acceptOut (basevisitor* v);
+
+    virtual void browseData (basevisitor* v);
+
+    virtual void print (ostream& os);
+
   private:

     int                       fUpbeatDivisions;
@@ -2854,6 +2824,19 @@

     SMARTP<msrVoice> createEmptyClone (
       S_msrStaff clonedStaff);
+
+  protected:
+
+    msrVoice (
+      S_msrOptions& msrOpts,
+      int           inputLineNumber,
+      int           voiceNumber,
+      int           staffRelativeVoiceNumber,
+      S_msrStaff    voiceStaffUplink);
+
+    virtual ~msrVoice();
+
+  public:

     // set and get
     // ------------------------------------------------------
@@ -2978,17 +2961,6 @@

     virtual void print (ostream& os);

-  protected:
-
-    msrVoice (
-      S_msrOptions& msrOpts,
-      int           inputLineNumber,
-      int           voiceNumber,
-      int           staffRelativeVoiceNumber,
-      S_msrStaff    voiceStaffUplink);
-
-    virtual ~msrVoice();
-
   private:

     int                       fVoiceNumber;
@@ -3045,6 +3017,18 @@

     SMARTP<msrStaff> createEmptyClone (
       S_msrPart clonedPart);
+
+  protected:
+
+    msrStaff (
+      S_msrOptions& msrOpts,
+      int           inputLineNumber,
+      int           staffNumber,
+      S_msrPart     fStaffPartUplink);
+
+    virtual ~msrStaff();
+
+  public:

     // set and get
     // ------------------------------------------------------
@@ -3112,15 +3096,6 @@

     virtual void print (ostream& os);

-  protected:
-
-    msrStaff (
-      S_msrOptions& msrOpts,
-      int           inputLineNumber,
-      int           staffNumber,
-      S_msrPart     fStaffPartUplink);
-    virtual ~msrStaff();
-
   private:

     static int              gMaxStaffVoices;
@@ -3164,6 +3139,18 @@

     SMARTP<msrPart> createEmptyClone (
       S_msrPartgroup clonedPartgroup);
+
+  protected:
+
+    msrPart (
+      S_msrOptions&  msrOpts,
+      int            inputLineNumber,
+      string         partMusicXMLID,
+      S_msrPartgroup partPartgroupUplink);
+
+    virtual ~msrPart();
+
+  public:

     // set and get
     // ------------------------------------------------------
@@ -3217,23 +3204,21 @@
     // services
     // ------------------------------------------------------

-    void      setAllPartDivisionsPerWholeNote (int divisions);
-
-    void      setAllPartStavesClef (S_msrClef clef);
+    void          setAllPartDivisionsPerWholeNote (int divisions);
+
+    void          setAllPartStavesClef (S_msrClef clef);

-    void      setAllPartStavesKey  (S_msrKey  key);
+    void          setAllPartStavesKey  (S_msrKey  key);

-    void      setAllPartStavesTime (S_msrTime time);
+    void          setAllPartStavesTime (S_msrTime time);

-    S_msrStaff
-              addStaffToPart (
-                int inputLineNumber,
-                int staffNumber);
-
-    void      addStaffToPart (S_msrStaff staff);
-
-    S_msrStaff
-              fetchStaffFromPart (int staffNumber);
+    S_msrStaff    addStaffToPart (
+                    int inputLineNumber,
+                    int staffNumber);
+
+    void          addStaffToPart (S_msrStaff staff);
+
+    S_msrStaff    fetchStaffFromPart (int staffNumber);

     // visitors
     // ------------------------------------------------------
@@ -3245,16 +3230,6 @@

     virtual void print (ostream& os);

-  protected:
-
-    msrPart (
-      S_msrOptions&  msrOpts,
-      int            inputLineNumber,
-      string         partMusicXMLID,
-      S_msrPartgroup partPartgroupUplink);
-
-    virtual ~msrPart();
-
   private:

     string                  fPartMusicXMLID; // native
@@ -3342,8 +3317,6 @@

     virtual ~msrPartgroup();

-    static int gPartgroupsCounter;
-
   public:

     // set and get
@@ -3404,6 +3377,8 @@

   private:

+    static int              gPartgroupsCounter;
+
     int                     fPartgroupAbsoluteNumber;

     int                     fPartgroupNumber;
@@ -3446,6 +3421,16 @@

     SMARTP<msrScore> createEmptyClone ();

+  protected:
+
+    msrScore (
+      S_msrOptions& msrOpts,
+      int           inputLineNumber);
+
+    virtual ~msrScore();
+
+  public:
+
     // set and get
     // ------------------------------------------------------

@@ -3476,14 +3461,6 @@

     virtual void print (ostream& os);

-  protected:
-
-    msrScore (
-      S_msrOptions& msrOpts,
-      int           inputLineNumber);
-
-    virtual ~msrScore();
-
   private:

     S_msrIdentification  fIdentification;
@@ -3512,22 +3489,6 @@
       S_msrOptions& msrOpts,
       int                    inputLineNumber);

-    // set and get
-    // ------------------------------------------------------
-
-    // services
-    // ------------------------------------------------------
-
-    // visitors
-    // ------------------------------------------------------
-
-    virtual void acceptIn  (basevisitor* v);
-    virtual void acceptOut (basevisitor* v);
-
-    virtual void browseData (basevisitor* v);
-
-    virtual void print (ostream& os);
-
   protected:

     msrMidi (
@@ -3536,6 +3497,24 @@

     virtual ~msrMidi();

+  public:
+
+    // set and get
+    // ------------------------------------------------------
+
+    // services
+    // ------------------------------------------------------
+
+    // visitors
+    // ------------------------------------------------------
+
+    virtual void acceptIn  (basevisitor* v);
+    virtual void acceptOut (basevisitor* v);
+
+    virtual void browseData (basevisitor* v);
+
+    virtual void print (ostream& os);
+
   private:

 };


* modules/audio_output/directx.c: use common channel re-ordering code.

--- modules/audio_output/directx.c
+++ modules/audio_output/directx.c
@@ -2,9 +2,9 @@
  * directx.c: Windows DirectX audio output method
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: directx.c,v 1.27 2004/02/26 17:02:17 gbazin Exp $
+ * $Id$
  *
- * Authors: Gildas Bazin <gbazin@netcourrier.com>
+ * Authors: Gildas Bazin <gbazin@videolan.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -165,22 +165,27 @@
     int i_frame_size;                         /* Size in bytes of one frame */

     vlc_bool_t b_chan_reorder;              /* do we need channel reordering */
-    int *pi_chan_table;
+    int pi_chan_table[AOUT_CHAN_MAX];
     uint32_t i_channel_mask;
+    uint32_t i_bits_per_sample;
+    uint32_t i_channels;
 };

+static const uint32_t pi_channels_src[] =
+    { AOUT_CHAN_LEFT, AOUT_CHAN_RIGHT,
+      AOUT_CHAN_MIDDLELEFT, AOUT_CHAN_MIDDLERIGHT,
+      AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT,
+      AOUT_CHAN_CENTER, AOUT_CHAN_LFE, 0 };
 static const uint32_t pi_channels_in[] =
-    { AOUT_CHAN_LEFT, AOUT_CHAN_RIGHT,
-      AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT,
-      AOUT_CHAN_CENTER, AOUT_CHAN_LFE };
+    { SPEAKER_FRONT_LEFT, SPEAKER_FRONT_RIGHT,
+      SPEAKER_SIDE_LEFT, SPEAKER_SIDE_RIGHT,
+      SPEAKER_BACK_LEFT, SPEAKER_BACK_RIGHT,
+      SPEAKER_FRONT_CENTER, SPEAKER_LOW_FREQUENCY, 0 };
 static const uint32_t pi_channels_out[] =
     { SPEAKER_FRONT_LEFT, SPEAKER_FRONT_RIGHT,
+      SPEAKER_FRONT_CENTER, SPEAKER_LOW_FREQUENCY,
       SPEAKER_BACK_LEFT, SPEAKER_BACK_RIGHT,
-      SPEAKER_FRONT_CENTER, SPEAKER_LOW_FREQUENCY };
-static const uint32_t pi_channels_ordered[] =
-    { SPEAKER_FRONT_LEFT, SPEAKER_FRONT_RIGHT, SPEAKER_FRONT_CENTER,
-      SPEAKER_LOW_FREQUENCY,
-      SPEAKER_BACK_LEFT, SPEAKER_BACK_RIGHT };
+      SPEAKER_SIDE_LEFT, SPEAKER_SIDE_RIGHT, 0 };

 /*****************************************************************************
  * Local prototypes.
@@ -198,10 +203,6 @@
 static void DirectSoundThread ( notification_thread_t * );
 static int  FillBuffer        ( aout_instance_t *, int, aout_buffer_t * );

-static void CheckReordering   ( aout_instance_t *, int );
-static void InterleaveFloat32 ( float *, float *, int *, int );
-static void InterleaveS16     ( int16_t *, int16_t *, int *, int );
-
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
@@ -239,7 +240,6 @@
     p_aout->output.p_sys->p_dsnotify = NULL;
     p_aout->output.p_sys->p_notif = NULL;
     p_aout->output.p_sys->b_playing = 0;
-    p_aout->output.p_sys->pi_chan_table = NULL;

     p_aout->output.pf_play = Play;
     aout_VolumeSoftInit( p_aout );
@@ -557,42 +557,37 @@
 static void CloseAudio( vlc_object_t *p_this )
 {
     aout_instance_t * p_aout = (aout_instance_t *)p_this;
+    aout_sys_t *p_sys = p_aout->output.p_sys;

     msg_Dbg( p_aout, "CloseAudio" );

     /* kill the position notification thread, if any */
-    if( p_aout->output.p_sys->p_notif )
-    {
-        vlc_object_detach( p_aout->output.p_sys->p_notif );
-        if( p_aout->output.p_sys->p_notif->b_thread )
-        {
-            p_aout->output.p_sys->p_notif->b_die = 1;
-
-            if( !p_aout->output.p_sys->b_playing )
+    if( p_sys->p_notif )
+    {
+        vlc_object_detach( p_sys->p_notif );
+        if( p_sys->p_notif->b_thread )
+        {
+            p_sys->p_notif->b_die = 1;
+
+            if( !p_sys->b_playing )
                 /* wake up the audio thread */
-                SetEvent(
-                    p_aout->output.p_sys->p_notif->p_events[0].hEventNotify );
-
-            vlc_thread_join( p_aout->output.p_sys->p_notif );
-        }
-        vlc_object_destroy( p_aout->output.p_sys->p_notif );
+                SetEvent( p_sys->p_notif->p_events[0].hEventNotify );
+
+            vlc_thread_join( p_sys->p_notif );
+        }
+        vlc_object_destroy( p_sys->p_notif );
     }

     /* release the secondary buffer */
     DestroyDSBuffer( p_aout );

     /* finally release the DirectSound object */
-    if( p_aout->output.p_sys->p_dsobject )
-        IDirectSound_Release( p_aout->output.p_sys->p_dsobject );
+    if( p_sys->p_dsobject ) IDirectSound_Release( p_sys->p_dsobject );

     /* free DSOUND.DLL */
-    if( p_aout->output.p_sys->hdsound_dll )
-       FreeLibrary( p_aout->output.p_sys->hdsound_dll );
-
-    if( p_aout->output.p_sys->pi_chan_table )
-        free( p_aout->output.p_sys->pi_chan_table );
-
-    free( p_aout->output.p_sys );
+    if( p_sys->hdsound_dll ) FreeLibrary( p_sys->hdsound_dll );
+
+    free( p_sys );
 }

 /*****************************************************************************
@@ -721,6 +716,9 @@
     waveformat.Format.nAvgBytesPerSec =
         waveformat.Format.nSamplesPerSec * waveformat.Format.nBlockAlign;

+    p_aout->output.p_sys->i_bits_per_sample = waveformat.Format.wBitsPerSample;
+    p_aout->output.p_sys->i_channels = i_nb_channels;
+
     /* Then fill in the direct sound descriptor */
     memset(&dsbdesc, 0, sizeof(DSBUFFERDESC));
     dsbdesc.dwSize = sizeof(DSBUFFERDESC);
@@ -810,7 +808,16 @@
     }

     p_aout->output.p_sys->i_channel_mask = waveformat.dwChannelMask;
-    CheckReordering( p_aout, i_nb_channels );
+
+    p_aout->output.p_sys->b_chan_reorder =
+        aout_CheckChannelReorder( pi_channels_in, pi_channels_out,
+                                  waveformat.dwChannelMask, i_nb_channels,
+                                  p_aout->output.p_sys->pi_chan_table );
+
+    if( p_aout->output.p_sys->b_chan_reorder )
+    {
+        msg_Dbg( p_aout, "channel reordering needed" );
+    }

     return VLC_SUCCESS;

@@ -886,13 +893,14 @@
                        aout_buffer_t *p_buffer )
 {
     notification_thread_t *p_notif = p_aout->output.p_sys->p_notif;
+    aout_sys_t *p_sys = p_aout->output.p_sys;
     void *p_write_position, *p_wrap_around;
     long l_bytes1, l_bytes2;
     HRESULT dsresult;

     /* Before copying anything, we have to lock the buffer */
     dsresult = IDirectSoundBuffer_Lock(
-                p_aout->output.p_sys->p_dsbuffer,               /* DS buffer */
+                p_sys->p_dsbuffer,                              /* DS buffer */
                 i_frame * p_notif->i_frame_size,             /* Start offset */
                 p_notif->i_frame_size,                    /* Number of bytes */
                 &p_write_position,                  /* Address of lock start */
@@ -902,9 +910,9 @@
                 0 );                                                /* Flags */
     if( dsresult == DSERR_BUFFERLOST )
     {
-        IDirectSoundBuffer_Restore( p_aout->output.p_sys->p_dsbuffer );
+        IDirectSoundBuffer_Restore( p_sys->p_dsbuffer );
         dsresult = IDirectSoundBuffer_Lock(
-                               p_aout->output.p_sys->p_dsbuffer,
+                               p_sys->p_dsbuffer,
                                i_frame * p_notif->i_frame_size,
                                p_notif->i_frame_size,
                                &p_write_position,
@@ -924,33 +932,23 @@
     {
         memset( p_write_position, 0, l_bytes1 );
     }
-    else if( p_aout->output.p_sys->b_chan_reorder )
-    {
-        /* Do the channel reordering here */
-
-        if( p_aout->output.output.i_format ==  VLC_FOURCC('s','1','6','l') )
-          InterleaveS16( (int16_t *)p_buffer->p_buffer,
-                         (int16_t *)p_write_position,
-                         p_aout->output.p_sys->pi_chan_table,
-                         aout_FormatNbChannels( &p_aout->output.output ) );
-        else
-          InterleaveFloat32( (float *)p_buffer->p_buffer,
-                             (float *)p_write_position,
-                             p_aout->output.p_sys->pi_chan_table,
-                             aout_FormatNbChannels( &p_aout->output.output ) );
-
-        aout_BufferFree( p_buffer );
-    }
     else
     {
+        if( p_sys->b_chan_reorder )
+        {
+            /* Do the channel reordering here */
+            aout_ChannelReorder( p_buffer->p_buffer, p_buffer->i_nb_bytes,
+                                 p_sys->i_channels, p_sys->pi_chan_table,
+                                 p_sys->i_bits_per_sample );
+        }
+
         p_aout->p_vlc->pf_memcpy( p_write_position, p_buffer->p_buffer,
                                   l_bytes1 );
         aout_BufferFree( p_buffer );
     }

     /* Now the data has been copied, unlock the buffer */
-    IDirectSoundBuffer_Unlock( p_aout->output.p_sys->p_dsbuffer,
-                               p_write_position, l_bytes1,
+    IDirectSoundBuffer_Unlock( p_sys->p_dsbuffer, p_write_position, l_bytes1,
                                p_wrap_around, l_bytes2 );

     return VLC_SUCCESS;
@@ -1093,93 +1091,3 @@

     msg_Dbg( p_notif, "DirectSoundThread exiting" );
 }
-
-/*****************************************************************************
- * CheckReordering: Check if we need to do some channel re-ordering (the ac3
- *                  channel order is different from the one chosen by
- *                  Microsoft).
- *****************************************************************************/
-static void CheckReordering( aout_instance_t *p_aout, int i_nb_channels )
-{
-    int i, j, k, l;
-
-#define i_channel_mask p_aout->output.p_sys->i_channel_mask
-#define pi_chan_table p_aout->output.p_sys->pi_chan_table
-
-    p_aout->output.p_sys->b_chan_reorder = VLC_FALSE;
-
-    pi_chan_table = malloc( i_nb_channels * sizeof(int) );
-    if( !pi_chan_table )
-    {
-        return;
-    }
-
-    for( i = 0, j = 0;
-         i < (int)(sizeof(pi_channels_out)/sizeof(uint32_t)); i++ )
-    {
-        if( i_channel_mask & pi_channels_out[i] )
-        {
-            for( k = 0, l = 0;
-                 pi_channels_out[i] != pi_channels_ordered[k]; k++ )
-            {
-                if( i_channel_mask & pi_channels_ordered[k] )
-                {
-                    l++;
-                }
-            }
-
-            pi_chan_table[j] = l;
-
-            j++;
-        }
-    }
-
-    for( i = 0; i < i_nb_channels; i++ )
-    {
-        if( pi_chan_table[i] != i )
-        {
-            p_aout->output.p_sys->b_chan_reorder = VLC_TRUE;
-        }
-    }
-
-    if( p_aout->output.p_sys->b_chan_reorder )
-    {
-        msg_Dbg( p_aout, "channel reordering needed" );
-    }
-
-#undef pi_chan_table
-#undef waveformat
-}
-
-/*****************************************************************************
- * InterleaveFloat32/S16: change the channel order to the Microsoft one.
- *****************************************************************************/
-static void InterleaveFloat32( float *p_buf, float *p_buf_out,
-                               int *pi_chan_table, int i_nb_channels )
-{
-    int i, j;
-
-    for( i = 0; i < FRAME_SIZE; i++ )
-    {
-        for( j = 0; j < i_nb_channels; j++ )
-        {
-            p_buf_out[i*i_nb_channels + pi_chan_table[j]] =
-                p_buf[i*i_nb_channels + j];
-        }
-    }
-}
-
-static void InterleaveS16( int16_t *p_buf, int16_t *p_buf_out,
-                           int *pi_chan_table, int i_nb_channels )
-{
-    int i, j;
-
-    for( i = 0; i < FRAME_SIZE; i++ )
-    {
-        for( j = 0; j < i_nb_channels; j++ )
-        {
-            p_buf_out[ i*i_nb_channels + pi_chan_table[j]] =
-                p_buf[i*i_nb_channels + j];
-        }
-    }
-}


Minor kibitzing on previous patch: no need to run check more than once. (_PG_init should be called only once anyway, but as long as it's got an internal guard against repeat calls, that should be in front of the version check.)

--- src/pl/plpython/plpython.c
+++ src/pl/plpython/plpython.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  * plpython.c - python as a procedural language for PostgreSQL
  *
- *	$PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.147 2010/07/08 18:42:12 petere Exp $
+ *	$PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.148 2010/07/08 19:00:11 tgl Exp $
  *
  *********************************************************************
  */
@@ -3220,6 +3220,9 @@
 	static bool inited = false;
 	const int **version_ptr;

+	if (inited)
+		return;
+
 	/* Be sure we don't run Python 2 and 3 in the same session (might crash) */
 	version_ptr = (const int **) find_rendezvous_variable("plpython_python_version");
 	if (!(*version_ptr))
@@ -3233,9 +3236,6 @@
 							   **version_ptr, plpython_python_version),
 					 errhint("Start a new session to use a different Python major version.")));
 	}
-
-	if (inited)
-		return;

 	pg_bindtextdomain(TEXTDOMAIN);


Avutil: map 4:2:2 12bits

Avutil: map 4:2:2 12bits

--- modules/codec/avcodec/chroma.c
+++ modules/codec/avcodec/chroma.c
@@ -95,6 +95,10 @@
     {VLC_CODEC_I422_9B, AV_PIX_FMT_YUV422P9BE, 0, 0, 0 },
     {VLC_CODEC_I422_10L, AV_PIX_FMT_YUV422P10LE, 0, 0, 0 },
     {VLC_CODEC_I422_10B, AV_PIX_FMT_YUV422P10BE, 0, 0, 0 },
+#if (LIBAVUTIL_VERSION_MICRO >= 100 && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT( 54, 17, 100 ) )
+    {VLC_CODEC_I422_12L, AV_PIX_FMT_YUV422P12LE, 0, 0, 0 },
+    {VLC_CODEC_I422_12B, AV_PIX_FMT_YUV422P12BE, 0, 0, 0 },
+#endif

     {VLC_CODEC_YUV420A, AV_PIX_FMT_YUVA420P, 0, 0, 0 },
     {VLC_CODEC_YUV422A, AV_PIX_FMT_YUVA422P, 0, 0, 0 },


Remove redundant header file

Remove redundant header file

--- src/linuxthreads.c
+++ src/linuxthreads.c
@@ -40,7 +40,6 @@

 #include <asm/stat.h>
 #include <linux/sched.h>
-#include <dirent.h>
 #include <signal.h>
 #include <stdlib.h>
 #include <string.h>


app/testpmd: use per-core variable in flowgen

Use per-core variable for flow indexing to solve cache contention in
multi-core scenarios.

Signed-off-by: Zhihong Wang <d340c26e7e7f43270f08407698de08b85b54ac43@bytedance.com>
Acked-by: Xiaoyun Li <151cc00bdba86cfa2ecfc39aaa98def8f092d9d8@intel.com>

--- app/test-pmd/flowgen.c
+++ app/test-pmd/flowgen.c
@@ -52,6 +52,8 @@
 	{{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x01 }};

 #define IP_DEFTTL  64   /* from RFC 1340. */
+
+RTE_DEFINE_PER_LCORE(int, _next_flow);

 /*
  * Multi-flow generation mode.
@@ -80,7 +82,7 @@
 	uint32_t retry;
 	uint64_t tx_offloads;
 	uint64_t start_tsc = 0;
-	static int next_flow = 0;
+	int next_flow = RTE_PER_LCORE(_next_flow);

 	get_start_cycles(&start_tsc);

@@ -163,7 +165,8 @@
 		}
 		pkts_burst[nb_pkt] = pkt;

-		next_flow = (next_flow + 1) % cfg_n_flows;
+		if (++next_flow >= (int)cfg_n_flows)
+			next_flow = 0;
 	}

 	nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_pkt);
@@ -193,6 +196,8 @@
 		} while (++nb_tx < nb_pkt);
 	}

+	RTE_PER_LCORE(_next_flow) = next_flow;
+
 	get_end_cycles(fs, start_tsc);
 }


app/testpmd: fix RSS by setting mq_mode

app/testpmd: fix RSS by setting mq_mode

The mq_mode was not set when rxq is > 0; it's defaulted to ETH_MQ_RX_NONE.
As a result, RSS remains inactive. The fix is to set mq_mode to ETH_MQ_RX_RSS
when hf is non-zero.

This bug was introduced by commit 243db2ddee3094a2cb39fdd4b17e26df4e7735e1
igb/ixgbe: ETH_MQ_RX_NONE should disable RSS

Signed-off-by: Daniel Kan <2591e5f46f28d303f9dc027d475a5c60d8dea17a@nyansa.com>
Acked-by: Maxime Leroy <456097398e25fafb4037134ee0199bc711bfd454@6wind.com>

--- app/test-pmd/testpmd.c
+++ app/test-pmd/testpmd.c
@@ -1571,6 +1571,9 @@
 		if (nb_rxq > 0) {
 			port->dev_conf.rx_adv_conf.rss_conf.rss_key = NULL;
 			port->dev_conf.rx_adv_conf.rss_conf.rss_hf = rss_hf;
+			if (rss_hf != 0) {
+				port->dev_conf.rxmode.mq_mode = ETH_MQ_RX_RSS;
+			}
 		} else {
 			port->dev_conf.rx_adv_conf.rss_conf.rss_key = NULL;
 			port->dev_conf.rx_adv_conf.rss_conf.rss_hf = 0;


FEATURE(815): Implement seeking in eq.

FEATURE(815): Implement seeking in eq.

--- src/plugins/equalizer/eq.c
+++ src/plugins/equalizer/eq.c
@@ -32,6 +32,8 @@
 static void xmms_eq_destroy (xmms_xform_t *xform);
 static gint xmms_eq_read (xmms_xform_t *xform, xmms_sample_t *buf, gint len,
                           xmms_error_t *error);
+static gint64 xmms_eq_seek (xmms_xform_t *xform, gint64 offset,
+                            xmms_xform_seek_mode_t whence, xmms_error_t *err);
 static void xmms_eq_gain_changed (xmms_object_t *object, gconstpointer data,
                                   gpointer userdata);
 static void xmms_eq_config_changed (xmms_object_t *object, gconstpointer data,
@@ -64,6 +66,7 @@
 	methods.init = xmms_eq_init;
 	methods.destroy = xmms_eq_destroy;
 	methods.read = xmms_eq_read;
+	methods.seek = xmms_eq_seek;

 	xmms_xform_plugin_methods_set (xform_plugin, &methods);

@@ -273,6 +276,12 @@
 	return read;
 }

+static gint64
+xmms_eq_seek (xmms_xform_t *xform, gint64 offset, xmms_xform_seek_mode_t whence, xmms_error_t *err)
+{
+	return xmms_xform_seek (xform, offset, whence, err);
+}
+
 static void
 xmms_eq_gain_changed (xmms_object_t *object, gconstpointer data,
                       gpointer userdata)


All uncommented in struct_todo.c

All uncommented in struct_todo.c

--- struct_todo.c
+++ struct_todo.c
@@ -22,7 +22,7 @@

 	struct A comma = (y, z);

-	//struct A exp_stmt = ({ struct A sub = { .k = 1 }; sub; });
+	struct A exp_stmt = ({ struct A sub = { .k = 1 }; sub; });

 	struct A init = (struct A){ .j = 1 };

@@ -32,6 +32,6 @@
 	print_A(&z);
 	print_A(&x);
 	print_A(&comma);
-	//print_A(&exp_stmt);
+	print_A(&exp_stmt);
 	print_A(&init);
 }


added - (void)startAuthorization; to the header file

--- WeiboKit/WKOAuth2Client.h
+++ WeiboKit/WKOAuth2Client.h
@@ -21,6 +21,8 @@

 #pragma mark -
 #pragma mark OAuth 2.0 Authorization API
+
+- (void)startAuthorization;

 #pragma mark -
 #pragma mark Weibo API


Fixed -h, -? and -v

Fixed -h, -? and -v

--- src/main/saffire.c
+++ src/main/saffire.c
@@ -134,7 +134,7 @@
             }

             // Parse options clears the options as soon as they are processed
-            if (action->options) {
+            if (action->options && argc) {
                 saffire_parse_options(&argc, argv, &action->options, 1);
             }

@@ -185,7 +185,9 @@
 static char *parse_command_line(int *argc, char **argv[]) {
     // Turn "./saffire" into "./saffire help"
     if (*argc == 1) {
-        *argc = 0;
+        (*argv) += 1;
+        *argc -= 1;
+
         return "help";
     }

@@ -194,11 +196,20 @@
         strcmp((*argv)[1], "--help") == 0 ||
         strcmp((*argv)[1], "-?") == 0) {
         // Since "" is not a command, it will fall through commands and display usage
-        return "";
+
+        // assume it's the only argument given
+        (*argv) += 2;
+        *argc -= 2;
+
+        return "help";
     }

     // Special case for -v
     if (strcmp((*argv)[1], "-v") == 0) {
+        // assume it's the only argument given
+        (*argv) += 2;
+        *argc -= 2;
+
         return "version";
     }


In alsa-lib in snd_seq_close() there are a couple of missing calls to free().

--- src/seq/seq.c
+++ src/seq/seq.c
@@ -115,6 +115,10 @@
 	if (!seq)
 		return -EINVAL;
 	res = close(seq->fd) < 0 ? -errno : 0;
+	if (seq->obuf)
+		free(seq->obuf);
+	if (seq->ibuf)
+		free(seq->ibuf);
 	free(seq);
 	return res;
 }


Fix typo

Fix typo

--- YYKit/Cache/YYDiskCache.h
+++ YYKit/Cache/YYDiskCache.h
@@ -23,7 +23,7 @@
  * It can automatically decide the storage type (sqlite/file) for each object to get
       better performance.

- You may compile the lastest version of sqlite and ignore the libsqlite3.dylib in
+ You may compile the latest version of sqlite and ignore the libsqlite3.dylib in
  iOS system to get 2x~4x speed up.
  */
 @interface YYDiskCache : NSObject


swaybg: check for exact number of arguments

--- swaybg/main.c
+++ swaybg/main.c
@@ -28,7 +28,7 @@
 	surfaces = create_list();
 	registry = registry_poll();

-	if (argc < 4) {
+	if (argc != 4) {
 		sway_abort("Do not run this program manually. See man 5 sway and look for output options.");
 	}


UefiCpuPkg: Fix typos in comments

UefiCpuPkg: Fix typos in comments

- becasue to because

Cc: Jeff Fan <7d6fed0251a47076d6e691789131f22f07d057b4@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Giri P Mudusuru <25c53ebec15b492d82d7bf064153464c6e8fbfec@intel.com>
Reviewed-by: Jeff Fan <7d6fed0251a47076d6e691789131f22f07d057b4@intel.com>

--- UefiCpuPkg/CpuMpPei/Microcode.c
+++ UefiCpuPkg/CpuMpPei/Microcode.c
@@ -93,7 +93,7 @@
     if (MicrocodeEntryPoint->HeaderVersion == 0x1) {
       //
       // It is the microcode header. It is not the padding data between microcode patches
-      // becasue the padding data should not include 0x00000001 and it should be the repeated
+      // because the padding data should not include 0x00000001 and it should be the repeated
       // byte format (like 0xXYXYXYXY....).
       //
       if (MicrocodeEntryPoint->ProcessorId == RegEax &&


TransactionalDictionary: some trivial changes

--- stingraykit/collection/TransactionalDictionary.h
+++ stingraykit/collection/TransactionalDictionary.h
@@ -112,10 +112,12 @@
 		};
 		STINGRAYKIT_DECLARE_PTR(Holder);

-		struct ReverseEnumerable : public virtual IEnumerable<PairType>
-		{
+		class ReverseEnumerable : public virtual IEnumerable<PairType>
+		{
+		private:
 			HolderPtr		_holder;

+		public:
 			ReverseEnumerable(const HolderPtr& holder) : _holder(holder) { }

 			virtual shared_ptr<IEnumerator<PairType> > GetEnumerator() const
@@ -386,7 +388,6 @@
 				}
 			}
 		};
-		STINGRAYKIT_DECLARE_PTR(Transaction);

 	private:
 		ImplDataPtr							_impl;


Info Page: added status info for audioreactive

- Current sound source - including "failed to initialize"
- Current AGC or Manual Gain
- Sound Sync Status

--- usermods/audioreactive/audio_reactive.h
+++ usermods/audioreactive/audio_reactive.h
@@ -421,6 +421,12 @@
     unsigned long last_kick_time = 0;
     uint8_t  last_user_inputLevel = 0;

+    // used to feed "Info" Page
+    unsigned long last_UDPTime = 0;    // time of last valid UDP sound sync datapacket
+    float maxSample5sec = 0.0f;        // max sample (after AGC) in last 5 seconds
+    unsigned long sampleMaxTimer = 0;  // last time maxSample5sec was reset
+    #define CYCLE_SAMPLEMAX 3500       // time window for merasuring
+
     // strings to reduce flash memory usage (used more than twice)
     static const char _name[];
     static const char _enabled[];
@@ -968,6 +974,7 @@

       if (audioSyncEnabled & 0x02) disableSoundProcessing = true;   // make sure everything is disabled IF in audio Receive mode
       if (audioSyncEnabled & 0x01) disableSoundProcessing = false;  // keep running audio IF we're in audio Transmit mode
+      if(!audioSource->isInitialized()) disableSoundProcessing = true;  // no audio source

       // Only run the sampling code IF we're not in Receive mode or realtime mode
@@ -1056,6 +1063,7 @@
           bool have_new_sample = false;
           if (millis() - lastTime > delayMs) {
             have_new_sample = receiveAudioData();
+            if (have_new_sample) last_UDPTime = millis();
             lastTime = millis();
           }
           if (have_new_sample) syncVolumeSmth = volumeSmth;   // remember received sample
@@ -1069,6 +1077,14 @@
        }
       #endif

+      // peak sample from last 5 seconds
+      if ((millis() -  sampleMaxTimer) > CYCLE_SAMPLEMAX) {
+        sampleMaxTimer = millis();
+        maxSample5sec = (0.25 * maxSample5sec) + 0.75 *((soundAgc) ? sampleAgc : sampleAvg); // reset, with some smoothing
+        if (sampleAvg < 1) maxSample5sec = 0; // noise gate
+      } else {
+         maxSample5sec = fmaxf(maxSample5sec, (soundAgc) ? sampleAgc : sampleAvg); // follow maximum
+      }
       //UDP Microphone Sync  - transmit mode
       if ((audioSyncEnabled & 0x01) && (millis() - lastTime > 20)) {
         // Only run the transmit code IF we're in Transmit mode
@@ -1092,7 +1108,17 @@
 #ifdef WLED_DEBUG
       fftTime = sampleTime = 0;
 #endif
+      // gracefully suspend FFT task (if running)
       disableSoundProcessing = true;
+
+      // reset sound data
+      micDataReal = 0.0f;
+      volumeRaw = 0; volumeSmth = 0;
+      sampleAgc = 0; sampleAvg = 0;
+      sampleRaw = 0; rawSampleAgc = 0;
+      my_magnitude = 0; FFT_Magnitude = 0; FFT_MajorPeak = 0;
+      multAgc = 1;
+
       if (init && FFT_Task) {
         vTaskSuspend(FFT_Task);   // update is about to begin, disable task to prevent crash
       } else {
@@ -1111,6 +1137,7 @@
 //            , 0                                 // Core where the task should run
           );
       }
+      micDataReal = 0.0f;                      // just to ber sure
       if (enabled) disableSoundProcessing = false;
     }

@@ -1140,6 +1167,7 @@
      */
     void addToJsonInfo(JsonObject& root)
     {
+      char myStringBuffer[16]; // buffer for snprintf()
       JsonObject user = root["u"];
       if (user.isNull()) user = root.createNestedObject("u");

@@ -1166,6 +1194,75 @@
         uiDomString += inputLevel;
         uiDomString += F(" />

"); //<output class=\"sliderbubble\"></output>
         infoArr.add(uiDomString);
+
+        // current Audio input
+        infoArr = user.createNestedArray(F("Audio Source"));
+        if (audioSyncEnabled & 0x02) {
+            // UDP sound sync - receive mode
+            infoArr.add("UDP sound sync");
+            if (udpSyncConnected) {
+              if (millis() - last_UDPTime < 2500)
+                infoArr.add(" - receiving");
+              else
+                infoArr.add(" - idle");
+            } else {
+              infoArr.add(" - no network");
+            }
+        } else {
+          // Analog or I2S digital input
+          if (audioSource && (audioSource->isInitialized())) {
+              // audio source sucessfully configured
+              if(audioSource->getType() == AudioSource::Type_I2SAdc) {
+                infoArr.add("ADC analog");
+              } else {
+                infoArr.add("I2S digital");
+              }
+              // input level or "silence"
+              if (maxSample5sec > 1.0) {
+                float my_usage = 100.0f * (maxSample5sec / 255.0f);
+                snprintf(myStringBuffer, 15, " - peak %3d%%", int(my_usage));
+                infoArr.add(myStringBuffer);
+              } else {
+                infoArr.add(" -    quiet");
+              }
+          } else {
+              // error during audio source setup
+              infoArr.add("not initialized");
+              infoArr.add(" - check GPIO config");
+          }
+        }
+
+        // Sound processing (FFT and input filters)
+        infoArr = user.createNestedArray(F("Sound Processing"));
+        if (audioSource && (disableSoundProcessing == false)) {
+              infoArr.add("running");
+        } else {
+            infoArr.add("suspended");
+        }
+
+        // AGC or manual Gain
+        if((soundAgc==0) && (disableSoundProcessing == false) && !(audioSyncEnabled & 0x02)) {
+          infoArr = user.createNestedArray(F("Manual Gain"));
+          float myGain = ((float)sampleGain/40.0f * (float)inputLevel/128.0f) + 1.0f/16.0f;     // non-AGC gain from presets
+          infoArr.add(roundf(myGain*100.0f) / 100.0f);
+          infoArr.add("x");
+        }
+        if(soundAgc && (disableSoundProcessing == false) && !(audioSyncEnabled & 0x02)) {
+          infoArr = user.createNestedArray(F("AGC Gain"));
+          infoArr.add(roundf(multAgc*100.0f) / 100.0f);
+          infoArr.add("x");
+        }
+
+        // UDP Sound Sync status
+        infoArr = user.createNestedArray(F("UDP Sound Sync"));
+        if (audioSyncEnabled) {
+            if (audioSyncEnabled & 0x01) {
+              infoArr.add("send mode");
+            } else if (audioSyncEnabled & 0x02) {
+                infoArr.add("receive mode");
+            }
+        } else
+            infoArr.add("off");

         #ifdef WLED_DEBUG
         infoArr = user.createNestedArray(F("Sampling time"));


AR: use more accurate timer for benchmarking

use  esp_timer_get_time() because it is more accurate. Actually I don't trust millis() so much ;-)

--- usermods/audioreactive/audio_reactive.h
+++ usermods/audioreactive/audio_reactive.h
@@ -5,6 +5,10 @@

 #ifndef ESP32
   #error This audio reactive usermod does not support the ESP8266.
+#endif
+
+#ifdef WLED_DEBUG
+#include <esp_timer.h>
 #endif

 /*
@@ -31,7 +35,8 @@

 constexpr i2s_port_t I2S_PORT = I2S_NUM_0;
 constexpr int BLOCK_SIZE = 128;
-constexpr int SAMPLE_RATE = 20480;      // Base sample rate in Hz
+constexpr int SAMPLE_RATE = 20480;      // Base sample rate in Hz - 20Khz is experimental
+//constexpr int SAMPLE_RATE = 10240;      // Base sample rate in Hz - standard

 // #define MIC_LOGGER
 // #define MIC_SAMPLING_LOG
@@ -136,13 +141,18 @@
     if (audioSyncEnabled & 0x02) continue;

 #ifdef WLED_DEBUG
-    unsigned long start = millis();
+//    unsigned long start = millis();
+    uint64_t start = esp_timer_get_time();
 #endif

     if (audioSource) audioSource->getSamples(vReal, samplesFFT);

 #ifdef WLED_DEBUG
-    sampleTime = ((millis() - start)*3 + sampleTime*7)/10; // smooth
+    //sampleTime = ((millis() - start)*3 + sampleTime*7)/10; // smooth
+    if (start < esp_timer_get_time()) { // filter out overflows
+      unsigned long sampleTimeInMillis = (esp_timer_get_time() - start +500ULL) / 1000ULL; // "+500" to ensure proper rounding
+      sampleTime = (sampleTimeInMillis*3 + sampleTime*7)/10; // smooth
+    }
 #endif

     // old code - Last sample in vReal is our current mic sample
@@ -297,7 +307,11 @@
     micDataReal = maxSample2;

 #ifdef WLED_DEBUG
-    fftTime = ((millis() - start)*3 + fftTime*7)/10;
+    //fftTime = ((millis() - start)*3 + fftTime*7)/10;
+    if (start < esp_timer_get_time()) { // filter out overflows
+      unsigned long fftTimeInMillis = ((esp_timer_get_time() - start) +500ULL) / 1000ULL; // "+500" to ensure proper rounding
+      fftTime  = (fftTimeInMillis*3 + fftTime*7)/10; // smooth
+    }
 #endif

 #ifdef SR_DEBUG


Fixed identation.

Fixed identation.

--- src/pp/relic_ep2_mul_fix.c
+++ src/pp/relic_ep2_mul_fix.c
@@ -39,7 +39,7 @@
 /* Private definitions                                                        */
 /*============================================================================*/

-#if EP_FIX == LWNAF || EP_FIX == GLV || !defined(STRIP)
+#if EP_FIX == LWNAF || !defined(STRIP)

 /**
  * Precomputes a table for a point multiplication on an ordinary curve.
@@ -47,7 +47,7 @@
  * @param[out] t				- the destination table.
  * @param[in] p					- the point to multiply.
  */
-static void ep2_mul_pre_ordin(ep2_t * t, ep2_t p) {
+static void ep2_mul_pre_ordin(ep2_t *t, ep2_t p) {
 	int i;

 	ep2_dbl(t[0], p);
@@ -79,7 +79,7 @@
  * @param[in] p					- the point to multiply.
  * @param[in] k					- the integer.
  */
-static void ep2_mul_fix_ordin(ep2_t r, ep2_t * table, bn_t k) {
+static void ep2_mul_fix_ordin(ep2_t r, ep2_t *table, bn_t k) {
 	int len, i, n;
 	signed char naf[FP_BITS + 1], *t;

@@ -111,7 +111,7 @@

 #if EP_FIX == BASIC || !defined(STRIP)

-void ep2_mul_pre_basic(ep2_t * t, ep2_t p) {
+void ep2_mul_pre_basic(ep2_t *t, ep2_t p) {
 	bn_t n;

 	bn_null(n);
@@ -134,7 +134,7 @@
 	}
 }

-void ep2_mul_fix_basic(ep2_t r, ep2_t * t, bn_t k) {
+void ep2_mul_fix_basic(ep2_t r, ep2_t *t, bn_t k) {
 	int i, l;

 	l = bn_bits(k);
@@ -217,7 +217,7 @@

 #if EP_FIX == NAFWI || !defined(STRIP)

-void ep2_mul_pre_nafwi(ep2_t * t, ep2_t p) {
+void ep2_mul_pre_nafwi(ep2_t *t, ep2_t p) {
 	int l;
 	bn_t n;

@@ -246,7 +246,7 @@
 	}
 }

-void ep2_mul_fix_nafwi(ep2_t r, ep2_t * t, bn_t k) {
+void ep2_mul_fix_nafwi(ep2_t r, ep2_t *t, bn_t k) {
 	int i, j, l, d, m;
 	ep2_t a;
 	signed char naf[FP_BITS + 1];
@@ -306,7 +306,7 @@

 #if EP_FIX == COMBS || !defined(STRIP)

-void ep2_mul_pre_combs(ep2_t * t, ep2_t p) {
+void ep2_mul_pre_combs(ep2_t *t, ep2_t p) {
 	int i, j, l;
 	bn_t ord;

@@ -348,7 +348,7 @@
 	}
 }

-void ep2_mul_fix_combs(ep2_t r, ep2_t * t, bn_t k) {
+void ep2_mul_fix_combs(ep2_t r, ep2_t *t, bn_t k) {
 	int i, j, l, w, n0, p0, p1;
 	bn_t n;

@@ -404,7 +404,7 @@

 #if EP_FIX == COMBD || !defined(STRIP)

-void ep2_mul_pre_combd(ep2_t * t, ep2_t p) {
+void ep2_mul_pre_combd(ep2_t *t, ep2_t p) {
 	int i, j, d, e;
 	bn_t n;

@@ -453,7 +453,7 @@
 	}
 }

-void ep2_mul_fix_combd(ep2_t r, ep2_t * t, bn_t k) {
+void ep2_mul_fix_combd(ep2_t r, ep2_t *t, bn_t k) {
 	int i, j, d, e, w0, w1, n0, p0, p1;
 	bn_t n;

@@ -507,13 +507,14 @@

 #endif

-#if EP_FIX == LWNAF || EP_FIX == GLV || !defined(STRIP)
-
-void ep2_mul_pre_lwnaf(ep2_t * t, ep2_t p) {
+#if EP_FIX == LWNAF || !defined(STRIP)
+
+void ep2_mul_pre_lwnaf(ep2_t *t, ep2_t p) {
 	ep2_mul_pre_ordin(t, p);
 }

-void ep2_mul_fix_lwnaf(ep2_t r, ep2_t * t, bn_t k) {
+void ep2_mul_fix_lwnaf(ep2_t r, ep2_t *t, bn_t k) {
 	ep2_mul_fix_ordin(r, t, k);
 }
-#endif
+
+#endif


GUACAMOLE-326: Explicitly deny attempted reads/writes to Windows named data streams (like "foo:Zone.identifier" for the file "foo").

--- src/protocols/rdp/rdp_fs.c
+++ src/protocols/rdp/rdp_fs.c
@@ -654,6 +654,10 @@

         } /* end if separator */

+        /* We do not currently support named streams */
+        else if (c == ':')
+            return 1;
+
     } /* end for each character */

     /* If no components, the path is simply root */


Implement malloc, realloc, calloc funcitons.

Compile with: gcc -shared -fPIC -o memoryalloc.so
Run with: export LD_PRELOAD=$PWD/memoryalloc.so

--- memoryalloc.c
+++ memoryalloc.c
@@ -66,4 +66,100 @@
 void* malloc(size_t size)
 {
 	size_t total_size;
+	void *block;
+	struct header_t* header;

+	if (!size) {
+		return NULL;
+	}
+
+	pthread_mutex_lock(&global_malloc_lock);
+
+	header = get_free_block(size);
+
+	if (header) {
+		header->is_free = 0;
+
+		pthread_mutex_unlock(&global_malloc_lock);
+
+		return (void*)(header + 1);
+	}
+
+	total_size = sizeof(struct header_t) + size;
+	block = sbrk(total_size);
+
+	if (block == (void*) -1) {
+		pthread_mutex_unlock(&global_malloc_lock);
+		return NULL;
+	}
+
+	header = block;
+	header->size = size;
+	header->is_free = 0;
+	header->next = NULL;
+
+	if (!head) {
+		head = header;
+	}
+	if (tail) {
+		tail->next = header;
+	}
+	tail = header;
+
+	pthread_mutex_unlock(&global_malloc_lock);
+
+	return (void*)(header + 1);
+}
+
+void* calloc(size_t num, size_t nsize)
+{
+	size_t size;
+	void* block;
+
+	if (!num || !nsize) {
+		return NULL;
+	}
+
+	size = num * nsize;
+
+	if (nsize != size / num) {
+		return NULL;
+	}
+
+	block = malloc(size);
+
+	if (!block) {
+		return NULL;
+	}
+
+	memset(block, 0, size);
+
+	return block;
+}
+
+void* realloc(void* block, size_t size)
+{
+	struct header_t* header;
+	void* ret;
+
+	if (!block || !size) {
+		return malloc(size);
+	}
+
+	header = (struct header_t*)block - 1;
+
+	if (header->size >= size) {
+		return block;
+	}
+
+	ret = malloc(size);
+
+	if (ret) {
+		memcpy(ret, block, header->size);
+
+		free(block);
+	}
+
+	return ret;
+}
+


fix(pubsub): Ensure that shutdown does not take the mutex twice

--- src/pubsub/ua_pubsub_ns0.c
+++ src/pubsub/ua_pubsub_ns0.c
@@ -804,7 +804,7 @@
 UA_StatusCode
 removeDataSetReaderRepresentation(UA_Server *server,
                                   UA_DataSetReader* dataSetReader) {
-    return UA_Server_deleteNode(server, dataSetReader->identifier, true);
+    return deleteNode(server, dataSetReader->identifier, true);
 }

 #ifdef UA_ENABLE_PUBSUB_INFORMATIONMODEL_METHODS
@@ -1048,7 +1048,7 @@
 UA_StatusCode
 removePublishedDataSetRepresentation(UA_Server *server,
                                      UA_PublishedDataSet *publishedDataSet) {
-    return UA_Server_deleteNode(server, publishedDataSet->identifier, true);
+    return deleteNode(server, publishedDataSet->identifier, true);
 }

 #ifdef UA_ENABLE_PUBSUB_INFORMATIONMODEL_METHODS


(fix) fixing pubsub dataset representation in information model

published datasets should be connected via hasComponent reference

--- src/pubsub/ua_pubsub_ns0.c
+++ src/pubsub/ua_pubsub_ns0.c
@@ -889,7 +889,7 @@
     object_attr.displayName = UA_LOCALIZEDTEXT("", pdsName);
     retVal = UA_Server_addObjectNode(server, UA_NODEID_NUMERIC(1, 0), /* Create a new id */
                        UA_NODEID_NUMERIC(0, UA_NS0ID_PUBLISHSUBSCRIBE_PUBLISHEDDATASETS),
-                       UA_NODEID_NUMERIC(0, UA_NS0ID_HASPROPERTY),
+                       UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT),
                        UA_QUALIFIEDNAME(0, pdsName),
                        UA_NODEID_NUMERIC(0, UA_NS0ID_PUBLISHEDDATAITEMSTYPE),
                        object_attr, NULL, &publishedDataSet->identifier);


Update the copyright notice

Update the copyright notice

--- src/unistd.c
+++ src/unistd.c
@@ -1,5 +1,5 @@
 /* $Id$ */
-/* Copyright (c) 2004-2015 Pierre Pronchery <khorben@defora.org> */
+/* Copyright (c) 2004-2016 Pierre Pronchery <khorben@defora.org> */
 /* This file is part of DeforaOS System libc */
 /* All rights reserved.
  *


Update itag link

Update itag link

Moved from main Wikipedia page to talk page.

--- XCDYouTubeKit/XCDYouTubeVideo.h
+++ XCDYouTubeKit/XCDYouTubeVideo.h
@@ -15,7 +15,7 @@
 /**
  *  The quality of YouTube videos. These values are used as keys in the `<[XCDYouTubeVideo streamURLs]>` property.
  *
- *  The constant numbers are the YouTube [itag](https://en.wikipedia.org/wiki/YouTube#Quality_and_formats) values.
+ *  The constant numbers are the YouTube [itag](https://en.wikipedia.org/wiki/Talk:YouTube#Moved_from_YouTube.23Quality_formats) values.
  */
 typedef NS_ENUM(NSUInteger, XCDYouTubeVideoQuality) {
 	/**


[upload-mode] Int parsing

[upload-mode] Int parsing

--- src/upload.c
+++ src/upload.c
@@ -71,7 +71,7 @@
     tmpfd = mkstemp((char *)tmp_name->data);
     check(tmpfd != -1, "Failed to create secure tempfile, did you end it with XXXXXX?");
     log_info("Writing tempfile %s for large upload.", bdata(tmp_name));
-    log_info("Will set mode to: %s", bdata(UPLOAD_MODE));
+    log_info("Will set mode to: %s %lu", bdata(UPLOAD_MODE), strtoul(bdata(UPLOAD_MODE), NULL, 0));

     rc = Upload_notify(conn, handler, "start", tmp_name);


Make sure we conform to ANSI C in variable declaration

--- src/uthash.h
+++ src/uthash.h
@@ -203,8 +203,7 @@
     add->hh.prev = NULL;                                                         \
     head = add;                                                                  \
     HASH_MAKE_TABLE(hh,head);                                                    \
- } else {                                                                        \
-   add->hh.tbl = head->hh.tbl;
+ } else {

 #define HASH_ADD_EPILOGUE(hh,head,keyptr,keylen_in,add)                          \
       HASH_APPEND_LIST(hh, head, add);                                           \
@@ -220,6 +219,7 @@

 #define HASH_SADD_KEYPTR(hh,head,keyptr,keylen_in,add,cmpfcn)                    \
     HASH_ADD_PREAMBLE(hh,(head),(keyptr),(keylen_in),(add))                      \
+    (add)->hh.tbl = (head)->hh.tbl;                                              \
     struct UT_hash_handle *iter = &(head)->hh;                                   \
     do {                                                                         \
       if(cmpfcn(DECLTYPE(head) ELMT_FROM_HH((head)->hh.tbl, iter), add) > 0)     \
@@ -241,6 +241,7 @@

 #define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add)                            \
     HASH_ADD_PREAMBLE(hh,(head),(keyptr),(keylen_in),(add))                      \
+    (add)->hh.tbl = (head)->hh.tbl;                                              \
     HASH_ADD_EPILOGUE(hh,(head),(keyptr),(keylen_in),(add))

 #define HASH_TO_BKT( hashv, num_bkts, bkt )                                      \


Fix circular reference memory leaks

Fix circular reference memory leaks

When dispatching the promise result, we need to clear both handlers and catchers to prevent retaining circular references when the promise is captured into the handler and/or catcher. Also refactor part of the `notify` logic.

--- src/qtpromise/qpromise_p.h
+++ src/qtpromise/qpromise_p.h
@@ -331,11 +331,12 @@

 template <typename T> class PromiseData;

-template <typename T>
+template <typename T, typename F>
 class PromiseDataBase : public QSharedData
 {
 public:
     using Error = QtPromise::QPromiseError;
+    using Handler = std::pair<QPointer<QThread>, std::function<F> >;
     using Catcher = std::pair<QPointer<QThread>, std::function<void(const Error&)> >;

     virtual ~PromiseDataBase() {}
@@ -354,6 +355,12 @@
     {
         QReadLocker lock(&m_lock);
         return !m_settled;
+    }
+
+    void addHandler(std::function<F> handler)
+    {
+        QWriteLocker lock(&m_lock);
+        m_handlers.append({QThread::currentThread(), std::move(handler)});
     }

     void addCatcher(std::function<void(const Error&)> catcher)
@@ -376,14 +383,22 @@
             return;
         }

-        if (m_error.isNull()) {
-            notify();
-            return;
-        }
+        // A promise can't be resolved multiple times so once settled, its state can't
+        // change. When fulfilled, handlers must be called (a single time) and catchers
+        // ignored indefinitely (or vice-versa when the promise is rejected), so make
+        // sure to clear both handlers AND catchers when dispatching. This also prevents
+        // shared pointer circular reference memory leaks when the owning promise is
+        // captured in the handler and/or catcher lambdas.

         m_lock.lockForWrite();
+        QVector<Handler> handlers(std::move(m_handlers));
         QVector<Catcher> catchers(std::move(m_catchers));
         m_lock.unlock();
+
+        if (m_error.isNull()) {
+            notify(handlers);
+            return;
+        }

         QSharedPointer<Error> error = m_error;
         Q_ASSERT(!error.isNull());
@@ -406,26 +421,21 @@
         m_settled = true;
     }

-    virtual void notify() = 0;
+    virtual void notify(const QVector<Handler>&) = 0;

 private:
     bool m_settled = false;
+    QVector<Handler> m_handlers;
     QVector<Catcher> m_catchers;
     QSharedPointer<Error> m_error;
 };

 template <typename T>
-class PromiseData : public PromiseDataBase<T>
-{
-    using Handler = std::pair<QPointer<QThread>, std::function<void(const T&)> >;
+class PromiseData : public PromiseDataBase<T, void(const T&)>
+{
+    using Handler = typename PromiseDataBase<T, void(const T&)>::Handler;

 public:
-    void addHandler(std::function<void(const T&)> handler)
-    {
-        QWriteLocker lock(&this->m_lock);
-        m_handlers.append({QThread::currentThread(), std::move(handler)});
-    }
-
     void resolve(T&& value)
     {
         Q_ASSERT(m_value.isNull());
@@ -440,12 +450,8 @@
         this->setSettled();
     }

-    void notify() Q_DECL_OVERRIDE
-    {
-        this->m_lock.lockForWrite();
-        QVector<Handler> handlers(std::move(m_handlers));
-        this->m_lock.unlock();
-
+    void notify(const QVector<Handler>& handlers) Q_DECL_OVERRIDE
+    {
         QSharedPointer<T> value(m_value);
         Q_ASSERT(!value.isNull());

@@ -458,38 +464,24 @@
     }

 private:
-    QVector<Handler> m_handlers;
     QSharedPointer<T> m_value;
 };

 template <>
-class PromiseData<void> : public PromiseDataBase<void>
-{
-    using Handler = std::pair<QPointer<QThread>, std::function<void()> >;
+class PromiseData<void> : public PromiseDataBase<void, void()>
+{
+    using Handler = typename PromiseDataBase<void, void()>::Handler;

 public:
-    void addHandler(std::function<void()> handler)
-    {
-        QWriteLocker lock(&m_lock);
-        m_handlers.append({QThread::currentThread(), std::move(handler)});
-    }
-
     void resolve() { setSettled(); }

 protected:
-    void notify() Q_DECL_OVERRIDE
-    {
-        this->m_lock.lockForWrite();
-        QVector<Handler> handlers(std::move(m_handlers));
-        this->m_lock.unlock();
-
+    void notify(const QVector<Handler>& handlers) Q_DECL_OVERRIDE
+    {
         for (const auto& handler: handlers) {
             qtpromise_defer(handler.second, handler.first);
         }
     }
-
-private:
-    QVector<Handler> m_handlers;
 };

 } // namespace QtPromise


GC: bufqueues are not used under -current, we use bioqueues.

--- sys/sys/buf.h
+++ sys/sys/buf.h
@@ -385,53 +385,6 @@
 };

 #ifdef _KERNEL
-static __inline void bufq_init __P((struct buf_queue_head *head));
-static __inline void bufq_insert_tail __P((struct buf_queue_head *head,
-					   struct buf *bp));
-static __inline void bufq_remove __P((struct buf_queue_head *head,
-				      struct buf *bp));
-static __inline struct buf *bufq_first __P((struct buf_queue_head *head));
-
-static __inline void
-bufq_init(struct buf_queue_head *head)
-{
-	TAILQ_INIT(&head->queue);
-	head->last_pblkno = 0;
-	head->insert_point = NULL;
-	head->switch_point = NULL;
-}
-
-static __inline void
-bufq_insert_tail(struct buf_queue_head *head, struct buf *bp)
-{
-	if ((bp->b_ioflags & BIO_ORDERED) != 0) {
-		head->insert_point = bp;
-		head->switch_point = NULL;
-	}
-	TAILQ_INSERT_TAIL(&head->queue, bp, b_act);
-}
-
-static __inline void
-bufq_remove(struct buf_queue_head *head, struct buf *bp)
-{
-	if (bp == head->switch_point)
-		head->switch_point = TAILQ_NEXT(bp, b_act);
-	if (bp == head->insert_point) {
-		head->insert_point = TAILQ_PREV(bp, buf_queue, b_act);
-		if (head->insert_point == NULL)
-			head->last_pblkno = 0;
-	} else if (bp == TAILQ_FIRST(&head->queue))
-		head->last_pblkno = bp->b_pblkno;
-	TAILQ_REMOVE(&head->queue, bp, b_act);
-	if (TAILQ_FIRST(&head->queue) == head->switch_point)
-		head->switch_point = NULL;
-}
-
-static __inline struct buf *
-bufq_first(struct buf_queue_head *head)
-{
-	return (TAILQ_FIRST(&head->queue));
-}

 #define BUF_WRITE(bp)					\
 	(bp)->b_op->bop_write(bp)


Fixing signed/unsigned mismatch warning showing up in gyp build.

BUG=None
TEST=None
TBR=gman

Review URL: http://codereview.chromium.org/248026

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@27431 0039d316-1c4b-4281-b951-d872f2087c98

--- o3d/command_buffer/common/cross/cmd_buffer_format.h
+++ o3d/command_buffer/common/cross/cmd_buffer_format.h
@@ -179,8 +179,8 @@
   Uint32 command:24;

   void Init(uint32 _command, uint32 _size) {
-    DCHECK_LT(_size, 256);
-    DCHECK_LT(_command, static_cast<int>(kNumCommands));
+    DCHECK_LT(_size, 256u);
+    DCHECK_LT(_command, static_cast<unsigned int>(kNumCommands));
     command = _command;
     size = _size;
   }


Fixing a mispelling

Fixing a mispelling

--- PWGGA/EMCALTasks/AliAnalysisTaskEMCALPhotonIsolation.h
+++ PWGGA/EMCALTasks/AliAnalysisTaskEMCALPhotonIsolation.h
@@ -127,7 +127,7 @@
   void                         SetPythiaVersion            ( TString pythiaVersion                        ) { fPythiaVersion = pythiaVersion;                           }
   void                         SetVariableCPV              ( Bool_t  variable                             ) { fVariableCPV = variable;                                  }
   void                         SetVariableCPVInCone        ( Bool_t  variable                             ) { fVariableCPVInCone = variable;                            }
-  void                         SetVariableCPVSystematics   ( TString systematic                           ) { fVariableCPVSyst = systematic;                            }
+  void                         SetVariableCPVSystematics   ( TString systematics                          ) { fVariableCPVSyst = systematics;                           }
   void                         SetNonLinRecoEnergyScaling  ( Bool_t  scaling                              ) { fNonLinRecoEnergyScaling = scaling;                       }

  protected:


Implemented clustered dataset generator

Implemented clustered dataset generator

--- data/tests/TestDatasetGenerators.h
+++ data/tests/TestDatasetGenerators.h
@@ -4,6 +4,7 @@
 #include <gtest/gtest.h>
 #include "UniformDatasetGenerator.h"
 #include "RandomPointGenerator.h"
+#include "ClusteredDatasetGenerator.h"
 #include "SkewedDatasetGenerator.h"

 namespace mdsearch { namespace tests
@@ -143,6 +144,47 @@
 		}
 	}

+	TEST_F(DatasetGeneratorTests, ClusteredData)
+	{
+		// NOTE: Tests which validate the generated points are actually clustered
+		// in space will be in the RandomPointGenerator class tests, as the clustered
+		// points are actually generated using that.
+
+		ClusteredDatasetGenerator generator;
+
+		// Construct test data
+		Region testRegions[] = {
+			Region(3, Interval(1, 10)),
+			Region(3, Interval(84, 132)),
+			Region(3, Interval(50, 50))
+		};
+		Point zeroSizedRegionPoint = Point(3, 50);
+
+		std::vector<ClusterSpecification> oneCluster;
+		oneCluster.push_back( ClusterSpecification(testRegions[0], 10) );
+		std::vector<ClusterSpecification> twoClusters;
+		twoClusters.push_back( ClusterSpecification(testRegions[0], 10) );
+		twoClusters.push_back( ClusterSpecification(testRegions[1], 100) );
+		std::vector<ClusterSpecification> twoClustersWithZeroSized;
+		twoClustersWithZeroSized.push_back( ClusterSpecification(testRegions[1], 100) );
+		twoClustersWithZeroSized.push_back( ClusterSpecification(testRegions[2], 5) );
+
+		// Test no cluster specifications given
+		EXPECT_EQ(PointList(), generator.generate(3, std::vector<ClusterSpecification>()));
+		// Test one cluster
+		PointList oneClusterPoints = generator.generate(3, oneCluster);
+		EXPECT_EQ(10, oneClusterPoints.size());
+		// Test two clusters
+		PointList twoClusterPoints = generator.generate(3, twoClusters);
+		EXPECT_EQ(110, twoClusterPoints.size());
+		// Test two clusters, one with zero-sized region
+		PointList twoClustersWithZeroSizedPoints = generator.generate(3, twoClustersWithZeroSized);
+		EXPECT_EQ(105, twoClustersWithZeroSizedPoints.size());
+		// Ensure zero-sized region's points were generated correctly
+		for (unsigned int i = 100; (i < 105); i++)
+			ASSERT_EQ(twoClustersWithZeroSizedPoints[i], zeroSizedRegionPoint);
+	}
+
 	TEST_F(DatasetGeneratorTests, SkewedDatasetGenerator)
 	{
 		SkewedDatasetGenerator generator;
@@ -186,7 +228,6 @@
 			ASSERT_EQ(minPoint1D, *it);
 		}

-
 		// Repeat above tests where the data is skewed towards the upper values
 		skewDir = SKEW_DIRECTION_RIGHT;
 		oneDPoints = generator.generate(1, minPoint1D, maxPoint1D,
@@ -218,11 +259,6 @@
 		}
 	}

-	TEST_F(DatasetGeneratorTests, ClusteredData)
-	{
-		// TODO
-	}
-
 } }

 #endif


Bring in the trivial differences between this code and John Hay's new
code.  Added a copyright for the work I did to this file a couple of
years ago.  Add John's copyright too, since I'm sure I'll be pulling
more into this code.  This also implements a new -n option to not
allow breaking into the boot sequence which was original in the patch
John posted (not in the original i386 code I based this boot2.c on,
only the name is the same).  I haven't checked to see if he did that,
or if it was one of Sam's improvements.

Submitted by:	jhay@

--- sys/boot/arm/at91/boot2/boot2.c
+++ sys/boot/arm/at91/boot2/boot2.c
@@ -1,4 +1,6 @@
 /*-
+ * Copyright (c) 2008 John Hay
+ * Copyright (c) 2006 Warner Losh
  * Copyright (c) 1998 Robert Nordier
  * All rights reserved.
  *
@@ -51,7 +53,7 @@
 /* 0x13 is reserved for boot programs. */
 /* #define RBX_PAUSE	0x14	   -p */
 /* #define RBX_QUIET	0x15	   -q */
-/* #define RBX_NOINTR	0x1c	   -n */
+#define RBX_NOINTR	0x1c	/* -n */
 /* 0x1d is reserved for log2(RB_MULTIPLE) and is just misnamed here. */
 /* #define RBX_DUAL	0x1d	   -D */
 /* 0x1f is reserved for log2(RB_BOOTINFO). */
@@ -66,20 +68,21 @@
 //#define PATH_KERNEL	"/boot/kernel/kernel"
 #define PATH_KERNEL	"/boot/kernel/kernel.gz.tramp"

-#define NOPT		5
+extern uint32_t _end;
+
+#define NOPT		6

 #define OPT_SET(opt)	(1 << (opt))
 #define OPT_CHECK(opt)	((opts) & OPT_SET(opt))

-extern uint32_t _end;
-
-static const char optstr[NOPT] = "agrsv";
+static const char optstr[NOPT] = "agnrsv";
 static const unsigned char flags[NOPT] = {
-    RBX_ASKNAME,
-    RBX_GDB,
-    RBX_DFLTROOT,
-    RBX_SINGLE,
-    RBX_VERBOSE
+	RBX_ASKNAME,
+	RBX_GDB,
+	RBX_NOINTR,
+	RBX_DFLTROOT,
+	RBX_SINGLE,
+	RBX_VERBOSE
 };

 unsigned dsk_start;
@@ -95,6 +98,12 @@

 #define	UFS_SMALL_CGBASE
 #include "ufsread.c"
+
+#ifdef DEBUG
+#define	DPRINTF(fmt, ...) printf(fmt, __VA_ARGS__)
+#else
+#define	DPRINTF(fmt, ...)
+#endif

 static inline int
 xfsread(ino_t inode, void *buf, size_t nbyte)
@@ -142,31 +151,31 @@
 	int autoboot, c = 0;
 	ino_t ino;

+	dmadat = (void *)(0x20000000 + (16 << 20));
 	board_init();

-	dmadat = (void *)(0x20000000 + (16 << 20));
+	autoboot = 1;
+
 	/* Process configuration file */
-
-	autoboot = 1;
-
 	if ((ino = lookup(PATH_CONFIG)))
 		fsread(ino, cmd, sizeof(cmd));

 	if (*cmd) {
 		if (parse())
 			autoboot = 0;
-		printf("%s: %s", PATH_CONFIG, cmd);
+		printf("%s: %s\n", PATH_CONFIG, cmd);
 		/* Do not process this command twice */
 		*cmd = 0;
 	}

-	/* Present the user with the boot2 prompt. */
-
 	if (*kname == '\0')
 		strcpy(kname, PATH_KERNEL);
+
+	/* Present the user with the boot2 prompt. */
 	for (;;) {
 		printf("\nDefault: %s\nboot: ", kname);
-		if (!autoboot || (c = getc(2)) != -1)
+		if (!autoboot ||
+		    (OPT_CHECK(RBX_NOINTR) == 0 && (c = getc(2)) != 0))
 			getstr(c);
 		xputchar('\n');
 		autoboot = 0;


Fix the 'DEBUG' argument code to unbreak the amd64 LINT build.

--- sys/compat/linux/linux_signal.c
+++ sys/compat/linux/linux_signal.c
@@ -188,7 +188,7 @@
 #ifdef DEBUG
 	if (ldebug(signal))
 		printf(ARGS(signal, "%d, %p"),
-		    args->sig, (void *)args->handler);
+		    args->sig, (void *)(uintptr_t)args->handler);
 #endif

 	nsa.lsa_handler = args->handler;