Use SMFSource static method to look for MIDI file extensions.

git-svn-id: svn://localhost/ardour2/branches/3.0@7120 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2010-05-19 23:36:18 +00:00
parent 6ad69a206c
commit 03bed9a8cb
2 changed files with 6 additions and 7 deletions

View File

@ -47,6 +47,7 @@
#include "ardour/region_factory.h"
#include "ardour/source_factory.h"
#include "ardour/session.h"
#include "ardour/smf_source.h"
#include "pbd/memento_command.h"
#include "ardour_ui.h"
@ -726,8 +727,9 @@ Editor::add_sources (vector<Glib::ustring> paths, SourceList& sources, nframes64
}
// kludge (for MIDI we're abusing "channel" for "track" here)
if (paths.front().rfind(".mid") != Glib::ustring::npos)
if (SMFSource::safe_midi_file_extension (paths.front())) {
target_regions = -1;
}
if (target_regions == 1) {

View File

@ -169,8 +169,7 @@ get_paths_for_new_sources (const bool allow_replacing, const string& import_file
for (uint n = 0; n < channels; ++n) {
const DataType type = (import_file_path.rfind(".mid") != string::npos)
? DataType::MIDI : DataType::AUDIO;
const DataType type = SMFSource::safe_midi_file_extension (import_file_path) ? DataType::MIDI : DataType::AUDIO;
std::string filepath = (type == DataType::MIDI)
? sdir.midi_path().to_string() : sdir.sound_path().to_string();
@ -213,8 +212,7 @@ create_mono_sources_for_writing (const vector<string>& new_paths, Session& sess,
try
{
const DataType type = ((*i).rfind(".mid") != string::npos)
? DataType::MIDI : DataType::AUDIO;
const DataType type = SMFSource::safe_midi_file_extension (*i) ? DataType::MIDI : DataType::AUDIO;
source = SourceFactory::createWritable (type, sess,
@ -453,8 +451,7 @@ Session::import_audiofiles (ImportStatus& status)
{
boost::shared_ptr<ImportableSource> source;
std::auto_ptr<Evoral::SMF> smf_reader;
const DataType type = ((*p).rfind(".mid") != string::npos) ?
DataType::MIDI : DataType::AUDIO;
const DataType type = SMFSource::safe_midi_file_extension (*p) ? DataType::MIDI : DataType::AUDIO;
if (type == DataType::AUDIO) {
try {