changeset 2833:2d17bc7744d8

branch merge
author Andrew O. Shadoura <bugzilla@tut.by>
date Mon, 14 Jul 2008 01:25:03 +0300
parents eb4cacfc1d03 (diff) 615a87ac7a96 (current diff)
children b61d7e3837a5
files
diffstat 2 files changed, 92 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- a/src/filewriter/mp3.c	Sun Jul 13 15:30:39 2008 -0500
+++ b/src/filewriter/mp3.c	Mon Jul 14 01:25:03 2008 +0300
@@ -203,6 +203,8 @@
 
 static gint mp3_open(void)
 {
+    olen = 0;
+
     gfp = lame_init();
     if (gfp == NULL)
         return 0;
--- a/src/icecast/icecast.c	Sun Jul 13 15:30:39 2008 -0500
+++ b/src/icecast/icecast.c	Mon Jul 14 01:25:03 2008 +0300
@@ -30,9 +30,9 @@
 
 static GtkWidget *configure_win = NULL, *configure_vbox;
 static GtkWidget *addr_entry, *port_spin, *timeout_spin, *buffersize_spin, *bufferflush_spin;
-static GtkWidget *user_entry, *password_entry;
+static GtkWidget *user_entry, *password_entry, *mount_entry;
 static GtkWidget *configure_bbox, *configure_ok, *configure_cancel;
-static guint ice_tid=0;
+static guint ice_tid = 0;
 
 static gint ice_close_timeout;
 
@@ -62,18 +62,20 @@
 };
 
 static FileWriter plugin;
+static FileWriter plugin_new;
 static uint8_t *outputbuffer = NULL;
-static guint outputlength=0;
+static guint outputlength = 0;
 static gint buffersize;
 static gint bufferflush;
 static gint buffersize_new;
 static gint bufferflush_new;
 static gdouble bufferflushperc;
 static gchar *server_address = NULL;
-static gint server_port=8000;
+static gint server_port = 8000;
 
 static gchar *server_user = NULL;
 static gchar *server_password = NULL;
+static gchar *mountpoint = NULL;
 
 VFSFile *output_file = NULL;
 guint64 written = 0;
@@ -137,11 +139,11 @@
 
 #ifdef FILEWRITER_MP3
     if (streamformat == MP3)
-        plugin = mp3_plugin;
+        plugin_new = mp3_plugin;
 #endif
 #ifdef FILEWRITER_VORBIS
     if (streamformat == VORBIS)
-        plugin = vorbis_plugin;
+        plugin_new = vorbis_plugin;
 #endif
 }
 
@@ -156,23 +158,29 @@
     aud_cfg_db_get_int(db, ICECAST_CFGID, "streamformat", &streamformat);
     aud_cfg_db_get_string(db, ICECAST_CFGID, "server_address", &server_address);
     aud_cfg_db_get_int(db, ICECAST_CFGID, "server_port", &server_port);
-    if (!server_port) server_port=8000;
+    if (!server_port)
+        server_port = 8000;
     aud_cfg_db_get_int(db, ICECAST_CFGID, "timeout", &ice_close_timeout);
-    if (!ice_close_timeout) ice_close_timeout=5;
+    if (!ice_close_timeout)
+        ice_close_timeout = 5;
     aud_cfg_db_get_int(db, ICECAST_CFGID, "buffersize", &buffersize);
-    if (!buffersize) buffersize=8192;
-    buffersize_new=buffersize;
+    if (!buffersize)
+        buffersize = 8192;
+    buffersize_new = buffersize;
     aud_cfg_db_get_double(db, ICECAST_CFGID, "bufferflush", &bufferflushperc);
-    if (!bufferflushperc) bufferflushperc=80.0;
-    bufferflush=(gint)(buffersize*bufferflushperc);
-    bufferflush_new=bufferflush;
+    if (!bufferflushperc)
+        bufferflushperc = 80.0;
+    bufferflush = (gint)(buffersize*bufferflushperc);
+    bufferflush_new = bufferflush;
     aud_cfg_db_get_string(db, ICECAST_CFGID, "server_user", &server_user);
     aud_cfg_db_get_string(db, ICECAST_CFGID, "server_password", &server_password);
