changeset 2775:5df83337516f

branch merge
author Andrew O. Shadoura <bugzilla@tut.by>
date Fri, 13 Jun 2008 05:57:25 +0300
parents f1f7ee810de8 (diff) 99dd09396885 (current diff)
children 4c092042129b
files configure.ac extra.mk.in m4/libmikmod.m4 src/OSS/about.c src/OSS/convert.c src/OSS/init.c src/OSS4/about.c src/OSS4/init.c src/alsa/init.c src/filewriter/filewriter.c src/filewriter/filewriter.h src/filewriter/mp3.c src/filewriter/vorbis.c src/lirc/lirc_cfg.c src/modplug/gui/Makefile src/modplug/load_j2b.cxx src/modplug/load_mid.cxx src/modplug/modplug.h src/scrobbler/md5.c src/scrobbler/md5.h src/sid/xs_md5.c src/sid/xs_md5.h
diffstat 11 files changed, 694 insertions(+), 77 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Tue Jun 10 10:25:46 2008 +0300
+++ b/configure.ac	Fri Jun 13 05:57:25 2008 +0300
@@ -1,6 +1,6 @@
 dnl Process this file with autoconf to produce a configure script.
 
-AC_INIT([audacious-plugins], [1.9.0], [bugs+audacious-plugins@atheme.org])
+AC_INIT([audacious-plugins], [1.5.0], [bugs+audacious-plugins@atheme.org])
 AC_PREREQ([2.59])
 
 AC_CANONICAL_HOST
@@ -122,7 +122,7 @@
 
 INPUT_PLUGINS="tonegen console sexypsf cue alac metronom vtx"
 OUTPUT_PLUGINS="null"
-EFFECT_PLUGINS="audiocompress crystalizer ladspa voice_removal sndstretch stereo_plugin echo_plugin"
+EFFECT_PLUGINS="audiocompress ladspa voice_removal sndstretch stereo_plugin echo_plugin"
 GENERAL_PLUGINS="song_change alarm"
 VISUALIZATION_PLUGINS="blur_scope spectrum"
 CONTAINER_PLUGINS="m3u pls"
@@ -242,7 +242,7 @@
 dnl Check for esound
 
 AC_ARG_ENABLE( esd,
-    [  --disable-esd           disable esound output plugin [default=enabled]],
+    [  --disable-esd           disable esound output plugin (default=enabled)],
     [enable_esd=$enableval],
     [enable_esd="yes"]
 )
@@ -261,7 +261,7 @@
 dnl Check for PulseAudio
 
 AC_ARG_ENABLE( pulse,
-    [  --disable-pulse         disable PulseAudio output plugin [default=enabled]],
+    [  --disable-pulse         disable PulseAudio output plugin (default=enabled)],
     [enable_pulse=$enableval],
     [enable_pulse="yes"]
 )
@@ -295,6 +295,29 @@
 	have_coreaudio=no
 fi
 
