[Bf-blender-cvs] [9351e87] master: Fix T39607: Audio not in synch when the blend file loads.

Jörg Müller noreply at git.blender.org
Tue Apr 15 19:20:07 CEST 2014


Commit: 9351e872f5317a5690ecdaeaf9dd9db5e1558cfc
Author: Jörg Müller
Date:   Tue Apr 15 19:17:50 2014 +0200
https://developer.blender.org/rB9351e872f5317a5690ecdaeaf9dd9db5e1558cfc

Fix T39607: Audio not in synch when the blend file loads.

The problem here was that animation buffers got initialized with zeros in the beginning for unknown parts. Now it gets initialized with the first known value.
The bug's result was that the animation of the pitch started with 0 on first playback and thus any seeking while the pitch is zero resulted in seeking to the beginning.

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

M	intern/audaspace/intern/AUD_AnimateableProperty.cpp
M	intern/audaspace/intern/AUD_AnimateableProperty.h
M	intern/audaspace/intern/AUD_Sequencer.cpp
M	intern/audaspace/intern/AUD_SequencerEntry.cpp
M	source/blender/blenkernel/intern/sound.c

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

diff --git a/intern/audaspace/intern/AUD_AnimateableProperty.cpp b/intern/audaspace/intern/AUD_AnimateableProperty.cpp
index 61adae4..9f399a0 100644
--- a/intern/audaspace/intern/AUD_AnimateableProperty.cpp
+++ b/intern/audaspace/intern/AUD_AnimateableProperty.cpp
@@ -47,6 +47,23 @@ AUD_AnimateableProperty::AUD_AnimateableProperty(int count) :
 	pthread_mutexattr_destroy(&attr);
 }
 
+AUD_AnimateableProperty::AUD_AnimateableProperty(int count, float value) :
+	AUD_Buffer(count * sizeof(float)), m_count(count), m_isAnimated(false)
+{
+	sample_t* buf = getBuffer();
+
+	for(int i = 0; i < count; i++)
+		buf[i] = value;
+
+	pthread_mutexattr_t attr;
+	pthread_mutexattr_init(&attr);
+	pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+
+	pthread_mutex_init(&m_mutex, &attr);
+
+	pthread_mutexattr_destroy(&attr);
+}
+
 void AUD_AnimateableProperty::updateUnknownCache(int start, int end)
 {
 	float* buf = getBuffer();
@@ -104,7 +121,8 @@ void AUD_AnimateableProperty::write(const float* data, int position, int count)
 
 		if(pos == 0)
 		{
-			memset(buf, 0, position * m_count * sizeof(float));
+			for(int i = 0; i < position; i++)
+				memcpy(buf + i * m_count, data, m_count * sizeof(float));
 		}
 		else
 			updateUnknownCache(pos, position - 1);
diff --git a/intern/audaspace/intern/AUD_AnimateableProperty.h b/intern/audaspace/intern/AUD_AnimateableProperty.h
index 37eb8f8..f07e591 100644
--- a/intern/audaspace/intern/AUD_AnimateableProperty.h
+++ b/intern/audaspace/intern/AUD_AnimateableProperty.h
@@ -76,6 +76,13 @@ public:
 	AUD_AnimateableProperty(int count = 1);
 
 	/**
+	 * Creates a new animateable property.
+	 * \param count The count of floats for a single property.
+	 * \param count The value that the property should get initialized with. All count floats will be initialized to the same value.
+	 */
+	AUD_AnimateableProperty(int count, float value);
+
+	/**
 	 * Destroys the animateable property.
 	 */
 	~AUD_AnimateableProperty();
diff --git a/intern/audaspace/intern/AUD_Sequencer.cpp b/intern/audaspace/intern/AUD_Sequencer.cpp
index c59c56a..6c5e48c 100644
--- a/intern/audaspace/intern/AUD_Sequencer.cpp
+++ b/intern/audaspace/intern/AUD_Sequencer.cpp
@@ -42,6 +42,7 @@ AUD_Sequencer::AUD_Sequencer(AUD_Specs specs, float fps, bool muted) :
 	m_speed_of_sound(434),
 	m_doppler_factor(1),
 	m_distance_model(AUD_DISTANCE_MODEL_INVERSE_CLAMPED),
+	m_volume(1, 1.0f),
 	m_location(3),
 	m_orientation(4)
 {
diff --git a/intern/audaspace/intern/AUD_SequencerEntry.cpp b/intern/audaspace/intern/AUD_SequencerEntry.cpp
index 005557b..6ef8479 100644
--- a/intern/audaspace/intern/AUD_SequencerEntry.cpp
+++ b/intern/audaspace/intern/AUD_SequencerEntry.cpp
@@ -53,6 +53,8 @@ AUD_SequencerEntry::AUD_SequencerEntry(boost::shared_ptr<AUD_IFactory> sound, fl
 	m_cone_angle_outer(360),
 	m_cone_angle_inner(360),
 	m_cone_volume_outer(0),
+	m_volume(1, 1.0f),
+	m_pitch(1, 1.0f),
 	m_location(3),
 	m_orientation(4)
 {
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index bdd06e9..b906ff2 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -566,8 +566,6 @@ void sound_play_scene(struct Scene *scene)
 			AUD_unlock();
 			return;
 		}
-
-		AUD_seek(scene->sound_scene_handle, cur_time);
 	}
 
 	if (status != AUD_STATUS_PLAYING) {




More information about the Bf-blender-cvs mailing list