[Swfdec] 2 commits - libswfdec/swfdec_audio_event.c test/sound

Pekka Lampila medar at kemper.freedesktop.org
Mon Oct 29 14:44:47 PDT 2007


 libswfdec/swfdec_audio_event.c        |    3 +
 test/sound/Makefile.am                |    7 ++++
 test/sound/crash-0.5.3-no-samples.c   |   57 ++++++++++++++++++++++++++++++++++
 test/sound/crash-0.5.3-no-samples.swf |binary
 4 files changed, 67 insertions(+)

New commits:
commit 835f7dd6a8a7ea739b437e7721506755fa989ca7
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Mon Oct 29 23:44:07 2007 +0200

    Add a test for the no-samples sound crash

diff --git a/test/sound/Makefile.am b/test/sound/Makefile.am
index 41e5e2b..ddb3d13 100644
--- a/test/sound/Makefile.am
+++ b/test/sound/Makefile.am
@@ -34,5 +34,12 @@ EXTRA_DIST = \
 	adpcm-5.swf.1.0.raw \
 	adpcm-5-2.swf \
 	adpcm-5-2.swf.1.0.raw
+	crash-0.5.3-no-samples.c \
+	crash-0.5.3-no-samples.swf \
+	crash-0.5.3-no-samples.swf.1.0.raw \
+	crash-0.5.3-no-samples.swf.3.0.raw \
+	crash-0.5.3-no-samples.swf.5.0.raw \
+	crash-0.5.3-no-samples.swf.7.0.raw \
+	crash-0.5.3-no-samples.swf.9.0.raw
 
 CLEANFILES = tmp
diff --git a/test/sound/crash-0.5.3-no-samples.c b/test/sound/crash-0.5.3-no-samples.c
new file mode 100644
index 0000000..4339f03
--- /dev/null
+++ b/test/sound/crash-0.5.3-no-samples.c
@@ -0,0 +1,57 @@
+/* gcc `pkg-config --libs --cflags libming` crash-0.5.3-no-samples.c -o crash-0.5.3-no-samples && ./crash-0.5.3-no-samples
+ */
+
+#include <ming.h>
+
+static void
+do_movie ()
+{
+  char name[100];
+  SWFMovie movie;
+  FILE *file;
+  SWFMovieClip movie_clip;
+  SWFSound sound;
+  SWFSoundInstance instance;
+
+  movie = newSWFMovieWithVersion (8);
+  movie = newSWFMovie();
+  SWFMovie_setRate (movie, 10);
+  SWFMovie_setDimension (movie, 200, 150);
+
+  movie_clip = newSWFMovieClip ();
+
+  file = fopen ("/dev/null", "r");
+  sound = newSWFSound (file, SWF_SOUND_NOT_COMPRESSED | SWF_SOUND_44KHZ | SWF_SOUND_16BITS | SWF_SOUND_STEREO);
+  instance = SWFMovieClip_startSound(movie_clip, sound);
+  SWFMovieClip_nextFrame (movie_clip);
+
+  SWFMovie_add (movie, (SWFBlock) movie_clip);
+  SWFMovie_nextFrame (movie);
+
+  SWFMovie_add (movie, (SWFBlock) newSWFAction (""
+	"trace ('To crash or not to crash?');"
+	"function quit () {"
+	"  loadMovie ('FSCommand:quit', '');"
+	"}"
+	"setTimeout (quit, 200);"
+	""));
+  SWFMovie_nextFrame (movie);
+
+  SWFMovie_save (movie, "crash-0.5.3-no-samples.swf");
+
+  destroySWFSound (sound);
+  fclose (file);
+}
+
+int
+main (int argc, char **argv)
+{
+  int i;
+
+  if (Ming_init ())
+    return 1;
+
+  do_movie ();
+
+  return 0;
+}
diff --git a/test/sound/crash-0.5.3-no-samples.swf b/test/sound/crash-0.5.3-no-samples.swf
new file mode 100644
index 0000000..9dab6c1
Binary files /dev/null and b/test/sound/crash-0.5.3-no-samples.swf differ
diff --git a/test/sound/crash-0.5.3-no-samples.swf.1.0.raw b/test/sound/crash-0.5.3-no-samples.swf.1.0.raw
new file mode 100644
index 0000000..e69de29
diff --git a/test/sound/crash-0.5.3-no-samples.swf.3.0.raw b/test/sound/crash-0.5.3-no-samples.swf.3.0.raw
new file mode 100644
index 0000000..e69de29
diff --git a/test/sound/crash-0.5.3-no-samples.swf.5.0.raw b/test/sound/crash-0.5.3-no-samples.swf.5.0.raw
new file mode 100644
index 0000000..e69de29
diff --git a/test/sound/crash-0.5.3-no-samples.swf.7.0.raw b/test/sound/crash-0.5.3-no-samples.swf.7.0.raw
new file mode 100644
index 0000000..e69de29
diff --git a/test/sound/crash-0.5.3-no-samples.swf.9.0.raw b/test/sound/crash-0.5.3-no-samples.swf.9.0.raw
new file mode 100644
index 0000000..e69de29
commit 54ae118efee369b0d9ce73622266eafd57bf9553
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Mon Oct 29 23:29:32 2007 +0200

    Fix a crash when sound had no samples

diff --git a/libswfdec/swfdec_audio_event.c b/libswfdec/swfdec_audio_event.c
index 8520bf9..e0e5e93 100644
--- a/libswfdec/swfdec_audio_event.c
+++ b/libswfdec/swfdec_audio_event.c
@@ -59,6 +59,9 @@ swfdec_audio_event_render (SwfdecAudio *audio, gint16* dest,
   guint loop;
   guint samples;
 
+  if (event->n_samples == 0)
+    return;
+
   loop = event->loop + offset / event->n_samples;
   offset %= event->n_samples;
   for (; loop < event->n_loops && n_samples > 0; loop++) {


More information about the Swfdec mailing list