[Bf-blender-cvs] [08de05f] master: Some style cleanup in sound area.

Bastien Montagne noreply at git.blender.org
Tue Apr 15 14:27:13 CEST 2014


Commit: 08de05f3db64d6ab70f0bd93635ddb7f47530837
Author: Bastien Montagne
Date:   Tue Apr 15 10:59:42 2014 +0200
https://developer.blender.org/rB08de05f3db64d6ab70f0bd93635ddb7f47530837

Some style cleanup in sound area.

===================================================================

M	source/blender/blenkernel/BKE_sound.h
M	source/blender/blenkernel/intern/sound.c
M	source/blender/makesrna/intern/rna_speaker.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h
index eb0aec5..50ca5fc 100644
--- a/source/blender/blenkernel/BKE_sound.h
+++ b/source/blender/blenkernel/BKE_sound.h
@@ -140,6 +140,6 @@ void *sound_get_factory(void *sound);
 
 float sound_get_length(struct bSound *sound);
 
-int sound_is_jack_supported(void);
+bool sound_is_jack_supported(void);
 
-#endif
+#endif  /* __BKE_SOUND_H__ */
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index 1fe73a1..5c7b86a 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -61,7 +61,7 @@
 #include "BKE_scene.h"
 
 #ifdef WITH_AUDASPACE
-// evil global ;-)
+/* evil global ;-) */
 static int sound_cfra;
 #endif
 
@@ -86,7 +86,7 @@ bSound *sound_new_file(struct Main *bmain, const char *filename)
 
 	sound = BKE_libblock_alloc(bmain, ID_SO, filename + len);
 	BLI_strncpy(sound->name, filename, FILE_MAX);
-// XXX unused currently	sound->type = SOUND_TYPE_FILE;
+	/* sound->type = SOUND_TYPE_FILE; */ /* XXX unused currently */
 
 	sound_load(bmain, sound);
 
@@ -118,7 +118,7 @@ void BKE_sound_free(bSound *sound)
 	}
 
 	sound_free_waveform(sound);
-#endif // WITH_AUDASPACE
+#endif  /* WITH_AUDASPACE */
 }
 
 #ifdef WITH_AUDASPACE
@@ -223,7 +223,7 @@ void sound_exit_once(void)
 	AUD_exitOnce();
 }
 
-// XXX unused currently
+/* XXX unused currently */
 #if 0
 bSound *sound_new_buffer(struct Main *bmain, bSound *source)
 {
@@ -330,7 +330,7 @@ void sound_load(struct Main *bmain, bSound *sound)
 
 		sound_free_waveform(sound);
 
-// XXX unused currently
+/* XXX unused currently */
 #if 0
 		switch (sound->type)
 		{
@@ -353,7 +353,7 @@ void sound_load(struct Main *bmain, bSound *sound)
 			else
 				sound->handle = AUD_load(fullpath);
 		}
-// XXX unused currently
+/* XXX unused currently */
 #if 0
 			break;
 		}
@@ -437,10 +437,14 @@ void sound_update_scene_listener(struct Scene *scene)
 	                        scene->audio.doppler_factor, scene->audio.distance_model);
 }
 
-void *sound_scene_add_scene_sound(struct Scene *scene, struct Sequence *sequence, int startframe, int endframe, int frameskip)
+void *sound_scene_add_scene_sound(struct Scene *scene, struct Sequence *sequence,
+                                  int startframe, int endframe, int frameskip)
 {
-	if (scene != sequence->scene)
-		return AUD_addSequence(scene->sound_scene, sequence->scene->sound_scene, startframe / FPS, endframe / FPS, frameskip / FPS);
+	if (scene != sequence->scene) {
+		const double fps = FPS;
+		return AUD_addSequence(scene->sound_scene, sequence->scene->sound_scene,
+		                       startframe / fps, endframe / fps, frameskip / fps);
+	}
 	return NULL;
 }
 
