Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'extern/audaspace/plugins/libsndfile')
-rw-r--r--extern/audaspace/plugins/libsndfile/SndFile.cpp14
-rw-r--r--extern/audaspace/plugins/libsndfile/SndFile.h6
-rw-r--r--extern/audaspace/plugins/libsndfile/SndFileReader.cpp15
-rw-r--r--extern/audaspace/plugins/libsndfile/SndFileReader.h12
4 files changed, 43 insertions, 4 deletions
diff --git a/extern/audaspace/plugins/libsndfile/SndFile.cpp b/extern/audaspace/plugins/libsndfile/SndFile.cpp
index ba4ff24ad68..39335de9a1a 100644
--- a/extern/audaspace/plugins/libsndfile/SndFile.cpp
+++ b/extern/audaspace/plugins/libsndfile/SndFile.cpp
@@ -32,16 +32,26 @@ void SndFile::registerPlugin()
FileManager::registerOutput(plugin);
}
-std::shared_ptr<IReader> SndFile::createReader(std::string filename)
+std::shared_ptr<IReader> SndFile::createReader(std::string filename, int stream)
{
return std::shared_ptr<IReader>(new SndFileReader(filename));
}
-std::shared_ptr<IReader> SndFile::createReader(std::shared_ptr<Buffer> buffer)
+std::shared_ptr<IReader> SndFile::createReader(std::shared_ptr<Buffer> buffer, int stream)
{
return std::shared_ptr<IReader>(new SndFileReader(buffer));
}
+std::vector<StreamInfo> SndFile::queryStreams(std::string filename)
+{
+ return SndFileReader(filename).queryStreams();
+}
+
+std::vector<StreamInfo> SndFile::queryStreams(std::shared_ptr<Buffer> buffer)
+{
+ return SndFileReader(buffer).queryStreams();
+}
+
std::shared_ptr<IWriter> SndFile::createWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate)
{
return std::shared_ptr<IWriter>(new SndFileWriter(filename, specs, format, codec, bitrate));
diff --git a/extern/audaspace/plugins/libsndfile/SndFile.h b/extern/audaspace/plugins/libsndfile/SndFile.h
index 61afed1d564..10a7391180f 100644
--- a/extern/audaspace/plugins/libsndfile/SndFile.h
+++ b/extern/audaspace/plugins/libsndfile/SndFile.h
@@ -52,8 +52,10 @@ public:
*/
static void registerPlugin();
- virtual std::shared_ptr<IReader> createReader(std::string filename);
- virtual std::shared_ptr<IReader> createReader(std::shared_ptr<Buffer> buffer);
+ virtual std::shared_ptr<IReader> createReader(std::string filename, int stream = 0);
+ virtual std::shared_ptr<IReader> createReader(std::shared_ptr<Buffer> buffer, int stream = 0);
+ virtual std::vector<StreamInfo> queryStreams(std::string filename);
+ virtual std::vector<StreamInfo> queryStreams(std::shared_ptr<Buffer> buffer);
virtual std::shared_ptr<IWriter> createWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate);
};
diff --git a/extern/audaspace/plugins/libsndfile/SndFileReader.cpp b/extern/audaspace/plugins/libsndfile/SndFileReader.cpp
index d2d89814c07..21c733d8117 100644
--- a/extern/audaspace/plugins/libsndfile/SndFileReader.cpp
+++ b/extern/audaspace/plugins/libsndfile/SndFileReader.cpp
@@ -118,6 +118,21 @@ SndFileReader::~SndFileReader()
sf_close(m_sndfile);
}
+std::vector<StreamInfo> SndFileReader::queryStreams()
+{
+ std::vector<StreamInfo> result;
+
+ StreamInfo info;
+ info.start = 0;
+ info.duration = double(getLength()) / m_specs.rate;
+ info.specs.specs = m_specs;
+ info.specs.format = FORMAT_FLOAT32;
+
+ result.emplace_back(info);
+
+ return result;
+}
+
bool SndFileReader::isSeekable() const
{
return m_seekable;
diff --git a/extern/audaspace/plugins/libsndfile/SndFileReader.h b/extern/audaspace/plugins/libsndfile/SndFileReader.h
index 081c29c686c..b4158d9091a 100644
--- a/extern/audaspace/plugins/libsndfile/SndFileReader.h
+++ b/extern/audaspace/plugins/libsndfile/SndFileReader.h
@@ -28,9 +28,12 @@
* The SndFileReader class.
*/
+#include "file/FileInfo.h"
+
#include <string>
#include <sndfile.h>
#include <memory>
+#include <vector>
AUD_NAMESPACE_BEGIN
@@ -96,6 +99,7 @@ public:
/**
* Creates a new reader.
* \param filename The path to the file to be read.
+ * \param stream The index of the audio stream within the file if it contains multiple audio streams.
* \exception Exception Thrown if the file specified does not exist or
* cannot be read with libsndfile.
*/
@@ -104,6 +108,7 @@ public:
/**
* Creates a new reader.
* \param buffer The buffer to read from.
+ * \param stream The index of the audio stream within the file if it contains multiple audio streams.
* \exception Exception Thrown if the buffer specified cannot be read
* with libsndfile.
*/
@@ -114,6 +119,13 @@ public:
*/
virtual ~SndFileReader();
+ /**
+ * Queries the streams of a sound file.
+ * \return A vector with as many streams as there are in the file.
+ * \exception Exception Thrown if the file specified cannot be read.
+ */
+ virtual std::vector<StreamInfo> queryStreams();
+
virtual bool isSeekable() const;
virtual void seek(int position);
virtual int getLength() const;