sndfiile.hh : Add an std:string SndfileHandle constructor.

This commit is contained in:
Erik de Castro Lopo 2006-10-04 22:51:31 +00:00
parent 4973a9537a
commit e9d0af5e98
2 changed files with 30 additions and 1 deletions

View File

@ -1,5 +1,8 @@
2006-10-05 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/sndfile.hh
Add an std:string SndfileHandle constructor.
* tests/scale_clip_test.tpl
Fix the 'make distcheck' target.

View File

@ -54,6 +54,7 @@
#include <sndfile.h>
#include <string>
#include <new> // for std::nothrow
class SndfileHandle
@ -74,6 +75,8 @@ class SndfileHandle
SndfileHandle (void) : p (NULL) {} ;
SndfileHandle (const char *path, int mode = SFM_READ,
int format = 0, int channels = 0, int samplerate = 0) ;
SndfileHandle (std::string const & path, int mode = SFM_READ,
int format = 0, int channels = 0, int samplerate = 0) ;
~SndfileHandle (void) ;
SndfileHandle (const SndfileHandle &orig) ;
@ -163,7 +166,30 @@ SndfileHandle::SndfileHandle (const char *path, int mode, int fmt, int chans, in
p = NULL ;
} ;
} ;
} /* SndfileHandle constructor */
} /* SndfileHandle const char * constructor */
inline
SndfileHandle::SndfileHandle (std::string const & path, int mode, int fmt, int chans, int srate)
: p (NULL)
{
p = new (std::nothrow) SNDFILE_ref () ;
if (p != NULL)
{ p->ref = 1 ;
p->sfinfo.frames = 0 ;
p->sfinfo.channels = chans ;
p->sfinfo.format = fmt ;
p->sfinfo.samplerate = srate ;
p->sfinfo.sections = 0 ;
p->sfinfo.seekable = 0 ;
if ((p->sf = sf_open (path.c_str (), mode, &p->sfinfo)) == NULL)
{ delete p ;
p = NULL ;
} ;
} ;
} /* SndfileHandle std::string constructor */
inline
SndfileHandle::~SndfileHandle (void)