[Swfdec-commits] 6 commits - configure.ac m4/as-compiler-flag.m4 swfdec/jpeg swfdec/Makefile.am swfdec/swfdec_audio_decoder_adpcm.c swfdec/swfdec_audio_decoder.c swfdec/swfdec_audio_decoder_gst.c swfdec/swfdec_audio_decoder_gst.h swfdec/swfdec_audio_decoder.h swfdec/swfdec_audio_decoder_uncompressed.c swfdec/swfdec_init.c swfdec/swfdec_player.c

Benjamin Otte company at kemper.freedesktop.org
Sun Jun 8 04:43:57 PDT 2008


Rebased ref, commits from common ancestor:
commit 2fb0b7b4e715ca3c2f19af12424ef09eb67bef66
Author: Benjamin Otte <otte at gnome.org>
Date:   Sat Jun 7 00:19:46 2008 +0200

    emit a warning for unsupported flags
    
    turns out gcc 4.2 can't do -Wlogical-op, so if you use gcc 4.3 and get
    complaints, poke us

diff --git a/m4/as-compiler-flag.m4 b/m4/as-compiler-flag.m4
index 3c40a87..0f660cf 100644
--- a/m4/as-compiler-flag.m4
+++ b/m4/as-compiler-flag.m4
@@ -37,7 +37,8 @@ dnl Tries to compile with the given CFLAGS.
 AC_DEFUN([AS_COMPILER_FLAGS],
 [
   list=$2
-  flag_list=""
+  flags_supported=""
+  flags_unsupported=""
   AC_MSG_CHECKING([for supported compiler flags])
   for each in $list
   do
@@ -47,10 +48,15 @@ AC_DEFUN([AS_COMPILER_FLAGS],
     CFLAGS="$save_CFLAGS"
 
     if test "X$flag_ok" = Xyes ; then
-      flag_list="$flag_list $each"
+      flags_supported="$flags_supported $each"
+    else
+      flags_unsupported="$flags_unsupported $each"
     fi
   done
-  AC_MSG_RESULT([$flag_list])
-  $1="$$1 $flag_list"
+  AC_MSG_RESULT([$flags_supported])
+  if test "X$flags_unsupported" != X ; then
+    AC_MSG_WARN([unsupported compiler flags: $flags_unsupported])
+  fi
+  $1="$$1 $flags_supported"
 ])
 
commit 061563f3844e8abbb4e705a8eb6481a5fc5e177d
Author: Benjamin Otte <otte at gnome.org>
Date:   Sat Jun 7 00:11:16 2008 +0200

    add more warning flags
    
    And whoo, it still compiles!

diff --git a/configure.ac b/configure.ac
index 02f4b2b..ca54cec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,7 +20,7 @@ AC_CONFIG_MACRO_DIR([m4])
 dnl decide on error flags
 dnl if we support them, we set them unconditionally
 dnl FIXME: I want this but stupid headers don't let me: -Wshadow
-AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wold-style-definition -Wdeclaration-after-statement -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wmissing-noreturn -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Winline -Wformat-nonliteral -Wformat-security -Wswitch-enum -Wswitch-default")
+AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wold-style-definition -Wdeclaration-after-statement -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wmissing-noreturn -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Winline -Wformat-nonliteral -Wformat-security -Wswitch-enum -Wswitch-default -Winit-self -Wmissing-include-dirs -Wundef -Waddress -Wlogical-op -Waggregate-return -Wmissing-format-attribute -Wno-multichar -Wnested-externs")
 dnl if we're in nano >= 1, add -Werror if supported
 if test x$SWFDEC_CVS = xyes ; then
   AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Werror")
commit db3ad45b07b0dd29af518e0408420290db705b6f
Author: Benjamin Otte <otte at gnome.org>
Date:   Sat Jun 7 00:11:02 2008 +0200

    whoops, used wrong macro here

diff --git a/configure.ac b/configure.ac
index 8ea8590..02f4b2b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,7 +35,7 @@ AC_SUBST(SWFDEC_LIBVERSION)
 AM_PROG_LIBTOOL
 
 dnl C99 is only required to get definitions for NAN and INFINITY.
-AS_COMPILER_FLAG(GLOBAL_CFLAGS, "-std=gnu99")
+AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-std=gnu99")
 
 dnl ensures the library is linked against the internal Mozilla
 dnl if this doesn't work on your platform, I'll take patches :)
