fix (and comment) on subtle bug with audio file data width function
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 6 Feb 2015 15:19:58 +0000 (10:19 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 6 Feb 2015 15:33:01 +0000 (10:33 -0500)
libs/ardour/ardour/sndfile_helpers.h
libs/ardour/ardour/types.h
libs/ardour/globals.cc
libs/ardour/sndfile_helpers.cc

index b475b082befd3f8caf305f49325beeff0ddc1c66..1d11375fa639c316cc72b3d29df48ae7e28991c7 100644 (file)
@@ -49,7 +49,6 @@ int sndfile_header_format_by_index (int);
 int sndfile_endian_format_by_index (int);
 
 int sndfile_data_width (int format);
-int sndfile_data_width (ARDOUR::SampleFormat);
 
 // It'd be nice if libsndfile did this for us
 std::string sndfile_major_format (int);
index 8cdb372da822c402fdb7cb26875615a975105a0c..921cb3e39aa4771ea8c839e1a42d10071ee4eab5 100644 (file)
@@ -456,6 +456,8 @@ namespace ARDOUR {
                FormatInt16
        };
 
+       int format_data_width (ARDOUR::SampleFormat);
+
        enum CDMarkerFormat {
                CDMarkerNone,
                CDMarkerCUE,
index 1ccb169bfcd2b93799974df47007f8d30b5af46b..ea99420ff58ed8c1ee5331586fa4c8485eaa1fea 100644 (file)
@@ -609,3 +609,26 @@ ARDOUR::get_microseconds ()
        return (microseconds_t) ts.tv_sec * 1000000 + (ts.tv_nsec/1000);
 #endif
 }
+
+/** Return the number of bits per sample for a given sample format.
+ *
+ * This is closely related to sndfile_data_width() but does NOT
+ * return a "magic" value to differentiate between 32 bit integer
+ * and 32 bit floating point values.
+ */
+
+int
+format_data_width (ARDOUR::SampleFormat format)
+{
+
+
+
+       switch (format) {
+       case ARDOUR::FormatInt16:
+               return 16;
+       case ARDOUR::FormatInt24:
+               return 24;
+       default:
+               return 32;
+       }
+}
index 6a3ce248bce5bf440db1ae2a5a24138251d0c238..08c57bfec2703e8f881fe805c840e5e66d90168f 100644 (file)
@@ -133,26 +133,13 @@ sndfile_data_width (int format)
        case SF_FORMAT_PCM_32:
                return 32;
        case SF_FORMAT_FLOAT:
-               return 32;
+               return 1; /* ridiculous but used as a magic value */
        default:
                // we don't handle anything else within ardour
                return 0;
        }
 }
 
-int
-sndfile_data_width (ARDOUR::SampleFormat format)
-{
-       switch (format) {
-       case ARDOUR::FormatInt16:
-               return sndfile_data_width (SF_FORMAT_PCM_16);
-       case ARDOUR::FormatInt24:
-               return sndfile_data_width (SF_FORMAT_PCM_24);
-       default:
-               return sndfile_data_width (SF_FORMAT_FLOAT);
-       }
-}
-
 string
 sndfile_major_format(int format)
 {