From e9d0af5e98aa7ee249d91a6c1df572ddb0d6b395 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Wed, 4 Oct 2006 22:51:31 +0000 Subject: [PATCH] sndfiile.hh : Add an std:string SndfileHandle constructor. --- ChangeLog | 3 +++ src/sndfile.hh | 28 +++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7792ea22..c0e2d50a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2006-10-05 Erik de Castro Lopo + * src/sndfile.hh + Add an std:string SndfileHandle constructor. + * tests/scale_clip_test.tpl Fix the 'make distcheck' target. diff --git a/src/sndfile.hh b/src/sndfile.hh index 786e4ea0..586da7d8 100644 --- a/src/sndfile.hh +++ b/src/sndfile.hh @@ -54,6 +54,7 @@ #include +#include #include // 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)