commit d6cb3c8a62979ba23f63a640b9c29774ccaf70e5
Author: Benjamin Otte <otte at gnome.org>
Date:   Sat Jun 7 00:07:54 2008 +0200

    mark printf function as such

diff --git a/swfdec/jpeg/jpeg.h b/swfdec/jpeg/jpeg.h
index a52bb9b..066df75 100644
--- a/swfdec/jpeg/jpeg.h
+++ b/swfdec/jpeg/jpeg.h
@@ -4,6 +4,7 @@
 
 #include <jpeg/jpeg_bits.h>
 
+#include <glib.h>
 #include <stdint.h>
 
 #ifndef TRUE
@@ -159,7 +160,7 @@ uint32_t *jpeg_decoder_get_argb_image (JpegDecoder *dec);
 int jpeg_decode_argb (uint8_t *data, int length, uint32_t **image,
     unsigned int *width, unsigned int *height);
 
-void jpeg_decoder_error(JpegDecoder *dec, const char *fmt, ...);
+void jpeg_decoder_error(JpegDecoder *dec, const char *fmt, ...) G_GNUC_PRINTF (2, 3);
 
 int jpeg_decoder_sof_baseline_dct(JpegDecoder *dec, JpegBits *bits);
 int jpeg_decoder_define_quant_table(JpegDecoder *dec, JpegBits *bits);
commit 0cee20443ae3657e41ad25db1ac0ab62710599ce
Author: Benjamin Otte <otte at gnome.org>
Date:   Sat Jun 7 00:06:32 2008 +0200

    remove excessive whitespace

diff --git a/swfdec/jpeg/jpeg.c b/swfdec/jpeg/jpeg.c
index 7ff4187..d49f418 100644
--- a/swfdec/jpeg/jpeg.c
+++ b/swfdec/jpeg/jpeg.c
@@ -162,9 +162,6 @@ jpeg_decoder_init_decoder (JpegDecoder *dec)
     return;
   }
 
