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:
authorSergey Sharybin <sergey.vfx@gmail.com>2019-06-04 17:52:48 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2019-06-05 15:23:54 +0300
commitbbaa1bffe9dbc35d2791b83d0014ccb4ffb6087a (patch)
treed0ded24e2fb254943831cacca7c28b7752e57eae /source/blender/editors/sound
parent863b7b3668fe67a082439181eaf49c3e94a87536 (diff)
Sound: Port to a copy-on-write concept
This change makes it so sound handles are created for evaluated scene, sequencer and speakers. This allows to have properly evaluated animation on them. For the viewport playback sound uses regular dependency graph. For the final render sound uses dependency graph created for render pipeline, which now also contains sequencer and sound datablocks. All the direct sound update calls are replaced with corresponding dependency graph recalc tag.
Diffstat (limited to 'source/blender/editors/sound')
-rw-r--r--source/blender/editors/sound/CMakeLists.txt1
-rw-r--r--source/blender/editors/sound/sound_ops.c55
2 files changed, 21 insertions, 35 deletions
diff --git a/source/blender/editors/sound/CMakeLists.txt b/source/blender/editors/sound/CMakeLists.txt
index c2a88041a85..7f4b5a45aa3 100644
--- a/source/blender/editors/sound/CMakeLists.txt
+++ b/source/blender/editors/sound/CMakeLists.txt
@@ -19,6 +19,7 @@ set(INC
../include
../../blenkernel
../../blenlib
+ ../../depsgraph
../../makesdna
../../makesrna
../../windowmanager
diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c
index 381173999c4..30ddd8c7d33 100644
--- a/source/blender/editors/sound/sound_ops.c
+++ b/source/blender/editors/sound/sound_ops.c
@@ -62,6 +62,8 @@
# include <AUD_Special.h>
#endif
+#include "DEG_depsgraph_query.h"
+
#include "ED_sound.h"
#include "ED_util.h"
@@ -88,7 +90,6 @@ static int sound_open_exec(bContext *C, wmOperator *op)
bSound *sound;
PropertyPointerRNA *pprop;
PointerRNA idptr;
- AUD_SoundInfo info;
Main *bmain = CTX_data_main(C);
RNA_string_get(op->ptr, "filepath", path);
@@ -98,29 +99,8 @@ static int sound_open_exec(bContext *C, wmOperator *op)
sound_open_init(C, op);
}
- if (sound->playback_handle == NULL) {
- if (op->customdata) {
- MEM_freeN(op->customdata);
- }
- BKE_id_free(bmain, sound);
- BKE_report(op->reports, RPT_ERROR, "Unsupported audio format");
- return OPERATOR_CANCELLED;
- }
-
- info = AUD_getInfo(sound->playback_handle);
-
- if (info.specs.channels == AUD_CHANNELS_INVALID) {
- BKE_id_free(bmain, sound);
- if (op->customdata) {
- MEM_freeN(op->customdata);
- }
- BKE_report(op->reports, RPT_ERROR, "Unsupported audio format");
- return OPERATOR_CANCELLED;
- }
-
if (RNA_boolean_get(op->ptr, "mono")) {
sound->flags |= SOUND_FLAGS_MONO;
- BKE_sound_load(bmain, sound);
}
if (RNA_boolean_get(op->ptr, "cache")) {
@@ -140,6 +120,8 @@ static int sound_open_exec(bContext *C, wmOperator *op)
RNA_property_update(C, &pprop->ptr, pprop->prop);
}
+ DEG_relations_tag_update(bmain);
+
MEM_freeN(op->customdata);
return OPERATOR_FINISHED;
}
@@ -361,8 +343,9 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
#ifdef WITH_AUDASPACE
char path[FILE_MAX];
char filename[FILE_MAX];
- Scene *scene;
- Main *bmain;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
+ Main *bmain = CTX_data_main(C);
int split;
int bitrate, accuracy;
@@ -380,18 +363,20 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
container = RNA_enum_get(op->ptr, "container");
codec = RNA_enum_get(op->ptr, "codec");
split = RNA_boolean_get(op->ptr, "split_channels");
- scene = CTX_data_scene(C);
- bmain = CTX_data_main(C);
- specs.channels = scene->r.ffcodecdata.audio_channels;
- specs.rate = scene->r.ffcodecdata.audio_mixrate;
+ specs.channels = scene_eval->r.ffcodecdata.audio_channels;
+ specs.rate = scene_eval->r.ffcodecdata.audio_mixrate;
BLI_strncpy(filename, path, sizeof(filename));
BLI_path_abs(filename, BKE_main_blendfile_path(bmain));
+ const double fps = (((double)scene_eval->r.frs_sec) / (double)scene_eval->r.frs_sec_base);
+ const int start_frame = scene_eval->r.sfra;
+ const int end_frame = scene_eval->r.efra;
+
if (split) {
- result = AUD_mixdown_per_channel(scene->sound_scene,
- SFRA * specs.rate / FPS,
- (EFRA - SFRA + 1) * specs.rate / FPS,
+ result = AUD_mixdown_per_channel(scene_eval->sound_scene,
+ start_frame * specs.rate / fps,
+ (end_frame - start_frame + 1) * specs.rate / fps,
accuracy,
filename,
specs,
@@ -400,9 +385,9 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
bitrate);
}
else {
- result = AUD_mixdown(scene->sound_scene,
- SFRA * specs.rate / FPS,
- (EFRA - SFRA + 1) * specs.rate / FPS,
+ result = AUD_mixdown(scene_eval->sound_scene,
+ start_frame * specs.rate / fps,
+ (end_frame - start_frame + 1) * specs.rate / fps,
accuracy,
filename,
specs,
@@ -411,7 +396,7 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
bitrate);
}
- BKE_sound_reset_scene_specs(scene);
+ BKE_sound_reset_scene_specs(scene_eval);
if (result) {
BKE_report(op->reports, RPT_ERROR, result);