[Swfdec-commits] 10 commits - swfdec/swfdec_audio.c swfdec/swfdec_audio_internal.h swfdec/swfdec_load_sound.c swfdec/swfdec_load_sound.h swfdec/swfdec_sound.c swfdec/swfdec_sound_object.c swfdec/swfdec_sound_object.h swfdec/swfdec_sound_provider.c swfdec/swfdec_sound_provider.h test/trace
Benjamin Otte
company at kemper.freedesktop.org
Wed Jun 18 05:43:55 PDT 2008
swfdec/swfdec_audio.c | 19 ++-
swfdec/swfdec_audio_internal.h | 13 +-
swfdec/swfdec_load_sound.c | 44 +++++++-
swfdec/swfdec_load_sound.h | 4
swfdec/swfdec_sound.c | 46 ++++++++
swfdec/swfdec_sound_object.c | 116 ++++++++++------------
swfdec/swfdec_sound_object.h | 4
swfdec/swfdec_sound_provider.c | 35 +++++-
swfdec/swfdec_sound_provider.h | 16 ++-
test/trace/Makefile.am | 45 ++++++++
test/trace/loadSound-matrix-no-target-5.swf |binary
test/trace/loadSound-matrix-no-target-5.swf.trace | 2
test/trace/loadSound-matrix-no-target-6.swf |binary
test/trace/loadSound-matrix-no-target-6.swf.trace | 2
test/trace/loadSound-matrix-no-target-7.swf |binary
test/trace/loadSound-matrix-no-target-7.swf.trace | 2
test/trace/loadSound-matrix-no-target-8.swf |binary
test/trace/loadSound-matrix-no-target-8.swf.trace | 2
test/trace/loadSound-matrix-no-target.as | 17 +++
test/trace/loadSound-matrix-repeat-5.swf |binary
test/trace/loadSound-matrix-repeat-5.swf.trace | 2
test/trace/loadSound-matrix-repeat-6.swf |binary
test/trace/loadSound-matrix-repeat-6.swf.trace | 2
test/trace/loadSound-matrix-repeat-7.swf |binary
test/trace/loadSound-matrix-repeat-7.swf.trace | 2
test/trace/loadSound-matrix-repeat-8.swf |binary
test/trace/loadSound-matrix-repeat-8.swf.trace | 2
test/trace/loadSound-matrix-repeat.as | 17 +++
test/trace/loadSound-matrix-reset-5.swf |binary
test/trace/loadSound-matrix-reset-5.swf.trace | 6 +
test/trace/loadSound-matrix-reset-6.swf |binary
test/trace/loadSound-matrix-reset-6.swf.trace | 6 +
test/trace/loadSound-matrix-reset-7.swf |binary
test/trace/loadSound-matrix-reset-7.swf.trace | 6 +
test/trace/loadSound-matrix-reset-8.swf |binary
test/trace/loadSound-matrix-reset-8.swf.trace | 6 +
test/trace/loadSound-matrix-reset.as | 35 ++++++
test/trace/sound-target-reference-5.swf |binary
test/trace/sound-target-reference-5.swf.trace | 5
test/trace/sound-target-reference-6.swf |binary
test/trace/sound-target-reference-6.swf.trace | 10 +
test/trace/sound-target-reference-7.swf |binary
test/trace/sound-target-reference-7.swf.trace | 10 +
test/trace/sound-target-reference-8.swf |binary
test/trace/sound-target-reference-8.swf.trace | 10 +
test/trace/sound-target-reference.as | 32 ++++++
test/trace/sound-volume-5.swf |binary
test/trace/sound-volume-5.swf.trace | 10 +
test/trace/sound-volume-6.swf |binary
test/trace/sound-volume-6.swf.trace | 10 +
test/trace/sound-volume-7.swf |binary
test/trace/sound-volume-7.swf.trace | 10 +
test/trace/sound-volume-8.swf |binary
test/trace/sound-volume-8.swf.trace | 10 +
test/trace/sound-volume.as | 32 ++++++
test/trace/test.mp3 |binary
56 files changed, 498 insertions(+), 92 deletions(-)
New commits:
commit 27f9c76334abec496c472ad4312b54f6b037af1f
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Jun 18 13:14:41 2008 +0200
and the test that most confused me earlier
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index ad8cae5..0051372 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -3145,6 +3145,15 @@ EXTRA_DIST = \
sound-setTransform-propertytypes-8.swf \
sound-setTransform-propertytypes-8.swf.trace \
sound-setTransform-propertytypes.as \
+ sound-target-reference-5.swf \
+ sound-target-reference-5.swf.trace \
+ sound-target-reference-6.swf \
+ sound-target-reference-6.swf.trace \
+ sound-target-reference-7.swf \
+ sound-target-reference-7.swf.trace \
+ sound-target-reference-8.swf \
+ sound-target-reference-8.swf.trace \
+ sound-target-reference.as \
sound-textfield-5.swf \
sound-textfield-5.swf.trace \
sound-textfield-6.swf \
diff --git a/test/trace/sound-target-reference-5.swf b/test/trace/sound-target-reference-5.swf
new file mode 100644
index 0000000..517d5fc
Binary files /dev/null and b/test/trace/sound-target-reference-5.swf differ
diff --git a/test/trace/sound-target-reference-5.swf.trace b/test/trace/sound-target-reference-5.swf.trace
new file mode 100644
index 0000000..beecf3f
--- /dev/null
+++ b/test/trace/sound-target-reference-5.swf.trace
@@ -0,0 +1,5 @@
+10
+10
+
+
+14
diff --git a/test/trace/sound-target-reference-6.swf b/test/trace/sound-target-reference-6.swf
new file mode 100644
index 0000000..2995dc0
Binary files /dev/null and b/test/trace/sound-target-reference-6.swf differ
diff --git a/test/trace/sound-target-reference-6.swf.trace b/test/trace/sound-target-reference-6.swf.trace
new file mode 100644
index 0000000..dc83776
--- /dev/null
+++ b/test/trace/sound-target-reference-6.swf.trace
@@ -0,0 +1,10 @@
+10
+6
+10
+10
+14
+5 - 5
+3 - 3
+7 - 5
+7 - 7
+7 - 7
diff --git a/test/trace/sound-target-reference-7.swf b/test/trace/sound-target-reference-7.swf
new file mode 100644
index 0000000..cdd1303
Binary files /dev/null and b/test/trace/sound-target-reference-7.swf differ
diff --git a/test/trace/sound-target-reference-7.swf.trace b/test/trace/sound-target-reference-7.swf.trace
new file mode 100644
index 0000000..dc83776
--- /dev/null
+++ b/test/trace/sound-target-reference-7.swf.trace
@@ -0,0 +1,10 @@
+10
+6
+10
+10
+14
+5 - 5
+3 - 3
+7 - 5
+7 - 7
+7 - 7
diff --git a/test/trace/sound-target-reference-8.swf b/test/trace/sound-target-reference-8.swf
new file mode 100644
index 0000000..8468e59
Binary files /dev/null and b/test/trace/sound-target-reference-8.swf differ
diff --git a/test/trace/sound-target-reference-8.swf.trace b/test/trace/sound-target-reference-8.swf.trace
new file mode 100644
index 0000000..dc83776
--- /dev/null
+++ b/test/trace/sound-target-reference-8.swf.trace
@@ -0,0 +1,10 @@
+10
+6
+10
+10
+14
+5 - 5
+3 - 3
+7 - 5
+7 - 7
+7 - 7
diff --git a/test/trace/sound-target-reference.as b/test/trace/sound-target-reference.as
new file mode 100644
index 0000000..8b22322
--- /dev/null
+++ b/test/trace/sound-target-reference.as
@@ -0,0 +1,32 @@
+// makeswf -v 7 -s 200x150 -r 1 -o sound-target-reference.swf sound-target-reference.as
+
+createEmptyMovieClip ("a", 0);
+if (this == _root) {
+ Sound.prototype.toString = function () {
+ return "" + this.getVolume ();
+ };
+ Sound.prototype.toString2 = Sound.prototype.toString;
+ a.loadMovie (_url);
+ mult = 2;
+} else {
+ Sound.prototype.toString = function () {
+ return this.toString2 () + " - " + this.getVolume ();
+ };
+ getURL ("fscommand:quit", "");
+ mult = 1;
+}
+
+s = new Sound ();
+s.setVolume (mult * 3);
+s = new Sound (a);
+s.setVolume (mult * 5);
+s = new Sound (this);
+s.setVolume (mult * 7);
+
+trace (new Sound (a));
+setTarget ("a");
+trace (new Sound ());
+trace (new Sound ("a"));
+trace (new Sound ("/a"));
+setTarget ("");
+trace (new Sound (this));
commit 4ced9bdc39ebb80dbfa59566e822d15380831ed3
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Jun 18 13:05:14 2008 +0200
and another test
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 5b51803..ad8cae5 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -3154,6 +3154,15 @@ EXTRA_DIST = \
sound-textfield-8.swf \
sound-textfield-8.swf.trace \
sound-textfield.as \
+ sound-volume-5.swf \
+ sound-volume-5.swf.trace \
+ sound-volume-6.swf \
+ sound-volume-6.swf.trace \
+ sound-volume-7.swf \
+ sound-volume-7.swf.trace \
+ sound-volume-8.swf \
+ sound-volume-8.swf.trace \
+ sound-volume.as \
stack-overflow.as \
stack-overflow-5.swf \
stack-overflow-5.swf.trace \
diff --git a/test/trace/sound-volume-5.swf b/test/trace/sound-volume-5.swf
new file mode 100644
index 0000000..db7b3ba
Binary files /dev/null and b/test/trace/sound-volume-5.swf differ
diff --git a/test/trace/sound-volume-5.swf.trace b/test/trace/sound-volume-5.swf.trace
new file mode 100644
index 0000000..bd2a0d4
--- /dev/null
+++ b/test/trace/sound-volume-5.swf.trace
@@ -0,0 +1,10 @@
+from nonexistant name: { , , , } (, )
+after creating it: { , , , } (, )
+new movie with same name: { 100, 0, 0, 100} (100, 0)
+renaming that movie: { 100, 0, 0, 100} (100, 0)
+after removing the movie: { 100, 0, 0, 100} (100, 0)
+after loadSound: { 100, 0, 0, 100} (100, 0)
+{ 100, 0, 0, 100} (25, 0)
+{ 100, 0, 0, 100} (25, 0)
+{ 100, 0, 0, 100} (25, 0)
+{ 100, 0, 0, 100} (100, 0)
diff --git a/test/trace/sound-volume-6.swf b/test/trace/sound-volume-6.swf
new file mode 100644
index 0000000..684c05a
Binary files /dev/null and b/test/trace/sound-volume-6.swf differ
diff --git a/test/trace/sound-volume-6.swf.trace b/test/trace/sound-volume-6.swf.trace
new file mode 100644
index 0000000..bcd32fb
--- /dev/null
+++ b/test/trace/sound-volume-6.swf.trace
@@ -0,0 +1,10 @@
+from nonexistant name: { , , , } (, )
+after creating it: { 100, 0, 0, 100} (100, 0)
+new movie with same name: { 100, 0, 0, 100} (100, 0)
+renaming that movie: { , , , } (, )
+after removing the movie: { , , , } (, )
+after loadSound: { , , , } (, )
+{ , , , } (, )
+{ 100, 0, 0, 100} (100, 0)
+{ 100, 0, 0, 100} (100, 0)
+{ 100, 0, 0, 100} (100, 0)
diff --git a/test/trace/sound-volume-7.swf b/test/trace/sound-volume-7.swf
new file mode 100644
index 0000000..ed498f8
Binary files /dev/null and b/test/trace/sound-volume-7.swf differ
diff --git a/test/trace/sound-volume-7.swf.trace b/test/trace/sound-volume-7.swf.trace
new file mode 100644
index 0000000..5ff4154
--- /dev/null
+++ b/test/trace/sound-volume-7.swf.trace
@@ -0,0 +1,10 @@
+from nonexistant name: { undefined, undefined, undefined, undefined} (undefined, undefined)
+after creating it: { 100, 0, 0, 100} (100, 0)
+new movie with same name: { 100, 0, 0, 100} (100, 0)
+renaming that movie: { undefined, undefined, undefined, undefined} (undefined, undefined)
+after removing the movie: { undefined, undefined, undefined, undefined} (undefined, undefined)
+after loadSound: { undefined, undefined, undefined, undefined} (undefined, undefined)
+{ undefined, undefined, undefined, undefined} (undefined, undefined)
+{ 100, 0, 0, 100} (100, 0)
+{ 100, 0, 0, 100} (100, 0)
+{ 100, 0, 0, 100} (100, 0)
diff --git a/test/trace/sound-volume-8.swf b/test/trace/sound-volume-8.swf
new file mode 100644
index 0000000..194c5fd
Binary files /dev/null and b/test/trace/sound-volume-8.swf differ
diff --git a/test/trace/sound-volume-8.swf.trace b/test/trace/sound-volume-8.swf.trace
new file mode 100644
index 0000000..5ff4154
--- /dev/null
+++ b/test/trace/sound-volume-8.swf.trace
@@ -0,0 +1,10 @@
+from nonexistant name: { undefined, undefined, undefined, undefined} (undefined, undefined)
+after creating it: { 100, 0, 0, 100} (100, 0)
+new movie with same name: { 100, 0, 0, 100} (100, 0)
+renaming that movie: { undefined, undefined, undefined, undefined} (undefined, undefined)
+after removing the movie: { undefined, undefined, undefined, undefined} (undefined, undefined)
+after loadSound: { undefined, undefined, undefined, undefined} (undefined, undefined)
+{ undefined, undefined, undefined, undefined} (undefined, undefined)
+{ 100, 0, 0, 100} (100, 0)
+{ 100, 0, 0, 100} (100, 0)
+{ 100, 0, 0, 100} (100, 0)
diff --git a/test/trace/sound-volume.as b/test/trace/sound-volume.as
new file mode 100644
index 0000000..1719a2b
--- /dev/null
+++ b/test/trace/sound-volume.as
@@ -0,0 +1,32 @@
+// makeswf -v 7 -s 200x150 -r 1 -o sound-volume.swf sound-volume.as
+
+Sound.prototype.toString = function () {
+ var tf = this.getTransform ();
+ return "{ " + tf.ll + ", " + tf.rl + ", " + tf.lr + ", " + tf.rr + "} (" + this.getVolume () + ", " + this.getPan () + ")";
+};
+stop();
+
+s = new Sound ("a");
+s.setVolume (50);
+trace ("from nonexistant name: " + s);
+createEmptyMovieClip ("a", 0);
+trace ("after creating it: " + s);
+s = new Sound (a);
+trace ("new movie with same name: " + s);
+a._name = "b";
+trace ("renaming that movie: " + s);
+b.removeMovieClip ();
+trace ("after removing the movie: " + s);
+
+s.loadSound ("test.mp3", true);
+trace ("after loadSound: " + s);
+s.setVolume (25);
+trace (s);
+
+trace (new Sound (a));
+setTarget ("a");
+trace (new Sound ());
+setTarget ("");
+trace (new Sound (this));
+
+getURL ("fscommand:quit", "");
commit d271bfe1843e483824b7535f4bdd445dcd2f38f2
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Jun 18 11:51:11 2008 +0200
and another test
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 56d3c45..5b51803 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -1681,6 +1681,15 @@ EXTRA_DIST = \
loadSound-matrix-repeat-8.swf \
loadSound-matrix-repeat-8.swf.trace \
loadSound-matrix-repeat.as \
+ loadSound-matrix-reset-5.swf \
+ loadSound-matrix-reset-5.swf.trace \
+ loadSound-matrix-reset-6.swf \
+ loadSound-matrix-reset-6.swf.trace \
+ loadSound-matrix-reset-7.swf \
+ loadSound-matrix-reset-7.swf.trace \
+ loadSound-matrix-reset-8.swf \
+ loadSound-matrix-reset-8.swf.trace \
+ loadSound-matrix-reset.as \
loadvariables.as \
loadvariables-5.swf \
loadvariables-5.swf.trace \
diff --git a/test/trace/loadSound-matrix-reset-5.swf b/test/trace/loadSound-matrix-reset-5.swf
new file mode 100644
index 0000000..b30f3c3
Binary files /dev/null and b/test/trace/loadSound-matrix-reset-5.swf differ
diff --git a/test/trace/loadSound-matrix-reset-5.swf.trace b/test/trace/loadSound-matrix-reset-5.swf.trace
new file mode 100644
index 0000000..19432be
--- /dev/null
+++ b/test/trace/loadSound-matrix-reset-5.swf.trace
@@ -0,0 +1,6 @@
+{ 100, 0, 0, 100} (25, 0)
+{ 100, 0, 0, 100} (100, 0)
+{ 100, 0, 0, 100} (25, 0)
+{ 100, 0, 0, 100} (25, 0)
+{ 100, 0, 0, 100} (25, 0)
+{ 100, 0, 0, 100} (25, 0)
diff --git a/test/trace/loadSound-matrix-reset-6.swf b/test/trace/loadSound-matrix-reset-6.swf
new file mode 100644
index 0000000..c305380
Binary files /dev/null and b/test/trace/loadSound-matrix-reset-6.swf differ
diff --git a/test/trace/loadSound-matrix-reset-6.swf.trace b/test/trace/loadSound-matrix-reset-6.swf.trace
new file mode 100644
index 0000000..22a4ae2
--- /dev/null
+++ b/test/trace/loadSound-matrix-reset-6.swf.trace
@@ -0,0 +1,6 @@
+{ 100, 0, 0, 100} (100, 0)
+{ 100, 0, 0, 100} (100, 0)
+{ 100, 0, 0, 100} (100, 0)
+{ 100, 0, 0, 100} (100, 0)
+{ 100, 0, 0, 100} (100, 0)
+{ 100, 0, 0, 100} (100, 0)
diff --git a/test/trace/loadSound-matrix-reset-7.swf b/test/trace/loadSound-matrix-reset-7.swf
new file mode 100644
index 0000000..8aa5bbb
Binary files /dev/null and b/test/trace/loadSound-matrix-reset-7.swf differ
diff --git a/test/trace/loadSound-matrix-reset-7.swf.trace b/test/trace/loadSound-matrix-reset-7.swf.trace
new file mode 100644
index 0000000..22a4ae2
--- /dev/null
+++ b/test/trace/loadSound-matrix-reset-7.swf.trace
@@ -0,0 +1,6 @@
+{ 100, 0, 0, 100} (100, 0)
+{ 100, 0, 0, 100} (100, 0)
+{ 100, 0, 0, 100} (100, 0)
+{ 100, 0, 0, 100} (100, 0)
+{ 100, 0, 0, 100} (100, 0)
+{ 100, 0, 0, 100} (100, 0)
diff --git a/test/trace/loadSound-matrix-reset-8.swf b/test/trace/loadSound-matrix-reset-8.swf
new file mode 100644
index 0000000..9befb87
Binary files /dev/null and b/test/trace/loadSound-matrix-reset-8.swf differ
diff --git a/test/trace/loadSound-matrix-reset-8.swf.trace b/test/trace/loadSound-matrix-reset-8.swf.trace
new file mode 100644
index 0000000..22a4ae2
--- /dev/null
+++ b/test/trace/loadSound-matrix-reset-8.swf.trace
@@ -0,0 +1,6 @@
+{ 100, 0, 0, 100} (100, 0)
+{ 100, 0, 0, 100} (100, 0)
+{ 100, 0, 0, 100} (100, 0)
+{ 100, 0, 0, 100} (100, 0)
+{ 100, 0, 0, 100} (100, 0)
+{ 100, 0, 0, 100} (100, 0)
diff --git a/test/trace/loadSound-matrix-reset.as b/test/trace/loadSound-matrix-reset.as
new file mode 100644
index 0000000..ac71148
--- /dev/null
+++ b/test/trace/loadSound-matrix-reset.as
@@ -0,0 +1,35 @@
+// makeswf -v 7 -s 200x150 -r 1 -o loadSound-matrix-reset.swf loadSound-matrix-reset.as
+
+Sound.prototype.toString = function () {
+ var tf = this.getTransform ();
+ return "{ " + tf.ll + ", " + tf.rl + ", " + tf.lr + ", " + tf.rr + "} (" + this.getVolume () + ", " + this.getPan () + ")";
+};
+stop();
+
+s = new Sound (this);
+s.loadSound ("test.mp3", true);
+s.setVolume (25);
+
+trace (new Sound (this));
+trace (new Sound ());
+
+s = new Sound ();
+s.setVolume (25);
+s.loadSound ("test.mp3", true);
+trace (s);
+
+s = new Sound ();
+s.loadSound ("test.mp3", true);
+trace (s);
+
+s = new Sound (this);
+s.setVolume (25);
+s.loadSound ("test.mp3", true);
+trace (s);
+
+s = new Sound (this);
+s.loadSound ("test.mp3", true);
+trace (s);
+
+
+getURL ("fscommand:quit", "");
commit 50384b892f4330917e90a59437f9844b5a720b69
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Jun 18 11:39:56 2008 +0200
and another test
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index ab13cc8..56d3c45 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -1663,6 +1663,15 @@ EXTRA_DIST = \
loadobject-sendandload-7.swf.trace \
loadobject-sendandload-8.swf \
loadobject-sendandload-8.swf.trace \
+ loadSound-matrix-no-target-5.swf \
+ loadSound-matrix-no-target-5.swf.trace \
+ loadSound-matrix-no-target-6.swf \
+ loadSound-matrix-no-target-6.swf.trace \
+ loadSound-matrix-no-target-7.swf \
+ loadSound-matrix-no-target-7.swf.trace \
+ loadSound-matrix-no-target-8.swf \
+ loadSound-matrix-no-target-8.swf.trace \
+ loadSound-matrix-no-target.as \
loadSound-matrix-repeat-5.swf \
loadSound-matrix-repeat-5.swf.trace \
loadSound-matrix-repeat-6.swf \
diff --git a/test/trace/loadSound-matrix-no-target-5.swf b/test/trace/loadSound-matrix-no-target-5.swf
new file mode 100644
index 0000000..edcf50a
Binary files /dev/null and b/test/trace/loadSound-matrix-no-target-5.swf differ
diff --git a/test/trace/loadSound-matrix-no-target-5.swf.trace b/test/trace/loadSound-matrix-no-target-5.swf.trace
new file mode 100644
index 0000000..2a1418b
--- /dev/null
+++ b/test/trace/loadSound-matrix-no-target-5.swf.trace
@@ -0,0 +1,2 @@
+{ 100, 0, 0, 100} (100, 0)
+{ 100, 0, 0, 100} (100, 0)
diff --git a/test/trace/loadSound-matrix-no-target-6.swf b/test/trace/loadSound-matrix-no-target-6.swf
new file mode 100644
index 0000000..ae3efed
Binary files /dev/null and b/test/trace/loadSound-matrix-no-target-6.swf differ
diff --git a/test/trace/loadSound-matrix-no-target-6.swf.trace b/test/trace/loadSound-matrix-no-target-6.swf.trace
new file mode 100644
index 0000000..4548812
--- /dev/null
+++ b/test/trace/loadSound-matrix-no-target-6.swf.trace
@@ -0,0 +1,2 @@
+{ 100, 0, 0, 100} (100, 0)
+{ , , , } (, )
diff --git a/test/trace/loadSound-matrix-no-target-7.swf b/test/trace/loadSound-matrix-no-target-7.swf
new file mode 100644
index 0000000..9f758aa
Binary files /dev/null and b/test/trace/loadSound-matrix-no-target-7.swf differ
diff --git a/test/trace/loadSound-matrix-no-target-7.swf.trace b/test/trace/loadSound-matrix-no-target-7.swf.trace
new file mode 100644
index 0000000..7a224a7
--- /dev/null
+++ b/test/trace/loadSound-matrix-no-target-7.swf.trace
@@ -0,0 +1,2 @@
+{ 100, 0, 0, 100} (100, 0)
+{ undefined, undefined, undefined, undefined} (undefined, undefined)
diff --git a/test/trace/loadSound-matrix-no-target-8.swf b/test/trace/loadSound-matrix-no-target-8.swf
new file mode 100644
index 0000000..fe2b19c
Binary files /dev/null and b/test/trace/loadSound-matrix-no-target-8.swf differ
diff --git a/test/trace/loadSound-matrix-no-target-8.swf.trace b/test/trace/loadSound-matrix-no-target-8.swf.trace
new file mode 100644
index 0000000..7a224a7
--- /dev/null
+++ b/test/trace/loadSound-matrix-no-target-8.swf.trace
@@ -0,0 +1,2 @@
+{ 100, 0, 0, 100} (100, 0)
+{ undefined, undefined, undefined, undefined} (undefined, undefined)
diff --git a/test/trace/loadSound-matrix-no-target.as b/test/trace/loadSound-matrix-no-target.as
new file mode 100644
index 0000000..e27292f
--- /dev/null
+++ b/test/trace/loadSound-matrix-no-target.as
@@ -0,0 +1,17 @@
+// makeswf -v 7 -s 200x150 -r 1 -o loadSound-matrix-repeat.swf loadSound-matrix-no-target.as
+
+Sound.prototype.toString = function () {
+ var tf = this.getTransform ();
+ return "{ " + tf.ll + ", " + tf.rl + ", " + tf.lr + ", " + tf.rr + "} (" + this.getVolume () + ", " + this.getPan () + ")";
+};
+
+createEmptyMovieClip ("a", 0);
+s = new Sound (a);
+t = new Sound (a);
+s.loadSound ("test.mp3", true);
+a.removeMovieClip ();
+trace (s);
+trace (t);
+
+
+getURL ("fscommand:quit", "");
commit 13811b93cf16f2dc9359fdeeec4718c3f6e8621a
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Jun 18 11:36:24 2008 +0200
add test
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 587e6f0..ab13cc8 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -1663,6 +1663,15 @@ EXTRA_DIST = \
loadobject-sendandload-7.swf.trace \
loadobject-sendandload-8.swf \
loadobject-sendandload-8.swf.trace \
+ loadSound-matrix-repeat-5.swf \
+ loadSound-matrix-repeat-5.swf.trace \
+ loadSound-matrix-repeat-6.swf \
+ loadSound-matrix-repeat-6.swf.trace \
+ loadSound-matrix-repeat-7.swf \
+ loadSound-matrix-repeat-7.swf.trace \
+ loadSound-matrix-repeat-8.swf \
+ loadSound-matrix-repeat-8.swf.trace \
+ loadSound-matrix-repeat.as \
loadvariables.as \
loadvariables-5.swf \
loadvariables-5.swf.trace \
diff --git a/test/trace/loadSound-matrix-repeat-5.swf b/test/trace/loadSound-matrix-repeat-5.swf
new file mode 100644
index 0000000..21f0842
Binary files /dev/null and b/test/trace/loadSound-matrix-repeat-5.swf differ
diff --git a/test/trace/loadSound-matrix-repeat-5.swf.trace b/test/trace/loadSound-matrix-repeat-5.swf.trace
new file mode 100644
index 0000000..56ba3ff
--- /dev/null
+++ b/test/trace/loadSound-matrix-repeat-5.swf.trace
@@ -0,0 +1,2 @@
+{ 100, 0, 0, 100} (25, 0)
+{ 100, 0, 0, 100} (25, 0)
diff --git a/test/trace/loadSound-matrix-repeat-6.swf b/test/trace/loadSound-matrix-repeat-6.swf
new file mode 100644
index 0000000..ec71c9e
Binary files /dev/null and b/test/trace/loadSound-matrix-repeat-6.swf differ
diff --git a/test/trace/loadSound-matrix-repeat-6.swf.trace b/test/trace/loadSound-matrix-repeat-6.swf.trace
new file mode 100644
index 0000000..0220732
--- /dev/null
+++ b/test/trace/loadSound-matrix-repeat-6.swf.trace
@@ -0,0 +1,2 @@
+{ 100, 0, 0, 100} (25, 0)
+{ 100, 0, 0, 100} (100, 0)
diff --git a/test/trace/loadSound-matrix-repeat-7.swf b/test/trace/loadSound-matrix-repeat-7.swf
new file mode 100644
index 0000000..b989aaa
Binary files /dev/null and b/test/trace/loadSound-matrix-repeat-7.swf differ
diff --git a/test/trace/loadSound-matrix-repeat-7.swf.trace b/test/trace/loadSound-matrix-repeat-7.swf.trace
new file mode 100644
index 0000000..0220732
--- /dev/null
+++ b/test/trace/loadSound-matrix-repeat-7.swf.trace
@@ -0,0 +1,2 @@
+{ 100, 0, 0, 100} (25, 0)
+{ 100, 0, 0, 100} (100, 0)
diff --git a/test/trace/loadSound-matrix-repeat-8.swf b/test/trace/loadSound-matrix-repeat-8.swf
new file mode 100644
index 0000000..dbe4066
Binary files /dev/null and b/test/trace/loadSound-matrix-repeat-8.swf differ
diff --git a/test/trace/loadSound-matrix-repeat-8.swf.trace b/test/trace/loadSound-matrix-repeat-8.swf.trace
new file mode 100644
index 0000000..0220732
--- /dev/null
+++ b/test/trace/loadSound-matrix-repeat-8.swf.trace
@@ -0,0 +1,2 @@
+{ 100, 0, 0, 100} (25, 0)
+{ 100, 0, 0, 100} (100, 0)
diff --git a/test/trace/loadSound-matrix-repeat.as b/test/trace/loadSound-matrix-repeat.as
new file mode 100644
index 0000000..bbf27cc
--- /dev/null
+++ b/test/trace/loadSound-matrix-repeat.as
@@ -0,0 +1,17 @@
+// makeswf -v 7 -s 200x150 -r 1 -o loadSound-matrix-repeat.swf loadSound-matrix-repeat.as
+
+Sound.prototype.toString = function () {
+ var tf = this.getTransform ();
+ return "{ " + tf.ll + ", " + tf.rl + ", " + tf.lr + ", " + tf.rr + "} (" + this.getVolume () + ", " + this.getPan () + ")";
+};
+stop();
+
+s = new Sound ();
+s.loadSound ("test.mp3", true);
+s.setVolume (25);
+trace (s);
+s.loadSound ("test.mp3", true);
+trace (s);
+
+
+getURL ("fscommand:quit", "");
commit b722c9fc43ab0d067e96eab41cc827f75a5a9b10
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Jun 18 10:02:21 2008 +0200
add mp3 test file for Sound.loadSound()
diff --git a/test/trace/test.mp3 b/test/trace/test.mp3
new file mode 100644
index 0000000..a12bf44
Binary files /dev/null and b/test/trace/test.mp3 differ
commit 77b43ea59330219783024d3492e3cdf25d51b526
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Jun 18 09:30:44 2008 +0200
implement a SoundProvider get_matrix function
This allows loadSound to use its own matrix
diff --git a/swfdec/swfdec_audio.c b/swfdec/swfdec_audio.c
index 3c68d8f..260eb42 100644
--- a/swfdec/swfdec_audio.c
+++ b/swfdec/swfdec_audio.c
@@ -204,7 +204,6 @@ void
swfdec_audio_set_matrix (SwfdecAudio *audio, const SwfdecSoundMatrix *matrix)
{
g_return_if_fail (SWFDEC_IS_AUDIO (audio));
- g_return_if_fail (matrix != NULL);
audio->matrix = matrix;
}
diff --git a/swfdec/swfdec_load_sound.c b/swfdec/swfdec_load_sound.c
index 8393738..0a44c80 100644
--- a/swfdec/swfdec_load_sound.c
+++ b/swfdec/swfdec_load_sound.c
@@ -51,7 +51,7 @@ swfdec_load_sound_sound_provider_start (SwfdecSoundProvider *provider,
SWFDEC_FIXME ("implement starting at offset %"G_GSIZE_FORMAT" with %u loops",
samples_offset, loops);
}
- sound->audio = swfdec_audio_load_new (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (provider)->context), sound);
+ sound->audio = swfdec_audio_load_new (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (actor)->context), sound);
swfdec_audio_set_matrix (sound->audio, &sound->sound_matrix);
}
@@ -69,11 +69,20 @@ swfdec_load_sound_sound_provider_stop (SwfdecSoundProvider *provider, SwfdecActo
sound->audio = NULL;
}
+static SwfdecSoundMatrix *
+swfdec_load_sound_sound_provider_get_matrix (SwfdecSoundProvider *provider)
+{
+ SwfdecLoadSound *sound = SWFDEC_LOAD_SOUND (provider);
+
+ return &sound->sound_matrix;
+}
+
static void
swfdec_load_sound_sound_provider_init (SwfdecSoundProviderInterface *iface)
{
iface->start = swfdec_load_sound_sound_provider_start;
iface->stop = swfdec_load_sound_sound_provider_stop;
+ iface->get_matrix = swfdec_load_sound_sound_provider_get_matrix;
}
/*** SWFDEC_STREAM_TARGET ***/
diff --git a/swfdec/swfdec_sound.c b/swfdec/swfdec_sound.c
index ac53f4a..581c0eb 100644
--- a/swfdec/swfdec_sound.c
+++ b/swfdec/swfdec_sound.c
@@ -79,11 +79,18 @@ swfdec_sound_sound_provider_stop (SwfdecSoundProvider *provider, SwfdecActor *ac
swfdec_sound_object_should_stop, &data);
}
+static SwfdecSoundMatrix *
+swfdec_sound_sound_provider_get_matrix (SwfdecSoundProvider *provider)
+{
+ return NULL;
+}
+
static void
swfdec_sound_sound_provider_init (SwfdecSoundProviderInterface *iface)
{
iface->start = swfdec_sound_sound_provider_start;
iface->stop = swfdec_sound_sound_provider_stop;
+ iface->get_matrix = swfdec_sound_sound_provider_get_matrix;
}
/*** SWFDEC_SOUND ***/
diff --git a/swfdec/swfdec_sound_object.c b/swfdec/swfdec_sound_object.c
index 7caa8ff..cb278f9 100644
--- a/swfdec/swfdec_sound_object.c
+++ b/swfdec/swfdec_sound_object.c
@@ -107,6 +107,12 @@ swfdec_sound_object_get_sound (SwfdecSoundObject *sound, const char *name)
static SwfdecSoundMatrix *
swfdec_sound_object_get_matrix (SwfdecSoundObject *sound)
{
+ if (sound->provider) {
+ SwfdecSoundMatrix *ret = swfdec_sound_provider_get_matrix (sound->provider);
+ if (ret)
+ return ret;
+ }
+
if (sound->target == NULL) {
return &SWFDEC_PLAYER (SWFDEC_AS_OBJECT (sound)->context)->priv->sound_matrix;
} else {
diff --git a/swfdec/swfdec_sound_provider.c b/swfdec/swfdec_sound_provider.c
index ff781ec..3bc83f5 100644
--- a/swfdec/swfdec_sound_provider.c
+++ b/swfdec/swfdec_sound_provider.c
@@ -88,3 +88,13 @@ swfdec_sound_provider_stop (SwfdecSoundProvider *provider, SwfdecActor *actor)
iface->stop (provider, actor);
}
+SwfdecSoundMatrix *
+swfdec_sound_provider_get_matrix (SwfdecSoundProvider *provider)
+{
+ SwfdecSoundProviderInterface *iface;
+
+ g_return_val_if_fail (SWFDEC_IS_SOUND_PROVIDER (provider), NULL);
+
+ iface = SWFDEC_SOUND_PROVIDER_GET_INTERFACE (provider);
+ return iface->get_matrix (provider);
+}
diff --git a/swfdec/swfdec_sound_provider.h b/swfdec/swfdec_sound_provider.h
index 06f965a..0fe1e0b 100644
--- a/swfdec/swfdec_sound_provider.h
+++ b/swfdec/swfdec_sound_provider.h
@@ -21,6 +21,7 @@
#define __SWFDEC_SOUND_PROVIDER_H__
#include <swfdec/swfdec.h>
+#include <swfdec/swfdec_sound_matrix.h>
#include <swfdec/swfdec_types.h>
G_BEGIN_DECLS
@@ -43,6 +44,7 @@ struct _SwfdecSoundProviderInterface {
guint loops);
void (* stop) (SwfdecSoundProvider * provider,
SwfdecActor * actor);
+ SwfdecSoundMatrix * (* get_matrix) (SwfdecSoundProvider * provider);
};
GType swfdec_sound_provider_get_type (void) G_GNUC_CONST;
@@ -53,6 +55,7 @@ void swfdec_sound_provider_start (SwfdecSoundProvider * provider,
guint loops);
void swfdec_sound_provider_stop (SwfdecSoundProvider * provider,
SwfdecActor * actor);
+SwfdecSoundMatrix * swfdec_sound_provider_get_matrix (SwfdecSoundProvider * provider);
G_END_DECLS
commit ec921e1cffa8d7fcc8c11c9ba572ca75f26790fc
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Jun 18 09:15:53 2008 +0200
add API to set sound matrices
diff --git a/swfdec/swfdec_audio.c b/swfdec/swfdec_audio.c
index b74d05f..3c68d8f 100644
--- a/swfdec/swfdec_audio.c
+++ b/swfdec/swfdec_audio.c
@@ -197,6 +197,16 @@ swfdec_audio_set_actor (SwfdecAudio *audio, SwfdecActor *actor)
g_object_unref (audio->actor);
}
audio->actor = actor;
+ swfdec_audio_set_matrix (audio, actor ? &actor->sound_matrix : NULL);
+}
+
+void
+swfdec_audio_set_matrix (SwfdecAudio *audio, const SwfdecSoundMatrix *matrix)
+{
+ g_return_if_fail (SWFDEC_IS_AUDIO (audio));
+ g_return_if_fail (matrix != NULL);
+
+ audio->matrix = matrix;
}
/* FIXME: This function is pretty much a polling approach at sound matrix
@@ -210,16 +220,16 @@ swfdec_audio_update_matrix (SwfdecAudio *audio)
g_return_if_fail (SWFDEC_IS_AUDIO (audio));
- if (audio->actor) {
- swfdec_sound_matrix_multiply (&sound, &audio->actor->sound_matrix,
+ if (audio->matrix) {
+ swfdec_sound_matrix_multiply (&sound, audio->matrix,
&audio->player->priv->sound_matrix);
} else if (audio->player) {
sound = audio->player->priv->sound_matrix;
}
- if (swfdec_sound_matrix_is_equal (&sound, &audio->matrix))
+ if (swfdec_sound_matrix_is_equal (&sound, &audio->matrix_cache))
return;
- audio->matrix = sound;
+ audio->matrix_cache = sound;
g_signal_emit (audio, signals[CHANGED], 0);
}
@@ -253,7 +263,7 @@ swfdec_audio_render (SwfdecAudio *audio, gint16 *dest,
klass = SWFDEC_AUDIO_GET_CLASS (audio);
rendered = klass->render (audio, dest, start_offset, n_samples);
- swfdec_sound_matrix_apply (&audio->matrix, dest, rendered);
+ swfdec_sound_matrix_apply (&audio->matrix_cache, dest, rendered);
return rendered;
}
diff --git a/swfdec/swfdec_audio_internal.h b/swfdec/swfdec_audio_internal.h
index b88069a..d225d71 100644
--- a/swfdec/swfdec_audio_internal.h
+++ b/swfdec/swfdec_audio_internal.h
@@ -36,12 +36,13 @@ typedef guint SwfdecAudioFormat;
struct _SwfdecAudio {
- GObject object;
+ GObject object;
- SwfdecPlayer * player; /* the player that plays us */
- gboolean added; /* set to TRUE after the added signal has been emitted */
- SwfdecActor * actor; /* NULL or movieclip that controls our volume */
- SwfdecSoundMatrix matrix; /* matrix used by this audio instance */
+ SwfdecPlayer * player; /* the player that plays us */
+ gboolean added; /* set to TRUE after the added signal has been emitted */
+ SwfdecActor * actor; /* NULL or movieclip that controls our volume */
+ const SwfdecSoundMatrix * matrix; /* matrix this audio references or NULL if none */
+ SwfdecSoundMatrix matrix_cache; /* matrix used by this audio instance */
};
struct _SwfdecAudioClass {
@@ -60,6 +61,8 @@ void swfdec_audio_add (SwfdecAudio * audio,
void swfdec_audio_remove (SwfdecAudio * audio);
void swfdec_audio_set_actor (SwfdecAudio * audio,
SwfdecActor * actor);
+void swfdec_audio_set_matrix (SwfdecAudio * audio,
+ const SwfdecSoundMatrix *matrix);
gsize swfdec_audio_iterate (SwfdecAudio * audio,
gsize n_samples);
diff --git a/swfdec/swfdec_load_sound.c b/swfdec/swfdec_load_sound.c
index cb3a878..8393738 100644
--- a/swfdec/swfdec_load_sound.c
+++ b/swfdec/swfdec_load_sound.c
@@ -52,19 +52,21 @@ swfdec_load_sound_sound_provider_start (SwfdecSoundProvider *provider,
samples_offset, loops);
}
sound->audio = swfdec_audio_load_new (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (provider)->context), sound);
+ swfdec_audio_set_matrix (sound->audio, &sound->sound_matrix);
}
static void
swfdec_load_sound_sound_provider_stop (SwfdecSoundProvider *provider, SwfdecActor *actor)
{
- SwfdecLoadSound *load = SWFDEC_LOAD_SOUND (provider);
+ SwfdecLoadSound *sound = SWFDEC_LOAD_SOUND (provider);
- if (load->audio == NULL)
+ if (sound->audio == NULL)
return;
- swfdec_audio_remove (load->audio);
- g_object_unref (load->audio);
- load->audio = NULL;
+ swfdec_audio_set_matrix (sound->audio, NULL);
+ swfdec_audio_remove (sound->audio);
+ g_object_unref (sound->audio);
+ sound->audio = NULL;
}
static void
@@ -334,6 +336,7 @@ swfdec_load_sound_dispose (GObject *object)
}
g_free (sound->url);
if (sound->audio) {
+ swfdec_audio_set_matrix (sound->audio, NULL);
swfdec_audio_remove (sound->audio);
g_object_unref (sound->audio);
sound->audio = NULL;
@@ -354,6 +357,8 @@ static void
swfdec_load_sound_init (SwfdecLoadSound *sound)
{
sound->frames = g_ptr_array_new ();
+
+ swfdec_sound_matrix_init_identity (&sound->sound_matrix);
}
static void
diff --git a/swfdec/swfdec_load_sound.h b/swfdec/swfdec_load_sound.h
index e175b94..6e5cc8b 100644
--- a/swfdec/swfdec_load_sound.h
+++ b/swfdec/swfdec_load_sound.h
@@ -22,6 +22,7 @@
#include <swfdec/swfdec_as_object.h>
#include <swfdec/swfdec_audio.h>
+#include <swfdec/swfdec_sound_matrix.h>
#include <swfdec/swfdec_stream.h>
#include <swfdec/swfdec_types.h>
@@ -48,6 +49,7 @@ struct _SwfdecLoadSound
SwfdecStream * stream; /* stream we're parsing or NULL when done parsing */
GPtrArray * frames; /* buffers pointing to the frames of this file */
SwfdecAudio * audio; /* the stream currently running */
+ SwfdecSoundMatrix sound_matrix; /* matrix we reference */
};
struct _SwfdecLoadSoundClass
commit 4c368b5d380894084edb0f54993c9122d8d4b4d1
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Jun 18 00:03:32 2008 +0200
reimplement Sound.stop() with providers
diff --git a/swfdec/swfdec_load_sound.c b/swfdec/swfdec_load_sound.c
index 56ff312..cb3a878 100644
--- a/swfdec/swfdec_load_sound.c
+++ b/swfdec/swfdec_load_sound.c
@@ -24,6 +24,7 @@
#include "swfdec_load_sound.h"
#include "swfdec_as_strings.h"
#include "swfdec_audio_decoder.h"
+#include "swfdec_audio_internal.h"
#include "swfdec_audio_load.h"
#include "swfdec_bits.h"
#include "swfdec_buffer.h"
@@ -41,20 +42,36 @@ swfdec_load_sound_sound_provider_start (SwfdecSoundProvider *provider,
SwfdecActor *actor, gsize samples_offset, guint loops)
{
SwfdecLoadSound *sound = SWFDEC_LOAD_SOUND (provider);
- SwfdecAudio *audio;
+ if (sound->audio) {
+ swfdec_audio_remove (sound->audio);
+ g_object_unref (sound->audio);
+ }
if (samples_offset > 0 || loops > 1) {
SWFDEC_FIXME ("implement starting at offset %"G_GSIZE_FORMAT" with %u loops",
samples_offset, loops);
}
- audio = swfdec_audio_load_new (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (provider)->context), sound);
- g_object_unref (audio);
+ sound->audio = swfdec_audio_load_new (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (provider)->context), sound);
+}
+
+static void
+swfdec_load_sound_sound_provider_stop (SwfdecSoundProvider *provider, SwfdecActor *actor)
+{
+ SwfdecLoadSound *load = SWFDEC_LOAD_SOUND (provider);
+
+ if (load->audio == NULL)
+ return;
+
+ swfdec_audio_remove (load->audio);
+ g_object_unref (load->audio);
+ load->audio = NULL;
}
static void
swfdec_load_sound_sound_provider_init (SwfdecSoundProviderInterface *iface)
{
iface->start = swfdec_load_sound_sound_provider_start;
+ iface->stop = swfdec_load_sound_sound_provider_stop;
}
/*** SWFDEC_STREAM_TARGET ***/
@@ -316,6 +333,11 @@ swfdec_load_sound_dispose (GObject *object)
sound->stream = NULL;
}
g_free (sound->url);
+ if (sound->audio) {
+ swfdec_audio_remove (sound->audio);
+ g_object_unref (sound->audio);
+ sound->audio = NULL;
+ }
G_OBJECT_CLASS (swfdec_load_sound_parent_class)->dispose (object);
}
diff --git a/swfdec/swfdec_load_sound.h b/swfdec/swfdec_load_sound.h
index f5e7e97..e175b94 100644
--- a/swfdec/swfdec_load_sound.h
+++ b/swfdec/swfdec_load_sound.h
@@ -21,6 +21,7 @@
#define _SWFDEC_LOAD_SOUND_H_
#include <swfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_audio.h>
#include <swfdec/swfdec_stream.h>
#include <swfdec/swfdec_types.h>
@@ -46,6 +47,7 @@ struct _SwfdecLoadSound
char * url; /* URL we are loading - FIXME: make the security stuff hand us a loader */
SwfdecStream * stream; /* stream we're parsing or NULL when done parsing */
GPtrArray * frames; /* buffers pointing to the frames of this file */
+ SwfdecAudio * audio; /* the stream currently running */
};
struct _SwfdecLoadSoundClass
diff --git a/swfdec/swfdec_sound.c b/swfdec/swfdec_sound.c
index 92b0b62..ac53f4a 100644
--- a/swfdec/swfdec_sound.c
+++ b/swfdec/swfdec_sound.c
@@ -51,10 +51,39 @@ swfdec_sound_sound_provider_start (SwfdecSoundProvider *provider,
g_object_unref (audio);
}
+typedef struct {
+ SwfdecActor * actor;
+ SwfdecSound * sound;
+} RemoveData;
+
+static gboolean
+swfdec_sound_object_should_stop (SwfdecAudio *audio, gpointer datap)
+{
+ RemoveData *data = datap;
+ SwfdecAudioEvent *event;
+
+ if (!SWFDEC_IS_AUDIO_EVENT (audio))
+ return FALSE;
+ event = SWFDEC_AUDIO_EVENT (audio);
+ if (event->sound != data->sound)
+ return FALSE;
+ return audio->actor == data->actor;
+}
+
+static void
+swfdec_sound_sound_provider_stop (SwfdecSoundProvider *provider, SwfdecActor *actor)
+{
+ RemoveData data = { actor, SWFDEC_SOUND (provider) };
+
+ swfdec_player_stop_sounds (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (actor)->context),
+ swfdec_sound_object_should_stop, &data);
+}
+
static void
swfdec_sound_sound_provider_init (SwfdecSoundProviderInterface *iface)
{
iface->start = swfdec_sound_sound_provider_start;
+ iface->stop = swfdec_sound_sound_provider_stop;
}
/*** SWFDEC_SOUND ***/
diff --git a/swfdec/swfdec_sound_object.c b/swfdec/swfdec_sound_object.c
index 830b90e..7caa8ff 100644
--- a/swfdec/swfdec_sound_object.c
+++ b/swfdec/swfdec_sound_object.c
@@ -28,12 +28,11 @@
#include "swfdec_as_native_function.h"
#include "swfdec_as_object.h"
#include "swfdec_as_strings.h"
-#include "swfdec_audio_event.h"
-#include "swfdec_audio_internal.h"
#include "swfdec_debug.h"
#include "swfdec_internal.h"
#include "swfdec_player_internal.h"
#include "swfdec_resource.h"
+#include "swfdec_sound.h"
/*** SwfdecSoundObject ***/
@@ -409,56 +408,30 @@ swfdec_sound_object_start (SwfdecAsContext *cx, SwfdecAsObject *object, guint ar
swfdec_sound_provider_start (sound->provider, actor, offset * 44100, loops);
}
-#if 0
-typedef struct {
- SwfdecMovie * movie;
- gpointer sound;
-} RemoveData;
-
-static gboolean
-swfdec_sound_object_should_stop (SwfdecAudio *audio, gpointer datap)
-{
- RemoveData *data = datap;
- SwfdecAudioEvent *event;
-
- if (!SWFDEC_IS_AUDIO_EVENT (audio))
- return FALSE;
- event = SWFDEC_AUDIO_EVENT (audio);
- if (data->sound != NULL && event->sound != data->sound)
- return FALSE;
- /* FIXME: also check the movie is identical */
- return TRUE;
-}
-#endif
-
SWFDEC_AS_NATIVE (500, 6, swfdec_sound_object_stop)
void
swfdec_sound_object_stop (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
SwfdecAsValue *argv, SwfdecAsValue *ret)
{
-#if 0
SwfdecSoundObject *sound;
const char *name;
- RemoveData data;
+ SwfdecSound *stopme;
+ SwfdecActor *actor;
SWFDEC_AS_CHECK (SWFDEC_TYPE_SOUND_OBJECT, &sound, "|s", &name);
+ actor = swfdec_sound_object_get_actor (sound);
+ if (actor == NULL)
+ return;
- if (sound->global) {
- data.movie = NULL;
- } else {
- data.movie = sound->target;
- }
if (argc > 0) {
- data.sound = swfdec_sound_object_get_sound (sound, name);
- if (data.sound == NULL)
+ stopme = swfdec_sound_object_get_sound (sound, name);
+ if (stopme == NULL)
return;
+ if (sound->provider == NULL || SWFDEC_IS_SOUND (sound->provider))
+ swfdec_sound_provider_stop (SWFDEC_SOUND_PROVIDER (stopme), actor);
} else if (sound->provider) {
- data.sound = sound->provider;
- } else {
- data.sound = NULL;
+ swfdec_sound_provider_stop (sound->provider, actor);
}
- swfdec_player_stop_sounds (SWFDEC_PLAYER (cx), swfdec_sound_object_should_stop, &data);
-#endif
}
SWFDEC_AS_CONSTRUCTOR (500, 16, swfdec_sound_object_construct, swfdec_sound_object_get_type)
diff --git a/swfdec/swfdec_sound_provider.c b/swfdec/swfdec_sound_provider.c
index 10a95fe..ff781ec 100644
--- a/swfdec/swfdec_sound_provider.c
+++ b/swfdec/swfdec_sound_provider.c
@@ -76,3 +76,15 @@ swfdec_sound_provider_start (SwfdecSoundProvider *provider,
iface->start (provider, actor, samples_offset, loops);
}
+void
+swfdec_sound_provider_stop (SwfdecSoundProvider *provider, SwfdecActor *actor)
+{
+ SwfdecSoundProviderInterface *iface;
+
+ g_return_if_fail (SWFDEC_IS_SOUND_PROVIDER (provider));
+ g_return_if_fail (SWFDEC_IS_ACTOR (actor));
+
+ iface = SWFDEC_SOUND_PROVIDER_GET_INTERFACE (provider);
+ iface->stop (provider, actor);
+}
+
diff --git a/swfdec/swfdec_sound_provider.h b/swfdec/swfdec_sound_provider.h
index ea964de..06f965a 100644
--- a/swfdec/swfdec_sound_provider.h
+++ b/swfdec/swfdec_sound_provider.h
@@ -41,6 +41,8 @@ struct _SwfdecSoundProviderInterface {
SwfdecActor * actor,
gsize samples_offset,
guint loops);
+ void (* stop) (SwfdecSoundProvider * provider,
+ SwfdecActor * actor);
};
GType swfdec_sound_provider_get_type (void) G_GNUC_CONST;
@@ -49,6 +51,8 @@ void swfdec_sound_provider_start (SwfdecSoundProvider * provider,
SwfdecActor * actor,
gsize samples_offset,
guint loops);
+void swfdec_sound_provider_stop (SwfdecSoundProvider * provider,
+ SwfdecActor * actor);
G_END_DECLS
commit 894b73f21b9d28f6a5f8f35ec0e89dc568a06b2d
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Jun 17 23:07:25 2008 +0200
rewrite sound object
- the audio object is taken care of by the loadSound object (which is doubly
cool, because we can later on make it emit onSoundComplete)
- the target is a string
diff --git a/swfdec/swfdec_load_sound.c b/swfdec/swfdec_load_sound.c
index 1b3b029..56ff312 100644
--- a/swfdec/swfdec_load_sound.c
+++ b/swfdec/swfdec_load_sound.c
@@ -36,17 +36,19 @@
/*** SWFDEC_SOUND_PROVIDER ***/
-static SwfdecAudio *
+static void
swfdec_load_sound_sound_provider_start (SwfdecSoundProvider *provider,
- SwfdecPlayer *player, gsize samples_offset, guint loops)
+ SwfdecActor *actor, gsize samples_offset, guint loops)
{
SwfdecLoadSound *sound = SWFDEC_LOAD_SOUND (provider);
+ SwfdecAudio *audio;
if (samples_offset > 0 || loops > 1) {
SWFDEC_FIXME ("implement starting at offset %"G_GSIZE_FORMAT" with %u loops",
samples_offset, loops);
}
- return swfdec_audio_load_new (player, sound);
+ audio = swfdec_audio_load_new (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (provider)->context), sound);
+ g_object_unref (audio);
}
static void
diff --git a/swfdec/swfdec_sound.c b/swfdec/swfdec_sound.c
index 45dbcd4..92b0b62 100644
--- a/swfdec/swfdec_sound.c
+++ b/swfdec/swfdec_sound.c
@@ -38,13 +38,17 @@
/*** SWFDEC_SOUND_PROVIDER ***/
-static SwfdecAudio *
+static void
swfdec_sound_sound_provider_start (SwfdecSoundProvider *provider,
- SwfdecPlayer *player, gsize samples_offset, guint loops)
+ SwfdecActor *actor, gsize samples_offset, guint loops)
{
SwfdecSound *sound = SWFDEC_SOUND (provider);
+ SwfdecAudio *audio;
- return swfdec_audio_event_new (player, sound, samples_offset, loops);
+ audio = swfdec_audio_event_new (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (actor)->context),
+ sound, samples_offset, loops);
+ swfdec_audio_set_actor (audio, actor);
+ g_object_unref (audio);
}
static void
diff --git a/swfdec/swfdec_sound_object.c b/swfdec/swfdec_sound_object.c
index dbd234d..830b90e 100644
--- a/swfdec/swfdec_sound_object.c
+++ b/swfdec/swfdec_sound_object.c
@@ -45,7 +45,7 @@ swfdec_sound_object_mark (SwfdecAsObject *object)
SwfdecSoundObject *sound = SWFDEC_SOUND_OBJECT (object);
if (sound->target != NULL)
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (sound->target));
+ swfdec_as_string_mark (sound->target);
SWFDEC_AS_OBJECT_CLASS (swfdec_sound_object_parent_class)->mark (object);
}
@@ -79,13 +79,28 @@ swfdec_sound_object_init (SwfdecSoundObject *sound)
{
}
+static SwfdecActor *
+swfdec_sound_object_get_actor (SwfdecSoundObject *sound)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (sound)->context);
+ SwfdecMovie *movie;
+
+ movie = swfdec_player_get_movie_from_string (player,
+ sound->target ? sound->target : "");
+ if (!SWFDEC_IS_ACTOR (movie))
+ return NULL;
+ return SWFDEC_ACTOR (movie);
+}
+
static SwfdecSound *
swfdec_sound_object_get_sound (SwfdecSoundObject *sound, const char *name)
{
- if (sound->target == NULL)
+ SwfdecActor *actor = swfdec_sound_object_get_actor (sound);
+
+ if (actor == NULL)
return NULL;
- return swfdec_resource_get_export (sound->target->resource, name);
+ return swfdec_resource_get_export (SWFDEC_MOVIE (actor)->resource, name);
}
/*** AS CODE ***/
@@ -93,10 +108,12 @@ swfdec_sound_object_get_sound (SwfdecSoundObject *sound, const char *name)
static SwfdecSoundMatrix *
swfdec_sound_object_get_matrix (SwfdecSoundObject *sound)
{
- if (sound->global) {
+ if (sound->target == NULL) {
return &SWFDEC_PLAYER (SWFDEC_AS_OBJECT (sound)->context)->priv->sound_matrix;
- } else if (SWFDEC_IS_ACTOR (sound->target)) {
- return &SWFDEC_ACTOR (sound->target)->sound_matrix;
+ } else {
+ SwfdecActor *actor = swfdec_sound_object_get_actor (sound);
+ if (actor)
+ return &actor->sound_matrix;
}
return NULL;
}
@@ -287,22 +304,20 @@ swfdec_sound_object_loadSound (SwfdecAsContext *cx, SwfdecAsObject *object,
guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
{
SwfdecSoundObject *sound;
+ SwfdecActor *actor;
const char *url;
gboolean stream;
SWFDEC_AS_CHECK (SWFDEC_TYPE_SOUND_OBJECT, &sound, "sb", &url, &stream);
+ actor = swfdec_sound_object_get_actor (sound);
+ if (actor == NULL)
+ return;
- if (sound->audio) {
- swfdec_audio_remove (sound->audio);
- g_object_unref (sound->audio);
- sound->audio = NULL;
- }
if (sound->provider)
g_object_unref (sound->provider);
sound->provider = SWFDEC_SOUND_PROVIDER (swfdec_load_sound_new (object, url));
if (stream)
- sound->audio = swfdec_sound_provider_start (sound->provider,
- SWFDEC_PLAYER (cx), 0, 1);
+ swfdec_sound_provider_start (sound->provider, actor, 0, 1);
}
SWFDEC_AS_NATIVE (500, 14, swfdec_sound_object_getBytesLoaded)
@@ -373,30 +388,28 @@ swfdec_sound_object_start (SwfdecAsContext *cx, SwfdecAsObject *object, guint ar
SwfdecAsValue *argv, SwfdecAsValue *ret)
{
SwfdecSoundObject *sound;
+ SwfdecActor *actor;
double offset;
int loops;
SWFDEC_AS_CHECK (SWFDEC_TYPE_SOUND_OBJECT, &sound, "|ni", &offset, &loops);
+ actor = swfdec_sound_object_get_actor (sound);
+ if (actor == NULL)
+ return;
if (sound->provider == NULL) {
SWFDEC_INFO ("no sound attached when calling Sound.start()");
return;
}
- if (argc < 2 || loops < 0)
+ if (argc < 2 || loops <= 0)
loops = 1;
if (offset < 0 || !isfinite (offset))
offset = 0;
- if (sound->audio) {
- swfdec_audio_remove (sound->audio);
- g_object_unref (sound->audio);
- }
- sound->audio = swfdec_sound_provider_start (sound->provider, SWFDEC_PLAYER (cx),
- offset * 44100, loops);
- if (sound->target && !sound->global)
- swfdec_audio_set_actor (sound->audio, SWFDEC_ACTOR (sound->target));
+ swfdec_sound_provider_start (sound->provider, actor, offset * 44100, loops);
}
+#if 0
typedef struct {
SwfdecMovie * movie;
gpointer sound;
@@ -416,12 +429,14 @@ swfdec_sound_object_should_stop (SwfdecAudio *audio, gpointer datap)
/* FIXME: also check the movie is identical */
return TRUE;
}
+#endif
SWFDEC_AS_NATIVE (500, 6, swfdec_sound_object_stop)
void
swfdec_sound_object_stop (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
SwfdecAsValue *argv, SwfdecAsValue *ret)
{
+#if 0
SwfdecSoundObject *sound;
const char *name;
RemoveData data;
@@ -443,6 +458,7 @@ swfdec_sound_object_stop (SwfdecAsContext *cx, SwfdecAsObject *object, guint arg
data.sound = NULL;
}
swfdec_player_stop_sounds (SWFDEC_PLAYER (cx), swfdec_sound_object_should_stop, &data);
+#endif
}
SWFDEC_AS_CONSTRUCTOR (500, 16, swfdec_sound_object_construct, swfdec_sound_object_get_type)
@@ -460,14 +476,9 @@ swfdec_sound_object_construct (SwfdecAsContext *cx, SwfdecAsObject *object, guin
player = SWFDEC_PLAYER (cx);
if (argc == 0 || SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0])) {
- sound->global = TRUE;
- /* FIXME: what is the target for global sounds? Problem:
- * We use the target in attachSound to look up the sound object to attach.
- * But I'm not sure what is used for global sounds.
- * So we just use a random one that looks good for now. */
- sound->target = player->priv->roots->data;
+ sound->target = NULL;
} else {
- sound->target = swfdec_player_get_movie_from_value (player, &argv[0]);
+ sound->target = swfdec_as_value_to_string (cx, &argv[0]);
}
}
diff --git a/swfdec/swfdec_sound_object.h b/swfdec/swfdec_sound_object.h
index 0a79bc0..c543410 100644
--- a/swfdec/swfdec_sound_object.h
+++ b/swfdec/swfdec_sound_object.h
@@ -41,10 +41,8 @@ typedef struct _SwfdecSoundObjectClass SwfdecSoundObjectClass;
struct _SwfdecSoundObject {
SwfdecAsObject object;
- SwfdecMovie * target; /* target movie or NULL on constructing error */
- gboolean global; /* TRUE if handling global sound */
+ const char * target; /* target or NULL if global */
SwfdecSoundProvider * provider; /* sound that we play */
- SwfdecAudio * audio; /* audio stream we started */
};
struct _SwfdecSoundObjectClass {
diff --git a/swfdec/swfdec_sound_provider.c b/swfdec/swfdec_sound_provider.c
index add6ef9..10a95fe 100644
--- a/swfdec/swfdec_sound_provider.c
+++ b/swfdec/swfdec_sound_provider.c
@@ -22,6 +22,7 @@
#endif
#include "swfdec_sound_provider.h"
+#include "swfdec_actor.h"
#include "swfdec_debug.h"
#include "swfdec_player_internal.h"
@@ -61,17 +62,17 @@ swfdec_sound_provider_get_type (void)
return sound_provider_type;
}
-SwfdecAudio *
+void
swfdec_sound_provider_start (SwfdecSoundProvider *provider,
- SwfdecPlayer *player, gsize samples_offset, guint loops)
+ SwfdecActor *actor, gsize samples_offset, guint loops)
{
SwfdecSoundProviderInterface *iface;
- g_return_val_if_fail (SWFDEC_IS_SOUND_PROVIDER (provider), NULL);
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
- g_return_val_if_fail (loops > 0, NULL);
+ g_return_if_fail (SWFDEC_IS_SOUND_PROVIDER (provider));
+ g_return_if_fail (SWFDEC_IS_ACTOR (actor));
+ g_return_if_fail (loops > 0);
iface = SWFDEC_SOUND_PROVIDER_GET_INTERFACE (provider);
- return iface->start (provider, player, samples_offset, loops);
+ iface->start (provider, actor, samples_offset, loops);
}
diff --git a/swfdec/swfdec_sound_provider.h b/swfdec/swfdec_sound_provider.h
index 76689a2..ea964de 100644
--- a/swfdec/swfdec_sound_provider.h
+++ b/swfdec/swfdec_sound_provider.h
@@ -21,6 +21,7 @@
#define __SWFDEC_SOUND_PROVIDER_H__
#include <swfdec/swfdec.h>
+#include <swfdec/swfdec_types.h>
G_BEGIN_DECLS
@@ -36,16 +37,16 @@ typedef struct _SwfdecSoundProviderInterface SwfdecSoundProviderInterface;
struct _SwfdecSoundProviderInterface {
GTypeInterface interface;
- SwfdecAudio * (* start) (SwfdecSoundProvider * provider,
- SwfdecPlayer * player,
+ void (* start) (SwfdecSoundProvider * provider,
+ SwfdecActor * actor,
gsize samples_offset,
guint loops);
};
GType swfdec_sound_provider_get_type (void) G_GNUC_CONST;
-SwfdecAudio * swfdec_sound_provider_start (SwfdecSoundProvider * provider,
- SwfdecPlayer * player,
+void swfdec_sound_provider_start (SwfdecSoundProvider * provider,
+ SwfdecActor * actor,
gsize samples_offset,
guint loops);
More information about the Swfdec-commits
mailing list