Commit read-only stack security fix for 64bit processors.
[ardour.git] / libs / ardour / ardour / sndfilesource.h
index 53e5b9df677f52e3b1b6b1f851e29db0b547856f..50fd5e68393af1685a2263d547bb729a0299c7ca 100644 (file)
 
 #include <sndfile.h>
 
-#include <ardour/externalsource.h>
+#include <ardour/audiofilesource.h>
 
 namespace ARDOUR {
 
-class SndFileSource : public ExternalSource {
+class SndFileSource : public AudioFileSource {
   public:
-       SndFileSource (const string& path_plus_channel, bool build_peak = true);
-       SndFileSource (const XMLNode&);
+       /* constructor to be called for existing external-to-session files */
+
+       SndFileSource (Session&, std::string path, Flag flags);
+
+       /* constructor to be called for new in-session files */
+
+       SndFileSource (Session&, std::string path, SampleFormat samp_format, HeaderFormat hdr_format, nframes_t rate, 
+                      Flag flags = AudioFileSource::Flag (AudioFileSource::Writable|
+                                                          AudioFileSource::Removable|
+                                                          AudioFileSource::RemovableIfEmpty|
+                                                          AudioFileSource::CanRename));
+                      
+       /* constructor to be called for existing in-session files */
+       
+       SndFileSource (Session&, const XMLNode&);
+
        ~SndFileSource ();
 
-    jack_nframes_t length() const { return _info.frames; } 
+       float sample_rate () const;
+       int update_header (nframes_t when, struct tm&, time_t);
+       int flush_header ();
+
+       nframes_t natural_position () const;
+
+  protected:
+       void set_header_timeline_position ();
+
+       nframes_t read_unlocked (Sample *dst, nframes_t start, nframes_t cnt) const;
+       nframes_t write_unlocked (Sample *dst, nframes_t cnt);
 
-       jack_nframes_t read (Sample *dst, jack_nframes_t start, jack_nframes_t cnt, char * workbuf) const;
+       nframes_t write_float (Sample* data, nframes_t pos, nframes_t cnt);
 
   private:
        SNDFILE *sf;
        SF_INFO _info;
+       SF_BROADCAST_INFO *_broadcast_info;
 
-       mutable float *tmpbuf;
-       mutable jack_nframes_t tmpbufsize;
-       mutable PBD::Lock _tmpbuf_lock;
+       mutable float *interleave_buf;
+       mutable nframes_t interleave_bufsize;
 
-       void init (const string &str, bool build_peak);
-       jack_nframes_t read_unlocked (Sample *dst, jack_nframes_t start, jack_nframes_t cnt, char * workbuf) const;
+       void init (const string &str);
+       int open();
+       void close();
+       int setup_broadcast_info (nframes_t when, struct tm&, time_t);
 };
 
-}; /* namespace ARDOUR */
+} // namespace ARDOUR
 
 #endif /* __sndfile_source_h__ */