summaryrefslogtreecommitdiff
path: root/libs/evoral
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2014-06-02 11:32:13 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2014-06-02 11:32:13 -0400
commit8c9749e42faf7808034ed8b7afce4a2fe6dc6f33 (patch)
tree823af8a96f4e0b2a404f5e52eadf4f46e1d10229 /libs/evoral
parentf6d29abfc75c460b9e35717f2907e4e61bf38058 (diff)
parent08a1409b1f5b5558d2eccc28a3ae4cbd44391812 (diff)
merge with master and fix 4 conflicts by hand
Diffstat (limited to 'libs/evoral')
-rw-r--r--libs/evoral/evoral/SMF.hpp1
-rw-r--r--libs/evoral/src/SMF.cpp22
-rw-r--r--libs/evoral/test/SequenceTest.cpp2
3 files changed, 24 insertions, 1 deletions
diff --git a/libs/evoral/evoral/SMF.hpp b/libs/evoral/evoral/SMF.hpp
index 91bc928d9a..fe81b8f044 100644
--- a/libs/evoral/evoral/SMF.hpp
+++ b/libs/evoral/evoral/SMF.hpp
@@ -52,6 +52,7 @@ public:
SMF() : _smf(0), _smf_track(0), _empty(true) {};
virtual ~SMF();
+ static bool test(const std::string& path);
int open(const std::string& path, int track=1) THROW_FILE_ERROR;
int create(const std::string& path, int track=1, uint16_t ppqn=19200) THROW_FILE_ERROR;
void close() THROW_FILE_ERROR;
diff --git a/libs/evoral/src/SMF.cpp b/libs/evoral/src/SMF.cpp
index 51ccda583e..dc3512a0f6 100644
--- a/libs/evoral/src/SMF.cpp
+++ b/libs/evoral/src/SMF.cpp
@@ -71,6 +71,28 @@ SMF::seek_to_track(int track)
}
}
+/** Attempt to open the SMF file just to see if it is valid.
+ *
+ * \return true on success
+ * false on failure
+ */
+bool
+SMF::test(const std::string& path)
+{
+ PBD::StdioFileDescriptor d (path, "r");
+ FILE* f = d.allocate ();
+ if (f == 0) {
+ return false;
+ }
+
+ smf_t* test_smf;
+ if ((test_smf = smf_load (f)) == NULL) {
+ return false;
+ }
+ smf_delete (test_smf);
+ return true;
+}
+
/** Attempt to open the SMF file for reading and/or writing.
*
* \return 0 on success
diff --git a/libs/evoral/test/SequenceTest.cpp b/libs/evoral/test/SequenceTest.cpp
index 69931b8e0d..6e07776fdb 100644
--- a/libs/evoral/test/SequenceTest.cpp
+++ b/libs/evoral/test/SequenceTest.cpp
@@ -23,7 +23,7 @@ SequenceTest::preserveEventOrderingTest ()
seq->start_write();
for (Notes::const_iterator i = test_notes.begin(); i != test_notes.end(); ++i) {
- uint8_t buffer[2];
+ uint8_t buffer[3];
Event<Time>* event = new Event<Time>(
DummyTypeMap::CONTROL, (*i)->on_event().time(), 3, buffer, true
);