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
path: root/extern
diff options
context:
space:
mode:
authorJoerg Mueller <nexyon@gmail.com>2020-09-07 19:11:56 +0300
committerJoerg Mueller <nexyon@gmail.com>2020-09-07 19:12:45 +0300
commit9cac181fbead28c0bf963bf2b9f82fddf3c2b7df (patch)
tree75d720dabbdc67d706ff916d46984a65545916d1 /extern
parent53ca638f2b738af644661bd4fabcf7e3fdf6e73b (diff)
Audaspace: port changes from upstream.
Adds possibility to report progress during audio mixdown.
Diffstat (limited to 'extern')
-rw-r--r--extern/audaspace/bindings/C/AUD_Special.cpp8
-rw-r--r--extern/audaspace/bindings/C/AUD_Special.h10
-rw-r--r--extern/audaspace/include/file/FileWriter.h4
-rw-r--r--extern/audaspace/src/file/FileWriter.cpp20
4 files changed, 32 insertions, 10 deletions
diff --git a/extern/audaspace/bindings/C/AUD_Special.cpp b/extern/audaspace/bindings/C/AUD_Special.cpp
index c7155276a30..a83465620ab 100644
--- a/extern/audaspace/bindings/C/AUD_Special.cpp
+++ b/extern/audaspace/bindings/C/AUD_Special.cpp
@@ -270,7 +270,7 @@ AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, int length, int sampl
return length;
}
-AUD_API const char* AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned int length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate)
+AUD_API const char* AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned int length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate, void(*callback)(float, void*), void* data)
{
try
{
@@ -280,7 +280,7 @@ AUD_API const char* AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned i
std::shared_ptr<IReader> reader = f->createQualityReader();
reader->seek(start);
std::shared_ptr<IWriter> writer = FileWriter::createWriter(filename, convCToDSpec(specs), static_cast<Container>(format), static_cast<Codec>(codec), bitrate);
- FileWriter::writeReader(reader, writer, length, buffersize);
+ FileWriter::writeReader(reader, writer, length, buffersize, callback, data);
return nullptr;
}
@@ -290,7 +290,7 @@ AUD_API const char* AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned i
}
}
-AUD_API const char* AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, unsigned int length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate)
+AUD_API const char* AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, unsigned int length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate, void(*callback)(float, void*), void* data)
{
try
{
@@ -326,7 +326,7 @@ AUD_API const char* AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start
std::shared_ptr<IReader> reader = f->createQualityReader();
reader->seek(start);
- FileWriter::writeReader(reader, writers, length, buffersize);
+ FileWriter::writeReader(reader, writers, length, buffersize, callback, data);
return nullptr;
}
diff --git a/extern/audaspace/bindings/C/AUD_Special.h b/extern/audaspace/bindings/C/AUD_Special.h
index 9faf9e4ee74..ce51fa2e04e 100644
--- a/extern/audaspace/bindings/C/AUD_Special.h
+++ b/extern/audaspace/bindings/C/AUD_Special.h
@@ -68,12 +68,15 @@ extern AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, int length, in
* \param format The file's container format.
* \param codec The codec used for encoding the audio data.
* \param bitrate The bitrate for encoding.
+ * \param callback A callback function that is called periodically during mixdown, reporting progress if length > 0. Can be NULL.
+ * \param data Pass through parameter that is passed to the callback.
* \return An error message or NULL in case of success.
*/
extern AUD_API const char* AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned int length,
unsigned int buffersize, const char* filename,
AUD_DeviceSpecs specs, AUD_Container format,
- AUD_Codec codec, unsigned int bitrate);
+ AUD_Codec codec, unsigned int bitrate,
+ void(*callback)(float, void*), void* data);
/**
* Mixes a sound down into multiple files.
@@ -86,12 +89,15 @@ extern AUD_API const char* AUD_mixdown(AUD_Sound* sound, unsigned int start, uns
* \param format The file's container format.
* \param codec The codec used for encoding the audio data.
* \param bitrate The bitrate for encoding.
+ * \param callback A callback function that is called periodically during mixdown, reporting progress if length > 0. Can be NULL.
+ * \param data Pass through parameter that is passed to the callback.
* \return An error message or NULL in case of success.
*/
extern AUD_API const char* AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, unsigned int length,
unsigned int buffersize, const char* filename,
AUD_DeviceSpecs specs, AUD_Container format,
- AUD_Codec codec, unsigned int bitrate);
+ AUD_Codec codec, unsigned int bitrate,
+ void(*callback)(float, void*), void* data);
/**
* Opens a read device and prepares it for mixdown of the sound scene.
diff --git a/extern/audaspace/include/file/FileWriter.h b/extern/audaspace/include/file/FileWriter.h
index dac842f2a8f..13619d4de71 100644
--- a/extern/audaspace/include/file/FileWriter.h
+++ b/extern/audaspace/include/file/FileWriter.h
@@ -63,7 +63,7 @@ public:
* \param length How many samples should be transferred.
* \param buffersize How many samples should be transferred at once.
*/
- static void writeReader(std::shared_ptr<IReader> reader, std::shared_ptr<IWriter> writer, unsigned int length, unsigned int buffersize);
+ static void writeReader(std::shared_ptr<IReader> reader, std::shared_ptr<IWriter> writer, unsigned int length, unsigned int buffersize, void(*callback)(float, void*) = nullptr, void* data = nullptr);
/**
* Writes a reader to several writers.
@@ -72,7 +72,7 @@ public:
* \param length How many samples should be transferred.
* \param buffersize How many samples should be transferred at once.
*/
- static void writeReader(std::shared_ptr<IReader> reader, std::vector<std::shared_ptr<IWriter> >& writers, unsigned int length, unsigned int buffersize);
+ static void writeReader(std::shared_ptr<IReader> reader, std::vector<std::shared_ptr<IWriter> >& writers, unsigned int length, unsigned int buffersize, void(*callback)(float, void*) = nullptr, void* data = nullptr);
};
AUD_NAMESPACE_END
diff --git a/extern/audaspace/src/file/FileWriter.cpp b/extern/audaspace/src/file/FileWriter.cpp
index a6bb0f0049a..b28bbc5329d 100644
--- a/extern/audaspace/src/file/FileWriter.cpp
+++ b/extern/audaspace/src/file/FileWriter.cpp
@@ -27,7 +27,7 @@ std::shared_ptr<IWriter> FileWriter::createWriter(std::string filename,DeviceSpe
return FileManager::createWriter(filename, specs, format, codec, bitrate);
}
-void FileWriter::writeReader(std::shared_ptr<IReader> reader, std::shared_ptr<IWriter> writer, unsigned int length, unsigned int buffersize)
+void FileWriter::writeReader(std::shared_ptr<IReader> reader, std::shared_ptr<IWriter> writer, unsigned int length, unsigned int buffersize, void(*callback)(float, void*), void* data)
{
Buffer buffer(buffersize * AUD_SAMPLE_SIZE(writer->getSpecs()));
sample_t* buf = buffer.getBuffer();
@@ -53,10 +53,18 @@ void FileWriter::writeReader(std::shared_ptr<IReader> reader, std::shared_ptr<IW
}
writer->write(len, buf);
+
+ if(callback)
+ {
+ float progress = -1;
+ if(length > 0)
+ progress = pos / float(length);
+ callback(progress, data);
+ }
}
}
-void FileWriter::writeReader(std::shared_ptr<IReader> reader, std::vector<std::shared_ptr<IWriter> >& writers, unsigned int length, unsigned int buffersize)
+void FileWriter::writeReader(std::shared_ptr<IReader> reader, std::vector<std::shared_ptr<IWriter> >& writers, unsigned int length, unsigned int buffersize, void(*callback)(float, void*), void* data)
{
Buffer buffer(buffersize * AUD_SAMPLE_SIZE(reader->getSpecs()));
Buffer buffer2(buffersize * sizeof(sample_t));
@@ -89,6 +97,14 @@ void FileWriter::writeReader(std::shared_ptr<IReader> reader, std::vector<std::s
writers[channel]->write(len, buf2);
}
+
+ if(callback)
+ {
+ float progress = -1;
+ if(length > 0)
+ progress = pos / float(length);
+ callback(progress, data);
+ }
}
}