diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-06-01 23:53:06 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-06-01 23:53:06 +0100 |
| commit | a68b877d96a9e9f366f27752e071bc0e895e9dc7 (patch) | |
| tree | 11a32d1efd6abf182b03ce22f1f1fe84258bb7de /src/sound_asset.cc | |
| parent | f9cba324c8160a70b108d9e5b60a4ccad6ee9be2 (diff) | |
Add Reader classes to permit much more efficient DCP reading.
Diffstat (limited to 'src/sound_asset.cc')
| -rw-r--r-- | src/sound_asset.cc | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/sound_asset.cc b/src/sound_asset.cc index 590472a5..ffafe46c 100644 --- a/src/sound_asset.cc +++ b/src/sound_asset.cc @@ -27,6 +27,7 @@ #include "exceptions.h" #include "sound_frame.h" #include "sound_asset_writer.h" +#include "sound_asset_reader.h" #include "compose.hpp" #include "KM_fileio.h" #include "AS_DCP.h" @@ -125,10 +126,13 @@ SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHand shared_ptr<const SoundAsset> other_sound = dynamic_pointer_cast<const SoundAsset> (other); + shared_ptr<const SoundAssetReader> reader = start_read (); + shared_ptr<const SoundAssetReader> other_reader = other_sound->start_read (); + for (int i = 0; i < _intrinsic_duration; ++i) { - shared_ptr<const SoundFrame> frame_A = get_frame (i); - shared_ptr<const SoundFrame> frame_B = other_sound->get_frame (i); + shared_ptr<const SoundFrame> frame_A = reader->get_frame (i); + shared_ptr<const SoundFrame> frame_B = other_reader->get_frame (i); if (frame_A->size() != frame_B->size()) { note (DCP_ERROR, String::compose ("sizes of audio data for frame %1 differ", i)); @@ -149,13 +153,6 @@ SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHand return true; } -shared_ptr<const SoundFrame> -SoundAsset::get_frame (int n) const -{ - /* XXX: should add on entry point here? */ - return shared_ptr<const SoundFrame> (new SoundFrame (file(), n, _decryption_context)); -} - shared_ptr<SoundAssetWriter> SoundAsset::start_write (boost::filesystem::path file, Standard standard) { @@ -163,6 +160,12 @@ SoundAsset::start_write (boost::filesystem::path file, Standard standard) return shared_ptr<SoundAssetWriter> (new SoundAssetWriter (this, file, standard)); } +shared_ptr<SoundAssetReader> +SoundAsset::start_read () const +{ + return shared_ptr<SoundAssetReader> (new SoundAssetReader (this)); +} + string SoundAsset::pkl_type (Standard standard) const { |
