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:
authorJörg Müller <nexyon@gmail.com>2021-08-30 23:36:02 +0300
committerJörg Müller <nexyon@gmail.com>2021-09-18 22:45:33 +0300
commitbdbc7e12a02e15ad7265dfc1ac21fb6d0016308f (patch)
treee9b967deb25f77eef348786f5cd22524eef0ec20 /extern/audaspace/bindings/C/AUD_Sound.cpp
parent970c928f27106b26ec7cf6afa2316c60384ab4f1 (diff)
Audaspace: added audio file streams functionality.
On the blender side this commit fixes importing video files with audio and video streams that do not share the same start time and duration. Differential Revision: https://developer.blender.org/D12353
Diffstat (limited to 'extern/audaspace/bindings/C/AUD_Sound.cpp')
-rw-r--r--extern/audaspace/bindings/C/AUD_Sound.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/extern/audaspace/bindings/C/AUD_Sound.cpp b/extern/audaspace/bindings/C/AUD_Sound.cpp
index 8c99ce2341f..aa246b9a047 100644
--- a/extern/audaspace/bindings/C/AUD_Sound.cpp
+++ b/extern/audaspace/bindings/C/AUD_Sound.cpp
@@ -94,6 +94,36 @@ AUD_API int AUD_Sound_getLength(AUD_Sound* sound)
return (*sound)->createReader()->getLength();
}
+AUD_API int AUD_Sound_getFileStreams(AUD_Sound* sound, AUD_StreamInfo **stream_infos)
+{
+ assert(sound);
+
+ std::shared_ptr<File> file = std::dynamic_pointer_cast<File>(*sound);
+
+ if(file)
+ {
+ auto streams = file->queryStreams();
+
+ size_t size = sizeof(AUD_StreamInfo) * streams.size();
+
+ if(!size)
+ {
+ *stream_infos = nullptr;
+ return 0;
+ }
+
+ *stream_infos = reinterpret_cast<AUD_StreamInfo*>(std::malloc(size));
+ std::memcpy(*stream_infos, streams.data(), size);
+
+ return streams.size();
+ }
+ else
+ {
+ *stream_infos = nullptr;
+ return 0;
+ }
+}
+
AUD_API sample_t* AUD_Sound_data(AUD_Sound* sound, int* length, AUD_Specs* specs)
{
assert(sound);
@@ -252,6 +282,12 @@ AUD_API AUD_Sound* AUD_Sound_bufferFile(unsigned char* buffer, int size)
return new AUD_Sound(new File(buffer, size));
}
+AUD_API AUD_Sound* AUD_Sound_bufferFileStream(unsigned char* buffer, int size, int stream)
+{
+ assert(buffer);
+ return new AUD_Sound(new File(buffer, size, stream));
+}
+
AUD_API AUD_Sound* AUD_Sound_cache(AUD_Sound* sound)
{
assert(sound);
@@ -272,6 +308,12 @@ AUD_API AUD_Sound* AUD_Sound_file(const char* filename)
return new AUD_Sound(new File(filename));
}
+AUD_API AUD_Sound* AUD_Sound_fileStream(const char* filename, int stream)
+{
+ assert(filename);
+ return new AUD_Sound(new File(filename, stream));
+}
+
AUD_API AUD_Sound* AUD_Sound_sawtooth(float frequency, AUD_SampleRate rate)
{
return new AUD_Sound(new Sawtooth(frequency, rate));