+    aud_cfg_db_get_string(db, ICECAST_CFGID, "mountpoint", &mountpoint);
     aud_cfg_db_close(db);
 
-    outputbuffer=g_try_malloc(buffersize);
+    outputbuffer = g_try_malloc(buffersize);
 
     set_plugin();
+    plugin = plugin_new;
     if (plugin.init)
         plugin.init(&ice_write_output);
 }
@@ -196,23 +204,23 @@
         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);
+        _("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);
+        GTK_SIGNAL_FUNC(gtk_widget_destroyed), &dialog);
 }
 
 static gint ice_open(AFormat fmt, gint rate, gint nch)
@@ -221,14 +229,14 @@
     gint pos;
     Playlist *playlist;
 
-    if (buffersize!=buffersize_new)
+    if (buffersize != buffersize_new)
     {
-        buffersize=buffersize_new;
-        outputbuffer=g_try_realloc(outputbuffer, buffersize);
+        buffersize = buffersize_new;
+        outputbuffer = g_try_realloc(outputbuffer, buffersize);
     }
 
-    if (bufferflush!=bufferflush_new)
-        bufferflush=bufferflush_new;
+    if (bufferflush != bufferflush_new)
+        bufferflush = bufferflush_new;
 
     if (!outputbuffer)
         return 0;
@@ -250,10 +258,10 @@
     pos = aud_playlist_get_position(playlist);
     tuple = aud_playlist_get_tuple(playlist, pos);
 
+    plugin = plugin_new;
+
     if (!shout)
     {
-        rv = (plugin.open)();
-
         if (!(shout = shout_new()))
             return 0;
 
@@ -275,19 +283,19 @@
             return 0;
         }
 
-        if (shout_set_password(shout, "password") != SHOUTERR_SUCCESS)
+        if (shout_set_password(shout, server_password) != SHOUTERR_SUCCESS)
         {
             g_warning("Error setting password: %s\n", shout_get_error(shout));
             return 0;
         }
 
-        if (shout_set_mount(shout, "/test") != SHOUTERR_SUCCESS)
+        if (shout_set_mount(shout, mountpoint) != SHOUTERR_SUCCESS)
         {
             g_warning("Error setting mount: %s\n", shout_get_error(shout));
             return 0;
         }
 
-        if (shout_set_user(shout, "source") != SHOUTERR_SUCCESS)
+        if (shout_set_user(shout, server_user) != SHOUTERR_SUCCESS)
         {
             g_warning("Error setting user: %s\n", shout_get_error(shout));
             return 0;
@@ -305,9 +313,6 @@
             return 0;
         }
     }
-    else
-        rv = 1;
-
     {
         shout_metadata_t *sm = NULL;
         sm = shout_metadata_new();
@@ -321,6 +326,8 @@
         }
     }
 
+    rv = (plugin.open)();
+
     g_debug("ICE_OPEN");
     return rv;
 }
@@ -400,7 +407,8 @@
     g_debug("ice_write[%d:%d](", ret, length);
     {
         gint i;
-        for (i=0;(i<length)&&(i<16);i++) g_debug("%c",g_ascii_isprint(((char*)ptr)[i])?(((char*)ptr)[i]):'.');
+        for (i = 0; (i < length) && (i < 16); i++)
+            g_debug("%c", g_ascii_isprint(((char*)ptr)[i])?(((char*)ptr)[i]):'.');
     }
     g_debug(")");
     return 0;
@@ -409,14 +417,14 @@
 static gint ice_write_output(void *ptr, gint length)
 {
     if ((!shout) || (!length)) return 0;
-    g_debug("outputlength=%d, length=%d...",outputlength, length);
-    if ((outputlength>bufferflush)||((outputlength+length)>buffersize))
+    g_debug("outputlength=%d, length=%d...", outputlength, length);
+    if ((outputlength > bufferflush) || ((outputlength+length) > buffersize))
     {
         g_debug("flushing");
-        outputlength=ice_real_write(outputbuffer, outputlength);
+        outputlength = ice_real_write(outputbuffer, outputlength);
     }
     {
-        if (length>buffersize)
+        if (length > buffersize)
         {
             g_debug("data too long, flushing");
             ice_real_write(ptr, length);
@@ -425,7 +433,7 @@
         {
             g_debug("adding");
             memcpy(&(outputbuffer[outputlength]), ptr, length);
-            outputlength+=length;
+            outputlength += length;
         }
     }
     return length;
@@ -441,7 +449,7 @@
         shout_close(shout);
     }
     shout = NULL;
-    ice_tid=0;
+    ice_tid = 0;
     g_debug("ICE_REAL_CLOSE");
     return FALSE;
 }
