From 73bee3a4cda1c28a4aa785d4c3900da4740375fe Mon Sep 17 00:00:00 2001 From: Stefan Sayer Date: Thu, 5 Jun 2008 14:01:29 +0000 Subject: [PATCH] added "autorewind" feature to be able to re-use AmAudioFile without explicit rewind() git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1008 8eb893ce-cfd4-0310-b710-fb5ebe64c474 --- core/AmAudioFile.cpp | 7 ++++++- core/AmAudioFile.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/AmAudioFile.cpp b/core/AmAudioFile.cpp index bdef0ed8..7b188b2d 100644 --- a/core/AmAudioFile.cpp +++ b/core/AmAudioFile.cpp @@ -213,7 +213,7 @@ int AmAudioFile::fpopen_int(const string& filename, OpenMode mode, FILE* n_fp) AmAudioFile::AmAudioFile() : AmBufferedAudio(0, 0, 0), data_size(0), - fp(0), begin(0), loop(false), + fp(0), begin(0), loop(false), autorewind(false), on_close_done(false), close_on_exit(true) { @@ -322,6 +322,11 @@ int AmAudioFile::read(unsigned int user_ts, unsigned int size) rewind(); goto read_block; } + + if (autorewind.get() && data_size>0){ + DBG("autorewinding audio file...\n"); + rewind(); + } ret = -2; // eof } diff --git a/core/AmAudioFile.h b/core/AmAudioFile.h index e9acbf35..59445329 100644 --- a/core/AmAudioFile.h +++ b/core/AmAudioFile.h @@ -106,6 +106,7 @@ protected: public: AmSharedVar loop; + AmSharedVar autorewind; AmAudioFile(); ~AmAudioFile();