+dnl *** Icecast
+
+AC_ARG_ENABLE( icecast,
+    [  --disable-icecast       disable Icecast output plugin (default=enabled)],
+    [enable_icecast=$enableval],
+    [enable_icecast="yes"]
+)
+
+if test "x$enable_icecast" = "xyes"; then
+    PKG_CHECK_MODULES(SHOUT, [shout >= 2.0],
+         [have_shout=yes
+	  enable_filewriter=yes
+          OUTPUT_PLUGINS="$OUTPUT_PLUGINS icecast"],
+         [have_shout=no]
+    )
+else
+    AC_MSG_RESULT([*** icecast output plugin disabled per user request ***])
+    have_shout=no
+fi
+
+AC_SUBST(SHOUT_CFLAGS)
+AC_SUBST(SHOUT_LIBS)
+
 dnl *** Dock Album Art (MacOS)
 
 AC_ARG_ENABLE(dockalbumart,
@@ -919,7 +942,7 @@
 if test "x$have_oss" = "xyes"; then
 	OUTPUT_PLUGINS="$OUTPUT_PLUGINS OSS"
 fi
-AC_SUBST(OSS_CFLAGS)
+
 AC_SUBST(OSS_LIBS)
 
 
@@ -1328,12 +1351,13 @@
 
 if test "x$have_neon" = "xyes"; then
     PKG_CHECK_MODULES(NEON, [neon >= 0.26], [TRANSPORT_PLUGINS="$TRANSPORT_PLUGINS neon" ], [have_neon="no"])
-    AC_CHECK_LIB([neon], [ne_set_connect_timeout], [AC_DEFINE(HAVE_NE_SET_CONNECT_TIMEOUT, 1, [Whether we have ne_set_connect_timeout])], [], [$NEON_LIBS])
+    NEON_LIBS=`pkg-config --libs neon`
+    NEON_CFLAGS=`pkg-config --cflags neon`
 else
-    have_neon="no"
+    have_neon=no
 fi
-AC_SUBST([NEON_LIBS])
-AC_SUBST([NEON_CFLAGS])
+AC_SUBST(NEON_LIBS)
+AC_SUBST(NEON_CLFAGS)
 
 
 dnl *** MMS
@@ -1371,26 +1395,6 @@
 AC_SUBST(MTP_LIBS)
 AC_SUBST(MTP_CFLAGS)
 
-dnl *** Bluetooth audio suport 
-
-AC_ARG_ENABLE(bluetooth,
-[  --disable-bluetooth           disable bluetooth audio support. (default=enabled)],
-[have_bluetooth=$enableval],
-[have_bluetooth=yes])
-
-if test "x$have_bluetooth" = "xyes"; then
-    have_bluetooth=yes
-    PKG_CHECK_MODULES(BLUEZ, [bluez >= 2.22],
-    [GENERAL_PLUGINS="$GENERAL_PLUGINS bluetooth" ], [have_bluetooth="no"])
-    BLUEZ_LIBS=`pkg-config --libs bluez`
-    BLUEZ_CFLAGS=`pkg-config --cflags bluez`
-else
-    have_bluetooth=no
-    AC_MSG_RESULT([*** bluetooth audio suport plugin disabled by request ***])
-fi
-AC_SUBST(BLUEZ_LIBS)
-AC_SUBST(BLUEZ_CFLAGS)
-
 dnl *** libparanormal checks
 
 AC_ARG_ENABLE(paranormal,
@@ -1467,9 +1471,9 @@
 	PKG_CHECK_MODULES(GTKGLEXT, [gtkglext-1.0 >= 1.2.0], [have_projectm1="yes"], [have_projectm1="no"])
 fi
 
-if test "$have_projectm1" = "yes"; then
-	PKG_CHECK_MODULES(LIBPROJECTM1, [libprojectM >= 1.1], [have_projectm1="yes"], [have_projectm1="no"])
-	if test x$libprjM = xno; then
+if test "x$have_projectm1" = "xyes"; then
+	PKG_CHECK_MODULES(LIBPROJECTM1, [libprojectM < 1.1], [have_projectm1="yes"], [have_projectm1="no"])
+	if test "x$libprjM" = "xno"; then
 	        AC_MSG_WARN([*** libprojectM not found.
 	                        libprojectM is needed to build this package.
 	                        You can download libprojectM at http://projectm.sf.net/])
@@ -1664,6 +1668,7 @@
 echo "    -> FileWriter MP3 output part:        $have_lame"
 echo "    -> FileWriter Vorbis output part:     $have_vorbisenc"
 echo "    -> FileWriter FLAC output part:       $have_writer_flac"
+echo "  Icecast audio output (icecast):         $have_shout"
 echo "  Null Audio output (null):               yes"
 echo
 echo "  Input Plugins"
@@ -1706,7 +1711,6 @@
 echo "  LIRC:                                   $have_lirc"
 echo "  AudioScrobbler Client:                  $scrobbler"
 echo "  Upload to MTP device:                   $have_mtp_up"
-echo "  Bluetooth audio suport:                 $have_bluetooth"
 echo "  MacOS Dock Album Art plugin:            $have_dockalbumart"
 echo
 echo "  Effect"
@@ -1717,7 +1721,6 @@
 echo "  Extra Stereo:                           yes"
 echo "  Echo/Surround:                          yes"
 echo "  SndStretch:                             yes"
-echo "  Crystalizer:                            yes"
 echo
 echo "  Visualization"
 echo "  -------------"
--- a/extra.mk.in	Tue Jun 10 10:25:46 2008 +0300
+++ b/extra.mk.in	Fri Jun 13 05:57:25 2008 +0300
@@ -79,6 +79,8 @@
 BEEP_PATH ?= @BEEP_PATH@
 BINIO_CFLAGS ?= @BINIO_CFLAGS@
 BINIO_LIBS ?= @BINIO_LIBS@
+BUILDERS_INCLUDES ?= @BUILDERS_INCLUDES@
+BUILDERS_LDFLAGS ?= @BUILDERS_LDFLAGS@
 BUILD_INCLUDED_LIBINTL ?= @BUILD_INCLUDED_LIBINTL@
 CAIRO_CFLAGS ?= @CAIRO_CFLAGS@
 CAIRO_LIBS ?= @CAIRO_LIBS@
@@ -230,7 +232,6 @@
 OGG_VORBIS_CFLAGS ?= @OGG_VORBIS_CFLAGS@
 OGG_VORBIS_LIBS ?= @OGG_VORBIS_LIBS@
 OSS_LIBS ?= @OSS_LIBS@
-OSS_CFLAGS ?= @OSS_CFLAGS@
 OUTPUT_PLUGINS ?= @OUTPUT_PLUGINS@
 OUTPUT_PLUGIN_DIR ?= @OUTPUT_PLUGIN_DIR@
 PACKAGE ?= @PACKAGE@
@@ -257,13 +258,12 @@
 SDL_LIBS ?= @SDL_LIBS@
 SET_MAKE ?= @SET_MAKE@
 SHELL ?= @SHELL@
-SIDPLAY1_CFLAGS ?= @SIDPLAY1_CFLAGS@
-SIDPLAY1_LIBS ?= @SIDPLAY1_LIBS@
-SIDPLAY2_CFLAGS ?= @SIDPLAY2_CFLAGS@
-SIDPLAY2_LIBS ?= @SIDPLAY2_LIBS@
-BUILDERS_CFLAGS ?= @BUILDERS_CFLAGS@
-BUILDERS_LDFLAGS ?= @BUILDERS_LDFLAGS@
-BUILDERS_LIBS ?= @BUILDERS_LIBS@
+SHOUT_CFLAGS ?= @SHOUT_CFLAGS@
+SHOUT_LIBS ?= @SHOUT_LIBS@
+SIDPLAY1_INCLUDES ?= @SIDPLAY1_INCLUDES@
+SIDPLAY1_LDADD ?= @SIDPLAY1_LDADD@
+SIDPLAY2_INCLUDES ?= @SIDPLAY2_INCLUDES@
+SIDPLAY2_LDADD ?= @SIDPLAY2_LDADD@
 SNDFILE_CFLAGS ?= @SNDFILE_CFLAGS@
 SNDFILE_LIBS ?= @SNDFILE_LIBS@
 STRIP ?= @STRIP@
--- a/src/filewriter/filewriter.c	Tue Jun 10 10:25:46 2008 +0300
+++ b/src/filewriter/filewriter.c	Fri Jun 13 05:57:25 2008 +0300
@@ -17,7 +17,7 @@
  *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
 #include "filewriter.h"
@@ -77,10 +77,16 @@
 
 static gchar *file_path = NULL;
 
+VFSFile *output_file = NULL;
+guint64 written = 0;
+guint64 offset = 0;
+Tuple *tuple = NULL;
+
 static void file_init(void);
 static void file_about(void);
 static gint file_open(AFormat fmt, gint rate, gint nch);
 static void file_write(void *ptr, gint length);
+static gint file_write_output(void *ptr, gint length);
 static void file_close(void);
 static void file_flush(gint time);
 static void file_pause(short p);
@@ -134,7 +140,7 @@
 
 static void file_init(void)
 {
-    mcs_handle_t *db;
+    ConfigDb *db;
     /*GtkWidget *menu_root;
 
     menu_root = gtk_menu_item_new_with_label(_("FileWriter"));
@@ -155,7 +161,7 @@
 
     set_plugin();
     if (plugin.init)
-        plugin.init();
+        plugin.init(&file_write_output);
 }
 
 void file_about(void)
@@ -179,7 +185,7 @@
                                "\n"
                                "You should have received a copy of the GNU General Public License\n"
                                "along with this program; if not, write to the Free Software\n"
-                               "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,\n"
+                               "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,\n"
                                "USA."), _("Ok"), FALSE, NULL, NULL);
     gtk_signal_connect(GTK_OBJECT(dialog), "destroy",
                        GTK_SIGNAL_FUNC(gtk_widget_destroyed), &dialog);
@@ -326,6 +332,11 @@
     plugin.write(ptr, length);
 }
 
+static gint file_write_output(void *ptr, gint length)
+{
+    return aud_vfs_fwrite(ptr, 1, length, output_file);
+}
+
 static void file_close(void)
 {
     plugin.close();
@@ -375,7 +386,7 @@
 
 static void configure_ok_cb(gpointer data)
 {
-    mcs_handle_t *db;
+    ConfigDb *db;
 
     fileext = gtk_combo_box_get_active(GTK_COMBO_BOX(fileext_combo));
 
@@ -407,6 +418,8 @@
 {
     fileext = gtk_combo_box_get_active(GTK_COMBO_BOX(fileext_combo));
     set_plugin();
+    if (plugin.init)
+        plugin.init(&file_write_output);
 
     gtk_widget_set_sensitive(plugin_button, plugin.configure != NULL);
 }
@@ -630,8 +643,3 @@
         gtk_widget_show_all(configure_win);
     }
 }
-
-VFSFile *output_file = NULL;
-guint64 written = 0;
-guint64 offset = 0;
-Tuple *tuple = NULL;
--- a/src/filewriter/filewriter.h	Tue Jun 10 10:25:46 2008 +0300
+++ b/src/filewriter/filewriter.h	Fri Jun 13 05:57:25 2008 +0300
@@ -29,8 +29,13 @@
 #include <stdio.h>
 #include <string.h>
 
+#include <audacious/main.h>
 #include <audacious/plugin.h>
+#include <audacious/playlist.h>
+#include <audacious/configdb.h>
 #include <audacious/i18n.h>
+#include <audacious/util.h>
+#include <audacious/vfs.h>
 
 struct format_info { 
     AFormat format;
@@ -47,12 +52,15 @@
 
 typedef struct _FileWriter FileWriter;
 
+typedef gint (*write_output_callback)(void *ptr, gint length);
+
 struct _FileWriter
 {
-    void (*init)(void);
+    void (*init)(write_output_callback write_output_func);
     void (*configure)(void);
     gint (*open)(void);
     void (*write)(void *ptr, gint length);
+    void (*flush)(void);
     void (*close)(void);
     gint (*free)(void);
     gint (*playing)(void);
--- a/src/filewriter/flac.c	Tue Jun 10 10:25:46 2008 +0300
+++ b/src/filewriter/flac.c	Fri Jun 13 05:57:25 2008 +0300
@@ -28,6 +28,7 @@
 
 static gint flac_open(void);
 static void flac_write(gpointer data, gint length);
+static void flac_flush(void);
 static void flac_close(void);
 static gint flac_free(void);
 static gint flac_playing(void);
@@ -39,6 +40,7 @@
     NULL,
     flac_open,
     flac_write,
+    flac_flush,
     flac_close,
     flac_free,
     flac_playing,
@@ -172,6 +174,11 @@
 #endif
 }
 
+static void flac_flush(void)
+{
+    //should we do something here? --AOS
+}
+
 static void flac_close(void)
 {
     FLAC__stream_encoder_finish(flac_encoder);
--- a/src/filewriter/mp3.c	Tue Jun 10 10:25:46 2008 +0300
+++ b/src/filewriter/mp3.c	Fri Jun 13 05:57:25 2008 +0300
@@ -29,14 +29,16 @@
 #include <lame/lame.h>
 #define ENCBUFFER_SIZE 35000
 
-static void mp3_init(void);
+static void mp3_init(write_output_callback write_output_func);
 static void mp3_configure(void);
 static gint mp3_open(void);
 static void mp3_write(void *ptr, gint length);
+static void mp3_flush(void);
 static void mp3_close(void);
 static gint mp3_free(void);
 static gint mp3_playing(void);
 static gint mp3_get_written_time(void);
+static gint (*write_output)(void *ptr, gint length);
 
 FileWriter mp3_plugin =
 {
@@ -44,6 +46,7 @@
     mp3_configure,
     mp3_open,
     mp3_write,
+    mp3_flush,
     mp3_close,
     mp3_free,
     mp3_playing,
@@ -158,9 +161,9 @@
     (void) vfprintf(stdout, format, ap);
 }
 
-static void mp3_init(void)
+static void mp3_init(write_output_callback write_output_func)
 {
-    mcs_handle_t *db = aud_cfg_db_open();
+    ConfigDb *db = aud_cfg_db_open();
     aud_cfg_db_get_int(db, "filewriter_mp3", "vbr_on", &vbr_on);
     aud_cfg_db_get_int(db, "filewriter_mp3", "vbr_type", &vbr_type);
     aud_cfg_db_get_int(db, "filewriter_mp3", "vbr_min_val", &vbr_min_val);
@@ -194,6 +197,8 @@
     aud_cfg_db_get_int(db, "filewriter_mp3", "error_protect_val",
                        &error_protect_val);
     aud_cfg_db_close(db);
+    if (write_output_func)
+        write_output=write_output_func;
 }
 
 static gint mp3_open(void)
@@ -302,27 +307,33 @@
                                            ENCBUFFER_SIZE);
     }
 
-    aud_vfs_fwrite(encbuffer, 1, encout, output_file);
+    write_output(encbuffer, encout);
     written += encout;
     olen += length;
 }
 
+static void mp3_flush(void)
+{
+    encout = lame_encode_flush_nogap(gfp, encbuffer, ENCBUFFER_SIZE);
+    write_output(encbuffer, encout);
+}
+
 static void mp3_close(void)
 {
     if (output_file)
     {
         encout = lame_encode_flush_nogap(gfp, encbuffer, ENCBUFFER_SIZE);
-        aud_vfs_fwrite(encbuffer, 1, encout, output_file);
+        write_output(encbuffer, encout);
 
 //        lame_mp3_tags_fid(gfp, output_file); // will erase id3v2 tag??
 
-        lame_close(gfp);
-        AUDDBG("lame_close() done\n");
-
-        free_lameid3(&lameid3);
-
         olen = 0;
     }
+
+    lame_close(gfp);
+    AUDDBG("lame_close() done\n");
+
+    free_lameid3(&lameid3);
 }
 
 static gint mp3_free(void)
@@ -615,7 +626,7 @@
 
 static void configure_ok_cb(gpointer data)
 {
-    mcs_handle_t *db;
+    ConfigDb *db;
 
     if (vbr_min_val > vbr_max_val)
         vbr_max_val = vbr_min_val;
--- a/src/filewriter/vorbis.c	Tue Jun 10 10:25:46 2008 +0300
+++ b/src/filewriter/vorbis.c	Fri Jun 13 05:57:25 2008 +0300
@@ -26,14 +26,16 @@
 #include <vorbis/vorbisenc.h>
 #include <stdlib.h>
 
-static void vorbis_init(void);
+static void vorbis_init(write_output_callback write_output_func);
 static void vorbis_configure(void);
 static gint vorbis_open(void);
 static void vorbis_write(gpointer data, gint length);
+static void vorbis_flush(void);
 static void vorbis_close(void);
 static gint vorbis_free(void);
 static gint vorbis_playing(void);
 static gint vorbis_get_written_time(void);
+static gint (*write_output)(void *ptr, gint length);
 
 FileWriter vorbis_plugin =
 {
@@ -41,6 +43,7 @@
     vorbis_configure,
     vorbis_open,
     vorbis_write,
+    vorbis_flush,
     vorbis_close,
     vorbis_free,
     vorbis_playing,
@@ -61,13 +64,16 @@
 static float **encbuffer;
 static guint64 olen = 0;
 
-static void vorbis_init(void)
+static void vorbis_init(write_output_callback write_output_func)
 {
-    mcs_handle_t *db = aud_cfg_db_open();
+    ConfigDb *db = aud_cfg_db_open();
 
     aud_cfg_db_get_float(db, "filewriter_vorbis", "base_quality", &v_base_quality);
 
     aud_cfg_db_close(db);
+
+    if (write_output_func)
+        write_output=write_output_func;
 }
 
 static gint vorbis_open(void)
@@ -77,7 +83,7 @@
     ogg_packet header_comm;
     ogg_packet header_code;
 
-    vorbis_init();
+    vorbis_init(NULL);
 
     written = 0;
     olen = 0;
@@ -140,8 +146,8 @@
         if (result == 0)
             break;
 
-        written += aud_vfs_fwrite(og.header, 1, og.header_len, output_file);
-        written += aud_vfs_fwrite(og.body, 1, og.body_len, output_file);
+        written += write_output(og.header, og.header_len);
+        written += write_output(og.body, og.body_len);
     }
 
     return 1;
@@ -194,8 +200,8 @@
                 if (result == 0)
                     break;
 
-                written += aud_vfs_fwrite(og.header, 1, og.header_len, output_file);
-                written += aud_vfs_fwrite(og.body, 1, og.body_len, output_file);
+                written += write_output(og.header, og.header_len);
+                written += write_output(og.body, og.body_len);
             }
         }
     }
@@ -203,6 +209,11 @@
     olen += length;
 }
 
+static void vorbis_flush(void)
+{
+    //nothing to do here yet. --AOS
+}
+
 static void vorbis_close(void)
 {
     ogg_stream_clear(&os);
@@ -245,7 +256,7 @@
 
 static void configure_ok_cb(gpointer data)
 {
-    mcs_handle_t *db = aud_cfg_db_open();
+    ConfigDb *db = aud_cfg_db_open();
 
     aud_cfg_db_set_float(db, "filewrite_vorbis", "base_quality", v_base_quality);
 
--- a/src/filewriter/wav.c	Tue Jun 10 10:25:46 2008 +0300
+++ b/src/filewriter/wav.c	Fri Jun 13 05:57:25 2008 +0300
@@ -24,6 +24,7 @@
 
 static gint wav_open(void);
 static void wav_write(void *ptr, gint length);
+static void wav_flush(void);
 static void wav_close(void);
 static gint wav_free(void);
 static gint wav_playing(void);
@@ -35,6 +36,7 @@
     NULL,
     wav_open,
     wav_write,
+    wav_flush,
     wav_close,
     wav_free,
     wav_playing,
@@ -88,6 +90,11 @@
     written += aud_vfs_fwrite(ptr, 1, length, output_file);
 }
 
+static void wav_flush(void)
+{
+    //nothing to do here yet. --AOS
+}
+
 static void wav_close(void)
 {
     if (output_file)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/icecast/Makefile	Fri Jun 13 05:57:25 2008 +0300
@@ -0,0 +1,14 @@
+PLUGIN = icecast${PLUGIN_SUFFIX}
+
+SRCS = icecast.c	\
+       ../filewriter/mp3.o		\
+       ../filewriter/vorbis.o
+
+include ../../buildsys.mk
+include ../../extra.mk
+
+plugindir := ${plugindir}/${OUTPUT_PLUGIN_DIR}
+
+CFLAGS += ${PLUGIN_CFLAGS} ${SHOUT_CFLAGS}
+CPPFLAGS += ${PLUGIN_CPPFLAGS} ${GLIB_CFLAGS} ${GTK_CFLAGS} ${PANGO_CFLAGS} ${MOWGLI_CFLAGS} ${DBUS_CFLAGS} ${FILEWRITER_CFLAGS} ${OGG_VORBIS_CFLAGS} ${SHOUT_CFLAGS} -I../../intl -I../..
+LIBS += ${GTK_LIBS} ${FILEWRITER_LIBS} ${SHOUT_LIBS}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/icecast/icecast.c	Fri Jun 13 05:57:25 2008 +0300
@@ -0,0 +1,543 @@
+/*  Icecast-Plugin
+ *  (C) copyright 2008 based of FileWriter-plugin
+ *
+ *  Original Out-Lame-Plugin:
+ *  (C) copyright 2002 Lars Siebold <khandha5@gmx.net>
+ *  (C) copyright 2006-2007 porting to audacious by Yoshiki Yazawa <yaz@cc.rim.or.jp>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "../filewriter/filewriter.h"
+#include "../filewriter/plugins.h"
+#include <shout/shout.h>
+
+struct format_info input;
+
+static GtkWidget *configure_win = NULL, *configure_vbox;
+static GtkWidget *addr_hbox, *addr_label, *addr_entry;
+static GtkWidget *configure_bbox, *configure_ok, *configure_cancel;
+static guint ice_tid=0;
+
+static GtkWidget *streamformat_hbox, *streamformat_label, *streamformat_combo, *plugin_button;
+
+enum streamformat_t
+{
+#ifdef FILEWRITER_MP3
+    MP3,
+#endif
+#ifdef FILEWRITER_VORBIS
+    VORBIS,
+#endif
+    streamformat_MAX
+};
+
+static gint streamformat = VORBIS;
+
+static unsigned int streamformat_shout[] =
+{
+#ifdef FILEWRITER_MP3
+    SHOUT_FORMAT_MP3,
+#endif
+#ifdef FILEWRITER_VORBIS
+    SHOUT_FORMAT_OGG
+#endif
+};
+
+static FileWriter plugin;
+
+static gchar *server_address = NULL;
+
+VFSFile *output_file = NULL;
+guint64 written = 0;
+guint64 offset = 0;
+Tuple *tuple = NULL;
+static shout_t *shout = NULL;
+
+static void ice_init(void);
+static void ice_cleanup(void);
+static void ice_about(void);
+static gint ice_open(AFormat fmt, gint rate, gint nch);
+static void ice_write(void *ptr, gint length);
+static gint ice_write_output(void *ptr, gint length);
+static void ice_close(void);
+static void ice_flush(gint time);
+static void ice_pause(short p);
+static gint ice_free(void);
+static gint ice_playing(void);
+static gint ice_get_written_time(void);
+static gint ice_get_output_time(void);
+static void ice_configure(void);
+/*static int ice_mod_samples(gpointer * d, gint length, AFormat afmt, gint srate, gint nch);*/
+
+OutputPlugin ice_op =
+{
+    .description = "Icecast Plugin",
+    .init = ice_init,
+    .cleanup = ice_cleanup,
+    .about = ice_about,
+    .configure = ice_configure,
+    .open_audio = ice_open,
+    .write_audio = ice_write,
+    .close_audio = ice_close,
+    .flush = ice_flush,
+    .pause = ice_pause,
+    .buffer_free = ice_free,
+    .buffer_playing = ice_playing,
+    .output_time = ice_get_output_time,
+    .written_time = ice_get_written_time
+};
+/*
+EffectPlugin ice_ep =
+{
+        .description = "Icecast Plugin",
+        .init = ice_init,
+        .cleanup = ice_cleanup,
+        .about = ice_about,
+        .configure = ice_configure,
+        .mod_samples = ice_mod_samples,
+};
+*/
+OutputPlugin *ice_oplist[] = { &ice_op, NULL };
+
+SIMPLE_OUTPUT_PLUGIN(icecast, ice_oplist);
+
+static void set_plugin(void)
+{
+    if (streamformat < 0 || streamformat >= streamformat_MAX)
+        streamformat = 0;
+
+#ifdef FILEWRITER_MP3
+    if (streamformat == MP3)
+        plugin = mp3_plugin;
+#endif
+#ifdef FILEWRITER_VORBIS
+    if (streamformat == VORBIS)
+        plugin = vorbis_plugin;
+#endif
+}
+
+static void ice_init(void)
+{
+    ConfigDb *db;
+    puts("ICE_INIT");
+    shout_init();
+    printf("Using libshout %s\n", shout_version(NULL, NULL, NULL));
+
+    db = aud_cfg_db_open();
+    aud_cfg_db_get_int(db, "icecast", "streamformat", &streamformat);
+    aud_cfg_db_get_string(db, "icecast", "server_address", &server_address);
+    aud_cfg_db_close(db);
+
+    set_plugin();
+    if (plugin.init)
+        plugin.init(&ice_write_output);
+}
+
+static void ice_cleanup(void)
+{
+    if (shout)
+    {
+        shout_close(shout);
+    }
+    shout_shutdown();
+}
+
+void ice_about(void)
+{
+    static GtkWidget *dialog;
+
+    if (dialog != NULL)
+        return;
+
+    dialog = audacious_info_dialog(_("About Icecast-Plugin"),
+                               _("Icecast-Plugin\n\n"
+                               "This program is free software; you can redistribute it and/or modify\n"
+                               "it under the terms of the GNU General Public License as published by\n"
+                               "the Free Software Foundation; either version 2 of the License, or\n"
+                               "(at your option) any later version.\n"
+                               "\n"
+                               "This program is distributed in the hope that it will be useful,\n"
+                               "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+                               "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
+                               "GNU General Public License for more details.\n"
+                               "\n"
+                               "You should have received a copy of the GNU General Public License\n"
+                               "along with this program; if not, write to the Free Software\n"
+                               "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,\n"
+                               "USA."), _("Ok"), FALSE, NULL, NULL);
+    gtk_signal_connect(GTK_OBJECT(dialog), "destroy",
+                       GTK_SIGNAL_FUNC(gtk_widget_destroyed), &dialog);
+}
+
+static gint ice_open(AFormat fmt, gint rate, gint nch)
+{
+    gint rv;
+    gint pos;
+    Playlist *playlist;
+
+    if (ice_tid)
+    {
+	g_source_remove(ice_tid);
+	ice_tid = 0;
+    }
+
+    input.format = fmt;
+    input.frequency = rate;
+    input.channels = nch;
+
+    playlist = aud_playlist_get_active();
+    if(!playlist)
+        return 0;
+
+    pos = aud_playlist_get_position(playlist);
+    tuple = aud_playlist_get_tuple(playlist, pos);
+
+    if (!shout)
+    {
+        rv = (plugin.open)();
+
+        if (!(shout = shout_new()))
+            return 0;
+
+        if (shout_set_host(shout, server_address) != SHOUTERR_SUCCESS)
+        {
+            printf("Error setting hostname: %s\n", shout_get_error(shout));
+            return 0;
+        }
+
+        if (shout_set_protocol(shout, SHOUT_PROTOCOL_HTTP) != SHOUTERR_SUCCESS)
+        {
+            printf("Error setting protocol: %s\n", shout_get_error(shout));
+            return 0;
+        }
+
+        if (shout_set_port(shout, 8000) != SHOUTERR_SUCCESS)
+        {
+            printf("Error setting port: %s\n", shout_get_error(shout));
+            return 0;
+        }
+
+        if (shout_set_password(shout, "password") != SHOUTERR_SUCCESS)
+        {
+            printf("Error setting password: %s\n", shout_get_error(shout));
+            return 0;
+        }
+
+        if (shout_set_mount(shout, "/test") != SHOUTERR_SUCCESS)
+        {
+            printf("Error setting mount: %s\n", shout_get_error(shout));
+            return 0;
+        }
+
+        if (shout_set_user(shout, "source") != SHOUTERR_SUCCESS)
+        {
+            printf("Error setting user: %s\n", shout_get_error(shout));
+            return 0;
+        }
+
+        if (shout_set_format(shout, streamformat_shout[streamformat]) != SHOUTERR_SUCCESS)
+        {
+            printf("Error setting user: %s\n", shout_get_error(shout));
+            return 0;
+        }
+
+        if (shout_open(shout) != SHOUTERR_SUCCESS)
+        {
+            printf("Error connecting to server: %s\n", shout_get_error(shout));
+            return 0;
+        }
+    }
+    else
+        rv = 1;
+
+    {
+        shout_metadata_t *sm = NULL;
+        sm = shout_metadata_new();
+        if (sm)
+        {
+            shout_metadata_add(sm, "charset", "UTF-8");
+            shout_metadata_add(sm, "title", aud_tuple_get_string(tuple, FIELD_TITLE, NULL));
+            shout_metadata_add(sm, "artist", aud_tuple_get_string(tuple, FIELD_ARTIST, NULL));
+            shout_set_metadata(shout, sm);
+            shout_metadata_free(sm);
+        }
+    }
+
+    puts("ICE_OPEN");
+    return rv;
+}
+
+static void convert_buffer(gpointer buffer, gint length)
+{
+    gint i;
+
+    if (input.format == FMT_S8)
+    {
+        guint8 *ptr1 = buffer;
+        gint8 *ptr2 = buffer;
+
+        for (i = 0; i < length; i++)
+            *(ptr1++) = *(ptr2++) ^ 128;
+    }
+    if (input.format == FMT_S16_BE)
+    {
+        gint16 *ptr = buffer;
+
+        for (i = 0; i < length >> 1; i++, ptr++)
+            *ptr = GUINT16_SWAP_LE_BE(*ptr);
+    }
+    if (input.format == FMT_S16_NE)
+    {
+        gint16 *ptr = buffer;
+
+        for (i = 0; i < length >> 1; i++, ptr++)
+            *ptr = GINT16_TO_LE(*ptr);
+    }
+    if (input.format == FMT_U16_BE)
+    {
+        gint16 *ptr1 = buffer;
+        guint16 *ptr2 = buffer;
+
+        for (i = 0; i < length >> 1; i++, ptr2++)
+            *(ptr1++) = GINT16_TO_LE(GUINT16_FROM_BE(*ptr2) ^ 32768);
+    }
+    if (input.format == FMT_U16_LE)
+    {
+        gint16 *ptr1 = buffer;
+        guint16 *ptr2 = buffer;
+
+        for (i = 0; i < length >> 1; i++, ptr2++)
+            *(ptr1++) = GINT16_TO_LE(GUINT16_FROM_LE(*ptr2) ^ 32768);
+    }
+    if (input.format == FMT_U16_NE)
+    {
+        gint16 *ptr1 = buffer;
+        guint16 *ptr2 = buffer;
+
+        for (i = 0; i < length >> 1; i++, ptr2++)
+            *(ptr1++) = GINT16_TO_LE((*ptr2) ^ 32768);
+    }
+}
+
+static void ice_write(void *ptr, gint length)
+{
+    if (input.format == FMT_S8 || input.format == FMT_S16_BE ||
+        input.format == FMT_U16_LE || input.format == FMT_U16_BE ||
+        input.format == FMT_U16_NE)
+        convert_buffer(ptr, length);
+#ifdef WORDS_BIGENDIAN
+    if (input.format == FMT_S16_NE)
+        convert_buffer(ptr, length);
+#endif
+
+    plugin.write(ptr, length);
+}
+
+static gint ice_write_output(void *ptr, gint length)
+{
+    int i, ret;
+    if ((!shout) || (!length)) return 0;
+    ret = shout_send(shout, ptr, length);
+    //shout_send_raw(shout, ptr, length);
+    shout_sync(shout);
+    printf("ice_write[%d:%d](", ret, length);
+    for (i=0;(i<length)&&(i<16);i++)   printf("%c",g_ascii_isprint(((char*)ptr)[i])?(((char*)ptr)[i]):'.');
+    printf(")\n");
+    return length;
+}
+
+static gboolean ice_real_close(gpointer data)
+{
+    plugin.close();
+
+    if (shout)
+    {
+        written = 0;
+        shout_close(shout);
+    }
+    shout = NULL;
+    ice_tid=0;
+    puts("ICE_REAL_CLOSE");
+    return FALSE;
+}
+
+
+static void ice_close(void)
+{
+    if (ice_tid) g_source_remove(ice_tid);
+    ice_tid=g_timeout_add_seconds(3, ice_real_close, NULL);
+    puts("ICE_CLOSE: starting timer");
+}
+
+static void ice_flush(gint time)
+{
+    if (time < 0)
+        return;
+
+    plugin.flush();
+    ice_open(input.format, input.frequency, input.channels);
+
+    offset = time;
+}
+
+static void ice_pause(short p)
+{
+}
+
+static gint ice_free(void)
+{
+    return plugin.free();
+}
+
+static gint ice_playing(void)
+{
+    return plugin.playing();
+}
+
+static gint ice_get_written_time(void)
+{
+    return plugin.get_written_time();
+}
+
+static gint ice_get_output_time(void)
+{
+    return ice_get_written_time();
+}
+
+static void configure_ok_cb(gpointer data)
+{
+    ConfigDb *db;
+
+    streamformat = gtk_combo_box_get_active(GTK_COMBO_BOX(streamformat_combo));
+
+    g_free(server_address);
+    server_address = g_strdup(gtk_entry_get_text(GTK_ENTRY(addr_entry)));
+
+    db = aud_cfg_db_open();
+    aud_cfg_db_set_int(db, "icecast", "streamformat", streamformat);
+    aud_cfg_db_set_string(db, "icecast", "server_address", server_address);
+
+    aud_cfg_db_close(db);
+
+    gtk_widget_destroy(configure_win);
+}
+
+static void streamformat_cb(GtkWidget *combo, gpointer data)
+{
+    streamformat = gtk_combo_box_get_active(GTK_COMBO_BOX(streamformat_combo));
+    set_plugin();
+    if (plugin.init)
+        plugin.init(&ice_write_output);
+
+    gtk_widget_set_sensitive(plugin_button, plugin.configure != NULL);
+}
+
+static void plugin_configure_cb(GtkWidget *button, gpointer data)
+{
+    if (plugin.configure)
+        plugin.configure();
+}
+
+static void configure_destroy(void)
+{
+}
+
+static void ice_configure(void)
+{
+    if (!configure_win)
+    {
+        configure_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+
+        gtk_signal_connect(GTK_OBJECT(configure_win), "destroy",
+                           GTK_SIGNAL_FUNC(configure_destroy), NULL);
+        gtk_signal_connect(GTK_OBJECT(configure_win), "destroy",
+                           GTK_SIGNAL_FUNC(gtk_widget_destroyed),
+                           &configure_win);
+
+        gtk_window_set_title(GTK_WINDOW(configure_win),
+                             _("Icecast Configuration"));
+        gtk_window_set_position(GTK_WINDOW(configure_win), GTK_WIN_POS_MOUSE);
+
+        gtk_container_set_border_width(GTK_CONTAINER(configure_win), 10);
+
+        configure_vbox = gtk_vbox_new(FALSE, 10);
+        gtk_container_add(GTK_CONTAINER(configure_win), configure_vbox);
+
+
+        streamformat_hbox = gtk_hbox_new(FALSE, 5);
+        gtk_box_pack_start(GTK_BOX(configure_vbox), streamformat_hbox, FALSE, FALSE, 0);
+
+        streamformat_label = gtk_label_new(_("Output stream format:"));
+        gtk_box_pack_start(GTK_BOX(streamformat_hbox), streamformat_label, FALSE, FALSE, 0);
+
+        streamformat_combo = gtk_combo_box_new_text();
+#ifdef FILEWRITER_MP3
+        gtk_combo_box_append_text(GTK_COMBO_BOX(streamformat_combo), "MP3");
+#endif
+#ifdef FILEWRITER_VORBIS
+        gtk_combo_box_append_text(GTK_COMBO_BOX(streamformat_combo), "Vorbis");
+#endif
+        gtk_box_pack_start(GTK_BOX(streamformat_hbox), streamformat_combo, FALSE, FALSE, 0);
+        gtk_combo_box_set_active(GTK_COMBO_BOX(streamformat_combo), streamformat);
+        g_signal_connect(G_OBJECT(streamformat_combo), "changed", G_CALLBACK(streamformat_cb), NULL);
+
+        plugin_button = gtk_button_new_with_label(_("Configure"));
+        gtk_widget_set_sensitive(plugin_button, plugin.configure != NULL);
+        g_signal_connect(G_OBJECT(plugin_button), "clicked", G_CALLBACK(plugin_configure_cb), NULL);
+        gtk_box_pack_end(GTK_BOX(streamformat_hbox), plugin_button, FALSE, FALSE, 0);
+
+
+
+
+        gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
+
+        addr_hbox = gtk_hbox_new(FALSE, 5);
+        gtk_box_pack_start(GTK_BOX(configure_vbox), addr_hbox, FALSE, FALSE, 0);
+
+        addr_label = gtk_label_new(_("Server address:"));
+        gtk_box_pack_start(GTK_BOX(addr_hbox), addr_label, FALSE, FALSE, 0);
+
+        addr_entry = gtk_entry_new();
+
+	gtk_entry_set_text(GTK_ENTRY(addr_entry), server_address);
+
+        gtk_box_pack_start(GTK_BOX(addr_hbox), addr_entry, TRUE, TRUE, 0);
+
+        gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
+
+        configure_bbox = gtk_hbutton_box_new();
+        gtk_button_box_set_layout(GTK_BUTTON_BOX(configure_bbox),
+                                  GTK_BUTTONBOX_END);
+        gtk_button_box_set_spacing(GTK_BUTTON_BOX(configure_bbox), 5);
+        gtk_box_pack_start(GTK_BOX(configure_vbox), configure_bbox,
+                           FALSE, FALSE, 0);
+
+        configure_cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
+        gtk_signal_connect_object(GTK_OBJECT(configure_cancel), "clicked",
+                                  GTK_SIGNAL_FUNC(gtk_widget_destroy),
+                                  GTK_OBJECT(configure_win));
+        gtk_box_pack_start(GTK_BOX(configure_bbox), configure_cancel,
+                           TRUE, TRUE, 0);
+
+        configure_ok = gtk_button_new_from_stock(GTK_STOCK_OK);
+        gtk_signal_connect(GTK_OBJECT(configure_ok), "clicked",
+                           GTK_SIGNAL_FUNC(configure_ok_cb), NULL);
+        gtk_box_pack_start(GTK_BOX(configure_bbox), configure_ok,
+                           TRUE, TRUE, 0);
+
+        gtk_widget_show_all(configure_win);
+    }
+}
--- a/src/lirc/lirc_cfg.c	Tue Jun 10 10:25:46 2008 +0300
+++ b/src/lirc/lirc_cfg.c	Fri Jun 13 05:57:25 2008 +0300
@@ -3,6 +3,7 @@
 #include <gtk/gtk.h>
 #include <audacious/i18n.h>
 #include <audacious/plugin.h>
+#include <audacious/configdb.h>
 
 #include "common.h"
 
@@ -14,19 +15,23 @@
 
 void load_cfg(void)
 {
-  mcs_handle_t *db;
+  ConfigDb *db;
   db = aud_cfg_db_open();
   aud_cfg_db_get_int(db, "lirc", "enable_reconnect", &b_enable_reconnect);
   aud_cfg_db_get_int(db, "lirc", "reconnect_timeout", &reconnect_timeout);
   if (!aud_cfg_db_get_string(db, "aosd", "text_fonts_name_0", &aosd_font))
-   aosd_font = g_strdup("Sans 26");
-  if (!reconnect_timeout) reconnect_timeout = 5;
+    aosd_font = g_strdup("Sans 26");
+  if (!reconnect_timeout)
+  {
+    reconnect_timeout = 5;
+    b_enable_reconnect = 1;
+  }
   aud_cfg_db_close(db);
 }
 
 void save_cfg(void)
 {
-  mcs_handle_t *db;
+  ConfigDb *db;
   db = aud_cfg_db_open();
   aud_cfg_db_set_int(db, "lirc", "enable_reconnect", b_enable_reconnect);
   aud_cfg_db_set_int(db, "lirc", "reconnect_timeout", reconnect_timeout);