diff options
author | Tim Mayberry <mojofunk@gmail.com> | 2007-11-15 02:31:23 +0000 |
---|---|---|
committer | Tim Mayberry <mojofunk@gmail.com> | 2007-11-15 02:31:23 +0000 |
commit | 1bffd1c209fdb132ccedb3f331db885484e69fde (patch) | |
tree | 6c43a43b423490e576f234ce37fba0ed47875473 | |
parent | 4f7e6c0714fd385bbe68acc223c951ef9a07c1b9 (diff) |
Use std::vector and boost::shared_array instead of raw arrays for channel data in Session::import_audiofile
git-svn-id: svn://localhost/ardour2/trunk@2659 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | libs/ardour/import.cc | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc index 94bb309e75..9999f17340 100644 --- a/libs/ardour/import.cc +++ b/libs/ardour/import.cc @@ -32,6 +32,7 @@ #include <glibmm.h> #include <boost/scoped_array.hpp> +#include <boost/shared_array.hpp> #include <pbd/basename.h> #include <pbd/convert.h> @@ -96,7 +97,6 @@ Session::import_audiofile (import_status& status) { vector<boost::shared_ptr<AudioFileSource> > newfiles; SF_INFO info; - Sample **channel_data = 0; int nfiles = 0; string basepath; nframes_t so_far; @@ -157,10 +157,10 @@ Session::import_audiofile (import_status& status) } boost::scoped_array<float> data(new float[nframes * info.channels]); - channel_data = new Sample * [ info.channels ]; - + vector<boost::shared_array<Sample> > channel_data; + for (int n = 0; n < info.channels; ++n) { - channel_data[n] = new Sample[nframes]; + channel_data.push_back(boost::shared_array<Sample>(new Sample[nframes])); } so_far = 0; @@ -205,7 +205,7 @@ Session::import_audiofile (import_status& status) /* flush to disk */ for (chn = 0; chn < info.channels; ++chn) { - newfiles[chn]->write (channel_data[chn], nfread); + newfiles[chn]->write (channel_data[chn].get(), nfread); } so_far += nread; @@ -247,13 +247,6 @@ Session::import_audiofile (import_status& status) ret = 0; out: - - if (channel_data) { - for (int n = 0; n < info.channels; ++n) { - delete [] channel_data[n]; - } - delete [] channel_data; - } if (status.cancel) { |