-
-
-
   for (i=0; i < dec->n_components; i++) {
     max_h_sample = MAX (max_h_sample, dec->components[i].h_sample);
     max_v_sample = MAX (max_v_sample, dec->components[i].v_sample);
commit f3d103efaa20ece7831c58222eeaa9d47a59a2ca
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Jun 6 22:17:40 2008 +0200

    move audio decoders closer to an expoted API for plugging new decoders

diff --git a/swfdec/Makefile.am b/swfdec/Makefile.am
index b887678..6c8f5c1 100644
--- a/swfdec/Makefile.am
+++ b/swfdec/Makefile.am
@@ -88,6 +88,7 @@ libswfdec_source_files = \
 	swfdec_graphic_movie.c \
 	swfdec_image.c \
 	swfdec_image_decoder.c \
+	swfdec_init.c \
 	swfdec_interval.c \
 	swfdec_key_as.c \
 	swfdec_load_object.c \
diff --git a/swfdec/swfdec_audio_decoder.c b/swfdec/swfdec_audio_decoder.c
index eee4ecc..e969d27 100644
--- a/swfdec/swfdec_audio_decoder.c
+++ b/swfdec/swfdec_audio_decoder.c
@@ -22,9 +22,6 @@
 #endif
 
 #include "swfdec_audio_decoder.h"
-#include "swfdec_audio_decoder_adpcm.h"
-#include "swfdec_audio_decoder_gst.h"
-#include "swfdec_audio_decoder_uncompressed.h"
 #include "swfdec_debug.h"
 #include "swfdec_internal.h"
 
@@ -40,51 +37,30 @@ swfdec_audio_decoder_init (SwfdecAudioDecoder *audio_decoder)
 {
 }
 
-static SwfdecAudioDecoder *
-swfdec_audio_decoder_builtin_new (guint codec, SwfdecAudioFormat format)
-{
-  switch (codec) {
-    case SWFDEC_AUDIO_CODEC_UNDEFINED:
-    case SWFDEC_AUDIO_CODEC_UNCOMPRESSED:
-      return g_object_new (SWFDEC_TYPE_AUDIO_DECODER_UNCOMPRESSED, NULL);
-    case SWFDEC_AUDIO_CODEC_ADPCM:
-      return g_object_new (SWFDEC_TYPE_AUDIO_DECODER_ADPCM, NULL);
-    default:
-      return NULL;
-  }
-}
+static GSList *audio_codecs = NULL;
 
-static gboolean
-swfdec_audio_decoder_builtin_prepare (guint codec, SwfdecAudioFormat format, char **detail)
+void
+swfdec_audio_decoder_register (GType type)
 {
-  return codec == SWFDEC_AUDIO_CODEC_UNCOMPRESSED ||
-    codec == SWFDEC_AUDIO_CODEC_UNDEFINED ||
-    codec == SWFDEC_AUDIO_CODEC_ADPCM;
-}
+  g_return_if_fail (g_type_is_a (type, SWFDEC_TYPE_AUDIO_DECODER));
 
-static const struct {
-  const char *		name;
-  SwfdecAudioDecoder *	(* func) (guint, SwfdecAudioFormat);
-  gboolean		(* prepare) (guint, SwfdecAudioFormat, char **);
-} audio_codecs[] = {
-  { "builtin",	swfdec_audio_decoder_builtin_new, swfdec_audio_decoder_builtin_prepare },
-#ifdef HAVE_GST
-  { "gst",	swfdec_audio_decoder_gst_new, swfdec_audio_decoder_gst_prepare },
-#endif
-};
+  audio_codecs = g_slist_append (audio_codecs, GSIZE_TO_POINTER ((gsize) type));
+}
 
 gboolean
 swfdec_audio_decoder_prepare (guint codec, SwfdecAudioFormat format, char **missing)
 {
   char *detail = NULL, *s = NULL;
-  guint i;
+  GSList *walk;
   
-  for (i = 0; i < G_N_ELEMENTS (audio_codecs); i++) {
-    if (audio_codecs[i].prepare (codec, format, &s)) {
+  for (walk = audio_codecs; walk; walk = walk->next) {
+    SwfdecAudioDecoderClass *klass = g_type_class_ref (GPOINTER_TO_SIZE (walk->data));
+    if (klass->prepare (codec, format, &s)) {
       g_free (detail);
       g_free (s);
       if (missing)
 	*missing = NULL;
+      g_type_class_unref (klass);
       return TRUE;
     }
     if (s) {
@@ -94,6 +70,7 @@ swfdec_audio_decoder_prepare (guint codec, SwfdecAudioFormat format, char **miss
 	g_free (s);
       s = NULL;
     }
+    g_type_class_unref (klass);
   }
   if (missing)
     *missing = detail;
@@ -113,12 +90,14 @@ SwfdecAudioDecoder *
 swfdec_audio_decoder_new (guint codec, SwfdecAudioFormat format)
 {
   SwfdecAudioDecoder *ret;
-  guint i;
-
+  GSList *walk;
+  
   g_return_val_if_fail (SWFDEC_IS_AUDIO_FORMAT (format), NULL);
 
-  for (i = 0; i < G_N_ELEMENTS (audio_codecs); i++) {
-    ret = audio_codecs[i].func (codec, format);
+  for (walk = audio_codecs; walk; walk = walk->next) {
+    SwfdecAudioDecoderClass *klass = g_type_class_ref (GPOINTER_TO_SIZE (walk->data));
+    ret = klass->create (codec, format);
+    g_type_class_unref (klass);
     if (ret)
       break;
   }
diff --git a/swfdec/swfdec_audio_decoder.h b/swfdec/swfdec_audio_decoder.h
index 3f4363a..24e52f5 100644
--- a/swfdec/swfdec_audio_decoder.h
+++ b/swfdec/swfdec_audio_decoder.h
@@ -56,8 +56,16 @@ struct _SwfdecAudioDecoder
 
 struct _SwfdecAudioDecoderClass
 {
+  /*< private >*/
   GObjectClass		object_class;
 
+  /*< public >*/
+  gboolean		(* prepare)	(guint                  codec,
+                                         SwfdecAudioFormat      format,
+					 char **                missing);
+  SwfdecAudioDecoder *	(* create)	(guint                  codec,
+					 SwfdecAudioFormat      format);
+
   void			(* push)	(SwfdecAudioDecoder *	decoder,
 					 SwfdecBuffer *		buffer);
   SwfdecBuffer *	(* pull)	(SwfdecAudioDecoder *	decoder);
@@ -65,6 +73,8 @@ struct _SwfdecAudioDecoderClass
 
 GType			swfdec_audio_decoder_get_type	(void);
 
+void			swfdec_audio_decoder_register	(GType			type);
+
 gboolean		swfdec_audio_decoder_prepare	(guint			codec,
 							 SwfdecAudioFormat	format,
 							 char **		missing);
diff --git a/swfdec/swfdec_audio_decoder_adpcm.c b/swfdec/swfdec_audio_decoder_adpcm.c
index 257fb23..18eaab1 100644
--- a/swfdec/swfdec_audio_decoder_adpcm.c
+++ b/swfdec/swfdec_audio_decoder_adpcm.c
@@ -27,6 +27,21 @@
 
 G_DEFINE_TYPE (SwfdecAudioDecoderAdpcm, swfdec_audio_decoder_adpcm, SWFDEC_TYPE_AUDIO_DECODER)
 
+static gboolean
+swfdec_audio_decoder_adpcm_prepare (guint codec, SwfdecAudioFormat format, char **missing)
+{
+  return codec == SWFDEC_AUDIO_CODEC_ADPCM;
+}
+
+static SwfdecAudioDecoder *
+swfdec_audio_decoder_adpcm_create (guint codec, SwfdecAudioFormat format)
+{
+  if (codec != SWFDEC_AUDIO_CODEC_ADPCM)
+    return NULL;
+
+  return g_object_new (SWFDEC_TYPE_AUDIO_DECODER_ADPCM, NULL);
+}
+
 static const int indexTable[4][16] = {
   { -1, 2 },
   { -1, -1, 2, 4 },
@@ -188,6 +203,8 @@ swfdec_audio_decoder_adpcm_class_init (SwfdecAudioDecoderAdpcmClass *klass)
 
   object_class->dispose = swfdec_audio_decoder_adpcm_dispose;
 
+  decoder_class->prepare = swfdec_audio_decoder_adpcm_prepare;
+  decoder_class->create = swfdec_audio_decoder_adpcm_create;
   decoder_class->pull = swfdec_audio_decoder_adpcm_pull;
   decoder_class->push = swfdec_audio_decoder_adpcm_push;
 }
diff --git a/swfdec/swfdec_audio_decoder_gst.c b/swfdec/swfdec_audio_decoder_gst.c
index 73f4d06..ea343fa 100644
--- a/swfdec/swfdec_audio_decoder_gst.c
+++ b/swfdec/swfdec_audio_decoder_gst.c
@@ -59,59 +59,28 @@ swfdec_audio_decoder_get_caps (guint codec, SwfdecAudioFormat format)
 
 G_DEFINE_TYPE (SwfdecAudioDecoderGst, swfdec_audio_decoder_gst, SWFDEC_TYPE_AUDIO_DECODER)
 
-static void
-swfdec_audio_decoder_gst_push (SwfdecAudioDecoder *dec, SwfdecBuffer *buffer)
-{
-  SwfdecAudioDecoderGst *player = SWFDEC_AUDIO_DECODER_GST (dec);
-  GstBuffer *buf;
-
-  if (buffer == NULL) {
-    swfdec_gst_decoder_push_eos (&player->dec);
-  } else {
-    swfdec_buffer_ref (buffer);
-    buf = swfdec_gst_buffer_new (buffer);
-    if (!swfdec_gst_decoder_push (&player->dec, buf))
-      swfdec_audio_decoder_error (dec, "error pushing");
-  }
-}
-
-static SwfdecBuffer *
-swfdec_audio_decoder_gst_pull (SwfdecAudioDecoder *dec)
-{
-  SwfdecAudioDecoderGst *player = SWFDEC_AUDIO_DECODER_GST (dec);
-  GstBuffer *buf;
-
-  buf = swfdec_gst_decoder_pull (&player->dec);
-  if (buf == NULL)
-    return NULL;
-  return swfdec_buffer_new_from_gst (buf);
-}
-
-static void
-swfdec_audio_decoder_gst_dispose (GObject *object)
-{
-  SwfdecAudioDecoderGst *player = (SwfdecAudioDecoderGst *) object;
-
-  swfdec_gst_decoder_finish (&player->dec);
-
-  G_OBJECT_CLASS (swfdec_audio_decoder_gst_parent_class)->dispose (object);
-}
-
-static void
-swfdec_audio_decoder_gst_class_init (SwfdecAudioDecoderGstClass *klass)
+static gboolean
+swfdec_audio_decoder_gst_prepare (guint codec, SwfdecAudioFormat format, char **detail)
 {
-  GObjectClass *object_class = G_OBJECT_CLASS (klass);
-  SwfdecAudioDecoderClass *decoder_class = SWFDEC_AUDIO_DECODER_CLASS (klass);
+  GstElementFactory *factory;
+  GstCaps *caps;
 
-  object_class->dispose = swfdec_audio_decoder_gst_dispose;
+  /* Check if we can handle the format at all. If not, no plugin will help us. */
+  caps = swfdec_audio_decoder_get_caps (codec, format);
+  if (caps == NULL)
+    return FALSE;
 
-  decoder_class->pull = swfdec_audio_decoder_gst_pull;
-  decoder_class->push = swfdec_audio_decoder_gst_push;
-}
+  /* If we can already handle it, woohoo! */
+  factory = swfdec_gst_get_element_factory (caps);
+  if (factory != NULL) {
+    gst_object_unref (factory);
+    return TRUE;
+  }
 
-static void
-swfdec_audio_decoder_gst_init (SwfdecAudioDecoderGst *audio_decoder_gst)
-{
+  /* need to install plugins... */
+  *detail = gst_missing_decoder_installer_detail_new (caps);
+  gst_caps_unref (caps);
+  return FALSE;
 }
 
 static const char *
@@ -137,8 +106,8 @@ swfdec_audio_decoder_get_resampler (void)
   return NULL;
 }
 
-SwfdecAudioDecoder *
-swfdec_audio_decoder_gst_new (guint type, SwfdecAudioFormat format)
+static SwfdecAudioDecoder *
+swfdec_audio_decoder_gst_create (guint type, SwfdecAudioFormat format)
 {
   SwfdecAudioDecoderGst *player;
   GstCaps *srccaps, *sinkcaps;
@@ -171,29 +140,60 @@ error:
   return NULL;
 }
 
-/*** MISSING PLUGIN SUPPORT ***/
-  
-gboolean
-swfdec_audio_decoder_gst_prepare (guint codec, SwfdecAudioFormat format, char **detail)
+static void
+swfdec_audio_decoder_gst_push (SwfdecAudioDecoder *dec, SwfdecBuffer *buffer)
 {
-  GstElementFactory *factory;
-  GstCaps *caps;
-
-  /* Check if we can handle the format at all. If not, no plugin will help us. */
-  caps = swfdec_audio_decoder_get_caps (codec, format);
-  if (caps == NULL)
-    return FALSE;
+  SwfdecAudioDecoderGst *player = SWFDEC_AUDIO_DECODER_GST (dec);
+  GstBuffer *buf;
 
-  /* If we can already handle it, woohoo! */
-  factory = swfdec_gst_get_element_factory (caps);
-  if (factory != NULL) {
-    gst_object_unref (factory);
-    return TRUE;
+  if (buffer == NULL) {
+    swfdec_gst_decoder_push_eos (&player->dec);
+  } else {
+    swfdec_buffer_ref (buffer);
+    buf = swfdec_gst_buffer_new (buffer);
+    if (!swfdec_gst_decoder_push (&player->dec, buf))
+      swfdec_audio_decoder_error (dec, "error pushing");
   }
+}
 
-  /* need to install plugins... */
-  *detail = gst_missing_decoder_installer_detail_new (caps);
-  gst_caps_unref (caps);
-  return FALSE;
+static SwfdecBuffer *
+swfdec_audio_decoder_gst_pull (SwfdecAudioDecoder *dec)
+{
+  SwfdecAudioDecoderGst *player = SWFDEC_AUDIO_DECODER_GST (dec);
+  GstBuffer *buf;
+
+  buf = swfdec_gst_decoder_pull (&player->dec);
+  if (buf == NULL)
+    return NULL;
+  return swfdec_buffer_new_from_gst (buf);
+}
+
+static void
+swfdec_audio_decoder_gst_dispose (GObject *object)
+{
+  SwfdecAudioDecoderGst *player = (SwfdecAudioDecoderGst *) object;
+
+  swfdec_gst_decoder_finish (&player->dec);
+
+  G_OBJECT_CLASS (swfdec_audio_decoder_gst_parent_class)->dispose (object);
+}
+
+static void
+swfdec_audio_decoder_gst_class_init (SwfdecAudioDecoderGstClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  SwfdecAudioDecoderClass *decoder_class = SWFDEC_AUDIO_DECODER_CLASS (klass);
+
+  object_class->dispose = swfdec_audio_decoder_gst_dispose;
+
+  decoder_class->prepare = swfdec_audio_decoder_gst_prepare;
+  decoder_class->create = swfdec_audio_decoder_gst_create;
+  decoder_class->pull = swfdec_audio_decoder_gst_pull;
+  decoder_class->push = swfdec_audio_decoder_gst_push;
+}
+
+static void
+swfdec_audio_decoder_gst_init (SwfdecAudioDecoderGst *audio_decoder_gst)
+{
 }
 
diff --git a/swfdec/swfdec_audio_decoder_gst.h b/swfdec/swfdec_audio_decoder_gst.h
index 18fd146..3354cc6 100644
--- a/swfdec/swfdec_audio_decoder_gst.h
+++ b/swfdec/swfdec_audio_decoder_gst.h
@@ -50,12 +50,6 @@ struct _SwfdecAudioDecoderGstClass
 
 GType			swfdec_audio_decoder_gst_get_type	(void);
 
-SwfdecAudioDecoder *	swfdec_audio_decoder_gst_new		(guint			codec, 
-								 SwfdecAudioFormat	format);
-gboolean		swfdec_audio_decoder_gst_prepare	(guint			codec,
-								 SwfdecAudioFormat	format,
-								 char **		missing);
-
 
 G_END_DECLS
 #endif
diff --git a/swfdec/swfdec_audio_decoder_uncompressed.c b/swfdec/swfdec_audio_decoder_uncompressed.c
index b9be106..6681f2a 100644
--- a/swfdec/swfdec_audio_decoder_uncompressed.c
+++ b/swfdec/swfdec_audio_decoder_uncompressed.c
@@ -27,6 +27,23 @@
 
 G_DEFINE_TYPE (SwfdecAudioDecoderUncompressed, swfdec_audio_decoder_uncompressed, SWFDEC_TYPE_AUDIO_DECODER)
 
+static gboolean
+swfdec_audio_decoder_uncompressed_prepare (guint codec, SwfdecAudioFormat format, char **missing)
+{
+  return codec == SWFDEC_AUDIO_CODEC_UNDEFINED ||
+      codec == SWFDEC_AUDIO_CODEC_UNCOMPRESSED;
+}
+
+static SwfdecAudioDecoder *
+swfdec_audio_decoder_uncompressed_create (guint codec, SwfdecAudioFormat format)
+{
+  if (codec != SWFDEC_AUDIO_CODEC_UNDEFINED &&
+      codec != SWFDEC_AUDIO_CODEC_UNCOMPRESSED)
+    return NULL;
+
+  return g_object_new (SWFDEC_TYPE_AUDIO_DECODER_UNCOMPRESSED, NULL);
+}
+
 static SwfdecBuffer *
 swfdec_audio_decoder_uncompressed_upscale (SwfdecBuffer *buffer, SwfdecAudioFormat format)
 {
@@ -134,6 +151,8 @@ swfdec_audio_decoder_uncompressed_class_init (SwfdecAudioDecoderUncompressedClas
 
   object_class->dispose = swfdec_audio_decoder_uncompressed_dispose;
 
+  decoder_class->prepare = swfdec_audio_decoder_uncompressed_prepare;
+  decoder_class->create = swfdec_audio_decoder_uncompressed_create;
   decoder_class->pull = swfdec_audio_decoder_uncompressed_pull;
   decoder_class->push = swfdec_audio_decoder_uncompressed_push;
 }
diff --git a/swfdec/swfdec_init.c b/swfdec/swfdec_init.c
new file mode 100644
index 0000000..9fae716
--- /dev/null
+++ b/swfdec/swfdec_init.c
@@ -0,0 +1,82 @@
+/* Swfdec
+ * Copyright (C) 2006-2008 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+ * Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <errno.h>
+#ifdef HAVE_GST
+#include <gst/gst.h>
+#include <gst/pbutils/pbutils.h>
+#include "swfdec_audio_decoder_gst.h"
+#endif
+#include <liboil/liboil.h>
+
+#include "swfdec_audio_decoder_adpcm.h"
+#include "swfdec_audio_decoder_uncompressed.h"
+#include "swfdec_debug.h"
+
+/**
+ * swfdec_init:
+ *
+ * Initializes the Swfdec library.
+ **/
+void
+swfdec_init (void)
+{
+  static gboolean _inited = FALSE;
+  const char *s;
+
+  if (_inited)
+    return;
+
+  _inited = TRUE;
+
+  /* initialize all types */
+  if (!g_thread_supported ())
+    g_thread_init (NULL);
+  g_type_init ();
+  oil_init ();
+#ifdef HAVE_GST
+  gst_init (NULL, NULL);
+  gst_pb_utils_init ();
+#endif
+
+  /* setup debugging */
+  s = g_getenv ("SWFDEC_DEBUG");
+  if (s && s[0]) {
+    char *end;
+    int level;
+
+    level = strtoul (s, &end, 0);
+    if (end[0] == 0) {
+      swfdec_debug_set_level (level);
+    }
+  }
+
+  /* Setup audio and video decoders. 
+   * NB: The order is important! */
+  swfdec_audio_decoder_register (SWFDEC_TYPE_AUDIO_DECODER_UNCOMPRESSED);
+  swfdec_audio_decoder_register (SWFDEC_TYPE_AUDIO_DECODER_ADPCM);
+#ifdef HAVE_GST
+  swfdec_audio_decoder_register (SWFDEC_TYPE_AUDIO_DECODER_GST);
+#endif
+}
+
diff --git a/swfdec/swfdec_player.c b/swfdec/swfdec_player.c
index e5deee0..4e29909 100644
--- a/swfdec/swfdec_player.c
+++ b/swfdec/swfdec_player.c
@@ -1,5 +1,5 @@
 /* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ * Copyright (C) 2006-2008 Benjamin Otte <otte at gnome.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -22,14 +22,9 @@
 #endif
 
 #include <errno.h>
-#ifdef HAVE_GST
-#include <gst/gst.h>
-#include <gst/pbutils/pbutils.h>
-#endif
 #include <math.h>
 #include <string.h>
 #include <stdlib.h>
-#include <liboil/liboil.h>
 
 #include "swfdec_player_internal.h"
 #include "swfdec_as_frame_internal.h"
@@ -2836,43 +2831,6 @@ swfdec_player_new (SwfdecAsDebugger *debugger)
 }
 
 /**
- * swfdec_init:
- *
- * Initializes the Swfdec library.
- **/
-void
-swfdec_init (void)
-{
-  static gboolean _inited = FALSE;
-  const char *s;
-
-  if (_inited)
-    return;
-
-  _inited = TRUE;
-
-  if (!g_thread_supported ())
-    g_thread_init (NULL);
-  g_type_init ();
-  oil_init ();
-#ifdef HAVE_GST
-  gst_init (NULL, NULL);
-  gst_pb_utils_init ();
-#endif
-
-  s = g_getenv ("SWFDEC_DEBUG");
-  if (s && s[0]) {
-    char *end;
-    int level;
-
-    level = strtoul (s, &end, 0);
-    if (end[0] == 0) {
-      swfdec_debug_set_level (level);
-    }
-  }
-}
-
-/**
  * swfdec_player_mouse_move:
  * @player: a #SwfdecPlayer
  * @x: x coordinate of mouse


More information about the Swfdec-commits mailing list