@@ -453,7 +457,9 @@ void *sound_scene_add_scene_sound_defaults(struct Scene *scene, struct Sequence
 
 void *sound_add_scene_sound(struct Scene *scene, struct Sequence *sequence, int startframe, int endframe, int frameskip)
 {
-	void *handle = AUD_addSequence(scene->sound_scene, sequence->sound->playback_handle, startframe / FPS, endframe / FPS, frameskip / FPS);
+	const double fps = FPS;
+	void *handle = AUD_addSequence(scene->sound_scene, sequence->sound->playback_handle,
+	                               startframe / fps, endframe / fps, frameskip / fps);
 	AUD_muteSequence(handle, (sequence->flag & SEQ_MUTE) != 0);
 	AUD_setSequenceAnimData(handle, AUD_AP_VOLUME, CFRA, &sequence->volume, 0);
 	AUD_setSequenceAnimData(handle, AUD_AP_PITCH, CFRA, &sequence->pitch, 0);
@@ -480,7 +486,8 @@ void sound_mute_scene_sound(void *handle, char mute)
 
 void sound_move_scene_sound(struct Scene *scene, void *handle, int startframe, int endframe, int frameskip)
 {
-	AUD_moveSequence(handle, startframe / FPS, endframe / FPS, frameskip / FPS);
+	const double fps = FPS;
+	AUD_moveSequence(handle, startframe / fps, endframe / fps, frameskip / fps);
 }
 
 void sound_move_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence)
@@ -504,7 +511,8 @@ void sound_set_cfra(int cfra)
 
 void sound_set_scene_volume(struct Scene *scene, float volume)
 {
-	AUD_setSequencerAnimData(scene->sound_scene, AUD_AP_VOLUME, CFRA, &volume, (scene->audio.flag & AUDIO_VOLUME_ANIMATED) != 0);
+	AUD_setSequencerAnimData(scene->sound_scene, AUD_AP_VOLUME, CFRA, &volume,
+	                         (scene->audio.flag & AUDIO_VOLUME_ANIMATED) != 0);
 }
 
 void sound_set_scene_sound_volume(void *handle, float volume, char animated)
@@ -545,6 +553,8 @@ static void sound_start_play_scene(struct Scene *scene)
 void sound_play_scene(struct Scene *scene)
 {
 	AUD_Status status;
+	const float cur_time = (float)((double)CFRA / FPS);
+
 	AUD_lock();
 
 	status = scene->sound_scene_handle ? AUD_getStatus(scene->sound_scene_handle) : AUD_STATUS_INVALID;
@@ -558,7 +568,7 @@ void sound_play_scene(struct Scene *scene)
 	}
 
 	if (status != AUD_STATUS_PLAYING) {
-		AUD_seek(scene->sound_scene_handle, CFRA / FPS);
+		AUD_seek(scene->sound_scene_handle, cur_time);
 		AUD_resume(scene->sound_scene_handle);
 	}
 
@@ -584,6 +594,9 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene)
 	bScreen *screen;
 	int animation_playing;
 
+	const float one_frame = (float)(1.0 / FPS);
+	const float cur_time = (float)((double)CFRA / FPS);
+
 	AUD_lock();
 
 	status = scene->sound_scene_handle ? AUD_getStatus(scene->sound_scene_handle) : AUD_STATUS_INVALID;
@@ -608,26 +621,31 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene)
 
 	if (scene->audio.flag & AUDIO_SCRUB && !animation_playing) {
 		if (scene->audio.flag & AUDIO_SYNC) {
-			AUD_seek(scene->sound_scene_handle, CFRA / FPS);
-			AUD_seekSequencer(scene->sound_scene_handle, CFRA / FPS);
+			AUD_seek(scene->sound_scene_handle, cur_time);
+			AUD_seekSequencer(scene->sound_scene_handle, cur_time);
+		}
+		else {
+			AUD_seek(scene->sound_scene_handle, cur_time);
 		}
-		else
-			AUD_seek(scene->sound_scene_handle, CFRA / FPS);
 		AUD_resume(scene->sound_scene_handle);
-		if (scene->sound_scrub_handle && AUD_getStatus(scene->sound_scrub_handle) != AUD_STATUS_INVALID)
+		if (scene->sound_scrub_handle && AUD_getStatus(scene->sound_scrub_handle) != AUD_STATUS_INVALID) {
 			AUD_seek(scene->sound_scrub_handle, 0);
+		}
 		else {
-			if (scene->sound_scrub_handle)
+			if (scene->sound_scrub_handle) {
 				AUD_stop(scene->sound_scrub_handle);
-			scene->sound_scrub_handle = AUD_pauseAfter(scene->sound_scene_handle, 1 / FPS);
+			}
+			scene->sound_scrub_handle = AUD_pauseAfter(scene->sound_scene_handle, one_frame);
 		}
 	}
 	else {
-		if (scene->audio.flag & AUDIO_SYNC)
-			AUD_seekSequencer(scene->sound_scene_handle, CFRA / FPS);
+		if (scene->audio.flag & AUDIO_SYNC) {
+			AUD_seekSequencer(scene->sound_scene_handle, cur_time);
+		}
 		else {
-			if (status == AUD_STATUS_PLAYING)
-				AUD_seek(scene->sound_scene_handle, CFRA / FPS);
+			if (status == AUD_STATUS_PLAYING) {
+				AUD_seek(scene->sound_scene_handle, cur_time);
+			}
 		}
 	}
 
