diff options
author | Tim Mayberry <mojofunk@gmail.com> | 2007-11-15 02:31:58 +0000 |
---|---|---|
committer | Tim Mayberry <mojofunk@gmail.com> | 2007-11-15 02:31:58 +0000 |
commit | 27b022bdebcf324373c01f6aa4dc666630a2d5bf (patch) | |
tree | cd91767c542eb58bc5960980da454141c8bd80d0 /libs/ardour/resampled_source.cc | |
parent | 4076f7714aff134ae06859f16a7c4e9b88193afc (diff) |
Pass a path argument to ImportableSource rather than SNDFILE handle so resource management is contained
git-svn-id: svn://localhost/ardour2/trunk@2667 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/resampled_source.cc')
-rw-r--r-- | libs/ardour/resampled_source.cc | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/libs/ardour/resampled_source.cc b/libs/ardour/resampled_source.cc index 38aa3832b9..8330196d8a 100644 --- a/libs/ardour/resampled_source.cc +++ b/libs/ardour/resampled_source.cc @@ -28,12 +28,13 @@ using namespace PBD; const uint32_t ResampledImportableSource::blocksize = 4096U; -ResampledImportableSource::ResampledImportableSource (SNDFILE* sf, SF_INFO* info, nframes_t rate, SrcQuality srcq) - : ImportableSource (sf, info) +ResampledImportableSource::ResampledImportableSource (const std::string& path, + nframes_t rate, SrcQuality srcq) + : ImportableSource (path) { int err; - sf_seek (in, 0, SEEK_SET) ; + sf_seek (in.get(), 0, SEEK_SET) ; /* Initialize the sample rate converter. */ @@ -57,7 +58,7 @@ ResampledImportableSource::ResampledImportableSource (SNDFILE* sf, SF_INFO* info break; } - if ((src_state = src_new (src_type, sf_info->channels, &err)) == 0) { + if ((src_state = src_new (src_type, sf_info.channels, &err)) == 0) { error << string_compose(_("Import: src_new() failed : %1"), src_strerror (err)) << endmsg ; throw failed_constructor (); } @@ -69,7 +70,7 @@ ResampledImportableSource::ResampledImportableSource (SNDFILE* sf, SF_INFO* info src_data.input_frames = 0 ; src_data.data_in = input ; - src_data.src_ratio = ((float) rate) / sf_info->samplerate ; + src_data.src_ratio = ((float) rate) / sf_info.samplerate ; input = new float[blocksize]; } @@ -97,14 +98,14 @@ ResampledImportableSource::read (Sample* output, nframes_t nframes) src_data.end_of_input = SF_TRUE ; } - src_data.input_frames /= sf_info->channels; + src_data.input_frames /= sf_info.channels; src_data.data_in = input ; } src_data.data_out = output; if (!src_data.end_of_input) { - src_data.output_frames = nframes / sf_info->channels ; + src_data.output_frames = nframes / sf_info.channels ; } else { src_data.output_frames = src_data.input_frames; } @@ -120,9 +121,9 @@ ResampledImportableSource::read (Sample* output, nframes_t nframes) return 0; } - src_data.data_in += src_data.input_frames_used * sf_info->channels ; + src_data.data_in += src_data.input_frames_used * sf_info.channels ; src_data.input_frames -= src_data.input_frames_used ; - return src_data.output_frames_gen * sf_info->channels; + return src_data.output_frames_gen * sf_info.channels; } |