Mercurial > audlegacy-plugins
changeset 2781:7fc2c317d190
branch merge
author | Andrew O. Shadoura <bugzilla@tut.by> |
---|---|
date | Thu, 03 Jul 2008 17:37:11 +0300 |
parents | c40585c57877 (diff) ffb79e3d133a (current diff) |
children | c5005707a575 5a10f297b7d0 |
files | configure.ac |
diffstat | 11 files changed, 813 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
--- a/configure.ac Thu Jul 03 15:52:56 2008 +0200 +++ b/configure.ac Thu Jul 03 17:37:11 2008 +0300 @@ -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,28 @@ 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], + [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, @@ -1578,6 +1600,10 @@ AC_SUBST(FILEWRITER_CFLAGS) AC_SUBST(FILEWRITER_LIBS) +if test "x$have_shout" = "xyes"; then + OUTPUT_PLUGINS="$OUTPUT_PLUGINS icecast" +fi + dnl *** End of all plugin checks *** AC_SUBST(ARCH_DEFINES) @@ -1674,6 +1700,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" @@ -1720,7 +1747,7 @@ echo " LIRC: $have_lirc" echo " AudioScrobbler Client: $scrobbler" echo " Upload to MTP device: $have_mtp_up" -echo " Bluetooth audio suport: $have_bluetooth" +echo " Bluetooth audio support: $have_bluetooth" echo " MacOS Dock Album Art plugin: $have_dockalbumart" echo " Streambrowser: $enable_streambrowser" echo
--- a/extra.mk.in Thu Jul 03 15:52:56 2008 +0200 +++ b/extra.mk.in Thu Jul 03 17:37:11 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 Thu Jul 03 15:52:56 2008 +0200 +++ b/src/filewriter/filewriter.c Thu Jul 03 17:37:11 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 Thu Jul 03 15:52:56 2008 +0200 +++ b/src/filewriter/filewriter.h Thu Jul 03 17:37:11 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 Thu Jul 03 15:52:56 2008 +0200 +++ b/src/filewriter/flac.c Thu Jul 03 17:37:11 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 Thu Jul 03 15:52:56 2008 +0200 +++ b/src/filewriter/mp3.c Thu Jul 03 17:37:11 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 Thu Jul 03 15:52:56 2008 +0200 +++ b/src/filewriter/vorbis.c Thu Jul 03 17:37:11 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 Thu Jul 03 15:52:56 2008 +0200 +++ b/src/filewriter/wav.c Thu Jul 03 17:37:11 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 Thu Jul 03 17:37:11 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 Thu Jul 03 17:37:11 2008 +0300 @@ -0,0 +1,669 @@ +/* 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_entry, *port_spin, *timeout_spin, *buffersize_spin, *bufferflush_spin; +static GtkWidget *configure_bbox, *configure_ok, *configure_cancel; +static guint ice_tid=0; + +static gint ice_close_timeout; + +static GtkWidget *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 uint8_t *outputbuffer = NULL; +static guint outputlength=0; +static gint buffersize; +static gint bufferflush; +static gdouble bufferflushperc; +static gchar *server_address = NULL; +static gint server_port=8000; + +VFSFile *output_file = NULL; +guint64 written = 0; +guint64 offset = 0; +Tuple *tuple = NULL; +static shout_t *shout = NULL; +gboolean paused = FALSE; + +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_get_int(db, "icecast", "server_port", &server_port); + if (!server_port) server_port=8000; + aud_cfg_db_get_int(db, "icecast", "timeout", &ice_close_timeout); + if (!ice_close_timeout) ice_close_timeout=5; + aud_cfg_db_get_int(db, "icecast", "buffersize", &buffersize); + if (!buffersize) buffersize=8192; + aud_cfg_db_get_double(db, "icecast", "bufferflush", &bufferflushperc); + if (!bufferflushperc) bufferflushperc=80.0; + bufferflush=(gint)(buffersize*bufferflushperc); + aud_cfg_db_close(db); + + outputbuffer=g_try_malloc(buffersize); + + set_plugin(); + if (plugin.init) + plugin.init(&ice_write_output); +} + +static void ice_cleanup(void) +{ + if (shout) + { + shout_close(shout); + } + if (outputbuffer) + g_free(outputbuffer); + 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 (!outputbuffer) + return 0; + + 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, server_port) != 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_real_write(void* ptr, gint length) +{ + int ret; + if (!length) return length; + ret = shout_send(shout, ptr, length); + //shout_send_raw(shout, ptr, length); + shout_sync(shout); + printf("ice_write[%d:%d](", ret, length); + { + int i; + for (i=0;(i<length)&&(i<16);i++) printf("%c",g_ascii_isprint(((char*)ptr)[i])?(((char*)ptr)[i]):'.'); + } + printf(")\n"); + return 0; + //return ret; +} + +static gint ice_write_output(void *ptr, gint length) +{ + if ((!shout) || (!length)) return 0; + printf("outputlength=%d, length=%d...",outputlength, length); + if ((outputlength>bufferflush)||((outputlength+length)>buffersize)) + { + printf("flushing\n"); + outputlength=ice_real_write(outputbuffer, outputlength); + } + { + if (length>buffersize) + { + printf("data too long, flushing\n"); + ice_real_write(ptr, length); + } + else + { + printf("adding\n"); + memcpy(&(outputbuffer[outputlength]), ptr, length); + outputlength+=length; + } + } + 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) +{ + paused = p; +} + +static gint ice_free(void) +{ + return paused?0:plugin.free(); +} + +static gint ice_playing(void) +{ + return plugin.playing() && (!paused); +} + +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))); + + server_port = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(port_spin)); + + ice_close_timeout = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(timeout_spin)); + + buffersize = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(buffersize_spin)); + + bufferflushperc = gtk_spin_button_get_value(GTK_SPIN_BUTTON(bufferflush_spin)); + bufferflush=(gint)(buffersize*bufferflushperc); + + 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_set_int(db, "icecast", "server_port", server_port); + aud_cfg_db_set_int(db, "icecast", "timeout", ice_close_timeout); + aud_cfg_db_set_int(db, "icecast", "buffersize", buffersize); + aud_cfg_db_set_double(db, "icecast", "bufferflush", bufferflushperc); + + 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) + { + GtkWidget * hbox; + GtkWidget * label; + + 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); + + hbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(configure_vbox), hbox, FALSE, FALSE, 0); + + label = gtk_label_new(_("Output stream format:")); + gtk_box_pack_start(GTK_BOX(hbox), 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(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(hbox), plugin_button, FALSE, FALSE, 0); + + + + + gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_hseparator_new(), FALSE, FALSE, 0); + + hbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(configure_vbox), hbox, FALSE, FALSE, 0); + + label = gtk_label_new(_("Server address:")); + gtk_box_pack_start(GTK_BOX(hbox), 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(hbox), addr_entry, TRUE, TRUE, 0); + + port_spin = gtk_spin_button_new_with_range(0.0, 65535.0, 1.0); + + gtk_spin_button_set_digits(GTK_SPIN_BUTTON(port_spin), 0); + + gtk_spin_button_set_value(GTK_SPIN_BUTTON(port_spin), (gdouble)server_port); + + gtk_box_pack_start(GTK_BOX(hbox), port_spin, TRUE, TRUE, 0); + + gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_hseparator_new(), FALSE, FALSE, 0); + + hbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(configure_vbox), hbox, FALSE, FALSE, 0); + + label = gtk_label_new(_("Connection timeout (seconds):")); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + + timeout_spin = gtk_spin_button_new_with_range(1.0, 65535.0, 1.0); + + gtk_spin_button_set_digits(GTK_SPIN_BUTTON(timeout_spin), 0); + + gtk_spin_button_set_value(GTK_SPIN_BUTTON(timeout_spin), (gdouble)ice_close_timeout); + + gtk_box_pack_start(GTK_BOX(hbox), timeout_spin, TRUE, TRUE, 0); + + gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_hseparator_new(), FALSE, FALSE, 0); + + hbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(configure_vbox), hbox, FALSE, FALSE, 0); + + label = gtk_label_new(_("Buffer size (bytes):")); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + + buffersize_spin = gtk_spin_button_new_with_range(1.0, 65535.0, 1.0); + + gtk_spin_button_set_digits(GTK_SPIN_BUTTON(buffersize_spin), 0); + + gtk_spin_button_set_value(GTK_SPIN_BUTTON(buffersize_spin), (gdouble)buffersize); + + gtk_box_pack_start(GTK_BOX(hbox), buffersize_spin, TRUE, TRUE, 0); + + hbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(configure_vbox), hbox, FALSE, FALSE, 0); + + label = gtk_label_new(_("Flush buffer if ")); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + + bufferflush_spin = gtk_spin_button_new_with_range(1.0, 65535.0, 1.0); + + gtk_spin_button_set_digits(GTK_SPIN_BUTTON(bufferflush_spin), 0); + + gtk_spin_button_set_value(GTK_SPIN_BUTTON(bufferflush_spin), bufferflushperc); + + gtk_box_pack_start(GTK_BOX(hbox), bufferflush_spin, TRUE, TRUE, 0); + + label = gtk_label_new(_("percents are filled")); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 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 Thu Jul 03 15:52:56 2008 +0200 +++ b/src/lirc/lirc_cfg.c Thu Jul 03 17:37:11 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);