@@ -695,62 +713,59 @@ void sound_update_scene(Main *bmain, struct Scene *scene)
 	float quat[4];
 
 	/* cheap test to skip looping over all objects (no speakers is a common case) */
-	if (BLI_listbase_is_empty(&bmain->speaker)) {
-		goto skip_speakers;
-	}
+	if (!BLI_listbase_is_empty(&bmain->speaker)) {
+		for (SETLOOPER(scene, sce_it, base)) {
+			ob = base->object;
+			if ((ob->type != OB_SPEAKER) || !ob->adt) {
+				continue;
+			}
+			for (track = ob->adt->nla_tracks.first; track; track = track->next) {
+				for (strip = track->strips.first; strip; strip = strip->next) {
+					if (strip->type != NLASTRIP_TYPE_SOUND) {
+						continue;
+					}
+					speaker = (Speaker *)ob->data;
 
-	for (SETLOOPER(scene, sce_it, base)) {
-		ob = base->object;
-		if (ob->type == OB_SPEAKER) {
-			if (ob->adt) {
-				for (track = ob->adt->nla_tracks.first; track; track = track->next) {
-					for (strip = track->strips.first; strip; strip = strip->next) {
-						if (strip->type == NLASTRIP_TYPE_SOUND) {
-							speaker = (Speaker *)ob->data;
-
-							if (AUD_removeSet(scene->speaker_handles, strip->speaker_handle)) {
-								if (speaker->sound)
-									AUD_moveSequence(strip->speaker_handle, (double)strip->start / FPS, -1, 0);
-								else {
-									AUD_removeSequence(scene->sound_scene, strip->speaker_handle);
-									strip->speaker_handle = NULL;
-								}
-							}
-							else {
-								if (speaker->sound) {
-									strip->speaker_handle = AUD_addSequence(scene->sound_scene,
-									                                        speaker->sound->playback_handle,
-									                                        (double)strip->start / FPS, -1, 0);
-									AUD_setRelativeSequence(strip->speaker_handle, 0);
-								}
-							}
-
-							if (strip->speaker_handle) {
-								AUD_addSet(new_set, strip->speaker_handle);
-								AUD_updateSequenceData(strip->speaker_handle, speaker->volume_max,
-								                       speaker->volume_min, speaker->distance_max,
-								                       speaker->distance_reference, speaker->attenuation,
-								                       speaker->cone_angle_outer, speaker->cone_angle_inner,
-								                       speaker->cone_volume_outer);
-
-								mat4_to_quat(quat, ob->obmat);
-								AUD_setSequenceAnimData(strip->speaker_handle, AUD_AP_LOCATION, CFRA, ob->obmat[3], 1);
-								AUD_setSequenceAnimData(strip->speaker_handle, AUD_AP_ORIENTATION, CFRA, quat, 1);
-								AUD_setSequenceAnimData(strip->speaker_handle, AUD_AP_VOLUME, CFRA, &speaker->volume, 1);
-								AUD_setSequenceAnimData(strip->speaker_handle, AUD_AP_PITCH, CFRA, &speaker->pitch, 1);
-								AUD_updateSequenceSound(strip->speaker_handle, speaker->sound->playback_handle);
-								AUD_muteSequence(strip->speaker_handle, ((strip->flag & NLASTRIP_FLAG_MUTED) != 0) || ((speaker->flag & SPK_MUTED) != 0));
-							}
+					if (AUD_removeSet(scene->speaker_handles, strip->speaker_handle)) {
+						if (speaker->sound) {
+							AUD_moveSequence(strip->speaker_handle, (double)strip->start / FPS, -1, 0);
+						}
+						else {
+							AUD_removeSequence(scene->sound_scene, strip->speaker_handle);
+							strip->speaker_handle = NULL;
 						}
 					}
+					else {
+					

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list