@@ -449,8 +457,9 @@
 
 static void ice_close(void)
 {
-    if (ice_tid) g_source_remove(ice_tid);
-    ice_tid=g_timeout_add_seconds(3, ice_real_close, NULL);
+    if (ice_tid)
+        g_source_remove(ice_tid);
+    ice_tid = g_timeout_add_seconds(3, ice_real_close, NULL);
     g_debug("ICE_CLOSE: starting timer");
 }
 
@@ -472,12 +481,12 @@
 
 static gint ice_free(void)
 {
-    return paused?0:plugin.free();
+    return paused ? 0 : plugin.free();
 }
 
 static gint ice_playing(void)
 {
-    return plugin.playing() && (!paused);
+    return 0 && !paused;
 }
 
 static gint ice_get_written_time(void)
@@ -512,7 +521,10 @@
     buffersize_new = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(buffersize_spin));
 
     bufferflushperc = gtk_spin_button_get_value(GTK_SPIN_BUTTON(bufferflush_spin));
-    bufferflush_new=(gint)(buffersize*bufferflushperc);
+    bufferflush_new = (gint)(buffersize*bufferflushperc);
+
+    g_free(mountpoint);
+    mountpoint = g_strdup(gtk_entry_get_text(GTK_ENTRY(mount_entry)));
 
     db = aud_cfg_db_open();
     aud_cfg_db_set_int(db, ICECAST_CFGID, "streamformat", streamformat);
@@ -523,6 +535,7 @@
     aud_cfg_db_set_int(db, ICECAST_CFGID, "timeout", ice_close_timeout);
     aud_cfg_db_set_int(db, ICECAST_CFGID, "buffersize", buffersize_new);
     aud_cfg_db_set_double(db, ICECAST_CFGID, "bufferflush", bufferflushperc);
+    aud_cfg_db_set_string(db, ICECAST_CFGID, "mountpoint", mountpoint);
 
     aud_cfg_db_close(db);
 
@@ -533,16 +546,16 @@
 {
     streamformat = gtk_combo_box_get_active(GTK_COMBO_BOX(streamformat_combo));
     set_plugin();
-    if (plugin.init)
-        plugin.init(&ice_write_output);
+    if (plugin_new.init)
+        plugin_new.init(&ice_write_output);
 
-    gtk_widget_set_sensitive(plugin_button, plugin.configure != NULL);
+    gtk_widget_set_sensitive(plugin_button, plugin_new.configure != NULL);
 }
 
 static void plugin_configure_cb(GtkWidget *button, gpointer data)
 {
-    if (plugin.configure)
-        plugin.configure();
+    if (plugin_new.configure)
+        plugin_new.configure();
 }
 
 static void configure_destroy(void)
@@ -556,6 +569,8 @@
         GtkWidget * hbox;
         GtkWidget * label;
 
+        plugin_new = plugin;
+
         configure_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 
         gtk_signal_connect(GTK_OBJECT(configure_win), "destroy",
@@ -591,13 +606,10 @@
         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);
+        gtk_widget_set_sensitive(plugin_button, plugin_new.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);
@@ -625,6 +637,20 @@
         hbox = gtk_hbox_new(FALSE, 5);
         gtk_box_pack_start(GTK_BOX(configure_vbox), hbox, FALSE, FALSE, 0);
 
+        label = gtk_label_new(_("Mount point:"));
+        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+
+        mount_entry = gtk_entry_new();
+
+	gtk_entry_set_text(GTK_ENTRY(mount_entry), mountpoint);
+
+        gtk_box_pack_start(GTK_BOX(hbox), mount_entry, 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(_("User name:"));
         gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);