summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2015-02-06 10:19:58 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2015-02-06 10:33:01 -0500
commit63a1b56560df7f56c8d25c93d0ffeb30997e9325 (patch)
treeba6caa599202d757899998ad295609c4c96fc231 /libs
parent6b9415aedb35d03561ef16d846f08bc0fc7c57c7 (diff)
fix (and comment) on subtle bug with audio file data width function
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/sndfile_helpers.h1
-rw-r--r--libs/ardour/ardour/types.h2
-rw-r--r--libs/ardour/globals.cc23
-rw-r--r--libs/ardour/sndfile_helpers.cc15
4 files changed, 26 insertions, 15 deletions
diff --git a/libs/ardour/ardour/sndfile_helpers.h b/libs/ardour/ardour/sndfile_helpers.h
index b475b082be..1d11375fa6 100644
--- a/libs/ardour/ardour/sndfile_helpers.h
+++ b/libs/ardour/ardour/sndfile_helpers.h
@@ -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);
diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h
index 8cdb372da8..921cb3e39a 100644
--- a/libs/ardour/ardour/types.h
+++ b/libs/ardour/ardour/types.h
@@ -456,6 +456,8 @@ namespace ARDOUR {
FormatInt16
};
+ int format_data_width (ARDOUR::SampleFormat);
+
enum CDMarkerFormat {
CDMarkerNone,
CDMarkerCUE,
diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc
index 1ccb169bfc..ea99420ff5 100644
--- a/libs/ardour/globals.cc
+++ b/libs/ardour/globals.cc
@@ -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;
+ }
+}
diff --git a/libs/ardour/sndfile_helpers.cc b/libs/ardour/sndfile_helpers.cc
index 6a3ce248bc..08c57bfec2 100644
--- a/libs/ardour/sndfile_helpers.cc
+++ b/libs/ardour/sndfile_helpers.cc
@@ -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)
{