X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fcaimportable.cc;h=8bacbd1d15479f1ec06372c6102fcd5fa98adcb3;hb=456fb789d3adcdb52de3abd863c1bf64c973effa;hp=229bfa8809a314d66e6ef9e162076d13dded6f20;hpb=449aab3c465bbbf66d221fac3d7ea559f1720357;p=ardour.git diff --git a/libs/ardour/caimportable.cc b/libs/ardour/caimportable.cc index 229bfa8809..8bacbd1d15 100644 --- a/libs/ardour/caimportable.cc +++ b/libs/ardour/caimportable.cc @@ -1,6 +1,25 @@ -#include +/* + Copyright (C) 2012 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "ardour/caimportable.h" #include -#include +#include "pbd/error.h" #include "i18n.h" @@ -24,7 +43,9 @@ CAImportableSource::CAImportableSource (const string& path) af.SetClientFormat (client_format); } catch (CAXException& cax) { - error << string_compose ("CAImportable: %1", cax.mOperation) << endmsg; + //Don't report an error here since there is one higher up in import. + //Since libsndfile gets tried second, any failures here may show as + //invalid errors in the Error log. throw failed_constructor (); } @@ -34,12 +55,12 @@ CAImportableSource::~CAImportableSource () { } -nframes_t -CAImportableSource::read (Sample* buffer, nframes_t nframes) +framecnt_t +CAImportableSource::read (Sample* buffer, framecnt_t nframes) { - nframes_t nread = 0; + framecnt_t nread = 0; AudioBufferList abl; - nframes_t per_channel; + framecnt_t per_channel; bool at_end = false; abl.mNumberBuffers = 1; @@ -48,12 +69,12 @@ CAImportableSource::read (Sample* buffer, nframes_t nframes) per_channel = nframes / abl.mBuffers[0].mNumberChannels; while (nread < per_channel) { - + UInt32 new_cnt = per_channel - nread; - + abl.mBuffers[0].mDataByteSize = new_cnt * abl.mBuffers[0].mNumberChannels * sizeof(Sample); abl.mBuffers[0].mData = buffer + nread; - + try { af.Read (new_cnt, &abl); } catch (CAXException& cax) { @@ -73,24 +94,24 @@ CAImportableSource::read (Sample* buffer, nframes_t nframes) if (!at_end && nread < per_channel) { return 0; } else { - return nread * abl.mBuffers[0].mNumberChannels; + return nread * abl.mBuffers[0].mNumberChannels; } } uint -CAImportableSource::channels () const +CAImportableSource::channels () const { return af.GetFileDataFormat().NumberChannels(); } -nframes_t -CAImportableSource::length () const +framecnt_t +CAImportableSource::length () const { return af.GetNumberFrames(); } -nframes_t -CAImportableSource::samplerate() const +framecnt_t +CAImportableSource::samplerate () const { CAStreamBasicDescription client_asbd; @@ -105,7 +126,7 @@ CAImportableSource::samplerate() const } void -CAImportableSource::seek (nframes_t pos) +CAImportableSource::seek (framepos_t pos) { try { af.Seek (pos); @@ -114,5 +135,5 @@ CAImportableSource::seek (nframes_t pos) } } - +