summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorDave Camp <campd@src.gnome.org>2004-01-06 21:52:39 +0000
committerDave Camp <campd@src.gnome.org>2004-01-06 21:52:39 +0000
commitebee7d61a54cc79965c0133c4e63d6a7a00eb1d2 (patch)
tree35ddcddb0bcf9c1d0ea0e425fc5c0d5a1f494d9e /components
parentbd6e1847ced6fc5f041f5a05c108290a450c8c05 (diff)
downloadnautilus-NAUTILUS_EXTENSIONS_BRANCH_AFTER_MERGE_1.tar.gz
Diffstat (limited to 'components')
-rw-r--r--components/Makefile.am2
-rw-r--r--components/adapter/nautilus-adapter.c13
-rw-r--r--components/emblem/nautilus-emblem-view.c20
-rw-r--r--components/hardware/.cvsignore6
-rw-r--r--components/hardware/Makefile.am40
-rw-r--r--components/hardware/Nautilus_View_hardware.server.in.in27
-rw-r--r--components/hardware/icons/.cvsignore2
-rw-r--r--components/hardware/icons/CD_drive.pngbin11315 -> 0 bytes
-rw-r--r--components/hardware/icons/HD_drive.pngbin9540 -> 0 bytes
-rw-r--r--components/hardware/icons/Makefile.am9
-rw-r--r--components/hardware/icons/cpu.pngbin10656 -> 0 bytes
-rw-r--r--components/hardware/icons/memory_chip.gifbin4336 -> 0 bytes
-rw-r--r--components/hardware/main.c61
-rw-r--r--components/hardware/nautilus-hardware-view.c781
-rw-r--r--components/hardware/nautilus-hardware-view.h62
-rw-r--r--components/image_properties/nautilus-image-properties-view.c2
-rw-r--r--components/music/Makefile.am75
-rw-r--r--components/music/Nautilus_View_music.server.in.in35
-rw-r--r--components/music/common.c662
-rw-r--r--components/music/configure.c736
-rw-r--r--components/music/dct64.c167
-rw-r--r--components/music/dct64_i386.c315
-rw-r--r--components/music/decode.c223
-rw-r--r--components/music/decode_2to1.c247
-rw-r--r--components/music/decode_4to1.c260
-rw-r--r--components/music/decode_i386.c257
-rw-r--r--components/music/decode_ntom.c301
-rw-r--r--components/music/dxhead.c233
-rw-r--r--components/music/dxhead.h76
-rw-r--r--components/music/esd-audio.c444
-rw-r--r--components/music/esd-audio.h50
-rw-r--r--components/music/esd-mixer.c78
-rw-r--r--components/music/fileinfo.c470
-rw-r--r--components/music/getbits.c126
-rw-r--r--components/music/getbits.h46
-rw-r--r--components/music/huffman.h329
-rw-r--r--components/music/id3.c630
-rw-r--r--components/music/id3.h279
-rw-r--r--components/music/id3_frame.c534
-rw-r--r--components/music/id3_frame_content.c125
-rw-r--r--components/music/id3_frame_text.c337
-rw-r--r--components/music/id3_frame_url.c105
-rw-r--r--components/music/id3_header.h118
-rw-r--r--components/music/id3_tag.c131
-rw-r--r--components/music/l2tables.h997
-rw-r--r--components/music/layer1.c191
-rw-r--r--components/music/layer2.c340
-rw-r--r--components/music/layer3.c2104
-rw-r--r--components/music/main.c56
-rw-r--r--components/music/mp3head.c400
-rw-r--r--components/music/mp3head.h51
-rw-r--r--components/music/mpg123.c845
-rw-r--r--components/music/mpg123.h306
-rw-r--r--components/music/nautilus-music-view.c2020
-rw-r--r--components/music/nautilus-music-view.h56
-rw-r--r--components/music/pixmaps.h156
-rw-r--r--components/music/tabinit.c103
-rw-r--r--components/news/nautilus-news.c9
-rw-r--r--components/text/Makefile.am2
-rw-r--r--components/text/services/.cvsignore2
-rw-r--r--components/text/services/Makefile.am10
-rw-r--r--components/text/services/google.xml3
-rw-r--r--components/text/services/webster.xml3
-rw-r--r--components/tree/Makefile.am41
-rw-r--r--components/tree/Nautilus_View_tree.server.in.in15
-rw-r--r--components/tree/libmain.c85
-rw-r--r--components/tree/nautilus-tree-model.c1797
-rw-r--r--components/tree/nautilus-tree-model.h88
-rw-r--r--components/tree/nautilus-tree-view-iids.h32
-rw-r--r--components/tree/nautilus-tree-view.c743
-rw-r--r--components/tree/nautilus-tree-view.h53
71 files changed, 24 insertions, 18898 deletions
diff --git a/components/Makefile.am b/components/Makefile.am
index aa566a394..01670366f 100644
--- a/components/Makefile.am
+++ b/components/Makefile.am
@@ -2,12 +2,10 @@ NULL=
SUBDIRS = \
adapter \
- hardware \
history \
notes \
text \
throbber \
- tree \
emblem \
image_properties \
$(NULL)
diff --git a/components/adapter/nautilus-adapter.c b/components/adapter/nautilus-adapter.c
index 67502ee05..ba17057f2 100644
--- a/components/adapter/nautilus-adapter.c
+++ b/components/adapter/nautilus-adapter.c
@@ -33,10 +33,9 @@
#include "nautilus-adapter-load-strategy.h"
#include <bonobo/bonobo-control.h>
#include <bonobo/bonobo-item-container.h>
-#include <eel/eel-generous-bin.h>
#include <eel/eel-gtk-macros.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
-#include <gtk/gtksignal.h>
+#include <gtk/gtkhbox.h>
#include <libgnome/gnome-i18n.h>
#include <libgnomeui/gnome-stock-icons.h>
#include <libnautilus-adapter/nautilus-adapter-factory.h>
@@ -123,7 +122,7 @@ nautilus_adapter_new (Bonobo_Unknown component)
{
NautilusAdapter *adapter;
BonoboControl *control;
- GtkWidget *bin;
+ GtkWidget *box;
BonoboObject *zoomable;
/* FIXME bugzilla.gnome.org 44405: should be done with
@@ -133,9 +132,9 @@ nautilus_adapter_new (Bonobo_Unknown component)
adapter = NAUTILUS_ADAPTER (g_object_new (NAUTILUS_TYPE_ADAPTER, NULL));
/* Set up a few wrapper framework details */
- bin = gtk_widget_new (EEL_TYPE_GENEROUS_BIN, NULL);
- gtk_widget_show (bin);
- control = bonobo_control_new (bin);
+ box = gtk_hbox_new (FALSE, 0);
+ gtk_widget_show (box);
+ control = bonobo_control_new (box);
adapter->details->nautilus_view = nautilus_view_new_from_bonobo_control (control);
g_object_weak_ref (G_OBJECT (adapter->details->nautilus_view),
@@ -180,7 +179,7 @@ nautilus_adapter_new (Bonobo_Unknown component)
adapter, G_CONNECT_SWAPPED);
/* complete the embedding */
- gtk_container_add (GTK_CONTAINER (bin),
+ gtk_container_add (GTK_CONTAINER (box),
nautilus_adapter_embed_strategy_get_widget (adapter->details->embed_strategy));
/* hook up view signals. */
diff --git a/components/emblem/nautilus-emblem-view.c b/components/emblem/nautilus-emblem-view.c
index a19219214..e572677a7 100644
--- a/components/emblem/nautilus-emblem-view.c
+++ b/components/emblem/nautilus-emblem-view.c
@@ -200,8 +200,9 @@ nautilus_emblem_view_delete_cb (GtkWidget *menu_item,
if (nautilus_emblem_remove_emblem (emblem_view->details->popup_emblem_keyword)) {
nautilus_emblem_view_refresh (emblem_view);
} else {
- error = g_strdup_printf (_("Couldn't remove emblem with name '%s'. This is probably because the emblem is a permanent one, and not one you added yourself."), emblem_view->details->popup_emblem_display_name);
- eel_show_error_dialog (error, _("Couldn't remove emblem"),
+ error = g_strdup_printf (_("Couldn't remove emblem with name '%s'."), emblem_view->details->popup_emblem_display_name);
+ eel_show_error_dialog (error, _("This is probably because the emblem is a permanent one, and not one you added yourself."),
+ _("Couldn't Remove Emblem"),
NULL);
g_free (error);
}
@@ -235,8 +236,9 @@ rename_dialog_response_cb (GtkWidget *dialog, int response,
if (nautilus_emblem_rename_emblem (keyword, name)) {
nautilus_emblem_view_refresh (emblem_view);
} else {
- error = g_strdup_printf (_("Couldn't rename emblem with name '%s'. This is probably because the emblem is a permanent one, and not one that you added yourself."), name);
- eel_show_error_dialog (error, _("Couldn't rename emblem"),
+ error = g_strdup_printf (_("Couldn't rename emblem with name '%s'."), name);
+ eel_show_error_dialog (error, _("This is probably because the emblem is a permanent one, and not one that you added yourself."),
+ _("Couldn't Rename Emblem"),
NULL);
g_free (error);
}
@@ -737,9 +739,9 @@ nautilus_emblem_view_drag_received_cb (GtkWidget *widget,
nautilus_icon_dnd_uri_list_free_strings (uris);
if (had_failure && emblems != NULL) {
- eel_show_error_dialog (_("Some of the files could not be added as emblems because they did not appear to be valid images."), _("Couldn't add emblems"), NULL);
+ eel_show_error_dialog (_("Some of the files could not be added as emblems."), _("The emblems do not appear to be valid images."), _("Couldn't Add Emblems"), NULL);
} else if (had_failure && emblems == NULL) {
- eel_show_error_dialog (_("None of the files could be added as emblems because they did not appear to be valid images."), _("Couldn't add emblems"), NULL);
+ eel_show_error_dialog (_("None of the files could be added as emblems."), _("The emblems do not appear to be valid images."), _("Couldn't Add Emblems"), NULL);
}
@@ -760,7 +762,7 @@ nautilus_emblem_view_drag_received_cb (GtkWidget *widget,
uri = g_strndup (data->data, data->length);
if (!eel_is_valid_uri (uri)) {
- eel_show_error_dialog (_("The dragged text was not a valid file location."), _("Couldn't add emblem"), NULL);
+ eel_show_error_dialog (_("The emblem cannot be added."), _("The dragged text was not a valid file location."), _("Couldn't Add Emblem"), NULL);
break;
}
@@ -785,7 +787,7 @@ nautilus_emblem_view_drag_received_cb (GtkWidget *widget,
} else {
error = g_strdup (_("The dragged file does not appear to be a valid image."));
}
- eel_show_error_dialog (error, _("Couldn't add emblem"),
+ eel_show_error_dialog (_("The emblem cannot be added."), error, _("Couldn't Add Emblem"),
NULL);
g_free (error);
g_free (uri_utf8);
@@ -835,7 +837,7 @@ nautilus_emblem_view_drag_received_cb (GtkWidget *widget,
g_warning ("Tried to load '%s', but failed.\n",
uri);
error = g_strdup_printf (_("The file '%s' does not appear to be a valid image."), uri);
- eel_show_error_dialog (error, _("Couldn't add emblem"),
+ eel_show_error_dialog (_("The emblem cannot be added."), error, _("Couldn't Add Emblem"),
NULL);
g_free (error);
}
diff --git a/components/hardware/.cvsignore b/components/hardware/.cvsignore
deleted file mode 100644
index a62de2b07..000000000
--- a/components/hardware/.cvsignore
+++ /dev/null
@@ -1,6 +0,0 @@
-.deps
-.libs
-Makefile
-Makefile.in
-nautilus-hardware-view
-Nautilus_View_hardware.server
diff --git a/components/hardware/Makefile.am b/components/hardware/Makefile.am
deleted file mode 100644
index 7700dd6d9..000000000
--- a/components/hardware/Makefile.am
+++ /dev/null
@@ -1,40 +0,0 @@
-NULL=
-
-SUBDIRS=icons
-
-INCLUDES = \
- -DG_LOG_DOMAIN=\"Nautilus-Hardware\" \
- -DGNOMELOCALEDIR=\""$(prefix)/${DATADIRNAME}/locale"\" \
- -I$(top_srcdir) \
- $(DISABLE_DEPRECATED_CFLAGS) \
- $(COMPONENT_CFLAGS) \
- $(NULL)
-
-server_in_files = Nautilus_View_hardware.server.in.in
-
-serverdir = $(libdir)/bonobo/servers
-$(server_in_files:.server.in.in=.server.in): $(server_in_files)
- sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" $< > $@
-@INTLTOOL_SERVER_RULE@
-
-if ENABLE_HARDWARE_VIEW
-libexec_PROGRAMS=nautilus-hardware-view
-server_DATA = $(server_in_files:.server.in.in=.server)
-endif
-
-nautilus_hardware_view_SOURCES = \
- nautilus-hardware-view.c \
- nautilus-hardware-view.h \
- main.c
-
-nautilus_hardware_view_LDADD = \
- $(top_builddir)/libnautilus/libnautilus.la \
- $(top_builddir)/libnautilus-private/libnautilus-private.la \
- $(COMPONENT_LIBS) \
- $(NULL)
-
-EXTRA_DIST = $(server_in_files) $(nautilus_hardware_view_SOURCES)
-
-if ENABLE_HARDWARE_VIEW
-CLEANFILES = $(server_DATA) $(server_DATA).in
-endif
diff --git a/components/hardware/Nautilus_View_hardware.server.in.in b/components/hardware/Nautilus_View_hardware.server.in.in
deleted file mode 100644
index db3ad89c3..000000000
--- a/components/hardware/Nautilus_View_hardware.server.in.in
+++ /dev/null
@@ -1,27 +0,0 @@
-<oaf_info>
-
-<oaf_server iid="OAFIID:Nautilus_Hardware_View_Factory"
- type="exe" location="@LIBEXECDIR@/nautilus-hardware-view">
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/ObjectFactory:1.0"/>
- </oaf_attribute>
- <oaf_attribute name="description" type="string" _value="Factory for hardware view"/>
-</oaf_server>
-
-<oaf_server iid="OAFIID:Nautilus_Hardware_View" type="factory" location="OAFIID:Nautilus_Hardware_View_Factory">
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:Bonobo/Unknown:1.0"/>
- <item value="IDL:Bonobo/Control:1.0"/>
- <item value="IDL:Nautilus/View:1.0"/>
- </oaf_attribute>
- <oaf_attribute name="name" type="string" _value="Hardware view"/>
- <oaf_attribute name="description" type="string" _value="hardware view"/>
- <oaf_attribute name="bonobo:supported_uri_schemes" type="stringv">
- <item value="hardware"/>
- </oaf_attribute>
- <oaf_attribute name="nautilus:view_as_name" type="string" _value="Hardware"/>
- <oaf_attribute name="nautilus:view_as_label" type="string" _value="View as Hardware"/>
- <oaf_attribute name="nautilus:viewer_label" type="string" _value="Hardware Viewer"/>
-</oaf_server>
-
-</oaf_info>
diff --git a/components/hardware/icons/.cvsignore b/components/hardware/icons/.cvsignore
deleted file mode 100644
index 282522db0..000000000
--- a/components/hardware/icons/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-Makefile
-Makefile.in
diff --git a/components/hardware/icons/CD_drive.png b/components/hardware/icons/CD_drive.png
deleted file mode 100644
index 459f11256..000000000
--- a/components/hardware/icons/CD_drive.png
+++ /dev/null
Binary files differ
diff --git a/components/hardware/icons/HD_drive.png b/components/hardware/icons/HD_drive.png
deleted file mode 100644
index 9184fa3f6..000000000
--- a/components/hardware/icons/HD_drive.png
+++ /dev/null
Binary files differ
diff --git a/components/hardware/icons/Makefile.am b/components/hardware/icons/Makefile.am
deleted file mode 100644
index 6e48a759a..000000000
--- a/components/hardware/icons/Makefile.am
+++ /dev/null
@@ -1,9 +0,0 @@
-icondir = $(datadir)/pixmaps/nautilus
-
-icon_DATA = \
- cpu.png \
- HD_drive.png \
- CD_drive.png \
- memory_chip.gif
-
-EXTRA_DIST = $(icon_DATA)
diff --git a/components/hardware/icons/cpu.png b/components/hardware/icons/cpu.png
deleted file mode 100644
index aa0c63732..000000000
--- a/components/hardware/icons/cpu.png
+++ /dev/null
Binary files differ
diff --git a/components/hardware/icons/memory_chip.gif b/components/hardware/icons/memory_chip.gif
deleted file mode 100644
index e422d0661..000000000
--- a/components/hardware/icons/memory_chip.gif
+++ /dev/null
Binary files differ
diff --git a/components/hardware/main.c b/components/hardware/main.c
deleted file mode 100644
index 65c45cfd0..000000000
--- a/components/hardware/main.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/*
- * Copyright (C) 2000 Eazel, Inc
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: Andy Hertzfeld
- */
-
-/* main.c - main function and object activation function for the hardware view component. */
-
-#define FACTORY_IID "OAFIID:Nautilus_Hardware_View_Factory"
-#define VIEW_IID "OAFIID:Nautilus_Hardware_View"
-
-#include <config.h>
-
-#include "nautilus-hardware-view.h"
-#include <libnautilus/nautilus-view-standard-main.h>
-#include <libnautilus-private/nautilus-global-preferences.h>
-#include <eel/eel-debug.h>
-
-static BonoboObject *
-cb_create_hardware_view (const char *ignore0, void *ignore1)
-{
- NautilusHardwareView *hardware_view =
- g_object_new (NAUTILUS_TYPE_HARDWARE_VIEW, NULL);
- return nautilus_hardware_view_get_nautilus_view (hardware_view);
-
-}
-int
-main (int argc, char *argv[])
-{
- if (g_getenv ("NAUTILUS_DEBUG") != NULL) {
- eel_make_warnings_and_criticals_stop_in_debugger ();
- }
-
- return nautilus_view_standard_main ("nautilus-hardware-view",
- VERSION,
- GETTEXT_PACKAGE,
- GNOMELOCALEDIR,
- argc,
- argv,
- FACTORY_IID,
- VIEW_IID,
- cb_create_hardware_view,
- nautilus_global_preferences_init,
- NULL);
-}
diff --git a/components/hardware/nautilus-hardware-view.c b/components/hardware/nautilus-hardware-view.c
deleted file mode 100644
index cc821afde..000000000
--- a/components/hardware/nautilus-hardware-view.c
+++ /dev/null
@@ -1,781 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-
-/*
- * Copyright (C) 2000 Eazel, Inc.
- *
- * This library 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 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Author: Andy Hertzfeld <andy@eazel.com>
- * Shane Butler <shane_b@bigfoot.com>
- *
- */
-
-
-/* hardware view - presents various views of the hardware configuration */
-
-#include <config.h>
-#include "nautilus-hardware-view.h"
-
-#include <dirent.h>
-#include <fcntl.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
-#include <gnome.h>
-#include <gtk/gtksignal.h>
-#include <eel/eel-background.h>
-#include <bonobo/bonobo-property-bag.h>
-#include <libnautilus-private/nautilus-directory-background.h>
-#include <libnautilus-private/nautilus-file-utilities.h>
-#include <libnautilus-private/nautilus-file.h>
-#include <eel/eel-glib-extensions.h>
-#include <eel/eel-gtk-extensions.h>
-#include <eel/eel-gtk-macros.h>
-#include <libnautilus-private/nautilus-metadata.h>
-#include <eel/eel-string.h>
-#include <libnautilus/libnautilus.h>
-#include <limits.h>
-#include <locale.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-struct _NautilusHardwareViewDetails {
- NautilusView *nautilus_view;
- BonoboPropertyBag *property_bag;
-
- GtkWidget *form;
-
- GtkLabel *uptime_label;
- int timer_task;
-
- int cpu_count;
- int mem_size;
-};
-
-/* drag and drop properties */
-enum {
- TARGET_COLOR
-};
-
-/* property bag properties */
-enum {
- ICON_NAME,
- COMPONENT_INFO
-};
-
-static GtkTargetEntry hardware_dnd_target_table[] = {
- { "application/x-color", 0, TARGET_COLOR },
-};
-
-static void nautilus_hardware_view_drag_data_received (GtkWidget *widget,
- GdkDragContext *context,
- int x,
- int y,
- GtkSelectionData *selection_data,
- guint info,
- guint time);
-static void nautilus_hardware_view_class_init (NautilusHardwareViewClass *klass);
-static void nautilus_hardware_view_init (NautilusHardwareView *view);
-static void nautilus_hardware_view_finalize (GObject *object);
-static void hardware_view_load_location_callback (NautilusView *view,
- const char *location,
- NautilusHardwareView *hardware_view);
-static char* make_summary_string (NautilusHardwareView *hardware_view);
-static int update_uptime_text (gpointer callback_data);
-
-EEL_CLASS_BOILERPLATE (NautilusHardwareView, nautilus_hardware_view, EEL_TYPE_BACKGROUND_BOX)
-
-static void
-nautilus_hardware_view_class_init (NautilusHardwareViewClass *klass)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- object_class = G_OBJECT_CLASS (klass);
- widget_class = GTK_WIDGET_CLASS (klass);
-
- object_class->finalize = nautilus_hardware_view_finalize;
- widget_class->drag_data_received = nautilus_hardware_view_drag_data_received;
-}
-
-/* property bag property access routines */
-static void
-get_bonobo_properties (BonoboPropertyBag *bag,
- BonoboArg *arg,
- guint arg_id,
- CORBA_Environment *ev,
- gpointer callback_data)
-{
- char *hardware_summary;
-
- switch (arg_id) {
- case ICON_NAME:
- BONOBO_ARG_SET_STRING (arg, "computer");
- break;
-
- case COMPONENT_INFO:
- hardware_summary = make_summary_string ((NautilusHardwareView*) callback_data);
- BONOBO_ARG_SET_STRING (arg, hardware_summary);
- g_free (hardware_summary);
- break;
-
- default:
- g_warning ("Unhandled arg %d", arg_id);
- break;
- }
-}
-
-/* there are no settable properties, so complain if someone tries to set one */
-static void
-set_bonobo_properties (BonoboPropertyBag *bag,
- const BonoboArg *arg,
- guint arg_id,
- CORBA_Environment *ev,
- gpointer callback_data)
-{
- g_warning ("Bad Property set on hardware view: property ID %d", arg_id);
-}
-
-/* initialize ourselves by connecting to the load_location signal and allocating our subviews */
-static void
-nautilus_hardware_view_init (NautilusHardwareView *hardware_view)
-{
- EelBackground *background;
-
- hardware_view->details = g_new0 (NautilusHardwareViewDetails, 1);
-
- hardware_view->details->nautilus_view = nautilus_view_new (GTK_WIDGET (hardware_view));
-
- g_signal_connect_object (hardware_view->details->nautilus_view, "load_location",
- G_CALLBACK (hardware_view_load_location_callback), hardware_view, 0);
-
- background = eel_get_widget_background (GTK_WIDGET (hardware_view));
-
- /* prepare ourselves to receive dropped objects */
- gtk_drag_dest_set (GTK_WIDGET (hardware_view),
- GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP,
- hardware_dnd_target_table, G_N_ELEMENTS (hardware_dnd_target_table), GDK_ACTION_COPY);
-
- /* allocate a property bag to specify the name of the icon for this component */
- hardware_view->details->property_bag = bonobo_property_bag_new (get_bonobo_properties, set_bonobo_properties, hardware_view);
- bonobo_property_bag_add (hardware_view->details->property_bag, "icon_name", ICON_NAME, BONOBO_ARG_STRING, NULL,
- _("name of icon for the hardware view"), 0);
- bonobo_property_bag_add (hardware_view->details->property_bag, "summary_info", COMPONENT_INFO, BONOBO_ARG_STRING, NULL,
- _("summary of hardware info"), 0);
- bonobo_control_set_properties (nautilus_view_get_bonobo_control (hardware_view->details->nautilus_view),
- BONOBO_OBJREF (hardware_view->details->property_bag), NULL);
-
- /* add the timer task to update the uptime */
- hardware_view->details->timer_task = gtk_timeout_add (60000, update_uptime_text, hardware_view);
-
- gtk_widget_show_all (GTK_WIDGET (hardware_view));
-}
-
-static void
-nautilus_hardware_view_finalize (GObject *object)
-{
- NautilusHardwareView *hardware_view;
-
- hardware_view = NAUTILUS_HARDWARE_VIEW (object);
-
- bonobo_object_unref (hardware_view->details->property_bag);
-
- if (hardware_view->details->timer_task != 0) {
- gtk_timeout_remove (hardware_view->details->timer_task);
- }
-
- g_free (hardware_view->details);
-
- EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
-}
-
-/* Component embedding support */
-BonoboObject *
-nautilus_hardware_view_get_nautilus_view (NautilusHardwareView *hardware_view)
-{
- return BONOBO_OBJECT (hardware_view->details->nautilus_view);
-}
-
-static char *
-read_proc_info (const char* proc_filename)
-{
- FILE *thisFile;
- char *result;
- char buffer[256];
- char* path_name;
- GString* string_data = g_string_new("");
-
- path_name = g_strdup_printf ("/proc/%s", proc_filename);
- thisFile = fopen (path_name, "r");
- g_free (path_name);
- while (fgets (buffer, 255, thisFile) != NULL) {
- g_string_append (string_data, buffer);
- }
- fclose (thisFile);
-
- result = string_data->str;
- g_string_free(string_data, FALSE);
-
- return result;
-}
-
-/* utility routine to extract information from a string and add it to an XML node */
-
-static char*
-extract_info (char* data, const char *field_name, int nth)
-{
- int index;
- char **info_array;
- char *field_data = NULL;
-
- /* parse the data into a string array */
- info_array = g_strsplit (data, "\n", 32);
- /* iterate through the data isolating the field */
- for (index = 0; index < 32; index++) {
- if (info_array[index] == NULL) {
- break;
- }
- if (eel_str_has_prefix(info_array[index], field_name)) {
- if (nth > 0) {
- nth--;
- } else {
- field_data = info_array[index] + strlen(field_name);
- field_data = strchr(field_data, ':') + 1;
- field_data = g_strchug(field_data);
- break;
- }
- }
- }
-
- /* add the requested node if the field was found */
- field_data = g_strdup (field_data);
- g_strfreev (info_array);
- return field_data;
-}
-
-/* get descriptive text about the CPU */
-
-static char *
-get_CPU_description (int nth)
-{
- char *proc_data;
- char *model, *speed, *cache_size;
- char *localized_speed;
- char *result;
- char *p;
- struct lconv *l;
-
- proc_data = read_proc_info ("cpuinfo");
- model = extract_info (proc_data, "model name", nth);
- speed = extract_info (proc_data, "cpu MHz", nth);
- cache_size = extract_info (proc_data, "cache size", nth);
- g_free (proc_data);
-
- /* Hack to localize the decimal_point */
- p = speed == NULL ? NULL : strrchr (speed, '.');
- if (p == NULL) {
- localized_speed = g_strdup (speed);
- } else {
- *p = '\0';
- l = localeconv ();
- localized_speed = g_strconcat (speed, l->decimal_point,
- p + 1, NULL);
- }
-
- /* Remove the " KB" part so that it can be localized */
- if (cache_size != NULL) {
- p = strchr (cache_size, ' ');
- if (p != NULL) {
- *p = '\0';
- }
- }
-
- if (model == NULL || speed == NULL || cache_size == NULL) {
- result = NULL;
- } else {
- result = g_strdup_printf (_("%s CPU\n"
- "%s MHz\n"
- "%s K cache size"),
- model, localized_speed, cache_size);
- }
-
- g_free (model);
- g_free (speed);
- g_free (localized_speed);
- g_free (cache_size);
-
- return result;
-}
-
-/* get descriptive information about main memory */
-static char *
-get_RAM_description (void)
-{
- char *temp_str, *result;
- char *proc_data;
- gulong ram_size;
-
- proc_data = read_proc_info ("meminfo");
-
- temp_str = extract_info (proc_data, "MemTotal", 0);
- if (temp_str == NULL || strlen (temp_str) < 3) {
- g_free (temp_str);
- return NULL;
- }
-
- /* strip kbyte suffix */
- temp_str[strlen(temp_str) - 3] = '\0';
-
- ram_size = (strtoul (temp_str, NULL, 10) + 500) / 1000;
- if (ram_size >= 1000) {
- result = g_strdup_printf (_("%lu GB RAM"), ram_size / 1000);
- } else {
- result = g_strdup_printf (_("%lu MB RAM"), ram_size);
- }
-
- g_free (temp_str);
-
- g_free (proc_data);
-
- return result;
-}
-
-static char *
-get_IDE_description (const char *device)
-{
- char *temp_str, *num_str, *result;
- GString *string_data = g_string_new("");
- char *proc_file;
- gulong capacity;
-
- /* Read model information string */
- proc_file = g_strdup_printf ("%s/model", device);
- temp_str = read_proc_info (proc_file);
- temp_str[strlen (temp_str) - 1] = '\0';
- g_string_append (string_data, temp_str);
- g_free (temp_str);
- g_free (proc_file);
-
- /* Read media type */
- proc_file = g_strdup_printf ("%s/media", device);
- temp_str = read_proc_info (proc_file);
- g_free (proc_file);
-
- /* If a hard disk, get the size */
- if (strcmp (temp_str, "disk\n") == 0) {
- g_free (temp_str);
-
- proc_file = g_strdup_printf ("%s/capacity", device);
- temp_str = read_proc_info (proc_file);
- temp_str[strlen (temp_str) - 1] = '\0';
-
- /* NOTE: this should be
- * capacity = strtoul (...)
- * num_str = gnome_vfs_format_file_size_for_display (512 * numsectors);
- *
- * (512 bytes per sector)
- *
- * but with large disks we overflow an unsigned long, which is the
- * the type that gnome_vfs uses (Darin: Not true, gnome-vfs uses 64-bit integers).
- *
- * ALSO, in keeping with disk manufacturer convention, disk sizes
- * are quoted in powers of 10 (i.e., MB is 10^6, GB is 10^9).
- * (see http://www.maxtor.com/technology/Digi_vs_Deci.html
- * So as to not confuse the user too much, we will follow the
- * same convention.)
- *
- */
-
- capacity = (512 * (strtoul (temp_str, NULL, 10) / 1000)) / 1000;
- if (capacity >= 1000) {
- num_str = g_strdup_printf (_("%lu GB"), capacity / 1000);
- } else {
- num_str = g_strdup_printf (_("%lu MB"), capacity);
- }
-
- g_string_append (string_data, "\n");
- g_string_append (string_data, num_str);
- g_free (temp_str);
- g_free (proc_file);
- } else {
- g_free (temp_str);
- }
-
- result = string_data->str;
- g_string_free (string_data, FALSE);
-
- return result;
-}
-
-
-/* shared utility to allocate a title for a form */
-
-static void
-setup_form_title (NautilusHardwareView *view,
- const char *image_name,
- const char *title_text)
-{
- GtkWidget *temp_widget;
- char *file_name;
- GtkWidget *temp_container = gtk_hbox_new(FALSE, 0);
-
- gtk_box_pack_start (GTK_BOX(view->details->form), temp_container, 0, 0, 4);
- gtk_widget_show(temp_container);
-
- if (image_name != NULL) {
- file_name = gnome_program_locate_file (
- NULL, GNOME_FILE_DOMAIN_PIXMAP, image_name, TRUE, NULL);
-
- if (file_name != NULL) {
- temp_widget = gtk_image_new_from_file (file_name);
- gtk_box_pack_start (GTK_BOX(temp_container), temp_widget, 0, 0, 8);
- gtk_widget_show (temp_widget);
- g_free (file_name);
- }
- }
-
- temp_widget = gtk_label_new (title_text);
- eel_gtk_label_set_scale (GTK_LABEL (temp_widget), PANGO_SCALE_XX_LARGE);
-
- gtk_box_pack_start (GTK_BOX (temp_container), temp_widget, 0, 0, 8);
- gtk_widget_show (temp_widget);
-}
-
-/* utility to add an element to the hardware view */
-static void
-add_element_to_table (GtkWidget *table, GtkWidget *element, int element_index)
-{
- int column_pos, row_pos;
-
- column_pos = element_index % 3;
- row_pos = element_index / 3;
-
- gtk_table_attach (GTK_TABLE (table),element,
- column_pos, column_pos + 1, row_pos ,row_pos + 1,
- GTK_FILL, GTK_FILL, 12, 12);
-}
-
-/* uptime the uptime label with the current uptime */
-static int
-update_uptime_text (gpointer callback_data)
-{
- char *uptime_data, *uptime_text;
- double uptime_seconds;
- int uptime_days, uptime_hours, uptime_minutes;
-
- uptime_data = read_proc_info ("uptime");
- uptime_seconds = atof (uptime_data);
-
- uptime_days = uptime_seconds / 86400;
- uptime_hours = (uptime_seconds - (uptime_days * 86400)) / 3600;
- uptime_minutes = (uptime_seconds - (uptime_days * 86400) - (uptime_hours * 3600)) / 60;
-
- uptime_text = g_strdup_printf (_("Uptime is %d days, %d hours, %d minutes"), uptime_days, uptime_hours, uptime_minutes);
- gtk_label_set_text (NAUTILUS_HARDWARE_VIEW (callback_data)->details->uptime_label, uptime_text);
- g_free (uptime_text);
-
- g_free (uptime_data);
- return TRUE;
-}
-
-/* set up the widgetry for the overview page */
-static void
-setup_overview_form (NautilusHardwareView *view)
-{
- char *file_name, *temp_text;
- GtkWidget *temp_widget, *pixmap_widget, *temp_box;
- GtkWidget *table;
- int element_index;
- DIR *directory;
- struct dirent* entry;
- char *device, *proc_file, *ide_media;
-
- /* allocate a vbox as the container */
- view->details->form = gtk_vbox_new(FALSE,0);
- gtk_container_add (GTK_CONTAINER (view), view->details->form);
- gtk_widget_show(view->details->form);
-
- /* set up the title */
- setup_form_title (view, NULL, _("Hardware Overview"));
-
- /* allocate a table to hold the elements */
- table = gtk_table_new (3, 3, FALSE);
- gtk_box_pack_start (GTK_BOX (view->details->form), table, 0, 0, 2);
- gtk_widget_show (GTK_WIDGET(table));
- element_index = 0;
-
- view->details->cpu_count = 0;
- while( (temp_text = get_CPU_description (view->details->cpu_count)) != NULL ) {
- temp_box = gtk_vbox_new(FALSE, 4);
- add_element_to_table (table, temp_box, element_index++);
- gtk_widget_show (temp_box);
-
- file_name = nautilus_pixmap_file ("cpu.png");
- temp_widget = gtk_image_new_from_file (file_name);
- gtk_box_pack_start (GTK_BOX(temp_box), temp_widget, 0, 0, 0);
- gtk_widget_show (temp_widget);
- g_free (file_name);
-
- temp_widget = gtk_label_new (temp_text);
- eel_gtk_label_set_scale (GTK_LABEL (temp_widget), PANGO_SCALE_LARGE);
- gtk_label_set_justify (GTK_LABEL (temp_widget), GTK_JUSTIFY_CENTER);
- g_free(temp_text);
- gtk_box_pack_start(GTK_BOX(temp_box), temp_widget, 0, 0, 0 );
- gtk_widget_show (temp_widget);
-
- view->details->cpu_count++;
- }
-
- /* set up the memory info */
- temp_box = gtk_vbox_new(FALSE, 4);
- add_element_to_table (table, temp_box, element_index++);
- gtk_widget_show (temp_box);
-
- file_name = nautilus_pixmap_file ("memory_chip.gif");
- temp_widget = gtk_image_new_from_file (file_name);
- gtk_box_pack_start(GTK_BOX(temp_box), temp_widget, 0, 0, 0);
- gtk_widget_show(temp_widget);
- g_free (file_name);
-
- temp_text = get_RAM_description ();
- temp_widget = gtk_label_new (temp_text);
- eel_gtk_label_set_scale (GTK_LABEL (temp_widget), PANGO_SCALE_LARGE);
- g_free (temp_text);
- gtk_box_pack_start (GTK_BOX(temp_box), temp_widget, 0, 0, 0 );
- gtk_widget_show (temp_widget);
-
- /* Set up ide devices : by Shane Butler <shane_b@bigfoot.com> */
- /* Open the ide devices directory */
- if((directory = opendir("/proc/ide/")) != NULL) {
- while((entry = readdir(directory)) != NULL) {
- /* Scan though each entry for actual device dirs */
- if(!strncmp(entry->d_name, "hd", 2)) {
- temp_box = gtk_vbox_new(FALSE, 4);
- add_element_to_table (table, temp_box, element_index++);
- gtk_widget_show(temp_box);
-
- device = g_strdup_printf("ide/%s", entry->d_name);
-
- proc_file = g_strdup_printf("%s/media", device);
- ide_media = read_proc_info(proc_file);
- g_free(proc_file);
-
- /* Set the icon depending on the type of device */
- if (strcmp (ide_media, "disk\n") == 0) {
- file_name = nautilus_pixmap_file ("HD_drive.png");
- } else if (strcmp (ide_media, "cdrom\n") == 0) {
- file_name = nautilus_pixmap_file ("CD_drive.png");
- } else {
- /* some other device ... still set an icon */
- file_name = nautilus_pixmap_file ("HD_drive.png");
- }
-
- pixmap_widget = gtk_image_new_from_file (file_name);
- gtk_box_pack_start (GTK_BOX(temp_box), pixmap_widget, 0, 0, 0);
- gtk_widget_show(pixmap_widget);
- g_free(file_name);
- g_free(ide_media);
-
- temp_text = get_IDE_description (device);
- temp_widget = gtk_label_new (temp_text);
- eel_gtk_label_set_scale (GTK_LABEL (temp_widget), PANGO_SCALE_LARGE);
- gtk_label_set_justify (GTK_LABEL (temp_widget), GTK_JUSTIFY_CENTER);
-
- g_free(temp_text);
- gtk_box_pack_start(GTK_BOX(temp_box), temp_widget, 0, 0, 0);
- gtk_widget_show(temp_widget);
-
- g_free(device);
- }
- }
- closedir(directory);
- }
-
- /* allocate the uptime label */
- view->details->uptime_label = GTK_LABEL (gtk_label_new (""));
- eel_gtk_label_set_scale (view->details->uptime_label, PANGO_SCALE_LARGE);
-
- gtk_box_pack_end (GTK_BOX (view->details->form), GTK_WIDGET (view->details->uptime_label), 0, 0, GNOME_PAD);
- update_uptime_text (view);
- gtk_widget_show(GTK_WIDGET (view->details->uptime_label));
-
-}
-
-#ifdef ENABLE_SUBVIEWS
-
-/* set up the widgetry for the CPU page */
-
-static void
-setup_CPU_form (NautilusHardwareView *view)
-{
- char *message;
- GtkWidget *temp_widget;
-
- /* allocate a vbox as the container */
- view->details->form = gtk_vbox_new(FALSE,0);
- gtk_container_add (GTK_CONTAINER (view), view->details->form);
- gtk_widget_show(view->details->form);
-
- /* set up the title */
- setup_form_title (view, NULL, "CPU");
-
- message = _("This is a placeholder for the CPU page.");
- temp_widget = gtk_label_new (message);
- eel_gtk_label_set_scale (GTK_LABEL (temp_widget), PANGO_SCALE_LARGE);
- gtk_label_set_line_wrap (GTK_LABEL (temp_widget), TRUE);
-
- gtk_box_pack_start(GTK_BOX(view->details->form), temp_widget, 0, 0, 12);
- gtk_widget_show (temp_widget);
-}
-
-/* set up the widgetry for the RAM page */
-
-static void
-setup_RAM_form (NautilusHardwareView *view)
-{
- char *message;
- GtkWidget *temp_widget;
-
- /* allocate a vbox as the container */
- view->details->form = gtk_vbox_new(FALSE,0);
- gtk_container_add (GTK_CONTAINER (view), view->details->form);
- gtk_widget_show(view->details->form);
-
- /* set up the title */
- setup_form_title (view, NULL, "RAM");
-
- message = _("This is a placeholder for the RAM page.");
- temp_widget = gtk_label_new (message);
- eel_gtk_label_set_scale (GTK_LABEL (temp_widget), PANGO_SCALE_LARGE);
- gtk_label_set_line_wrap (GTK_LABEL (temp_widget), TRUE);
-
- gtk_box_pack_start(GTK_BOX(view->details->form), temp_widget, 0, 0, 12);
- gtk_widget_show (temp_widget);
-}
-
-/* set up the widgetry for the IDE page */
-
-static void
-setup_IDE_form (NautilusHardwareView *view)
-{
- char *message;
- GtkWidget *temp_widget;
-
- /* allocate a vbox as the container */
- view->details->form = gtk_vbox_new(FALSE,0);
- gtk_container_add (GTK_CONTAINER (view), view->details->form);
- gtk_widget_show(view->details->form);
-
- /* set up the title */
- setup_form_title (view, NULL, "IDE");
-
- message = _("This is a placeholder for the IDE page.");
- temp_widget = gtk_label_new (message);
- eel_gtk_label_set_scale (GTK_LABEL (temp_widget), PANGO_SCALE_LARGE);
- gtk_label_set_line_wrap (GTK_LABEL (temp_widget), TRUE);
-
- gtk_box_pack_start(GTK_BOX(view->details->form), temp_widget, 0, 0, 12);
- gtk_widget_show (temp_widget);
-}
-
-
-/* utility for checking uri */
-static gboolean
-is_location (const char *document_str, const char *place_str)
-{
- return document_str && strncmp(document_str + 1, place_str, strlen (place_str)) == 0;
-}
-
-#endif /* ENABLE_SUBVIEWS */
-
-/* load the uri by casing out on the path */
-
-void
-nautilus_hardware_view_load_uri (NautilusHardwareView *view, const char *uri)
-{
-#ifdef ENABLE_SUBVIEWS
- const char *document_name;
-#endif
-
- /* dispose of any old form that was installed */
- if (view->details->form != NULL) {
- gtk_widget_destroy (view->details->form);
- view->details->form = NULL;
- }
-
-#ifndef ENABLE_SUBVIEWS
- setup_overview_form (view);
-#else
- /* extract the document part of the uri */
- document_name = strchr (uri, ':');
-
- /* load the appropriate form, based on the uri and the registration state */
- if (is_location (document_name, "overview")) {
- setup_overview_form (view);
- } else if (is_location (document_name, "CPU")) {
- setup_CPU_form (view);
- } else if (is_location (document_name, "RAM")) {
- setup_RAM_form (view);
- } else if (is_location (document_name, "IDE")) {
- setup_IDE_form (view);
- } else {
- setup_overview_form (view); /* if we don't understand it, go to the overview */
- }
-#endif
-}
-
-/* Create a string summarizing the most important hardware attributes */
-static char *
-make_summary_string (NautilusHardwareView *hardware_view)
-{
- if (hardware_view->details->cpu_count == 1) {
- return g_strdup ("1 CPU");
- } else {
- return g_strdup_printf ("%d CPUs", hardware_view->details->cpu_count);
- }
-}
-
-static void
-hardware_view_load_location_callback (NautilusView *view,
- const char *location,
- NautilusHardwareView *hardware_view)
-{
- nautilus_view_report_load_underway (hardware_view->details->nautilus_view);
- nautilus_view_set_title (hardware_view->details->nautilus_view, _("Hardware"));
- nautilus_hardware_view_load_uri (hardware_view, location);
- nautilus_view_report_load_complete (hardware_view->details->nautilus_view);
-}
-
-/* handle drag and drop */
-
-static void
-nautilus_hardware_view_drag_data_received (GtkWidget *widget, GdkDragContext *context,
- int x, int y,
- GtkSelectionData *selection_data, guint info, guint time)
-{
- g_return_if_fail (NAUTILUS_IS_HARDWARE_VIEW (widget));
-
- switch (info) {
- case TARGET_COLOR:
- /* Let the background change based on the dropped color. */
- eel_background_receive_dropped_color (eel_get_widget_background (widget),
- widget,
- GDK_ACTION_COPY,
- x, y, selection_data);
- break;
-
- default:
- g_warning ("unknown drop type");
- break;
- }
-}
diff --git a/components/hardware/nautilus-hardware-view.h b/components/hardware/nautilus-hardware-view.h
deleted file mode 100644
index 57cf3a79e..000000000
--- a/components/hardware/nautilus-hardware-view.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/*
- * Copyright (C) 2000 Eazel, Inc
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: Andy Hertzfeld
- */
-
-/* header file for the hardware view component */
-
-#ifndef NAUTILUS_HARDWARE_VIEW_H
-#define NAUTILUS_HARDWARE_VIEW_H
-
-#include <libnautilus/nautilus-view.h>
-#include <eel/eel-background-box.h>
-
-
-typedef struct _NautilusHardwareView NautilusHardwareView;
-typedef struct _NautilusHardwareViewClass NautilusHardwareViewClass;
-
-#define NAUTILUS_TYPE_HARDWARE_VIEW (nautilus_hardware_view_get_type ())
-#define NAUTILUS_HARDWARE_VIEW(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_HARDWARE_VIEW, NautilusHardwareView))
-#define NAUTILUS_HARDWARE_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_HARDWARE_VIEW, NautilusHardwareViewClass))
-#define NAUTILUS_IS_HARDWARE_VIEW(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_HARDWARE_VIEW))
-#define NAUTILUS_IS_HARDWARE_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_HARDWARE_VIEW))
-
-typedef struct _NautilusHardwareViewDetails NautilusHardwareViewDetails;
-
-struct _NautilusHardwareView {
- EelBackgroundBox parent;
- NautilusHardwareViewDetails *details;
-};
-
-struct _NautilusHardwareViewClass {
- EelBackgroundBoxClass parent_class;
-};
-
-/* GObject support */
-GType nautilus_hardware_view_get_type (void);
-
-/* Component embedding support */
-BonoboObject *nautilus_hardware_view_get_nautilus_view (NautilusHardwareView *view);
-
-/* URI handling */
-void nautilus_hardware_view_load_uri (NautilusHardwareView *view,
- const char *uri);
-
-#endif /* NAUTILUS_HARDWARE_VIEW_H */
diff --git a/components/image_properties/nautilus-image-properties-view.c b/components/image_properties/nautilus-image-properties-view.c
index a940e9f2a..fe7b3e624 100644
--- a/components/image_properties/nautilus-image-properties-view.c
+++ b/components/image_properties/nautilus-image-properties-view.c
@@ -197,7 +197,7 @@ append_exifdata_string (ExifData *exifdata, GString *string)
append_tag_value_pair (string, exifdata, EXIF_TAG_APERTURE_VALUE, _("Aperture Value"));
append_tag_value_pair (string, exifdata, EXIF_TAG_METERING_MODE, _("Metering Mode"));
append_tag_value_pair (string, exifdata, EXIF_TAG_FLASH,_("Flash Fired"));
- append_tag_value_pair (string, exifdata, EXIF_TAG_FOCAL_LENGTH,_("Focal Lenght"));
+ append_tag_value_pair (string, exifdata, EXIF_TAG_FOCAL_LENGTH,_("Focal Length"));
append_tag_value_pair (string, exifdata, EXIF_TAG_SHUTTER_SPEED_VALUE, _("Shutter Speed"));
append_tag_value_pair (string, exifdata, EXIF_TAG_ISO_SPEED_RATINGS, _("ISO Speed Rating"));
append_tag_value_pair (string, exifdata, EXIF_TAG_SOFTWARE, _("Software"));
diff --git a/components/music/Makefile.am b/components/music/Makefile.am
deleted file mode 100644
index e4c0f9ab6..000000000
--- a/components/music/Makefile.am
+++ /dev/null
@@ -1,75 +0,0 @@
-NULL =
-
-if X86_OPTIMIZED
-optimized_source = dct64_i386.c decode_i386.c
-else
-optimized_source = dct64.c decode.c
-endif
-
-platform_source = decode.c dct64.c decode_i386.c dct64_i386.c
-
-INCLUDES = \
- -DG_LOG_DOMAIN=\"Nautilus-Music\" \
- -I$(top_srcdir) \
- -DGNOMELOCALEDIR=\""$(prefix)/${DATADIRNAME}/locale"\" \
- $(DISABLE_DEPRECATED_CFLAGS) \
- $(MUSIC_COMPONENT_CFLAGS) \
- $(NULL)
-
-libexec_PROGRAMS=nautilus-music-view
-
-nautilus_music_view_SOURCES = \
- common.c \
- decode_2to1.c \
- decode_4to1.c \
- decode_ntom.c \
- dxhead.c \
- dxhead.h \
- esd-audio.c \
- esd-audio.h \
- esd-mixer.c \
- getbits.h \
- huffman.h \
- id3.c \
- id3.h \
- id3_frame.c \
- id3_frame_content.c \
- id3_frame_text.c \
- id3_frame_url.c \
- id3_header.h \
- id3_tag.c \
- l2tables.h \
- layer1.c \
- layer2.c \
- layer3.c \
- main.c \
- mp3head.c \
- mp3head.h \
- mpg123.c \
- mpg123.h \
- nautilus-music-view.c \
- nautilus-music-view.h \
- pixmaps.h \
- tabinit.c \
- $(optimized_source)
-
-nautilus_music_view_LDADD = \
- $(top_builddir)/libnautilus/libnautilus.la \
- $(top_builddir)/libnautilus-private/libnautilus-private.la \
- $(MUSIC_COMPONENT_LIBS) \
- $(NULL)
-
-server_in_files = Nautilus_View_music.server.in.in
-
-serverdir = $(libdir)/bonobo/servers
-server_DATA = $(server_in_files:.server.in.in=.server)
-$(server_in_files:.server.in.in=.server.in): $(server_in_files)
- sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" $< > $@
-@INTLTOOL_SERVER_RULE@
-
-EXTRA_DIST=$(server_in_files) $(platform_source) \
- configure.c \
- fileinfo.c \
- getbits.c \
- $(NULL)
-CLEANFILES = $(server_DATA) $(server_DATA).in
diff --git a/components/music/Nautilus_View_music.server.in.in b/components/music/Nautilus_View_music.server.in.in
deleted file mode 100644
index 9a5152cc0..000000000
--- a/components/music/Nautilus_View_music.server.in.in
+++ /dev/null
@@ -1,35 +0,0 @@
-<oaf_info>
-
-<oaf_server iid="OAFIID:Nautilus_Music_View_Factory"
- type="exe" location="@LIBEXECDIR@/nautilus-music-view">
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/ObjectFactory:1.0"/>
- </oaf_attribute>
- <oaf_attribute name="name" type="string" _value="Music view factory"/>
- <oaf_attribute name="description" type="string" _value="Factory for music view"/>
-</oaf_server>
-
-<oaf_server iid="OAFIID:Nautilus_Music_View" type="factory" location="OAFIID:Nautilus_Music_View_Factory">
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:Bonobo/Unknown:1.0"/>
- <item value="IDL:Bonobo/Control:1.0"/>
- <item value="IDL:Nautilus/View:1.0"/>
- </oaf_attribute>
- <oaf_attribute name="name" type="string" _value="Music view"/>
- <oaf_attribute name="description" type="string" _value="Music view"/>
- <oaf_attribute name="bonobo:supported_mime_types" type="stringv">
- <item value="x-directory/*"/>
- </oaf_attribute>
- <oaf_attribute name="bonobo:supported_uri_schemes" type="stringv">
- <item value="file"/>
- </oaf_attribute>
- <oaf_attribute name="nautilus:required_directory_content_mime_types" type="stringv">
- <item value="audio/x-mpeg"/>
- <item value="audio/x-mp3"/>
- </oaf_attribute>
- <oaf_attribute name="nautilus:view_as_name" type="string" _value="Music"/>
- <oaf_attribute name="nautilus:view_as_label" type="string" _value="View as Music"/>
- <oaf_attribute name="nautilus:viewer_label" type="string" _value="Music Viewer"/>
-</oaf_server>
-
-</oaf_info>
diff --git a/components/music/common.c b/components/music/common.c
deleted file mode 100644
index 46a6ee636..000000000
--- a/components/music/common.c
+++ /dev/null
@@ -1,662 +0,0 @@
-#include "config.h"
-
-#include <stdlib.h>
-#include <signal.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-/* #ifdef HAVE_MMAP */
-#if 0
-#include <sys/mman.h>
-#ifndef MAP_FAILED
-#define MAP_FAILED ( (void *) -1 )
-#endif
-#endif
-
-#include "mpg123.h"
-#include "id3.h"
-#include "id3_header.h"
-
-#include <glib/gmem.h>
-
-/* max = 1728 */
-#define MAXFRAMESIZE 1792
-
-int tabsel_123[2][3][16] =
-{
- {
- {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448,},
- {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384,},
- {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320,}},
-
- {
- {0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256,},
- {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,},
- {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,}}
-};
-
-long mpg123_freqs[9] =
-{44100, 48000, 32000, 22050, 24000, 16000, 11025, 12000, 8000};
-
-struct bitstream_info bsi;
-
-extern gint mpg123_bitrate, mpg123_frequency, mpg123_length;
-extern gchar *mpg123_title, *mpg123_filename;
-extern gboolean mpg123_stereo;
-
-static int fsizeold = 0, ssize;
-static unsigned char bsspace[2][MAXFRAMESIZE + 512]; /* MAXFRAMESIZE */
-static unsigned char *bsbuf = bsspace[1], *bsbufold;
-static int bsnum = 0;
-
-unsigned char *mpg123_pcm_sample;
-int mpg123_pcm_point = 0;
-
-static FILE *filept;
-
-static int get_fileinfo(void);
-
-static int fullread(FILE * fd, unsigned char *buf, int count)
-{
- int ret, cnt = 0;
-
- while (cnt < count)
- {
- ret = fread(buf + cnt, 1, count - cnt, fd);
- if (ret < 0)
- return ret;
- if (ret == 0)
- break;
- cnt += ret;
- }
- return cnt;
-}
-
-#define HDRCMPMASK 0xfffffd00
-
-/* #ifdef HAVE_MMAP */
-#if 0
-
-static unsigned char *mapbuf;
-static unsigned char *mappnt;
-static unsigned char *mapend;
-
-static int stream_init(void)
-{
- long len;
-
- len = get_fileinfo();
- if (len < 0)
- return -1;
-
- mappnt = mapbuf = mmap(NULL, len, PROT_READ, MAP_SHARED, filept, 0);
- if (!mapbuf || mapbuf == MAP_FAILED)
- return -1;
-
- mapend = mapbuf + len;
-
- return 0;
-}
-
-static void stream_rewind(void)
-{
- mappnt = mapbuf;
-}
-
-void mpg123_stream_close (void)
-{
- if (filept) {
- munmap(mapbuf, mapend - mapbuf);
- close (filept);
- filept = 0;
- }
-}
-
-static int stream_head_read(unsigned long *newhead)
-{
- unsigned long nh;
-
- if (filept) {
- if (mappnt + 4 > mapend)
- return FALSE;
-
- nh = (*mappnt++) << 24;
- nh |= (*mappnt++) << 16;
- nh |= (*mappnt++) << 8;
- nh |= (*mappnt++);
-
- *newhead = nh;
-
- }
- else
- {
- unsigned char hbuf[4];
-
- if (fullread(filept, hbuf, 4) != 4)
- return FALSE;
-
- *newhead = ((unsigned long) hbuf[0] << 24) |
- ((unsigned long) hbuf[1] << 16) |
- ((unsigned long) hbuf[2] << 8) |
- (unsigned long) hbuf[3];
- }
- return TRUE;
-
-}
-
-static int stream_head_shift(unsigned long *head)
-{
-
- if (filept) {
- if (mappnt + 1 > mapend)
- return FALSE;
- *head <<= 8;
- *head |= *mappnt++;
- *head &= 0xffffffff;
- }
- else
- {
- unsigned char hbuf;
-
- if (fullread(filept, &hbuf, 1) != 1)
- return 0;
- *head <<= 8;
- *head |= hbuf;
- *head &= 0xffffffff;
- }
- return TRUE;
-}
-
-static int stream_mpg123_read_frame_body(unsigned char *buf,
- int size)
-{
- if (filept) {
-#if 1
- if (mappnt + size > mapend)
- return FALSE;
-#else
- long l;
-
- if (size > (mapend - mappnt))
- {
- l = mapend - mappnt;
- memcpy(buf, mappnt, l);
- memset(buf + l, 0, size - l);
- }
- else
-#endif
- memcpy(buf, mappnt, size);
-
- mappnt += size;
- }
- else
- {
- long l;
-
- if ((l = fullread(filept, buf, size)) != size)
- {
- if (l <= 0)
- return 0;
- memset(buf + l, 0, size - l);
- }
- }
-
- return TRUE;
-}
-
-static int stream_back_bytes(int bytes)
-{
- if ((mappnt - bytes) < mapbuf || (mappnt - bytes + 4) > mapend)
- return -1;
- mappnt -= bytes;
- return 0;
-}
-
-void mpg123_stream_jump_to_frame(struct frame *fr, int frame)
-{
- if (mapbuf + frame * (fr->framesize + 4) < mapend)
- {
- mpg123__init();
- stream_rewind();
- mpg123_read_frame(fr);
- mappnt = mapbuf + frame * (fr->framesize + 4);
-
- mpg123_read_frame(fr);
- }
-}
-
-void mpg123_stream_jump_to_byte(struct frame *fr, int byte)
-{
- if (mapbuf + byte < mapend)
- {
- mappnt = mapbuf + byte;
- mpg123_read_frame(fr);
- }
-}
-
-int mpg123_stream_check_for_xing_header(struct frame *fr, XHEADDATA * xhead)
-{
- unsigned char *head_data;
- int ret = 0;
-
- stream_back_bytes(fr->framesize + 4);
-
- if (mappnt + (fr->framesize + 4) < mapend)
- {
- ret = mpg123_get_xing_header(xhead, mappnt);
- mappnt += fr->framesize + 4;
- }
- return ret;
-}
-
-#else
-
-static int stream_init(void)
-{
- if (get_fileinfo() < 0)
- return -1;
- return 0;
-}
-
-void mpg123_stream_close(void)
-{
- if (filept) {
- fclose (filept);
- filept = 0;
- }
-}
-
-/****************************************
- * HACK,HACK,HACK: step back <num> frames
- * can only work if the 'stream' isn't a real stream but a file
- */
-
-static int stream_head_read(unsigned long *newhead)
-{
- unsigned char hbuf[4];
-
- if (fullread(filept, hbuf, 4) != 4)
- return FALSE;
-
- *newhead = ((unsigned long) hbuf[0] << 24) |
- ((unsigned long) hbuf[1] << 16) |
- ((unsigned long) hbuf[2] << 8) |
- (unsigned long) hbuf[3];
-
- return TRUE;
-}
-
-static int stream_head_shift(unsigned long *head)
-{
- unsigned char hbuf;
-
- if (fullread(filept, &hbuf, 1) != 1)
- return 0;
- *head <<= 8;
- *head |= hbuf;
- *head &= 0xffffffff;
- return 1;
-}
-
-static int stream_mpg123_read_frame_body(unsigned char *buf,
- int size)
-{
- long l;
-
- if ((l = fullread(filept, buf, size)) != size)
- {
- if (l <= 0)
- return 0;
- memset(buf + l, 0, size - l);
- }
- return 1;
-}
-
-void mpg123_stream_jump_to_frame(struct frame *fr, int frame)
-{
- mpg123_read_frame_init();
- fseek(filept, frame * (fr->framesize + 4), SEEK_SET);
- mpg123_read_frame(fr);
-}
-
-void mpg123_stream_jump_to_byte(struct frame *fr, int byte)
-{
- fseek(filept, byte, SEEK_SET);
- mpg123_read_frame(fr);
-}
-
-int mpg123_stream_check_for_xing_header(struct frame *fr, XHEADDATA * xhead)
-{
- unsigned char *head_data;
- int ret;
-
- fseek(filept, -(fr->framesize + 4), SEEK_CUR);
- head_data = malloc(fr->framesize + 4);
- fread(head_data, 1, fr->framesize + 4, filept);
- ret = mpg123_get_xing_header(xhead, head_data);
- free(head_data);
- return ret;
-}
-
-#endif
-
-static int get_fileinfo(void)
-{
- guchar buf[3];
-
- if (filept == NULL)
- return -1;
- if (fseek(filept, 0, SEEK_END) < 0)
- return -1;
-
- mpg123_info->filesize = ftell(filept);
- if (fseek(filept, -128, SEEK_END) < 0)
- return -1;
- if (fullread(filept, buf, 3) != 3)
- return -1;
- if (!strncmp(buf, "TAG", 3))
- mpg123_info->filesize -=128;
- if (fseek(filept, 0, SEEK_SET) < 0)
- return -1;
-
- if (mpg123_info->filesize <= 0)
- return -1;
-
- return mpg123_info->filesize;
-}
-
-void mpg123_read_frame_init(void)
-{
- memset(bsspace[0],0,MAXFRAMESIZE + 512);
- memset(bsspace[1],0,MAXFRAMESIZE + 512);
- mpg123_info->output_audio = FALSE;
-}
-
-/*
- * Function read_id3v2_tag (head)
- *
- * Read ID3v2 tag from stream. Return TRUE upon success, or FALSE if
- * an error occurred.
- *
- */
-static gboolean read_id3v2_tag(unsigned long head)
-{
- struct
- {
- char id3[3];
- struct id3_taghdr_t tag;
- } id3header;
- gchar *id3buf, *songname;
- int hdrsize;
- id3_t *id3d;
- struct id3tag_t tag;
- /*
- * Read ID3tag header.
- */
- *(unsigned long *) &id3header = g_htonl(head);
- if (fullread(filept, ((char *) &id3header) + sizeof (head),
- sizeof (id3header) - sizeof (head))
- != sizeof (id3header) - sizeof (head))
- return FALSE;
-
- hdrsize = ID3_GET_SIZE28(g_ntohl(id3header.tag.th_size));
-
- /*
- * A invalid header could fool us into requesting insane
- * amounts of memory. Make sure the header size is
- * reasonable.
- */
- if ((mpg123_info->filesize && hdrsize > (int)mpg123_info->filesize) ||
- (!mpg123_info->filesize && hdrsize > 1000000))
- return FALSE;
-
- if (mpg123_cfg.disable_id3v2)
- {
- guint8 *tmp = g_malloc(hdrsize);
- gboolean ret;
- ret = (fullread(filept, tmp, hdrsize) == hdrsize);
- g_free(tmp);
- return ret;
- }
-
- id3buf = g_malloc(hdrsize + sizeof (id3header));
- memcpy(id3buf, &id3header, sizeof (id3header));
-
- /*
- * Read ID3tag body.
- */
- if (fullread(filept, id3buf + sizeof (id3header),
- hdrsize) != hdrsize)
- {
- g_free(id3buf);
- return FALSE;
- }
-
- /*
- * Get info from tag.
- */
- id3d = id3_open_mem(id3buf, 0);
- mpg123_get_id3v2(id3d, &tag);
- if(!mpg123_info->first_frame)
- {
- songname = mpg123_title;
- mpg123_title = mpg123_format_song_title(&tag, mpg123_filename);
- //mpg123_ip.set_info(mpg123_title, mpg123_length,
- // mpg123_bitrate * 1000,
- // mpg123_frequency, mpg123_stereo);
- if(songname)
- g_free(songname);
- }
- else
- {
-
- mpg123_title = mpg123_format_song_title(&tag, mpg123_filename);
- }
- id3_close(id3d);
- g_free(id3buf);
-
- return TRUE;
-}
-
-int mpg123_head_check(unsigned long head)
-{
- if ((head & 0xffe00000) != 0xffe00000)
- return FALSE;
- if (!((head >> 17) & 3))
- return FALSE;
- if (((head >> 12) & 0xf) == 0xf)
- return FALSE;
- if (!((head >> 12) & 0xf))
- return FALSE;
- if (((head >> 10) & 0x3) == 0x3)
- return FALSE;
- if (((head >> 19) & 1) == 1 && ((head >> 17) & 3) == 3 && ((head >> 16) & 1) == 1)
- return FALSE;
- if ((head & 0xffff0000) == 0xfffe0000)
- return FALSE;
-
- return TRUE;
-}
-
-/*****************************************************************
- * read next frame
- */
-int mpg123_read_frame(struct frame *fr)
-{
- unsigned long newhead;
-
- fsizeold = fr->framesize; /* for Layer3 */
-
- if (!stream_head_read(&newhead))
- return FALSE;
-
- if (!mpg123_head_check(newhead) || !mpg123_decode_header(fr, newhead))
- {
- int try = 0;
-
- do
- {
- try++;
- if ((newhead & 0xffffff00) == ('I' << 24) + ('D' << 16) + ('3' << 8))
- {
- read_id3v2_tag(newhead);
- if (!stream_head_read(&newhead))
- return FALSE;
- }
- else if (!stream_head_shift(&newhead))
- return 0;
-
- }
- while ((!mpg123_head_check(newhead) ||
- !mpg123_decode_header(fr,newhead)) &&
- try < (256 * 1024));
- if(try >= (256 * 1024))
- return FALSE;
-
- mpg123_info->filesize -= try;
- }
- /* flip/init buffer for Layer 3 */
- bsbufold = bsbuf;
- bsbuf = bsspace[bsnum] + 512;
- bsnum = (bsnum + 1) & 1;
-
- if (!stream_mpg123_read_frame_body(bsbuf, fr->framesize))
- return 0;
-
- bsi.bitindex = 0;
- bsi.wordpointer = (unsigned char *) bsbuf;
-
-
- return 1;
-
-}
-
-/*
- * the code a header and write the information
- * into the frame structure
- */
-int mpg123_decode_header(struct frame *fr, unsigned long newhead)
-{
- if (newhead & (1 << 20))
- {
- fr->lsf = (newhead & (1 << 19)) ? 0x0 : 0x1;
- fr->mpeg25 = 0;
- }
- else
- {
- fr->lsf = 1;
- fr->mpeg25 = 1;
- }
- fr->lay = 4 - ((newhead >> 17) & 3);
- if (fr->mpeg25)
- {
- fr->sampling_frequency = 6 + ((newhead >> 10) & 0x3);
- }
- else
- fr->sampling_frequency = ((newhead >> 10) & 0x3) + (fr->lsf * 3);
- fr->error_protection = ((newhead >> 16) & 0x1) ^ 0x1;
-
- if (fr->mpeg25) /* allow Bitrate change for 2.5 ... */
- fr->bitrate_index = ((newhead >> 12) & 0xf);
-
- fr->bitrate_index = ((newhead >> 12) & 0xf);
- fr->padding = ((newhead >> 9) & 0x1);
- fr->extension = ((newhead >> 8) & 0x1);
- fr->mode = ((newhead >> 6) & 0x3);
- fr->mode_ext = ((newhead >> 4) & 0x3);
- fr->copyright = ((newhead >> 3) & 0x1);
- fr->original = ((newhead >> 2) & 0x1);
- fr->emphasis = newhead & 0x3;
-
- fr->stereo = (fr->mode == MPG_MD_MONO) ? 1 : 2;
-
- ssize = 0;
-
- if (!fr->bitrate_index)
- return (0);
-
- switch (fr->lay)
- {
- case 1:
- fr->do_layer = mpg123_do_layer1;
- mpg123_init_layer2(); /* inits also shared tables with layer1 */
- fr->framesize = (long) tabsel_123[fr->lsf][0][fr->bitrate_index] * 12000;
- fr->framesize /= mpg123_freqs[fr->sampling_frequency];
- fr->framesize = ((fr->framesize + fr->padding) << 2) - 4;
- break;
- case 2:
- fr->do_layer = mpg123_do_layer2;
- mpg123_init_layer2(); /* inits also shared tables with layer1 */
- fr->framesize = (long) tabsel_123[fr->lsf][1][fr->bitrate_index] * 144000;
- fr->framesize /= mpg123_freqs[fr->sampling_frequency];
- fr->framesize += fr->padding - 4;
- break;
- case 3:
- fr->do_layer = mpg123_do_layer3;
- if (fr->lsf)
- ssize = (fr->stereo == 1) ? 9 : 17;
- else
- ssize = (fr->stereo == 1) ? 17 : 32;
- if (fr->error_protection)
- ssize += 2;
- fr->framesize = (long) tabsel_123[fr->lsf][2][fr->bitrate_index] * 144000;
- fr->framesize /= mpg123_freqs[fr->sampling_frequency] << (fr->lsf);
- fr->framesize = fr->framesize + fr->padding - 4;
- break;
- default:
- return (0);
- }
- if(fr->framesize > MAXFRAMESIZE)
- return 0;
- return 1;
-}
-
-void mpg123_open_stream(char *bs_filenam, int fd)
-{
- if ((filept = fopen(bs_filenam, "rb")) != NULL) {
- if (stream_init() == -1) {
- mpg123_info->eof = 1;
- }
- } else {
- mpg123_info->eof = 1;
- }
-}
-
-void mpg123_set_pointer(long backstep)
-{
- bsi.wordpointer = bsbuf + ssize - backstep;
- if (backstep)
- memcpy(bsi.wordpointer, bsbufold + fsizeold - backstep, backstep);
- bsi.bitindex = 0;
-}
-
-double mpg123_compute_bpf(struct frame *fr)
-{
- double bpf;
-
- switch (fr->lay)
- {
- case 1:
- bpf = tabsel_123[fr->lsf][0][fr->bitrate_index];
- bpf *= 12000.0 * 4.0;
- bpf /= mpg123_freqs[fr->sampling_frequency] << (fr->lsf);
- break;
- case 2:
- case 3:
- bpf = tabsel_123[fr->lsf][fr->lay - 1][fr->bitrate_index];
- bpf *= 144000;
- bpf /= mpg123_freqs[fr->sampling_frequency] << (fr->lsf);
- break;
- default:
- bpf = 1.0;
- }
-
- return bpf;
-}
-
-int mpg123_calc_numframes(struct frame *fr)
-{
- return (int) (mpg123_info->filesize / mpg123_compute_bpf(fr));
-}
diff --git a/components/music/configure.c b/components/music/configure.c
deleted file mode 100644
index 3569e3a59..000000000
--- a/components/music/configure.c
+++ /dev/null
@@ -1,736 +0,0 @@
-#include "mpg123.h"
-
-static GtkWidget *mpg123_configurewin = NULL;
-static GtkWidget *vbox, *notebook;
-static GtkWidget *decode_vbox, *decode_hbox1;
-static GtkWidget *decode_res_frame, *decode_res_vbox, *decode_res_16, *decode_res_8;
-static GtkWidget *decode_ch_frame, *decode_ch_vbox, *decode_ch_stereo,
- *decode_ch_mono;
-static GtkWidget *decode_freq_frame, *decode_freq_vbox, *decode_freq_1to1,
- *decode_freq_1to2, *decode_freq_1to4;
-static GtkWidget *option_frame, *option_vbox, *detect_by_content;
-#ifdef USE_3DNOW
-static GtkWidget *decoder_frame, *decoder_vbox, *auto_select,
- *decoder_3dnow, *decoder_fpu;
-#endif
-
-/* unused
- static GtkWidget *decode_freq_custom,*decode_freq_custom_hbox,*decode_freq_custom_spin,*decode_freq_custom_label;
- static GtkObject *decode_freq_custom_adj;
- */
-static GtkObject *streaming_size_adj, *streaming_pre_adj;
-static GtkWidget *streaming_proxy_use, *streaming_proxy_host_entry;
-static GtkWidget *streaming_proxy_port_entry, *streaming_save_use, *streaming_save_entry;
-static GtkWidget *streaming_proxy_auth_use;
-static GtkWidget *streaming_proxy_auth_pass_entry, *streaming_proxy_auth_user_entry;
-static GtkWidget *streaming_proxy_auth_user_label, *streaming_proxy_auth_pass_label;
-static GtkWidget *streaming_cast_title, *streaming_udp_title;
-static GtkWidget *streaming_proxy_hbox, *streaming_proxy_auth_hbox, *streaming_save_dirbrowser;
-static GtkWidget *streaming_save_hbox, *title_id3_box, *title_id3_desc_box;
-static GtkWidget *title_id3_use, *title_id3_entry, *title_id3v2_disable;
-
-MPG123Config mpg123_cfg;
-
-static void mpg123_configurewin_ok(GtkWidget * widget, gpointer data)
-{
- ConfigFile *cfg;
- gchar *filename;
-
- if (GTK_TOGGLE_BUTTON(decode_res_16)->active)
- mpg123_cfg.resolution = 16;
- else if (GTK_TOGGLE_BUTTON(decode_res_8)->active)
- mpg123_cfg.resolution = 8;
-
- if (GTK_TOGGLE_BUTTON(decode_ch_stereo)->active)
- mpg123_cfg.channels = 2;
- else if (GTK_TOGGLE_BUTTON(decode_ch_mono)->active)
- mpg123_cfg.channels = 1;
-
- if (GTK_TOGGLE_BUTTON(decode_freq_1to1)->active)
- mpg123_cfg.downsample = 0;
- else if (GTK_TOGGLE_BUTTON(decode_freq_1to2)->active)
- mpg123_cfg.downsample = 1;
- if (GTK_TOGGLE_BUTTON(decode_freq_1to4)->active)
- mpg123_cfg.downsample = 2;
- mpg123_cfg.detect_by_content = GTK_TOGGLE_BUTTON(detect_by_content)->active;
-/*
- if(GTK_TOGGLE_BUTTON(decode_freq_custom)->active)
- mpg123_cfg.downsample=3;
- mpg123_cfg.downsample_custom=(gint)GTK_ADJUSTMENT(decode_freq_custom_adj)->value;
- */
-#ifdef USE_3DNOW
- if (GTK_TOGGLE_BUTTON(auto_select)->active)
- mpg123_cfg.use_3dnow = 0;
- else if (GTK_TOGGLE_BUTTON(decoder_fpu)->active)
- mpg123_cfg.use_3dnow = 2;
- else mpg123_cfg.use_3dnow = 1;
-#endif
- mpg123_cfg.http_buffer_size = (gint) GTK_ADJUSTMENT(streaming_size_adj)->value;
- mpg123_cfg.http_prebuffer = (gint) GTK_ADJUSTMENT(streaming_pre_adj)->value;
-
- mpg123_cfg.use_proxy = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_proxy_use));
- g_free(mpg123_cfg.proxy_host);
- mpg123_cfg.proxy_host = g_strdup(gtk_entry_get_text(GTK_ENTRY(streaming_proxy_host_entry)));
- mpg123_cfg.proxy_port = atoi(gtk_entry_get_text(GTK_ENTRY(streaming_proxy_port_entry)));
-
- mpg123_cfg.proxy_use_auth = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_proxy_auth_use));
-
- if(mpg123_cfg.proxy_user)
- g_free(mpg123_cfg.proxy_user);
- mpg123_cfg.proxy_user = NULL;
- if(strlen(gtk_entry_get_text(GTK_ENTRY(streaming_proxy_auth_user_entry))) > 0)
- mpg123_cfg.proxy_user = g_strdup(gtk_entry_get_text(GTK_ENTRY(streaming_proxy_auth_user_entry)));
-
- if(mpg123_cfg.proxy_pass)
- g_free(mpg123_cfg.proxy_pass);
- mpg123_cfg.proxy_pass = NULL;
- if(strlen(gtk_entry_get_text(GTK_ENTRY(streaming_proxy_auth_pass_entry))) > 0)
- mpg123_cfg.proxy_pass = g_strdup(gtk_entry_get_text(GTK_ENTRY(streaming_proxy_auth_pass_entry)));
-
-
- mpg123_cfg.save_http_stream = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_save_use));
- if (mpg123_cfg.save_http_path)
- g_free(mpg123_cfg.save_http_path);
- mpg123_cfg.save_http_path = g_strdup(gtk_entry_get_text(GTK_ENTRY(streaming_save_entry)));
-
- mpg123_cfg.cast_title_streaming = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_cast_title));
- mpg123_cfg.use_udp_channel = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_udp_title));
-
- mpg123_cfg.use_id3 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(title_id3_use));
- mpg123_cfg.disable_id3v2 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(title_id3v2_disable));
- g_free(mpg123_cfg.id3_format);
- mpg123_cfg.id3_format = g_strdup(gtk_entry_get_text(GTK_ENTRY(title_id3_entry)));
-
- filename = g_strconcat(g_get_home_dir(), "/.xmms/config", NULL);
- cfg = xmms_cfg_open_file(filename);
- if (!cfg)
- cfg = xmms_cfg_new();
- xmms_cfg_write_int(cfg, "MPG123", "resolution", mpg123_cfg.resolution);
- xmms_cfg_write_int(cfg, "MPG123", "channels", mpg123_cfg.channels);
- xmms_cfg_write_int(cfg, "MPG123", "downsample", mpg123_cfg.downsample);
-/* xmms_cfg_write_int(cfg,"MPG123","downsample_custom",mpg123_cfg.downsample_custom); */
- xmms_cfg_write_int(cfg, "MPG123", "http_buffer_size", mpg123_cfg.http_buffer_size);
- xmms_cfg_write_int(cfg, "MPG123", "http_prebuffer", mpg123_cfg.http_prebuffer);
- xmms_cfg_write_boolean(cfg, "MPG123", "use_proxy", mpg123_cfg.use_proxy);
- xmms_cfg_write_string(cfg, "MPG123", "proxy_host", mpg123_cfg.proxy_host);
- xmms_cfg_write_int(cfg, "MPG123", "proxy_port", mpg123_cfg.proxy_port);
- xmms_cfg_write_boolean(cfg, "MPG123", "proxy_use_auth", mpg123_cfg.proxy_use_auth);
- if(mpg123_cfg.proxy_user)
- xmms_cfg_write_string(cfg, "MPG123", "proxy_user", mpg123_cfg.proxy_user);
- else
- xmms_cfg_remove_key(cfg, "MPG123", "proxy_user");
- if(mpg123_cfg.proxy_pass)
- xmms_cfg_write_string(cfg, "MPG123", "proxy_pass", mpg123_cfg.proxy_pass);
- else
- xmms_cfg_remove_key(cfg, "MPG123", "proxy_pass");
- xmms_cfg_write_boolean(cfg, "MPG123", "save_http_stream", mpg123_cfg.save_http_stream);
- xmms_cfg_write_string(cfg, "MPG123", "save_http_path", mpg123_cfg.save_http_path);
- xmms_cfg_write_boolean(cfg, "MPG123", "cast_title_streaming", mpg123_cfg.cast_title_streaming);
- xmms_cfg_write_boolean(cfg, "MPG123", "use_udp_channel", mpg123_cfg.use_udp_channel);
- xmms_cfg_write_boolean(cfg, "MPG123", "use_id3", mpg123_cfg.use_id3);
- xmms_cfg_write_boolean(cfg, "MPG123", "disable_id3v2", mpg123_cfg.disable_id3v2);
- xmms_cfg_write_string(cfg, "MPG123", "id3_format", mpg123_cfg.id3_format);
- xmms_cfg_write_boolean(cfg, "MPG123", "detect_by_content", mpg123_cfg.detect_by_content);
-#ifdef USE_3DNOW
- xmms_cfg_write_int(cfg, "MPG123", "use_3dnow", mpg123_cfg.use_3dnow);
-#endif
- xmms_cfg_write_file(cfg, filename);
- xmms_cfg_free(cfg);
- g_free(filename);
- gtk_widget_destroy(mpg123_configurewin);
-}
-
-#ifdef USE_3DNOW
-static void auto_select_cb(GtkWidget * w, gpointer data)
-{
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auto_select)) == TRUE) {
- gtk_widget_set_sensitive(decoder_fpu, FALSE);
- gtk_widget_set_sensitive(decoder_3dnow, FALSE);
- if (support_3dnow() == TRUE)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decoder_3dnow), TRUE);
- else
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decoder_fpu), TRUE);
- } else {
- gtk_widget_set_sensitive(decoder_3dnow, TRUE);
- gtk_widget_set_sensitive(decoder_fpu, TRUE);
- }
-}
-
-static void use_3dnow_cb(GtkWidget * w, gpointer data)
-{
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(decoder_3dnow)) == TRUE) {
- mpg123_cfg.resolution = 16;
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_res_16), TRUE);
- gtk_widget_set_sensitive(decode_res_8, FALSE);
-
- mpg123_cfg.channels = 2;
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_ch_stereo), TRUE);
- gtk_widget_set_sensitive(decode_ch_mono, FALSE);
-
- mpg123_cfg.downsample = 0;
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_freq_1to1), TRUE);
- gtk_widget_set_sensitive(decode_freq_1to2, FALSE);
- gtk_widget_set_sensitive(decode_freq_1to4, FALSE);
- }
-}
-
-static void use_fpu_cb(GtkWidget * w, gpointer data)
-{
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(decoder_fpu)) == TRUE) {
- gtk_widget_set_sensitive(decode_res_8, TRUE);
-
- gtk_widget_set_sensitive(decode_ch_mono, TRUE);
-
- gtk_widget_set_sensitive(decode_freq_1to2, TRUE);
- gtk_widget_set_sensitive(decode_freq_1to4, TRUE);
- }
-}
-#endif
-
-static void proxy_use_cb(GtkWidget * w, gpointer data)
-{
- gboolean use_proxy, use_proxy_auth;
-
- use_proxy = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_proxy_use));
- use_proxy_auth = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_proxy_auth_use));
-
- gtk_widget_set_sensitive(streaming_proxy_hbox, use_proxy);
- gtk_widget_set_sensitive(streaming_proxy_auth_use, use_proxy);
- gtk_widget_set_sensitive(streaming_proxy_auth_hbox, use_proxy && use_proxy_auth);
-}
-
-static void proxy_auth_use_cb(GtkWidget *w, gpointer data)
-{
- gboolean use_proxy, use_proxy_auth;
-
- use_proxy = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_proxy_use));
- use_proxy_auth = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_proxy_auth_use));
-
- gtk_widget_set_sensitive(streaming_proxy_auth_hbox, use_proxy && use_proxy_auth);
-}
-
-static void streaming_save_dirbrowser_cb(gchar * dir)
-{
- gtk_entry_set_text(GTK_ENTRY(streaming_save_entry), dir);
-}
-
-static void streaming_save_browse_cb(GtkWidget * w, gpointer data)
-{
- if (!streaming_save_dirbrowser)
- {
- streaming_save_dirbrowser = xmms_create_dir_browser(_("Select the directory where you want to store the MPEG streams:"),
- mpg123_cfg.save_http_path, GTK_SELECTION_SINGLE, streaming_save_dirbrowser_cb);
- g_signal_connect(streaming_save_dirbrowser, "destroy", G_CALLBACK(gtk_widget_destroyed), &streaming_save_dirbrowser);
- gtk_window_set_transient_for(GTK_WINDOW(streaming_save_dirbrowser), GTK_WINDOW(mpg123_configurewin));
- gtk_widget_show(streaming_save_dirbrowser);
- }
-}
-
-static void streaming_save_use_cb(GtkWidget * w, gpointer data)
-{
- gboolean save_stream;
-
- save_stream = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_save_use));
-
- gtk_widget_set_sensitive(streaming_save_hbox, save_stream);
-}
-
-static void title_id3_use_cb(GtkWidget * w, gpointer data)
-{
- gboolean use_id3;
-
- use_id3 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(title_id3_use));
-
- gtk_widget_set_sensitive(title_id3v2_disable, use_id3);
- gtk_widget_set_sensitive(title_id3_box, use_id3);
- gtk_widget_set_sensitive(title_id3_desc_box, use_id3);
-}
-
-static void configure_destroy(GtkWidget * w, gpointer data)
-{
- if (streaming_save_dirbrowser)
- gtk_widget_destroy(streaming_save_dirbrowser);
-}
-
-void mpg123_configure(void)
-{
- GtkWidget *streaming_vbox;
- GtkWidget *streaming_buf_frame, *streaming_buf_hbox;
- GtkWidget *streaming_size_box, *streaming_size_label, *streaming_size_spin;
- GtkWidget *streaming_pre_box, *streaming_pre_label, *streaming_pre_spin;
- GtkWidget *streaming_proxy_frame, *streaming_proxy_vbox;
- GtkWidget *streaming_proxy_port_label, *streaming_proxy_host_label;
- GtkWidget *streaming_save_frame, *streaming_save_vbox;
- GtkWidget *streaming_save_label, *streaming_save_browse;
- GtkWidget *streaming_cast_frame, *streaming_cast_vbox;
- GtkWidget *title_frame, *title_id3_vbox, *title_id3_label;
- GtkWidget *title_id3_desc_label1, *title_id3_desc_label2;
- GtkWidget *bbox, *ok, *cancel;
-
- gchar *temp;
-
- if (mpg123_configurewin != NULL)
- {
- gdk_window_raise(mpg123_configurewin->window);
- return;
- }
- mpg123_configurewin = gtk_window_new(GTK_WINDOW_DIALOG);
- g_signal_connect(mpg123_configurewin, "destroy", G_CALLBACK(gtk_widget_destroyed), &mpg123_configurewin);
- g_signal_connect(mpg123_configurewin, "destroy", G_CALLBACK(configure_destroy), &mpg123_configurewin);
- gtk_window_set_title(GTK_WINDOW(mpg123_configurewin), _("MPG123 Configuration"));
- gtk_window_set_wmclass(GTK_WINDOW(mpg123_configurewin), "mpg123_configuration", "Nautilus");
- gtk_window_set_policy(GTK_WINDOW(mpg123_configurewin), FALSE, FALSE, FALSE);
- /* gtk_window_set_position(GTK_WINDOW(mpg123_configurewin), GTK_WIN_POS_MOUSE); */
- gtk_container_border_width(GTK_CONTAINER(mpg123_configurewin), 10);
-
- vbox = gtk_vbox_new(FALSE, 10);
- gtk_container_add(GTK_CONTAINER(mpg123_configurewin), vbox);
-
- notebook = gtk_notebook_new();
- gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
-
- decode_vbox = gtk_vbox_new(FALSE, 5);
- gtk_container_set_border_width(GTK_CONTAINER(decode_vbox), 5);
-
- decode_hbox1 = gtk_hbox_new(TRUE, 5);
- gtk_box_pack_start(GTK_BOX(decode_vbox), decode_hbox1, FALSE, FALSE, 0);
-
- decode_res_frame = gtk_frame_new(_("Resolution:"));
- gtk_box_pack_start(GTK_BOX(decode_hbox1), decode_res_frame, TRUE, TRUE, 0);
-
- decode_res_vbox = gtk_vbox_new(FALSE, 5);
- gtk_container_set_border_width(GTK_CONTAINER(decode_res_vbox), 5);
- gtk_container_add(GTK_CONTAINER(decode_res_frame), decode_res_vbox);
-
- decode_res_16 = gtk_radio_button_new_with_label(NULL, _("16 bit"));
- if (mpg123_cfg.resolution == 16)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_res_16), TRUE);
- gtk_box_pack_start(GTK_BOX(decode_res_vbox), decode_res_16, FALSE, FALSE, 0);
- gtk_widget_show(decode_res_16);
-
- decode_res_8 = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(decode_res_16)), _("8 bit"));
- if (mpg123_cfg.resolution == 8)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_res_8), TRUE);
-
- gtk_box_pack_start(GTK_BOX(decode_res_vbox), decode_res_8, FALSE, FALSE, 0);
- gtk_widget_show(decode_res_8);
-
-#ifdef USE_3DNOW
- if (((support_3dnow() == TRUE) && (mpg123_cfg.use_3dnow !=2 )) ||
- ((support_3dnow() == FALSE) && (mpg123_cfg.use_3dnow == 1)))
- {
- mpg123_cfg.resolution = 16;
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_res_16), TRUE);
- gtk_widget_set_sensitive(decode_res_8, FALSE);
- }
-#endif
- gtk_widget_show(decode_res_vbox);
- gtk_widget_show(decode_res_frame);
-
- decode_ch_frame = gtk_frame_new(_("Channels:"));
- gtk_box_pack_start(GTK_BOX(decode_hbox1), decode_ch_frame, TRUE, TRUE, 0);
-
- decode_ch_vbox = gtk_vbox_new(FALSE, 5);
- gtk_container_set_border_width(GTK_CONTAINER(decode_ch_vbox), 5);
- gtk_container_add(GTK_CONTAINER(decode_ch_frame), decode_ch_vbox);
-
- decode_ch_stereo = gtk_radio_button_new_with_label(NULL, _("Stereo (if available)"));
- if (mpg123_cfg.channels == 2)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_ch_stereo), TRUE);
-
- gtk_box_pack_start(GTK_BOX(decode_ch_vbox), decode_ch_stereo, FALSE, FALSE, 0);
- gtk_widget_show(decode_ch_stereo);
-
- decode_ch_mono = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(decode_ch_stereo)), _("Mono"));
- if (mpg123_cfg.channels == 1)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_ch_mono), TRUE);
-
- gtk_box_pack_start(GTK_BOX(decode_ch_vbox), decode_ch_mono, FALSE, FALSE, 0);
- gtk_widget_show(decode_ch_mono);
-
-#ifdef USE_3DNOW
- if (((support_3dnow() == TRUE) && (mpg123_cfg.use_3dnow !=2 )) ||
- ((support_3dnow() == FALSE) && (mpg123_cfg.use_3dnow == 1)))
- {
- mpg123_cfg.channels = 2;
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_ch_stereo), TRUE);
- gtk_widget_set_sensitive(decode_ch_mono, FALSE);
- }
-#endif
- gtk_widget_show(decode_ch_vbox);
- gtk_widget_show(decode_ch_frame);
- gtk_widget_show(decode_hbox1);
-
- decode_freq_frame = gtk_frame_new(_("Down sample:"));
- gtk_box_pack_start(GTK_BOX(decode_vbox), decode_freq_frame, FALSE, FALSE, 0);
-
- decode_freq_vbox = gtk_vbox_new(FALSE, 5);
- gtk_container_set_border_width(GTK_CONTAINER(decode_freq_vbox), 5);
- gtk_container_add(GTK_CONTAINER(decode_freq_frame), decode_freq_vbox);
-
- decode_freq_1to1 = gtk_radio_button_new_with_label(NULL, _("1:1 (44 kHz)"));
- if (mpg123_cfg.downsample == 0)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_freq_1to1), TRUE);
- gtk_box_pack_start(GTK_BOX(decode_freq_vbox), decode_freq_1to1, FALSE, FALSE, 0);
- gtk_widget_show(decode_freq_1to1);
-
- decode_freq_1to2 = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(decode_freq_1to1)), _("1:2 (22 kHz)"));
- if (mpg123_cfg.downsample == 1)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_freq_1to2), TRUE);
- gtk_box_pack_start(GTK_BOX(decode_freq_vbox), decode_freq_1to2, FALSE, FALSE, 0);
- gtk_widget_show(decode_freq_1to2);
-
- decode_freq_1to4 = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(decode_freq_1to1)), _("1:4 (11 kHz)"));
- if (mpg123_cfg.downsample == 2)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_freq_1to4), TRUE);
-
- gtk_box_pack_start(GTK_BOX(decode_freq_vbox), decode_freq_1to4, FALSE, FALSE, 0);
- gtk_widget_show(decode_freq_1to4);
-#ifdef USE_3DNOW
- if (((support_3dnow() == TRUE) && (mpg123_cfg.use_3dnow !=2 )) ||
- ((support_3dnow() == FALSE) && (mpg123_cfg.use_3dnow == 1)))
- {
- mpg123_cfg.downsample = 0;
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_freq_1to1), TRUE);
- gtk_widget_set_sensitive(decode_freq_1to2, FALSE);
- gtk_widget_set_sensitive(decode_freq_1to4, FALSE);
- }
-#endif
- /*decode_freq_custom_hbox=gtk_hbox_new(FALSE,5);
- gtk_box_pack_start(GTK_BOX(decode_freq_vbox),decode_freq_custom_hbox,FALSE,FALSE,0);
-
- decode_freq_custom=gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(decode_freq_1to1)),_("Custom"));
- if(mpg123_cfg.downsample==3)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_freq_custom),TRUE);
- gtk_box_pack_start(GTK_BOX(decode_freq_custom_hbox),decode_freq_custom,FALSE,FALSE,0);
- gtk_widget_show(decode_freq_custom);
-
- decode_freq_custom_adj=gtk_adjustment_new(mpg123_cfg.downsample_custom,8000,48000,25,25,25);
- decode_freq_custom_spin=gtk_spin_button_new(GTK_ADJUSTMENT(decode_freq_custom_adj),25,0);
- gtk_widget_set_usize(decode_freq_custom_spin,60,-1);
- gtk_box_pack_start(GTK_BOX(decode_freq_custom_hbox),decode_freq_custom_spin,FALSE,FALSE,0);
- gtk_widget_show(decode_freq_custom_spin);
-
- decode_freq_custom_label=gtk_label_new(_("Hz"));
- gtk_box_pack_start(GTK_BOX(decode_freq_custom_hbox),decode_freq_custom_label,FALSE,FALSE,0);
- gtk_widget_show(decode_freq_custom_label);
-
- gtk_widget_show(decode_freq_custom_hbox); */
-
-
-#ifdef USE_3DNOW
- decoder_frame = gtk_frame_new(_("Decoder:"));
- gtk_box_pack_start(GTK_BOX(decode_vbox), decoder_frame, FALSE, FALSE, 0);
-
- decoder_vbox = gtk_vbox_new(FALSE, 5);
- gtk_container_set_border_width(GTK_CONTAINER(decoder_vbox), 5);
- gtk_container_add(GTK_CONTAINER(decoder_frame), decoder_vbox);
-
- auto_select = gtk_check_button_new_with_label(_("Enable Automatic detection"));
- if (mpg123_cfg.use_3dnow == 0)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(auto_select), TRUE);
- gtk_box_pack_start(GTK_BOX(decoder_vbox), auto_select, FALSE, FALSE, 0);
- g_signal_connect(auto_select, "clicked", G_CALLBACK(auto_select_cb), NULL);
- gtk_widget_show(auto_select);
-
- decoder_3dnow = gtk_radio_button_new_with_label(NULL, _("use 3DNow! optimized decoder"));
- if (((support_3dnow() == TRUE) && mpg123_cfg.use_3dnow != 2) || (mpg123_cfg.use_3dnow == 1))
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decoder_3dnow), TRUE);
- gtk_box_pack_start(GTK_BOX(decoder_vbox), decoder_3dnow, FALSE, FALSE, 0);
- g_signal_connect(decoder_3dnow, "clicked", G_CALLBACK(use_3dnow_cb), NULL);
- gtk_widget_show(decoder_3dnow);
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auto_select)) == TRUE)
- gtk_widget_set_sensitive(decoder_3dnow, FALSE);
-
- decoder_fpu = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(decoder_3dnow)), _("use FPU decoder"));
- if (((support_3dnow() == FALSE) && mpg123_cfg.use_3dnow != 1) || (mpg123_cfg.use_3dnow == 2))
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decoder_fpu), TRUE);
- gtk_box_pack_start(GTK_BOX(decoder_vbox), decoder_fpu, FALSE, FALSE, 0);
- g_signal_connect(decoder_fpu, "clicked", G_CALLBACK(use_fpu_cb), NULL);
- gtk_widget_show(decoder_fpu);
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auto_select)) == TRUE)
- gtk_widget_set_sensitive(decoder_fpu, FALSE);
-
- gtk_widget_show(decoder_vbox);
- gtk_widget_show(decoder_frame);
-#endif
-
- gtk_widget_show(decode_freq_vbox);
- gtk_widget_show(decode_freq_frame);
-
- option_frame = gtk_frame_new(_("Options"));
- gtk_box_pack_start(GTK_BOX(decode_vbox), option_frame, FALSE, FALSE, 0);
-
- option_vbox = gtk_vbox_new(FALSE, 5);
- gtk_container_add(GTK_CONTAINER(option_frame), option_vbox);
-
- detect_by_content = gtk_check_button_new_with_label(_("Detect files by content (instead of file extention)"));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(detect_by_content), mpg123_cfg.detect_by_content);
- gtk_box_pack_start(GTK_BOX(option_vbox), detect_by_content, FALSE, FALSE, 0);
-
- gtk_widget_show(detect_by_content);
- gtk_widget_show(option_vbox);
- gtk_widget_show(option_frame);
-
- gtk_widget_show(decode_vbox);
- gtk_notebook_append_page(GTK_NOTEBOOK(notebook), decode_vbox, gtk_label_new(_("Decoder")));
-
- streaming_vbox = gtk_vbox_new(FALSE, 0);
-
- streaming_buf_frame = gtk_frame_new(_("Buffering:"));
- gtk_container_set_border_width(GTK_CONTAINER(streaming_buf_frame), 5);
- gtk_box_pack_start(GTK_BOX(streaming_vbox), streaming_buf_frame, FALSE, FALSE, 0);
-
- streaming_buf_hbox = gtk_hbox_new(TRUE, 5);
- gtk_container_set_border_width(GTK_CONTAINER(streaming_buf_hbox), 5);
- gtk_container_add(GTK_CONTAINER(streaming_buf_frame), streaming_buf_hbox);
-
- streaming_size_box = gtk_hbox_new(FALSE, 5);
- /*gtk_table_attach_defaults(GTK_TABLE(streaming_buf_table),streaming_size_box,0,1,0,1); */
- gtk_box_pack_start(GTK_BOX(streaming_buf_hbox), streaming_size_box, TRUE, TRUE, 0);
- streaming_size_label = gtk_label_new(_("Buffer size (kb):"));
- gtk_box_pack_start(GTK_BOX(streaming_size_box), streaming_size_label, FALSE, FALSE, 0);
- gtk_widget_show(streaming_size_label);
- streaming_size_adj = gtk_adjustment_new(mpg123_cfg.http_buffer_size, 4, 4096, 4, 4, 4);
- streaming_size_spin = gtk_spin_button_new(GTK_ADJUSTMENT(streaming_size_adj), 8, 0);
- gtk_widget_set_usize(streaming_size_spin, 60, -1);
- gtk_box_pack_start(GTK_BOX(streaming_size_box), streaming_size_spin, FALSE, FALSE, 0);
- gtk_widget_show(streaming_size_spin);
- gtk_widget_show(streaming_size_box);
-
- streaming_pre_box = gtk_hbox_new(FALSE, 5);
- /*gtk_table_attach_defaults(GTK_TABLE(streaming_buf_table),streaming_pre_box,1,2,0,1); */
- gtk_box_pack_start(GTK_BOX(streaming_buf_hbox), streaming_pre_box, TRUE, TRUE, 0);
- streaming_pre_label = gtk_label_new(_("Pre-buffer (percent):"));
- gtk_box_pack_start(GTK_BOX(streaming_pre_box), streaming_pre_label, FALSE, FALSE, 0);
- gtk_widget_show(streaming_pre_label);
- streaming_pre_adj = gtk_adjustment_new(mpg123_cfg.http_prebuffer, 0, 90, 1, 1, 1);
- streaming_pre_spin = gtk_spin_button_new(GTK_ADJUSTMENT(streaming_pre_adj), 1, 0);
- gtk_widget_set_usize(streaming_pre_spin, 60, -1);
- gtk_box_pack_start(GTK_BOX(streaming_pre_box), streaming_pre_spin, FALSE, FALSE, 0);
- gtk_widget_show(streaming_pre_spin);
- gtk_widget_show(streaming_pre_box);
-
- gtk_widget_show(streaming_buf_hbox);
- gtk_widget_show(streaming_buf_frame);
-
- /*
- * Proxy config.
- */
- streaming_proxy_frame = gtk_frame_new(_("Proxy:"));
- gtk_container_set_border_width(GTK_CONTAINER(streaming_proxy_frame), 5);
- gtk_box_pack_start(GTK_BOX(streaming_vbox), streaming_proxy_frame, FALSE, FALSE, 0);
-
- streaming_proxy_vbox = gtk_vbox_new(FALSE, 5);
- gtk_container_set_border_width(GTK_CONTAINER(streaming_proxy_vbox), 5);
- gtk_container_add(GTK_CONTAINER(streaming_proxy_frame), streaming_proxy_vbox);
-
- streaming_proxy_use = gtk_check_button_new_with_label(_("Use proxy"));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(streaming_proxy_use), mpg123_cfg.use_proxy);
- g_signal_connect(streaming_proxy_use, "clicked", G_CALLBACK(proxy_use_cb), NULL);
- gtk_box_pack_start(GTK_BOX(streaming_proxy_vbox), streaming_proxy_use, FALSE, FALSE, 0);
- gtk_widget_show(streaming_proxy_use);
-
- streaming_proxy_hbox = gtk_hbox_new(FALSE, 5);
- gtk_widget_set_sensitive(streaming_proxy_hbox, mpg123_cfg.use_proxy);
- gtk_box_pack_start(GTK_BOX(streaming_proxy_vbox), streaming_proxy_hbox, FALSE, FALSE, 0);
-
- streaming_proxy_host_label = gtk_label_new(_("Host:"));
- gtk_box_pack_start(GTK_BOX(streaming_proxy_hbox), streaming_proxy_host_label, FALSE, FALSE, 0);
- gtk_widget_show(streaming_proxy_host_label);
-
- streaming_proxy_host_entry = gtk_entry_new();
- gtk_entry_set_text(GTK_ENTRY(streaming_proxy_host_entry), mpg123_cfg.proxy_host);
- gtk_box_pack_start(GTK_BOX(streaming_proxy_hbox), streaming_proxy_host_entry, TRUE, TRUE, 0);
- gtk_widget_show(streaming_proxy_host_entry);
-
- streaming_proxy_port_label = gtk_label_new(_("Port:"));
- gtk_box_pack_start(GTK_BOX(streaming_proxy_hbox), streaming_proxy_port_label, FALSE, FALSE, 0);
- gtk_widget_show(streaming_proxy_port_label);
-
- streaming_proxy_port_entry = gtk_entry_new();
- gtk_widget_set_usize(streaming_proxy_port_entry, 50, -1);
- temp = g_strdup_printf("%d", mpg123_cfg.proxy_port);
- gtk_entry_set_text(GTK_ENTRY(streaming_proxy_port_entry), temp);
- g_free(temp);
- gtk_box_pack_start(GTK_BOX(streaming_proxy_hbox), streaming_proxy_port_entry, FALSE, FALSE, 0);
- gtk_widget_show(streaming_proxy_port_entry);
-
- gtk_widget_show(streaming_proxy_hbox);
-
- streaming_proxy_auth_use = gtk_check_button_new_with_label(_("Use authentication"));
- gtk_widget_set_sensitive(streaming_proxy_auth_use, mpg123_cfg.use_proxy);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(streaming_proxy_auth_use), mpg123_cfg.proxy_use_auth);
- g_signal_connect(streaming_proxy_auth_use, "clicked", G_CALLBACK(proxy_auth_use_cb), NULL);
- gtk_box_pack_start(GTK_BOX(streaming_proxy_vbox), streaming_proxy_auth_use, FALSE, FALSE, 0);
- gtk_widget_show(streaming_proxy_auth_use);
-
- streaming_proxy_auth_hbox = gtk_hbox_new(FALSE, 5);
- gtk_widget_set_sensitive(streaming_proxy_auth_hbox, mpg123_cfg.use_proxy && mpg123_cfg.proxy_use_auth);
- gtk_box_pack_start(GTK_BOX(streaming_proxy_vbox), streaming_proxy_auth_hbox, FALSE, FALSE, 0);
-
- streaming_proxy_auth_user_label = gtk_label_new(_("Username:"));
- gtk_box_pack_start(GTK_BOX(streaming_proxy_auth_hbox), streaming_proxy_auth_user_label, FALSE, FALSE, 0);
- gtk_widget_show(streaming_proxy_auth_user_label);
-
- streaming_proxy_auth_user_entry = gtk_entry_new();
- if(mpg123_cfg.proxy_user)
- gtk_entry_set_text(GTK_ENTRY(streaming_proxy_auth_user_entry), mpg123_cfg.proxy_user);
- gtk_box_pack_start(GTK_BOX(streaming_proxy_auth_hbox), streaming_proxy_auth_user_entry, TRUE, TRUE, 0);
- gtk_widget_show(streaming_proxy_auth_user_entry);
-
- streaming_proxy_auth_pass_label = gtk_label_new(_("Password:"));
- gtk_box_pack_start(GTK_BOX(streaming_proxy_auth_hbox), streaming_proxy_auth_pass_label, FALSE, FALSE, 0);
- gtk_widget_show(streaming_proxy_auth_pass_label);
-
- streaming_proxy_auth_pass_entry = gtk_entry_new();
- if(mpg123_cfg.proxy_pass)
- gtk_entry_set_text(GTK_ENTRY(streaming_proxy_auth_pass_entry), mpg123_cfg.proxy_pass);
- gtk_entry_set_visibility(GTK_ENTRY(streaming_proxy_auth_pass_entry), FALSE);
- gtk_box_pack_start(GTK_BOX(streaming_proxy_auth_hbox), streaming_proxy_auth_pass_entry, TRUE, TRUE, 0);
- gtk_widget_show(streaming_proxy_auth_pass_entry);
-
- gtk_widget_show(streaming_proxy_auth_hbox);
- gtk_widget_show(streaming_proxy_vbox);
- gtk_widget_show(streaming_proxy_frame);
-
-
- /*
- * Save to disk config.
- */
- streaming_save_frame = gtk_frame_new(_("Save stream to disk:"));
- gtk_container_set_border_width(GTK_CONTAINER(streaming_save_frame), 5);
- gtk_box_pack_start(GTK_BOX(streaming_vbox), streaming_save_frame, FALSE, FALSE, 0);
-
- streaming_save_vbox = gtk_vbox_new(FALSE, 5);
- gtk_container_set_border_width(GTK_CONTAINER(streaming_save_vbox), 5);
- gtk_container_add(GTK_CONTAINER(streaming_save_frame), streaming_save_vbox);
-
- streaming_save_use = gtk_check_button_new_with_label(_("Save stream to disk"));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(streaming_save_use), mpg123_cfg.save_http_stream);
- g_signal_connect(streaming_save_use, "clicked", G_CALLBACK(streaming_save_use_cb), NULL);
- gtk_box_pack_start(GTK_BOX(streaming_save_vbox), streaming_save_use, FALSE, FALSE, 0);
- gtk_widget_show(streaming_save_use);
-
- streaming_save_hbox = gtk_hbox_new(FALSE, 5);
- gtk_widget_set_sensitive(streaming_save_hbox, mpg123_cfg.save_http_stream);
- gtk_box_pack_start(GTK_BOX(streaming_save_vbox), streaming_save_hbox, FALSE, FALSE, 0);
-
- streaming_save_label = gtk_label_new(_("Path:"));
- gtk_box_pack_start(GTK_BOX(streaming_save_hbox), streaming_save_label, FALSE, FALSE, 0);
- gtk_widget_show(streaming_save_label);
-
- streaming_save_entry = gtk_entry_new();
- gtk_entry_set_text(GTK_ENTRY(streaming_save_entry), mpg123_cfg.save_http_path);
- gtk_box_pack_start(GTK_BOX(streaming_save_hbox), streaming_save_entry, TRUE, TRUE, 0);
- gtk_widget_show(streaming_save_entry);
-
- streaming_save_browse = gtk_button_new_with_label(_("Browse"));
- g_signal_connect(streaming_save_browse, "clicked", G_CALLBACK(streaming_save_browse_cb), NULL);
- gtk_box_pack_start(GTK_BOX(streaming_save_hbox), streaming_save_browse, FALSE, FALSE, 0);
- gtk_widget_show(streaming_save_browse);
-
- gtk_widget_show(streaming_save_hbox);
- gtk_widget_show(streaming_save_vbox);
- gtk_widget_show(streaming_save_frame);
-
- streaming_cast_frame = gtk_frame_new(_("SHOUT/Icecast:"));
- gtk_container_set_border_width(GTK_CONTAINER(streaming_cast_frame), 5);
- gtk_box_pack_start(GTK_BOX(streaming_vbox), streaming_cast_frame, FALSE, FALSE, 0);
-
- streaming_cast_vbox = gtk_vbox_new(5, FALSE);
- gtk_container_add(GTK_CONTAINER(streaming_cast_frame), streaming_cast_vbox);
-
- streaming_cast_title = gtk_check_button_new_with_label(_("Enable SHOUT/Icecast title streaming"));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(streaming_cast_title), mpg123_cfg.cast_title_streaming);
- gtk_box_pack_start(GTK_BOX(streaming_cast_vbox), streaming_cast_title, FALSE, FALSE, 0);
- gtk_widget_show(streaming_cast_title);
-
- streaming_udp_title = gtk_check_button_new_with_label(_("Enable Icecast Metadata UDP Channel"));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(streaming_udp_title), mpg123_cfg.use_udp_channel);
- gtk_box_pack_start(GTK_BOX(streaming_cast_vbox), streaming_udp_title, FALSE, FALSE, 0);
- gtk_widget_show(streaming_udp_title);
-
- gtk_widget_show(streaming_cast_vbox);
- gtk_widget_show(streaming_cast_frame);
-
- gtk_widget_show(streaming_vbox);
- gtk_notebook_append_page(GTK_NOTEBOOK(notebook), streaming_vbox, gtk_label_new(_("Streaming")));
-
- title_frame = gtk_frame_new(_("ID3 Tags:"));
- gtk_container_border_width(GTK_CONTAINER(title_frame), 5);
-
- title_id3_vbox = gtk_vbox_new(FALSE, 10);
- gtk_container_border_width(GTK_CONTAINER(title_id3_vbox), 5);
- gtk_container_add(GTK_CONTAINER(title_frame), title_id3_vbox);
-
- title_id3_use = gtk_check_button_new_with_label(_("Use ID3 tags"));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(title_id3_use), mpg123_cfg.use_id3);
- g_signal_connect(title_id3_use, "clicked", title_id3_use_cb, NULL);
- gtk_box_pack_start(GTK_BOX(title_id3_vbox), title_id3_use, FALSE, FALSE, 0);
- gtk_widget_show(title_id3_use);
-
- title_id3v2_disable = gtk_check_button_new_with_label(_("Disable ID3V2 tags"));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(title_id3v2_disable),
- mpg123_cfg.disable_id3v2);
- gtk_box_pack_start(GTK_BOX(title_id3_vbox), title_id3v2_disable, FALSE, FALSE, 0);
- gtk_widget_show(title_id3v2_disable);
-
- title_id3_box = gtk_hbox_new(FALSE, 5);
- gtk_widget_set_sensitive(title_id3_box, mpg123_cfg.use_id3);
- gtk_box_pack_start(GTK_BOX(title_id3_vbox), title_id3_box, FALSE, FALSE, 0);
-
- title_id3_label = gtk_label_new(_("ID3 format:"));
- gtk_box_pack_start(GTK_BOX(title_id3_box), title_id3_label, FALSE, FALSE, 0);
- gtk_widget_show(title_id3_label);
-
- title_id3_entry = gtk_entry_new();
- gtk_entry_set_text(GTK_ENTRY(title_id3_entry), mpg123_cfg.id3_format);
- gtk_box_pack_start(GTK_BOX(title_id3_box), title_id3_entry, TRUE, TRUE, 0);
- gtk_widget_show(title_id3_entry);
- gtk_widget_show(title_id3_box);
-
- title_id3_desc_box = gtk_hbox_new(TRUE, 5);
- gtk_widget_set_sensitive(title_id3_desc_box, mpg123_cfg.use_id3);
- gtk_box_pack_start(GTK_BOX(title_id3_vbox), title_id3_desc_box, FALSE, FALSE, 0);
-
- title_id3_desc_label1 = gtk_label_new(_("%1 = Artist\n%3 = Album\n%5 = Comment\n%7 = File name\n%9 = File extension"));
- gtk_misc_set_alignment(GTK_MISC(title_id3_desc_label1), 0, 0);
- gtk_label_set_justify(GTK_LABEL(title_id3_desc_label1), GTK_JUSTIFY_LEFT);
- gtk_box_pack_start(GTK_BOX(title_id3_desc_box), title_id3_desc_label1, TRUE, TRUE, 0);
- gtk_widget_show(title_id3_desc_label1);
-
- title_id3_desc_label2 = gtk_label_new(_("%2 = Title\n%4 = Year\n%6 = Genre\n%8 = Path"));
- gtk_label_set_justify(GTK_LABEL(title_id3_desc_label2), GTK_JUSTIFY_LEFT);
- gtk_misc_set_alignment(GTK_MISC(title_id3_desc_label2), 0, 0);
- gtk_box_pack_start(GTK_BOX(title_id3_desc_box), title_id3_desc_label2, TRUE, TRUE, 0);
- gtk_widget_show(title_id3_desc_label2);
- gtk_widget_show(title_id3_desc_box);
- gtk_widget_show(title_id3_vbox);
- gtk_widget_show(title_frame);
- gtk_notebook_append_page(GTK_NOTEBOOK(notebook), title_frame, gtk_label_new(_("Title")));
-
- gtk_widget_show(notebook);
-
- bbox = gtk_hbutton_box_new();
- gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
- gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
- gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
-
- ok = gtk_button_new_from_stock (GTK_STOCK_OK);
- g_signal_connect(ok, "clicked", G_CALLBACK(mpg123_configurewin_ok), NULL);
- GTK_WIDGET_SET_FLAGS(ok, GTK_CAN_DEFAULT);
- gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 0);
- gtk_widget_show(ok);
- gtk_widget_grab_default(ok);
-
- cancel = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
- g_signal_connect_object(cancel, "clicked", G_CALLBACK(gtk_widget_destroy), mpg123_configurewin, 0);
- GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT);
- gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0);
- gtk_widget_show(cancel);
-
- gtk_widget_show(bbox);
- gtk_widget_show(vbox);
- gtk_widget_show(mpg123_configurewin);
-}
diff --git a/components/music/dct64.c b/components/music/dct64.c
deleted file mode 100644
index dad147619..000000000
--- a/components/music/dct64.c
+++ /dev/null
@@ -1,167 +0,0 @@
-
-/*
- * Discrete Cosine Tansform (DCT) for subband synthesis
- *
- * -funroll-loops (for gcc) will remove the loops for better performance
- * using loops in the source-code enhances readabillity
- */
-
-/*
- * TODO: write an optimized version for the down-sampling modes
- * (in these modes the bands 16-31 (2:1) or 8-31 (4:1) are zero
- */
-
-#include "mpg123.h"
-
-void mpg123_dct64(real * out0, real * out1, real * samples)
-{
- real bufs[64];
-
- {
- register int i, j;
- register real *b1, *b2, *bs, *costab;
-
- b1 = samples;
- bs = bufs;
- costab = mpg123_pnts[0] + 16;
- b2 = b1 + 32;
-
- for (i = 15; i >= 0; i--)
- *bs++ = (*b1++ + *--b2);
- for (i = 15; i >= 0; i--)
- *bs++ = (*--b2 - *b1++) * *--costab;
-
- b1 = bufs;
- costab = mpg123_pnts[1] + 8;
- b2 = b1 + 16;
-
- {
- for (i = 7; i >= 0; i--)
- *bs++ = (*b1++ + *--b2);
- for (i = 7; i >= 0; i--)
- *bs++ = (*--b2 - *b1++) * *--costab;
- b2 += 32;
- costab += 8;
- for (i = 7; i >= 0; i--)
- *bs++ = (*b1++ + *--b2);
- for (i = 7; i >= 0; i--)
- *bs++ = (*b1++ - *--b2) * *--costab;
- b2 += 32;
- }
-
- bs = bufs;
- costab = mpg123_pnts[2];
- b2 = b1 + 8;
-
- for (j = 2; j; j--)
- {
- for (i = 3; i >= 0; i--)
- *bs++ = (*b1++ + *--b2);
- for (i = 3; i >= 0; i--)
- *bs++ = (*--b2 - *b1++) * costab[i];
- b2 += 16;
- for (i = 3; i >= 0; i--)
- *bs++ = (*b1++ + *--b2);
- for (i = 3; i >= 0; i--)
- *bs++ = (*b1++ - *--b2) * costab[i];
- b2 += 16;
- }
-
- b1 = bufs;
- costab = mpg123_pnts[3];
- b2 = b1 + 4;
-
- for (j = 4; j; j--)
- {
- *bs++ = (*b1++ + *--b2);
- *bs++ = (*b1++ + *--b2);
- *bs++ = (*--b2 - *b1++) * costab[1];
- *bs++ = (*--b2 - *b1++) * costab[0];
- b2 += 8;
- *bs++ = (*b1++ + *--b2);
- *bs++ = (*b1++ + *--b2);
- *bs++ = (*b1++ - *--b2) * costab[1];
- *bs++ = (*b1++ - *--b2) * costab[0];
- b2 += 8;
- }
- bs = bufs;
- costab = mpg123_pnts[4];
-
- for (j = 8; j; j--)
- {
- real v0, v1;
-
- v0 = *b1++;
- v1 = *b1++;
- *bs++ = (v0 + v1);
- *bs++ = (v0 - v1) * (*costab);
- v0 = *b1++;
- v1 = *b1++;
- *bs++ = (v0 + v1);
- *bs++ = (v1 - v0) * (*costab);
- }
-
- }
-
- {
- register real *b1;
- register int i;
-
- for (b1 = bufs, i = 8; i; i--, b1 += 4)
- b1[2] += b1[3];
-
- for (b1 = bufs, i = 4; i; i--, b1 += 8)
- {
- b1[4] += b1[6];
- b1[6] += b1[5];
- b1[5] += b1[7];
- }
-
- for (b1 = bufs, i = 2; i; i--, b1 += 16)
- {
- b1[8] += b1[12];
- b1[12] += b1[10];
- b1[10] += b1[14];
- b1[14] += b1[9];
- b1[9] += b1[13];
- b1[13] += b1[11];
- b1[11] += b1[15];
- }
- }
-
- out0[0x10 * 16] = bufs[0];
- out0[0x10 * 15] = bufs[16 + 0] + bufs[16 + 8];
- out0[0x10 * 14] = bufs[8];
- out0[0x10 * 13] = bufs[16 + 8] + bufs[16 + 4];
- out0[0x10 * 12] = bufs[4];
- out0[0x10 * 11] = bufs[16 + 4] + bufs[16 + 12];
- out0[0x10 * 10] = bufs[12];
- out0[0x10 * 9] = bufs[16 + 12] + bufs[16 + 2];
- out0[0x10 * 8] = bufs[2];
- out0[0x10 * 7] = bufs[16 + 2] + bufs[16 + 10];
- out0[0x10 * 6] = bufs[10];
- out0[0x10 * 5] = bufs[16 + 10] + bufs[16 + 6];
- out0[0x10 * 4] = bufs[6];
- out0[0x10 * 3] = bufs[16 + 6] + bufs[16 + 14];
- out0[0x10 * 2] = bufs[14];
- out0[0x10 * 1] = bufs[16 + 14] + bufs[16 + 1];
- out0[0x10 * 0] = bufs[1];
-
- out1[0x10 * 0] = bufs[1];
- out1[0x10 * 1] = bufs[16 + 1] + bufs[16 + 9];
- out1[0x10 * 2] = bufs[9];
- out1[0x10 * 3] = bufs[16 + 9] + bufs[16 + 5];
- out1[0x10 * 4] = bufs[5];
- out1[0x10 * 5] = bufs[16 + 5] + bufs[16 + 13];
- out1[0x10 * 6] = bufs[13];
- out1[0x10 * 7] = bufs[16 + 13] + bufs[16 + 3];
- out1[0x10 * 8] = bufs[3];
- out1[0x10 * 9] = bufs[16 + 3] + bufs[16 + 11];
- out1[0x10 * 10] = bufs[11];
- out1[0x10 * 11] = bufs[16 + 11] + bufs[16 + 7];
- out1[0x10 * 12] = bufs[7];
- out1[0x10 * 13] = bufs[16 + 7] + bufs[16 + 15];
- out1[0x10 * 14] = bufs[15];
- out1[0x10 * 15] = bufs[16 + 15];
-
-}
diff --git a/components/music/dct64_i386.c b/components/music/dct64_i386.c
deleted file mode 100644
index f0f6c8930..000000000
--- a/components/music/dct64_i386.c
+++ /dev/null
@@ -1,315 +0,0 @@
-
-/*
- * Discrete Cosine Tansform (DCT) for subband synthesis
- * optimized for machines with no auto-increment.
- * The performance is highly compiler dependend. Maybe
- * the mpg123_dct64.c version for 'normal' processor may be faster
- * even for Intel processors.
- */
-
-#include "mpg123.h"
-
-static void
-mpg123_dct64_1(real * out0, real * out1, real * b1, real * b2, real * samples)
-{
-
- {
- register real *costab = mpg123_pnts[0];
-
- b1[0x00] = samples[0x00] + samples[0x1F];
- b1[0x1F] = (samples[0x00] - samples[0x1F]) * costab[0x0];
-
- b1[0x01] = samples[0x01] + samples[0x1E];
- b1[0x1E] = (samples[0x01] - samples[0x1E]) * costab[0x1];
-
- b1[0x02] = samples[0x02] + samples[0x1D];
- b1[0x1D] = (samples[0x02] - samples[0x1D]) * costab[0x2];
-
- b1[0x03] = samples[0x03] + samples[0x1C];
- b1[0x1C] = (samples[0x03] - samples[0x1C]) * costab[0x3];
-
- b1[0x04] = samples[0x04] + samples[0x1B];
- b1[0x1B] = (samples[0x04] - samples[0x1B]) * costab[0x4];
-
- b1[0x05] = samples[0x05] + samples[0x1A];
- b1[0x1A] = (samples[0x05] - samples[0x1A]) * costab[0x5];
-
- b1[0x06] = samples[0x06] + samples[0x19];
- b1[0x19] = (samples[0x06] - samples[0x19]) * costab[0x6];
-
- b1[0x07] = samples[0x07] + samples[0x18];
- b1[0x18] = (samples[0x07] - samples[0x18]) * costab[0x7];
-
- b1[0x08] = samples[0x08] + samples[0x17];
- b1[0x17] = (samples[0x08] - samples[0x17]) * costab[0x8];
-
- b1[0x09] = samples[0x09] + samples[0x16];
- b1[0x16] = (samples[0x09] - samples[0x16]) * costab[0x9];
-
- b1[0x0A] = samples[0x0A] + samples[0x15];
- b1[0x15] = (samples[0x0A] - samples[0x15]) * costab[0xA];
-
- b1[0x0B] = samples[0x0B] + samples[0x14];
- b1[0x14] = (samples[0x0B] - samples[0x14]) * costab[0xB];
-
- b1[0x0C] = samples[0x0C] + samples[0x13];
- b1[0x13] = (samples[0x0C] - samples[0x13]) * costab[0xC];
-
- b1[0x0D] = samples[0x0D] + samples[0x12];
- b1[0x12] = (samples[0x0D] - samples[0x12]) * costab[0xD];
-
- b1[0x0E] = samples[0x0E] + samples[0x11];
- b1[0x11] = (samples[0x0E] - samples[0x11]) * costab[0xE];
-
- b1[0x0F] = samples[0x0F] + samples[0x10];
- b1[0x10] = (samples[0x0F] - samples[0x10]) * costab[0xF];
- }
-
- {
- register real *costab = mpg123_pnts[1];
-
- b2[0x00] = b1[0x00] + b1[0x0F];
- b2[0x0F] = (b1[0x00] - b1[0x0F]) * costab[0];
- b2[0x01] = b1[0x01] + b1[0x0E];
- b2[0x0E] = (b1[0x01] - b1[0x0E]) * costab[1];
- b2[0x02] = b1[0x02] + b1[0x0D];
- b2[0x0D] = (b1[0x02] - b1[0x0D]) * costab[2];
- b2[0x03] = b1[0x03] + b1[0x0C];
- b2[0x0C] = (b1[0x03] - b1[0x0C]) * costab[3];
- b2[0x04] = b1[0x04] + b1[0x0B];
- b2[0x0B] = (b1[0x04] - b1[0x0B]) * costab[4];
- b2[0x05] = b1[0x05] + b1[0x0A];
- b2[0x0A] = (b1[0x05] - b1[0x0A]) * costab[5];
- b2[0x06] = b1[0x06] + b1[0x09];
- b2[0x09] = (b1[0x06] - b1[0x09]) * costab[6];
- b2[0x07] = b1[0x07] + b1[0x08];
- b2[0x08] = (b1[0x07] - b1[0x08]) * costab[7];
-
- b2[0x10] = b1[0x10] + b1[0x1F];
- b2[0x1F] = (b1[0x1F] - b1[0x10]) * costab[0];
- b2[0x11] = b1[0x11] + b1[0x1E];
- b2[0x1E] = (b1[0x1E] - b1[0x11]) * costab[1];
- b2[0x12] = b1[0x12] + b1[0x1D];
- b2[0x1D] = (b1[0x1D] - b1[0x12]) * costab[2];
- b2[0x13] = b1[0x13] + b1[0x1C];
- b2[0x1C] = (b1[0x1C] - b1[0x13]) * costab[3];
- b2[0x14] = b1[0x14] + b1[0x1B];
- b2[0x1B] = (b1[0x1B] - b1[0x14]) * costab[4];
- b2[0x15] = b1[0x15] + b1[0x1A];
- b2[0x1A] = (b1[0x1A] - b1[0x15]) * costab[5];
- b2[0x16] = b1[0x16] + b1[0x19];
- b2[0x19] = (b1[0x19] - b1[0x16]) * costab[6];
- b2[0x17] = b1[0x17] + b1[0x18];
- b2[0x18] = (b1[0x18] - b1[0x17]) * costab[7];
- }
-
- {
- register real *costab = mpg123_pnts[2];
-
- b1[0x00] = b2[0x00] + b2[0x07];
- b1[0x07] = (b2[0x00] - b2[0x07]) * costab[0];
- b1[0x01] = b2[0x01] + b2[0x06];
- b1[0x06] = (b2[0x01] - b2[0x06]) * costab[1];
- b1[0x02] = b2[0x02] + b2[0x05];
- b1[0x05] = (b2[0x02] - b2[0x05]) * costab[2];
- b1[0x03] = b2[0x03] + b2[0x04];
- b1[0x04] = (b2[0x03] - b2[0x04]) * costab[3];
-
- b1[0x08] = b2[0x08] + b2[0x0F];
- b1[0x0F] = (b2[0x0F] - b2[0x08]) * costab[0];
- b1[0x09] = b2[0x09] + b2[0x0E];
- b1[0x0E] = (b2[0x0E] - b2[0x09]) * costab[1];
- b1[0x0A] = b2[0x0A] + b2[0x0D];
- b1[0x0D] = (b2[0x0D] - b2[0x0A]) * costab[2];
- b1[0x0B] = b2[0x0B] + b2[0x0C];
- b1[0x0C] = (b2[0x0C] - b2[0x0B]) * costab[3];
-
- b1[0x10] = b2[0x10] + b2[0x17];
- b1[0x17] = (b2[0x10] - b2[0x17]) * costab[0];
- b1[0x11] = b2[0x11] + b2[0x16];
- b1[0x16] = (b2[0x11] - b2[0x16]) * costab[1];
- b1[0x12] = b2[0x12] + b2[0x15];
- b1[0x15] = (b2[0x12] - b2[0x15]) * costab[2];
- b1[0x13] = b2[0x13] + b2[0x14];
- b1[0x14] = (b2[0x13] - b2[0x14]) * costab[3];
-
- b1[0x18] = b2[0x18] + b2[0x1F];
- b1[0x1F] = (b2[0x1F] - b2[0x18]) * costab[0];
- b1[0x19] = b2[0x19] + b2[0x1E];
- b1[0x1E] = (b2[0x1E] - b2[0x19]) * costab[1];
- b1[0x1A] = b2[0x1A] + b2[0x1D];
- b1[0x1D] = (b2[0x1D] - b2[0x1A]) * costab[2];
- b1[0x1B] = b2[0x1B] + b2[0x1C];
- b1[0x1C] = (b2[0x1C] - b2[0x1B]) * costab[3];
- }
-
- {
- register real const cos0 = mpg123_pnts[3][0];
- register real const cos1 = mpg123_pnts[3][1];
-
- b2[0x00] = b1[0x00] + b1[0x03];
- b2[0x03] = (b1[0x00] - b1[0x03]) * cos0;
- b2[0x01] = b1[0x01] + b1[0x02];
- b2[0x02] = (b1[0x01] - b1[0x02]) * cos1;
-
- b2[0x04] = b1[0x04] + b1[0x07];
- b2[0x07] = (b1[0x07] - b1[0x04]) * cos0;
- b2[0x05] = b1[0x05] + b1[0x06];
- b2[0x06] = (b1[0x06] - b1[0x05]) * cos1;
-
- b2[0x08] = b1[0x08] + b1[0x0B];
- b2[0x0B] = (b1[0x08] - b1[0x0B]) * cos0;
- b2[0x09] = b1[0x09] + b1[0x0A];
- b2[0x0A] = (b1[0x09] - b1[0x0A]) * cos1;
-
- b2[0x0C] = b1[0x0C] + b1[0x0F];
- b2[0x0F] = (b1[0x0F] - b1[0x0C]) * cos0;
- b2[0x0D] = b1[0x0D] + b1[0x0E];
- b2[0x0E] = (b1[0x0E] - b1[0x0D]) * cos1;
-
- b2[0x10] = b1[0x10] + b1[0x13];
- b2[0x13] = (b1[0x10] - b1[0x13]) * cos0;
- b2[0x11] = b1[0x11] + b1[0x12];
- b2[0x12] = (b1[0x11] - b1[0x12]) * cos1;
-
- b2[0x14] = b1[0x14] + b1[0x17];
- b2[0x17] = (b1[0x17] - b1[0x14]) * cos0;
- b2[0x15] = b1[0x15] + b1[0x16];
- b2[0x16] = (b1[0x16] - b1[0x15]) * cos1;
-
- b2[0x18] = b1[0x18] + b1[0x1B];
- b2[0x1B] = (b1[0x18] - b1[0x1B]) * cos0;
- b2[0x19] = b1[0x19] + b1[0x1A];
- b2[0x1A] = (b1[0x19] - b1[0x1A]) * cos1;
-
- b2[0x1C] = b1[0x1C] + b1[0x1F];
- b2[0x1F] = (b1[0x1F] - b1[0x1C]) * cos0;
- b2[0x1D] = b1[0x1D] + b1[0x1E];
- b2[0x1E] = (b1[0x1E] - b1[0x1D]) * cos1;
- }
-
- {
- register real const cos0 = mpg123_pnts[4][0];
-
- b1[0x00] = b2[0x00] + b2[0x01];
- b1[0x01] = (b2[0x00] - b2[0x01]) * cos0;
- b1[0x02] = b2[0x02] + b2[0x03];
- b1[0x03] = (b2[0x03] - b2[0x02]) * cos0;
- b1[0x02] += b1[0x03];
-
- b1[0x04] = b2[0x04] + b2[0x05];
- b1[0x05] = (b2[0x04] - b2[0x05]) * cos0;
- b1[0x06] = b2[0x06] + b2[0x07];
- b1[0x07] = (b2[0x07] - b2[0x06]) * cos0;
- b1[0x06] += b1[0x07];
- b1[0x04] += b1[0x06];
- b1[0x06] += b1[0x05];
- b1[0x05] += b1[0x07];
-
- b1[0x08] = b2[0x08] + b2[0x09];
- b1[0x09] = (b2[0x08] - b2[0x09]) * cos0;
- b1[0x0A] = b2[0x0A] + b2[0x0B];
- b1[0x0B] = (b2[0x0B] - b2[0x0A]) * cos0;
- b1[0x0A] += b1[0x0B];
-
- b1[0x0C] = b2[0x0C] + b2[0x0D];
- b1[0x0D] = (b2[0x0C] - b2[0x0D]) * cos0;
- b1[0x0E] = b2[0x0E] + b2[0x0F];
- b1[0x0F] = (b2[0x0F] - b2[0x0E]) * cos0;
- b1[0x0E] += b1[0x0F];
- b1[0x0C] += b1[0x0E];
- b1[0x0E] += b1[0x0D];
- b1[0x0D] += b1[0x0F];
-
- b1[0x10] = b2[0x10] + b2[0x11];
- b1[0x11] = (b2[0x10] - b2[0x11]) * cos0;
- b1[0x12] = b2[0x12] + b2[0x13];
- b1[0x13] = (b2[0x13] - b2[0x12]) * cos0;
- b1[0x12] += b1[0x13];
-
- b1[0x14] = b2[0x14] + b2[0x15];
- b1[0x15] = (b2[0x14] - b2[0x15]) * cos0;
- b1[0x16] = b2[0x16] + b2[0x17];
- b1[0x17] = (b2[0x17] - b2[0x16]) * cos0;
- b1[0x16] += b1[0x17];
- b1[0x14] += b1[0x16];
- b1[0x16] += b1[0x15];
- b1[0x15] += b1[0x17];
-
- b1[0x18] = b2[0x18] + b2[0x19];
- b1[0x19] = (b2[0x18] - b2[0x19]) * cos0;
- b1[0x1A] = b2[0x1A] + b2[0x1B];
- b1[0x1B] = (b2[0x1B] - b2[0x1A]) * cos0;
- b1[0x1A] += b1[0x1B];
-
- b1[0x1C] = b2[0x1C] + b2[0x1D];
- b1[0x1D] = (b2[0x1C] - b2[0x1D]) * cos0;
- b1[0x1E] = b2[0x1E] + b2[0x1F];
- b1[0x1F] = (b2[0x1F] - b2[0x1E]) * cos0;
- b1[0x1E] += b1[0x1F];
- b1[0x1C] += b1[0x1E];
- b1[0x1E] += b1[0x1D];
- b1[0x1D] += b1[0x1F];
- }
-
- out0[0x10 * 16] = b1[0x00];
- out0[0x10 * 12] = b1[0x04];
- out0[0x10 * 8] = b1[0x02];
- out0[0x10 * 4] = b1[0x06];
- out0[0x10 * 0] = b1[0x01];
- out1[0x10 * 0] = b1[0x01];
- out1[0x10 * 4] = b1[0x05];
- out1[0x10 * 8] = b1[0x03];
- out1[0x10 * 12] = b1[0x07];
-
- b1[0x08] += b1[0x0C];
- out0[0x10 * 14] = b1[0x08];
- b1[0x0C] += b1[0x0a];
- out0[0x10 * 10] = b1[0x0C];
- b1[0x0A] += b1[0x0E];
- out0[0x10 * 6] = b1[0x0A];
- b1[0x0E] += b1[0x09];
- out0[0x10 * 2] = b1[0x0E];
- b1[0x09] += b1[0x0D];
- out1[0x10 * 2] = b1[0x09];
- b1[0x0D] += b1[0x0B];
- out1[0x10 * 6] = b1[0x0D];
- b1[0x0B] += b1[0x0F];
- out1[0x10 * 10] = b1[0x0B];
- out1[0x10 * 14] = b1[0x0F];
-
- b1[0x18] += b1[0x1C];
- out0[0x10 * 15] = b1[0x10] + b1[0x18];
- out0[0x10 * 13] = b1[0x18] + b1[0x14];
- b1[0x1C] += b1[0x1a];
- out0[0x10 * 11] = b1[0x14] + b1[0x1C];
- out0[0x10 * 9] = b1[0x1C] + b1[0x12];
- b1[0x1A] += b1[0x1E];
- out0[0x10 * 7] = b1[0x12] + b1[0x1A];
- out0[0x10 * 5] = b1[0x1A] + b1[0x16];
- b1[0x1E] += b1[0x19];
- out0[0x10 * 3] = b1[0x16] + b1[0x1E];
- out0[0x10 * 1] = b1[0x1E] + b1[0x11];
- b1[0x19] += b1[0x1D];
- out1[0x10 * 1] = b1[0x11] + b1[0x19];
- out1[0x10 * 3] = b1[0x19] + b1[0x15];
- b1[0x1D] += b1[0x1B];
- out1[0x10 * 5] = b1[0x15] + b1[0x1D];
- out1[0x10 * 7] = b1[0x1D] + b1[0x13];
- b1[0x1B] += b1[0x1F];
- out1[0x10 * 9] = b1[0x13] + b1[0x1B];
- out1[0x10 * 11] = b1[0x1B] + b1[0x17];
- out1[0x10 * 13] = b1[0x17] + b1[0x1F];
- out1[0x10 * 15] = b1[0x1F];
-}
-
-/*
- * the call via mpg123_dct64 is a trick to force GCC to use
- * (new) registers for the b1,b2 pointer to the bufs[xx] field
- */
-void mpg123_dct64 (real * a, real * b, real * c)
-{
- real bufs[0x40];
-
- mpg123_dct64_1(a, b, bufs, bufs + 0x20, c);
-}
diff --git a/components/music/decode.c b/components/music/decode.c
deleted file mode 100644
index 9c766620a..000000000
--- a/components/music/decode.c
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Mpeg Layer-1,2,3 audio decoder
- * ------------------------------
- * copyright (c) 1995,1996,1997 by Michael Hipp, All rights reserved.
- * See also 'README'
- *
- */
-
-#include <stdlib.h>
-#include <math.h>
-#include <string.h>
-
-#include "mpg123.h"
-
-#define WRITE_SAMPLE(samples,sum,clip) \
- if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \
- else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \
- else { *(samples) = sum; }
-
-int mpg123_synth_1to1_8bit(real *bandPtr,int channel,unsigned char *samples,int *pnt)
-{
- short samples_tmp[64];
- short *tmp1 = samples_tmp + channel;
- int i,ret;
- int pnt1=0;
-
- ret = mpg123_synth_1to1(bandPtr,channel,(unsigned char *) samples_tmp,&pnt1);
- samples += channel + *pnt;
-
- for(i=0;i<32;i++) {
- *samples = mpg123_conv16to8[*tmp1>>AUSHIFT];
- samples += 2;
- tmp1 += 2;
- }
- *pnt += 64;
-
- return ret;
-}
-
-int mpg123_synth_1to1_8bit_mono(real *bandPtr,unsigned char *samples,int *pnt)
-{
- short samples_tmp[64];
- short *tmp1 = samples_tmp;
- int i,ret;
- int pnt1 = 0;
-
- ret = mpg123_synth_1to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1);
- samples += *pnt;
-
- for(i=0;i<32;i++) {
- *samples++ = mpg123_conv16to8[*tmp1>>AUSHIFT];
- tmp1 += 2;
- }
- *pnt += 32;
-
- return ret;
-}
-
-int mpg123_synth_1to1_8bit_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
-{
- short samples_tmp[64];
- short *tmp1 = samples_tmp;
- int i,ret;
- int pnt1 = 0;
-
- ret = mpg123_synth_1to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1);
- samples += *pnt;
-
- for(i=0;i<32;i++) {
- *samples++ = mpg123_conv16to8[*tmp1>>AUSHIFT];
- *samples++ = mpg123_conv16to8[*tmp1>>AUSHIFT];
- tmp1 += 2;
- }
- *pnt += 64;
-
- return ret;
-}
-
-int mpg123_synth_1to1_mono(real *bandPtr,unsigned char *samples,int *pnt)
-{
- short samples_tmp[64];
- short *tmp1 = samples_tmp;
- int i,ret;
- int pnt1 = 0;
-
- ret = mpg123_synth_1to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1);
- samples += *pnt;
-
- for(i=0;i<32;i++) {
- *( (short *)samples) = *tmp1;
- samples += 2;
- tmp1 += 2;
- }
- *pnt += 64;
-
- return ret;
-}
-
-
-int mpg123_synth_1to1_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
-{
- int i,ret;
-
- ret = mpg123_synth_1to1(bandPtr,0,samples,pnt);
- samples = samples + *pnt - 128;
-
- for(i=0;i<32;i++) {
- ((short *)samples)[1] = ((short *)samples)[0];
- samples+=4;
- }
-
- return ret;
-}
-
-
-int mpg123_synth_1to1(real *bandPtr,int channel,unsigned char *out,int *pnt)
-{
- static real buffs[2][2][0x110];
- static const int step = 2;
- static int bo = 1;
- short *samples = (short *) (out+*pnt);
-
- real *b0,(*buf)[0x110];
- int clip = 0;
- int bo1;
-
- /*if(equalfile)
- do_equalizer(bandPtr,channel);*/
-
- if(!channel) {
- bo--;
- bo &= 0xf;
- buf = buffs[0];
- }
- else {
- samples++;
- buf = buffs[1];
- }
-
- if(bo & 0x1) {
- b0 = buf[0];
- bo1 = bo;
- mpg123_dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr);
- }
- else {
- b0 = buf[1];
- bo1 = bo+1;
- mpg123_dct64(buf[0]+bo,buf[1]+bo+1,bandPtr);
- }
-
-
- {
- register int j;
- real *window = mpg123_decwin + 16 - bo1;
-
- for (j=16;j;j--,window+=0x10,samples+=step)
- {
- real sum;
- sum = *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
-
- WRITE_SAMPLE(samples,sum,clip);
- }
-
- {
- real sum;
- sum = window[0x0] * b0[0x0];
- sum += window[0x2] * b0[0x2];
- sum += window[0x4] * b0[0x4];
- sum += window[0x6] * b0[0x6];
- sum += window[0x8] * b0[0x8];
- sum += window[0xA] * b0[0xA];
- sum += window[0xC] * b0[0xC];
- sum += window[0xE] * b0[0xE];
- WRITE_SAMPLE(samples,sum,clip);
- b0-=0x10,window-=0x20,samples+=step;
- }
- window += bo1<<1;
-
- for (j=15;j;j--,b0-=0x20,window-=0x10,samples+=step)
- {
- real sum;
- sum = -*(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
-
- WRITE_SAMPLE(samples,sum,clip);
- }
- }
-
- *pnt += 128;
-
- return clip;
-}
-
-
diff --git a/components/music/decode_2to1.c b/components/music/decode_2to1.c
deleted file mode 100644
index 28448d49e..000000000
--- a/components/music/decode_2to1.c
+++ /dev/null
@@ -1,247 +0,0 @@
-
-/*
- * Mpeg Layer-1,2,3 audio decoder
- * ------------------------------
- * copyright (c) 1995 by Michael Hipp, All rights reserved. See also 'README'
- * version for slower machines .. decodes only every second sample
- * sounds like 24000,22050 or 16000 kHz .. (depending on original sample freq.)
- *
- */
-
-#include <stdlib.h>
-#include <math.h>
-#include <string.h>
-
-#include "mpg123.h"
-
-#define WRITE_SAMPLE(samples,sum,clip) \
- if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \
- else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \
- else { *(samples) = sum; }
-
-int mpg123_synth_2to1_8bit(real * bandPtr, int channel, unsigned char *samples, int *pnt)
-{
- short samples_tmp[32];
- short *tmp1 = samples_tmp + channel;
- int i, ret;
- int pnt1 = 0;
-
- ret = mpg123_synth_2to1(bandPtr, channel, (unsigned char *) samples_tmp, &pnt1);
- samples += channel + *pnt;
-
- for (i = 0; i < 16; i++)
- {
- *samples = (*tmp1 >> 8) ^ 128;
- samples += 2;
- tmp1 += 2;
- }
- *pnt += 32;
-
- return ret;
-}
-
-int mpg123_synth_2to1_8bit_mono(real * bandPtr, unsigned char *samples, int *pnt)
-{
- short samples_tmp[32];
- short *tmp1 = samples_tmp;
- int i, ret;
- int pnt1 = 0;
-
- ret = mpg123_synth_2to1(bandPtr, 0, (unsigned char *) samples_tmp, &pnt1);
- samples += *pnt;
-
- for (i = 0; i < 16; i++)
- {
- *samples++ = (*tmp1 >> 8) ^ 128;
- tmp1 += 2;
- }
- *pnt += 16;
-
- return ret;
-}
-
-int mpg123_synth_2to1_8bit_mono2stereo(real * bandPtr, unsigned char *samples, int *pnt)
-{
- short samples_tmp[32];
- short *tmp1 = samples_tmp;
- int i, ret;
- int pnt1 = 0;
-
- ret = mpg123_synth_2to1(bandPtr, 0, (unsigned char *) samples_tmp, &pnt1);
- samples += *pnt;
-
- for (i = 0; i < 16; i++)
- {
- *samples++ = (*tmp1 >> 8) ^ 128;
- *samples++ = (*tmp1 >> 8) ^ 128;
- tmp1 += 2;
- }
- *pnt += 32;
-
- return ret;
-}
-
-int mpg123_synth_2to1_mono(real * bandPtr, unsigned char *samples, int *pnt)
-{
- short samples_tmp[32];
- short *tmp1 = samples_tmp;
- int i, ret;
- int pnt1 = 0;
-
- ret = mpg123_synth_2to1(bandPtr, 0, (unsigned char *) samples_tmp, &pnt1);
- samples += *pnt;
-
- for (i = 0; i < 16; i++)
- {
- *((short *) samples) = *tmp1;
- samples += 2;
- tmp1 += 2;
- }
- *pnt += 32;
-
- return ret;
-}
-
-int mpg123_synth_2to1_mono2stereo(real * bandPtr, unsigned char *samples, int *pnt)
-{
- int i, ret;
-
- ret = mpg123_synth_2to1(bandPtr, 0, samples, pnt);
- samples = samples + *pnt - 64;
-
- for (i = 0; i < 16; i++)
- {
- ((short *) samples)[1] = ((short *) samples)[0];
- samples += 4;
- }
-
- return ret;
-}
-
-int mpg123_synth_2to1(real * bandPtr, int channel, unsigned char *out, int *pnt)
-{
- static real buffs[2][2][0x110];
- static const int step = 2;
- static int bo = 1;
- short *samples = (short *) (out + *pnt);
-
- real *b0, (*buf)[0x110];
- int clip = 0;
- int bo1;
-
-/* if(param.equalizer)
- do_equalizer(bandPtr,channel); */
-
- if (!channel)
- {
- bo--;
- bo &= 0xf;
- buf = buffs[0];
- }
- else
- {
- samples++;
- buf = buffs[1];
- }
-
- if (bo & 0x1)
- {
- b0 = buf[0];
- bo1 = bo;
- mpg123_dct64(buf[1] + ((bo + 1) & 0xf), buf[0] + bo, bandPtr);
- }
- else
- {
- b0 = buf[1];
- bo1 = bo + 1;
- mpg123_dct64(buf[0] + bo, buf[1] + bo + 1, bandPtr);
- }
-
- {
- register int j;
- real *window = mpg123_decwin + 16 - bo1;
-
- for (j = 8; j; j--, b0 += 0x10, window += 0x30)
- {
- real sum;
-
- sum = *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
-
- WRITE_SAMPLE(samples, sum, clip);
- samples += step;
-#if 0
- WRITE_SAMPLE(samples, sum, clip);
- samples += step;
-#endif
- }
-
- {
- real sum;
-
- sum = window[0x0] * b0[0x0];
- sum += window[0x2] * b0[0x2];
- sum += window[0x4] * b0[0x4];
- sum += window[0x6] * b0[0x6];
- sum += window[0x8] * b0[0x8];
- sum += window[0xA] * b0[0xA];
- sum += window[0xC] * b0[0xC];
- sum += window[0xE] * b0[0xE];
- WRITE_SAMPLE(samples, sum, clip);
- samples += step;
-#if 0
- WRITE_SAMPLE(samples, sum, clip);
- samples += step;
-#endif
- b0 -= 0x20, window -= 0x40;
- }
- window += bo1 << 1;
-
- for (j = 7; j; j--, b0 -= 0x30, window -= 0x30)
- {
- real sum;
-
- sum = -*(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
-
- WRITE_SAMPLE(samples, sum, clip);
- samples += step;
-#if 0
- WRITE_SAMPLE(samples, sum, clip);
- samples += step;
-#endif
- }
- }
-
- *pnt += 64;
-
- return clip;
-}
diff --git a/components/music/decode_4to1.c b/components/music/decode_4to1.c
deleted file mode 100644
index 85ed16c90..000000000
--- a/components/music/decode_4to1.c
+++ /dev/null
@@ -1,260 +0,0 @@
-
-/*
- * Mpeg Layer-1,2,3 audio decoder
- * ------------------------------
- * copyright (c) 1995,1996,1997 by Michael Hipp, All rights reserved.
- * See also 'README'
- * version for slower machines .. decodes only every fourth sample
- * dunno why it sounds THIS annoying (maybe we should adapt the window?)
- * absolutely not optimized for this operation
- */
-
-#include <stdlib.h>
-#include <math.h>
-#include <string.h>
-
-#include "mpg123.h"
-
-#define WRITE_SAMPLE(samples,sum,clip) \
- if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \
- else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \
- else { *(samples) = sum; }
-
-int mpg123_synth_4to1_8bit(real * bandPtr, int channel, unsigned char *samples, int *pnt)
-{
- short samples_tmp[16];
- short *tmp1 = samples_tmp + channel;
- int i, ret;
- int pnt1 = 0;
-
- ret = mpg123_synth_4to1(bandPtr, channel, (unsigned char *) samples_tmp, &pnt1);
- samples += channel + *pnt;
-
- for (i = 0; i < 8; i++)
- {
- *samples = (*tmp1 >> 8) ^ 128;
- samples += 2;
- tmp1 += 2;
- }
- *pnt += 16;
-
- return ret;
-}
-
-int mpg123_synth_4to1_8bit_mono(real * bandPtr, unsigned char *samples, int *pnt)
-{
- short samples_tmp[16];
- short *tmp1 = samples_tmp;
- int i, ret;
- int pnt1 = 0;
-
- ret = mpg123_synth_4to1(bandPtr, 0, (unsigned char *) samples_tmp, &pnt1);
- samples += *pnt;
-
- for (i = 0; i < 8; i++)
- {
- *samples++ = (*tmp1 >> 8) ^ 128;
- tmp1 += 2;
- }
- *pnt += 8;
-
- return ret;
-}
-
-int mpg123_synth_4to1_8bit_mono2stereo(real * bandPtr, unsigned char *samples, int *pnt)
-{
- short samples_tmp[16];
- short *tmp1 = samples_tmp;
- int i, ret;
- int pnt1 = 0;
-
- ret = mpg123_synth_4to1(bandPtr, 0, (unsigned char *) samples_tmp, &pnt1);
- samples += *pnt;
-
- for (i = 0; i < 8; i++)
- {
- *samples++ = (*tmp1 >> 8) ^ 128;
- *samples++ = (*tmp1 >> 8) ^ 128;
- tmp1 += 2;
- }
- *pnt += 16;
-
- return ret;
-}
-
-int mpg123_synth_4to1_mono(real * bandPtr, unsigned char *samples, int *pnt)
-{
- short samples_tmp[16];
- short *tmp1 = samples_tmp;
- int i, ret;
- int pnt1 = 0;
-
- ret = mpg123_synth_4to1(bandPtr, 0, (unsigned char *) samples_tmp, &pnt1);
- samples += *pnt;
-
- for (i = 0; i < 8; i++)
- {
- *((short *) samples) = *tmp1;
- samples += 2;
- tmp1 += 2;
- }
- *pnt += 16;
-
- return ret;
-}
-
-int mpg123_synth_4to1_mono2stereo(real * bandPtr, unsigned char *samples, int *pnt)
-{
- int i, ret;
-
- ret = mpg123_synth_4to1(bandPtr, 0, samples, pnt);
- samples = samples + *pnt - 32;
-
- for (i = 0; i < 8; i++)
- {
- ((short *) samples)[1] = ((short *) samples)[0];
- samples += 4;
- }
-
- return ret;
-}
-
-int mpg123_synth_4to1(real * bandPtr, int channel, unsigned char *out, int *pnt)
-{
- static real buffs[2][2][0x110];
- static const int step = 2;
- static int bo = 1;
- short *samples = (short *) (out + *pnt);
-
- real *b0, (*buf)[0x110];
- int clip = 0;
- int bo1;
-
-/* if(param.equalizer)
- do_equalizer(bandPtr,channel); */
-
- if (!channel)
- {
- bo--;
- bo &= 0xf;
- buf = buffs[0];
- }
- else
- {
- samples++;
- buf = buffs[1];
- }
-
- if (bo & 0x1)
- {
- b0 = buf[0];
- bo1 = bo;
- mpg123_dct64(buf[1] + ((bo + 1) & 0xf), buf[0] + bo, bandPtr);
- }
- else
- {
- b0 = buf[1];
- bo1 = bo + 1;
- mpg123_dct64(buf[0] + bo, buf[1] + bo + 1, bandPtr);
- }
-
- {
- register int j;
- real *window = mpg123_decwin + 16 - bo1;
-
- for (j = 4; j; j--, b0 += 0x30, window += 0x70)
- {
- real sum;
-
- sum = *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
-
- WRITE_SAMPLE(samples, sum, clip);
- samples += step;
-#if 0
- WRITE_SAMPLE(samples, sum, clip);
- samples += step;
- WRITE_SAMPLE(samples, sum, clip);
- samples += step;
- WRITE_SAMPLE(samples, sum, clip);
- samples += step;
-#endif
- }
-
- {
- real sum;
-
- sum = window[0x0] * b0[0x0];
- sum += window[0x2] * b0[0x2];
- sum += window[0x4] * b0[0x4];
- sum += window[0x6] * b0[0x6];
- sum += window[0x8] * b0[0x8];
- sum += window[0xA] * b0[0xA];
- sum += window[0xC] * b0[0xC];
- sum += window[0xE] * b0[0xE];
- WRITE_SAMPLE(samples, sum, clip);
- samples += step;
-#if 0
- WRITE_SAMPLE(samples, sum, clip);
- samples += step;
- WRITE_SAMPLE(samples, sum, clip);
- samples += step;
- WRITE_SAMPLE(samples, sum, clip);
- samples += step;
-#endif
- b0 -= 0x40, window -= 0x80;
- }
- window += bo1 << 1;
-
- for (j = 3; j; j--, b0 -= 0x50, window -= 0x70)
- {
- real sum;
-
- sum = -*(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
-
- WRITE_SAMPLE(samples, sum, clip);
- samples += step;
-#if 0
- WRITE_SAMPLE(samples, sum, clip);
- samples += step;
- WRITE_SAMPLE(samples, sum, clip);
- samples += step;
- WRITE_SAMPLE(samples, sum, clip);
- samples += step;
-#endif
- }
- }
-
- *pnt += 32;
-
- return clip;
-}
diff --git a/components/music/decode_i386.c b/components/music/decode_i386.c
deleted file mode 100644
index 172f9dc65..000000000
--- a/components/music/decode_i386.c
+++ /dev/null
@@ -1,257 +0,0 @@
-
-/*
- * Mpeg Layer-1,2,3 audio decoder
- * ------------------------------
- * copyright (c) 1995,1996,1997 by Michael Hipp, All rights reserved.
- * See also 'README'
- *
- * slighlty optimized for machines without autoincrement/decrement.
- * The performance is highly compiler dependend. Maybe
- * the decode.c version for 'normal' processor may be faster
- * even for Intel processors.
- */
-
-#include <stdlib.h>
-#include <math.h>
-#include <string.h>
-
-#include "mpg123.h"
-
-#if 0
- /* old WRITE_SAMPLE */
-#define WRITE_SAMPLE(samples,sum,clip) \
- if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \
- else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \
- else { *(samples) = sum; }
-#else
- /* new WRITE_SAMPLE */
-#define WRITE_SAMPLE(samples,sum,clip) { \
- double dtemp; int v; /* sizeof(int) == 4 */ \
- dtemp = ((((65536.0 * 65536.0 * 16)+(65536.0 * 0.5))* 65536.0)) + (sum); \
- v = ((*(int *)&dtemp) - 0x80000000); \
- if( v > 32767) { *(samples) = 0x7fff; (clip)++; } \
- else if( v < -32768) { *(samples) = -0x8000; (clip)++; } \
- else { *(samples) = v; } \
-}
-#endif
-
-int mpg123_synth_1to1_8bit(real * bandPtr, int channel, unsigned char *samples, int *pnt)
-{
- short samples_tmp[64];
- short *tmp1 = samples_tmp + channel;
- int i, ret;
- int pnt1 = 0;
-
- ret = mpg123_synth_1to1(bandPtr, channel, (unsigned char *) samples_tmp, &pnt1);
- samples += channel + *pnt;
-
- for (i = 0; i < 32; i++)
- {
- *samples = (*tmp1 >> 8) ^ 128;
- samples += 2;
- tmp1 += 2;
- }
- *pnt += 64;
-
- return ret;
-}
-
-int mpg123_synth_1to1_8bit_mono(real * bandPtr, unsigned char *samples, int *pnt)
-{
- short samples_tmp[64];
- short *tmp1 = samples_tmp;
- int i, ret;
- int pnt1 = 0;
-
- ret = mpg123_synth_1to1(bandPtr, 0, (unsigned char *) samples_tmp, &pnt1);
- samples += *pnt;
-
- for (i = 0; i < 32; i++)
- {
- *samples++ = (*tmp1 >> 8) ^ 128;
- tmp1 += 2;
- }
- *pnt += 32;
-
- return ret;
-}
-
-int mpg123_synth_1to1_8bit_mono2stereo(real * bandPtr, unsigned char *samples, int *pnt)
-{
- short samples_tmp[64];
- short *tmp1 = samples_tmp;
- int i, ret;
- int pnt1 = 0;
-
- ret = mpg123_synth_1to1(bandPtr, 0, (unsigned char *) samples_tmp, &pnt1);
- samples += *pnt;
-
- for (i = 0; i < 32; i++)
- {
- *samples++ = (*tmp1 >> 8) ^ 128;
- *samples++ = (*tmp1 >> 8) ^ 128;
- tmp1 += 2;
- }
- *pnt += 64;
-
- return ret;
-}
-
-int mpg123_synth_1to1_mono(real * bandPtr, unsigned char *samples, int *pnt)
-{
- short samples_tmp[64];
- short *tmp1 = samples_tmp;
- int i, ret;
- int pnt1 = 0;
-
- ret = mpg123_synth_1to1(bandPtr, 0, (unsigned char *) samples_tmp, &pnt1);
- samples += *pnt;
-
- for (i = 0; i < 32; i++)
- {
- *((short *) samples) = *tmp1;
- samples += 2;
- tmp1 += 2;
- }
- *pnt += 64;
-
- return ret;
-}
-
-int mpg123_synth_1to1_mono2stereo(real * bandPtr, unsigned char *samples, int *pnt)
-{
- int i, ret;
-
- ret = mpg123_synth_1to1(bandPtr, 0, samples, pnt);
- samples = samples + *pnt - 128;
-
- for (i = 0; i < 32; i++)
- {
- ((short *) samples)[1] = ((short *) samples)[0];
- samples += 4;
- }
-
- return ret;
-}
-
-int mpg123_synth_1to1(real * bandPtr, int channel, unsigned char *out, int *pnt)
-{
-#if 1
- static real buffs[2][2][0x110];
- static const int step = 2;
- static int bo = 1;
- short *samples = (short *) (out + *pnt);
-
- real *b0, (*buf)[0x110];
- int clip = 0;
- int bo1;
-
-#endif
-
-#if 1
- if (!channel)
- {
- bo--;
- bo &= 0xf;
- buf = buffs[0];
- }
- else
- {
- samples++;
- buf = buffs[1];
- }
-
- if (bo & 0x1)
- {
- b0 = buf[0];
- bo1 = bo;
- mpg123_dct64(buf[1] + ((bo + 1) & 0xf), buf[0] + bo, bandPtr);
- }
- else
- {
- b0 = buf[1];
- bo1 = bo + 1;
- mpg123_dct64(buf[0] + bo, buf[1] + bo + 1, bandPtr);
- }
-
- {
- register int j;
- real *window = mpg123_decwin + 16 - bo1;
-
- for (j = 16; j; j--, b0 += 0x10, window += 0x20, samples += step)
- {
- real sum;
-
- sum = window[0x0] * b0[0x0];
- sum -= window[0x1] * b0[0x1];
- sum += window[0x2] * b0[0x2];
- sum -= window[0x3] * b0[0x3];
- sum += window[0x4] * b0[0x4];
- sum -= window[0x5] * b0[0x5];
- sum += window[0x6] * b0[0x6];
- sum -= window[0x7] * b0[0x7];
- sum += window[0x8] * b0[0x8];
- sum -= window[0x9] * b0[0x9];
- sum += window[0xA] * b0[0xA];
- sum -= window[0xB] * b0[0xB];
- sum += window[0xC] * b0[0xC];
- sum -= window[0xD] * b0[0xD];
- sum += window[0xE] * b0[0xE];
- sum -= window[0xF] * b0[0xF];
-
- WRITE_SAMPLE(samples, sum, clip);
- }
-
- {
- real sum;
-
- sum = window[0x0] * b0[0x0];
- sum += window[0x2] * b0[0x2];
- sum += window[0x4] * b0[0x4];
- sum += window[0x6] * b0[0x6];
- sum += window[0x8] * b0[0x8];
- sum += window[0xA] * b0[0xA];
- sum += window[0xC] * b0[0xC];
- sum += window[0xE] * b0[0xE];
- WRITE_SAMPLE(samples, sum, clip);
- b0 -= 0x10, window -= 0x20, samples += step;
- }
- window += bo1 << 1;
-
- for (j = 15; j; j--, b0 -= 0x10, window -= 0x20, samples += step)
- {
- real sum;
-
- sum = -window[-0x1] * b0[0x0];
- sum -= window[-0x2] * b0[0x1];
- sum -= window[-0x3] * b0[0x2];
- sum -= window[-0x4] * b0[0x3];
- sum -= window[-0x5] * b0[0x4];
- sum -= window[-0x6] * b0[0x5];
- sum -= window[-0x7] * b0[0x6];
- sum -= window[-0x8] * b0[0x7];
- sum -= window[-0x9] * b0[0x8];
- sum -= window[-0xA] * b0[0x9];
- sum -= window[-0xB] * b0[0xA];
- sum -= window[-0xC] * b0[0xB];
- sum -= window[-0xD] * b0[0xC];
- sum -= window[-0xE] * b0[0xD];
- sum -= window[-0xF] * b0[0xE];
- sum -= window[-0x0] * b0[0xF];
-
- WRITE_SAMPLE(samples, sum, clip);
- }
- }
- *pnt += 128;
-
- return clip;
-#else
- {
- int ret;
-
- ret = mpg123_synth_1to1_pent(bandPtr, channel, out + *pnt);
- *pnt += 128;
- return ret;
- }
-#endif
-}
diff --git a/components/music/decode_ntom.c b/components/music/decode_ntom.c
deleted file mode 100644
index 2a4e4177b..000000000
--- a/components/music/decode_ntom.c
+++ /dev/null
@@ -1,301 +0,0 @@
-
-/*
- * Mpeg Layer-1,2,3 audio decoder
- * ------------------------------
- * copyright (c) 1995,1996,1997 by Michael Hipp, All rights reserved.
- * See also 'README'
- *
- * N->M down/up sampling. Not optimized for speed.
- */
-
-#include <stdlib.h>
-#include <math.h>
-#include <string.h>
-
-#include "mpg123.h"
-
-#define WRITE_SAMPLE(samples,sum,clip) \
- if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \
- else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \
- else { *(samples) = sum; }
-
-#define NTOM_MUL (32768)
-static unsigned long ntom_val[2] =
-{NTOM_MUL >> 1, NTOM_MUL >> 1};
-static unsigned long ntom_step = NTOM_MUL;
-
-void mpg123_synth_ntom_set_step(long m, long n)
-{
-/* if(param.verbose > 1)
- fprintf(stderr,"Init rate converter: %ld->%ld\n",m,n); */
-
- if (n >= 96000 || m >= 96000 || m == 0 || n == 0)
- {
-/* fprintf(stderr,"NtoM converter: illegal rates\n");
- exit(1); */
- }
-
- n *= NTOM_MUL;
- ntom_step = n / m;
-
- if (ntom_step > 8 * NTOM_MUL)
- {
-/* fprintf(stderr,"max. 1:8 conversion allowed!\n");
- exit(1); */
- }
-
- ntom_val[0] = ntom_val[1] = NTOM_MUL >> 1;
-}
-
-int mpg123_synth_ntom_8bit(real * bandPtr, int channel, unsigned char *samples, int *pnt)
-{
- short samples_tmp[8 * 64];
- short *tmp1 = samples_tmp + channel;
- int i, ret;
- int pnt1 = 0;
-
- ret = mpg123_synth_ntom(bandPtr, channel, (unsigned char *) samples_tmp, &pnt1);
- samples += channel + *pnt;
-
- for (i = 0; i < (pnt1 >> 2); i++)
- {
- *samples = (*tmp1 >> 8) ^ 128;
- samples += 2;
- tmp1 += 2;
- }
- *pnt += pnt1 >> 1;
-
- return ret;
-}
-
-int mpg123_synth_ntom_8bit_mono(real * bandPtr, unsigned char *samples, int *pnt)
-{
- short samples_tmp[8 * 64];
- short *tmp1 = samples_tmp;
- int i, ret;
- int pnt1 = 0;
-
- ret = mpg123_synth_ntom(bandPtr, 0, (unsigned char *) samples_tmp, &pnt1);
- samples += *pnt;
-
- for (i = 0; i < (pnt1 >> 21); i++)
- {
- *samples++ = (*tmp1 >> 8) ^ 128;
- tmp1 += 2;
- }
- *pnt += pnt1 >> 2;
-
- return ret;
-}
-
-int mpg123_synth_ntom_8bit_mono2stereo(real * bandPtr, unsigned char *samples, int *pnt)
-{
- short samples_tmp[8 * 64];
- short *tmp1 = samples_tmp;
- int i, ret;
- int pnt1 = 0;
-
- ret = mpg123_synth_ntom(bandPtr, 0, (unsigned char *) samples_tmp, &pnt1);
- samples += *pnt;
-
- for (i = 0; i < (pnt1 >> 2); i++)
- {
- *samples++ = (*tmp1 >> 8) ^ 128;
- *samples++ = (*tmp1 >> 8) ^ 128;
- tmp1 += 2;
- }
- *pnt += pnt1 >> 1;
-
- return ret;
-}
-
-int mpg123_synth_ntom_mono(real * bandPtr, unsigned char *samples, int *pnt)
-{
- short samples_tmp[8 * 64];
- short *tmp1 = samples_tmp;
- int i, ret;
- int pnt1 = 0;
-
- ret = mpg123_synth_ntom(bandPtr, 0, (unsigned char *) samples_tmp, &pnt1);
- samples += *pnt;
-
- for (i = 0; i < (pnt1 >> 2); i++)
- {
- *((short *) samples) = *tmp1;
- samples += 2;
- tmp1 += 2;
- }
- *pnt += pnt1 >> 1;
-
- return ret;
-}
-
-int mpg123_synth_ntom_mono2stereo(real * bandPtr, unsigned char *samples, int *pnt)
-{
- int i, ret;
- int pnt1 = *pnt;
-
- ret = mpg123_synth_ntom(bandPtr, 0, samples, pnt);
- samples += pnt1;
-
- for (i = 0; i < ((*pnt - pnt1) >> 2); i++)
- {
- ((short *) samples)[1] = ((short *) samples)[0];
- samples += 4;
- }
-
- return ret;
-}
-
-int mpg123_synth_ntom(real * bandPtr, int channel, unsigned char *out, int *pnt)
-{
- static real buffs[2][2][0x110];
- static const int step = 2;
- static int bo = 1;
- short *samples = (short *) (out + *pnt);
-
- real *b0, (*buf)[0x110];
- int clip = 0;
- int bo1;
- int ntom;
-
-/* if(param.equalizer)
- do_equalizer(bandPtr,channel); */
-
- if (!channel)
- {
- bo--;
- bo &= 0xf;
- buf = buffs[0];
- ntom = ntom_val[1] = ntom_val[0];
- }
- else
- {
- samples++;
- out += 2; /* to compute the right *pnt value */
- buf = buffs[1];
- ntom = ntom_val[1];
- }
-
- if (bo & 0x1)
- {
- b0 = buf[0];
- bo1 = bo;
- mpg123_dct64(buf[1] + ((bo + 1) & 0xf), buf[0] + bo, bandPtr);
- }
- else
- {
- b0 = buf[1];
- bo1 = bo + 1;
- mpg123_dct64(buf[0] + bo, buf[1] + bo + 1, bandPtr);
- }
-
- {
- register int j;
- real *window = mpg123_decwin + 16 - bo1;
-
- for (j = 16; j; j--, window += 0x10)
- {
- real sum;
-
- ntom += ntom_step;
- if (ntom < NTOM_MUL)
- {
- window += 16;
- b0 += 16;
- continue;
- }
-
- sum = *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
- sum += *window++ * *b0++;
- sum -= *window++ * *b0++;
-
- while (ntom >= NTOM_MUL)
- {
- WRITE_SAMPLE(samples, sum, clip);
- samples += step;
- ntom -= NTOM_MUL;
- }
- }
-
- ntom += ntom_step;
- if (ntom >= NTOM_MUL)
- {
- real sum;
-
- sum = window[0x0] * b0[0x0];
- sum += window[0x2] * b0[0x2];
- sum += window[0x4] * b0[0x4];
- sum += window[0x6] * b0[0x6];
- sum += window[0x8] * b0[0x8];
- sum += window[0xA] * b0[0xA];
- sum += window[0xC] * b0[0xC];
- sum += window[0xE] * b0[0xE];
-
- while (ntom >= NTOM_MUL)
- {
- WRITE_SAMPLE(samples, sum, clip);
- samples += step;
- ntom -= NTOM_MUL;
- }
- }
-
- b0 -= 0x10, window -= 0x20;
- window += bo1 << 1;
-
- for (j = 15; j; j--, b0 -= 0x20, window -= 0x10)
- {
- real sum;
-
- ntom += ntom_step;
- if (ntom < NTOM_MUL)
- {
- window -= 16;
- b0 += 16;
- continue;
- }
-
- sum = -*(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
- sum -= *(--window) * *b0++;
-
- while (ntom >= NTOM_MUL)
- {
- WRITE_SAMPLE(samples, sum, clip);
- samples += step;
- ntom -= NTOM_MUL;
- }
- }
- }
-
- ntom_val[channel] = ntom;
- *pnt = ((unsigned char *) samples - out);
-
- return clip;
-}
diff --git a/components/music/dxhead.c b/components/music/dxhead.c
deleted file mode 100644
index e6e9269bf..000000000
--- a/components/music/dxhead.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/*---- DXhead.c --------------------------------------------
-
-
-decoder MPEG Layer III
-
-handle Xing header
-
-mod 12/7/98 add vbr scale
-
-Copyright 1998 Xing Technology Corp.
------------------------------------------------------------*/
-#include <stdlib.h>
-#include <stdio.h>
-#include <float.h>
-#include <math.h>
-#include "dxhead.h"
-
-/* 4 Xing
- * 4 flags
- * 4 frames
- * 4 bytes
- * 100 toc
- */
-
-/*-------------------------------------------------------------*/
-static int ExtractI4(unsigned char *buf)
-{
-
- int x;
-
-/* big endian extract */
-
- x = buf[0];
-
- x <<= 8;
-
- x |= buf[1];
-
- x <<= 8;
-
- x |= buf[2];
-
- x <<= 8;
-
- x |= buf[3];
-
-
- return x;
-
-}
-
-/*-------------------------------------------------------------*/
-int mpg123_get_xing_header(XHEADDATA * X, unsigned char *buf)
-{
-
- int i, head_flags;
-
- int h_id, h_mode, h_sr_index;
-
- static int sr_table[4] =
- {44100, 48000, 32000, 99999};
-
-
-/* get Xing header data */
-
-
- X->flags = 0; /* clear to null incase fail */
-
-
-
-/* get selected MPEG header data */
- h_id = (buf[1] >> 3) & 1;
-
- h_sr_index = (buf[2] >> 2) & 3;
-
- h_mode = (buf[3] >> 6) & 3;
-
-
-
-/* determine offset of header */
- if (h_id)
- { /* mpeg1 */
-
- if (h_mode != 3)
- buf += (32 + 4);
-
- else
- buf += (17 + 4);
-
- }
-
- else
- { /* mpeg2 */
-
- if (h_mode != 3)
- buf += (17 + 4);
-
- else
- buf += (9 + 4);
-
- }
-
-
- if (buf[0] != 'X')
- return 0; /* fail */
-
- if (buf[1] != 'i')
- return 0; /* header not found */
-
- if (buf[2] != 'n')
- return 0;
-
- if (buf[3] != 'g')
- return 0;
-
- buf += 4;
-
-
- X->h_id = h_id;
-
- X->samprate = sr_table[h_sr_index];
-
- if (h_id == 0)
- X->samprate >>= 1;
-
-
- head_flags = X->flags = ExtractI4(buf);
- buf += 4; /* get flags */
-
-
- if (head_flags & FRAMES_FLAG)
- {
- X->frames = ExtractI4(buf);
- buf += 4;
- }
-
- if (head_flags & BYTES_FLAG)
- {
- X->bytes = ExtractI4(buf);
- buf += 4;
- }
-
-
- if (head_flags & TOC_FLAG)
- {
-
- if (X->toc != NULL)
- {
-
- for (i = 0; i < 100; i++)
- X->toc[i] = buf[i];
-
- }
-
- buf += 100;
-
- }
-
-
- X->vbr_scale = -1;
-
- if (head_flags & VBR_SCALE_FLAG)
- {
- X->vbr_scale = ExtractI4(buf);
- buf += 4;
- }
-
-
-/*if( X->toc != NULL ) {
- *for(i=0;i<100;i++) {
- * if( (i%10) == 0 ) printf("\n");
- * printf(" %3d", (int)(X->toc[i]));
- *}
- *}
- */
-
- return 1; /* success */
-
-}
-
-/*-------------------------------------------------------------*/
-int mpg123_seek_point(unsigned char TOC[100], int file_bytes, float percent)
-{
-
-/* interpolate in TOC to get file seek point in bytes */
- int a, seekpoint;
-
- float fa, fb, fx;
-
-
-
- if (percent < 0.0f)
- percent = 0.0f;
-
- if (percent > 100.0f)
- percent = 100.0f;
-
-
- a = (int) percent;
-
- if (a > 99)
- a = 99;
-
- fa = TOC[a];
-
- if (a < 99)
- {
-
- fb = TOC[a + 1];
-
- }
-
- else
- {
-
- fb = 256.0f;
-
- }
-
-
-
- fx = fa + (fb - fa) * (percent - a);
-
-
- seekpoint = (int) ((1.0f / 256.0f) * fx * file_bytes);
-
-
-
- return seekpoint;
-
-}
-
-/*-------------------------------------------------------------*/
diff --git a/components/music/dxhead.h b/components/music/dxhead.h
deleted file mode 100644
index 0c88566ff..000000000
--- a/components/music/dxhead.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*---- DXhead.h --------------------------------------------
-
-
-decoder MPEG Layer III
-
-handle Xing header
-
-
-Copyright 1998 Xing Technology Corp.
------------------------------------------------------------*/
-/* A Xing header may be present in the ancillary
- * data field of the first frame of an mp3 bitstream
- * The Xing header (optionally) contains
- * frames total number of audio frames in the bitstream
- * bytes total number of bytes in the bitstream
- * toc table of contents
-
- * toc (table of contents) gives seek points
- * for random access
- * the ith entry determines the seek point for
- * i-percent duration
- * seek point in bytes = (toc[i]/256.0) * total_bitstream_bytes
- * e.g. half duration seek point = (toc[50]/256.0) * total_bitstream_bytes
- */
-
-#define FRAMES_FLAG 0x0001
-#define BYTES_FLAG 0x0002
-#define TOC_FLAG 0x0004
-#define VBR_SCALE_FLAG 0x0008
-
-#define FRAMES_AND_BYTES (FRAMES_FLAG | BYTES_FLAG)
-
-/* structure to receive extracted header
- * toc may be NULL
- */
-typedef struct
-{
-
- int h_id; /* from MPEG header, 0=MPEG2, 1=MPEG1 */
-
- int samprate; /* determined from MPEG header */
-
- int flags; /* from Xing header data */
-
- int frames; /* total bit stream frames from Xing header data */
-
- int bytes; /* total bit stream bytes from Xing header data */
-
- int vbr_scale; /* encoded vbr scale from Xing header data */
-
- unsigned char *toc; /* pointer to unsigned char toc_buffer[100] */
-
- /* may be NULL if toc not desired */
-}
-XHEADDATA;
-
-
-
-int mpg123_get_xing_header(XHEADDATA * X, unsigned char *buf);
-
-/* return 0=fail, 1=success
- * X structure to receive header data (output)
- * buf bitstream input
- */
-
-int mpg123_seek_point(unsigned char TOC[100], int file_bytes, float percent);
-
-/* return seekpoint in bytes (may be at eof if percent=100.0)
- * TOC = table of contents from Xing header
- * file_bytes = number of bytes in mp3 file
- * percent = play time percentage of total playtime. May be
- * fractional (e.g. 87.245)
- */
-
-
-
diff --git a/components/music/esd-audio.c b/components/music/esd-audio.c
deleted file mode 100644
index 7ab6e6fc4..000000000
--- a/components/music/esd-audio.c
+++ /dev/null
@@ -1,444 +0,0 @@
-
-#include <config.h>
-#include "esd-audio.h"
-
-#include <glib/gmem.h>
-#include <glib/gstrfuncs.h>
-#include <pthread.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-static gint fd = 0;
-static gpointer buffer;
-static gboolean going = FALSE, prebuffer, paused = FALSE, remove_prebuffer = FALSE;
-static gint buffer_size, prebuffer_size, blk_size = 4096;
-static gint rd_index = 0, wr_index = 0;
-static gint output_time_offset = 0;
-static guint64 written = 0, output_bytes = 0;
-static gint bps, ebps;
-static gint flush;
-static gint channels, frequency, latency;
-static AFormat format;
-static esd_format_t esd_format;
-static gint input_bps, input_format, input_frequency, input_channels;
-static gchar *hostname;
-static pthread_t buffer_thread;
-static void *(*esd_translate)(void *, gint);
-
-
-ESDConfig esd_cfg;
-esd_info_t *all_info;
-esd_player_info_t *player_info;
-
-static void
-esdout_init (void)
-{
- memset (&esd_cfg, 0, sizeof (ESDConfig));
- esd_cfg.port = ESD_DEFAULT_PORT;
- esd_cfg.buffer_size = 3000;
- esd_cfg.prebuffer = 25;
-}
-
-static gint
-get_latency(void)
-{
- int fd, amount = 0;
-
-#ifndef HAVE_ESD_GET_LATENCY
- esd_server_info_t *info;
-#endif
-
- fd = esd_open_sound (hostname);
- if (fd == -1) {
- return 0;
- }
-
-#ifdef HAVE_ESD_GET_LATENCY
- amount = esd_get_latency(fd);
-#else
- info = esd_get_server_info(fd);
- if (info) {
- if (info->format & ESD_STEREO) {
- if (info->format & ESD_BITS16)
- amount = (44100 * (ESD_BUF_SIZE + 64)) / info->rate;
- else
- amount = (44100 * (ESD_BUF_SIZE + 128)) / info->rate;
- } else {
- if (info->format & ESD_BITS16)
- amount = (2 * 44100 * (ESD_BUF_SIZE + 128)) / info->rate;
- else
- amount = (2 * 44100 * (ESD_BUF_SIZE + 256)) / info->rate;
- }
- free(info);
- }
- amount += ESD_BUF_SIZE * 2;
-#endif
- esd_close (fd);
- return amount;
-}
-
-static void *
-esd_stou8(void *data, gint length)
-{
- int len = length;
- unsigned char *dat = (unsigned char *)data;
- while (len-- > 0)
- *dat++ ^= 0x80;
- return data;
-}
-
-static void *esd_utos16sw(void *data, gint length)
-{
- int len = length;
- short *dat = data;
- while ( len > 0 ) {
- *dat = GUINT16_SWAP_LE_BE( *dat ) ^ 0x8000;
- dat++;
- len-=2;
- }
- return data;
-}
-
-static void *esd_utos16(void *data, gint length)
-{
- int len = length;
- short *dat = data;
- while ( len > 0 ) {
- *dat ^= 0x8000;
- dat++;
- len-=2;
- }
- return data;
-}
-
-static void *esd_16sw(void *data, gint length)
-{
- int len = length;
- short *dat = data;
- while ( len > 0 ) {
- *dat = GUINT16_SWAP_LE_BE( *dat );
- dat++;
- len-=2;
- }
- return data;
-}
-
-static void
-esdout_setup_format (AFormat fmt, gint rate, gint nch)
-{
- gboolean swap_sign = FALSE;
- gboolean swap_16 = FALSE;
-
- format = fmt;
- frequency = rate;
- channels = nch;
- switch (fmt)
- {
- case FMT_S8:
- swap_sign = TRUE;
- case FMT_U8:
- esd_format = ESD_BITS8;
- break;
- case FMT_U16_LE:
- case FMT_U16_BE:
- case FMT_U16_NE:
- swap_sign = TRUE;
- case FMT_S16_LE:
- case FMT_S16_BE:
- case FMT_S16_NE:
- esd_format = ESD_BITS16;
- break;
- }
-
-#ifdef WORDS_BIGENDIAN
- if (fmt == FMT_U16_LE || fmt == FMT_S16_LE)
-#else
- if (fmt == FMT_U16_BE || fmt == FMT_S16_BE)
-#endif
- swap_16 = TRUE;
-
- esd_translate = (void*(*)())NULL;
- if (esd_format == ESD_BITS8) {
- if (swap_sign == TRUE)
- esd_translate = esd_stou8;
- } else {
- if (swap_sign == TRUE) {
- if (swap_16 == TRUE)
- esd_translate = esd_utos16sw;
- else
- esd_translate = esd_utos16;
- } else {
- if (swap_16 == TRUE)
- esd_translate = esd_16sw;
- }
- }
-
- bps = rate * nch;
- if (esd_format == ESD_BITS16)
- bps *= 2;
- if(nch == 1)
- esd_format |= ESD_MONO;
- else
- esd_format |= ESD_STEREO;
- esd_format |= ESD_STREAM | ESD_PLAY;
-
- latency = ((get_latency() * frequency) / 44100) * channels;
- if (format != FMT_U8 && format != FMT_S8)
- latency *= 2;
-}
-
-
-gint
-esdout_get_written_time (void)
-{
- if (!going)
- return 0;
- return (gint) ((written * 1000) / input_bps);
-}
-
-gint
-esdout_get_output_time (void)
-{
- guint64 bytes;
-
- if (!fd || !going) {
- return 0;
- }
-
- bytes = output_bytes;
- if (!paused) {
- bytes -= (bytes < (guint64)latency ? bytes : (guint64)latency);
- }
-
- return output_time_offset + (gint) ((bytes * 1000) / ebps);
-}
-
-/* Returns the number of bytes in our buffer still to be sent to esd. */
-gint
-esdout_used (void)
-{
- if (wr_index >= rd_index) {
- return wr_index - rd_index;
- }
- return buffer_size - (rd_index - wr_index);
-}
-
-/* Returns TRUE if we can play a track, i.e. we can connect to esd. */
-int
-esdout_can_play (void)
-{
- int fd;
-
- fd = esd_open_sound (hostname);
- if (fd == -1) {
- return FALSE;
- }
- esd_close (fd);
-
- return TRUE;
-}
-
-/* Returns TRUE if we are playing a track, i.e. the thread is still streaming
- data to esd. */
-int
-esdout_playing (void)
-{
- /* If our thread is not streaming data to esd, return FALSE. */
- if (!going)
- return FALSE;
-
- /* If we've run out of data to send, we assume the track is done. */
- if (esdout_used () == 0)
- return FALSE;
-
- return TRUE;
-}
-
-gint
-esdout_free (void)
-{
- if (remove_prebuffer && prebuffer) {
- prebuffer = FALSE;
- remove_prebuffer = FALSE;
- }
-
- if (prebuffer) {
- remove_prebuffer = TRUE;
- }
-
- if (rd_index > wr_index) {
- return (rd_index - wr_index) - 1;
- }
-
- return (buffer_size - (wr_index - rd_index)) - 1;
-}
-
-static void
-esdout_write_audio (gpointer data, gint length)
-{
- AFormat new_format;
- gint new_frequency,new_channels;
-
- new_format = input_format;
- new_frequency = input_frequency;
- new_channels = input_channels;
-
- if (new_format != format || new_frequency != frequency || new_channels != channels) {
- output_time_offset += (gint) ((output_bytes * 1000) / ebps);
- output_bytes = 0;
- esdout_setup_format(new_format, new_frequency, new_channels);
- frequency = new_frequency;
- channels = new_channels;
- close(fd);
- esdout_set_audio_params();
- }
-
- if (esd_translate) {
- output_bytes += write(fd,esd_translate(data,length),length);
- } else {
- output_bytes += write(fd,data,length);
- }
-}
-
-
-void
-esdout_write (gpointer ptr, gint length)
-{
- gint cnt, off = 0;
-
- remove_prebuffer = FALSE;
-
- written += length;
- while (length > 0) {
- cnt = MIN(length, buffer_size - wr_index);
- memcpy((gchar *)buffer + wr_index, (gchar *)ptr + off, cnt);
- wr_index = (wr_index + cnt) % buffer_size;
- length -= cnt;
- off += cnt;
-
- }
-}
-
-void
-esdout_close (void)
-{
- if (!going) {
- return;
- }
-
- wr_index = 0;
- rd_index = 0;
- going = 0;
- g_free (hostname);
- hostname = NULL;
- pthread_join (buffer_thread, NULL);
-}
-
-void
-esdout_flush (gint time)
-{
- flush = time;
- while (flush != -1) {
- usleep(10000);
- }
-}
-
-void
-esdout_pause (gboolean p)
-{
- paused = p;
-}
-
-static void *
-esdout_loop (void *arg)
-{
- gint length, cnt;
-
- while (going) {
- if (esdout_used () > prebuffer_size) {
- prebuffer = FALSE;
- }
-
- if (esdout_used () > 0 && !paused && !prebuffer) {
- length = MIN (blk_size, esdout_used ());
- while (length > 0) {
- cnt = MIN(length,buffer_size-rd_index);
- esdout_write_audio ((gchar *)buffer + rd_index, cnt);
- rd_index=(rd_index+cnt)%buffer_size;
- length-=cnt;
- }
- } else {
- usleep (10000);
- }
-
- if (flush != -1) {
- output_time_offset = flush;
- written = (guint64)(flush / 10) * (guint64)(input_bps / 100);
- rd_index = wr_index = output_bytes = 0;
- flush = -1;
- prebuffer = TRUE;
- }
- }
-
- close (fd);
- g_free (buffer);
- pthread_exit (NULL);
- return NULL; /* make gcc happy */
-}
-
-void
-esdout_set_audio_params(void)
-{
- /* frequency = GUINT16_SWAP_LE_BE( frequency ); */
- fd = esd_play_stream (esd_format, frequency, hostname, "nautilus-music-view");
- ebps = frequency * channels;
- if (format == FMT_U16_BE || format == FMT_U16_LE || format == FMT_S16_BE || format == FMT_S16_LE || format == FMT_S16_NE || format == FMT_U16_NE)
- ebps *= 2;
-}
-
-gint
-esdout_open (AFormat fmt, gint rate, gint nch)
-{
- esdout_init ();
-
- esdout_setup_format (fmt,rate,nch);
-
- input_format = format;
- input_channels = channels;
- input_frequency = frequency;
- input_bps = bps;
-
- buffer_size = (esd_cfg.buffer_size * input_bps) / 1000;
- if (buffer_size < 8192)
- buffer_size = 8192;
- prebuffer_size = (buffer_size * esd_cfg.prebuffer) / 100;
- if (buffer_size - prebuffer_size < 4096)
- prebuffer_size = buffer_size - 4096;
-
- buffer = g_malloc0(buffer_size);
-
- flush = -1;
- prebuffer = 1;
- wr_index = rd_index = output_time_offset = written = output_bytes = 0;
- paused = FALSE;
- remove_prebuffer = FALSE;
-
- if (hostname)
- g_free (hostname);
- if (esd_cfg.use_remote)
- hostname = g_strdup_printf("%s:%d", esd_cfg.server, esd_cfg.port);
- else
- hostname = NULL;
-
- esdout_set_audio_params ();
- if (fd == -1) {
- g_free(buffer);
- return 0;
- }
- going = 1;
-
- pthread_create (&buffer_thread, NULL, esdout_loop, NULL);
-
- return 1;
-}
diff --git a/components/music/esd-audio.h b/components/music/esd-audio.h
deleted file mode 100644
index 15aabe777..000000000
--- a/components/music/esd-audio.h
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef ESD_AUDIO_H
-#define ESD_AUDIO_H
-
-#include <esd.h>
-#include <glib/gtypes.h>
-
-typedef struct {
- gboolean use_remote;
- char *server;
- int port;
- int buffer_size;
- int prebuffer;
-}
-ESDConfig;
-
-extern ESDConfig esd_cfg;
-
-typedef enum {
- FMT_U8,
- FMT_S8,
- FMT_U16_LE,
- FMT_U16_BE,
- FMT_U16_NE,
- FMT_S16_LE,
- FMT_S16_BE,
- FMT_S16_NE
-}
-AFormat;
-
-int esdout_open (AFormat fmt, int rate, int nch);
-void esdout_set_audio_params (void);
-int esdout_get_written_time (void);
-int esdout_used (void);
-int esdout_can_play (void);
-int esdout_playing (void);
-int esdout_free (void);
-void esdout_write (gpointer ptr, int length);
-void esdout_close (void);
-void esdout_flush (int time);
-void esdout_pause (gboolean p);
-int esdout_get_output_time (void);
-
-/* esd-mixer.c */
-void esdout_get_volume(int *l, int *r);
-void esdout_set_volume(int l, int r);
-
-#endif
-
-
-
diff --git a/components/music/esd-mixer.c b/components/music/esd-mixer.c
deleted file mode 100644
index a137eaa7a..000000000
--- a/components/music/esd-mixer.c
+++ /dev/null
@@ -1,78 +0,0 @@
-
-#include "config.h"
-#include "esd-audio.h"
-
-#include <sys/ioctl.h>
-#if defined(HAVE_SYS_SOUNDCARD_H)
-#include <sys/soundcard.h>
-#elif defined(HAVE_MACHINE_SOUNDCARD_H)
-#include <machine/soundcard.h>
-#endif
-
-void
-esdout_get_volume(int *l, int *r)
-{
-#if defined(HAVE_SYS_SOUNDCARD_H) || defined(HAVE_MACHINE_SOUNDCARD_H)
- int fd, v, cmd, devs;
-
- if (esd_cfg.use_remote)
- {
- *l = 100;
- *r = 100;
- return;
- }
-
- fd = open(DEV_MIXER, O_RDONLY);
- if (fd != -1)
- {
- ioctl(fd, SOUND_MIXER_READ_DEVMASK, &devs);
- if (devs & SOUND_MASK_PCM)
- cmd = SOUND_MIXER_READ_PCM;
- else if (devs & SOUND_MASK_VOLUME)
- cmd = SOUND_MIXER_READ_VOLUME;
- else
- {
- close(fd);
- return;
- }
- ioctl(fd, cmd, &v);
- *r = (v & 0xFF00) >> 8;
- *l = (v & 0x00FF);
- close(fd);
- }
-#else
- *l = 100;
- *r = 100;
-#endif
-}
-
-void
-esdout_set_volume(int l, int r)
-{
-#if defined(HAVE_SYS_SOUNDCARD_H) || defined(HAVE_MACHINE_SOUNDCARD_H)
-
- int fd, v, cmd, devs;
-
- if (esd_cfg.use_remote)
- return;
-
- fd = open(DEV_MIXER, O_RDONLY);
-
- if (fd != -1)
- {
- ioctl(fd, SOUND_MIXER_READ_DEVMASK, &devs);
- if (devs & SOUND_MASK_PCM)
- cmd = SOUND_MIXER_WRITE_PCM;
- else if (devs & SOUND_MASK_VOLUME)
- cmd = SOUND_MIXER_WRITE_VOLUME;
- else
- {
- close(fd);
- return;
- }
- v = (r << 8) | l;
- ioctl(fd, cmd, &v);
- close(fd);
- }
-#endif
-}
diff --git a/components/music/fileinfo.c b/components/music/fileinfo.c
deleted file mode 100644
index d153f5e35..000000000
--- a/components/music/fileinfo.c
+++ /dev/null
@@ -1,470 +0,0 @@
-/* XMMS - Cross-platform multimedia player
- * Copyright (C) 1998-2000 Peter Alm, Mikael Alm, Olle Hallnas, Thomas Nilsson and 4Front Technologies
- * Copyright (C) 1999,2000 Håvard Kvålen
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdarg.h>
-#include "mpg123.h"
-
-static GtkWidget *window = NULL;
-static GtkWidget *filename_entry, *id3_frame;
-static GtkWidget *title_entry, *artist_entry, *album_entry, *year_entry, *comment_entry;
-static GtkWidget *genre_combo;
-static GtkWidget *mpeg_level, *mpeg_bitrate, *mpeg_samplerate, *mpeg_flags;
-static GtkWidget *mpeg_fileinfo;
-
-static GList *genre_list = NULL;
-static gchar *current_filename = NULL;
-
-extern gchar *mpg123_filename;
-extern gint mpg123_bitrate, mpg123_frequency, mpg123_layer, mpg123_lsf, mpg123_mode;
-extern gboolean mpg123_stereo, mpg123_mpeg25;
-
-#define MAX_STR_LEN 100
-
-static void set_entry_tag(GtkEntry * entry, gchar * tag, gint length)
-{
- gint stripped_len;
- gchar *text;
-
- stripped_len = mpg123_strip_spaces(tag, length);
- text = g_strdup_printf("%-*.*s", stripped_len, stripped_len, tag);
- gtk_entry_set_text(entry, text);
- g_free(text);
-}
-
-static void get_entry_tag(GtkEntry * entry, gchar * tag, gint length)
-{
- gchar *text;
-
- text = gtk_entry_get_text(entry);
- memset(tag, ' ', length);
- memcpy(tag, text, strlen(text) > length ? length : strlen(text));
-}
-
-static gint find_genre_id(gchar * text)
-{
- gint i;
-
- for (i = 0; i < GENRE_MAX; i++)
- {
- if (strcmp (mpg123_id3_genres[i], text) == 0)
- return i;
- }
- if (text[0] == '\0')
- return 0xff;
- return 0;
-}
-
-static gint genre_comp_func(gconstpointer a, gconstpointer b)
-{
- return eel_strcoll(a, b);
-}
-
-static void save_cb(GtkWidget * w, gpointer data)
-{
- gint fd;
- struct id3v1tag_t tag;
-
- if (!g_ascii_strncasecmp(current_filename, "http://", 7))
- return;
-
- if ((fd = open(current_filename, O_RDWR)) != -1)
- {
- lseek(fd, -128, SEEK_END);
- read(fd, &tag, sizeof (struct id3v1tag_t));
-
- if (!strncmp(tag.tag, "TAG", 3))
- lseek(fd, -128, SEEK_END);
- else
- lseek(fd, 0, SEEK_END);
- tag.tag[0] = 'T';
- tag.tag[1] = 'A';
- tag.tag[2] = 'G';
- get_entry_tag(GTK_ENTRY(title_entry), tag.title, 30);
- get_entry_tag(GTK_ENTRY(artist_entry), tag.artist, 30);
- get_entry_tag(GTK_ENTRY(album_entry), tag.album, 30);
- get_entry_tag(GTK_ENTRY(year_entry), tag.year, 4);
- get_entry_tag(GTK_ENTRY(comment_entry), tag.comment, 30);
- tag.genre = find_genre_id(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(genre_combo)->entry)));
- if (write(fd, &tag, sizeof (struct id3v1tag_t)) != sizeof (struct id3v1tag_t))
- xmms_show_message(_("File Info"), _("Couldn't write tag!"),
- _("Ok"), FALSE, NULL, NULL);
-
- close(fd);
- }
- else
- xmms_show_message(_("File Info"), _("Couldn't write tag!"), _("Ok"),
- FALSE, NULL, NULL);
- gtk_widget_destroy(window);
-}
-
-static void label_set_text(GtkWidget * label, char *str, ...)
-{
- va_list args;
- gchar tempstr[MAX_STR_LEN];
-
- va_start(args, str);
- g_vsnprintf(tempstr, MAX_STR_LEN, str, args);
- va_end(args);
-
- gtk_label_set_text(GTK_LABEL(label), tempstr);
-}
-
-static void remove_id3_cb(GtkWidget * w, gpointer data)
-{
- gint fd, len;
- struct id3v1tag_t tag;
-
- if (!g_ascii_strncasecmp(current_filename, "http://", 7))
- return;
-
- if ((fd = open(current_filename, O_RDWR)) != -1)
- {
- len = lseek(fd, -128, SEEK_END);
- read(fd, &tag, sizeof (struct id3v1tag_t));
-
- if (!strncmp(tag.tag, "TAG", 3))
- {
- if (ftruncate(fd, len))
- xmms_show_message(_("File Info"),
- _("Couldn't remove tag!"), _("Ok"),
- FALSE, NULL, NULL);
- }
- else
- xmms_show_message(_("File Info"), _("No tag to remove!"), _("Ok"),
- FALSE, NULL, NULL);
- close(fd);
- }
- else
- xmms_show_message(_("File Info"), _("Couldn't remove tag!"),
- _("Ok"), FALSE, NULL, NULL);
- gtk_widget_destroy(window);
-}
-
-static void set_mpeg_level_label(gboolean mpeg25, gint lsf, gint layer)
-{
- if (mpeg25)
- label_set_text(mpeg_level, "MPEG 2.5, layer %d", layer);
- else
- label_set_text(mpeg_level, "MPEG %d, layer %d", lsf + 1, layer);
-}
-
-static gchar* channel_mode_name(int mode)
-{
- static const gchar *channel_mode[] =
- {N_("Stereo"), N_("Joint stereo"),
- N_("Dual channel"), N_("Single channel")};
- if (mode < 0 || mode > 3)
- return "";
- return gettext(channel_mode[mode]);
-}
-
-static void file_info_http(char *filename)
-{
- gtk_widget_set_sensitive(id3_frame, FALSE);
- if (mpg123_filename && strcmp(filename, mpg123_filename) == 0 &&
- mpg123_bitrate != 0)
- {
- set_mpeg_level_label(mpg123_mpeg25, mpg123_lsf, mpg123_layer);
- label_set_text(mpeg_bitrate, _("Bitrate: %d kb/s"), mpg123_bitrate);
- label_set_text(mpeg_samplerate, _("Samplerate: %ld Hz"), mpg123_frequency);
- label_set_text(mpeg_flags, "%s", channel_mode_name(mpg123_mode));
- }
-}
-
-void mpg123_file_info_box(char *filename)
-{
- gint i;
- struct id3v1tag_t tag;
- FILE *fh;
- gchar *tmp, *title;
- const gchar *emphasis[] = {N_("None"), N_("50/15 ms"),
- "", N_("CCIT J.17")};
- const gchar *bool_label[] = {N_("No"), N_("Yes")};
-
- {
- int i;
-
- for (i=0; i < 4; i++)
- if (*emphasis[i])
- emphasis[i] = _(emphasis[i]);
- for (i=0; i < 2; i++)
- bool_label[i] = _(bool_label[i]);
- }
- if (!window)
- {
- GtkWidget *vbox, *hbox, *left_vbox, *table;
- GtkWidget *mpeg_frame, *mpeg_box;
- GtkWidget *label, *filename_hbox;
- GtkWidget *bbox, *save, *remove_id3, *cancel;
-
- window = gtk_window_new(GTK_WINDOW_DIALOG);
- gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE);
- g_signal_connect(window, "destroy", G_CALLBACK(gtk_widget_destroyed), &window);
- gtk_container_set_border_width(GTK_CONTAINER(window), 10);
-
- vbox = gtk_vbox_new(FALSE, 10);
- gtk_container_add(GTK_CONTAINER(window), vbox);
-
- filename_hbox = gtk_hbox_new(FALSE, 5);
- gtk_box_pack_start(GTK_BOX(vbox), filename_hbox, FALSE, TRUE, 0);
-
- label = gtk_label_new(_("Filename:"));
- gtk_box_pack_start(GTK_BOX(filename_hbox), label, FALSE, TRUE, 0);
- filename_entry = gtk_entry_new();
- gtk_editable_set_editable(GTK_EDITABLE(filename_entry), FALSE);
- gtk_box_pack_start(GTK_BOX(filename_hbox), filename_entry, TRUE, TRUE, 0);
-
- hbox = gtk_hbox_new(FALSE, 10);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
-
- left_vbox = gtk_vbox_new(FALSE, 10);
- gtk_box_pack_start(GTK_BOX(hbox), left_vbox, FALSE, FALSE, 0);
-
- id3_frame = gtk_frame_new(_("ID3 Tag:"));
- gtk_box_pack_start(GTK_BOX(left_vbox), id3_frame, FALSE, FALSE, 0);
-
- table = gtk_table_new(4, 5, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(table), 5);
- gtk_container_add(GTK_CONTAINER(id3_frame), table);
-
- label = gtk_label_new(_("Title:"));
- gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
- gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 5, 5);
-
- title_entry = gtk_entry_new_with_max_length(30);
- gtk_table_attach(GTK_TABLE(table), title_entry, 1, 4, 0, 1, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
-
- label = gtk_label_new(_("Artist:"));
- gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
- gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 5, 5);
-
- artist_entry = gtk_entry_new_with_max_length(30);
- gtk_table_attach(GTK_TABLE(table), artist_entry, 1, 4, 1, 2, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
-
- label = gtk_label_new(_("Album:"));
- gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
- gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, GTK_FILL, GTK_FILL, 5, 5);
-
- album_entry = gtk_entry_new_with_max_length(30);
- gtk_table_attach(GTK_TABLE(table), album_entry, 1, 4, 2, 3, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
-
- label = gtk_label_new(_("Comment:"));
- gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
- gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, GTK_FILL, GTK_FILL, 5, 5);
-
- comment_entry = gtk_entry_new_with_max_length(30);
- gtk_table_attach(GTK_TABLE(table), comment_entry, 1, 4, 3, 4, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
-
- label = gtk_label_new(_("Year:"));
- gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
- gtk_table_attach(GTK_TABLE(table), label, 0, 1, 4, 5, GTK_FILL, GTK_FILL, 5, 5);
-
- year_entry = gtk_entry_new_with_max_length(4);
- gtk_widget_set_usize(year_entry, 40, -1);
- gtk_table_attach(GTK_TABLE(table), year_entry, 1, 2, 4, 5, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
-
- label = gtk_label_new(_("Genre:"));
- gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
- gtk_table_attach(GTK_TABLE(table), label, 2, 3, 4, 5, GTK_FILL, GTK_FILL, 5, 5);
-
- genre_combo = gtk_combo_new();
- gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(genre_combo)->entry), FALSE);
- if (!genre_list)
- {
- for (i = 0; i < GENRE_MAX; i++)
- genre_list = g_list_prepend(genre_list, (gchar *) mpg123_id3_genres[i]);
- genre_list = g_list_prepend(genre_list, "");
- genre_list = g_list_sort(genre_list, genre_comp_func);
- }
- gtk_combo_set_popdown_strings(GTK_COMBO(genre_combo), genre_list);
-
- gtk_table_attach(GTK_TABLE(table), genre_combo, 3, 4, 4, 5, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
-
- bbox = gtk_hbutton_box_new();
- gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
- gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
- gtk_box_pack_start(GTK_BOX(left_vbox), bbox, FALSE, FALSE, 0);
-
- save = gtk_button_new_with_label(_("Save"));
- g_signal_connect(save, "clicked", G_CALLBACK(save_cb), NULL);
- GTK_WIDGET_SET_FLAGS(save, GTK_CAN_DEFAULT);
- gtk_box_pack_start(GTK_BOX(bbox), save, TRUE, TRUE, 0);
- gtk_widget_grab_default(save);
-
- remove_id3 = gtk_button_new_with_label(_("Remove ID3"));
- g_signal_connect(remove_id3, "clicked", G_CALLBACK(remove_id3_cb), NULL);
- GTK_WIDGET_SET_FLAGS(remove_id3, GTK_CAN_DEFAULT);
- gtk_box_pack_start(GTK_BOX(bbox), remove_id3, TRUE, TRUE, 0);
-
- cancel = gtk_button_new_with_label(_("Cancel"));
- g_signal_connect_object(cancel, "clicked", G_CALLBACK(gtk_widget_destroy), window, G_CONNECT_SWAPPED);
- GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT);
- gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0);
-
- mpeg_frame = gtk_frame_new(_("MPEG Info:"));
- gtk_box_pack_start(GTK_BOX(hbox), mpeg_frame, FALSE, FALSE, 0);
-
- mpeg_box = gtk_vbox_new(FALSE, 5);
- gtk_container_add(GTK_CONTAINER(mpeg_frame), mpeg_box);
- gtk_container_set_border_width(GTK_CONTAINER(mpeg_box), 10);
- gtk_box_set_spacing(GTK_BOX(mpeg_box), 0);
-
- mpeg_level = gtk_label_new("");
- gtk_widget_set_usize(mpeg_level, 120, -2);
- gtk_misc_set_alignment(GTK_MISC(mpeg_level), 0, 0);
- gtk_box_pack_start(GTK_BOX(mpeg_box), mpeg_level, FALSE, FALSE, 0);
-
- mpeg_bitrate = gtk_label_new("");
- gtk_misc_set_alignment(GTK_MISC(mpeg_bitrate), 0, 0);
- gtk_label_set_justify(GTK_LABEL(mpeg_bitrate), GTK_JUSTIFY_LEFT);
- gtk_box_pack_start(GTK_BOX(mpeg_box), mpeg_bitrate, FALSE, FALSE, 0);
-
- mpeg_samplerate = gtk_label_new("");
- gtk_misc_set_alignment(GTK_MISC(mpeg_samplerate), 0, 0);
- gtk_box_pack_start(GTK_BOX(mpeg_box), mpeg_samplerate, FALSE, FALSE, 0);
-
- mpeg_flags = gtk_label_new("");
- gtk_misc_set_alignment(GTK_MISC(mpeg_flags), 0, 0);
- gtk_label_set_justify(GTK_LABEL(mpeg_flags), GTK_JUSTIFY_LEFT);
- gtk_box_pack_start(GTK_BOX(mpeg_box), mpeg_flags, FALSE, FALSE, 0);
-
- mpeg_fileinfo = gtk_label_new("");
- gtk_misc_set_alignment(GTK_MISC(mpeg_fileinfo), 0, 0);
- gtk_label_set_justify(GTK_LABEL(mpeg_fileinfo), GTK_JUSTIFY_LEFT);
- gtk_box_pack_start(GTK_BOX(mpeg_box), mpeg_fileinfo, FALSE, FALSE, 0);
-
- gtk_widget_show_all(window);
- }
-
- if (current_filename)
- g_free(current_filename);
- current_filename = g_strdup(filename);
-
- title = g_strdup_printf(_("File Info - %s"), g_basename(filename));
- gtk_window_set_title(GTK_WINDOW(window), title);
- gtk_window_set_wmclass(GTK_WINDOW(window), "mpg123_file_info", "Nautilus");
- g_free(title);
-
- gtk_entry_set_text(GTK_ENTRY(filename_entry), filename);
- gtk_editable_set_position(GTK_EDITABLE(filename_entry), -1);
-
- title = g_strdup(g_basename(filename));
- if ((tmp = strrchr(title, '.')) != NULL)
- *tmp = '\0';
- gtk_entry_set_text(GTK_ENTRY(title_entry), title);
- g_free(title);
-
- gtk_entry_set_text(GTK_ENTRY(artist_entry), "");
- gtk_entry_set_text(GTK_ENTRY(album_entry), "");
- gtk_entry_set_text(GTK_ENTRY(year_entry), "");
- gtk_entry_set_text(GTK_ENTRY(comment_entry), "");
- gtk_list_select_item(GTK_LIST(GTK_COMBO(genre_combo)->list), g_list_index(genre_list, ""));
- gtk_label_set_text(GTK_LABEL(mpeg_level), "MPEG ?, layer ?");
- gtk_label_set_text(GTK_LABEL(mpeg_bitrate), "");
- gtk_label_set_text(GTK_LABEL(mpeg_samplerate), "");
- gtk_label_set_text(GTK_LABEL(mpeg_flags), "");
- gtk_label_set_text(GTK_LABEL(mpeg_fileinfo), "");
-
- if (!g_ascii_strncasecmp(filename, "http://", 7))
- {
- file_info_http(filename);
- return;
- }
-
- gtk_widget_set_sensitive(id3_frame, TRUE);
-
- if ((fh = fopen(current_filename, "rb")) != NULL)
- {
- guint32 head;
- unsigned char tmp[4];
- struct frame frm;
- gboolean id3_found = FALSE;
-
- fseek(fh, -sizeof (tag), SEEK_END);
- if (fread(&tag, 1, sizeof (tag), fh) == sizeof (tag))
- {
- if (!strncmp(tag.tag, "TAG", 3))
- {
- id3_found = TRUE;
- set_entry_tag(GTK_ENTRY(title_entry),
- tag.title, 30);
- set_entry_tag(GTK_ENTRY(artist_entry),
- tag.artist, 30);
- set_entry_tag(GTK_ENTRY(album_entry),
- tag.album, 30);
- set_entry_tag(GTK_ENTRY(year_entry),
- tag.year, 4);
- set_entry_tag(GTK_ENTRY(comment_entry),
- tag.comment, 30);
- gtk_list_select_item(GTK_LIST(GTK_COMBO(genre_combo)->list), g_list_index(genre_list, (gchar *) mpg123_id3_genres[tag.genre]));
- }
- }
- rewind(fh);
- if (fread(tmp, 1, 4, fh) != 4)
- {
- fclose(fh);
- return;
- }
- head = ((guint32) tmp[0] << 24) | ((guint32) tmp[1] << 16) | ((guint32) tmp[2] << 8) | (guint32) tmp[3];
- while (!mpg123_head_check(head))
- {
- head <<= 8;
- if (fread(tmp, 1, 1, fh) != 1)
- {
- fclose(fh);
- return;
- }
- head |= tmp[0];
- }
- if (mpg123_decode_header(&frm, head))
- {
- guchar *buf;
- gdouble tpf;
- gint pos;
- XHEADDATA xing_header;
- guint32 num_frames;
-
- buf = g_malloc(frm.framesize + 4);
- fseek(fh, -4, SEEK_CUR);
- fread(buf, 1, frm.framesize + 4, fh);
- xing_header.toc = NULL;
- tpf = mpg123_compute_tpf(&frm);
- set_mpeg_level_label(frm.mpeg25, frm.lsf, frm.lay);
- pos = ftell(fh);
- fseek(fh, 0, SEEK_END);
- if (mpg123_get_xing_header(&xing_header, buf))
- {
- num_frames = xing_header.frames;
- label_set_text(mpeg_bitrate, _("Bitrate: Variable,\navg. bitrate: %d kb/s"), (gint) ((xing_header.bytes * 8) / (tpf * xing_header.frames * 1000)));
- }
- else
- {
- num_frames = ((ftell(fh) - pos - (id3_found ? 128 : 0)) / mpg123_compute_bpf(&frm)) + 1;
- label_set_text(mpeg_bitrate, _("Bitrate: %d kb/s"), tabsel_123[frm.lsf][frm.lay - 1][frm.bitrate_index]);
- }
- label_set_text(mpeg_samplerate, _("Samplerate: %ld Hz"), mpg123_freqs[frm.sampling_frequency]);
- label_set_text(mpeg_flags, _("%s\nError protection: %s\nCopyright: %s\nOriginal: %s\nEmphasis: %s"), channel_mode_name(frm.mode), bool_label[frm.error_protection], bool_label[frm.copyright], bool_label[frm.original], emphasis[frm.emphasis]);
- label_set_text(mpeg_fileinfo, _("%d frames\nFilesize: %lu B"), num_frames, ftell(fh));
- g_free(buf);
- }
- fclose(fh);
- }
-}
diff --git a/components/music/getbits.c b/components/music/getbits.c
deleted file mode 100644
index a071b5e80..000000000
--- a/components/music/getbits.c
+++ /dev/null
@@ -1,126 +0,0 @@
-#include "mpg123.h"
-
-#if 0
-static void check_buffer_range(int size)
-{
- int pos = (bsi.wordpointer-bsbuf) + (size >> 3);
-
- if( pos >= fsizeold) {
- fprintf(stderr, "Pointer out of range (%d,%d)!\n", pos, fsizeold);
- }
-}
-#endif
-
-void mpg123_backbits(int number_of_bits)
-{
- bsi.bitindex -= number_of_bits;
- bsi.wordpointer += (bsi.bitindex>>3);
- bsi.bitindex &= 0x7;
-}
-
-int mpg123_getbitoffset(void)
-{
- return (-bsi.bitindex)&0x7;
-}
-
-int mpg123_getbyte(void)
-{
-#ifdef DEBUG_GETBITS
- if(bsi.bitindex)
- fprintf(stderr,"getbyte called unsynched!\n");
-#endif
- return *bsi.wordpointer++;
-}
-
-unsigned int mpg123_getbits(int number_of_bits)
-{
- unsigned long rval;
-
-#ifdef DEBUG_GETBITS
- fprintf(stderr, "g%d", number_of_bits);
-#endif
-
- if(!number_of_bits)
- return 0;
-
-#if 0
- check_buffer_range(number_of_bits + bsi.bitindex);
-#endif
-
- {
- rval = bsi.wordpointer[0];
- rval <<= 8;
- rval |= bsi.wordpointer[1];
- rval <<= 8;
- rval |= bsi.wordpointer[2];
-
- rval <<= bsi.bitindex;
- rval &= 0xffffff;
-
- bsi.bitindex += number_of_bits;
-
- rval >>= (24-number_of_bits);
-
- bsi.wordpointer += (bsi.bitindex >> 3);
- bsi.bitindex &= 7;
- }
-
-#ifdef DEBUG_GETBITS
- fprintf(stderr,":%x ",rval);
-#endif
-
- return rval;
-}
-
-unsigned int mpg123_getbits_fast(int number_of_bits)
-{
- unsigned int rval;
-#ifdef DEBUG_GETBITS
- fprintf(stderr,"g%d",number_of_bits);
-#endif
-
-#if 0
- check_buffer_range(number_of_bits+bsi.bitindex);
-#endif
-
- rval = (unsigned char) (bsi.wordpointer[0] << bsi.bitindex);
- rval |= ((unsigned int) bsi.wordpointer[1] << bsi.bitindex) >> 8;
- rval <<= number_of_bits;
- rval >>= 8;
-
- bsi.bitindex += number_of_bits;
-
- bsi.wordpointer += (bsi.bitindex >> 3);
- bsi.bitindex &= 7;
-
-#ifdef DEBUG_GETBITS
- fprintf(stderr,":%x ",rval);
-#endif
- return rval;
-}
-
-unsigned int mpg123_get1bit(void)
-{
- unsigned char rval;
-
-#ifdef DEBUG_GETBITS
- fprintf(stderr,"g%d",1);
-#endif
-
-#if 0
- check_buffer_range(1+bsi.bitindex);
-#endif
-
- rval = *bsi.wordpointer << bsi.bitindex;
-
- bsi.bitindex++;
- bsi.wordpointer += (bsi.bitindex >> 3);
- bsi.bitindex &= 7;
-
-#ifdef DEBUG_GETBITS
- fprintf(stderr,":%d ",rval >> 7);
-#endif
-
- return rval>>7;
-}
-
diff --git a/components/music/getbits.h b/components/music/getbits.h
deleted file mode 100644
index 1e5cf6519..000000000
--- a/components/music/getbits.h
+++ /dev/null
@@ -1,46 +0,0 @@
-
-/*
- * This does the same as getbits.c but with defines to
- * force inlining
- */
-
-#define mpg123_backbits(nob) \
-do { \
- bsi.bitindex -= nob; \
- bsi.wordpointer += (bsi.bitindex >> 3); \
- bsi.bitindex &= 0x7; \
-} while (0)
-
-#define mpg123_getbitoffset() ((-bsi.bitindex) & 0x7)
-#define mpg123_getbyte() (*bsi.wordpointer++)
-
-#define mpg123_getbits(nob) \
- (rval = bsi.wordpointer[0], \
- rval <<= 8, \
- rval |= bsi.wordpointer[1], \
- rval <<= 8, \
- rval |= bsi.wordpointer[2], \
- rval <<= bsi.bitindex, \
- rval &= 0xffffff, \
- bsi.bitindex += (nob), \
- rval >>= (24-(nob)), \
- bsi.wordpointer += (bsi.bitindex>>3), \
- bsi.bitindex &= 7, \
- rval)
-
-#define mpg123_getbits_fast(nob) \
- (rval = (unsigned char) (bsi.wordpointer[0] << bsi.bitindex), \
- rval |= ((unsigned long) bsi.wordpointer[1] << bsi.bitindex) >> 8, \
- rval <<= (nob), \
- rval >>= 8, \
- bsi.bitindex += (nob), \
- bsi.wordpointer += (bsi.bitindex >> 3), \
- bsi.bitindex &= 7, \
- rval)
-
-#define mpg123_get1bit() \
- (rval_uc = *bsi.wordpointer << bsi.bitindex, \
- bsi.bitindex++, \
- bsi.wordpointer += (bsi.bitindex>>3), \
- bsi.bitindex &= 7, \
- rval_uc >> 7)
diff --git a/components/music/huffman.h b/components/music/huffman.h
deleted file mode 100644
index 83a230b1c..000000000
--- a/components/music/huffman.h
+++ /dev/null
@@ -1,329 +0,0 @@
-
-/*
- * huffman tables ... recalcualted to work with my optimzed
- * decoder scheme (MH)
- *
- * probably we could save a few bytes of memory, because the
- * smaller tables are often the part of a bigger table
- */
-
-struct newhuff
-{
- unsigned int linbits;
- short *table;
-};
-
-static short tab0[] =
-{
- 0
-};
-
-static short tab1[] =
-{
- -5, -3, -1, 17, 1, 16, 0
-};
-
-static short tab2[] =
-{
- -15, -11, -9, -5, -3, -1, 34, 2, 18, -1, 33, 32, 17, -1, 1,
- 16, 0
-};
-
-static short tab3[] =
-{
- -13, -11, -9, -5, -3, -1, 34, 2, 18, -1, 33, 32, 16, 17, -1,
- 1, 0
-};
-
-static short tab5[] =
-{
- -29, -25, -23, -15, -7, -5, -3, -1, 51, 35, 50, 49, -3, -1, 19,
- 3, -1, 48, 34, -3, -1, 18, 33, -1, 2, 32, 17, -1, 1, 16,
- 0
-};
-
-static short tab6[] =
-{
- -25, -19, -13, -9, -5, -3, -1, 51, 3, 35, -1, 50, 48, -1, 19,
- 49, -3, -1, 34, 2, 18, -3, -1, 33, 32, 1, -1, 17, -1, 16,
- 0
-};
-
-static short tab7[] =
-{
- -69, -65, -57, -39, -29, -17, -11, -7, -3, -1, 85, 69, -1, 84, 83,
- -1, 53, 68, -3, -1, 37, 82, 21, -5, -1, 81, -1, 5, 52, -1,
- 80, -1, 67, 51, -5, -3, -1, 36, 66, 20, -1, 65, 64, -11, -7,
- -3, -1, 4, 35, -1, 50, 3, -1, 19, 49, -3, -1, 48, 34, 18,
- -5, -1, 33, -1, 2, 32, 17, -1, 1, 16, 0
-};
-
-static short tab8[] =
-{
- -65, -63, -59, -45, -31, -19, -13, -7, -5, -3, -1, 85, 84, 69, 83,
- -3, -1, 53, 68, 37, -3, -1, 82, 5, 21, -5, -1, 81, -1, 52,
- 67, -3, -1, 80, 51, 36, -5, -3, -1, 66, 20, 65, -3, -1, 4,
- 64, -1, 35, 50, -9, -7, -3, -1, 19, 49, -1, 3, 48, 34, -1,
- 2, 32, -1, 18, 33, 17, -3, -1, 1, 16, 0
-};
-
-static short tab9[] =
-{
- -63, -53, -41, -29, -19, -11, -5, -3, -1, 85, 69, 53, -1, 83, -1,
- 84, 5, -3, -1, 68, 37, -1, 82, 21, -3, -1, 81, 52, -1, 67,
- -1, 80, 4, -7, -3, -1, 36, 66, -1, 51, 64, -1, 20, 65, -5,
- -3, -1, 35, 50, 19, -1, 49, -1, 3, 48, -5, -3, -1, 34, 2,
- 18, -1, 33, 32, -3, -1, 17, 1, -1, 16, 0
-};
-
-static short tab10[] =
-{
- -125, -121, -111, -83, -55, -35, -21, -13, -7, -3, -1, 119, 103, -1, 118,
- 87, -3, -1, 117, 102, 71, -3, -1, 116, 86, -1, 101, 55, -9, -3,
- -1, 115, 70, -3, -1, 85, 84, 99, -1, 39, 114, -11, -5, -3, -1,
- 100, 7, 112, -1, 98, -1, 69, 53, -5, -1, 6, -1, 83, 68, 23,
- -17, -5, -1, 113, -1, 54, 38, -5, -3, -1, 37, 82, 21, -1, 81,
- -1, 52, 67, -3, -1, 22, 97, -1, 96, -1, 5, 80, -19, -11, -7,
- -3, -1, 36, 66, -1, 51, 4, -1, 20, 65, -3, -1, 64, 35, -1,
- 50, 3, -3, -1, 19, 49, -1, 48, 34, -7, -3, -1, 18, 33, -1,
- 2, 32, 17, -1, 1, 16, 0
-};
-
-static short tab11[] =
-{
- -121, -113, -89, -59, -43, -27, -17, -7, -3, -1, 119, 103, -1, 118, 117,
- -3, -1, 102, 71, -1, 116, -1, 87, 85, -5, -3, -1, 86, 101, 55,
- -1, 115, 70, -9, -7, -3, -1, 69, 84, -1, 53, 83, 39, -1, 114,
- -1, 100, 7, -5, -1, 113, -1, 23, 112, -3, -1, 54, 99, -1, 96,
- -1, 68, 37, -13, -7, -5, -3, -1, 82, 5, 21, 98, -3, -1, 38,
- 6, 22, -5, -1, 97, -1, 81, 52, -5, -1, 80, -1, 67, 51, -1,
- 36, 66, -15, -11, -7, -3, -1, 20, 65, -1, 4, 64, -1, 35, 50,
- -1, 19, 49, -5, -3, -1, 3, 48, 34, 33, -5, -1, 18, -1, 2,
- 32, 17, -3, -1, 1, 16, 0
-};
-
-static short tab12[] =
-{
- -115, -99, -73, -45, -27, -17, -9, -5, -3, -1, 119, 103, 118, -1, 87,
- 117, -3, -1, 102, 71, -1, 116, 101, -3, -1, 86, 55, -3, -1, 115,
- 85, 39, -7, -3, -1, 114, 70, -1, 100, 23, -5, -1, 113, -1, 7,
- 112, -1, 54, 99, -13, -9, -3, -1, 69, 84, -1, 68, -1, 6, 5,
- -1, 38, 98, -5, -1, 97, -1, 22, 96, -3, -1, 53, 83, -1, 37,
- 82, -17, -7, -3, -1, 21, 81, -1, 52, 67, -5, -3, -1, 80, 4,
- 36, -1, 66, 20, -3, -1, 51, 65, -1, 35, 50, -11, -7, -5, -3,
- -1, 64, 3, 48, 19, -1, 49, 34, -1, 18, 33, -7, -5, -3, -1,
- 2, 32, 0, 17, -1, 1, 16
-};
-
-static short tab13[] =
-{
- -509, -503, -475, -405, -333, -265, -205, -153, -115, -83, -53, -35, -21, -13, -9,
- -7, -5, -3, -1, 254, 252, 253, 237, 255, -1, 239, 223, -3, -1, 238,
- 207, -1, 222, 191, -9, -3, -1, 251, 206, -1, 220, -1, 175, 233, -1,
- 236, 221, -9, -5, -3, -1, 250, 205, 190, -1, 235, 159, -3, -1, 249,
- 234, -1, 189, 219, -17, -9, -3, -1, 143, 248, -1, 204, -1, 174, 158,
- -5, -1, 142, -1, 127, 126, 247, -5, -1, 218, -1, 173, 188, -3, -1,
- 203, 246, 111, -15, -7, -3, -1, 232, 95, -1, 157, 217, -3, -1, 245,
- 231, -1, 172, 187, -9, -3, -1, 79, 244, -3, -1, 202, 230, 243, -1,
- 63, -1, 141, 216, -21, -9, -3, -1, 47, 242, -3, -1, 110, 156, 15,
- -5, -3, -1, 201, 94, 171, -3, -1, 125, 215, 78, -11, -5, -3, -1,
- 200, 214, 62, -1, 185, -1, 155, 170, -1, 31, 241, -23, -13, -5, -1,
- 240, -1, 186, 229, -3, -1, 228, 140, -1, 109, 227, -5, -1, 226, -1,
- 46, 14, -1, 30, 225, -15, -7, -3, -1, 224, 93, -1, 213, 124, -3,
- -1, 199, 77, -1, 139, 184, -7, -3, -1, 212, 154, -1, 169, 108, -1,
- 198, 61, -37, -21, -9, -5, -3, -1, 211, 123, 45, -1, 210, 29, -5,
- -1, 183, -1, 92, 197, -3, -1, 153, 122, 195, -7, -5, -3, -1, 167,
- 151, 75, 209, -3, -1, 13, 208, -1, 138, 168, -11, -7, -3, -1, 76,
- 196, -1, 107, 182, -1, 60, 44, -3, -1, 194, 91, -3, -1, 181, 137,
- 28, -43, -23, -11, -5, -1, 193, -1, 152, 12, -1, 192, -1, 180, 106,
- -5, -3, -1, 166, 121, 59, -1, 179, -1, 136, 90, -11, -5, -1, 43,
- -1, 165, 105, -1, 164, -1, 120, 135, -5, -1, 148, -1, 119, 118, 178,
- -11, -3, -1, 27, 177, -3, -1, 11, 176, -1, 150, 74, -7, -3, -1,
- 58, 163, -1, 89, 149, -1, 42, 162, -47, -23, -9, -3, -1, 26, 161,
- -3, -1, 10, 104, 160, -5, -3, -1, 134, 73, 147, -3, -1, 57, 88,
- -1, 133, 103, -9, -3, -1, 41, 146, -3, -1, 87, 117, 56, -5, -1,
- 131, -1, 102, 71, -3, -1, 116, 86, -1, 101, 115, -11, -3, -1, 25,
- 145, -3, -1, 9, 144, -1, 72, 132, -7, -5, -1, 114, -1, 70, 100,
- 40, -1, 130, 24, -41, -27, -11, -5, -3, -1, 55, 39, 23, -1, 113,
- -1, 85, 7, -7, -3, -1, 112, 54, -1, 99, 69, -3, -1, 84, 38,
- -1, 98, 53, -5, -1, 129, -1, 8, 128, -3, -1, 22, 97, -1, 6,
- 96, -13, -9, -5, -3, -1, 83, 68, 37, -1, 82, 5, -1, 21, 81,
- -7, -3, -1, 52, 67, -1, 80, 36, -3, -1, 66, 51, 20, -19, -11,
- -5, -1, 65, -1, 4, 64, -3, -1, 35, 50, 19, -3, -1, 49, 3,
- -1, 48, 34, -3, -1, 18, 33, -1, 2, 32, -3, -1, 17, 1, 16,
- 0
-};
-
-static short tab15[] =
-{
--495, -445, -355, -263, -183, -115, -77, -43, -27, -13, -7, -3, -1, 255, 239,
- -1, 254, 223, -1, 238, -1, 253, 207, -7, -3, -1, 252, 222, -1, 237,
- 191, -1, 251, -1, 206, 236, -7, -3, -1, 221, 175, -1, 250, 190, -3,
- -1, 235, 205, -1, 220, 159, -15, -7, -3, -1, 249, 234, -1, 189, 219,
- -3, -1, 143, 248, -1, 204, 158, -7, -3, -1, 233, 127, -1, 247, 173,
- -3, -1, 218, 188, -1, 111, -1, 174, 15, -19, -11, -3, -1, 203, 246,
- -3, -1, 142, 232, -1, 95, 157, -3, -1, 245, 126, -1, 231, 172, -9,
- -3, -1, 202, 187, -3, -1, 217, 141, 79, -3, -1, 244, 63, -1, 243,
- 216, -33, -17, -9, -3, -1, 230, 47, -1, 242, -1, 110, 240, -3, -1,
- 31, 241, -1, 156, 201, -7, -3, -1, 94, 171, -1, 186, 229, -3, -1,
- 125, 215, -1, 78, 228, -15, -7, -3, -1, 140, 200, -1, 62, 109, -3,
- -1, 214, 227, -1, 155, 185, -7, -3, -1, 46, 170, -1, 226, 30, -5,
- -1, 225, -1, 14, 224, -1, 93, 213, -45, -25, -13, -7, -3, -1, 124,
- 199, -1, 77, 139, -1, 212, -1, 184, 154, -7, -3, -1, 169, 108, -1,
- 198, 61, -1, 211, 210, -9, -5, -3, -1, 45, 13, 29, -1, 123, 183,
- -5, -1, 209, -1, 92, 208, -1, 197, 138, -17, -7, -3, -1, 168, 76,
- -1, 196, 107, -5, -1, 182, -1, 153, 12, -1, 60, 195, -9, -3, -1,
- 122, 167, -1, 166, -1, 192, 11, -1, 194, -1, 44, 91, -55, -29, -15,
- -7, -3, -1, 181, 28, -1, 137, 152, -3, -1, 193, 75, -1, 180, 106,
- -5, -3, -1, 59, 121, 179, -3, -1, 151, 136, -1, 43, 90, -11, -5,
- -1, 178, -1, 165, 27, -1, 177, -1, 176, 105, -7, -3, -1, 150, 74,
- -1, 164, 120, -3, -1, 135, 58, 163, -17, -7, -3, -1, 89, 149, -1,
- 42, 162, -3, -1, 26, 161, -3, -1, 10, 160, 104, -7, -3, -1, 134,
- 73, -1, 148, 57, -5, -1, 147, -1, 119, 9, -1, 88, 133, -53, -29,
- -13, -7, -3, -1, 41, 103, -1, 118, 146, -1, 145, -1, 25, 144, -7,
- -3, -1, 72, 132, -1, 87, 117, -3, -1, 56, 131, -1, 102, 71, -7,
- -3, -1, 40, 130, -1, 24, 129, -7, -3, -1, 116, 8, -1, 128, 86,
- -3, -1, 101, 55, -1, 115, 70, -17, -7, -3, -1, 39, 114, -1, 100,
- 23, -3, -1, 85, 113, -3, -1, 7, 112, 54, -7, -3, -1, 99, 69,
- -1, 84, 38, -3, -1, 98, 22, -3, -1, 6, 96, 53, -33, -19, -9,
- -5, -1, 97, -1, 83, 68, -1, 37, 82, -3, -1, 21, 81, -3, -1,
- 5, 80, 52, -7, -3, -1, 67, 36, -1, 66, 51, -1, 65, -1, 20,
- 4, -9, -3, -1, 35, 50, -3, -1, 64, 3, 19, -3, -1, 49, 48,
- 34, -9, -7, -3, -1, 18, 33, -1, 2, 32, 17, -3, -1, 1, 16,
- 0
-};
-
-static short tab16[] =
-{
- -509, -503, -461, -323, -103, -37, -27, -15, -7, -3, -1, 239, 254, -1, 223,
- 253, -3, -1, 207, 252, -1, 191, 251, -5, -1, 175, -1, 250, 159, -3,
- -1, 249, 248, 143, -7, -3, -1, 127, 247, -1, 111, 246, 255, -9, -5,
- -3, -1, 95, 245, 79, -1, 244, 243, -53, -1, 240, -1, 63, -29, -19,
- -13, -7, -5, -1, 206, -1, 236, 221, 222, -1, 233, -1, 234, 217, -1,
- 238, -1, 237, 235, -3, -1, 190, 205, -3, -1, 220, 219, 174, -11, -5,
- -1, 204, -1, 173, 218, -3, -1, 126, 172, 202, -5, -3, -1, 201, 125,
- 94, 189, 242, -93, -5, -3, -1, 47, 15, 31, -1, 241, -49, -25, -13,
- -5, -1, 158, -1, 188, 203, -3, -1, 142, 232, -1, 157, 231, -7, -3,
- -1, 187, 141, -1, 216, 110, -1, 230, 156, -13, -7, -3, -1, 171, 186,
- -1, 229, 215, -1, 78, -1, 228, 140, -3, -1, 200, 62, -1, 109, -1,
- 214, 155, -19, -11, -5, -3, -1, 185, 170, 225, -1, 212, -1, 184, 169,
- -5, -1, 123, -1, 183, 208, 227, -7, -3, -1, 14, 224, -1, 93, 213,
- -3, -1, 124, 199, -1, 77, 139, -75, -45, -27, -13, -7, -3, -1, 154,
- 108, -1, 198, 61, -3, -1, 92, 197, 13, -7, -3, -1, 138, 168, -1,
- 153, 76, -3, -1, 182, 122, 60, -11, -5, -3, -1, 91, 137, 28, -1,
- 192, -1, 152, 121, -1, 226, -1, 46, 30, -15, -7, -3, -1, 211, 45,
- -1, 210, 209, -5, -1, 59, -1, 151, 136, 29, -7, -3, -1, 196, 107,
- -1, 195, 167, -1, 44, -1, 194, 181, -23, -13, -7, -3, -1, 193, 12,
- -1, 75, 180, -3, -1, 106, 166, 179, -5, -3, -1, 90, 165, 43, -1,
- 178, 27, -13, -5, -1, 177, -1, 11, 176, -3, -1, 105, 150, -1, 74,
- 164, -5, -3, -1, 120, 135, 163, -3, -1, 58, 89, 42, -97, -57, -33,
- -19, -11, -5, -3, -1, 149, 104, 161, -3, -1, 134, 119, 148, -5, -3,
- -1, 73, 87, 103, 162, -5, -1, 26, -1, 10, 160, -3, -1, 57, 147,
- -1, 88, 133, -9, -3, -1, 41, 146, -3, -1, 118, 9, 25, -5, -1,
- 145, -1, 144, 72, -3, -1, 132, 117, -1, 56, 131, -21, -11, -5, -3,
- -1, 102, 40, 130, -3, -1, 71, 116, 24, -3, -1, 129, 128, -3, -1,
- 8, 86, 55, -9, -5, -1, 115, -1, 101, 70, -1, 39, 114, -5, -3,
- -1, 100, 85, 7, 23, -23, -13, -5, -1, 113, -1, 112, 54, -3, -1,
- 99, 69, -1, 84, 38, -3, -1, 98, 22, -1, 97, -1, 6, 96, -9,
- -5, -1, 83, -1, 53, 68, -1, 37, 82, -1, 81, -1, 21, 5, -33,
- -23, -13, -7, -3, -1, 52, 67, -1, 80, 36, -3, -1, 66, 51, 20,
- -5, -1, 65, -1, 4, 64, -1, 35, 50, -3, -1, 19, 49, -3, -1,
- 3, 48, 34, -3, -1, 18, 33, -1, 2, 32, -3, -1, 17, 1, 16,
- 0
-};
-
-static short tab24[] =
-{
- -451, -117, -43, -25, -15, -7, -3, -1, 239, 254, -1, 223, 253, -3, -1,
- 207, 252, -1, 191, 251, -5, -1, 250, -1, 175, 159, -1, 249, 248, -9,
- -5, -3, -1, 143, 127, 247, -1, 111, 246, -3, -1, 95, 245, -1, 79,
- 244, -71, -7, -3, -1, 63, 243, -1, 47, 242, -5, -1, 241, -1, 31,
- 240, -25, -9, -1, 15, -3, -1, 238, 222, -1, 237, 206, -7, -3, -1,
- 236, 221, -1, 190, 235, -3, -1, 205, 220, -1, 174, 234, -15, -7, -3,
- -1, 189, 219, -1, 204, 158, -3, -1, 233, 173, -1, 218, 188, -7, -3,
- -1, 203, 142, -1, 232, 157, -3, -1, 217, 126, -1, 231, 172, 255, -235,
- -143, -77, -45, -25, -15, -7, -3, -1, 202, 187, -1, 141, 216, -5, -3,
- -1, 14, 224, 13, 230, -5, -3, -1, 110, 156, 201, -1, 94, 186, -9,
- -5, -1, 229, -1, 171, 125, -1, 215, 228, -3, -1, 140, 200, -3, -1,
- 78, 46, 62, -15, -7, -3, -1, 109, 214, -1, 227, 155, -3, -1, 185,
- 170, -1, 226, 30, -7, -3, -1, 225, 93, -1, 213, 124, -3, -1, 199,
- 77, -1, 139, 184, -31, -15, -7, -3, -1, 212, 154, -1, 169, 108, -3,
- -1, 198, 61, -1, 211, 45, -7, -3, -1, 210, 29, -1, 123, 183, -3,
- -1, 209, 92, -1, 197, 138, -17, -7, -3, -1, 168, 153, -1, 76, 196,
- -3, -1, 107, 182, -3, -1, 208, 12, 60, -7, -3, -1, 195, 122, -1,
- 167, 44, -3, -1, 194, 91, -1, 181, 28, -57, -35, -19, -7, -3, -1,
- 137, 152, -1, 193, 75, -5, -3, -1, 192, 11, 59, -3, -1, 176, 10,
- 26, -5, -1, 180, -1, 106, 166, -3, -1, 121, 151, -3, -1, 160, 9,
- 144, -9, -3, -1, 179, 136, -3, -1, 43, 90, 178, -7, -3, -1, 165,
- 27, -1, 177, 105, -1, 150, 164, -17, -9, -5, -3, -1, 74, 120, 135,
- -1, 58, 163, -3, -1, 89, 149, -1, 42, 162, -7, -3, -1, 161, 104,
- -1, 134, 119, -3, -1, 73, 148, -1, 57, 147, -63, -31, -15, -7, -3,
- -1, 88, 133, -1, 41, 103, -3, -1, 118, 146, -1, 25, 145, -7, -3,
- -1, 72, 132, -1, 87, 117, -3, -1, 56, 131, -1, 102, 40, -17, -7,
- -3, -1, 130, 24, -1, 71, 116, -5, -1, 129, -1, 8, 128, -1, 86,
- 101, -7, -5, -1, 23, -1, 7, 112, 115, -3, -1, 55, 39, 114, -15,
- -7, -3, -1, 70, 100, -1, 85, 113, -3, -1, 54, 99, -1, 69, 84,
- -7, -3, -1, 38, 98, -1, 22, 97, -5, -3, -1, 6, 96, 53, -1,
- 83, 68, -51, -37, -23, -15, -9, -3, -1, 37, 82, -1, 21, -1, 5,
- 80, -1, 81, -1, 52, 67, -3, -1, 36, 66, -1, 51, 20, -9, -5,
- -1, 65, -1, 4, 64, -1, 35, 50, -1, 19, 49, -7, -5, -3, -1,
- 3, 48, 34, 18, -1, 33, -1, 2, 32, -3, -1, 17, 1, -1, 16,
- 0
-};
-
-static short tab_c0[] =
-{
- -29, -21, -13, -7, -3, -1, 11, 15, -1, 13, 14, -3, -1, 7, 5,
- 9, -3, -1, 6, 3, -1, 10, 12, -3, -1, 2, 1, -1, 4, 8,
- 0
-};
-
-static short tab_c1[] =
-{
- -15, -7, -3, -1, 15, 14, -1, 13, 12, -3, -1, 11, 10, -1, 9,
- 8, -7, -3, -1, 7, 6, -1, 5, 4, -3, -1, 3, 2, -1, 1,
- 0
-};
-
-static struct newhuff ht[] =
-{
- { /* 0 */ 0, tab0},
- { /* 2 */ 0, tab1},
- { /* 3 */ 0, tab2},
- { /* 3 */ 0, tab3},
- { /* 0 */ 0, tab0},
- { /* 4 */ 0, tab5},
- { /* 4 */ 0, tab6},
- { /* 6 */ 0, tab7},
- { /* 6 */ 0, tab8},
- { /* 6 */ 0, tab9},
- { /* 8 */ 0, tab10},
- { /* 8 */ 0, tab11},
- { /* 8 */ 0, tab12},
- { /* 16 */ 0, tab13},
- { /* 0 */ 0, tab0},
- { /* 16 */ 0, tab15},
-
- { /* 16 */ 1, tab16},
- { /* 16 */ 2, tab16},
- { /* 16 */ 3, tab16},
- { /* 16 */ 4, tab16},
- { /* 16 */ 6, tab16},
- { /* 16 */ 8, tab16},
- { /* 16 */ 10, tab16},
- { /* 16 */ 13, tab16},
- { /* 16 */ 4, tab24},
- { /* 16 */ 5, tab24},
- { /* 16 */ 6, tab24},
- { /* 16 */ 7, tab24},
- { /* 16 */ 8, tab24},
- { /* 16 */ 9, tab24},
- { /* 16 */ 11, tab24},
- { /* 16 */ 13, tab24}
-};
-
-static struct newhuff htc[] =
-{
- { /* 1 , 1 , */ 0, tab_c0},
- { /* 1 , 1 , */ 0, tab_c1}
-};
diff --git a/components/music/id3.c b/components/music/id3.c
deleted file mode 100644
index 727808fee..000000000
--- a/components/music/id3.c
+++ /dev/null
@@ -1,630 +0,0 @@
-/*********************************************************************
- *
- * Copyright (C) 1999, Espen Skoglund
- * Department of Computer Science, University of Tromsø
- *
- * Filename: id3.c
- * Description: Code for accessing ID3 tags.
- * Author: Espen Skoglund <espensk@stud.cs.uit.no>
- * Created at: Fri Feb 5 23:55:13 1999
- *
- * $Id$
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- ********************************************************************/
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <glib.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-
-#include "id3.h"
-#include "id3_header.h"
-
-
-
-/*
-**
-** Functions for accessing the ID3 tag using a memory pointer.
-**
-*/
-
-/*
- * Function id3_seek_mem (id3, offset)
- *
- * Seek `offset' bytes forward in the indicated ID3-tag. Return 0
- * upon success, or -1 if an error occured.
- *
- */
-static int id3_seek_mem(id3_t *id3, int offset)
-{
- id3->s.me.id3_ptr = (char *) id3->s.me.id3_ptr + offset;
- id3->id3_pos += offset;
-
- if ( id3->id3_pos > id3->id3_tagsize ) {
- id3->id3_pos = id3->id3_tagsize;
- id3_error( id3, "seeking beyond tag boundary" );
- return -1;
- }
-
- return 0;
-}
-
-
-/*
- * Function id3_read_mem (id3, buf, size)
- *
- * Read `size' bytes from indicated ID3-tag. If `buf' is non-NULL,
- * read into that buffer. Return a pointer to the data which was
- * read, or NULL upon error.
- *
- */
-static void *id3_read_mem(id3_t *id3, void *buf, int size)
-{
- void *ret = id3->s.me.id3_ptr;
-
- /*
- * Check boundary.
- */
- if ( id3->id3_pos + size > id3->id3_tagsize ) {
- size = id3->id3_tagsize - id3->id3_pos;
- }
-
- /*
- * If buffer is non-NULL, we have to copy the data.
- */
- if ( buf != NULL )
- memcpy( buf, id3->s.me.id3_ptr, size );
-
- /*
- * Update memory pointer.
- */
- id3->s.me.id3_ptr = (char *) id3->s.me.id3_ptr + size;
- id3->id3_pos += size;
-
- return ret;
-}
-
-
-/*
-**
-** Functions for accessing the ID3 tag using a file descriptor.
-**
-*/
-
-/*
- * Function id3_seek_fd (id3, offset)
- *
- * Seek `offset' bytes forward in the indicated ID3-tag. Return 0
- * upon success, or -1 if an error occured.
- *
- */
-static int id3_seek_fd(id3_t *id3, int offset)
-{
- if ( lseek( id3->s.fd.id3_fd, offset, SEEK_CUR ) == -1 ) {
- id3_error( id3, "seeking beyond tag boundary" );
- return -1;
- }
- id3->id3_pos += offset;
-
- return 0;
-}
-
-
-/*
- * Function id3_read_fd (id3, buf, size)
- *
- * Read `size' bytes from indicated ID3-tag. If `buf' is non-NULL,
- * read into that buffer. Return a pointer to the data which was
- * read, or NULL upon error.
- *
- */
-static void *id3_read_fd(id3_t *id3, void *buf, int size)
-{
- int rsize = size > ID3_FD_BUFSIZE ? ID3_FD_BUFSIZE : size;
- int done = 0;
-
- /*
- * Check boundary.
- */
- if ( id3->id3_pos + size > id3->id3_tagsize ) {
- size = id3->id3_tagsize - id3->id3_pos;
- }
-
- /*
- * If buffer is NULL, we use the default buffer.
- */
- if ( buf == NULL )
- buf = id3->s.fd.id3_buf;
-
- /*
- * Read until we have slurped as much data as we wanted.
- */
- while ( done < rsize ) {
- char *buffer = (char *)buf + done;
- int ret;
-
- /*
- * Try reading from file.
- */
- ret = read( id3->s.fd.id3_fd, buffer, rsize );
- if ( ret == -1 ) {
- id3_error( id3, "read(2) failed" );
- return NULL;
- }
-
- /*
- * Check if we've reached end-of-file.
- */
- if ( ret == 0 )
- return buf;
-
- id3->id3_pos += ret;
- done += ret;
- }
-
- return buf;
-}
-
-
-/*
-**
-** Functions for accessing the ID3 tag using a file pointer.
-**
-*/
-
-/*
- * Function id3_seek_fp (id3, offset)
- *
- * Seek `offset' bytes forward in the indicated ID3-tag. Return 0
- * upon success, or -1 if an error occured.
- *
- */
-static int id3_seek_fp(id3_t *id3, int offset)
-{
- if ( offset > 0 ) {
- /*
- * If offset is positive, we use fread() instead of fseek(). This
- * is more robust with respect to streams.
- */
- char buf[64];
- int r, remain = offset;
-
- while ( remain > 0 ) {
- r = fread( buf, 1, 64, id3->s.fp.id3_fp );
- if ( r == -1 ) {
- id3_error( id3, "fread() failed" );
- return -1;
- }
- remain -= r;
- }
- } else {
- /*
- * If offset is negative, we ahve to use fseek(). Let us hope
- * that it works.
- */
- if ( fseek( id3->s.fp.id3_fp, offset, SEEK_CUR ) == -1 ) {
- id3_error( id3, "seeking beyond tag boundary" );
- return -1;
- }
- }
- id3->id3_pos += offset;
-
- return 0;
-}
-
-
-/*
- * Function id3_read_fp (id3, buf, size)
- *
- * Read `size' bytes from indicated ID3-tag. If `buf' is non-NULL,
- * read into that buffer. Return a pointer to the data which was
- * read, or NULL upon error.
- *
- */
-static void *id3_read_fp(id3_t *id3, void *buf, int size)
-{
- int rsize = size > ID3_FD_BUFSIZE ? ID3_FD_BUFSIZE : size;
- int done = 0;
-
- /*
- * Check boundary.
- */
- if ( id3->id3_pos + size > id3->id3_tagsize ) {
- size = id3->id3_tagsize - id3->id3_pos;
- }
-
- /*
- * If buffer is NULL, we use the default buffer.
- */
- if ( buf == NULL )
- buf = id3->s.fp.id3_buf;
-
- /*
- * Read until we have slurped as much data as we wanted.
- */
- while ( done < rsize ) {
- char *buffer = (char *)buf + done;
- int ret;
-
- /*
- * Try reading from file.
- */
- ret = fread( buffer, 1, rsize, id3->s.fp.id3_fp );
- if ( ret == -1 ) {
- id3_error( id3, "fread() failed" );
- return NULL;
- }
-
- /*
- * Check if we've reached end-of-file.
- */
- if ( ret == 0 )
- return buf;
-
- id3->id3_pos += ret;
- done += ret;
- }
-
- return buf;
-}
-
-
-
-
-/*
- * Function id3_open_mem (ptr, flags)
- *
- * Open an ID3 tag using a memory pointer. Return a pointer to a
- * structure describing the ID3 tag, or NULL if an error occured.
- *
- */
-id3_t *id3_open_mem(void *ptr, int flags)
-{
- id3_t *id3;
-
- /*
- * Allocate ID3 structure.
- */
- id3 = malloc( sizeof(id3_t) );
- if ( id3 == NULL )
- return NULL;
- bzero( id3, sizeof(id3_t) );
-
- /*
- * Initialize access pointers.
- */
- id3->id3_seek = id3_seek_mem;
- id3->id3_read = id3_read_mem;
-
- id3->id3_oflags = flags;
- id3->id3_type = ID3_TYPE_MEM;
- id3->id3_pos = 0;
- id3->s.me.id3_ptr = ptr;
-
- /*
- * Try reading ID3 tag.
- */
- if ( id3_read_tag( id3 ) == -1 ) {
- if ( ~flags & ID3_OPENF_CREATE )
- goto Return_NULL;
- id3_init_tag ( id3 );
- }
-
- return id3;
-
- Return_NULL:
- free( id3 );
- return NULL;
-}
-
-
-/*
- * Function id3_open_fd (fd, flags)
- *
- * Open an ID3 tag using a file descriptor. Return a pointer to a
- * structure describing the ID3 tag, or NULL if an error occured.
- *
- */
-id3_t *id3_open_fd(int fd, int flags)
-{
- id3_t *id3;
-
- /*
- * Allocate ID3 structure.
- */
- id3 = malloc( sizeof(id3_t) );
- if ( id3 == NULL )
- return NULL;
- bzero( id3, sizeof(id3_t) );
-
- /*
- * Initialize access pointers.
- */
- id3->id3_seek = id3_seek_fd;
- id3->id3_read = id3_read_fd;
-
- id3->id3_oflags = flags;
- id3->id3_type = ID3_TYPE_FD;
- id3->id3_pos = 0;
- id3->s.fd.id3_fd = fd;
-
- /*
- * Allocate buffer to hold read data.
- */
- id3->s.fd.id3_buf = malloc( ID3_FD_BUFSIZE );
- if ( id3->s.fd.id3_buf == NULL ) {
- id3_error( id3, "malloc - no memory" );
- goto Error_nobuf;
- }
-
- /*
- * Try reading ID3 tag.
- */
- if ( id3_read_tag( id3 ) == -1 ) {
- if ( ~flags & ID3_OPENF_CREATE )
- goto Return_NULL;
- id3_init_tag ( id3 );
- }
-
- return id3;
-
- /*
- * Cleanup code.
- */
- Return_NULL:
- free( id3->s.fd.id3_buf );
- Error_nobuf:
- free( id3 );
- return NULL;
-}
-
-
-/*
- * Function id3_open_fp (fp, flags)
- *
- * Open an ID3 tag using a file pointer. Return a pointer to a
- * structure describing the ID3 tag, or NULL if an error occured.
- *
- */
-id3_t *id3_open_fp(FILE *fp, int flags)
-{
- id3_t *id3;
-
- /*
- * Allocate ID3 structure.
- */
- id3 = malloc( sizeof(id3_t) );
- if ( id3 == NULL )
- return NULL;
- bzero( id3, sizeof(id3_t) );
-
- /*
- * Initialize access pointers.
- */
- id3->id3_seek = id3_seek_fp;
- id3->id3_read = id3_read_fp;
-
- id3->id3_oflags = flags;
- id3->id3_type = ID3_TYPE_FP;
- id3->id3_pos = 0;
- id3->s.fp.id3_fp = fp;
-
- /*
- * Allocate buffer to hold read data.
- */
- id3->s.fp.id3_buf = malloc( ID3_FD_BUFSIZE );
- if ( id3->s.fp.id3_buf == NULL ) {
- id3_error( id3, "malloc - no memory" );
- goto Error_nobuf;
- }
-
- /*
- * Try reading ID3 tag.
- */
- if ( id3_read_tag( id3 ) == -1 ) {
- if ( ~flags & ID3_OPENF_CREATE )
- goto Return_NULL;
- id3_init_tag ( id3 );
- }
-
-
- return id3;
-
- /*
- * Cleanup code.
- */
- Return_NULL:
- free( id3->s.fp.id3_buf );
- Error_nobuf:
- free( id3 );
- return NULL;
-}
-
-
-/*
- * Function id3_close (id3)
- *
- * Free all resources assoicated with the ID3 tag.
- *
- */
-int id3_close(id3_t *id3)
-{
- int ret = 0;
-
- switch( id3->id3_type ) {
- case ID3_TYPE_MEM:
- break;
- case ID3_TYPE_FD:
- free( id3->s.fd.id3_buf );
- break;
- case ID3_TYPE_FP:
- free( id3->s.fp.id3_buf );
- break;
- case ID3_TYPE_NONE:
- id3_error( id3, "unknown ID3 type" );
- ret = -1;
- }
- free( id3 );
-
- return ret;
-}
-
-
-/*
- * Function id3_tell (id3)
- *
- * Return the current position in ID3 tag. This will always be
- * directly after the tag.
- *
- */
-int id3_tell(id3_t *id3)
-{
- if ( id3->id3_newtag ) {
- return 0;
- } else {
- return id3->id3_tagsize + 3 + sizeof(id3_taghdr_t);
- }
-}
-
-
-/*
- * Function id3_alter_file (id3)
- *
- * When altering a file, some ID3 tags should be discarded. As the ID3
- * library has no means of knowing when a file has been altered
- * outside of the library, this function must be called manually
- * whenever the file is altered.
- *
- */
-int id3_alter_file(id3_t *id3)
-{
- /*
- * List of frame classes that should be discarded whenever the
- * file is altered.
- */
- static guint32 discard_list[] = {
- ID3_ETCO, ID3_EQUA, ID3_MLLT, ID3_POSS, ID3_SYLT,
- ID3_SYTC, ID3_RVAD, ID3_TENC, ID3_TLEN, ID3_TSIZ,
- 0
- };
- id3_frame_t *fr;
- guint32 id, i = 0;
-
- /*
- * Go through list of frame types that should be discarded.
- */
- while ( (id = discard_list[i++]) != 0 ) {
- /*
- * Discard all frames of that type.
- */
- while ( (fr = id3_get_frame(id3, id, 1)) ) {
- id3_delete_frame( fr );
- }
- }
-
- return 0;
-}
-
-
-/*
- * Function safe_write (fd, buf, size)
- *
- * Like write(2), except that the whole buffer will be written.
- *
- */
-static int safe_write(int fd, void *buf, int size)
-{
- int remaining = size;
- char *ptr = buf;
- int r;
-
- while ( remaining > 0 ) {
- if ( (r = write( fd, ptr, remaining )) == -1 )
- return -1;
- remaining -= r;
- ptr += r;
- }
-
- return 0;
-}
-
-
-/*
- * Function id3_write_tag (id3, fd)
- *
- * Wrtite the ID3 tag to the indicated file descriptor. Return 0
- * upon success, or -1 if an error occured.
- *
- */
-int id3_write_tag(id3_t *id3, int fd)
-{
- id3_frame_t *fr;
- id3_taghdr_t taghdr;
- int size = 0;
-
- /*
- * Calculate size of ID3 tag.
- */
- for ( fr = id3->id3_frame; fr != NULL; fr = fr->fr_next ) {
- size += fr->fr_size + sizeof(id3_framehdr_t);
- }
-
- /*
- * Write tag header.
- */
- taghdr.th_version = id3->id3_version;
- taghdr.th_revision = id3->id3_revision;
- taghdr.th_flags = id3->id3_flags;
- taghdr.th_size = g_htonl( ID3_SET_SIZE28(size) );
-
- if ( safe_write(fd, "ID3", 3) == -1 )
- return -1;
- if ( safe_write(fd, &taghdr, sizeof(taghdr)) == -1 )
- return -1;
-
- /*
- * TODO: Write extended header.
- */
-#if 0
- if ( id3->id3_flags & ID3_THFLAG_EXT ) {
- id3_exthdr_t exthdr;
- }
-#endif
-
- for ( fr = id3->id3_frame; fr != NULL; fr = fr->fr_next ) {
- id3_framehdr_t fhdr;
-
- /*
- * TODO: Support compressed headers, encoded
- * headers, and grouping info.
- */
- fhdr.fh_id = fr->fr_desc ? g_htonl(fr->fr_desc->fd_id) : 0;
- fhdr.fh_size = g_htonl( fr->fr_size );
- fhdr.fh_flags = g_ntohl( fr->fr_flags );
-
- if ( safe_write(fd, &fhdr, sizeof(fhdr)) == -1 )
- return -1;
-
- if ( safe_write(fd, fr->fr_data, fr->fr_size) == -1 )
- return -1;
- }
- return 0;
-}
diff --git a/components/music/id3.h b/components/music/id3.h
deleted file mode 100644
index 5705b30b2..000000000
--- a/components/music/id3.h
+++ /dev/null
@@ -1,279 +0,0 @@
-/*********************************************************************
- *
- * Copyright (C) 1998, 1999, Espen Skoglund
- * Department of Computer Science, University of Tromsø
- *
- * Filename: id3.h
- * Description: Include file for accessing the ID3 library.
- * Author: Espen Skoglund <espensk@stud.cs.uit.no>
- * Created at: Thu Nov 5 15:55:10 1998
- *
- * $Id$
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- ********************************************************************/
-#ifndef ID3_H
-#define ID3_H
-
-#include <glib/gtypes.h>
-
-/*
- * Option flags to id3_open_*().
- */
-#define ID3_OPENF_NONE 0x0000
-#define ID3_OPENF_NOCHK 0x0001
-#define ID3_OPENF_CREATE 0x0002
-
-
-/*
- * The size of the read buffer used by file operations.
- */
-#define ID3_FD_BUFSIZE 8192
-
-
-typedef struct id3_t id3_t;
-typedef struct id3_frame_t id3_frame_t;
-typedef struct id3_framedesc_t id3_framedesc_t;
-
-
-/*
- * Structure describing the ID3 tag.
- */
-struct id3_t {
- int id3_type; /* Memory or file desriptor */
- int id3_oflags; /* Flags from open call */
- int id3_flags; /* Flags from tag header */
- int id3_altered; /* Set when tag has been altered */
- int id3_newtag; /* Set if this is a new tag */
-
- int id3_version; /* Major ID3 version number */
- int id3_revision; /* ID3 revision number */
-
- int id3_tagsize; /* Total size of ID3 tag */
- int id3_pos; /* Current position within tag */
-
- char *id3_error_msg; /* Last error message */
-
- char id3_buffer[256]; /* Used for various strings */
-
- union {
- /*
- * Memory specific fields.
- */
- struct {
- void *id3_ptr;
- } me;
-
- /*
- * File desc. specific fields.
- */
- struct {
- int id3_fd;
- void *id3_buf;
- } fd;
-
- /*
- * File ptr. specific fields.
- */
- struct {
- FILE *id3_fp;
- void *id3_buf;
- } fp;
- } s;
-
- /*
- * Functions for doing operations within ID3 tag.
- */
- int (*id3_seek)(id3_t *, int);
- void *(*id3_read)(id3_t *, void *, int);
-
- /*
- * Linked list of ID3 frames.
- */
- int id3_numframes;
- id3_frame_t *id3_frame;
- id3_frame_t *id3_tail;
-};
-
-#define ID3_TYPE_NONE 0
-#define ID3_TYPE_MEM 1
-#define ID3_TYPE_FD 2
-#define ID3_TYPE_FP 3
-
-
-/*
- * Structure describing an ID3 frame.
- */
-struct id3_frame_t {
- id3_t *fr_owner;
- id3_framedesc_t *fr_desc;
- int fr_flags;
- unsigned char fr_encryption;
- unsigned char fr_grouping;
- unsigned char fr_altered;
-
- void *fr_data; /* The uncompressed frame */
- int fr_size; /* Size of uncompressed frame */
-
- void *fr_data_z; /* The compressed frame */
- int fr_size_z; /* Size of compressed frame */
-
- id3_frame_t *fr_next;
-};
-
-
-/*
- * Structure describing an ID3 frame type.
- */
-struct id3_framedesc_t {
- guint32 fd_id;
- char fd_idstr[4];
- char *fd_description;
-};
-
-
-/*
- * Text encodings.
- */
-#define ID3_ENCODING_ISO_8859_1 0x00
-#define ID3_ENCODING_UNICODE 0x01
-
-
-
-/*
- * ID3 frame id numbers.
- */
-#define ID3_FRAME_ID(a,b,c,d) ((a << 24) | (b << 16) | (c << 8) | d)
-
-#define ID3_AENC ID3_FRAME_ID('A','E','N','C')
-#define ID3_APIC ID3_FRAME_ID('A','P','I','C')
-#define ID3_COMM ID3_FRAME_ID('C','O','M','M')
-#define ID3_COMR ID3_FRAME_ID('C','O','M','R')
-#define ID3_ENCR ID3_FRAME_ID('E','N','C','R')
-#define ID3_EQUA ID3_FRAME_ID('E','Q','U','A')
-#define ID3_ETCO ID3_FRAME_ID('E','T','C','O')
-#define ID3_GEOB ID3_FRAME_ID('G','E','O','B')
-#define ID3_GRID ID3_FRAME_ID('G','R','I','D')
-#define ID3_IPLS ID3_FRAME_ID('I','P','L','S')
-#define ID3_LINK ID3_FRAME_ID('L','I','N','K')
-#define ID3_MCDI ID3_FRAME_ID('M','C','D','I')
-#define ID3_MLLT ID3_FRAME_ID('M','L','L','T')
-#define ID3_OWNE ID3_FRAME_ID('O','W','N','E')
-#define ID3_PRIV ID3_FRAME_ID('P','R','I','V')
-#define ID3_PCNT ID3_FRAME_ID('P','C','N','T')
-#define ID3_POPM ID3_FRAME_ID('P','O','P','M')
-#define ID3_POSS ID3_FRAME_ID('P','O','S','S')
-#define ID3_RBUF ID3_FRAME_ID('R','B','U','F')
-#define ID3_RVAD ID3_FRAME_ID('R','V','A','D')
-#define ID3_RVRB ID3_FRAME_ID('R','V','R','B')
-#define ID3_SYLT ID3_FRAME_ID('S','Y','L','T')
-#define ID3_SYTC ID3_FRAME_ID('S','Y','T','C')
-#define ID3_TALB ID3_FRAME_ID('T','A','L','B')
-#define ID3_TBPM ID3_FRAME_ID('T','B','P','M')
-#define ID3_TCOM ID3_FRAME_ID('T','C','O','M')
-#define ID3_TCON ID3_FRAME_ID('T','C','O','N')
-#define ID3_TCOP ID3_FRAME_ID('T','C','O','P')
-#define ID3_TDAT ID3_FRAME_ID('T','D','A','T')
-#define ID3_TDLY ID3_FRAME_ID('T','D','L','Y')
-#define ID3_TENC ID3_FRAME_ID('T','E','N','C')
-#define ID3_TEXT ID3_FRAME_ID('T','E','X','T')
-#define ID3_TFLT ID3_FRAME_ID('T','F','L','T')
-#define ID3_TIME ID3_FRAME_ID('T','I','M','E')
-#define ID3_TIT1 ID3_FRAME_ID('T','I','T','1')
-#define ID3_TIT2 ID3_FRAME_ID('T','I','T','2')
-#define ID3_TIT3 ID3_FRAME_ID('T','I','T','3')
-#define ID3_TKEY ID3_FRAME_ID('T','K','E','Y')
-#define ID3_TLAN ID3_FRAME_ID('T','L','A','N')
-#define ID3_TLEN ID3_FRAME_ID('T','L','E','N')
-#define ID3_TMED ID3_FRAME_ID('T','M','E','D')
-#define ID3_TOAL ID3_FRAME_ID('T','O','A','L')
-#define ID3_TOFN ID3_FRAME_ID('T','O','F','N')
-#define ID3_TOLY ID3_FRAME_ID('T','O','L','Y')
-#define ID3_TOPE ID3_FRAME_ID('T','O','P','E')
-#define ID3_TORY ID3_FRAME_ID('T','O','R','Y')
-#define ID3_TOWN ID3_FRAME_ID('T','O','W','N')
-#define ID3_TPE1 ID3_FRAME_ID('T','P','E','1')
-#define ID3_TPE2 ID3_FRAME_ID('T','P','E','2')
-#define ID3_TPE3 ID3_FRAME_ID('T','P','E','3')
-#define ID3_TPE4 ID3_FRAME_ID('T','P','E','4')
-#define ID3_TPOS ID3_FRAME_ID('T','P','O','S')
-#define ID3_TPUB ID3_FRAME_ID('T','P','U','B')
-#define ID3_TRCK ID3_FRAME_ID('T','R','C','K')
-#define ID3_TRDA ID3_FRAME_ID('T','R','D','A')
-#define ID3_TRSN ID3_FRAME_ID('T','R','S','N')
-#define ID3_TRSO ID3_FRAME_ID('T','R','S','O')
-#define ID3_TSIZ ID3_FRAME_ID('T','S','I','Z')
-#define ID3_TSRC ID3_FRAME_ID('T','S','R','C')
-#define ID3_TSSE ID3_FRAME_ID('T','S','S','E')
-#define ID3_TYER ID3_FRAME_ID('T','Y','E','R')
-#define ID3_TXXX ID3_FRAME_ID('T','X','X','X')
-#define ID3_UFID ID3_FRAME_ID('U','F','I','D')
-#define ID3_USER ID3_FRAME_ID('U','S','E','R')
-#define ID3_USLT ID3_FRAME_ID('U','S','L','T')
-#define ID3_WCOM ID3_FRAME_ID('W','C','O','M')
-#define ID3_WCOP ID3_FRAME_ID('W','C','O','P')
-#define ID3_WOAF ID3_FRAME_ID('W','O','A','F')
-#define ID3_WOAR ID3_FRAME_ID('W','O','A','R')
-#define ID3_WOAS ID3_FRAME_ID('W','O','A','S')
-#define ID3_WORS ID3_FRAME_ID('W','O','R','S')
-#define ID3_WPAY ID3_FRAME_ID('W','P','A','Y')
-#define ID3_WPUB ID3_FRAME_ID('W','P','U','B')
-#define ID3_WXXX ID3_FRAME_ID('W','X','X','X')
-
-
-
-/*
- * Prototypes.
- */
-
-/* From id3.c */
-id3_t *id3_open_mem(void *, int);
-id3_t *id3_open_fd(int, int);
-id3_t *id3_open_fp(FILE *, int);
-int id3_set_output(id3_t *, char *);
-int id3_close(id3_t *);
-int id3_tell(id3_t *);
-int id3_alter_file(id3_t *);
-int id3_write_tag(id3_t *, int);
-
-/* From id3_frame.c */
-int id3_read_frame(id3_t *id3);
-id3_frame_t *id3_get_frame(id3_t *, guint32, int);
-int id3_delete_frame(id3_frame_t *frame);
-id3_frame_t *id3_add_frame(id3_t *, guint32);
-int id3_decompress_frame(id3_frame_t *);
-
-/* From id3_frame_text.c */
-gint8 id3_get_encoding(id3_frame_t *);
-int id3_set_encoding(id3_frame_t *, gint8);
-char *id3_get_text(id3_frame_t *);
-char *id3_get_text_desc(id3_frame_t *);
-int id3_get_text_number(id3_frame_t *);
-int id3_set_text(id3_frame_t *, char *);
-int id3_set_text_number(id3_frame_t *, int);
-
-/* From id3_frame_content.c */
-char *id3_get_content(id3_frame_t *);
-
-/* From id3_frame_url.c */
-char *id3_get_url(id3_frame_t *);
-char *id3_get_url_desc(id3_frame_t *);
-
-/* From id3_tag.c */
-void id3_init_tag(id3_t *id3);
-int id3_read_tag(id3_t *id3);
-
-#endif /* ID3_H */
diff --git a/components/music/id3_frame.c b/components/music/id3_frame.c
deleted file mode 100644
index 4fa77e0cd..000000000
--- a/components/music/id3_frame.c
+++ /dev/null
@@ -1,534 +0,0 @@
-/*********************************************************************
- *
- * Copyright (C) 1999-2000, Espen Skoglund
- * Department of Computer Science, University of Tromsø
- *
- * Filename: id3_frame.c
- * Description: Code for handling ID3 frames.
- * Author: Espen Skoglund <espensk@stud.cs.uit.no>
- * Created at: Fri Feb 5 23:47:08 1999
- *
- * $Id$
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- ********************************************************************/
-#if HAVE_LIBZ
-#include <zlib.h>
-#endif
-#include <glib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-#include "id3.h"
-#include "id3_header.h"
-
-/*
- * Description of all valid ID3v2 frames.
- */
-static id3_framedesc_t Framedesc[] = {
- { ID3_AENC, "AENC", "Audio encryption" },
- { ID3_APIC, "APIC", "Attached picture" },
-
- { ID3_COMM, "COMM", "Comments" },
- { ID3_COMR, "COMR", "Commercial frame" },
-
- { ID3_ENCR, "ENCR", "Encryption method registration" },
- { ID3_EQUA, "EQUA", "Equalization" },
- { ID3_ETCO, "ETCO", "Event timing codes" },
-
- { ID3_GEOB, "GEOB", "General encapsulated object" },
- { ID3_GRID, "GRID", "Group identification registration" },
-
- { ID3_IPLS, "IPLS", "Involved people list" },
-
- { ID3_LINK, "LINK", "Linked information" },
-
- { ID3_MCDI, "MCDI", "Music CD identifier" },
- { ID3_MLLT, "MLLT", "MPEG location lookup table" },
-
- { ID3_OWNE, "OWNE", "Ownership frame" },
-
- { ID3_PRIV, "PRIV", "Private frame" },
- { ID3_PCNT, "PCNT", "Play counter" },
- { ID3_POPM, "POPM", "Popularimeter" },
- { ID3_POSS, "POSS", "Position synchronisation frame" },
-
- { ID3_RBUF, "RBUF", "Recommended buffer size" },
- { ID3_RVAD, "RVAD", "Relative volume adjustment" },
- { ID3_RVRB, "RVRB", "Reverb" },
-
- { ID3_SYLT, "SYLT", "Synchronized lyric/text" },
- { ID3_SYTC, "SYTC", "Synchronized tempo codes" },
-
- { ID3_TALB, "TALB", "Album/Movie/Show title" },
- { ID3_TBPM, "TBPM", "BPM (beats per minute)" },
- { ID3_TCOM, "TCOM", "Composer" },
- { ID3_TCON, "TCON", "Content type" },
- { ID3_TCOP, "TCOP", "Copyright message" },
- { ID3_TDAT, "TDAT", "Date" },
- { ID3_TDLY, "TDLY", "Playlist delay" },
- { ID3_TENC, "TENC", "Encoded by" },
- { ID3_TEXT, "TEXT", "Lyricist/Text writer" },
- { ID3_TFLT, "TFLT", "File type" },
- { ID3_TIME, "TIME", "Time" },
- { ID3_TIT1, "TIT1", "Content group description" },
- { ID3_TIT2, "TIT2", "Title/songname/content description" },
- { ID3_TIT3, "TIT3", "Subtitle/Description refinement" },
- { ID3_TKEY, "TKEY", "Initial key" },
- { ID3_TLAN, "TLAN", "Language(s)" },
- { ID3_TLEN, "TLEN", "Length" },
- { ID3_TMED, "TMED", "Media type" },
- { ID3_TOAL, "TOAL", "Original album/movie/show title" },
- { ID3_TOFN, "TOFN", "Original filename" },
- { ID3_TOLY, "TOLY", "Original lyricist(s)/text writer(s)" },
- { ID3_TOPE, "TOPE", "Original artist(s)/performer(s)" },
- { ID3_TORY, "TORY", "Original release year" },
- { ID3_TOWN, "TOWN", "File owner/licensee" },
- { ID3_TPE1, "TPE1", "Lead performer(s)/Soloist(s)" },
- { ID3_TPE2, "TPE2", "Band/orchestra/accompaniment" },
- { ID3_TPE3, "TPE3", "Conductor/performer refinement" },
- { ID3_TPE4, "TPE4", "Interpreted, remixed, or otherwise modified by" },
- { ID3_TPOS, "TPOS", "Part of a set" },
- { ID3_TPUB, "TPUB", "Publisher" },
- { ID3_TRCK, "TRCK", "Track number/Position in set" },
- { ID3_TRDA, "TRDA", "Recording dates" },
- { ID3_TRSN, "TRSN", "Internet radio station name" },
- { ID3_TRSO, "TRSO", "Internet radio station owner" },
- { ID3_TSIZ, "TSIZ", "Size" },
- { ID3_TSRC, "TSRC", "ISRC (international standard recording code)" },
- { ID3_TSSE, "TSSE", "Software/Hardware and settings used for encoding" },
- { ID3_TYER, "TYER", "Year" },
- { ID3_TXXX, "TXXX", "User defined text information frame" },
-
- { ID3_UFID, "UFID", "Unique file identifier" },
- { ID3_USER, "USER", "Terms of use" },
- { ID3_USLT, "USLT", "Unsychronized lyric/text transcription" },
-
- { ID3_WCOM, "WCOM", "Commercial information" },
- { ID3_WCOP, "WCOP", "Copyright/Legal information" },
- { ID3_WOAF, "WOAF", "Official audio file webpage" },
- { ID3_WOAR, "WOAR", "Official artist/performer webpage" },
- { ID3_WOAS, "WOAS", "Official audio source webpage" },
- { ID3_WORS, "WORS", "Official internet radio station homepage" },
- { ID3_WPAY, "WPAY", "Payment" },
- { ID3_WPUB, "WPUB", "Publishers official webpage" },
- { ID3_WXXX, "WXXX", "User defined URL link frame" },
-};
-
-
-/*
- * Function id3_read_frame (id3)
- *
- * Read next frame from the indicated ID3 tag. Return 0 upon
- * success, or -1 if an error occured.
- *
- */
-int id3_read_frame(id3_t *id3)
-{
- id3_framehdr_t *framehdr;
- id3_frame_t *frame;
- guint32 id;
- void *p;
- int i;
-
- /*
- * Read frame header.
- */
- framehdr = id3->id3_read( id3, NULL, sizeof(*framehdr) );
- if ( framehdr == NULL )
- return -1;
-
- /*
- * If we encounter an invalid frame id, we assume that there is
- * some padding in the header. We just skip the rest of the ID3
- * tag.
- */
- i = *((guint8 *) &framehdr->fh_id);
- if ( !((i >= '0' && i <= '9') || (i >= 'A' && i <= 'Z')) ) {
- id3->id3_seek( id3, id3->id3_tagsize - id3->id3_pos );
- return 0;
- }
- id = g_ntohl( framehdr->fh_id );
-
- /*
- * Allocate frame.
- */
- frame = malloc( sizeof(*frame) );
- if ( frame == NULL )
- return -1;
-
- frame->fr_owner = id3;
- frame->fr_size = g_ntohl(framehdr->fh_size);
- frame->fr_flags = g_ntohs(framehdr->fh_flags);
- frame->fr_encryption = 0;
- frame->fr_grouping = 0;
- frame->fr_desc = NULL;
- frame->fr_altered = 0;
- frame->fr_data = NULL;
-
- /*
- * Determine the type of the frame.
- */
- for ( i = 0;
- i < (int)(sizeof(Framedesc) / sizeof(id3_framedesc_t));
- i++ ) {
-
- if ( Framedesc[i].fd_id == id ) {
- /*
- * Insert frame into linked list.
- */
- frame->fr_next = NULL;
- if ( id3->id3_frame ) {
- id3->id3_tail->fr_next = frame;
- } else {
- id3->id3_frame = frame;
- }
- id3->id3_tail = frame;
- id3->id3_numframes++;
-
- /*
- * Initialize frame.
- */
- frame->fr_desc = Framedesc + i;
-
- /*
- * When allocating memory to hold a text frame, we
- * allocate 2 extra byte. This simplifies retrieval of
- * text strings.
- */
- frame->fr_data = malloc( frame->fr_size +
- (frame->fr_desc->fd_idstr[0] == 'T' ||
- frame->fr_desc->fd_idstr[0] == 'W' ?
- 2 : 0) );
- if ( frame->fr_data == NULL ) {
- free( frame );
- return -1;
- }
- p = id3->id3_read(id3, frame->fr_data, frame->fr_size );
- if ( p == NULL ) {
- free( frame->fr_data );
- free( frame );
- return -1;
- }
-
- /*
- * Null-terminate text frames.
- */
- if ( frame->fr_desc->fd_idstr[0] == 'T' ||
- frame->fr_desc->fd_idstr[0] == 'W' ) {
- ((char *) frame->fr_data)[frame->fr_size] = 0;
- ((char *) frame->fr_data)[frame->fr_size+1] = 0;
- }
-
- break;
- }
- }
-
- /*
- * Check if frame had a valid id.
- */
- if ( frame->fr_desc == NULL ) {
- /*
- * No. Ignore the frame.
- */
- return 0;
- }
-
-
- if ( frame->fr_flags & ID3_FHFLAG_COMPRESS ) {
- /*
- * Frame is compressed using zlib. Fetch the size of the
- * decompressed data.
- */
- frame->fr_size_z = frame->fr_size;
- frame->fr_size = g_ntohl( *((guint32 *) frame->fr_data) );
- frame->fr_data_z = GINT_TO_POINTER ((GPOINTER_TO_INT (frame->fr_data) + 4));
- frame->fr_data = NULL;
- } else {
- /*
- * Frame is not compressed.
- */
- frame->fr_size_z = 0;
- frame->fr_data_z = NULL;
- }
-
- /*
- * If frame is encrypted, we have one extra byte in the header.
- */
- if ( frame->fr_flags & ID3_FHFLAG_ENCRYPT ) {
- if ( frame->fr_data_z )
- frame->fr_data_z = (char *) frame->fr_data_z + 1;
- else
- frame->fr_data = (char *) frame->fr_data + 1;
- }
-
- /*
- * If frame has grouping identity, we have one extra byte in the
- * header.
- */
- if ( frame->fr_flags & ID3_FHFLAG_GROUP ) {
- if ( frame->fr_data_z )
- frame->fr_data_z = (char *) frame->fr_data + 1;
- else
- frame->fr_data = (char *) frame->fr_data + 1;
- }
-
- return 0;
-}
-
-
-/*
- * Function id3_get_frame (id3, type, num)
- *
- * Search in the list of frames for the ID3-tag, and return a frame
- * of the indicated type. If tag contains several frames of the
- * indicated type, the third argument tells which of the frames to
- * return.
- *
- */
-id3_frame_t *id3_get_frame(id3_t *id3, guint32 type, int num)
-{
- id3_frame_t *fr = id3->id3_frame;
-
- while ( fr != NULL ) {
- if (fr->fr_desc && fr->fr_desc->fd_id == type )
- {
- if ( --num <= 0 )
- break;
- }
- fr = fr->fr_next;
- }
- return fr;
-}
-
-
-/*
- * Function id3_decompress_frame (frame)
- *
- * Uncompress the indicated frame. Return 0 upon success, or -1 if
- * an error occured.
- *
- */
-int id3_decompress_frame(id3_frame_t *frame)
-{
-#ifdef HAVE_LIBZ
- z_stream z;
- int r;
-
- /*
- * Allocate memory to hold uncompressed frame.
- */
- frame->fr_data = malloc( frame->fr_size +
- (frame->fr_desc->fd_idstr[0] == 'T' ||
- frame->fr_desc->fd_idstr[0] == 'W' ? 2 : 0) );
- if ( frame->fr_data == NULL ) {
- id3_error( frame->fr_owner, "malloc - no memory" );
- return -1;
- }
-
- /*
- * Initialize zlib.
- */
- z.next_in = (Bytef *) frame->fr_data_z;
- z.avail_in = frame->fr_size_z;
- z.zalloc = NULL;
- z.zfree = NULL;
- z.opaque = NULL;
-
- r = inflateInit( &z );
- switch ( r ) {
- case Z_OK:
- break;
- case Z_MEM_ERROR:
- id3_error( frame->fr_owner, "zlib - no memory" );
- goto Error_init;
- case Z_VERSION_ERROR:
- id3_error( frame->fr_owner, "zlib - invalid version" );
- goto Error_init;
- default:
- id3_error( frame->fr_owner, "zlib - unknown error" );
- goto Error_init;
- }
-
- /*
- * Decompress frame.
- */
- z.next_out = (Bytef *) frame->fr_data;
- z.avail_out = frame->fr_size;
- r = inflate( &z, Z_SYNC_FLUSH );
- switch ( r ) {
- case Z_STREAM_END:
- break;
- case Z_OK:
- if ( z.avail_in == 0 )
- /*
- * This should not be possible with a correct stream.
- * We will be nice however, and try to go on.
- */
- break;
- id3_error( frame->fr_owner, "zlib - buffer exhausted" );
- goto Error_inflate;
- default:
- id3_error( frame->fr_owner, "zlib - unknown error" );
- goto Error_inflate;
- }
-
- r = inflateEnd( &z );
- if ( r != Z_OK )
- id3_error( frame->fr_owner, "zlib - inflateEnd error" );
-
- /*
- * Null-terminate text frames.
- */
- if ( frame->fr_desc->fd_idstr[0] == 'T' ||
- frame->fr_desc->fd_idstr[0] == 'W' ) {
- ((char *) frame->fr_data)[frame->fr_size] = 0;
- ((char *) frame->fr_data)[frame->fr_size+1] = 0;
- }
-
- return 0;
-
- /*
- * Cleanup code.
- */
- Error_inflate:
- r = inflateEnd( &z );
- Error_init:
- free( frame->fr_data );
- frame->fr_data = NULL;
-#endif
- return -1;
-}
-
-
-/*
- * Function id3_delete_frame (frame)
- *
- * Remove frame from ID3 tag and release memory ocupied by it.
- *
- */
-int id3_delete_frame(id3_frame_t *frame)
-{
- id3_frame_t *fr = frame->fr_owner->id3_frame;
- id3_frame_t *prev = NULL;
- int ret;
-
- /*
- * Search for frame in list.
- */
- while ( fr != frame && fr != NULL ) {
- prev = fr;
- fr = fr->fr_next;
- }
-
- if ( fr == NULL ) {
- /*
- * Frame does not exist in frame list.
- */
- ret = -1;
-
- } else {
- /*
- * Remove frame from frame list.
- */
- if ( prev == NULL ) {
- frame->fr_owner->id3_frame = frame->fr_next;
- } else {
- prev->fr_next = frame->fr_next;
- }
- if ( frame->fr_owner->id3_tail == frame )
- frame->fr_owner->id3_tail = prev;
-
- frame->fr_owner->id3_numframes--;
- frame->fr_owner->id3_altered = 1;
- ret = 0;
- }
-
- /*
- * Release memory occupied by frame.
- */
- if ( frame->fr_data )
- free( frame->fr_data );
- if ( frame->fr_data_z )
- free( frame->fr_data_z );
- free( frame );
-
- return ret;
-}
-
-
-/*
- * Function id3_add_frame (id3, type)
- *
- * Add a new frame to the ID3 tag. Return a pointer to the new
- * frame, or NULL if an error occured.
- *
- */
-id3_frame_t *id3_add_frame(id3_t *id3, guint32 type)
-{
- id3_frame_t *frame;
- int i;
-
- /*
- * Allocate frame.
- */
- frame = malloc( sizeof(*frame) );
- if ( frame == NULL )
- return NULL;
-
- /*
- * Initialize frame
- */
- frame->fr_owner = id3;
- frame->fr_desc = NULL;
- frame->fr_flags = 0;
- frame->fr_encryption = 0;
- frame->fr_grouping = 0;
- frame->fr_altered = 0;
- frame->fr_data = frame->fr_data_z = NULL;
- frame->fr_size = frame->fr_size_z = 0;
-
- /*
- * Try finding the correct frame descriptor.
- */
- for ( i = 0;
- i < (int)(sizeof(Framedesc) / sizeof(id3_framedesc_t));
- i++ ) {
- if ( Framedesc[i].fd_id == type ) {
- frame->fr_desc = &Framedesc[i];
- break;
- }
- }
-
- /*
- * Insert frame into linked list.
- */
- frame->fr_next = NULL;
- if ( id3->id3_frame ) {
- id3->id3_tail->fr_next = frame;
- } else {
- id3->id3_frame = frame;
- }
- id3->id3_tail = frame;
- id3->id3_numframes++;
- id3->id3_altered = 1;
-
- return frame;
-}
-
-
diff --git a/components/music/id3_frame_content.c b/components/music/id3_frame_content.c
deleted file mode 100644
index aaa6b4456..000000000
--- a/components/music/id3_frame_content.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/*********************************************************************
- *
- * Copyright (C) 1999, Espen Skoglund
- * Department of Computer Science, University of Tromsø
- *
- * Filename: id3_frame_content.c
- * Description: Code for handling ID3 content frames.
- * Author: Espen Skoglund <espensk@stud.cs.uit.no>
- * Created at: Mon Feb 8 17:13:46 1999
- *
- * $Id$
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- ********************************************************************/
-
-#include <stdio.h>
-#include "mpg123.h"
-
-#include "id3.h"
-
-
-/*
- * Function id3_get_content (frame)
- *
- * Expand content type string of frame and return it. Return NULL
- * upon error.
- *
- */
-char *id3_get_content(id3_frame_t *frame)
-{
- char *text, *ptr;
- char *buffer = frame->fr_owner->id3_buffer;
- int spc = sizeof( frame->fr_owner->id3_buffer ) - 1;
-
- /* Type check */
- if ( frame->fr_desc->fd_id != ID3_TCON )
- return NULL;
-
- /* Check if frame is compressed */
- if ( frame->fr_data_z && !frame->fr_data )
- if ( id3_decompress_frame( frame ) == -1 )
- return NULL;
-
- text = (char *) frame->fr_data + 1;
-
- /*
- * If content is just plain text, return it.
- */
- if ( text[0] != '(' )
- return text;
-
- /*
- * Expand ID3v1 genre numbers.
- */
- ptr = buffer;
- while ( text[0] == '(' && text[1] != '(' && spc > 0 ) {
- char *genre;
- int num = 0;
-
- if ( text[1] == 'R' && text[2] == 'X' ) {
- text += 4;
- genre = ptr != buffer ? " (Remix)" : "(Remix)";
-
- } else if ( text[1] == 'C' && text[2] == 'R' ) {
- text += 4;
- genre = ptr != buffer ? " (Cover)" : "(Cover)";
-
- } else {
- /* Get ID3v1 genre number */
- text++;
- while ( *text != ')' ) {
- num *= 10;
- num += *text++ - '0';
- }
- text++;
-
- /* Boundary check */
- if ( num >= (int)(sizeof(mpg123_id3_genres) / sizeof(char *)) )
- continue;
-
- genre = (char *)mpg123_id3_genres[num];
-
- if ( ptr != buffer && spc-- > 0 )
- *ptr++ = '/';
- }
-
- /* Expand string into buffer */
- while ( *genre != '\0' && spc > 0 ) {
- *ptr++ = *genre++;
- spc--;
- }
- }
-
- /*
- * Add plaintext refinement.
- */
- if ( *text == '(' )
- text++;
- if ( *text != '\0' && ptr != buffer && spc-- > 0 )
- *ptr++ = ' ';
- while ( *text != '\0' && spc > 0 ) {
- *ptr++ = *text++;
- spc--;
- }
- *ptr = '\0';
-
-
- /*
- * Return the expanded content string.
- */
- return buffer;
-}
diff --git a/components/music/id3_frame_text.c b/components/music/id3_frame_text.c
deleted file mode 100644
index 566c4ae9b..000000000
--- a/components/music/id3_frame_text.c
+++ /dev/null
@@ -1,337 +0,0 @@
-/*********************************************************************
- *
- * Copyright (C) 1999, Espen Skoglund
- * Department of Computer Science, University of Tromsø
- *
- * Filename: id3_frame_text.c
- * Description: Code for handling ID3 text frames.
- * Author: Espen Skoglund <espensk@stud.cs.uit.no>
- * Created at: Fri Feb 5 23:50:33 1999
- *
- * $Id$
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- ********************************************************************/
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "id3.h"
-#include "id3_header.h"
-
-
-/*
- * Function id3_get_encoding (frame)
- *
- * Return text encoding for frame, or -1 if frame does not have any
- * text encoding.
- *
- */
-gint8 id3_get_encoding(id3_frame_t *frame)
-{
- /* Type check */
- if ( frame->fr_desc->fd_idstr[0] != 'T' &&
- frame->fr_desc->fd_id != ID3_WXXX &&
- frame->fr_desc->fd_id != ID3_IPLS &&
- frame->fr_desc->fd_id != ID3_USLT &&
- frame->fr_desc->fd_id != ID3_SYLT &&
- frame->fr_desc->fd_id != ID3_COMM &&
- frame->fr_desc->fd_id != ID3_APIC &&
- frame->fr_desc->fd_id != ID3_GEOB &&
- frame->fr_desc->fd_id != ID3_USER &&
- frame->fr_desc->fd_id != ID3_OWNE &&
- frame->fr_desc->fd_id != ID3_COMR )
- return -1;
-
- /* Check if frame is compressed */
- if ( frame->fr_data_z && !frame->fr_data )
- if ( id3_decompress_frame( frame ) == -1 )
- return -1;
-
- return *(gint8 *) frame->fr_data;
-}
-
-
-/*
- * Function id3_set_encoding (frame, encoding)
- *
- * Set text encoding for frame. Return 0 upon success, or -1 if an
- * error occured.
- *
- */
-int id3_set_encoding(id3_frame_t *frame, gint8 encoding)
-{
- /* Type check */
- if ( frame->fr_desc->fd_idstr[0] != 'T' &&
- frame->fr_desc->fd_id != ID3_WXXX &&
- frame->fr_desc->fd_id != ID3_IPLS &&
- frame->fr_desc->fd_id != ID3_USLT &&
- frame->fr_desc->fd_id != ID3_SYLT &&
- frame->fr_desc->fd_id != ID3_COMM &&
- frame->fr_desc->fd_id != ID3_APIC &&
- frame->fr_desc->fd_id != ID3_GEOB &&
- frame->fr_desc->fd_id != ID3_USER &&
- frame->fr_desc->fd_id != ID3_OWNE &&
- frame->fr_desc->fd_id != ID3_COMR )
- return -1;
-
- /* Check if frame is compressed */
- if ( frame->fr_data_z && !frame->fr_data )
- if ( id3_decompress_frame( frame ) == -1 )
- return -1;
-
- /* Changing the encoding of frames is not supported yet */
- if ( *(gint8 *) frame->fr_data != encoding )
- return -1;
-
- /* Set encoding */
- *(gint8 *) frame->fr_data = encoding;
- return 0;
-}
-
-
-/*
- * Function id3_get_text (frame)
- *
- * Return string contents of frame.
- *
- */
-char *id3_get_text(id3_frame_t *frame)
-{
- /* Type check */
- if ( frame->fr_desc->fd_idstr[0] != 'T' )
- return NULL;
-
- /* Check if frame is compressed */
- if ( frame->fr_data_z && !frame->fr_data )
- if ( id3_decompress_frame( frame ) == -1 )
- return NULL;
-
- if ( frame->fr_desc->fd_id == ID3_TXXX ) {
- /*
- * This is a user defined text frame. Skip the description.
- */
- switch ( *(guint8 *) frame->fr_data ) {
- case ID3_ENCODING_ISO_8859_1:
- {
- char *text = (char *) frame->fr_data + 1;
-
- while ( *text != 0 )
- text++;
-
- return ++text;
- }
- case ID3_ENCODING_UNICODE:
- {
- gint16 *text16 = GINT_TO_POINTER ((GPOINTER_TO_INT (frame->fr_data) + 1));
-
- while ( *text16 != 0 )
- text16++;
-
- return (char *) ++text16;
- }
- default:
- return NULL;
- }
- }
-
- return (char *) frame->fr_data + 1;
-}
-
-
-/*
- * Function id3_get_text_desc (frame)
- *
- * Get description part of a text frame.
- *
- */
-char *id3_get_text_desc(id3_frame_t *frame)
-{
- /* Type check */
- if ( frame->fr_desc->fd_idstr[0] != 'T' )
- return NULL;
-
- /* If predefined text frame, return description. */
- if ( frame->fr_desc->fd_id != ID3_TXXX )
- return frame->fr_desc->fd_description;
-
- /* Check if frame is compressed */
- if ( frame->fr_data_z && !frame->fr_data )
- if ( id3_decompress_frame( frame ) == -1 )
- return NULL;
-
- return (char *) frame->fr_data + 1;
-}
-
-
-/*
- * Function id3_get_text_number (frame)
- *
- * Return string contents of frame translated to a positive
- * integer, or -1 if an error occured.
- *
- */
-int id3_get_text_number(id3_frame_t *frame)
-{
- int number = 0;
-
- /* Check if frame is compressed */
- if ( frame->fr_data_z && !frame->fr_data )
- if ( id3_decompress_frame( frame ) == -1 )
- return -1;
-
- /*
- * Generate integer according to encoding.
- */
- switch ( *(guint8 *) frame->fr_data ) {
- case ID3_ENCODING_ISO_8859_1:
- {
- char *text = ((char *) frame->fr_data) + 1;
-
- while ( *text >= '0' && *text <= '9' ) {
- number *= 10;
- number += *text - '0';
- text++;
- }
-
- return number;
- }
- case ID3_ENCODING_UNICODE:
- {
- gint16 *text = ((gint16 *) frame->fr_data) + 1;
-
- while ( *text >= '0' && *text <= '9' ) {
- number *= 10;
- number += *text - '0';
- text++;
- }
-
- return number;
- }
-
- default:
- return -1;
- }
-}
-
-
-/*
- * Function id3_set_text (frame, text)
- *
- * Set text for the indicated frame (only ISO-8859-1 is currently
- * supported). Return 0 upon success, or -1 if an error occured.
- *
- */
-int id3_set_text(id3_frame_t *frame, char *text)
-{
- /* Type check */
- if ( frame->fr_desc->fd_idstr[0] != 'T' )
- return -1;
-
- /*
- * Release memory occupied by previous data.
- */
- if ( frame->fr_data )
- free( frame->fr_data );
- if ( frame->fr_data_z )
- free( frame->fr_data_z );
- frame->fr_data_z = NULL;
- frame->fr_size_z = 0;
-
- /*
- * Allocate memory for new data.
- */
- frame->fr_size = strlen(text) + 1;
- frame->fr_data = malloc( frame->fr_size + 1 );
- if ( frame->fr_data == NULL )
- return -1;
-
- /*
- * Copy contents.
- */
- *(gint8 *) frame->fr_data = ID3_ENCODING_ISO_8859_1;
- memcpy( (char *) frame->fr_data + 1, text, frame->fr_size );
-
- frame->fr_altered = 1;
- frame->fr_owner->id3_altered = 1;
-
- return 0;
-}
-
-
-/*
- * Function id3_set_text_number (frame, number)
- *
- * Set number for the indicated frame (only ISO-8859-1 is currently
- * supported). Return 0 upon success, or -1 if an error occured.
- *
- */
-int id3_set_text_number(id3_frame_t *frame, int number)
-{
- char buf[64];
- int pos;
- char *text;
-
- /* Type check */
- if ( frame->fr_desc->fd_idstr[0] != 'T' )
- return -1;
-
- /*
- * Release memory occupied by previous data.
- */
- if ( frame->fr_data )
- free( frame->fr_data );
- if ( frame->fr_data_z )
- free( frame->fr_data_z );
- frame->fr_data_z = NULL;
- frame->fr_size_z = 0;
-
- /*
- * Create a string with a reversed number.
- */
- pos = 0;
- while ( number > 0 && pos < 64 ) {
- buf[pos++] = (number % 10) + '0';
- number /= 10;
- }
- if ( pos == 64 )
- return -1;
- if ( pos == 0 )
- buf[pos++] = '0';
-
- /*
- * Allocate memory for new data.
- */
- frame->fr_size = pos + 1;
- frame->fr_data = malloc( frame->fr_size + 1 );
- if ( frame->fr_data == NULL )
- return -1;
-
- /*
- * Insert contents.
- */
- *(gint8 *) frame->fr_data = ID3_ENCODING_ISO_8859_1;
- text = (char *) frame->fr_data + 1;
- while ( --pos >= 0 )
- *text++ = buf[pos];
- *text = '\0';
-
- frame->fr_altered = 1;
- frame->fr_owner->id3_altered = 1;
-
- return 0;
-}
diff --git a/components/music/id3_frame_url.c b/components/music/id3_frame_url.c
deleted file mode 100644
index 7b598af3d..000000000
--- a/components/music/id3_frame_url.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*********************************************************************
- *
- * Copyright (C) 1999,
- * Department of Computer Science, University of Tromsø
- *
- * Filename: id3_frame_url.c
- * Description: Code for handling ID3 URL frames.
- * Author: Espen Skoglund <espensk@stud.cs.uit.no>
- * Created at: Tue Feb 9 21:10:45 1999
- *
- * $Id$
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- ********************************************************************/
-#include <stdio.h>
-
-#include "id3.h"
-#include "id3_header.h"
-
-
-/*
- * Function id3_get_url (frame)
- *
- * Return URL of frame.
- *
- */
-char *id3_get_url(id3_frame_t *frame)
-{
- /* Type check */
- if ( frame->fr_desc->fd_idstr[0] != 'W' )
- return NULL;
-
- /* Check if frame is compressed */
- if ( frame->fr_data_z && !frame->fr_data )
- if ( id3_decompress_frame( frame ) == -1 )
- return NULL;
-
- if ( frame->fr_desc->fd_id == ID3_WXXX ) {
- /*
- * This is a user defined link frame. Skip the description.
- */
- switch ( *(guint8 *) frame->fr_data ) {
- case ID3_ENCODING_ISO_8859_1:
- {
- char *text = (char *) frame->fr_data + 1;
-
- while ( *text != 0 )
- text++;
-
- return ++text;
- }
- case ID3_ENCODING_UNICODE:
- {
- gint16 *text16 = GINT_TO_POINTER ((GPOINTER_TO_INT (frame->fr_data) + 1));
-
- while ( *text16 != 0 )
- text16++;
-
- return (char *) ++text16;
- }
- default:
- return NULL;
- }
- }
-
- return (char *) frame->fr_data;
-}
-
-
-/*
- * Function id3_get_url_desc (frame)
- *
- * Get description of a URL.
- *
- */
-char *id3_get_url_desc(id3_frame_t *frame)
-{
- /* Type check */
- if ( frame->fr_desc->fd_idstr[0] != 'W' )
- return NULL;
-
- /* If predefined link frame, return description. */
- if ( frame->fr_desc->fd_id != ID3_WXXX )
- return frame->fr_desc->fd_description;
-
- /* Check if frame is compressed */
- if ( frame->fr_data_z && !frame->fr_data )
- if ( id3_decompress_frame( frame ) == -1 )
- return NULL;
-
- return (char *) frame->fr_data + 1;
-}
diff --git a/components/music/id3_header.h b/components/music/id3_header.h
deleted file mode 100644
index 3827bd418..000000000
--- a/components/music/id3_header.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*********************************************************************
- *
- * Copyright (C) 1998, 1999, Espen Skoglund
- * Department of Computer Science, University of Tromsø
- *
- * Filename: id3_header.h
- * Description: Definitions for various ID3 headers.
- * Author: Espen Skoglund <espensk@stud.cs.uit.no>
- * Created at: Thu Nov 5 15:55:10 1998
- *
- * $Id$
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- ********************************************************************/
-#ifndef ID3_HEADER_H
-#define ID3_HEADER_H
-
-#ifndef __GNUC__
-#define __attribute__(A)
-#endif
-
-/*
- * Layout for the ID3 tag header.
- */
-typedef struct id3_taghdr_t id3_taghdr_t;
-struct id3_taghdr_t {
- guint8 th_version;
- guint8 th_revision;
- guint8 th_flags;
- guint32 th_size;
-} __attribute__ ((packed));
-
-#define ID3_THFLAG_USYNC 0x80000000
-#define ID3_THFLAG_EXT 0x40000000
-#define ID3_THFLAG_EXP 0x20000000
-
-#define ID3_SET_SIZE28(size) \
- ( ((size << 3) & 0x7f000000) | \
- ((size << 2) & 0x007f0000) | \
- ((size << 1) & 0x00007f00) | \
- ((size ) & 0x0000007f) )
-
-#define ID3_GET_SIZE28(size) \
- ( ((size & 0x7f000000) >> 3) | \
- ((size & 0x007f0000) >> 2) | \
- ((size & 0x00007f00) >> 1) | \
- ((size & 0x0000007f) ) )
-
-
-
-/*
- * Layout for the extended header.
- */
-typedef struct id3_exthdr_t id3_exthdr_t;
-struct id3_exthdr_t {
- guint32 eh_size;
- guint16 eh_flags;
- guint32 eh_padsize;
-} __attribute__ ((packed));
-
-#define ID3_EHFLAG_CRC 0x80000000
-
-
-
-/*
- * Layout for the frame header.
- */
-typedef struct id3_framehdr_t id3_framehdr_t;
-struct id3_framehdr_t {
- guint32 fh_id;
- guint32 fh_size;
- guint16 fh_flags;
-} __attribute__ ((packed));
-
-#define ID3_FHFLAG_TAGALT 0x8000
-#define ID3_FHFLAG_FILEALT 0x4000
-#define ID3_FHFLAG_RO 0x2000
-#define ID3_FHFLAG_COMPRESS 0x0080
-#define ID3_FHFLAG_ENCRYPT 0x0040
-#define ID3_FHFLAG_GROUP 0x0020
-
-
-typedef enum {
- ID3_UNI_LATIN = 0x007f,
- ID3_UNI_LATIN_1 = 0x00ff,
-
- ID3_UNI_SUPPORTED = 0x00ff,
- ID3_UNI_UNSUPPORTED = 0xffff,
-} id3_unicode_blocks;
-
-
-#ifdef DEBUG_ID3
-#define id3_error(id3, error) \
- (void) ( id3->id3_error_msg = error, \
- printf( "Error %s, line %d: %s\n", __FILE__, __LINE__, error ) )
-
-
-#else
-#define id3_error(id3, error) \
- (void) ( id3->id3_error_msg = error )
-
-#endif
-
-
-#endif /* ID3_HEADER_H */
diff --git a/components/music/id3_tag.c b/components/music/id3_tag.c
deleted file mode 100644
index 196873a38..000000000
--- a/components/music/id3_tag.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/*********************************************************************
- *
- * Copyright (C) 1999-2000, Espen Skoglund
- * Department of Computer Science, University of Tromsø
- *
- * Filename: id3_tag.c
- * Description: Code for handling ID3 tags.
- * Author: Espen Skoglund <espensk@stud.cs.uit.no>
- * Created at: Tue Feb 9 21:13:19 1999
- *
- * $Id$
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- ********************************************************************/
-#include <glib.h>
-#include <stdio.h>
-
-#include "id3.h"
-#include "id3_header.h"
-
-
-/*
- * Function id3_init_tag (id3)
- *
- * Initialize an empty ID3 tag.
- *
- */
-void id3_init_tag(id3_t *id3)
-{
- /*
- * Initialize header.
- */
- id3->id3_version = 3;
- id3->id3_revision = 0;
- id3->id3_flags = ID3_THFLAG_USYNC | ID3_THFLAG_EXP;
- id3->id3_tagsize = 0;
-
- id3->id3_altered = 1;
- id3->id3_newtag = 1;
- id3->id3_pos = 0;
-
- /*
- * Initialize frames.
- */
- id3->id3_numframes = 0;
- id3->id3_frame = id3->id3_tail = NULL;
-}
-
-
-/*
- * Function id3_read_tag (id3)
- *
- * Read the ID3 tag from the input stream. The start of the tag
- * must be positioned in the next tag in the stream. Return 0 upon
- * success, or -1 if an error occured.
- *
- */
-int id3_read_tag(id3_t *id3)
-{
- id3_taghdr_t *taghdr;
- id3_exthdr_t *exthdr;
- char *id;
-
- /*
- * We know that the tag will be at least this big.
- */
- id3->id3_tagsize = sizeof(*taghdr) + 3;
-
- if ( !(id3->id3_oflags & ID3_OPENF_NOCHK) ) {
- /*
- * Check if we have a valid ID3 tag.
- */
- id = id3->id3_read( id3, NULL, 3 );
- if ( id == NULL )
- return -1;
-
- if ( id[0] != 'I' || id[1] != 'D' || id[2] != '3' ) {
- /*
- * ID3 tag was not detected.
- */
- id3->id3_seek( id3, -3 );
- return -1;
- }
- }
-
- /*
- * Read ID3 tag-header.
- */
- taghdr = id3->id3_read( id3, NULL, sizeof(*taghdr) );
- if ( taghdr == NULL )
- return -1;
-
- id3->id3_version = taghdr->th_version;
- id3->id3_revision = taghdr->th_revision;
- id3->id3_flags = taghdr->th_flags;
- id3->id3_tagsize = ID3_GET_SIZE28( g_ntohl(taghdr->th_size) );
- id3->id3_newtag = 0;
- id3->id3_pos = 0;
-
- /*
- * Parse extended header.
- */
- if ( taghdr->th_flags & ID3_THFLAG_EXT ) {
- exthdr = id3->id3_read( id3, NULL, sizeof(*exthdr) );
- if ( exthdr == NULL )
- return -1;
- }
-
- /*
- * Parse frames.
- */
- while ( id3->id3_pos < id3->id3_tagsize ) {
- if ( id3_read_frame( id3 ) == -1 )
- return -1;
- }
-
- return 0;
-}
diff --git a/components/music/l2tables.h b/components/music/l2tables.h
deleted file mode 100644
index 51eb22f35..000000000
--- a/components/music/l2tables.h
+++ /dev/null
@@ -1,997 +0,0 @@
-/*
- * Layer 2 Alloc tables ..
- * most other tables are calculated on program start (which is (of course)
- * not ISO-conform) ..
- * Layer-3 huffman table is in huffman.h
- */
-
-struct al_table alloc_0[] =
-{
- {4, 0},
- {5, 3},
- {3, -3},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {14, -8191},
- {15, -16383},
- {16, -32767},
- {4, 0},
- {5, 3},
- {3, -3},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {14, -8191},
- {15, -16383},
- {16, -32767},
- {4, 0},
- {5, 3},
- {3, -3},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {14, -8191},
- {15, -16383},
- {16, -32767},
- {4, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {16, -32767},
- {4, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {16, -32767},
- {4, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {16, -32767},
- {4, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {16, -32767},
- {4, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {16, -32767},
- {4, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {16, -32767},
- {4, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {16, -32767},
- {4, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {16, -32767},
- {3, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {16, -32767},
- {3, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {16, -32767},
- {3, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {16, -32767},
- {3, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {16, -32767},
- {3, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {16, -32767},
- {3, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {16, -32767},
- {3, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {16, -32767},
- {3, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {16, -32767},
- {3, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {16, -32767},
- {3, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {16, -32767},
- {3, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {16, -32767},
- {3, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {16, -32767},
- {2, 0},
- {5, 3},
- {7, 5},
- {16, -32767},
- {2, 0},
- {5, 3},
- {7, 5},
- {16, -32767},
- {2, 0},
- {5, 3},
- {7, 5},
- {16, -32767},
- {2, 0},
- {5, 3},
- {7, 5},
- {16, -32767}};
-
-struct al_table alloc_1[] =
-{
- {4, 0},
- {5, 3},
- {3, -3},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {14, -8191},
- {15, -16383},
- {16, -32767},
- {4, 0},
- {5, 3},
- {3, -3},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {14, -8191},
- {15, -16383},
- {16, -32767},
- {4, 0},
- {5, 3},
- {3, -3},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {14, -8191},
- {15, -16383},
- {16, -32767},
- {4, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {16, -32767},
- {4, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {16, -32767},
- {4, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {16, -32767},
- {4, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {16, -32767},
- {4, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {16, -32767},
- {4, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {16, -32767},
- {4, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {16, -32767},
- {4, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {16, -32767},
- {3, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {16, -32767},
- {3, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {16, -32767},
- {3, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {16, -32767},
- {3, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {16, -32767},
- {3, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {16, -32767},
- {3, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {16, -32767},
- {3, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {16, -32767},
- {3, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {16, -32767},
- {3, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {16, -32767},
- {3, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {16, -32767},
- {3, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {16, -32767},
- {3, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {16, -32767},
- {2, 0},
- {5, 3},
- {7, 5},
- {16, -32767},
- {2, 0},
- {5, 3},
- {7, 5},
- {16, -32767},
- {2, 0},
- {5, 3},
- {7, 5},
- {16, -32767},
- {2, 0},
- {5, 3},
- {7, 5},
- {16, -32767},
- {2, 0},
- {5, 3},
- {7, 5},
- {16, -32767},
- {2, 0},
- {5, 3},
- {7, 5},
- {16, -32767},
- {2, 0},
- {5, 3},
- {7, 5},
- {16, -32767}};
-
-struct al_table alloc_2[] =
-{
- {4, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {14, -8191},
- {15, -16383},
- {4, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {14, -8191},
- {15, -16383},
- {3, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {3, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {3, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {3, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {3, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {3, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63}};
-
-struct al_table alloc_3[] =
-{
- {4, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {14, -8191},
- {15, -16383},
- {4, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {14, -8191},
- {15, -16383},
- {3, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {3, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {3, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {3, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {3, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {3, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {3, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {3, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {3, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {3, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63}};
-
-struct al_table alloc_4[] =
-{
- {4, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {14, -8191},
- {4, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {14, -8191},
- {4, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {14, -8191},
- {4, 0},
- {5, 3},
- {7, 5},
- {3, -3},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {8, -127},
- {9, -255},
- {10, -511},
- {11, -1023},
- {12, -2047},
- {13, -4095},
- {14, -8191},
- {3, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {3, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {3, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {3, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {3, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {3, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {3, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {4, -7},
- {5, -15},
- {6, -31},
- {7, -63},
- {2, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {2, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {2, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {2, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {2, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {2, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {2, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {2, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {2, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {2, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {2, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {2, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {2, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {2, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {2, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {2, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {2, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {2, 0},
- {5, 3},
- {7, 5},
- {10, 9},
- {2, 0},
- {5, 3},
- {7, 5},
- {10, 9}};
diff --git a/components/music/layer1.c b/components/music/layer1.c
deleted file mode 100644
index 32915644c..000000000
--- a/components/music/layer1.c
+++ /dev/null
@@ -1,191 +0,0 @@
-
-/*
- * Mpeg Layer-1 audio decoder
- * --------------------------
- * copyright (c) 1995 by Michael Hipp, All rights reserved. See also 'README'
- * near unoptimzed ...
- *
- * may have a few bugs after last optimization ...
- *
- */
-
-#include "esd-audio.h"
-#include "mpg123.h"
-#include "getbits.h"
-
-/* Used by the getbits macros */
-static unsigned long rval;
-
-static void
-I_step_one(unsigned int balloc[], unsigned int scale_index[2][SBLIMIT], struct frame *fr)
-{
- unsigned int *ba = balloc;
- unsigned int *sca = (unsigned int *) scale_index;
-
- if (fr->stereo)
- {
- int i;
- int jsbound = fr->jsbound;
-
- for (i = 0; i < jsbound; i++)
- {
- *ba++ = mpg123_getbits(4);
- *ba++ = mpg123_getbits(4);
- }
- for (i = jsbound; i < SBLIMIT; i++)
- *ba++ = mpg123_getbits(4);
-
- ba = balloc;
-
- for (i = 0; i < jsbound; i++)
- {
- if ((*ba++))
- *sca++ = mpg123_getbits(6);
- if ((*ba++))
- *sca++ = mpg123_getbits(6);
- }
- for (i = jsbound; i < SBLIMIT; i++)
- if ((*ba++))
- {
- *sca++ = mpg123_getbits(6);
- *sca++ = mpg123_getbits(6);
- }
- }
- else
- {
- int i;
-
- for (i = 0; i < SBLIMIT; i++)
- *ba++ = mpg123_getbits(4);
- ba = balloc;
- for (i = 0; i < SBLIMIT; i++)
- if ((*ba++))
- *sca++ = mpg123_getbits(6);
- }
-}
-
-static void
-I_step_two(real fraction[2][SBLIMIT], unsigned int balloc[2 * SBLIMIT],
- unsigned int scale_index[2][SBLIMIT], struct frame *fr)
-{
- int i, n;
- int smpb[2 * SBLIMIT]; /* values: 0-65535 */
- int *sample;
- register unsigned int *ba;
- register unsigned int *sca = (unsigned int *) scale_index;
-
- if (fr->stereo)
- {
- int jsbound = fr->jsbound;
- register real *f0 = fraction[0];
- register real *f1 = fraction[1];
-
- ba = balloc;
- for (sample = smpb, i = 0; i < jsbound; i++)
- {
- if ((n = *ba++))
- *sample++ = mpg123_getbits(n + 1);
- if ((n = *ba++))
- *sample++ = mpg123_getbits(n + 1);
- }
- for (i = jsbound; i < SBLIMIT; i++)
- if ((n = *ba++))
- *sample++ = mpg123_getbits(n + 1);
-
- ba = balloc;
- for (sample = smpb, i = 0; i < jsbound; i++)
- {
- if ((n = *ba++))
- *f0++ = (real) (((-1) << n) + (*sample++) + 1) * mpg123_muls[n + 1][*sca++];
- else
- *f0++ = 0.0;
- if ((n = *ba++))
- *f1++ = (real) (((-1) << n) + (*sample++) + 1) * mpg123_muls[n + 1][*sca++];
- else
- *f1++ = 0.0;
- }
- for (i = jsbound; i < SBLIMIT; i++)
- {
- if ((n = *ba++))
- {
- real samp = (((-1) << n) + (*sample++) + 1);
-
- *f0++ = samp * mpg123_muls[n + 1][*sca++];
- *f1++ = samp * mpg123_muls[n + 1][*sca++];
- }
- else
- *f0++ = *f1++ = 0.0;
- }
- for (i = fr->down_sample_sblimit; i < 32; i++)
- fraction[0][i] = fraction[1][i] = 0.0;
- }
- else
- {
- register real *f0 = fraction[0];
-
- ba = balloc;
- for (sample = smpb, i = 0; i < SBLIMIT; i++)
- if ((n = *ba++))
- *sample++ = mpg123_getbits(n + 1);
- ba = balloc;
- for (sample = smpb, i = 0; i < SBLIMIT; i++)
- {
- if ((n = *ba++))
- *f0++ = (real) (((-1) << n) + (*sample++) + 1) * mpg123_muls[n + 1][*sca++];
- else
- *f0++ = 0.0;
- }
- for (i = fr->down_sample_sblimit; i < 32; i++)
- fraction[0][i] = 0.0;
- }
-}
-
-int mpg123_do_layer1(struct frame *fr)
-{
- int i, stereo = fr->stereo;
- unsigned int balloc[2 * SBLIMIT];
- unsigned int scale_index[2][SBLIMIT];
- real fraction[2][SBLIMIT];
- int single = fr->single;
-
- fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? (fr->mode_ext << 2) + 4 : 32;
-
- if (stereo == 1 || single == 3)
- single = 0;
-
- I_step_one (balloc, scale_index, fr);
-
- for (i = 0; i < SCALE_BLOCK; i++)
- {
- I_step_two (fraction, balloc, scale_index, fr);
-
- if (single >= 0)
- {
- (fr->synth_mono) ((real *) fraction[single], mpg123_pcm_sample, &mpg123_pcm_point);
- }
- else
- {
- int p1 = mpg123_pcm_point;
-
- (fr->synth) ((real *) fraction[0], 0, mpg123_pcm_sample, &p1);
- (fr->synth) ((real *) fraction[1], 1, mpg123_pcm_sample, &mpg123_pcm_point);
- }
-
- if (mpg123_info->output_audio)
- {
-
- //mpg123_ip.add_vis_pcm(mpg123_ip.output->written_time(), mpg123_cfg.resolution == 16 ? FMT_S16_NE : FMT_U8,
- // mpg123_cfg.channels == 2 ? fr->stereo : 1, mpg123_pcm_point, mpg123_pcm_sample);
- while (esdout_free () < mpg123_pcm_point && mpg123_info->going && mpg123_info->jump_to_time == -1) {
- usleep(10000);
- }
-
- if (mpg123_info->going && mpg123_info->jump_to_time == -1) {
- esdout_write (mpg123_pcm_sample, mpg123_pcm_point);
- }
- }
- mpg123_pcm_point = 0;
- }
-
- return 1;
-}
diff --git a/components/music/layer2.c b/components/music/layer2.c
deleted file mode 100644
index af234b7af..000000000
--- a/components/music/layer2.c
+++ /dev/null
@@ -1,340 +0,0 @@
-
-/*
- * Mpeg Layer-2 audio decoder
- * --------------------------
- * copyright (c) 1995 by Michael Hipp, All rights reserved. See also 'README'
- *
- */
-
-#include "esd-audio.h"
-#include "mpg123.h"
-#include "l2tables.h"
-#include "getbits.h"
-
-static int grp_3tab[32 * 3] =
-{0,}; /* used: 27 */
-static int grp_5tab[128 * 3] =
-{0,}; /* used: 125 */
-static int grp_9tab[1024 * 3] =
-{0,}; /* used: 729 */
-
-real mpg123_muls[27][64]; /* also used by layer 1 */
-
-/* Used by the getbits macros */
-static unsigned long rval;
-
-void mpg123_init_layer2(void)
-{
- static double mulmul[27] =
- {
- 0.0, -2.0 / 3.0, 2.0 / 3.0,
- 2.0 / 7.0, 2.0 / 15.0, 2.0 / 31.0, 2.0 / 63.0, 2.0 / 127.0, 2.0 / 255.0,
- 2.0 / 511.0, 2.0 / 1023.0, 2.0 / 2047.0, 2.0 / 4095.0, 2.0 / 8191.0,
- 2.0 / 16383.0, 2.0 / 32767.0, 2.0 / 65535.0,
- -4.0 / 5.0, -2.0 / 5.0, 2.0 / 5.0, 4.0 / 5.0,
- -8.0 / 9.0, -4.0 / 9.0, -2.0 / 9.0, 2.0 / 9.0, 4.0 / 9.0, 8.0 / 9.0};
- static int base[3][9] =
- {
- {1, 0, 2,},
- {17, 18, 0, 19, 20,},
- {21, 1, 22, 23, 0, 24, 25, 2, 26}};
- int i, j, k, l, len;
- real *table;
- static int tablen[3] =
- {3, 5, 9};
- static int *itable, *tables[3] =
- {grp_3tab, grp_5tab, grp_9tab};
-
- for (i = 0; i < 3; i++)
- {
- itable = tables[i];
- len = tablen[i];
- for (j = 0; j < len; j++)
- for (k = 0; k < len; k++)
- for (l = 0; l < len; l++)
- {
- *itable++ = base[i][l];
- *itable++ = base[i][k];
- *itable++ = base[i][j];
- }
- }
-
- for (k = 0; k < 27; k++)
- {
- double m = mulmul[k];
-
- table = mpg123_muls[k];
- for (j = 3, i = 0; i < 63; i++, j--)
- *table++ = m * pow(2.0, (double) j / 3.0);
- *table++ = 0.0;
- }
-}
-
-static void
-II_step_one(unsigned int *bit_alloc, int *scale, struct frame *fr)
-{
- int stereo = fr->stereo - 1;
- int sblimit = fr->II_sblimit;
- int jsbound = fr->jsbound;
- int sblimit2 = fr->II_sblimit << stereo;
- struct al_table *alloc1 = fr->alloc;
- int i;
- static unsigned int scfsi_buf[64];
- unsigned int *scfsi, *bita;
- int sc, step;
-
- bita = bit_alloc;
- if (stereo)
- {
- for (i = jsbound; i > 0; i--, alloc1 += (1 << step))
- {
- *bita++ = (char) mpg123_getbits(step = alloc1->bits);
- *bita++ = (char) mpg123_getbits(step);
- }
- for (i = sblimit - jsbound; i > 0; i--, alloc1 += (1 << step))
- {
- bita[0] = (char) mpg123_getbits(step = alloc1->bits);
- bita[1] = bita[0];
- bita += 2;
- }
- bita = bit_alloc;
- scfsi = scfsi_buf;
- for (i = sblimit2; i; i--)
- if (*bita++)
- *scfsi++ = (char) mpg123_getbits_fast(2);
- }
- else
- /* mono */
- {
- for (i = sblimit; i; i--, alloc1 += (1 << step))
- *bita++ = (char) mpg123_getbits(step = alloc1->bits);
- bita = bit_alloc;
- scfsi = scfsi_buf;
- for (i = sblimit; i; i--)
- if (*bita++)
- *scfsi++ = (char) mpg123_getbits_fast(2);
- }
-
- bita = bit_alloc;
- scfsi = scfsi_buf;
- for (i = sblimit2; i; i--)
- if (*bita++)
- switch (*scfsi++)
- {
- case 0:
- *scale++ = mpg123_getbits_fast(6);
- *scale++ = mpg123_getbits_fast(6);
- *scale++ = mpg123_getbits_fast(6);
- break;
- case 1:
- *scale++ = sc = mpg123_getbits_fast(6);
- *scale++ = sc;
- *scale++ = mpg123_getbits_fast(6);
- break;
- case 2:
- *scale++ = sc = mpg123_getbits_fast(6);
- *scale++ = sc;
- *scale++ = sc;
- break;
- default: /* case 3 */
- *scale++ = mpg123_getbits_fast(6);
- *scale++ = sc = mpg123_getbits_fast(6);
- *scale++ = sc;
- break;
- }
-
-}
-
-static void
-II_step_two(unsigned int *bit_alloc, real fraction[2][4][SBLIMIT], int *scale, struct frame *fr, int x1)
-{
- int i, j, k, ba;
- int stereo = fr->stereo;
- int sblimit = fr->II_sblimit;
- int jsbound = fr->jsbound;
- struct al_table *alloc2, *alloc1 = fr->alloc;
- unsigned int *bita = bit_alloc;
- int d1, step;
-
- for (i = 0; i < jsbound; i++, alloc1 += (1 << step))
- {
- step = alloc1->bits;
- for (j = 0; j < stereo; j++)
- {
- if ((ba = *bita++))
- {
- k = (alloc2 = alloc1 + ba)->bits;
- if ((d1 = alloc2->d) < 0)
- {
- real cm = mpg123_muls[k][scale[x1]];
-
- fraction[j][0][i] = ((real) ((int) mpg123_getbits(k) + d1)) * cm;
- fraction[j][1][i] = ((real) ((int) mpg123_getbits(k) + d1)) * cm;
- fraction[j][2][i] = ((real) ((int) mpg123_getbits(k) + d1)) * cm;
- }
- else
- {
- static int *table[] =
- {0, 0, 0, grp_3tab, 0, grp_5tab, 0, 0, 0, grp_9tab};
- unsigned int idx, *tab, m = scale[x1];
-
- idx = (unsigned int) mpg123_getbits(k);
- tab = (unsigned int *) (table[d1] + idx + idx + idx);
- fraction[j][0][i] = mpg123_muls[*tab++][m];
- fraction[j][1][i] = mpg123_muls[*tab++][m];
- fraction[j][2][i] = mpg123_muls[*tab][m];
- }
- scale += 3;
- }
- else
- fraction[j][0][i] = fraction[j][1][i] = fraction[j][2][i] = 0.0;
- }
- }
-
- for (i = jsbound; i < sblimit; i++, alloc1 += (1 << step))
- {
- step = alloc1->bits;
- bita++; /* channel 1 and channel 2 bitalloc are the same */
- if ((ba = *bita++))
- {
- k = (alloc2 = alloc1 + ba)->bits;
- if ((d1 = alloc2->d) < 0)
- {
- real cm;
-
- cm = mpg123_muls[k][scale[x1 + 3]];
- fraction[1][0][i] = (fraction[0][0][i] = (real) ((int) mpg123_getbits(k) + d1)) * cm;
- fraction[1][1][i] = (fraction[0][1][i] = (real) ((int) mpg123_getbits(k) + d1)) * cm;
- fraction[1][2][i] = (fraction[0][2][i] = (real) ((int) mpg123_getbits(k) + d1)) * cm;
- cm = mpg123_muls[k][scale[x1]];
- fraction[0][0][i] *= cm;
- fraction[0][1][i] *= cm;
- fraction[0][2][i] *= cm;
- }
- else
- {
- static int *table[] =
- {0, 0, 0, grp_3tab, 0, grp_5tab, 0, 0, 0, grp_9tab};
- unsigned int idx, *tab, m1, m2;
-
- m1 = scale[x1];
- m2 = scale[x1 + 3];
- idx = (unsigned int) mpg123_getbits(k);
- tab = (unsigned int *) (table[d1] + idx + idx + idx);
- fraction[0][0][i] = mpg123_muls[*tab][m1];
- fraction[1][0][i] = mpg123_muls[*tab++][m2];
- fraction[0][1][i] = mpg123_muls[*tab][m1];
- fraction[1][1][i] = mpg123_muls[*tab++][m2];
- fraction[0][2][i] = mpg123_muls[*tab][m1];
- fraction[1][2][i] = mpg123_muls[*tab][m2];
- }
- scale += 6;
- }
- else
- {
- fraction[0][0][i] = fraction[0][1][i] = fraction[0][2][i] =
- fraction[1][0][i] = fraction[1][1][i] = fraction[1][2][i] = 0.0;
- }
-/*
- should we use individual scalefac for channel 2 or
- is the current way the right one , where we just copy channel 1 to
- channel 2 ??
- The current 'strange' thing is, that we throw away the scalefac
- values for the second channel ...!!
- -> changed .. now we use the scalefac values of channel one !!
- */
- }
-
- if (sblimit > (fr->down_sample_sblimit))
- sblimit = fr->down_sample_sblimit;
-
- for (i = sblimit; i < SBLIMIT; i++)
- for (j = 0; j < stereo; j++)
- fraction[j][0][i] = fraction[j][1][i] = fraction[j][2][i] = 0.0;
-
-}
-
-static void II_select_table(struct frame *fr)
-{
- static int translate[3][2][16] = {
- {{0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 1, 1, 1, 1, 1, 0},
- {0, 2, 2, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}},
- {{0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
- {{0, 3, 3, 3, 3, 3, 3, 0, 0, 0, 1, 1, 1, 1, 1, 0},
- {0, 3, 3, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}}
- };
-
- int table, sblim;
- static struct al_table *tables[5] =
- {alloc_0, alloc_1, alloc_2, alloc_3, alloc_4};
- static int sblims[5] = { 27, 30, 8, 12, 30 };
-
- if (fr->lsf)
- table = 4;
- else
- table = translate[fr->sampling_frequency][2 - fr->stereo][fr->bitrate_index];
- sblim = sblims[table];
-
- fr->alloc = tables[table];
- fr->II_sblimit = sblim;
-}
-
-
-int
-mpg123_do_layer2(struct frame *fr)
-{
- int i, j;
- int stereo = fr->stereo;
- real fraction[2][4][SBLIMIT]; /* pick_table clears unused subbands */
- unsigned int bit_alloc[64];
- int scale[192];
- int single = fr->single;
-
- II_select_table(fr);
- fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ?
- (fr->mode_ext << 2) + 4 : fr->II_sblimit;
-
- if (stereo == 1 || single == 3)
- single = 0;
-
- II_step_one(bit_alloc, scale, fr);
-
- for (i = 0; i < SCALE_BLOCK; i++)
- {
- II_step_two(bit_alloc, fraction, scale, fr, i >> 2);
- for (j = 0; j < 3; j++)
- {
- if (single >= 0)
- {
- (fr->synth_mono) (fraction[single][j], mpg123_pcm_sample, &mpg123_pcm_point);
- }
- else
- {
- int p1 = mpg123_pcm_point;
-
- (fr->synth) (fraction[0][j], 0, mpg123_pcm_sample, &p1);
- (fr->synth) (fraction[1][j], 1, mpg123_pcm_sample, &mpg123_pcm_point);
- }
-
- /* if(mpg123_pcm_point >= audiobufsize)
- audio_flush(outmode,ai); */
- }
- }
-
- if (mpg123_info->output_audio) {
-
- //mpg123_ip.add_vis_pcm(mpg123_ip.output->written_time(), mpg123_cfg.resolution == 16 ? FMT_S16_NE : FMT_U8,
- // mpg123_cfg.channels == 2 ? fr->stereo : 1, mpg123_pcm_point, mpg123_pcm_sample);
- while (esdout_free () < mpg123_pcm_point && mpg123_info->going && mpg123_info->jump_to_time == -1) {
- usleep(10000);
- }
-
- if (mpg123_info->going && mpg123_info->jump_to_time == -1) {
- esdout_write (mpg123_pcm_sample, mpg123_pcm_point);
- }
- }
- mpg123_pcm_point = 0;
-
- return 1;
-}
diff --git a/components/music/layer3.c b/components/music/layer3.c
deleted file mode 100644
index c6bf7c6c1..000000000
--- a/components/music/layer3.c
+++ /dev/null
@@ -1,2104 +0,0 @@
-
-/*
- * Mpeg Layer-3 audio decoder
- * --------------------------
- * copyright (c) 1995-1999 by Michael Hipp.
- * All rights reserved. See also 'README'
- *
- * Optimize-TODO: put short bands into the band-field without the stride of 3 reals
- * Length-optimze: unify long and short band code where it is possible
- */
-
-#include <stdlib.h>
-#include "esd-audio.h"
-#include "mpg123.h"
-#include "huffman.h"
-
-#include "getbits.h"
-
-static real ispow[8207];
-static real aa_ca[8], aa_cs[8];
-static real COS1[12][6];
-static real win[4][36];
-static real win1[4][36];
-static real gainpow2[256 + 118 + 4];
-real COS9[9];
-static real COS6_1, COS6_2;
-real tfcos36[9];
-static real tfcos12[3];
-#define NEW_DCT9
-#ifdef NEW_DCT9
-static real cos9[3], cos18[3];
-#endif
-
-struct bandInfoStruct
-{
- int longIdx[23];
- int longDiff[22];
- int shortIdx[14];
- int shortDiff[13];
-};
-
-int longLimit[9][23];
-int shortLimit[9][14];
-
-/* Used by the getbits macros */
-static unsigned long rval;
-static unsigned char rval_uc;
-
-struct bandInfoStruct bandInfo[9] =
-{
-
-/* MPEG 1.0 */
- {
- {0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 52, 62, 74, 90, 110, 134, 162, 196, 238, 288, 342, 418, 576},
- {4, 4, 4, 4, 4, 4, 6, 6, 8, 8, 10, 12, 16, 20, 24, 28, 34, 42, 50, 54, 76, 158},
- {0, 4 * 3, 8 * 3, 12 * 3, 16 * 3, 22 * 3, 30 * 3, 40 * 3, 52 * 3, 66 * 3, 84 * 3, 106 * 3, 136 * 3, 192 * 3},
- {4, 4, 4, 4, 6, 8, 10, 12, 14, 18, 22, 30, 56}},
-
- {
- {0, 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 60, 72, 88, 106, 128, 156, 190, 230, 276, 330, 384, 576},
- {4, 4, 4, 4, 4, 4, 6, 6, 6, 8, 10, 12, 16, 18, 22, 28, 34, 40, 46, 54, 54, 192},
- {0, 4 * 3, 8 * 3, 12 * 3, 16 * 3, 22 * 3, 28 * 3, 38 * 3, 50 * 3, 64 * 3, 80 * 3, 100 * 3, 126 * 3, 192 * 3},
- {4, 4, 4, 4, 6, 6, 10, 12, 14, 16, 20, 26, 66}},
-
- {
- {0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 54, 66, 82, 102, 126, 156, 194, 240, 296, 364, 448, 550, 576},
- {4, 4, 4, 4, 4, 4, 6, 6, 8, 10, 12, 16, 20, 24, 30, 38, 46, 56, 68, 84, 102, 26},
- {0, 4 * 3, 8 * 3, 12 * 3, 16 * 3, 22 * 3, 30 * 3, 42 * 3, 58 * 3, 78 * 3, 104 * 3, 138 * 3, 180 * 3, 192 * 3},
- {4, 4, 4, 4, 6, 8, 12, 16, 20, 26, 34, 42, 12}},
-
-/* MPEG 2.0 */
- {
- {0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576},
- {6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, 20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54},
- {0, 4 * 3, 8 * 3, 12 * 3, 18 * 3, 24 * 3, 32 * 3, 42 * 3, 56 * 3, 74 * 3, 100 * 3, 132 * 3, 174 * 3, 192 * 3},
- {4, 4, 4, 6, 6, 8, 10, 14, 18, 26, 32, 42, 18}},
-
- {
- {0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 114, 136, 162, 194, 232, 278, 330, 394, 464, 540, 576},
- {6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, 18, 22, 26, 32, 38, 46, 52, 64, 70, 76, 36},
- {0, 4 * 3, 8 * 3, 12 * 3, 18 * 3, 26 * 3, 36 * 3, 48 * 3, 62 * 3, 80 * 3, 104 * 3, 136 * 3, 180 * 3, 192 * 3},
- {4, 4, 4, 6, 8, 10, 12, 14, 18, 24, 32, 44, 12}},
-
- {
- {0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576},
- {6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, 20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54},
- {0, 4 * 3, 8 * 3, 12 * 3, 18 * 3, 26 * 3, 36 * 3, 48 * 3, 62 * 3, 80 * 3, 104 * 3, 134 * 3, 174 * 3, 192 * 3},
- {4, 4, 4, 6, 8, 10, 12, 14, 18, 24, 30, 40, 18}},
-/* MPEG 2.5 */
- {
- {0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576},
- {6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, 20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54},
- {0, 12, 24, 36, 54, 78, 108, 144, 186, 240, 312, 402, 522, 576},
- {4, 4, 4, 6, 8, 10, 12, 14, 18, 24, 30, 40, 18}},
- {
- {0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576},
- {6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, 20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54},
- {0, 12, 24, 36, 54, 78, 108, 144, 186, 240, 312, 402, 522, 576},
- {4, 4, 4, 6, 8, 10, 12, 14, 18, 24, 30, 40, 18}},
- {
- {0, 12, 24, 36, 48, 60, 72, 88, 108, 132, 160, 192, 232, 280, 336, 400, 476, 566, 568, 570, 572, 574, 576},
- {12, 12, 12, 12, 12, 12, 16, 20, 24, 28, 32, 40, 48, 56, 64, 76, 90, 2, 2, 2, 2, 2},
- {0, 24, 48, 72, 108, 156, 216, 288, 372, 480, 486, 492, 498, 576},
- {8, 8, 8, 12, 16, 20, 24, 28, 36, 2, 2, 2, 26}},
-};
-
-static int mapbuf0[9][152];
-static int mapbuf1[9][156];
-static int mapbuf2[9][44];
-static int *map[9][3];
-static int *mapend[9][3];
-
-static unsigned int n_slen2[512]; /* MPEG 2.0 slen for 'normal' mode */
-static unsigned int i_slen2[256]; /* MPEG 2.0 slen for intensity stereo */
-
-static real tan1_1[16], tan2_1[16], tan1_2[16], tan2_2[16];
-static real pow1_1[2][16], pow2_1[2][16], pow1_2[2][16], pow2_2[2][16];
-
-/*
- * init tables for layer-3
- */
-void mpg123_init_layer3(int down_sample_sblimit)
-{
- int i, j, k, l;
-
- for (i = -256; i < 118 + 4; i++)
- gainpow2[i + 256] = pow((double) 2.0, -0.25 * (double) (i + 210));
-
- for (i = 0; i < 8207; i++)
- ispow[i] = pow((double) i, (double) 4.0 / 3.0);
-
- for (i = 0; i < 8; i++)
- {
- static double Ci[8] =
- {-0.6, -0.535, -0.33, -0.185, -0.095, -0.041, -0.0142, -0.0037};
- double sq = sqrt(1.0 + Ci[i] * Ci[i]);
-
- aa_cs[i] = 1.0 / sq;
- aa_ca[i] = Ci[i] / sq;
- }
-
- for (i = 0; i < 18; i++)
- {
- win[0][i] = win[1][i] = 0.5 * sin(M_PI / 72.0 * (double) (2 * (i + 0) + 1)) / cos(M_PI * (double) (2 * (i + 0) + 19) / 72.0);
- win[0][i + 18] = win[3][i + 18] = 0.5 * sin(M_PI / 72.0 * (double) (2 * (i + 18) + 1)) / cos(M_PI * (double) (2 * (i + 18) + 19) / 72.0);
- }
- for (i = 0; i < 6; i++)
- {
- win[1][i + 18] = 0.5 / cos(M_PI * (double) (2 * (i + 18) + 19) / 72.0);
- win[3][i + 12] = 0.5 / cos(M_PI * (double) (2 * (i + 12) + 19) / 72.0);
- win[1][i + 24] = 0.5 * sin(M_PI / 24.0 * (double) (2 * i + 13)) / cos(M_PI * (double) (2 * (i + 24) + 19) / 72.0);
- win[1][i + 30] = win[3][i] = 0.0;
- win[3][i + 6] = 0.5 * sin(M_PI / 24.0 * (double) (2 * i + 1)) / cos(M_PI * (double) (2 * (i + 6) + 19) / 72.0);
- }
-
- for (i = 0; i < 9; i++)
- COS9[i] = cos(M_PI / 18.0 * (double) i);
-
- for (i = 0; i < 9; i++)
- tfcos36[i] = 0.5 / cos(M_PI * (double) (i * 2 + 1) / 36.0);
- for (i = 0; i < 3; i++)
- tfcos12[i] = 0.5 / cos(M_PI * (double) (i * 2 + 1) / 12.0);
-
- COS6_1 = cos(M_PI / 6.0 * (double) 1);
- COS6_2 = cos(M_PI / 6.0 * (double) 2);
-
-#ifdef NEW_DCT9
- cos9[0] = cos(1.0 * M_PI / 9.0);
- cos9[1] = cos(5.0 * M_PI / 9.0);
- cos9[2] = cos(7.0 * M_PI / 9.0);
- cos18[0] = cos(1.0 * M_PI / 18.0);
- cos18[1] = cos(11.0 * M_PI / 18.0);
- cos18[2] = cos(13.0 * M_PI / 18.0);
-#endif
-
- for (i = 0; i < 12; i++)
- {
- win[2][i] = 0.5 * sin(M_PI / 24.0 * (double) (2 * i + 1)) / cos(M_PI * (double) (2 * i + 7) / 24.0);
- for (j = 0; j < 6; j++)
- COS1[i][j] = cos(M_PI / 24.0 * (double) ((2 * i + 7) * (2 * j + 1)));
- }
-
- for (j = 0; j < 4; j++)
- {
- static int len[4] = { 36, 36, 12, 36 };
-
- for (i = 0; i < len[j]; i += 2)
- win1[j][i] = +win[j][i];
- for (i = 1; i < len[j]; i += 2)
- win1[j][i] = -win[j][i];
- }
-
- for (i = 0; i < 16; i++)
- {
- double t = tan((double) i * M_PI / 12.0);
-
- tan1_1[i] = t / (1.0 + t);
- tan2_1[i] = 1.0 / (1.0 + t);
- tan1_2[i] = M_SQRT2 * t / (1.0 + t);
- tan2_2[i] = M_SQRT2 / (1.0 + t);
-
- for (j = 0; j < 2; j++)
- {
- double base = pow(2.0, -0.25 * (j + 1.0));
- double p1 = 1.0, p2 = 1.0;
-
- if (i > 0)
- {
- if (i & 1)
- p1 = pow(base, (i + 1.0) * 0.5);
- else
- p2 = pow(base, i * 0.5);
- }
- pow1_1[j][i] = p1;
- pow2_1[j][i] = p2;
- pow1_2[j][i] = M_SQRT2 * p1;
- pow2_2[j][i] = M_SQRT2 * p2;
- }
- }
-
- for (j = 0; j < 9; j++)
- {
- struct bandInfoStruct *bi = &bandInfo[j];
- int *mp;
- int cb, lwin;
- int *bdf;
-
- mp = map[j][0] = mapbuf0[j];
- bdf = bi->longDiff;
- for (i = 0, cb = 0; cb < 8; cb++, i += *bdf++)
- {
- *mp++ = (*bdf) >> 1;
- *mp++ = i;
- *mp++ = 3;
- *mp++ = cb;
- }
- bdf = bi->shortDiff + 3;
- for (cb = 3; cb < 13; cb++)
- {
- int l = (*bdf++) >> 1;
-
- for (lwin = 0; lwin < 3; lwin++)
- {
- *mp++ = l;
- *mp++ = i + lwin;
- *mp++ = lwin;
- *mp++ = cb;
- }
- i += 6 * l;
- }
- mapend[j][0] = mp;
-
- mp = map[j][1] = mapbuf1[j];
- bdf = bi->shortDiff + 0;
- for (i = 0, cb = 0; cb < 13; cb++)
- {
- int l = (*bdf++) >> 1;
-
- for (lwin = 0; lwin < 3; lwin++)
- {
- *mp++ = l;
- *mp++ = i + lwin;
- *mp++ = lwin;
- *mp++ = cb;
- }
- i += 6 * l;
- }
- mapend[j][1] = mp;
-
- mp = map[j][2] = mapbuf2[j];
- bdf = bi->longDiff;
- for (cb = 0; cb < 22; cb++)
- {
- *mp++ = (*bdf++) >> 1;
- *mp++ = cb;
- }
- mapend[j][2] = mp;
-
- }
-
- for (j = 0; j < 9; j++)
- {
- for (i = 0; i < 23; i++)
- {
- longLimit[j][i] = (bandInfo[j].longIdx[i] - 1 + 8) / 18 + 1;
- if (longLimit[j][i] > (down_sample_sblimit))
- longLimit[j][i] = down_sample_sblimit;
- }
- for (i = 0; i < 14; i++)
- {
- shortLimit[j][i] = (bandInfo[j].shortIdx[i] - 1) / 18 + 1;
- if (shortLimit[j][i] > (down_sample_sblimit))
- shortLimit[j][i] = down_sample_sblimit;
- }
- }
-
- for (i = 0; i < 5; i++)
- {
- for (j = 0; j < 6; j++)
- {
- for (k = 0; k < 6; k++)
- {
- int n = k + j * 6 + i * 36;
-
- i_slen2[n] = i | (j << 3) | (k << 6) | (3 << 12);
- }
- }
- }
- for (i = 0; i < 4; i++)
- {
- for (j = 0; j < 4; j++)
- {
- for (k = 0; k < 4; k++)
- {
- int n = k + j * 4 + i * 16;
-
- i_slen2[n + 180] = i | (j << 3) | (k << 6) | (4 << 12);
- }
- }
- }
- for (i = 0; i < 4; i++)
- {
- for (j = 0; j < 3; j++)
- {
- int n = j + i * 3;
-
- i_slen2[n + 244] = i | (j << 3) | (5 << 12);
- n_slen2[n + 500] = i | (j << 3) | (2 << 12) | (1 << 15);
- }
- }
-
- for (i = 0; i < 5; i++)
- {
- for (j = 0; j < 5; j++)
- {
- for (k = 0; k < 4; k++)
- {
- for (l = 0; l < 4; l++)
- {
- int n = l + k * 4 + j * 16 + i * 80;
-
- n_slen2[n] = i | (j << 3) | (k << 6) | (l << 9) | (0 << 12);
- }
- }
- }
- }
- for (i = 0; i < 5; i++)
- {
- for (j = 0; j < 5; j++)
- {
- for (k = 0; k < 4; k++)
- {
- int n = k + j * 4 + i * 20;
-
- n_slen2[n + 400] = i | (j << 3) | (k << 6) | (1 << 12);
- }
- }
- }
-}
-
-/*
- * read additional side information (for MPEG 1 and MPEG 2)
- */
-static int III_get_side_info(struct III_sideinfo *si, int stereo,
- int ms_stereo, long sfreq, int single, int lsf)
-{
- int ch, gr;
- int powdiff = (single == 3) ? 4 : 0;
-
- static const int tabs[2][5] = { {2, 9, 5, 3, 4}, {1, 8, 1, 2, 9} };
- const int *tab = tabs[lsf];
-
- si->main_data_begin = mpg123_getbits(tab[1]);
- if (stereo == 1)
- si->private_bits = mpg123_getbits_fast(tab[2]);
- else
- si->private_bits = mpg123_getbits_fast(tab[3]);
-
- if (!lsf)
- {
- for (ch = 0; ch < stereo; ch++)
- {
- si->ch[ch].gr[0].scfsi = -1;
- si->ch[ch].gr[1].scfsi = mpg123_getbits_fast(4);
- }
- }
-
- for (gr = 0; gr < tab[0]; gr++)
- {
- for (ch = 0; ch < stereo; ch++)
- {
- register struct gr_info_s *gr_info = &(si->ch[ch].gr[gr]);
-
- gr_info->part2_3_length = mpg123_getbits(12);
- gr_info->big_values = mpg123_getbits(9);
- if (gr_info->big_values > 288)
- {
- /* fprintf(stderr, "big_values too large!\n"); */
- /* gr_info->big_values = 288; */
- return 0;
- }
- gr_info->pow2gain = gainpow2 + 256 - mpg123_getbits_fast(8) + powdiff;
- if (ms_stereo)
- gr_info->pow2gain += 2;
- gr_info->scalefac_compress = mpg123_getbits(tab[4]);
-
- if (mpg123_get1bit())
- { /* window switch flag */
- int i;
-
- gr_info->block_type = mpg123_getbits_fast(2);
- gr_info->mixed_block_flag = mpg123_get1bit();
- gr_info->table_select[0] = mpg123_getbits_fast(5);
- gr_info->table_select[1] = mpg123_getbits_fast(5);
- /*
- * table_select[2] not needed, because there is no region2,
- * but to satisfy some verifications tools we set it either.
- */
- gr_info->table_select[2] = 0;
- for (i = 0; i < 3; i++)
- gr_info->full_gain[i] = gr_info->pow2gain + (mpg123_getbits_fast(3) << 3);
-
- if (gr_info->block_type == 0)
- {
- /* fprintf(stderr, "Blocktype == 0 and window-switching == 1 not allowed.\n"); */
- /* exit(1); */
- return 0;
- }
-
- /* region_count/start parameters are implicit in this case. */
- if (!lsf || gr_info->block_type == 2)
- gr_info->region1start = 36 >> 1;
- else
- {
- /* check this again for 2.5 and sfreq=8 */
- if (sfreq == 8)
- gr_info->region1start = 108 >> 1;
- else
- gr_info->region1start = 54 >> 1;
- }
- gr_info->region2start = 576 >> 1;
- }
- else
- {
- int i, r0c, r1c;
-
- for (i = 0; i < 3; i++)
- gr_info->table_select[i] = mpg123_getbits_fast(5);
- r0c = mpg123_getbits_fast(4);
- r1c = mpg123_getbits_fast(3);
- gr_info->region1start = bandInfo[sfreq].longIdx[r0c + 1] >> 1;
- if (r0c + r1c + 2 > 22)
- gr_info->region2start = 576 >> 1;
- else
- gr_info->region2start = bandInfo[sfreq].longIdx[r0c + 1 + r1c + 1] >> 1;
- gr_info->block_type = 0;
- gr_info->mixed_block_flag = 0;
- }
- if (!lsf)
- gr_info->preflag = mpg123_get1bit();
- gr_info->scalefac_scale = mpg123_get1bit();
- gr_info->count1table_select = mpg123_get1bit();
- }
- }
- return 1;
-}
-
-
-/*
- * read scalefactors
- */
-static int III_get_scale_factors_1(int *scf, struct gr_info_s *gr_info)
-{
- static const unsigned char slen[2][16] = {
- {0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4},
- {0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3}
- };
- int numbits;
- int num0 = slen[0][gr_info->scalefac_compress];
- int num1 = slen[1][gr_info->scalefac_compress];
-
- if (gr_info->block_type == 2)
- {
- int i = 18;
-
- numbits = (num0 + num1) * 18;
-
- if (gr_info->mixed_block_flag)
- {
- for (i = 8; i; i--)
- *scf++ = mpg123_getbits_fast(num0);
- i = 9;
- numbits -= num0; /* num0 * 17 + num1 * 18 */
- }
-
- for (; i; i--)
- *scf++ = mpg123_getbits_fast(num0);
- for (i = 18; i; i--)
- *scf++ = mpg123_getbits_fast(num1);
- *scf++ = 0;
- *scf++ = 0;
- *scf++ = 0; /* short[13][0..2] = 0 */
- }
- else
- {
- int i;
- int scfsi = gr_info->scfsi;
-
- if (scfsi < 0)
- { /* scfsi < 0 => granule == 0 */
- for (i = 11; i; i--)
- *scf++ = mpg123_getbits_fast(num0);
- for (i = 10; i; i--)
- *scf++ = mpg123_getbits_fast(num1);
- numbits = (num0 + num1) * 10 + num0;
- *scf++ = 0;
- }
- else
- {
- numbits = 0;
- if (!(scfsi & 0x8))
- {
- for (i = 0; i < 6; i++)
- *scf++ = mpg123_getbits_fast(num0);
- numbits += num0 * 6;
- }
- else
- {
- scf += 6;
- }
-
- if (!(scfsi & 0x4))
- {
- for (i = 0; i < 5; i++)
- *scf++ = mpg123_getbits_fast(num0);
- numbits += num0 * 5;
- }
- else
- {
- scf += 5;
- }
-
- if (!(scfsi & 0x2))
- {
- for (i = 0; i < 5; i++)
- *scf++ = mpg123_getbits_fast(num1);
- numbits += num1 * 5;
- }
- else
- {
- scf += 5;
- }
-
- if (!(scfsi & 0x1))
- {
- for (i = 0; i < 5; i++)
- *scf++ = mpg123_getbits_fast(num1);
- numbits += num1 * 5;
- }
- else
- {
- scf += 5;
- }
- *scf++ = 0; /* no l[21] in original sources */
- }
- }
- return numbits;
-}
-
-static int III_get_scale_factors_2(int *scf, struct gr_info_s *gr_info, int i_stereo)
-{
- unsigned char *pnt;
- int i, j, n = 0, numbits = 0;
- unsigned int slen;
-
- static unsigned char stab[3][6][4] =
- {
- {{6, 5, 5, 5}, {6, 5, 7, 3}, {11, 10, 0, 0},
- {7, 7, 7, 0}, {6, 6, 6, 3}, {8, 8, 5, 0}},
- {{9, 9, 9, 9}, {9, 9, 12, 6}, {18, 18, 0, 0},
- {12, 12, 12, 0}, {12, 9, 9, 6}, {15, 12, 9, 0}},
- {{6, 9, 9, 9}, {6, 9, 12, 6}, {15, 18, 0, 0},
- {6, 15, 12, 0}, {6, 12, 9, 6}, {6, 18, 9, 0}}
- };
-
- if (i_stereo) /* i_stereo AND second channel -> mpg123_do_layer3() checks this */
- slen = i_slen2[gr_info->scalefac_compress >> 1];
- else
- slen = n_slen2[gr_info->scalefac_compress];
-
- gr_info->preflag = (slen >> 15) & 0x1;
-
- n = 0;
- if (gr_info->block_type == 2)
- {
- n++;
- if (gr_info->mixed_block_flag)
- n++;
- }
-
- pnt = stab[n][(slen >> 12) & 0x7];
-
- for (i = 0; i < 4; i++)
- {
- int num = slen & 0x7;
-
- slen >>= 3;
- if (num)
- {
- for (j = 0; j < (int) (pnt[i]); j++)
- *scf++ = mpg123_getbits_fast(num);
- numbits += pnt[i] * num;
- }
- else
- {
- for (j = 0; j < (int) (pnt[i]); j++)
- *scf++ = 0;
- }
- }
-
- n = (n << 1) + 1;
- for (i = 0; i < n; i++)
- *scf++ = 0;
-
- return numbits;
-}
-
-static int pretab1[22] =
-{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 2, 0};
-static int pretab2[22] =
-{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-
-/*
- * Dequantize samples (includes huffman decoding)
- */
-/* 24 is enough because tab13 has max. a 19 bit huffvector */
-#define BITSHIFT ((sizeof (long) - 1) * 8)
-
-#define REFRESH_MASK() \
-while(num < (int)BITSHIFT) { \
- mask |= ((unsigned long)mpg123_getbyte()) << (BITSHIFT - num); \
- num += 8; \
- part2remain -= 8; \
-}
-
-static int III_dequantize_sample(real xr[SBLIMIT][SSLIMIT], int *scf,
- struct gr_info_s *gr_info, int sfreq, int part2bits)
-{
- int shift = 1 + gr_info->scalefac_scale;
- real *xrpnt = (real *) xr;
- int l[3], l3;
- int part2remain = gr_info->part2_3_length - part2bits;
- int *me;
-
- int num = mpg123_getbitoffset();
- long mask;
- /* we must split this, because for num==0 the shift is undefined if you do it in one step */
- mask = ((unsigned long) mpg123_getbits(num)) << BITSHIFT;
- mask <<= 8 - num;
- part2remain -= num;
-
- {
- int bv = gr_info->big_values;
- int region1 = gr_info->region1start;
- int region2 = gr_info->region2start;
-
- l3 = ((576 >> 1) - bv) >> 1;
-/*
- * we may lose the 'odd' bit here !!
- * check this later again
- */
- if (bv <= region1)
- {
- l[0] = bv;
- l[1] = 0;
- l[2] = 0;
- }
- else
- {
- l[0] = region1;
- if (bv <= region2)
- {
- l[1] = bv - l[0];
- l[2] = 0;
- }
- else
- {
- l[1] = region2 - l[0];
- l[2] = bv - region2;
- }
- }
- }
-
- if (gr_info->block_type == 2)
- {
- /*
- * decoding with short or mixed mode BandIndex table
- */
- int i, max[4];
- int step = 0, lwin = 3, cb = 0;
- register real v = 0.0;
- register int *m, mc;
-
- if (gr_info->mixed_block_flag)
- {
- max[3] = -1;
- max[0] = max[1] = max[2] = 2;
- m = map[sfreq][0];
- me = mapend[sfreq][0];
- }
- else
- {
- max[0] = max[1] = max[2] = max[3] = -1;
- /* max[3] not really needed in this case */
- m = map[sfreq][1];
- me = mapend[sfreq][1];
- }
-
- mc = 0;
- for (i = 0; i < 2; i++)
- {
- int lp = l[i];
- struct newhuff *h = ht + gr_info->table_select[i];
-
- for (; lp; lp--, mc--)
- {
- register int x, y;
- if ((!mc))
- {
- mc = *m++;
- xrpnt = ((real *) xr) + (*m++);
- lwin = *m++;
- cb = *m++;
- if (lwin == 3)
- {
- v = gr_info->pow2gain[(*scf++) << shift];
- step = 1;
- }
- else
- {
- v = gr_info->full_gain[lwin][(*scf++) << shift];
- step = 3;
- }
- }
- {
- register short *val = h->table;
-
- REFRESH_MASK ();
- while ((y = *val++) < 0)
- {
- if (mask < 0)
- val -= y;
- num--;
- mask <<= 1;
- }
- x = y >> 4;
- y &= 0xf;
- }
- if (x == 15 && h->linbits)
- {
- max[lwin] = cb;
- REFRESH_MASK();
- x += ((unsigned long) mask) >> (BITSHIFT + 8 - h->linbits);
- num -= h->linbits + 1;
- mask <<= h->linbits;
- if (mask < 0)
- *xrpnt = -ispow[x] * v;
- else
- *xrpnt = ispow[x] * v;
- mask <<= 1;
- }
- else if (x)
- {
- max[lwin] = cb;
- if (mask < 0)
- *xrpnt = -ispow[x] * v;
- else
- *xrpnt = ispow[x] * v;
- num--;
- mask <<= 1;
- }
- else
- *xrpnt = 0.0;
- xrpnt += step;
- if (y == 15 && h->linbits)
- {
- max[lwin] = cb;
- REFRESH_MASK();
- y += ((unsigned long) mask) >> (BITSHIFT + 8 - h->linbits);
- num -= h->linbits + 1;
- mask <<= h->linbits;
- if (mask < 0)
- *xrpnt = -ispow[y] * v;
- else
- *xrpnt = ispow[y] * v;
- mask <<= 1;
- }
- else if (y)
- {
- max[lwin] = cb;
- if (mask < 0)
- *xrpnt = -ispow[y] * v;
- else
- *xrpnt = ispow[y] * v;
- num--;
- mask <<= 1;
- }
- else
- *xrpnt = 0.0;
- xrpnt += step;
- }
- }
-
- for (; l3 && (part2remain + num > 0); l3--)
- {
- struct newhuff *h = htc + gr_info->count1table_select;
- register short *val = h->table, a;
-
- REFRESH_MASK();
- while ((a = *val++) < 0)
- {
- if (mask < 0)
- val -= a;
- num--;
- mask <<= 1;
- }
- if (part2remain + num <= 0)
- {
- num -= part2remain + num;
- break;
- }
-
- for (i = 0; i < 4; i++)
- {
- if (!(i & 1))
- {
- if (!mc)
- {
- mc = *m++;
- xrpnt = ((real *) xr) + (*m++);
- lwin = *m++;
- cb = *m++;
- if (lwin == 3)
- {
- v = gr_info->pow2gain[(*scf++) << shift];
- step = 1;
- }
- else
- {
- v = gr_info->full_gain[lwin][(*scf++) << shift];
- step = 3;
- }
- }
- mc--;
- }
- if ((a & (0x8 >> i)))
- {
- max[lwin] = cb;
- if (part2remain + num <= 0)
- {
- break;
- }
- if (mask < 0)
- *xrpnt = -v;
- else
- *xrpnt = v;
- num--;
- mask <<= 1;
- }
- else
- *xrpnt = 0.0;
- xrpnt += step;
- }
- }
-
- if (lwin < 3)
- { /* short band? */
- while (1)
- {
- for (; mc > 0; mc--)
- {
- *xrpnt = 0.0;
- xrpnt += 3; /* short band -> step=3 */
- *xrpnt = 0.0;
- xrpnt += 3;
- }
- if (m >= me)
- break;
- mc = *m++;
- xrpnt = ((real *) xr) + *m++;
- if (*m++ == 0)
- break; /* optimize: field will be set to zero at the end of the function */
- m++; /* cb */
- }
- }
-
- gr_info->maxband[0] = max[0] + 1;
- gr_info->maxband[1] = max[1] + 1;
- gr_info->maxband[2] = max[2] + 1;
- gr_info->maxbandl = max[3] + 1;
-
- {
- int rmax = max[0] > max[1] ? max[0] : max[1];
-
- rmax = (rmax > max[2] ? rmax : max[2]) + 1;
- gr_info->maxb = rmax ? shortLimit[sfreq][rmax] : longLimit[sfreq][max[3] + 1];
- }
-
- }
- else
- {
- /*
- * decoding with 'long' BandIndex table (block_type != 2)
- */
- int *pretab = gr_info->preflag ? pretab1 : pretab2;
- int i, max = -1;
- int cb = 0;
- int *m = map[sfreq][2];
- register real v = 0.0;
- int mc = 0;
-
- /*
- * long hash table values
- */
- for (i = 0; i < 3; i++)
- {
- int lp = l[i];
- struct newhuff *h = ht + gr_info->table_select[i];
-
- for (; lp; lp--, mc--)
- {
- int x, y;
-
- if (!mc)
- {
- mc = *m++;
- cb = *m++;
- if (cb == 21)
- v = 0.0;
- else
- v = gr_info->pow2gain[((*scf++) + (*pretab++)) << shift];
-
- }
- {
- register short *val = h->table;
- REFRESH_MASK();
- while ((y = *val++) < 0)
- {
- if (mask < 0)
- val -= y;
- num--;
- mask <<= 1;
- }
- x = y >> 4;
- y &= 0xf;
- }
-
- if (x == 15 && h->linbits)
- {
- max = cb;
- REFRESH_MASK();
- x += ((unsigned long) mask) >> (BITSHIFT + 8 - h->linbits);
- num -= h->linbits + 1;
- mask <<= h->linbits;
- if (mask < 0)
- *xrpnt++ = -ispow[x] * v;
- else
- *xrpnt++ = ispow[x] * v;
- mask <<= 1;
- }
- else if (x)
- {
- max = cb;
- if (mask < 0)
- *xrpnt++ = -ispow[x] * v;
- else
- *xrpnt++ = ispow[x] * v;
- num--;
- mask <<= 1;
- }
- else
- *xrpnt++ = 0.0;
-
- if (y == 15 && h->linbits)
- {
- max = cb;
- REFRESH_MASK();
- y += ((unsigned long) mask) >> (BITSHIFT + 8 - h->linbits);
- num -= h->linbits + 1;
- mask <<= h->linbits;
- if (mask < 0)
- *xrpnt++ = -ispow[y] * v;
- else
- *xrpnt++ = ispow[y] * v;
- mask <<= 1;
- }
- else if (y)
- {
- max = cb;
- if (mask < 0)
- *xrpnt++ = -ispow[y] * v;
- else
- *xrpnt++ = ispow[y] * v;
- num--;
- mask <<= 1;
- }
- else
- *xrpnt++ = 0.0;
- }
- }
-
- /*
- * short (count1table) values
- */
- for (; l3 && (part2remain + num > 0); l3--)
- {
- struct newhuff *h = htc + gr_info->count1table_select;
- register short *val = h->table, a;
-
- REFRESH_MASK();
- while ((a = *val++) < 0)
- {
- if (mask < 0)
- val -= a;
- num--;
- mask <<= 1;
- }
- if (part2remain + num <= 0)
- {
- num -= part2remain + num;
- break;
- }
-
- for (i = 0; i < 4; i++)
- {
- if (!(i & 1))
- {
- if (!mc)
- {
- mc = *m++;
- cb = *m++;
- if (cb == 21)
- v = 0.0;
- else
- v = gr_info->pow2gain[((*scf++) + (*pretab++)) << shift];
- }
- mc--;
- }
- if ((a & (0x8 >> i)))
- {
- max = cb;
- if (part2remain + num <= 0)
- {
- break;
- }
- if (mask < 0)
- *xrpnt++ = -v;
- else
- *xrpnt++ = v;
- num--;
- mask <<= 1;
- }
- else
- *xrpnt++ = 0.0;
- }
- }
-
- gr_info->maxbandl = max + 1;
- gr_info->maxb = longLimit[sfreq][gr_info->maxbandl];
- }
-
- part2remain += num;
- mpg123_backbits(num);
- num = 0;
-
- while (xrpnt < &xr[SBLIMIT][0])
- *xrpnt++ = 0.0;
-
- while (part2remain > 16)
- {
- mpg123_getbits(16); /* Dismiss stuffing Bits */
- part2remain -= 16;
- }
- if (part2remain > 0)
- mpg123_getbits(part2remain);
- else if (part2remain < 0)
- {
-/* fprintf(stderr, "mpg123: Can't rewind stream by %d bits!\n", */
-/* -part2remain); */
- return 1; /* -> error */
- }
- return 0;
-}
-
-/*
- * III_stereo: calculate real channel values for Joint-I-Stereo-mode
- */
-static void III_i_stereo(real xr_buf[2][SBLIMIT][SSLIMIT], int *scalefac, struct gr_info_s *gr_info, int sfreq, int ms_stereo, int lsf)
-{
- real(*xr)[SBLIMIT * SSLIMIT] = (real(*)[SBLIMIT * SSLIMIT]) xr_buf;
- struct bandInfoStruct *bi = &bandInfo[sfreq];
-
- const real *tab1, *tab2;
-
-#if 1
- int tab;
- static const real *tabs[3][2][2] = {
- {{tan1_1, tan2_1}, {tan1_2, tan2_2}},
- {{pow1_1[0], pow2_1[0]}, {pow1_2[0], pow2_2[0]}},
- {{pow1_1[1], pow2_1[1]}, {pow1_2[1], pow2_2[1]}}
- };
-
- tab = lsf + (gr_info->scalefac_compress & lsf);
- tab1 = tabs[tab][ms_stereo][0];
- tab2 = tabs[tab][ms_stereo][1];
-#else
- if (lsf)
- {
- int p = gr_info->scalefac_compress & 0x1;
-
- if (ms_stereo)
- {
- tab1 = pow1_2[p];
- tab2 = pow2_2[p];
- }
- else
- {
- tab1 = pow1_1[p];
- tab2 = pow2_1[p];
- }
- }
- else
- {
- if (ms_stereo)
- {
- tab1 = tan1_2;
- tab2 = tan2_2;
- }
- else
- {
- tab1 = tan1_1;
- tab2 = tan2_1;
- }
- }
-#endif
-
- if (gr_info->block_type == 2)
- {
- int lwin, do_l = 0;
-
- if (gr_info->mixed_block_flag)
- do_l = 1;
-
- for (lwin = 0; lwin < 3; lwin++)
- { /* process each window */
- /* get first band with zero values */
- int is_p, sb, idx, sfb = gr_info->maxband[lwin]; /* sfb is minimal 3 for mixed mode */
-
- if (sfb > 3)
- do_l = 0;
-
- for (; sfb < 12; sfb++)
- {
- is_p = scalefac[sfb * 3 + lwin - gr_info->mixed_block_flag]; /* scale: 0-15 */
- if (is_p != 7)
- {
- real t1, t2;
-
- sb = bi->shortDiff[sfb];
- idx = bi->shortIdx[sfb] + lwin;
- t1 = tab1[is_p];
- t2 = tab2[is_p];
- for (; sb > 0; sb--, idx += 3)
- {
- real v = xr[0][idx];
-
- xr[0][idx] = v * t1;
- xr[1][idx] = v * t2;
- }
- }
- }
-
-#if 1
-/* in the original: copy 10 to 11 , here: copy 11 to 12
- maybe still wrong??? (copy 12 to 13?) */
- is_p = scalefac[11 * 3 + lwin - gr_info->mixed_block_flag]; /* scale: 0-15 */
- sb = bi->shortDiff[12];
- idx = bi->shortIdx[12] + lwin;
-#else
- is_p = scalefac[10 * 3 + lwin - gr_info->mixed_block_flag]; /* scale: 0-15 */
- sb = bi->shortDiff[11];
- idx = bi->shortIdx[11] + lwin;
-#endif
- if (is_p != 7)
- {
- real t1, t2;
- t1 = tab1[is_p];
- t2 = tab2[is_p];
- for (; sb > 0; sb--, idx += 3)
- {
- real v = xr[0][idx];
- xr[0][idx] = v * t1;
- xr[1][idx] = v * t2;
- }
- }
- } /* end for(lwin; .. ; . ) */
-
-/* also check l-part, if ALL bands in the three windows are 'empty'
- * and mode = mixed_mode
- */
- if (do_l)
- {
- int sfb = gr_info->maxbandl;
- int idx = bi->longIdx[sfb];
-
- for (; sfb < 8; sfb++)
- {
- int sb = bi->longDiff[sfb];
- int is_p = scalefac[sfb]; /* scale: 0-15 */
-
- if (is_p != 7)
- {
- real t1, t2;
-
- t1 = tab1[is_p];
- t2 = tab2[is_p];
- for (; sb > 0; sb--, idx++)
- {
- real v = xr[0][idx];
-
- xr[0][idx] = v * t1;
- xr[1][idx] = v * t2;
- }
- }
- else
- idx += sb;
- }
- }
- }
- else
- { /* ((gr_info->block_type != 2)) */
- int sfb = gr_info->maxbandl;
- int is_p, idx = bi->longIdx[sfb];
-
-/* hmm ... maybe the maxbandl stuff for i-stereo is buggy? */
- if (sfb <= 21)
- {
- for (; sfb < 21; sfb++)
- {
- int sb = bi->longDiff[sfb];
-
- is_p = scalefac[sfb]; /* scale: 0-15 */
- if (is_p != 7)
- {
- real t1, t2;
- t1 = tab1[is_p];
- t2 = tab2[is_p];
- for (; sb > 0; sb--, idx++)
- {
- real v = xr[0][idx];
- xr[0][idx] = v * t1;
- xr[1][idx] = v * t2;
- }
- }
- else
- idx += sb;
- }
- }
-
- is_p = scalefac[20];
- if (is_p != 7)
- { /* copy l-band 20 to l-band 21 */
- int sb;
- real t1 = tab1[is_p], t2 = tab2[is_p];
-
- for (sb = bi->longDiff[21]; sb > 0; sb--, idx++)
- {
- real v = xr[0][idx];
-
- xr[0][idx] = v * t1;
- xr[1][idx] = v * t2;
- }
- }
- } /* ... */
-}
-
-static void III_antialias(real xr[SBLIMIT][SSLIMIT], struct gr_info_s *gr_info)
-{
- int sblim;
-
- if (gr_info->block_type == 2)
- {
- if (!gr_info->mixed_block_flag)
- return;
- sblim = 1;
- }
- else
- {
- sblim = gr_info->maxb - 1;
- }
-
- /* 31 alias-reduction operations between each pair of sub-bands */
- /* with 8 butterflies between each pair */
-
- {
- int sb;
- real *xr1 = (real *) xr[1];
-
- if (sblim < 1 || sblim > SBLIMIT)
- return;
-
- for (sb = sblim; sb; sb--, xr1 += 10)
- {
- int ss;
- real *cs = aa_cs, *ca = aa_ca;
- real *xr2 = xr1;
-
- for (ss = 7; ss >= 0; ss--)
- { /* upper and lower butterfly inputs */
- register real bu = *--xr2, bd = *xr1;
-
- *xr2 = (bu * (*cs)) - (bd * (*ca));
- *xr1++ = (bd * (*cs++)) + (bu * (*ca++));
- }
- }
- }
-}
-
-/*
- This is an optimized DCT from Jeff Tsay's maplay 1.2+ package.
- Saved one multiplication by doing the 'twiddle factor' stuff
- together with the window mul. (MH)
-
- This uses Byeong Gi Lee's Fast Cosine Transform algorithm, but the
- 9 point IDCT needs to be reduced further. Unfortunately, I don't
- know how to do that, because 9 is not an even number. - Jeff.
-
- ****************************************************************
-
- 9 Point Inverse Discrete Cosine Transform
-
- This piece of code is Copyright 1997 Mikko Tommila and is freely usable
- by anybody. The algorithm itself is of course in the public domain.
-
- Again derived heuristically from the 9-point WFTA.
-
- The algorithm is optimized (?) for speed, not for small rounding errors or
- good readability.
-
- 36 additions, 11 multiplications
-
- Again this is very likely sub-optimal.
-
- The code is optimized to use a minimum number of temporary variables,
- so it should compile quite well even on 8-register Intel x86 processors.
- This makes the code quite obfuscated and very difficult to understand.
-
- References:
- [1] S. Winograd: "On Computing the Discrete Fourier Transform",
- Mathematics of Computation, Volume 32, Number 141, January 1978,
- Pages 175-199
-*/
-
-/*------------------------------------------------------------------*/
-/* */
-/* Function: Calculation of the inverse MDCT */
-/* */
-/*------------------------------------------------------------------*/
-
-#ifdef USE_3DNOW
-void dct36(real *inbuf,real *o1,real *o2,real *wintab,real *tsbuf)
-#else
-static void dct36(real * inbuf, real * o1, real * o2, real * wintab, real * tsbuf)
-#endif
-{
-#ifdef NEW_DCT9
- real tmp[18];
-#endif
-
- {
- register real *in = inbuf;
-
- in[17] += in[16];
- in[16] += in[15];
- in[15] += in[14];
- in[14] += in[13];
- in[13] += in[12];
- in[12] += in[11];
- in[11] += in[10];
- in[10] += in[9];
- in[9] += in[8];
- in[8] += in[7];
- in[7] += in[6];
- in[6] += in[5];
- in[5] += in[4];
- in[4] += in[3];
- in[3] += in[2];
- in[2] += in[1];
- in[1] += in[0];
-
- in[17] += in[15];
- in[15] += in[13];
- in[13] += in[11];
- in[11] += in[9];
- in[9] += in[7];
- in[7] += in[5];
- in[5] += in[3];
- in[3] += in[1];
-
-
-#ifdef NEW_DCT9
-#if 1
- {
- real t3;
- {
- real t0, t1, t2;
-
- t0 = COS6_2 * (in[8] + in[16] - in[4]);
- t1 = COS6_2 * in[12];
-
- t3 = in[0];
- t2 = t3 - t1 - t1;
- tmp[1] = tmp[7] = t2 - t0;
- tmp[4] = t2 + t0 + t0;
- t3 += t1;
-
- t2 = COS6_1 * (in[10] + in[14] - in[2]);
- tmp[1] -= t2;
- tmp[7] += t2;
- }
- {
- real t0, t1, t2;
-
- t0 = cos9[0] * (in[4] + in[8]);
- t1 = cos9[1] * (in[8] - in[16]);
- t2 = cos9[2] * (in[4] + in[16]);
-
- tmp[2] = tmp[6] = t3 - t0 - t2;
- tmp[0] = tmp[8] = t3 + t0 + t1;
- tmp[3] = tmp[5] = t3 - t1 + t2;
- }
- }
- {
- real t1, t2, t3;
-
- t1 = cos18[0] * (in[2] + in[10]);
- t2 = cos18[1] * (in[10] - in[14]);
- t3 = COS6_1 * in[6];
-
- {
- real t0 = t1 + t2 + t3;
- tmp[0] += t0;
- tmp[8] -= t0;
- }
-
- t2 -= t3;
- t1 -= t3;
-
- t3 = cos18[2] * (in[2] + in[14]);
-
- t1 += t3;
- tmp[3] += t1;
- tmp[5] -= t1;
-
- t2 -= t3;
- tmp[2] += t2;
- tmp[6] -= t2;
- }
-
-#else
- {
- real t0, t1, t2, t3, t4, t5, t6, t7;
-
- t1 = COS6_2 * in[12];
- t2 = COS6_2 * (in[8] + in[16] - in[4]);
-
- t3 = in[0] + t1;
- t4 = in[0] - t1 - t1;
- t5 = t4 - t2;
- tmp[4] = t4 + t2 + t2;
-
- t0 = cos9[0] * (in[4] + in[8]);
- t1 = cos9[1] * (in[8] - in[16]);
-
- t2 = cos9[2] * (in[4] + in[16]);
-
- t6 = t3 - t0 - t2;
- t0 += t3 + t1;
- t3 += t2 - t1;
-
- t2 = cos18[0] * (in[2] + in[10]);
- t4 = cos18[1] * (in[10] - in[14]);
- t7 = COS6_1 * in[6];
-
- t1 = t2 + t4 + t7;
- tmp[0] = t0 + t1;
- tmp[8] = t0 - t1;
- t1 = cos18[2] * (in[2] + in[14]);
- t2 += t1 - t7;
-
- tmp[3] = t3 + t2;
- t0 = COS6_1 * (in[10] + in[14] - in[2]);
- tmp[5] = t3 - t2;
-
- t4 -= t1 + t7;
-
- tmp[1] = t5 - t0;
- tmp[7] = t5 + t0;
- tmp[2] = t6 + t4;
- tmp[6] = t6 - t4;
- }
-#endif
-
- {
- real t0, t1, t2, t3, t4, t5, t6, t7;
-
- t1 = COS6_2 * in[13];
- t2 = COS6_2 * (in[9] + in[17] - in[5]);
-
- t3 = in[1] + t1;
- t4 = in[1] - t1 - t1;
- t5 = t4 - t2;
-
- t0 = cos9[0] * (in[5] + in[9]);
- t1 = cos9[1] * (in[9] - in[17]);
-
- tmp[13] = (t4 + t2 + t2) * tfcos36[17 - 13];
- t2 = cos9[2] * (in[5] + in[17]);
-
- t6 = t3 - t0 - t2;
- t0 += t3 + t1;
- t3 += t2 - t1;
-
- t2 = cos18[0] * (in[3] + in[11]);
- t4 = cos18[1] * (in[11] - in[15]);
- t7 = COS6_1 * in[7];
-
- t1 = t2 + t4 + t7;
- tmp[17] = (t0 + t1) * tfcos36[17 - 17];
- tmp[9] = (t0 - t1) * tfcos36[17 - 9];
- t1 = cos18[2] * (in[3] + in[15]);
- t2 += t1 - t7;
-
- tmp[14] = (t3 + t2) * tfcos36[17 - 14];
- t0 = COS6_1 * (in[11] + in[15] - in[3]);
- tmp[12] = (t3 - t2) * tfcos36[17 - 12];
-
- t4 -= t1 + t7;
-
- tmp[16] = (t5 - t0) * tfcos36[17 - 16];
- tmp[10] = (t5 + t0) * tfcos36[17 - 10];
- tmp[15] = (t6 + t4) * tfcos36[17 - 15];
- tmp[11] = (t6 - t4) * tfcos36[17 - 11];
- }
-
-#define MACRO(v) \
-do { \
- real tmpval; \
- \
- tmpval = tmp[(v)] + tmp[17-(v)]; \
- out2[9+(v)] = tmpval * w[27+(v)]; \
- out2[8-(v)] = tmpval * w[26-(v)]; \
- tmpval = tmp[(v)] - tmp[17-(v)]; \
- ts[SBLIMIT*(8-(v))] = out1[8-(v)] + tmpval * w[8-(v)]; \
- ts[SBLIMIT*(9+(v))] = out1[9+(v)] + tmpval * w[9+(v)]; \
-} while (0)
-
- {
- register real *out2 = o2;
- register real *w = wintab;
- register real *out1 = o1;
- register real *ts = tsbuf;
-
- MACRO(0);
- MACRO(1);
- MACRO(2);
- MACRO(3);
- MACRO(4);
- MACRO(5);
- MACRO(6);
- MACRO(7);
- MACRO(8);
- }
-
-#else
-
- {
-
-#define MACRO0(v) \
-do { \
- real tmp; \
- out2[9+(v)] = (tmp = sum0 + sum1) * w[27+(v)]; \
- out2[8-(v)] = tmp * w[26-(v)]; \
- sum0 -= sum1; \
- ts[SBLIMIT*(8-(v))] = out1[8-(v)] + sum0 * w[8-(v)]; \
- ts[SBLIMIT*(9+(v))] = out1[9+(v)] + sum0 * w[9+(v)]; \
-} while (0)
-
-#define MACRO1(v) \
-do { \
- real sum0,sum1; \
- sum0 = tmp1a + tmp2a; \
- sum1 = (tmp1b + tmp2b) * tfcos36[(v)]; \
- MACRO0(v); \
-} while (0)
-
-#define MACRO2(v) \
-do { \
- real sum0, sum1; \
- sum0 = tmp2a - tmp1a; \
- sum1 = (tmp2b - tmp1b) * tfcos36[(v)]; \
- MACRO0(v); \
-} while (0)
-
- register const real *c = COS9;
- register real *out2 = o2;
- register real *w = wintab;
- register real *out1 = o1;
- register real *ts = tsbuf;
-
- real ta33, ta66, tb33, tb66;
-
- ta33 = in[2 * 3 + 0] * c[3];
- ta66 = in[2 * 6 + 0] * c[6] + in[2 * 0 + 0];
- tb33 = in[2 * 3 + 1] * c[3];
- tb66 = in[2 * 6 + 1] * c[6] + in[2 * 0 + 1];
-
- {
- real tmp1a, tmp2a, tmp1b, tmp2b;
- tmp1a = in[2 * 1 + 0] * c[1] + ta33 + in[2 * 5 + 0] * c[5] + in[2 * 7 + 0] * c[7];
- tmp1b = in[2 * 1 + 1] * c[1] + tb33 + in[2 * 5 + 1] * c[5] + in[2 * 7 + 1] * c[7];
- tmp2a = in[2 * 2 + 0] * c[2] + in[2 * 4 + 0] * c[4] + ta66 + in[2 * 8 + 0] * c[8];
- tmp2b = in[2 * 2 + 1] * c[2] + in[2 * 4 + 1] * c[4] + tb66 + in[2 * 8 + 1] * c[8];
-
- MACRO1(0);
- MACRO2(8);
- }
-
- {
- real tmp1a, tmp2a, tmp1b, tmp2b;
- tmp1a = (in[2 * 1 + 0] - in[2 * 5 + 0] - in[2 * 7 + 0]) * c[3];
- tmp1b = (in[2 * 1 + 1] - in[2 * 5 + 1] - in[2 * 7 + 1]) * c[3];
- tmp2a = (in[2 * 2 + 0] - in[2 * 4 + 0] - in[2 * 8 + 0]) * c[6] - in[2 * 6 + 0] + in[2 * 0 + 0];
- tmp2b = (in[2 * 2 + 1] - in[2 * 4 + 1] - in[2 * 8 + 1]) * c[6] - in[2 * 6 + 1] + in[2 * 0 + 1];
-
- MACRO1(1);
- MACRO2(7);
- }
-
- {
- real tmp1a, tmp2a, tmp1b, tmp2b;
- tmp1a = in[2 * 1 + 0] * c[5] - ta33 - in[2 * 5 + 0] * c[7] + in[2 * 7 + 0] * c[1];
- tmp1b = in[2 * 1 + 1] * c[5] - tb33 - in[2 * 5 + 1] * c[7] + in[2 * 7 + 1] * c[1];
- tmp2a = -in[2 * 2 + 0] * c[8] - in[2 * 4 + 0] * c[2] + ta66 + in[2 * 8 + 0] * c[4];
- tmp2b = -in[2 * 2 + 1] * c[8] - in[2 * 4 + 1] * c[2] + tb66 + in[2 * 8 + 1] * c[4];
-
- MACRO1(2);
- MACRO2(6);
- }
-
- {
- real tmp1a, tmp2a, tmp1b, tmp2b;
- tmp1a = in[2 * 1 + 0] * c[7] - ta33 + in[2 * 5 + 0] * c[1] - in[2 * 7 + 0] * c[5];
- tmp1b = in[2 * 1 + 1] * c[7] - tb33 + in[2 * 5 + 1] * c[1] - in[2 * 7 + 1] * c[5];
- tmp2a = -in[2 * 2 + 0] * c[4] + in[2 * 4 + 0] * c[8] + ta66 - in[2 * 8 + 0] * c[2];
- tmp2b = -in[2 * 2 + 1] * c[4] + in[2 * 4 + 1] * c[8] + tb66 - in[2 * 8 + 1] * c[2];
-
- MACRO1(3);
- MACRO2(5);
- }
-
- {
- real sum0, sum1;
-
- sum0 = in[2 * 0 + 0] - in[2 * 2 + 0] + in[2 * 4 + 0] - in[2 * 6 + 0] + in[2 * 8 + 0];
- sum1 = (in[2 * 0 + 1] - in[2 * 2 + 1] + in[2 * 4 + 1] - in[2 * 6 + 1] + in[2 * 8 + 1]) * tfcos36[4];
- MACRO0(4);
- }
- }
-#endif
-
- }
-}
-
-/*
- * new DCT12
- */
-static void dct12(real * in, real * rawout1, real * rawout2, register real * wi, register real * ts)
-{
-
-#define DCT12_PART1() \
-do { \
- in5 = in[5*3]; \
- in5 += (in4 = in[4*3]); \
- in4 += (in3 = in[3*3]); \
- in3 += (in2 = in[2*3]); \
- in2 += (in1 = in[1*3]); \
- in1 += (in0 = in[0*3]); \
- \
- in5 += in3; in3 += in1; \
- \
- in2 *= COS6_1; \
- in3 *= COS6_1; \
-} while (0)
-
-#define DCT12_PART2() \
-do { \
- in0 += in4 * COS6_2; \
- \
- in4 = in0 + in2; \
- in0 -= in2; \
- \
- in1 += in5 * COS6_2; \
- \
- in5 = (in1 + in3) * tfcos12[0]; \
- in1 = (in1 - in3) * tfcos12[2]; \
- \
- in3 = in4 + in5; \
- in4 -= in5; \
- \
- in2 = in0 + in1; \
- in0 -= in1; \
-} while (0)
-
-
- {
- real in0, in1, in2, in3, in4, in5;
- register real *out1 = rawout1;
-
- ts[SBLIMIT * 0] = out1[0];
- ts[SBLIMIT * 1] = out1[1];
- ts[SBLIMIT * 2] = out1[2];
- ts[SBLIMIT * 3] = out1[3];
- ts[SBLIMIT * 4] = out1[4];
- ts[SBLIMIT * 5] = out1[5];
-
- DCT12_PART1();
-
- {
- real tmp0, tmp1 = (in0 - in4);
-
- {
- real tmp2 = (in1 - in5) * tfcos12[1];
-
- tmp0 = tmp1 + tmp2;
- tmp1 -= tmp2;
- }
- ts[(17 - 1) * SBLIMIT] = out1[17 - 1] + tmp0 * wi[11 - 1];
- ts[(12 + 1) * SBLIMIT] = out1[12 + 1] + tmp0 * wi[6 + 1];
- ts[(6 + 1) * SBLIMIT] = out1[6 + 1] + tmp1 * wi[1];
- ts[(11 - 1) * SBLIMIT] = out1[11 - 1] + tmp1 * wi[5 - 1];
- }
-
- DCT12_PART2();
-
- ts[(17 - 0) * SBLIMIT] = out1[17 - 0] + in2 * wi[11 - 0];
- ts[(12 + 0) * SBLIMIT] = out1[12 + 0] + in2 * wi[6 + 0];
- ts[(12 + 2) * SBLIMIT] = out1[12 + 2] + in3 * wi[6 + 2];
- ts[(17 - 2) * SBLIMIT] = out1[17 - 2] + in3 * wi[11 - 2];
-
- ts[(6 + 0) * SBLIMIT] = out1[6 + 0] + in0 * wi[0];
- ts[(11 - 0) * SBLIMIT] = out1[11 - 0] + in0 * wi[5 - 0];
- ts[(6 + 2) * SBLIMIT] = out1[6 + 2] + in4 * wi[2];
- ts[(11 - 2) * SBLIMIT] = out1[11 - 2] + in4 * wi[5 - 2];
- }
-
- in++;
-
- {
- real in0, in1, in2, in3, in4, in5;
- register real *out2 = rawout2;
-
- DCT12_PART1();
-
- {
- real tmp0, tmp1 = (in0 - in4);
-
- {
- real tmp2 = (in1 - in5) * tfcos12[1];
-
- tmp0 = tmp1 + tmp2;
- tmp1 -= tmp2;
- }
- out2[5 - 1] = tmp0 * wi[11 - 1];
- out2[0 + 1] = tmp0 * wi[6 + 1];
- ts[(12 + 1) * SBLIMIT] += tmp1 * wi[1];
- ts[(17 - 1) * SBLIMIT] += tmp1 * wi[5 - 1];
- }
-
- DCT12_PART2();
-
- out2[5 - 0] = in2 * wi[11 - 0];
- out2[0 + 0] = in2 * wi[6 + 0];
- out2[0 + 2] = in3 * wi[6 + 2];
- out2[5 - 2] = in3 * wi[11 - 2];
-
- ts[(12 + 0) * SBLIMIT] += in0 * wi[0];
- ts[(17 - 0) * SBLIMIT] += in0 * wi[5 - 0];
- ts[(12 + 2) * SBLIMIT] += in4 * wi[2];
- ts[(17 - 2) * SBLIMIT] += in4 * wi[5 - 2];
- }
-
- in++;
-
- {
- real in0, in1, in2, in3, in4, in5;
- register real *out2 = rawout2;
-
- out2[12] = out2[13] = out2[14] = out2[15] = out2[16] = out2[17] = 0.0;
-
- DCT12_PART1();
-
- {
- real tmp0, tmp1 = (in0 - in4);
-
- {
- real tmp2 = (in1 - in5) * tfcos12[1];
-
- tmp0 = tmp1 + tmp2;
- tmp1 -= tmp2;
- }
- out2[11 - 1] = tmp0 * wi[11 - 1];
- out2[6 + 1] = tmp0 * wi[6 + 1];
- out2[0 + 1] += tmp1 * wi[1];
- out2[5 - 1] += tmp1 * wi[5 - 1];
- }
-
- DCT12_PART2();
-
- out2[11 - 0] = in2 * wi[11 - 0];
- out2[6 + 0] = in2 * wi[6 + 0];
- out2[6 + 2] = in3 * wi[6 + 2];
- out2[11 - 2] = in3 * wi[11 - 2];
-
- out2[0 + 0] += in0 * wi[0];
- out2[5 - 0] += in0 * wi[5 - 0];
- out2[0 + 2] += in4 * wi[2];
- out2[5 - 2] += in4 * wi[5 - 2];
- }
-}
-
-/*
- * III_hybrid
- */
-#ifdef USE_3DNOW
-static void III_hybrid(real fsIn[SBLIMIT][SSLIMIT],
- real tsOut[SSLIMIT][SBLIMIT], int ch,
- struct gr_info_s *gr_info, struct frame *fr)
-#else
-static void III_hybrid(real fsIn[SBLIMIT][SSLIMIT],
- real tsOut[SSLIMIT][SBLIMIT], int ch,
- struct gr_info_s *gr_info)
-#endif
-{
- static real block[2][2][SBLIMIT * SSLIMIT] = { {{0,}} };
- static int blc[2] = { 0, 0 };
-
- real *tspnt = (real *) tsOut;
- real *rawout1, *rawout2;
- int bt, sb = 0;
-
- {
- int b = blc[ch];
- rawout1 = block[b][ch];
- b = -b + 1;
- rawout2 = block[b][ch];
- blc[ch] = b;
- }
-
- if (gr_info->mixed_block_flag)
- {
- sb = 2;
- #ifdef USE_3DNOW
- (fr->dct36)(fsIn[0],rawout1,rawout2,win[0],tspnt);
- (fr->dct36)(fsIn[1],rawout1+18,rawout2+18,win1[0],tspnt+1);
- #else
- dct36(fsIn[0], rawout1, rawout2, win[0], tspnt);
- dct36(fsIn[1], rawout1 + 18, rawout2 + 18, win1[0], tspnt + 1);
- #endif
- rawout1 += 36;
- rawout2 += 36;
- tspnt += 2;
- }
-
- bt = gr_info->block_type;
- if (bt == 2)
- {
- for (; sb < (int)gr_info->maxb; sb += 2, tspnt += 2, rawout1 += 36, rawout2 += 36)
- {
- dct12(fsIn[sb], rawout1, rawout2, win[2], tspnt);
- dct12(fsIn[sb + 1], rawout1 + 18, rawout2 + 18, win1[2], tspnt + 1);
- }
- }
- else
- {
- for (; sb < (int)gr_info->maxb; sb += 2, tspnt += 2, rawout1 += 36, rawout2 += 36)
- {
- #ifdef USE_3DNOW
- (fr->dct36)(fsIn[sb],rawout1,rawout2,win[bt],tspnt);
- (fr->dct36)(fsIn[sb+1],rawout1+18,rawout2+18,win1[bt],tspnt+1);
- #else
- dct36(fsIn[sb], rawout1, rawout2, win[bt], tspnt);
- dct36(fsIn[sb + 1], rawout1 + 18, rawout2 + 18, win1[bt], tspnt + 1);
- #endif
- }
- }
-
- for (; sb < SBLIMIT; sb++, tspnt++)
- {
- int i;
- for (i = 0; i < SSLIMIT; i++)
- {
- tspnt[i * SBLIMIT] = *rawout1++;
- *rawout2++ = 0.0;
- }
- }
-}
-
-/*
- * main layer3 handler
- */
-int mpg123_do_layer3(struct frame *fr)
-{
- int gr, ch, ss;
- int scalefacs[2][39]; /* max 39 for short[13][3] mode, mixed: 38, long: 22 */
- struct III_sideinfo sideinfo;
- int stereo = fr->stereo;
- int single = fr->single;
- int ms_stereo, i_stereo;
- int sfreq = fr->sampling_frequency;
- int stereo1, granules;
-
- if (stereo == 1)
- { /* stream is mono */
- stereo1 = 1;
- single = 0;
- }
- else if (single >= 0) /* stream is stereo, but force to mono */
- stereo1 = 1;
- else
- stereo1 = 2;
-
- if (fr->mode == MPG_MD_JOINT_STEREO)
- {
- ms_stereo = (fr->mode_ext & 0x2) >> 1;
- i_stereo = fr->mode_ext & 0x1;
- }
- else
- ms_stereo = i_stereo = 0;
-
- granules = fr->lsf ? 1 : 2;
- if (!III_get_side_info(&sideinfo, stereo, ms_stereo, sfreq, single, fr->lsf))
- return 0;
-
- mpg123_set_pointer(sideinfo.main_data_begin);
-
- for (gr = 0; gr < granules; gr++)
- {
- real hybridIn[2][SBLIMIT][SSLIMIT];
- real hybridOut[2][SSLIMIT][SBLIMIT];
-
- {
- struct gr_info_s *gr_info = &(sideinfo.ch[0].gr[gr]);
- long part2bits;
-
- if (fr->lsf)
- part2bits = III_get_scale_factors_2(scalefacs[0], gr_info, 0);
- else
- part2bits = III_get_scale_factors_1(scalefacs[0], gr_info);
-
- if (III_dequantize_sample(hybridIn[0], scalefacs[0], gr_info, sfreq, part2bits))
- return 0;
- }
-
- if (stereo == 2)
- {
- struct gr_info_s *gr_info = &(sideinfo.ch[1].gr[gr]);
- long part2bits;
-
- if (fr->lsf)
- part2bits = III_get_scale_factors_2(scalefacs[1], gr_info, i_stereo);
- else
- part2bits = III_get_scale_factors_1(scalefacs[1], gr_info);
-
- if (III_dequantize_sample(hybridIn[1], scalefacs[1], gr_info, sfreq, part2bits))
- return 0;
-
- if (ms_stereo)
- {
- int i;
- int maxb = sideinfo.ch[0].gr[gr].maxb;
-
- if ((int)sideinfo.ch[1].gr[gr].maxb > maxb)
- maxb = sideinfo.ch[1].gr[gr].maxb;
- for (i = 0; i < SSLIMIT * maxb; i++)
- {
- real tmp0 = ((real *) hybridIn[0])[i];
- real tmp1 = ((real *) hybridIn[1])[i];
- ((real *) hybridIn[0])[i] = tmp0 + tmp1;
- ((real *) hybridIn[1])[i] = tmp0 - tmp1;
- }
- }
-
- if (i_stereo)
- III_i_stereo(hybridIn, scalefacs[1], gr_info, sfreq, ms_stereo, fr->lsf);
-
- if (ms_stereo || i_stereo || (single == 3))
- {
- if (gr_info->maxb > sideinfo.ch[0].gr[gr].maxb)
- sideinfo.ch[0].gr[gr].maxb = gr_info->maxb;
- else
- gr_info->maxb = sideinfo.ch[0].gr[gr].maxb;
- }
-
- switch (single)
- {
- case 3:
- {
- register int i;
- register real *in0 = (real *) hybridIn[0],
- *in1 = (real *) hybridIn[1];
- for (i = 0; i < (int)(SSLIMIT * gr_info->maxb); i++, in0++)
- *in0 = (*in0 + *in1++); /* *0.5 done by pow-scale */
- }
- break;
- case 1:
- {
- register int i;
- register real *in0 = (real *) hybridIn[0],
- *in1 = (real *) hybridIn[1];
- for (i = 0; i < (int)(SSLIMIT * gr_info->maxb); i++)
- *in0++ = *in1++;
- }
- break;
- }
- }
- if (mpg123_info->eq_active)
- {
- int i, sb;
-
- if (single < 0)
- {
- for (sb = 0, i = 0; sb < SBLIMIT; sb++)
- {
- for (ss = 0; ss < SSLIMIT; ss++)
- {
- hybridIn[0][sb][ss] *= mpg123_info->eq_mul[i];
- hybridIn[1][sb][ss] *= mpg123_info->eq_mul[i++];
- }
- }
- }
- else
- {
- for (sb = 0, i = 0; sb < SBLIMIT; sb++)
- {
- for (ss = 0; ss < SSLIMIT; ss++)
- hybridIn[0][sb][ss] *= mpg123_info->eq_mul[i++];
- }
- }
- }
-
- for (ch = 0; ch < stereo1; ch++)
- {
- struct gr_info_s *gr_info = &(sideinfo.ch[ch].gr[gr]);
-
- III_antialias(hybridIn[ch], gr_info);
- if (gr_info->maxb < 1 || gr_info->maxb > SBLIMIT)
- return 0;
- #ifdef USE_3DNOW
- III_hybrid(hybridIn[ch], hybridOut[ch], ch,gr_info,fr);
- #else
- III_hybrid(hybridIn[ch], hybridOut[ch], ch, gr_info);
- #endif
- }
-
- for (ss = 0; ss < SSLIMIT; ss++)
- {
- if (single >= 0) {
- (fr->synth_mono) (hybridOut[0][ss], mpg123_pcm_sample, &mpg123_pcm_point);
- } else {
- int p1 = mpg123_pcm_point;
-
- (fr->synth) (hybridOut[0][ss], 0, mpg123_pcm_sample, &p1);
- (fr->synth) (hybridOut[1][ss], 1, mpg123_pcm_sample, &mpg123_pcm_point);
- }
- }
-
- if (mpg123_info->output_audio) {
- //mpg123_ip.add_vis_pcm(mpg123_ip.output->written_time(),
- // mpg123_cfg.resolution == 16 ? FMT_S16_NE : FMT_U8,
- // mpg123_cfg.channels == 2 ? fr->stereo : 1,
- // mpg123_pcm_point, mpg123_pcm_sample);
- while (esdout_free () < mpg123_pcm_point && mpg123_info->going && mpg123_info->jump_to_time == -1) {
- usleep (10000);
- }
-
- if (mpg123_info->going && mpg123_info->jump_to_time == -1) {
- esdout_write (mpg123_pcm_sample, mpg123_pcm_point);
- }
- }
- mpg123_pcm_point = 0;
- }
- return 1;
-}
diff --git a/components/music/main.c b/components/music/main.c
deleted file mode 100644
index 5f43548a2..000000000
--- a/components/music/main.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/*
- * Copyright (C) 2000 Eazel, Inc
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: Maciej Stachowiak <mjs@eazel.com>
- */
-
-/* main.c - Main function and object activation function for music
- * view component.
- */
-
-#include <config.h>
-
-#include "nautilus-music-view.h"
-#include <libnautilus/nautilus-view-standard-main.h>
-#include <libnautilus-private/nautilus-global-preferences.h>
-#include <eel/eel-debug.h>
-
-#define VIEW_IID "OAFIID:Nautilus_Music_View"
-#define FACTORY_IID "OAFIID:Nautilus_Music_View_Factory"
-
-int
-main (int argc, char *argv[])
-{
- if (g_getenv ("NAUTILUS_DEBUG") != NULL) {
- eel_make_warnings_and_criticals_stop_in_debugger ();
- }
-
- return nautilus_view_standard_main ("nautilus-music-view",
- VERSION,
- GETTEXT_PACKAGE,
- GNOMELOCALEDIR,
- argc,
- argv,
- FACTORY_IID,
- VIEW_IID,
- nautilus_view_create_from_get_type_function,
- nautilus_global_preferences_init,
- nautilus_music_view_get_type);
-}
diff --git a/components/music/mp3head.c b/components/music/mp3head.c
deleted file mode 100644
index 32051fcf5..000000000
--- a/components/music/mp3head.c
+++ /dev/null
@@ -1,400 +0,0 @@
-/*
- * MPEG Layer3 header info extraction routines
- *
- * Author: Erik Gustavsson, <cyrano@algonet.se>
- *
- * This software is released under the GNU General Public License.
- * Please read the included file COPYING for more information.
- * This software comes with no warranty of any kind, use at you own risk!
- */
-
-#include "mp3head.h"
-
-int bitrates[2][16] = {
-{0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,}, /* MPEG2 */
-{0,32,40,48, 56, 64, 80, 96,112,128,160,192,224,256,320,}}; /* MPEG1 */
-
-long samprates[2][3] = {
-{ 22050, 24000, 16000 }, /* MPEG2 */
-{ 44100, 48000, 32000 }}; /* MPEG1 */
-
-
-static int extractI4(unsigned char *buf)
-{
- int x;
- /* big endian extract */
-
- x = buf[0];
- x <<= 8;
- x |= buf[1];
- x <<= 8;
- x |= buf[2];
- x <<= 8;
- x |= buf[3];
-
- return(x);
-}
-
-/* check for valid MPEG header */
-static int is_mphead(unsigned char *buf)
-{
- if (buf[0] != 0xff) return(0);
- if ((buf[1] & 0xf0) != 0xf0) return(0); /* 12 bits framesync */
-
- return(1);
-}
-
-/* check for valid "Xing" VBR header */
-static int is_xhead(unsigned char *buf)
-{
- if (buf[0] != 'X') return(0);
- if (buf[1] != 'i') return(0);
- if (buf[2] != 'n') return(0);
- if (buf[3] != 'g') return(0);
-
- return(1);
-}
-
-/* return bitrate from MPEG header, average rate for VBR files or -1 on error */
-int get_bitrate (unsigned char *buf,int bufsize)
-{
- int i=0;
- int ver,srindex,brindex,xbytes,xframes;
- float br;
-
- while(!is_mphead(buf+i)) {
- i++;
- if (i>bufsize-4) return(-1); /* no valid header, give up */
- }
-
- ver = (buf[i+1] & 0x08) >> 3;
- brindex = (buf[i+2] & 0xf0) >> 4;
- srindex = (buf[i+2] & 0x0c) >> 2;
-
- /* but if there is a Xing header we'll use that instead... */
- i=0;
- while(!is_xhead(buf+i)) {
- i++;
- if (i>bufsize-16) return(bitrates[ver][brindex]);
- }
-
- xframes = extractI4(buf+i+8);
- xbytes = extractI4(buf+i+12);
-
- br = (float)samprates[ver][srindex]*xbytes/(576+ver*576)/xframes/125;
- return(br);
-}
-
-/* return sample rate from MPEG header */
-int get_samprate(unsigned char *buf, int bufsize)
-{
- int i=0;
- int ver,srindex;
-
- while(!is_mphead(buf+i))
- {
- i++;
- if (i>bufsize-4) return(-1); /* no valid header, give up */
- }
-
- ver = (buf[i+1] & 0x08) >> 3;
- srindex = (buf[i+2] & 0x0c) >> 2;
-
- return(samprates[ver][srindex]);
-}
-
-
-/* return 1 for MPEG1, 0 for MPEG2, -1 for error */
-int get_mpgver(unsigned char *buf,int bufsize)
-{
- int i=0;
- int ver;
-
- while(!is_mphead(buf+i))
- {
- i++;
- if (i>bufsize-4) return(-1); /* no valid header, give up */
- }
-
- ver = (buf[i+1] & 0x08) >> 3;
-
- return(ver);
-}
-
-/* return 0=mono, 1=dual ch, 2=joint stereo, 3=stereo */
-int get_stereo(unsigned char *buf,int bufsize)
-{
- int i=0;
- int st;
-
- while(!is_mphead(buf+i))
- {
- i++;
- if (i>bufsize-4) return(-1); /* no valid header, give up */
- }
-
- st = (buf[i+3] & 0xC0) >> 6;
-
- return(3-st);
-}
-
-
-static int mp_br_table[2][16] =
- {{0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0},
- {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 0}};
-
-static int mp_sr20_table[2][4] =
- {{441, 480, 320, -999}, {882, 960, 640, -999}};
-
-/* mpeg2 */
-static int mp_br_tableL1[2][16] =
- {{0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 0},
- {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 0}};
-
-/* mpeg 2 */
-static int mp_br_tableL3[2][16] =
- {{0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0},
- {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 0}};
-
-
-static int
-compare(unsigned char *buf, unsigned char *buf2)
-{
- if (buf[0] != buf2[0]) {
- return 0;
- }
-
- if (buf[1] != buf2[1]) {
- return 0;
- }
-
- return 1;
-}
-
-
-
-/*------------------------------------------------------*/
-/*---- scan for next sync, assume start is valid -------*/
-/*---- return number bytes to next sync ----------------*/
-static int
-sync_scan (unsigned char *buf, int n, int i0)
-{
- int i;
-
- for (i = i0; i < n; i++) {
- if (compare (buf, buf + i)) {
- return i;
- }
- }
-
- return 0;
-}
-
-/*------------------------------------------------------*/
-/*- test consecutative syncs, input isync without pad --*/
-static int
-sync_test (unsigned char *buf, int n, int isync, int padbytes)
-{
- int i, nmatch, pad;
-
- nmatch = 0;
- for (i = 0;;) {
- pad = padbytes * ((buf[i + 2] & 0x02) >> 1);
- i += (pad + isync);
-
- if (i > n) {
- break;
- }
-
- if (!compare(buf, buf + i)) {
- return -nmatch;
- }
-
- nmatch++;
- }
-
- return nmatch;
-}
-
-
-static int
-find_sync (unsigned char *buf, int n)
-{
- int i0, isync, nmatch, pad;
- int padbytes, option;
-
- /* mod 4/12/95 i0 change from 72, allows as low as 8kbits for mpeg1 */
- i0 = 24;
- padbytes = 1;
- option = (buf[1] & 0x06) >> 1;
- if (option == 3) {
- padbytes = 4;
- i0 = 24; /* for shorter layer I frames */
- }
-
- pad = (buf[2] & 0x02) >> 1;
-
- n -= 3; /* need 3 bytes of header */
-
- while (i0 < 2000) {
- isync = sync_scan (buf, n, i0);
- i0 = isync + 1;
- isync -= pad;
- if (isync <= 0) {
- return 0;
- }
-
- nmatch = sync_test (buf, n, isync, padbytes);
- if (nmatch > 0) {
- return isync;
- }
- }
-
- return 0;
-}
-
-
-
-int
-get_header_info (unsigned char *buf, unsigned int n, MPEGHeader *h)
-{
- int framebytes;
- int mpeg25_flag;
-
- if (n > 10000) {
- /* limit scan for free format */
- n = 10000;
- }
-
- h->sync = 0;
-
- if ((buf[0] == 0xFF) && ((buf[0+1] & 0xF0) == 0xF0)) {
- /* mpeg 1 & 2 */
- mpeg25_flag = 0;
-
- } else if ((buf[0] == 0xFF) && ((buf[0+1] & 0xF0) == 0xE0)) {
- /* mpeg 2.5 */
- mpeg25_flag = 1;
- } else {
- /* sync fail */
- return 0;
- }
-
- h->sync = 1;
- if (mpeg25_flag) {
- /* low bit clear signals mpeg25 (as in 0xFFE) */
- h->sync = 2;
- }
-
- h->id = (buf[0+1] & 0x08) >> 3;
- h->option = (buf[0+1] & 0x06) >> 1;
- h->prot = (buf[0+1] & 0x01);
-
- h->br_index = (buf[0+2] & 0xf0) >> 4;
- h->sr_index = (buf[0+2] & 0x0c) >> 2;
- h->pad = (buf[0+2] & 0x02) >> 1;
- h->private_bit = (buf[0+2] & 0x01);
- h->mode = (buf[0+3] & 0xc0) >> 6;
- h->mode_ext = (buf[0+3] & 0x30) >> 4;
- h->cr = (buf[0+3] & 0x08) >> 3;
- h->original = (buf[0+3] & 0x04) >> 2;
- h->emphasis = (buf[0+3] & 0x03);
-
- /* compute framebytes for Layer I, II, III */
- if (h->option < 1) {
- return 0;
- }
-
- if (h->option > 3) {
- return 0;
- }
-
- framebytes = 0;
-
- if (h->br_index > 0) {
- if (h->option == 3) {
- /* layer I */
- framebytes = 240 * mp_br_tableL1[h->id][h->br_index] / mp_sr20_table[h->id][h->sr_index];
- framebytes = 4 * framebytes;
- } else if (h->option == 2) {
- /* layer II */
- framebytes = 2880 * mp_br_table[h->id][h->br_index] / mp_sr20_table[h->id][h->sr_index];
- } else if (h->option == 1) {
- /* layer III */
- if (h->id) {
- // mpeg1
- framebytes = 2880 * mp_br_tableL3[h->id][h->br_index] / mp_sr20_table[h->id][h->sr_index];
- } else {
- /* mpeg2 */
- if (mpeg25_flag) {
- /* mpeg2.2 */
- framebytes = 2880 * mp_br_tableL3[h->id][h->br_index] / mp_sr20_table[h->id][h->sr_index];
- } else {
- framebytes = 1440 * mp_br_tableL3[h->id][h->br_index] / mp_sr20_table[h->id][h->sr_index];
- }
- }
- } else {
- /* free format */
- framebytes = find_sync (buf, n);
- }
- }
-
- return framebytes;
-}
-
-int
-get_header_info_extended (unsigned char *buf, unsigned int n, MPEGHeader *h, int *bitrate)
-{
- int framebytes;
-
- /*--- return bitrate (in bits/sec) in addition to frame bytes ---*/
- *bitrate = 0;
-
- /*-- assume fail --*/
- framebytes = get_header_info (buf, n, h);
-
- if (framebytes == 0) {
- return 0;
- }
-
- /* layer III */
- if (h->option == 1) {
- if (h->br_index > 0) {
- *bitrate = 1000 * mp_br_tableL3[h->id][h->br_index];
- } else {
- if (h->id) {
- /* mpeg1 */
- *bitrate = 1000 * framebytes * mp_sr20_table[h->id][h->sr_index] / (144 * 20);
- } else {
- /* mpeg2 */
- if ((h->sync & 1) == 0) {
- /* flags mpeg25 */
- *bitrate = 500 * framebytes * mp_sr20_table[h->id][h->sr_index] / (72 * 20);
- } else {
- *bitrate = 1000 * framebytes * mp_sr20_table[h->id][h->sr_index] / (72 * 20);
- }
- }
- }
- }
-
- /* layer II */
- if (h->option == 2) {
- if (h->br_index > 0) {
- *bitrate = 1000 * mp_br_table[h->id][h->br_index];
- } else {
- *bitrate = 1000 * framebytes * mp_sr20_table[h->id][h->sr_index] / (144 * 20);
- }
- }
-
- /* layer I */
- if (h->option == 3) {
- if (h->br_index > 0) {
- *bitrate = 1000 * mp_br_tableL1[h->id][h->br_index];
- } else {
- *bitrate = 1000 * framebytes * mp_sr20_table[h->id][h->sr_index] / (48 * 20);
- }
- }
-
- return framebytes;
-}
-
diff --git a/components/music/mp3head.h b/components/music/mp3head.h
deleted file mode 100644
index 34070de76..000000000
--- a/components/music/mp3head.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * MPEG Layer3 header info extraction routines
- *
- * Author: Erik Gustavsson, <cyrano@algonet.se>
- *
- * This software is released under the GNU General Public License.
- * Please read the included file COPYING for more information.
- * This software comes with no warranty of any kind, use at you own risk!
- */
-
-#ifndef MP3HEAD_H
-#define MP3HEAD_H
-
-/* mpeg audio header */
-typedef struct
-{
- int sync; /* 1 if valid sync */
- int id;
- int option;
- int prot;
- int br_index;
- int sr_index;
- int pad;
- int private_bit;
- int mode;
- int mode_ext;
- int cr;
- int original;
- int emphasis;
-} MPEGHeader;
-
-
-/* ID3v2 Tag Header */
-typedef struct {
- char id_str[3];
- unsigned char version[2];
- unsigned char flags[1];
- unsigned char size[4];
-} ID3V2Header;
-
-
-int get_bitrate(unsigned char *buf,int bufsize);
-int get_samprate(unsigned char *buf,int bufsize);
-int get_mpgver(unsigned char *buf,int bufsize);
-int get_stereo(unsigned char *buf,int bufsize);
-
-int get_header_info (unsigned char *buf, unsigned int n, MPEGHeader *h);
-int get_header_info_extended (unsigned char *buf, unsigned int n, MPEGHeader *h, int *bitrate);
-
-#endif
-
diff --git a/components/music/mpg123.c b/components/music/mpg123.c
deleted file mode 100644
index ea087de5f..000000000
--- a/components/music/mpg123.c
+++ /dev/null
@@ -1,845 +0,0 @@
-#include <config.h>
-#include "mpg123.h"
-
-#include "esd-audio.h"
-#include <string.h>
-#include <stdlib.h>
-#include <pthread.h>
-#include <libgnome/gnome-i18n.h>
-
-static long outscale = 32768;
-
-static struct frame fr, temp_fr;
-
-PlayerInfo *mpg123_info = NULL;
-static pthread_t decode_thread;
-MPG123Config mpg123_cfg;
-
-static gboolean vbr_set = FALSE, have_xing_header = FALSE;
-static XHEADDATA xing_header;
-static unsigned char xing_toc[100];
-static gboolean audio_error = FALSE;
-gint mpg123_bitrate, mpg123_frequency, mpg123_length, mpg123_layer, mpg123_lsf;
-gchar *mpg123_title = NULL, *mpg123_filename = NULL;
-static gint disp_bitrate, skip_frames = 0;
-gboolean mpg123_stereo, mpg123_mpeg25;
-gint mpg123_mode;
-
-const gchar *mpg123_id3_genres[GENRE_MAX] =
-{
- N_("Blues"), N_("Classic Rock"), N_("Country"), N_("Dance"),
- N_("Disco"), N_("Funk"), N_("Grunge"), N_("Hip-Hop"),
- N_("Jazz"), N_("Metal"), N_("New Age"), N_("Oldies"),
- N_("Other"), N_("Pop"), N_("R&B"), N_("Rap"), N_("Reggae"),
- N_("Rock"), N_("Techno"), N_("Industrial"), N_("Alternative"),
- N_("Ska"), N_("Death Metal"), N_("Pranks"), N_("Soundtrack"),
- N_("Euro-Techno"), N_("Ambient"), N_("Trip-Hop"), N_("Vocal"),
- N_("Jazz+Funk"), N_("Fusion"), N_("Trance"), N_("Classical"),
- N_("Instrumental"), N_("Acid"), N_("House"), N_("Game"),
- N_("Sound Clip"), N_("Gospel"), N_("Noise"), N_("Alt"),
- N_("Bass"), N_("Soul"), N_("Punk"), N_("Space"),
- N_("Meditative"), N_("Instrumental Pop"),
- N_("Instrumental Rock"), N_("Ethnic"), N_("Gothic"),
- N_("Darkwave"), N_("Techno-Industrial"), N_("Electronic"),
- N_("Pop-Folk"), N_("Eurodance"), N_("Dream"),
- N_("Southern Rock"), N_("Comedy"), N_("Cult"),
- N_("Gangsta Rap"), N_("Top 40"), N_("Christian Rap"),
- N_("Pop/Funk"), N_("Jungle"), N_("Native American"),
- N_("Cabaret"), N_("New Wave"), N_("Psychedelic"), N_("Rave"),
- N_("Showtunes"), N_("Trailer"), N_("Lo-Fi"), N_("Tribal"),
- N_("Acid Punk"), N_("Acid Jazz"), N_("Polka"), N_("Retro"),
- N_("Musical"), N_("Rock & Roll"), N_("Hard Rock"), N_("Folk"),
- N_("Folk/Rock"), N_("National Folk"), N_("Swing"),
- N_("Fast-Fusion"), N_("Bebob"), N_("Latin"), N_("Revival"),
- N_("Celtic"), N_("Bluegrass"), N_("Avantgarde"),
- N_("Gothic Rock"), N_("Progressive Rock"),
- N_("Psychedelic Rock"), N_("Symphonic Rock"), N_("Slow Rock"),
- N_("Big Band"), N_("Chorus"), N_("Easy Listening"),
- N_("Acoustic"), N_("Humour"), N_("Speech"), N_("Chanson"),
- N_("Opera"), N_("Chamber Music"), N_("Sonata"), N_("Symphony"),
- N_("Booty Bass"), N_("Primus"), N_("Porn Groove"),
- N_("Satire"), N_("Slow Jam"), N_("Club"), N_("Tango"),
- N_("Samba"), N_("Folklore"), N_("Ballad"), N_("Power Ballad"),
- N_("Rhythmic Soul"), N_("Freestyle"), N_("Duet"),
- N_("Punk Rock"), N_("Drum Solo"), N_("A Cappella"),
- N_("Euro-House"), N_("Dance Hall"), N_("Goa"),
- N_("Drum & Bass"), N_("Club-House"), N_("Hardcore"),
- N_("Terror"), N_("Indie"), N_("BritPop"), N_("Negerpunk"),
- N_("Polsk Punk"), N_("Beat"), N_("Christian Gangsta Rap"),
- N_("Heavy Metal"), N_("Black Metal"), N_("Crossover"),
- N_("Contemporary Christian"), N_("Christian Rock"),
- N_("Merengue"), N_("Salsa"), N_("Thrash Metal"),
- N_("Anime"), N_("JPop"), N_("Synthpop")
-};
-
-double mpg123_compute_tpf(struct frame *fr)
-{
- static int bs[4] =
- {0, 384, 1152, 1152};
- double tpf;
-
- tpf = (double) bs[fr->lay];
- tpf /= mpg123_freqs[fr->sampling_frequency] << (fr->lsf);
- return tpf;
-}
-
-static void
-set_mpg123_synth_functions(struct frame *fr)
-{
- typedef int (*func) (real *, int, unsigned char *, int *);
- typedef int (*func_mono) (real *, unsigned char *, int *);
- int ds = fr->down_sample;
- int p8 = 0;
-
- static func funcs[2][4] =
- {
- {mpg123_synth_1to1,
- mpg123_synth_2to1,
- mpg123_synth_4to1,
- mpg123_synth_ntom},
- {mpg123_synth_1to1_8bit,
- mpg123_synth_2to1_8bit,
- mpg123_synth_4to1_8bit,
- mpg123_synth_ntom_8bit}
- };
-
- static func_mono funcs_mono[2][2][4] =
- {
- {
- {mpg123_synth_1to1_mono2stereo,
- mpg123_synth_2to1_mono2stereo,
- mpg123_synth_4to1_mono2stereo,
- mpg123_synth_ntom_mono2stereo},
- {mpg123_synth_1to1_8bit_mono2stereo,
- mpg123_synth_2to1_8bit_mono2stereo,
- mpg123_synth_4to1_8bit_mono2stereo,
- mpg123_synth_ntom_8bit_mono2stereo}},
- {
- {mpg123_synth_1to1_mono,
- mpg123_synth_2to1_mono,
- mpg123_synth_4to1_mono,
- mpg123_synth_ntom_mono},
- {mpg123_synth_1to1_8bit_mono,
- mpg123_synth_2to1_8bit_mono,
- mpg123_synth_4to1_8bit_mono,
- mpg123_synth_ntom_8bit_mono}}
- };
-
- if (mpg123_cfg.resolution == 8)
- p8 = 1;
- fr->synth = funcs[p8][ds];
- fr->synth_mono = funcs_mono[1][p8][ds];
-
- if (p8) {
- mpg123_make_conv16to8_table();
- }
-}
-
-static void
-mpg123_init (void)
-{
- mpg123_make_decode_tables(outscale);
-
- mpg123_cfg.resolution = 16;
- mpg123_cfg.channels = 2;
- mpg123_cfg.downsample = 0;
- mpg123_cfg.downsample_custom = 44100;
- mpg123_cfg.proxy_port = 8080;
- mpg123_cfg.proxy_use_auth = FALSE;
- mpg123_cfg.proxy_user = NULL;
- mpg123_cfg.proxy_pass = NULL;
- mpg123_cfg.cast_title_streaming = FALSE;
- mpg123_cfg.use_udp_channel = TRUE;
- mpg123_cfg.use_id3 = TRUE;
- mpg123_cfg.disable_id3v2 = FALSE;
- mpg123_cfg.detect_by_content = FALSE;
- mpg123_cfg.id3_format = g_strdup("%1 - %2");
- mpg123_cfg.proxy_host = g_strdup("localhost");
-}
-
-static guint32
-convert_to_header (guint8 * buf)
-{
-
- return (buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + buf[3];
-}
-
-static void
-play_frame (struct frame *fr)
-{
- if (fr->error_protection) {
- bsi.wordpointer += 2;
- /* mpg123_getbits(16); */ /* skip crc */
- }
-
- if(!fr->do_layer(fr)) {
- skip_frames = 2;
- mpg123_info->output_audio = FALSE;
- } else {
- if(!skip_frames)
- mpg123_info->output_audio = TRUE;
- else
- skip_frames--;
- }
-}
-
-/* as defined in WinAmp's Nullsoft Nitrane pllugin preferences
- default is "%1 - %2" (Artist - Title), %% = '%' */
-enum id3_format_codes
-{
- ID3_ARTIST = '1', ID3_TITLE, ID3_ALBUM, ID3_YEAR,
- ID3_COMMENT, ID3_GENRE, FILE_NAME, FILE_PATH,
- FILE_EXT
-};
-
-static const gchar *get_id3_genre(unsigned char genre_code)
-{
- return (genre_code < GENRE_MAX) ? mpg123_id3_genres[genre_code] : "";
-};
-
-guint mpg123_strip_spaces(char *src, size_t n)
-/* strips trailing spaces from string of length n
- returns length of adjusted string */
-{
- gchar *space = NULL, /* last space in src */
- *start = src;
-
- while (n--)
- switch (*src++)
- {
- case '\0':
- n = 0; /* breaks out of while loop */
-
- src--;
- break;
- case ' ':
- if (space == NULL)
- space = src - 1;
- break;
- default:
- space = NULL; /* don't terminate intermediate spaces */
-
- break;
- }
- if (space != NULL)
- {
- src = space;
- *src = '\0';
- }
- return src - start;
-}
-
-/*
- * Function extname (filename)
- *
- * Return pointer within filename to its extenstion, or NULL if
- * filename has no extension.
- *
- */
-static gchar *extname(const char *filename)
-{
- gchar *ext = strrchr(filename, '.');
-
- if (ext != NULL)
- ++ext;
-
- return ext;
-}
-
-static gchar *eval_id3_format(const char *id3_format, struct id3tag_t *id3,
- const char *filename)
-/* returns ID3 and filename data as specified in format
- as in Nullsoft's Nitrane plugin v1.31b (their MPEG decoder) */
-{
- gchar *ans, c, *base, *path, *ext;
- guint length = 0, allocated, baselen, pathlen, extlen, tmp;
- const size_t alloc_size = 256; /* size of memory block allocations */
- gboolean got_field = FALSE;
-
- ans = g_malloc (allocated = alloc_size);
- pathlen = strlen (path = g_path_get_dirname (filename));
- base = g_path_get_basename (filename);
- if ((ext = extname(base)) == NULL)
- {
- ext = "";
- extlen = 0;
- } else {
- *(ext - 1) = '\0';
- extlen = strlen(ext);
- }
- baselen = strlen(base);
- while ((c = *id3_format++) != '\0')
- {
- tmp = 1;
- if (c == '%')
- {
- switch (*id3_format++)
- {
- case 0:
- id3_format--; /* otherwise we'll lose terminator */
-
- case '%':
- ans[length] = '%';
- break;
- case ID3_ARTIST:
- tmp = strlen(id3->artist);
- if(tmp != 0)
- got_field = TRUE;
- strncpy(&ans[length], id3->artist, tmp);
- break;
- case ID3_TITLE:
- tmp = strlen(id3->title);
- if(tmp != 0)
- got_field = TRUE;
- strncpy(&ans[length], id3->title, tmp);
- break;
- case ID3_ALBUM:
- tmp = strlen(id3->album);
- if(tmp != 0)
- got_field = TRUE;
- strncpy(&ans[length], id3->album, tmp);
- break;
- case ID3_YEAR:
- tmp = strlen(id3->year);
- if(tmp != 0)
- got_field = TRUE;
- strncpy(&ans[length], id3->year, tmp);
- break;
- case ID3_COMMENT:
- tmp = strlen(id3->comment);
- if(tmp != 0)
- got_field = TRUE;
- strncpy(&ans[length], id3->comment, tmp);
- break;
- case ID3_GENRE:
- tmp = strlen(id3->genre);
- if(tmp != 0)
- got_field = TRUE;
- strncpy(&ans[length], id3->genre, tmp);
- break;
- case FILE_NAME:
- strncpy(&ans[length], base, tmp = baselen);
- got_field = TRUE;
- break;
- case FILE_PATH:
- strncpy(&ans[length], path, tmp = pathlen);
- got_field = TRUE;
- break;
- case FILE_EXT:
- strncpy(&ans[length], ext, tmp = extlen);
- got_field = TRUE;
- break;
- default:
- ans[length] = c;
- break;
- }
- }
- else
- ans[length] = c;
- ans[length += tmp] = '\0';
- if (allocated - length <= 30)
- ans = g_realloc(ans, allocated += alloc_size);
- }
- ans = g_realloc(ans, length + 1);
- if(!got_field)
- {
- g_free(ans);
- ans = g_strdup(base);
- }
- g_free(base);
- g_free(path);
- return ans;
-}
-
-/*
- * Function id3v1_to_id3v2 (v1, v2)
- *
- * Convert ID3v1 tag `v1' to ID3v2 tag `v2'.
- *
- */
-
-void
-mpg123_id3v1_to_id3v2 (struct id3v1tag_t *v1, struct id3tag_t *v2)
-{
- memset(v2,0,sizeof(struct id3tag_t));
- strncpy(v2->title, v1->title, 30);
- strncpy(v2->artist, v1->artist, 30);
- strncpy(v2->album, v1->album, 30);
- strncpy(v2->year, v1->year, 4);
- strncpy(v2->comment, v1->comment, 28);
- g_snprintf(v2->track, sizeof v2->track, "%d", v1->track);
- strncpy(v2->genre, get_id3_genre(v1->genre), sizeof (v2->genre));
- mpg123_strip_spaces(v2->title, 30);
- mpg123_strip_spaces(v2->artist, 30);
- mpg123_strip_spaces(v2->album, 30);
- mpg123_strip_spaces(v2->year, 4);
- mpg123_strip_spaces(v2->comment, 30);
- mpg123_strip_spaces(v2->genre, sizeof (v2->genre));
-}
-
-/*
- * Function mpg123_format_song_title (tag, filename)
- *
- * Create song title according to `tag' and/or `filename' and
- * return it. The title must be subsequently freed using g_free().
- *
- */
-gchar *mpg123_format_song_title(struct id3tag_t *tag, gchar * filename)
-{
- gchar *ret = NULL;
-
- if (mpg123_cfg.use_id3 && tag)
- {
- /*
- * Format according to tag.
- */
- ret = eval_id3_format(mpg123_cfg.id3_format,
- tag, filename);
- }
-
- if (!ret)
- {
- /*
- * Format according to filename.
- */
- ret = g_path_get_basename (filename);
- if (extname(ret) != NULL)
- *(extname(ret) - 1) = '\0'; /* removes period */
- }
-
- return ret;
-}
-
-/*
- * Function mpg123_get_id3v2 (id3d, tag)
- *
- * Get desired contents from the indicated id3tag and store it in
- * `tag'.
- *
- */
-void mpg123_get_id3v2(id3_t * id3d, struct id3tag_t *tag)
-{
- id3_frame_t *id3frm;
- char *txt;
- int tlen;
-
-#define ID3_SET(_tid,_fld) \
-{ \
- id3frm = id3_get_frame( id3d, _tid, 1 ); \
- if (id3frm) { \
- txt = _tid == ID3_TCON ? id3_get_content(id3frm) \
- : id3_get_text(id3frm); \
- if(txt) \
- { \
- tlen = strlen(txt); \
- if ( tlen >= (int)sizeof(tag->_fld) ) \
- tlen = sizeof(tag->_fld)-1; \
- strncpy( tag->_fld, txt, tlen ); \
- tag->_fld[tlen] = 0; \
- } \
- else \
- tag->_fld[0] = 0; \
- } else { \
- tag->_fld[0] = 0; \
- } \
-}
- ID3_SET(ID3_TIT2, title);
- ID3_SET(ID3_TPE1, artist);
- ID3_SET(ID3_TALB, album);
- ID3_SET(ID3_TYER, year);
- ID3_SET(ID3_TXXX, comment);
- ID3_SET(ID3_TCON, genre);
-}
-
-/*
- * Function get_song_title (fd, filename)
- *
- * Get song title of file. File position of `fd' will be
- * clobbered. `fd' may be NULL, in which case `filename' is opened
- * separately. The returned song title must be subsequently freed
- * using g_free().
- *
- */
-static gchar *get_song_title(FILE * fd, char *filename)
-{
- FILE *file = fd;
- char *ret = NULL;
- struct id3v1tag_t id3v1tag;
- struct id3tag_t id3tag;
-
- if (file || (file = fopen(filename, "rb")) != 0)
- {
- id3_t *id3 = NULL;
-
- /*
- * Try reading ID3v2 tag.
- */
- if (!mpg123_cfg.disable_id3v2)
- {
- fseek(file, 0, SEEK_SET);
- id3 = id3_open_fp(file, 0);
- if (id3)
- {
- mpg123_get_id3v2(id3, &id3tag);
- ret = mpg123_format_song_title(&id3tag, filename);
- id3_close(id3);
- }
- }
-
- /*
- * Try reading ID3v1 tag.
- */
- if (!id3 && (fseek(file, -1 * sizeof (id3v1tag), SEEK_END) == 0) &&
- (fread(&id3v1tag, 1, sizeof (id3v1tag), file) == sizeof (id3v1tag)) &&
- (strncmp(id3v1tag.tag, "TAG", 3) == 0))
- {
- mpg123_id3v1_to_id3v2(&id3v1tag, &id3tag);
- ret = mpg123_format_song_title(&id3tag, filename);
- }
-
- if (!fd)
- /*
- * File was opened in this function.
- */
- fclose(file);
- }
-
- if (ret == NULL)
- /*
- * Unable to get ID3 tag.
- */
- ret = mpg123_format_song_title(NULL, filename);
-
- return ret;
-}
-
-static guint
-get_song_time (FILE * file)
-{
- guint32 head;
- guchar tmp[4], *buf;
- struct frame frm;
- XHEADDATA xing_header;
- double tpf, bpf;
- guint32 len;
-
- if (!file)
- return -1;
-
- fseek(file, 0, SEEK_SET);
- if (fread(tmp, 1, 4, file) != 4)
- return 0;
- head = convert_to_header(tmp);
- while (!mpg123_head_check(head))
- {
- head <<= 8;
- if (fread(tmp, 1, 1, file) != 1)
- return 0;
- head |= tmp[0];
- }
- if (mpg123_decode_header(&frm, head))
- {
- buf = g_malloc(frm.framesize + 4);
- fseek(file, -4, SEEK_CUR);
- fread(buf, 1, frm.framesize + 4, file);
- xing_header.toc = NULL;
- tpf = mpg123_compute_tpf(&frm);
- if (mpg123_get_xing_header(&xing_header, buf))
- {
- g_free(buf);
- return ((guint) (tpf * xing_header.frames * 1000));
- }
- g_free(buf);
- bpf = mpg123_compute_bpf(&frm);
- fseek(file, 0, SEEK_END);
- len = ftell(file);
- fseek(file, -128, SEEK_END);
- fread(tmp, 1, 3, file);
- if (!strncmp(tmp, "TAG", 3))
- len -= 128;
- return ((guint) ((guint)(len / bpf) * tpf * 1000));
- }
- return 0;
-}
-
-void
-get_song_info (char *filename, char **title_real, int *len_real)
-{
- FILE *file;
-
- (*len_real) = -1;
- (*title_real) = NULL;
-
- if ((file = fopen(filename, "rb")) != NULL) {
- (*len_real) = get_song_time (file);
- (*title_real) = get_song_title (file, filename);
- fclose(file);
- }
-}
-
-static void
-*decode_loop (void *arg)
-{
- gboolean output_opened = FALSE;
- gint disp_count = 0, temp_time;
- gchar *filename = arg;
-
- mpg123_bitrate = 0;
-
- mpg123_pcm_sample = (unsigned char *) g_malloc0(32768);
- mpg123_pcm_point = 0;
- mpg123_filename = filename;
-
- mpg123_read_frame_init();
-
- mpg123_open_stream (filename, -1);
- if (mpg123_info->eof || !mpg123_read_frame(&fr)) {
- mpg123_info->eof = TRUE;
- }
-
- if(!mpg123_info->eof) {
- if (mpg123_cfg.channels == 2) {
- fr.single = -1;
- } else {
- fr.single = 3;
- }
-
- fr.down_sample = mpg123_cfg.downsample;
- fr.down_sample_sblimit = SBLIMIT >> mpg123_cfg.downsample;
- set_mpg123_synth_functions(&fr);
- mpg123_init_layer3 (fr.down_sample_sblimit);
-
- mpg123_info->tpf = mpg123_compute_tpf (&fr);
- xing_header.toc = xing_toc;
- if (mpg123_stream_check_for_xing_header (&fr, &xing_header)) {
- mpg123_info->num_frames = xing_header.frames;
- have_xing_header = TRUE;
- vbr_set = TRUE;
- mpg123_read_frame (&fr);
- }
-
- for(;;) {
- memcpy (&temp_fr,&fr,sizeof(struct frame));
- if (!mpg123_read_frame (&temp_fr)) {
- mpg123_info->eof = TRUE;
- break;
- }
-
- if (fr.lay != temp_fr.lay || fr.sampling_frequency != temp_fr.sampling_frequency ||
- fr.stereo != temp_fr.stereo || fr.lsf != temp_fr.lsf) {
- memcpy(&fr,&temp_fr,sizeof(struct frame));
- } else {
- break;
- }
- }
-
- if(!have_xing_header) {
- mpg123_info->num_frames = mpg123_calc_numframes (&fr);
- }
-
- memcpy (&fr,&temp_fr,sizeof(struct frame));
- mpg123_bitrate = disp_bitrate = tabsel_123[fr.lsf][fr.lay - 1][fr.bitrate_index];
- mpg123_frequency = mpg123_freqs[fr.sampling_frequency];
- mpg123_stereo = fr.stereo;
- mpg123_layer = fr.lay;
- mpg123_lsf = fr.lsf;
- mpg123_mpeg25 = fr.mpeg25;
- mpg123_mode = fr.mode;
-
- mpg123_length = mpg123_info->num_frames * mpg123_info->tpf * 1000;
- if (!mpg123_title) {
- mpg123_title = get_song_title(NULL,filename);
- }
-
- output_opened = TRUE;
- if (!esdout_open (mpg123_cfg.resolution == 16 ? FMT_S16_NE : FMT_U8,
- mpg123_freqs[fr.sampling_frequency] >> mpg123_cfg.downsample,
- mpg123_cfg.channels == 2 ? fr.stereo : 1)) {
- audio_error = TRUE;
- mpg123_info->eof = TRUE;
- }
- }
-
- mpg123_info->first_frame = FALSE;
- while (mpg123_info->going) {
- if (mpg123_info->jump_to_time != -1) {
- if (!have_xing_header) {
- mpg123_stream_jump_to_frame(&fr, (int) (mpg123_info->jump_to_time / mpg123_info->tpf));
- } else {
- mpg123_stream_jump_to_byte(&fr, mpg123_seek_point(xing_toc, xing_header.bytes, ((double) mpg123_info->jump_to_time * 100.0) / ((double) mpg123_info->num_frames * mpg123_info->tpf)));
- }
- esdout_flush (mpg123_info->jump_to_time * 1000);
- mpg123_info->jump_to_time = -1;
- mpg123_info->eof = FALSE;
- }
-
- if (!mpg123_info->eof) {
- if (mpg123_read_frame(&fr) != 0) {
- if(fr.lay != mpg123_layer || fr.lsf != mpg123_lsf) {
- memcpy(&temp_fr,&fr,sizeof(struct frame));
- if(mpg123_read_frame(&temp_fr) != 0) {
- if(fr.lay == temp_fr.lay && fr.lsf == temp_fr.lsf) {
- mpg123_layer = fr.lay;
- mpg123_lsf = fr.lsf;
- memcpy(&fr,&temp_fr,sizeof(struct frame));
- set_mpg123_synth_functions(&fr);
- } else {
- memcpy(&fr,&temp_fr,sizeof(struct frame));
- skip_frames = 2;
- mpg123_info->output_audio = FALSE;
- continue;
- }
- }
- }
-
- if(mpg123_freqs[fr.sampling_frequency] != mpg123_frequency || mpg123_stereo != fr.stereo) {
- memcpy(&temp_fr,&fr,sizeof(struct frame));
- if(mpg123_read_frame(&temp_fr) != 0) {
- if(fr.sampling_frequency == temp_fr.sampling_frequency && temp_fr.stereo == fr.stereo) {
- esdout_free ();
- esdout_free ();
- while(mpg123_info->going && mpg123_info->jump_to_time == -1) {
- usleep (20000);
- }
-
- if(!mpg123_info->going) {
- break;
- }
- temp_time = esdout_get_output_time ();
- esdout_close ();
- mpg123_frequency = mpg123_freqs[fr.sampling_frequency];
- mpg123_stereo = fr.stereo;
-
- if (!esdout_open (mpg123_cfg.resolution == 16 ? FMT_S16_NE : FMT_U8,
- mpg123_freqs[fr.sampling_frequency] >> mpg123_cfg.downsample,
- mpg123_cfg.channels == 2 ? fr.stereo : 1)) {
- audio_error = TRUE;
- mpg123_info->eof = TRUE;
- }
- esdout_flush (temp_time);
- //mpg123_ip.set_info(mpg123_title, mpg123_length, mpg123_bitrate * 1000, mpg123_frequency, mpg123_stereo);
- memcpy(&fr,&temp_fr,sizeof(struct frame));
- set_mpg123_synth_functions(&fr);
- }
- else
- {
- memcpy(&fr,&temp_fr,sizeof(struct frame));
- skip_frames = 2;
- mpg123_info->output_audio = FALSE;
- continue;
- }
- }
- }
-
- if (tabsel_123[fr.lsf][fr.lay - 1][fr.bitrate_index] != mpg123_bitrate) {
- mpg123_bitrate = tabsel_123[fr.lsf][fr.lay - 1][fr.bitrate_index];
- }
-
- if (!disp_count) {
- disp_count = 20;
- if (mpg123_bitrate != disp_bitrate) {
- disp_bitrate = mpg123_bitrate;
- if(!have_xing_header) {
- mpg123_info->num_frames = mpg123_calc_numframes(&fr);
- mpg123_info->tpf = mpg123_compute_tpf(&fr);
- mpg123_length = mpg123_info->num_frames * mpg123_info->tpf * 1000;
- }
- //mpg123_ip.set_info(mpg123_title, mpg123_length, mpg123_bitrate * 1000, mpg123_frequency, mpg123_stereo);
- }
- } else {
- disp_count--;
- }
- play_frame (&fr);
- } else {
- esdout_free ();
- esdout_free ();
- mpg123_info->eof = TRUE;
- usleep(10000);
- }
- } else {
- usleep(10000);
- }
- }
-
- g_free(mpg123_title);
- mpg123_title = NULL;
- mpg123_stream_close();
- if (output_opened && !audio_error) {
- esdout_close ();
- }
-
- g_free (mpg123_pcm_sample);
-
- pthread_exit (NULL);
- return NULL; /* make GCC happy */
-}
-
-void
-mpg123_play_file (const char *filename)
-{
- /* Just to be safe */
- mpg123_stop ();
-
- /* Start playback */
- mpg123_init ();
-
- memset(&fr, 0, sizeof (struct frame));
- memset(&temp_fr, 0, sizeof (struct frame));
-
- mpg123_info = g_malloc0(sizeof (PlayerInfo));
- mpg123_info->going = TRUE;
- mpg123_info->paused = FALSE;
- mpg123_info->first_frame = TRUE;
- mpg123_info->output_audio = TRUE;
- mpg123_info->jump_to_time = -1;
- skip_frames = 0;
- audio_error = FALSE;
- have_xing_header = FALSE;
-
- pthread_create (&decode_thread, NULL, decode_loop, g_strdup (filename));
-}
-
-void
-mpg123_stop (void)
-{
- if (mpg123_info && mpg123_info->going) {
- g_free (mpg123_filename);
- mpg123_filename = NULL;
- mpg123_info->going = FALSE;
- pthread_join (decode_thread, NULL);
- g_free (mpg123_info);
- mpg123_info = NULL;
- }
-}
-
-void
-mpg123_seek (int time)
-{
- mpg123_info->jump_to_time = time;
-
- while (mpg123_info->jump_to_time != -1) {
- usleep(10000);
- }
-}
-
-void
-mpg123_pause (gboolean pause)
-{
- esdout_pause (pause);
-}
-
-int
-get_time (void)
-{
- if (audio_error)
- return -2;
-
- if (!mpg123_info)
- return -1;
-
- if (!mpg123_info->going || mpg123_info->eof) {
- return -1;
- }
-
- return esdout_get_output_time ();
-}
diff --git a/components/music/mpg123.h b/components/music/mpg123.h
deleted file mode 100644
index 329b79a53..000000000
--- a/components/music/mpg123.h
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * mpg123 defines
- * used source: musicout.h from mpegaudio package
- */
-
-#ifndef __MPG123_H__
-#define __MPG123_H__
-
-#include "config.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-#include <math.h>
-
-#include "dxhead.h"
-#include "id3.h"
-
-#define real float
-
-/* #define MAX_NAME_SIZE 81 */
-#define SBLIMIT 32
-#define SCALE_BLOCK 12
-#define SSLIMIT 18
-
-#define MPG_MD_STEREO 0
-#define MPG_MD_JOINT_STEREO 1
-#define MPG_MD_DUAL_CHANNEL 2
-#define MPG_MD_MONO 3
-
-/* Pre Shift fo 16 to 8 bit converter table */
-#define AUSHIFT (3)
-
-struct id3v1tag_t {
- char tag[3]; /* always "TAG": defines ID3v1 tag 128 bytes before EOF */
- char title[30];
- char artist[30];
- char album[30];
- char year[4];
- char comment[28];
- char fill;
- char track;
- unsigned char genre;
-};
-
-struct id3tag_t {
- char title[64];
- char artist[64];
- char album[64];
- char year[5];
- char comment[256];
- char genre[256];
- char track[4];
-};
-
-typedef struct
-{
- gboolean going, paused;
- gint num_frames, eof, jump_to_time, eq_active;
- gint songtime;
- gdouble tpf;
- gfloat eq_mul[576];
- gboolean output_audio;
- gboolean first_frame;
- guint32 filesize; /* Filesize without junk */
-}
-PlayerInfo;
-
-void mpg123_set_eq(int on, float preamp, float *band);
-void mpg123_file_info_box(char *);
-
-extern PlayerInfo *mpg123_info;
-
-struct al_table
-{
- short bits;
- short d;
-};
-
-struct frame
-{
- struct al_table *alloc;
- int (*synth) (real *, int, unsigned char *, int *);
- int (*synth_mono) (real *, unsigned char *, int *);
-#ifdef USE_3DNOW
- void (*dct36)(real *,real *,real *,real *,real *);
-#endif
- int stereo;
- int jsbound;
- int single;
- int II_sblimit;
- int down_sample_sblimit;
- int lsf;
- int mpeg25;
- int down_sample;
- int header_change;
- int lay;
- int (*do_layer) (struct frame * fr);
- int error_protection;
- int bitrate_index;
- int sampling_frequency;
- int padding;
- int extension;
- int mode;
- int mode_ext;
- int copyright;
- int original;
- int emphasis;
- int framesize; /* computed framesize */
-};
-
-void mpg123_configure(void);
-
-typedef struct
-{
- gint resolution;
- gint channels;
- gint downsample;
- gint downsample_custom;
- gint http_buffer_size;
- gint http_prebuffer;
- gboolean use_proxy;
- gchar *proxy_host;
- gint proxy_port;
- gboolean proxy_use_auth;
- gchar *proxy_user, *proxy_pass;
- gboolean save_http_stream;
- gchar *save_http_path;
- gboolean cast_title_streaming;
- gboolean use_udp_channel;
- gchar *id3_format;
- gboolean use_id3, disable_id3v2;
- gboolean detect_by_content;
-}
-MPG123Config;
-
-extern MPG123Config mpg123_cfg;
-
-struct bitstream_info
-{
- int bitindex;
- unsigned char *wordpointer;
-};
-
-extern struct bitstream_info bsi;
-
-/* ------ Declarations from "http.c" ------ */
-
-extern int mpg123_http_open(char *url);
-int mpg123_http_read(gpointer data, gint length);
-void mpg123_http_close(void);
-gchar *mpg123_http_get_title(gchar * url);
-gint mpg123_http_get_icy_br(void);
-
-/* ------ Declarations from "common.c" ------ */
-extern unsigned int mpg123_get1bit(void);
-extern unsigned int mpg123_getbits(int);
-extern unsigned int mpg123_getbits_fast(int);
-
-extern void mpg123_open_stream(char *bs_filenam, int fd);
-extern int mpg123_head_check(unsigned long);
-extern void mpg123_stream_close(void);
-
-extern void mpg123_set_pointer(long);
-
-extern unsigned char *mpg123_pcm_sample;
-extern int mpg123_pcm_point;
-
-struct gr_info_s
-{
- int scfsi;
- unsigned part2_3_length;
- unsigned big_values;
- unsigned scalefac_compress;
- unsigned block_type;
- unsigned mixed_block_flag;
- unsigned table_select[3];
- unsigned subblock_gain[3];
- unsigned maxband[3];
- unsigned maxbandl;
- unsigned maxb;
- unsigned region1start;
- unsigned region2start;
- unsigned preflag;
- unsigned scalefac_scale;
- unsigned count1table_select;
- real *full_gain[3];
- real *pow2gain;
-};
-
-struct III_sideinfo
-{
- unsigned main_data_begin;
- unsigned private_bits;
- struct
- {
- struct gr_info_s gr[2];
- }
- ch[2];
-};
-
-extern void open_stream(char *, int fd);
-extern long mpg123_tell_stream(void);
-extern void mpg123_read_frame_init(void);
-extern int mpg123_read_frame(struct frame *fr);
-extern int mpg123_back_frame(struct frame *fr, int num);
-void mpg123_stream_jump_to_frame(struct frame *fr, int frame);
-void mpg123_stream_jump_to_byte(struct frame *fr, int byte);
-int mpg123_stream_check_for_xing_header(struct frame *fr, XHEADDATA * xhead);
-int mpg123_calc_numframes(struct frame *fr);
-
-extern int mpg123_do_layer3(struct frame *fr);
-extern int mpg123_do_layer2(struct frame *fr);
-extern int mpg123_do_layer1(struct frame *fr);
-
-#ifdef I386_ASSEM
-extern int mpg123_synth_1to1_pent(real *, int, unsigned char *);
-
-#endif
-extern int mpg123_synth_1to1(real *, int, unsigned char *, int *);
-extern int mpg123_synth_1to1_8bit(real *, int, unsigned char *, int *);
-extern int mpg123_synth_1to1_mono(real *, unsigned char *, int *);
-extern int mpg123_synth_1to1_mono2stereo(real *, unsigned char *, int *);
-extern int mpg123_synth_1to1_8bit_mono(real *, unsigned char *, int *);
-extern int mpg123_synth_1to1_8bit_mono2stereo(real *, unsigned char *, int *);
-
-extern int mpg123_synth_2to1(real *, int, unsigned char *, int *);
-extern int mpg123_synth_2to1_8bit(real *, int, unsigned char *, int *);
-extern int mpg123_synth_2to1_mono(real *, unsigned char *, int *);
-extern int mpg123_synth_2to1_mono2stereo(real *, unsigned char *, int *);
-extern int mpg123_synth_2to1_8bit_mono(real *, unsigned char *, int *);
-extern int mpg123_synth_2to1_8bit_mono2stereo(real *, unsigned char *, int *);
-
-extern int mpg123_synth_4to1(real *, int, unsigned char *, int *);
-extern int mpg123_synth_4to1_8bit(real *, int, unsigned char *, int *);
-extern int mpg123_synth_4to1_mono(real *, unsigned char *, int *);
-extern int mpg123_synth_4to1_mono2stereo(real *, unsigned char *, int *);
-extern int mpg123_synth_4to1_8bit_mono(real *, unsigned char *, int *);
-extern int mpg123_synth_4to1_8bit_mono2stereo(real *, unsigned char *, int *);
-
-extern int mpg123_synth_ntom(real *, int, unsigned char *, int *);
-extern int mpg123_synth_ntom_8bit(real *, int, unsigned char *, int *);
-extern int mpg123_synth_ntom_mono(real *, unsigned char *, int *);
-extern int mpg123_synth_ntom_mono2stereo(real *, unsigned char *, int *);
-extern int mpg123_synth_ntom_8bit_mono(real *, unsigned char *, int *);
-extern int mpg123_synth_ntom_8bit_mono2stereo(real *, unsigned char *, int *);
-
-/* 3DNow! optimizations */
-#ifdef USE_3DNOW
-extern int mpg123_getcpuflags(void);
-extern int support_3dnow(void);
-extern void dct36(real *,real *,real *,real *,real *);
-extern void dct36_3dnow(real *,real *,real *,real *,real *);
-extern int mpg123_synth_1to1_3dnow(real *,int,unsigned char *,int *);
-#endif
-
-extern void mpg123_rewindNbits(int bits);
-extern int mpg123_hsstell(void);
-extern void mpg123_set_pointer(long);
-extern void mpg123_huffman_decoder(int, int *);
-extern void mpg123_huffman_count1(int, int *);
-extern int mpg123_get_songlen(struct frame *fr, int no);
-
-extern void mpg123_init_layer3(int);
-extern void mpg123_init_layer2(void);
-extern void mpg123_make_decode_tables(long scale);
-extern void mpg123_make_conv16to8_table(void);
-extern void mpg123_dct64(real *, real *, real *);
-
-extern void mpg123_synth_ntom_set_step(long, long);
-
-int mpg123_decode_header(struct frame *fr, unsigned long newhead);
-double mpg123_compute_bpf(struct frame *fr);
-double mpg123_compute_tpf(struct frame *fr);
-guint mpg123_strip_spaces(char *src, size_t n);
-void mpg123_get_id3v2(id3_t * id3d, struct id3tag_t *tag);
-gchar *mpg123_format_song_title(struct id3tag_t *tag, gchar *filename);
-void mpg123_id3v1_to_id3v2 (struct id3v1tag_t *v1, struct id3tag_t *v2);
-
-
-
-extern unsigned char *mpg123_conv16to8;
-extern long mpg123_freqs[9];
-extern real mpg123_muls[27][64];
-extern real mpg123_decwin[512 + 32];
-extern real *mpg123_pnts[5];
-
-#define GENRE_MAX 0x94
-extern const gchar *mpg123_id3_genres[GENRE_MAX];
-extern int tabsel_123[2][3][16];
-
-
-void get_song_info (char *filename, char **title_real, int *len_real);
-void mpg123_play_file (const char *filename);
-void mpg123_stop (void);
-void mpg123_seek (int time);
-void mpg123_pause (gboolean pause);
-int get_time (void);
-
-#endif
diff --git a/components/music/nautilus-music-view.c b/components/music/nautilus-music-view.c
deleted file mode 100644
index c5e691443..000000000
--- a/components/music/nautilus-music-view.c
+++ /dev/null
@@ -1,2020 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-
-/*
- * Copyright (C) 2000, 2001 Eazel, Inc.
- * Copyright (C) 2002 Anders Carlsson <andersca@gnu.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * by the Free Software Foundation; either version 2 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Authors: Andy Hertzfeld <andy@eazel.com>
- * Anders Carlsson <andersca@gnu.org>
- *
- */
-
-/* music view - presents the contents of the directory as an album of music */
-
-#include <config.h>
-#include "nautilus-music-view.h"
-
-#include "esd-audio.h"
-#include "mp3head.h"
-#include "mpg123.h"
-#include "pixmaps.h"
-#include <eel/eel-accessibility.h>
-#include <eel/eel-background.h>
-#include <eel/eel-background-box.h>
-#include <eel/eel-gdk-extensions.h>
-#include <eel/eel-gdk-pixbuf-extensions.h>
-#include <eel/eel-glib-extensions.h>
-#include <eel/eel-gtk-extensions.h>
-#include <eel/eel-gtk-macros.h>
-#include <eel/eel-preferences.h>
-#include <eel/eel-stock-dialogs.h>
-#include <eel/eel-string.h>
-#include <esd.h>
-#include <fcntl.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
-#include <glib/gtypes.h>
-#include <gtk/gtkadjustment.h>
-#include <gtk/gtkcellrendererpixbuf.h>
-#include <gtk/gtkcellrenderertext.h>
-#include <gtk/gtkfilesel.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkhscale.h>
-#include <gtk/gtkimage.h>
-#include <gtk/gtkliststore.h>
-#include <gtk/gtkmain.h>
-#include <gtk/gtkscrolledwindow.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtktooltips.h>
-#include <gtk/gtktreeselection.h>
-#include <gtk/gtktreeview.h>
-#include <gtk/gtkvbox.h>
-#include <libgnome/gnome-config.h>
-#include <libgnome/gnome-i18n.h>
-#include <libgnomevfs/gnome-vfs-directory.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libnautilus-private/nautilus-directory-background.h>
-#include <libnautilus-private/nautilus-directory-notify.h>
-#include <libnautilus-private/nautilus-file-attributes.h>
-#include <libnautilus-private/nautilus-file-utilities.h>
-#include <libnautilus-private/nautilus-file.h>
-#include <libnautilus-private/nautilus-global-preferences.h>
-#include <libnautilus-private/nautilus-metadata.h>
-#include <libnautilus-private/nautilus-sound.h>
-#include <limits.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#define SCALED_IMAGE_WIDTH 108
-#define SCALED_IMAGE_HEIGHT 108
-
-typedef enum {
- PLAYER_STOPPED,
- PLAYER_PAUSED,
- PLAYER_PLAYING
-} PlayerState;
-
-struct NautilusMusicViewDetails {
- NautilusFile *file;
- GtkWidget *event_box;
-
- int selected_index;
- int status_timeout;
-
- int current_samprate;
- int current_duration;
-
- gboolean slider_dragging;
-
- GtkListStore *list_store;
- GtkWidget *tree_view;
-
- GtkVBox *album_container;
- GtkWidget *scroll_window;
- GtkWidget *album_title;
- GtkWidget *album_image;
- GtkWidget *image_box;
- GtkWidget *dialog;
-
- GtkWidget *control_box;
- GtkWidget *play_control_box;
-
- GtkWidget *song_label;
-
- GtkWidget *playtime;
- GtkWidget *playtime_bar;
- GtkObject *playtime_adjustment;
-
- GtkWidget *previous_track_button;
- GtkWidget *pause_button;
- GtkWidget *stop_button;
- GtkWidget *next_track_button;
- GtkWidget *inactive_play_pixwidget;
- GtkWidget *active_play_pixwidget;
- GtkWidget *inactive_pause_pixwidget;
- GtkWidget *active_pause_pixwidget;
-
- PlayerState player_state;
- PlayerState last_player_state;
-
- guint value_changed_update_handler;
-};
-
-
-/* structure for holding song info */
-typedef struct {
- int track_number;
- int bitrate;
- int track_time;
- int stereo;
- int samprate;
-
- char *title;
- char *artist;
- char *album;
- char *year;
- char *comment;
- char *path_uri;
-} SongInfo;
-
-enum {
- TARGET_URI_LIST,
- TARGET_COLOR,
- TARGET_BGIMAGE,
- TARGET_GNOME_URI_LIST
-};
-
-/* list columns */
-enum {
- TRACK_NUMBER_COLUMN,
- TITLE_COLUMN,
- ARTIST_COLUMN,
- BITRATE_COLUMN,
- TIME_COLUMN,
- SAMPLE_RATE_COLUMN,
- YEAR_COLUMN,
- COMMENT_COLUMN,
- PATH_URI_COLUMN,
- ALBUM_COLUMN,
- NUM_COLUMNS
-};
-
-/* button commands */
-enum {
- PREVIOUS_BUTTON,
- PLAY_BUTTON,
- PAUSE_BUTTON,
- STOP_BUTTON,
- NEXT_BUTTON
-};
-
-static GtkTargetEntry music_dnd_target_table[] = {
- { "text/uri-list", 0, TARGET_URI_LIST },
- { "application/x-color", 0, TARGET_COLOR },
- { "property/bgimage", 0, TARGET_BGIMAGE },
- { "x-special/gnome-icon-list", 0, TARGET_GNOME_URI_LIST }
-};
-
-static void nautilus_music_view_drag_data_received (GtkWidget *widget,
- GdkDragContext *context,
- int x,
- int y,
- GtkSelectionData *selection_data,
- guint info,
- guint time,
- gpointer user_data);
-static void nautilus_music_view_class_init (NautilusMusicViewClass *klass);
-static void nautilus_music_view_init (NautilusMusicView *view);
-static void nautilus_music_view_destroy (BonoboObject *object);
-static void nautilus_music_view_finalize (GObject *object);
-
-static void nautilus_music_view_update (NautilusMusicView *music_view);
-static void music_view_background_appearance_changed_callback (EelBackground *background,
- NautilusMusicView *music_view);
-static void music_view_load_location_callback (NautilusView *view,
- const char *location,
- NautilusMusicView *music_view);
-
-static void selection_changed (GtkTreeSelection *selection,
- NautilusMusicView *music_view);
-static void row_activated_callback (GtkTreeView *tree_view,
- GtkTreePath *path,
- GtkTreeViewColumn *column,
- NautilusMusicView *music_view);
-static void nautilus_music_view_set_album_image (NautilusMusicView *music_view,
- const char *image_path_uri);
-static void image_button_callback (GtkWidget *widget,
- NautilusMusicView *music_view);
-static void go_to_next_track (NautilusMusicView *music_view);
-static void play_current_file (NautilusMusicView *music_view,
- gboolean from_start);
-static void detach_file (NautilusMusicView *music_view);
-static void start_playing_file (NautilusMusicView *music_view,
- const char *file_name);
-static void stop_playing_file (NautilusMusicView *music_view);
-static PlayerState get_player_state (NautilusMusicView *music_view);
-static void set_player_state (NautilusMusicView *music_view,
- PlayerState state);
-
-static void list_reveal_row (GtkTreeView *view,
- int row_index);
-static void slider_changed_callback (GtkWidget *bar,
- NautilusMusicView *music_view);
-
-static void nautilus_music_view_load_uri (NautilusMusicView *view,
- const char *uri);
-
-
-
-EEL_CLASS_BOILERPLATE (NautilusMusicView,
- nautilus_music_view,
- NAUTILUS_TYPE_VIEW)
-
-static void
-nautilus_music_view_class_init (NautilusMusicViewClass *klass)
-{
- GObjectClass *gobject_class;
- BonoboObjectClass *object_class;
-
- gobject_class = G_OBJECT_CLASS (klass);
- object_class = BONOBO_OBJECT_CLASS (klass);
-
- object_class->destroy = nautilus_music_view_destroy;
- gobject_class->finalize = nautilus_music_view_finalize;
-}
-
-
-static void
-track_cell_data_func (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
-{
- int track_number;
- char *str;
-
- gtk_tree_model_get (tree_model,
- iter,
- TRACK_NUMBER_COLUMN, &track_number,
- -1);
-
- /* Don't show the track number if it's lower than 1 */
- if (track_number < 1) {
- str = NULL;
- }
- else {
- str = g_strdup_printf ("%d", track_number);
- }
-
- g_object_set (cell,
- "text", str,
- NULL);
-
- g_free (str);
-}
-
-static void
-bitrate_cell_data_func (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
-{
- int bitrate;
- char *str;
-
- gtk_tree_model_get (tree_model,
- iter,
- BITRATE_COLUMN, &bitrate,
- -1);
-
- if (bitrate <= 0) {
- str = g_strdup (_("Unknown"));
- }
- else {
- str = g_strdup_printf ("%d kbps", bitrate);
- }
-
- g_object_set (cell,
- "text", str,
- NULL);
-
- g_free (str);
-}
-
-static void
-time_cell_data_func (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
-{
- int time;
- int seconds, minutes, remain_seconds;
- char *str;
-
- gtk_tree_model_get (tree_model,
- iter,
- TIME_COLUMN, &time,
- -1);
-
- seconds = time;
- minutes = seconds / 60;
- remain_seconds = seconds - (60 * minutes);
-
- str = g_strdup_printf ("%d:%02d ", minutes, remain_seconds);
-
- g_object_set (cell,
- "text", str,
- NULL);
-
- g_free (str);
-}
-
-static void
-set_up_tree_view (NautilusMusicView *music_view)
-{
- GtkCellRenderer *cell;
- GtkTreeViewColumn *column;
- GtkTreeView *tree_view;
-
- tree_view = GTK_TREE_VIEW (music_view->details->tree_view);
-
- /* The track number column */
- cell = gtk_cell_renderer_text_new ();
- g_object_set (cell, "xalign", 1.0, NULL);
-
- column = gtk_tree_view_column_new ();
- gtk_tree_view_column_set_title (column, _("Track"));
- gtk_tree_view_column_pack_start (column, cell, TRUE);
- gtk_tree_view_column_set_cell_data_func (column, cell,
- track_cell_data_func,
- NULL, NULL);
- gtk_tree_view_column_set_sort_column_id (column, TRACK_NUMBER_COLUMN);
- gtk_tree_view_column_set_resizable (column, TRUE);
- gtk_tree_view_append_column (tree_view, column);
-
- /* The name column */
- cell = gtk_cell_renderer_text_new ();
- column = gtk_tree_view_column_new_with_attributes (_("Title"),
- cell,
- "text", TITLE_COLUMN,
- NULL);
- gtk_tree_view_column_set_sort_column_id (column, TITLE_COLUMN);
- gtk_tree_view_column_set_resizable (column, TRUE);
- gtk_tree_view_append_column (tree_view, column);
-
- /* The artist column */
- cell = gtk_cell_renderer_text_new ();
- column = gtk_tree_view_column_new_with_attributes (_("Artist"),
- cell,
- "text", ARTIST_COLUMN,
- NULL);
- gtk_tree_view_column_set_sort_column_id (column, ARTIST_COLUMN);
- gtk_tree_view_column_set_resizable (column, TRUE);
- gtk_tree_view_append_column (tree_view, column);
-
- /* The bitrate column */
- cell = gtk_cell_renderer_text_new ();
- g_object_set (cell, "xalign", 1.0, NULL);
- column = gtk_tree_view_column_new ();
- gtk_tree_view_column_set_title (column, _("Bit Rate"));
- gtk_tree_view_column_pack_start (column, cell, TRUE);
- gtk_tree_view_column_set_cell_data_func (column, cell,
- bitrate_cell_data_func,
- NULL, NULL);
- gtk_tree_view_column_set_sort_column_id (column, BITRATE_COLUMN);
- gtk_tree_view_column_set_resizable (column, TRUE);
- gtk_tree_view_append_column (tree_view, column);
-
- /* The time column */
- cell = gtk_cell_renderer_text_new ();
- g_object_set (cell, "xalign", 1.0, NULL);
- column = gtk_tree_view_column_new ();
- gtk_tree_view_column_set_title (column, _("Time"));
- gtk_tree_view_column_pack_start (column, cell, TRUE);
- gtk_tree_view_column_set_cell_data_func (column, cell,
- time_cell_data_func,
- NULL, NULL);
- gtk_tree_view_column_set_sort_column_id (column, TIME_COLUMN);
- gtk_tree_view_column_set_resizable (column, TRUE);
- gtk_tree_view_append_column (tree_view, column);
-}
-
-/* initialize ourselves by connecting to the location change signal and allocating our subviews */
-
-static void
-nautilus_music_view_init (NautilusMusicView *music_view)
-{
- GtkWidget *label;
- GtkWidget *button;
-
- music_view->details = g_new0 (NautilusMusicViewDetails, 1);
-
-
- music_view->details->event_box = eel_background_box_new ();
- gtk_widget_show (music_view->details->event_box);
-
- g_signal_connect_object (music_view->details->event_box, "drag_data_received",
- G_CALLBACK (nautilus_music_view_drag_data_received), music_view, 0);
-
- nautilus_view_construct (NAUTILUS_VIEW (music_view),
- music_view->details->event_box);
-
- g_signal_connect_object (music_view, "load_location",
- G_CALLBACK (music_view_load_location_callback), music_view, 0);
-
- g_signal_connect_object (eel_get_widget_background (GTK_WIDGET (music_view->details->event_box)),
- "appearance_changed",
- G_CALLBACK (music_view_background_appearance_changed_callback), music_view, 0);
-
- /* NOTE: we don't show the widgets until the directory has been loaded,
- to avoid showing degenerate widgets during the loading process */
-
- /* allocate a vbox to contain all of the views */
- music_view->details->album_container = GTK_VBOX (gtk_vbox_new (FALSE, 8));
- gtk_widget_show (GTK_WIDGET (music_view->details->album_container));
- gtk_container_set_border_width (GTK_CONTAINER (music_view->details->album_container), 4);
- gtk_container_add (GTK_CONTAINER (music_view->details->event_box), GTK_WIDGET (music_view->details->album_container));
-
- /* allocate a widget for the album title */
- music_view->details->album_title = gtk_label_new ("");
- gtk_widget_show (music_view->details->album_title);
- gtk_box_pack_start (GTK_BOX (music_view->details->album_container), music_view->details->album_title, FALSE, FALSE, 0);
-
- /* Create list model*/
- music_view->details->list_store = gtk_list_store_new (NUM_COLUMNS,
- G_TYPE_INT, /* TRACK_NUMBER_COLUMN */
- G_TYPE_STRING, /* TITLE_COLUMN */
- G_TYPE_STRING, /* ARTIST_COLUMN */
- G_TYPE_INT, /* BITRATE_COLUMN */
- G_TYPE_INT, /* TIME_COLUMN */
- G_TYPE_INT, /* BITRATE_COLUMN */
- G_TYPE_STRING, /* YEAR_COLUMN */
- G_TYPE_STRING, /* COMMENT_COLUMN */
- G_TYPE_STRING, /* PATH_URI_COLUMN */
- G_TYPE_STRING /* ALBUM_COLUMN */);
- music_view->details->tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (music_view->details->list_store));
- g_signal_connect (music_view->details->tree_view,
- "row_activated",
- G_CALLBACK (row_activated_callback),
- music_view);
-
- g_object_unref (music_view->details->list_store);
- set_up_tree_view (music_view);
-
- g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (music_view->details->tree_view)),
- "changed",
- G_CALLBACK (selection_changed),
- music_view);
-
- /* We sort ascending by track number by default */
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (music_view->details->list_store),
- TRACK_NUMBER_COLUMN, GTK_SORT_ASCENDING);
-
- gtk_widget_show (music_view->details->tree_view);
-
- music_view->details->scroll_window = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_show (music_view->details->scroll_window);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (music_view->details->scroll_window),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (music_view->details->scroll_window),
- GTK_SHADOW_ETCHED_IN);
- gtk_container_add (GTK_CONTAINER (music_view->details->scroll_window), music_view->details->tree_view);
-
- gtk_box_pack_start (GTK_BOX (music_view->details->album_container), music_view->details->scroll_window, TRUE, TRUE, 0);
-
- /* make an hbox to hold the optional cover and other controls */
- music_view->details->control_box = gtk_hbox_new (FALSE, 2);
- gtk_widget_show (music_view->details->control_box);
- gtk_box_pack_start (GTK_BOX (music_view->details->album_container), music_view->details->control_box, FALSE, FALSE, 2);
-
- /* make the "set album button" and show it */
- music_view->details->image_box = gtk_vbox_new (0, FALSE);
- gtk_widget_show (music_view->details->image_box);
- button = gtk_button_new ();
- gtk_widget_show (button);
- gtk_box_pack_end (GTK_BOX (music_view->details->image_box), button, FALSE, FALSE, 2);
-
- label = gtk_label_new (_("Set Cover Image"));
- gtk_widget_show (label);
- gtk_container_add (GTK_CONTAINER(button), label);
- gtk_box_pack_end (GTK_BOX(music_view->details->control_box), music_view->details->image_box, FALSE, FALSE, 4);
- g_signal_connect (button, "clicked", G_CALLBACK (image_button_callback), music_view);
-
- /* prepare ourselves to receive dropped objects */
- gtk_drag_dest_set (GTK_WIDGET (music_view->details->event_box),
- GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP,
- music_dnd_target_table, G_N_ELEMENTS (music_dnd_target_table), GDK_ACTION_COPY);
-
-
- music_view->details->player_state = PLAYER_STOPPED;
- music_view->details->last_player_state = PLAYER_STOPPED;
-}
-
-static void
-nautilus_music_view_destroy (BonoboObject *object)
-{
- NautilusMusicView *music_view;
-
- music_view = NAUTILUS_MUSIC_VIEW (object);
-
- /* we'd rather allow the song to keep playing, but it's hard to maintain state */
- /* so we stop things on exit for now, and improve it post 1.0 */
- stop_playing_file (music_view);
-
- /* Free the status timer callback */
- if (music_view->details->status_timeout != 0) {
- gtk_timeout_remove (music_view->details->status_timeout);
- music_view->details->status_timeout = 0;
- }
-
- if (music_view->details->value_changed_update_handler) {
- g_source_remove (music_view->details->value_changed_update_handler);
- music_view->details->value_changed_update_handler = 0;
- }
-
- detach_file (music_view);
-
- EEL_CALL_PARENT (BONOBO_OBJECT_CLASS, destroy, (object));
-}
-
-static void
-nautilus_music_view_finalize (GObject *object)
-{
- NautilusMusicView *music_view;
-
- music_view = NAUTILUS_MUSIC_VIEW (object);
-
- g_free (music_view->details);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static gboolean
-string_non_empty (char *str)
-{
- return (str != NULL && str[0] != '\0');
-}
-
-static void
-get_tree_iter_for_row (NautilusMusicView *music_view, int row, GtkTreeIter *iter)
-{
- GtkTreePath *path;
-
- path = gtk_tree_path_new ();
- gtk_tree_path_append_index (path, row);
- gtk_tree_model_get_iter (GTK_TREE_MODEL (music_view->details->list_store), iter, path);
- gtk_tree_path_free (path);
-}
-
-/* utility to return the text describing a song */
-static char *
-get_song_text (NautilusMusicView *music_view, int row)
-{
- char *artist_album_string;
- char *song_text;
- char *song_title;
- GtkTreeIter iter;
- char *info_title, *info_album, *info_year, *info_artist;
- gint num_rows;
-
- song_text = NULL;
- artist_album_string = NULL;
-
- num_rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (music_view->details->list_store), NULL);
- if (num_rows == 0)
- return g_strdup ("");
-
- get_tree_iter_for_row (music_view, row, &iter);
-
- gtk_tree_model_get (GTK_TREE_MODEL (music_view->details->list_store),
- &iter,
- ARTIST_COLUMN, &info_artist,
- TITLE_COLUMN, &info_title,
- ALBUM_COLUMN, &info_album,
- YEAR_COLUMN, &info_year,
- -1);
-
- if (!string_non_empty (info_title)) {
- song_title = "-";
- } else {
- song_title = info_title;
- }
-
- if (string_non_empty (info_album)) {
- if (string_non_empty (info_artist)) {
- artist_album_string = g_strdup_printf ("%s / %s", info_artist, info_album);
- } else {
- artist_album_string = g_strdup (info_album);
- }
- } else {
- if (string_non_empty (info_artist)) {
- artist_album_string = g_strdup (info_artist);
- }
- }
-
- if (string_non_empty (artist_album_string)) {
- if (string_non_empty (info_year)) {
- song_text = g_strdup_printf ("%s\n%s (%s)", song_title, artist_album_string, info_year);
- } else {
- song_text = g_strdup_printf ("%s\n%s", song_title, artist_album_string);
- }
- } else {
- if (string_non_empty (info_year)) {
- song_text = g_strdup_printf ("%s (%s)\n-", song_title, info_year);
- } else {
- song_text = g_strdup_printf ("%s\n-", song_title);
- }
- }
-
- g_free (artist_album_string);
-
- return song_text;
-}
-
-/* set the song title to the selected one */
-
-static void
-music_view_set_selected_song_title (NautilusMusicView *music_view, int row)
-{
- char *label_text;
- char *temp_str;
- char *escaped_label_text;
-
- music_view->details->selected_index = row;
-
- label_text = get_song_text (music_view, row);
-
- escaped_label_text = g_markup_escape_text (label_text, -1);
- temp_str = g_strdup_printf ("<span size=\"x-large\">%s</span>", escaped_label_text);
- g_free (escaped_label_text);
-
- gtk_label_set_markup (GTK_LABEL(music_view->details->song_label), temp_str);
- g_free (label_text);
- g_free (temp_str);
-}
-
-static void
-row_activated_callback (GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, NautilusMusicView *music_view)
-{
- PlayerState state;
- gboolean is_playing_or_paused;
-
- state = get_player_state (music_view);
- is_playing_or_paused = (state == PLAYER_PLAYING || state == PLAYER_PAUSED);
-
- play_current_file (music_view, FALSE);
-}
-
-/* handle a row being selected in the list view by playing the corresponding song */
-static void
-selection_changed (GtkTreeSelection *selection, NautilusMusicView *music_view)
-{
- gboolean is_playing_or_paused;
- PlayerState state;
- GtkTreePath *path;
- GtkTreeIter iter;
- int row;
- gboolean selected_current_track = FALSE;
-
- state = get_player_state (music_view);
- is_playing_or_paused = (state == PLAYER_PLAYING || state == PLAYER_PAUSED);
-
- if (gtk_tree_selection_get_selected (selection, NULL, &iter)) {
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (music_view->details->list_store), &iter);
- row = gtk_tree_path_get_indices (path)[0];
- gtk_tree_path_free (path);
-
- /* If the track selected is currently playing, we'll let it
- continue. Otherwise we'll stop any track that is playing. */
- if (music_view->details->selected_index == row)
- selected_current_track = TRUE;
-
- music_view_set_selected_song_title (music_view, row);
- }
-
- if (is_playing_or_paused && !selected_current_track) {
- stop_playing_file (music_view);
- }
-}
-
-
-/* utility routine to check if the passed-in uri is an image file */
-static gboolean
-ensure_uri_is_image(const char *uri)
-{
- gboolean is_image;
- GnomeVFSResult result;
- GnomeVFSFileInfo *file_info;
-
- file_info = gnome_vfs_file_info_new ();
- result = gnome_vfs_get_file_info
- (uri, file_info,
- GNOME_VFS_FILE_INFO_GET_MIME_TYPE
- | GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
- /* FIXME: can the code really handle any type of image other
- * than an SVG? Probably not.
- */
- is_image = eel_istr_has_prefix (file_info->mime_type, "image/") && (eel_strcmp (file_info->mime_type, "image/svg") != 0);
- gnome_vfs_file_info_unref (file_info);
- return is_image;
-}
-
-/* callback to handle setting the album cover image */
-static void
-set_album_cover (GtkWidget *widget, gpointer *data)
-{
- char *path_name, *path_uri;
- NautilusMusicView *music_view;
-
- music_view = NAUTILUS_MUSIC_VIEW (data);
-
- /* get the file path from the file selection widget */
- path_name = g_strdup (gtk_file_selection_get_filename (GTK_FILE_SELECTION (music_view->details->dialog)));
- path_uri = gnome_vfs_get_uri_from_local_path (path_name);
-
- /* make sure that it's an image */
- if (!ensure_uri_is_image (path_uri)) {
- char *message = g_strdup_printf
- (_("Sorry, but '%s' is not a usable image file."),
- path_name);
- eel_show_error_dialog (message, _("Not an Image"), NULL);
- g_free (message);
-
- g_free (path_uri);
- g_free (path_name);
- return;
- }
-
- /* set the meta-data */
- nautilus_file_set_metadata (music_view->details->file,
- NAUTILUS_METADATA_KEY_CUSTOM_ICON, NULL, path_uri);
-
- /* set the album image */
- nautilus_music_view_set_album_image (music_view, path_uri);
- g_free (path_uri);
-
- /* tell the world the file changed */
- nautilus_file_changed (music_view->details->file);
-
- /* destroy the file dialog */
- gtk_widget_destroy (music_view->details->dialog);
- music_view->details->dialog = NULL;
-
- g_free (path_name);
-}
-
-/* Callback used when the color selection dialog is destroyed */
-static void
-dialog_destroy (GtkObject *object, gpointer callback_data)
-{
- NAUTILUS_MUSIC_VIEW (callback_data)->details->dialog = NULL;
-}
-
-/* handle the set image button by displaying a file selection dialog */
-static void
-image_button_callback (GtkWidget * widget, NautilusMusicView *music_view)
-{
- if (music_view->details->dialog) {
- gtk_widget_show(music_view->details->dialog);
- if (music_view->details->dialog->window)
- gdk_window_raise(music_view->details->dialog->window);
-
- } else {
- GtkFileSelection *file_dialog;
-
- music_view->details->dialog = gtk_file_selection_new
- (_("Select an image file for the album cover:"));
- file_dialog = GTK_FILE_SELECTION (music_view->details->dialog);
-
- g_signal_connect_object (music_view->details->dialog, "destroy",
- G_CALLBACK (dialog_destroy), music_view, 0);
- g_signal_connect_object (file_dialog->ok_button, "clicked",
- G_CALLBACK (set_album_cover), music_view, 0);
-
- g_signal_connect_object (file_dialog->cancel_button, "clicked",
- G_CALLBACK (gtk_widget_destroy), file_dialog, G_CONNECT_SWAPPED);
-
- gtk_window_set_position (GTK_WINDOW (file_dialog), GTK_WIN_POS_MOUSE);
- gtk_window_set_wmclass (GTK_WINDOW (file_dialog), "file_selector", "Nautilus");
- gtk_widget_show (GTK_WIDGET(file_dialog));
- }
-}
-
-/* here are some utility routines for reading ID3 tags from mp3 files */
-
-/* initialize a songinfo structure */
-static void
-initialize_song_info (SongInfo *info)
-{
- /* Only called after g_new0. */
- info->track_number = -1;
-}
-
-/* deallocate a songinfo structure */
-static void
-song_info_free (SongInfo *info)
-{
- g_free (info->title);
- g_free (info->artist);
- g_free (info->album);
- g_free (info->year);
- g_free (info->comment);
- g_free (info->path_uri);
- g_free (info);
-}
-
-
-/* determine if a file is an mp3 file by looking at the mime type */
-static gboolean
-is_mp3_file (GnomeVFSFileInfo *file_info)
-{
- return eel_istr_has_prefix (file_info->mime_type, "audio/")
- && eel_istr_has_suffix (file_info->mime_type, "mp3");
-}
-
-
-static char *
-filter_out_unset_year (const char *year)
-{
- /* All-zero year should be interpreted as unset year. */
- if (strspn (year, "0 ") == strlen (year)) {
- return g_strdup ("");
- } else {
- return g_strdup (year);
- }
-}
-
-/* read the id3 tag of the file if present */
-static gboolean
-read_id_tag (const char *song_uri, SongInfo *song_info)
-{
- char *path;
- id3_t *id3;
- struct id3v1tag_t id3v1tag;
- struct id3tag_t tag;
- FILE *file;
-
- path = gnome_vfs_get_local_path_from_uri (song_uri);
- if (path == NULL) {
- return FALSE;
- }
-
- file = fopen (path, "rb");
- g_free (path);
-
- if (file == NULL) {
- return FALSE;
- }
-
- /* Try ID3v2 tag first */
- fseek (file, 0, SEEK_SET);
- id3 = id3_open_fp (file, O_RDONLY);
- if (id3 != NULL) {
- mpg123_get_id3v2 (id3, &tag);
- id3_close (id3);
- } else if ((fseek (file, -1 * sizeof (id3v1tag), SEEK_END) == 0) &&
- (fread (&id3v1tag, 1, sizeof (id3v1tag), file) == sizeof (id3v1tag)) &&
- (strncmp (id3v1tag.tag, "TAG", 3) == 0)) {
- /* Try reading ID3v1 tag. */
- mpg123_id3v1_to_id3v2 (&id3v1tag, &tag);
- } else {
- /* Failed to read any sort of tag */
- fclose (file);
- return FALSE;
- }
-
- /* Copy data from tag into our info struct */
- if (!g_utf8_validate (tag.title, -1, NULL)) {
- song_info->title = g_convert (tag.title, -1, "UTF8", "ISO-8859-1", NULL, NULL, NULL);
- } else {
- song_info->title = g_strdup (tag.title);
- }
- if (!g_utf8_validate (tag.album, -1, NULL)) {
- song_info->album = g_convert (tag.album, -1, "UTF8", "ISO-8859-1", NULL, NULL, NULL);
- } else {
- song_info->album = g_strdup (tag.album);
- }
- if (!g_utf8_validate (tag.artist, -1, NULL)) {
- song_info->artist = g_convert (tag.artist, -1, "UTF8", "ISO-8859-1", NULL, NULL, NULL);
- } else {
- song_info->artist = g_strdup (tag.artist);
- }
- if (!g_utf8_validate (tag.comment, -1, NULL)) {
- song_info->comment = g_convert (tag.comment, -1, "UTF8", "ISO-8859-1", NULL, NULL, NULL);
- } else {
- song_info->comment = g_strdup (tag.comment);
- }
-
- song_info->year = filter_out_unset_year (tag.year);
- song_info->track_number = atoi (tag.track);
-
- /* Clean up */
- fclose (file);
- return TRUE;
-}
-
-
-/* fetch_play_time takes the pathname to a file and returns the play time in seconds */
-static int
-fetch_play_time (GnomeVFSFileInfo *file_info, int bitrate)
-{
- if ((file_info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE) == 0) {
- return 0;
- }
-
- /* Avoid divide by zero. */
- return bitrate == 0 ? 0 : file_info->size / (125 * bitrate);
-}
-
-/* extract a track number from the file name
- return -1 if there wasn't any */
-static int
-extract_number(const char *name_str)
-{
- const char *temp_str;
- gboolean found_digit;
- int accumulator;
-
- found_digit = FALSE;
- accumulator = 0;
- if (g_ascii_isdigit (*name_str)) {
- temp_str = name_str;
- } else if (strchr(name_str, '(') != NULL) {
- temp_str = strchr(name_str, '(') + 1;
- } else {
- return -1;
- }
-
- while (g_ascii_isdigit (*temp_str)) {
- found_digit = TRUE;
- accumulator = (10 * accumulator) + *temp_str - 48;
- temp_str += 1;
- }
-
- if (found_digit) {
- return accumulator;
- }
-
- return -1;
-}
-
-/* allocate a return a song info record, from an mp3 tag if present, or from intrinsic info */
-static SongInfo *
-fetch_song_info (const char *song_uri, GnomeVFSFileInfo *file_info, int file_order)
-{
- gboolean has_info = FALSE;
- SongInfo *info;
- guchar buffer[8192];
- GnomeVFSHandle *mp3_file;
- GnomeVFSResult result;
- GnomeVFSFileSize length_read;
- ID3V2Header v2header;
- long header_size;
- NautilusFile *file;
-
- if (!is_mp3_file (file_info)) {
- return NULL;
- }
-
- info = g_new0 (SongInfo, 1);
- initialize_song_info (info);
-
- has_info = read_id_tag (song_uri, info);
-
- /* if we couldn't get a track number, see if we can pull one from
- the file name */
- if (info->track_number <= 0) {
- info->track_number = extract_number(file_info->name);
- }
-
- /* there was no id3 tag, so set up the info heuristically from the file name and file order */
- if (!has_info) {
- file = nautilus_file_get (song_uri);
- info->title = nautilus_file_get_display_name (file);
- nautilus_file_unref (file);
- }
-
- result = gnome_vfs_open (&mp3_file, song_uri, GNOME_VFS_OPEN_READ);
- if (result == GNOME_VFS_OK) {
- result = gnome_vfs_read (mp3_file, buffer, sizeof (buffer), &length_read);
- if ((result == GNOME_VFS_OK) && (length_read > 512)) {
- /* Make sure ID3v2 tag is not at start of file */
- if ( buffer[0] == 'I' && buffer[1] == 'D' && buffer[2] == '3' ) {
- /* Read in header and determine size */
- gnome_vfs_seek (mp3_file, GNOME_VFS_SEEK_START, 0);
- result = gnome_vfs_read (mp3_file, &v2header, sizeof (ID3V2Header), &length_read);
- if (result != GNOME_VFS_OK) {
- return info;
- }
-
- header_size = ((long) v2header.size[3] |
- ((long) v2header.size[2] << (8 - 1)) |
- ((long) v2header.size[1] << (16 - 2)) |
- ((long) v2header.size[0] << (24 - 3)))
- + sizeof (ID3V2Header);
-
- /* Seek past the tag to the mp3 data */
- gnome_vfs_seek (mp3_file, GNOME_VFS_SEEK_START, header_size);
- result = gnome_vfs_read (mp3_file, buffer, sizeof (buffer), &length_read);
- if (result != GNOME_VFS_OK) {
- return info;
- }
- }
-
- info->bitrate = get_bitrate (buffer, length_read);
- info->samprate = get_samprate (buffer, length_read);
- info->stereo = get_stereo (buffer, length_read);
- info->track_time = fetch_play_time (file_info, info->bitrate);
- }
- gnome_vfs_close (mp3_file);
- }
-
- return info;
-}
-
-/* utility routine to determine most common attribute in song list. The passed in boolean selects
- album or artist. Return NULL if they are heterogenous */
-static char *
-determine_attribute (GList *song_list, gboolean is_artist)
-{
- SongInfo *info;
- GList *p;
- char *current_attribute, *this_attribute;
-
- current_attribute = NULL;
-
- for (p = song_list; p != NULL; p = p->next) {
- info = (SongInfo *) p->data;
- this_attribute = is_artist ? info->artist : info->album;
-
- if (this_attribute && eel_strcmp (this_attribute, current_attribute)) {
- if (current_attribute == NULL) {
- current_attribute = g_strdup (this_attribute);
- } else {
- g_free (current_attribute);
- return NULL;
- }
-
- }
- }
- return current_attribute;
-}
-
-/* update the status feedback of the play controls */
-static void
-update_play_controls_status (NautilusMusicView *music_view, PlayerState state)
-{
- if (state == PLAYER_PLAYING) {
- gtk_widget_show (music_view->details->active_play_pixwidget);
- gtk_widget_hide (music_view->details->inactive_play_pixwidget);
- //gtk_widget_set_sensitive (music_view->details->pause_button, TRUE);
- } else {
- gtk_widget_hide (music_view->details->active_play_pixwidget);
- gtk_widget_show (music_view->details->inactive_play_pixwidget);
- }
-
- if (state == PLAYER_PAUSED) {
- gtk_widget_show (music_view->details->active_pause_pixwidget);
- gtk_widget_hide (music_view->details->inactive_pause_pixwidget);
- //gtk_widget_set_sensitive (music_view->details->pause_button, FALSE);
- } else {
- gtk_widget_hide (music_view->details->active_pause_pixwidget);
- gtk_widget_show (music_view->details->inactive_pause_pixwidget);
- }
-}
-
-static void
-set_adjustment_value (NautilusMusicView *music_view,
- gdouble value)
-{
- g_signal_handlers_block_by_func (G_OBJECT (music_view->details->playtime_bar),
- slider_changed_callback,
- music_view);
- gtk_adjustment_set_value (GTK_ADJUSTMENT (music_view->details->playtime_adjustment),
- value);
- g_signal_handlers_unblock_by_func (G_OBJECT (music_view->details->playtime_bar),
- slider_changed_callback,
- music_view);
-}
-
-/* utility to reset the playtime to the inactive state */
-static void
-reset_playtime (NautilusMusicView *music_view)
-{
- set_adjustment_value (music_view, 0.0);
- gtk_range_set_adjustment (GTK_RANGE (music_view->details->playtime_bar),
- GTK_ADJUSTMENT (music_view->details->playtime_adjustment));
- gtk_widget_set_sensitive (music_view->details->playtime_bar, FALSE);
- gtk_label_set_markup (GTK_LABEL (music_view->details->playtime), "<span size=\"x-large\">--:--</span>");
-}
-
-/* status display timer task */
-static int
-play_status_display (NautilusMusicView *music_view)
-{
- int minutes, seconds;
- float percentage;
- char *play_time_str;
- int current_time;
- gboolean is_playing_or_paused;
- int samps_per_frame;
- PlayerState status;
-
- status = get_player_state (music_view);
- is_playing_or_paused = (status == PLAYER_PLAYING) || (status == PLAYER_PAUSED);
-
- /* Check if we've reached the end of the track. If we have, move to
- the next track. */
- if (status == PLAYER_PLAYING) {
- if (!esdout_playing ()) {
- stop_playing_file (music_view);
- go_to_next_track (music_view);
- return FALSE;
- }
- }
-
- if (music_view->details->last_player_state != status) {
- music_view->details->last_player_state = status;
- update_play_controls_status (music_view, status);
- }
-
- if (is_playing_or_paused) {
- if (!music_view->details->slider_dragging) {
- samps_per_frame = (music_view->details->current_samprate >= 32000) ? 1152 : 576;
-
- if (music_view->details->current_duration != 0) {
- current_time = esdout_get_output_time ();
- seconds = current_time / 1000;
- minutes = seconds / 60;
- seconds = seconds % 60;
-
- play_time_str = g_strdup_printf ("<span size=\"x-large\">%02d:%02d</span>", minutes, seconds);
-
- percentage = (float) ((float)current_time / (float)music_view->details->current_duration) * 100.0;
-
- set_adjustment_value (music_view, percentage);
- gtk_range_set_adjustment (GTK_RANGE (music_view->details->playtime_bar),
- GTK_ADJUSTMENT(music_view->details->playtime_adjustment));
-
- if (!music_view->details->slider_dragging) {
- gtk_label_set_markup (GTK_LABEL(music_view->details->playtime),
- play_time_str);
- }
- g_free (play_time_str);
- }
- }
- } else {
- reset_playtime (music_view);
- }
-
- return is_playing_or_paused;
-}
-
-static void
-list_reveal_row (GtkTreeView *view, int row_index)
-{
- GtkTreePath *path;
- GtkTreeModel *model;
-
- model = gtk_tree_view_get_model (view);
- path = gtk_tree_path_new ();
- gtk_tree_path_append_index (path, row_index);
-
- gtk_tree_view_scroll_to_cell (view, path, NULL,
- TRUE, 0.5, 0.5);
-}
-
-/* track incrementing routines */
-static void
-play_current_file (NautilusMusicView *music_view, gboolean from_start)
-{
- char *song_filename, *title;
- GnomeVFSResult result;
- GnomeVFSFileInfo file_info;
- int length, num_rows;
- char *path_uri;
- GtkTreeIter iter;
- gboolean enable_esd = FALSE;
- GConfClient *client;
-
- /* If there are no tracks in the list, just return. */
- num_rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (music_view->details->list_store), NULL);
- if (num_rows == 0)
- return;
-
- /* Check gconf sound preference */
- client = gconf_client_get_default ();
- enable_esd = gconf_client_get_bool (client, "/desktop/gnome/sound/enable_esd", NULL);
- g_object_unref (client);
-
- if (!enable_esd) {
- eel_show_error_dialog (_("Sorry, but the music view is unable to play back sound right now. "
- "This is because the Enable sound server startup setting "
- "in the Sound section of the Control Center is turned off."),
- _("Unable to Play File"),
- //GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (&music_view->details->event_box->parent))));
- NULL);
- return;
-
- }
-
- if (!esdout_can_play ()) {
- eel_show_error_dialog (_("Sorry, but the music view is unable to play back sound right now. "
- "Either another program is using or blocking the sound card, "
- "or your sound card is not configured properly. Try quitting any "
- "applications that may be blocking use of the sound card."),
- _("Unable to Play File"),
- //GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (&music_view->details->event_box->parent))));
- NULL);
- return;
- }
-
- /* Scroll the list to display the current new selection */
- list_reveal_row (GTK_TREE_VIEW (music_view->details->tree_view), music_view->details->selected_index);
- get_tree_iter_for_row (music_view, music_view->details->selected_index, &iter);
-
- gtk_tree_model_get (GTK_TREE_MODEL (music_view->details->list_store),
- &iter,
- PATH_URI_COLUMN, &path_uri,
- -1);
-
- /* Make the song selected */
- gtk_tree_selection_select_iter (gtk_tree_view_get_selection (GTK_TREE_VIEW (music_view->details->tree_view)),
- &iter);
-
- song_filename = gnome_vfs_get_local_path_from_uri (path_uri);
-
- /* for now, we can only play local files, so apologize to the user and give up */
- if (song_filename == NULL) {
- eel_show_error_dialog
- ( _("Sorry, but the music view can't play non-local files yet."),
- _("Can't Play Remote Files"),
- NULL);
- return;
- }
-
- /* set up the current duration so we can give progress feedback */
- get_song_info (song_filename, &title, &length);
- music_view->details->current_duration = length;
- g_free (title);
-
- result = gnome_vfs_get_file_info (path_uri, &file_info, GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
- if (result != GNOME_VFS_OK) {
- /* File must be unavailable for some reason. Let's yank it from the list */
- gtk_list_store_remove (music_view->details->list_store, &iter);
- g_free (song_filename);
- music_view->details->selected_index -= 1;
- go_to_next_track (music_view);
- return;
- }
-
- gtk_widget_set_sensitive (music_view->details->playtime_bar, TRUE);
-
- if (music_view->details->status_timeout != 0) {
- gtk_timeout_remove (music_view->details->status_timeout);
- music_view->details->status_timeout = 0;
- }
-
- music_view->details->status_timeout = gtk_timeout_add (900, (GtkFunction) play_status_display, music_view);
-
- start_playing_file (music_view, song_filename);
- g_free (song_filename);
-}
-
-
-static void
-go_to_next_track (NautilusMusicView *music_view)
-{
- int num_rows;
-
- mpg123_stop ();
-
- num_rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (music_view->details->list_store), NULL);
-
- if ((music_view->details->selected_index + 1) < num_rows) {
- music_view->details->selected_index += 1;
- play_current_file (music_view, TRUE);
- } else {
- update_play_controls_status (music_view, get_player_state (music_view));
- reset_playtime (music_view);
- }
-}
-
-static void
-go_to_previous_track (NautilusMusicView *music_view)
-{
- /* if we're in the first 3 seconds of the song, go to the previous one, otherwise go to the beginning of this track */
- if ((esdout_get_output_time () < 3000) && (music_view->details->selected_index > 0)) {
- music_view->details->selected_index -= 1;
- }
-
- mpg123_stop ();
- play_current_file (music_view, TRUE);
-}
-
-
-/* callback for the play control semantics */
-
-/* callback for buttons */
-static void
-play_button_callback (GtkWidget *widget, NautilusMusicView *music_view)
-{
- if (get_player_state (music_view) == PLAYER_PLAYING) {
- return;
- }
-
- if (get_player_state (music_view) == PLAYER_PAUSED) {
- set_player_state (music_view, PLAYER_PLAYING);
- mpg123_pause (FALSE);
- } else {
- play_current_file (music_view, FALSE);
- }
-}
-
-static void
-stop_button_callback (GtkWidget *widget, NautilusMusicView *music_view)
-{
- stop_playing_file (music_view);
-}
-
-static void
-pause_button_callback (GtkWidget *widget, NautilusMusicView *music_view)
-{
- PlayerState state;
- state = get_player_state (music_view);
-
- if (state == PLAYER_PLAYING) {
- set_player_state (music_view, PLAYER_PAUSED);
- mpg123_pause (TRUE);
- } else if (state == PLAYER_PAUSED) {
- set_player_state (music_view, PLAYER_PLAYING);
- mpg123_pause (FALSE);
- }
-}
-
-static void
-prev_button_callback (GtkWidget *widget, NautilusMusicView *music_view)
-{
- go_to_previous_track (music_view);
-}
-
-static void
-next_button_callback (GtkWidget *widget, NautilusMusicView *music_view)
-{
- go_to_next_track (music_view);
-}
-
-/* here are the callbacks that handle seeking within a song by dragging the progress bar.
- "Mouse down" sets the slider_dragging boolean, "motion_notify" updates the label on the left, while
- "mouse up" actually moves the frame index. */
-
-/* handle slider button press */
-static int
-slider_press_callback (GtkWidget *bar, GdkEvent *event, NautilusMusicView *music_view)
-{
- music_view->details->slider_dragging = TRUE;
- return FALSE;
-}
-
-/* handle mouse motion by updating the time, but not actually seeking until the user lets go */
-static int
-slider_moved_callback (GtkWidget *bar, GdkEvent *event, NautilusMusicView *music_view)
-{
- GtkAdjustment *adjustment;
- char *temp_str;
- int time, seconds, minutes;
- float multiplier;
-
- if (music_view->details->slider_dragging) {
- adjustment = gtk_range_get_adjustment (GTK_RANGE (bar));
-
- /* don't attempt this if any of the values are zero */
- if (music_view->details->current_duration == 0) {
- return FALSE;
- }
-
- multiplier = adjustment->value / 100.0;
- time = (int) (multiplier * (float)music_view->details->current_duration);
-
- seconds = time / 1000;
- minutes = seconds / 60;
- seconds = seconds % 60;
-
- temp_str = g_strdup_printf ("<span size=\"x-large\">%02d:%02d</span>", minutes, seconds);
-
- gtk_label_set_markup (GTK_LABEL(music_view->details->playtime), temp_str);
- }
- return FALSE;
-}
-
-/* callback for slider button release - seek to desired location */
-static int
-slider_release_callback (GtkWidget *bar, GdkEvent *event, NautilusMusicView *music_view)
-{
- GtkAdjustment *adjustment;
- float multiplier;
- int time;
-
- if (music_view->details->slider_dragging) {
- adjustment = gtk_range_get_adjustment (GTK_RANGE (bar));
-
- if (music_view->details->current_duration == 0) {
- music_view->details->slider_dragging = FALSE;
- return FALSE;
- }
-
- /* Seek to time */
- multiplier = adjustment->value / 100.0;
- time = (int) (multiplier * (float)music_view->details->current_duration);
-
- mpg123_seek (time / 1000);
- }
- music_view->details->slider_dragging = FALSE;
-
- return FALSE;
-}
-
-static gboolean
-changed_idle_callback (gpointer data)
-{
- float multiplier;
- int time;
- NautilusMusicView *music_view;
-
- music_view = NAUTILUS_MUSIC_VIEW (data);
-
- multiplier = GTK_ADJUSTMENT (music_view->details->playtime_adjustment)->value / 100.0;
- time = (int) (multiplier * (float)music_view->details->current_duration);
- mpg123_seek (time / 1000);
-
- music_view->details->slider_dragging = FALSE;
- music_view->details->value_changed_update_handler = 0;
-
- return FALSE;
-}
-
-static void
-slider_changed_callback (GtkWidget *bar,
- NautilusMusicView *music_view)
-{
- if (!music_view->details->slider_dragging && !music_view->details->value_changed_update_handler) {
- music_view->details->slider_dragging = TRUE;
- music_view->details->value_changed_update_handler =
- g_idle_add (changed_idle_callback, music_view);
- }
-}
-
-/* create a button with an xpm label */
-static GtkWidget *
-xpm_label_box (NautilusMusicView *music_view, char * xpm_data[])
-{
- GdkPixbuf *pixbuf;
- GtkWidget *pix_widget;
- GtkWidget *box;
- GtkStyle *style;
-
- box = gtk_hbox_new (FALSE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (box), 2);
- style = gtk_widget_get_style (GTK_WIDGET (music_view->details->event_box));
-
- pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **)xpm_data);
-
- pix_widget = gtk_image_new_from_pixbuf (pixbuf);
- gtk_box_pack_start (GTK_BOX (box), pix_widget, TRUE, FALSE, 3);
- gtk_widget_show (pix_widget);
-
- g_object_unref (pixbuf);
-
- return box;
-}
-
-/* creates a button with 2 internal pixwidgets, with only one visible at a time */
-
-static GtkWidget *
-xpm_dual_label_box (NautilusMusicView *music_view, char * xpm_data[],
- char *alt_xpm_data[],
- GtkWidget **main_pixwidget, GtkWidget **alt_pixwidget )
-{
- GtkWidget *box;
- GtkStyle *style;
- GdkPixbuf *pixbuf;
-
-
- box = gtk_hbox_new (FALSE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (box), 2);
-
- style = gtk_widget_get_style (GTK_WIDGET (music_view->details->event_box));
-
- /* create the main pixwidget */
- pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **)xpm_data);
- *main_pixwidget = gtk_image_new_from_pixbuf (pixbuf);
- g_object_unref (pixbuf);
-
- gtk_box_pack_start (GTK_BOX (box), *main_pixwidget, TRUE, FALSE, 3);
- gtk_widget_show (*main_pixwidget);
-
- /* create the alternative pixwidget */
- pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **)alt_xpm_data);
- *alt_pixwidget = gtk_image_new_from_pixbuf (pixbuf);
- g_object_unref (pixbuf);
-
- gtk_box_pack_start (GTK_BOX (box), *alt_pixwidget, TRUE, FALSE, 3);
- gtk_widget_hide (*alt_pixwidget);
-
- return box;
-}
-
-/* add the play controls */
-
-static void
-add_play_controls (NautilusMusicView *music_view)
-{
- GtkWidget *box;
- GtkWidget *vbox, *hbox;
- GtkWidget *button;
- GtkTooltips *tooltips;
-
- tooltips = gtk_tooltips_new ();
-
- /* Create main vbox */
- vbox = gtk_vbox_new (0, 0);
- gtk_box_pack_start (GTK_BOX (music_view->details->control_box), vbox, FALSE, FALSE, 6);
- gtk_widget_show (vbox);
- music_view->details->play_control_box = vbox;
-
-
- /* Pack the items into the box in reverse order so that the controls are always
- * at the bottom regardless of the size of the album image.
- */
-
- /* hbox to hold slider and song progress time */
- hbox = gtk_hbox_new (0, 0);
- gtk_box_pack_end (GTK_BOX (vbox), hbox, FALSE, FALSE, 7);
- gtk_widget_show (hbox);
-
- /* progress bar */
- music_view->details->playtime_adjustment = gtk_adjustment_new (0, 0, 101, 1, 5, 1);
- music_view->details->playtime_bar = gtk_hscale_new (GTK_ADJUSTMENT (music_view->details->playtime_adjustment));
-
- g_signal_connect_object (music_view->details->playtime_bar, "button_press_event",
- G_CALLBACK (slider_press_callback), music_view, 0);
- g_signal_connect_object (music_view->details->playtime_bar, "button_release_event",
- G_CALLBACK (slider_release_callback), music_view, 0);
- g_signal_connect_object (music_view->details->playtime_bar, "motion_notify_event",
- G_CALLBACK (slider_moved_callback), music_view, 0);
- g_signal_connect_object (music_view->details->playtime_bar, "value_changed",
- G_CALLBACK (slider_changed_callback), music_view, 0);
-
- gtk_tooltips_set_tip (GTK_TOOLTIPS (tooltips), music_view->details->playtime_bar,
- _("Drag to seek within track"), NULL);
- gtk_scale_set_draw_value (GTK_SCALE (music_view->details->playtime_bar), 0);
- gtk_widget_show (music_view->details->playtime_bar);
- gtk_widget_set_sensitive (music_view->details->playtime_bar, FALSE);
- gtk_box_pack_start (GTK_BOX (hbox), music_view->details->playtime_bar, FALSE, FALSE, 4);
- gtk_widget_set_size_request (music_view->details->playtime_bar, 150, -1);
- gtk_widget_show (music_view->details->playtime_bar);
-
- /* playtime label */
- music_view->details->playtime = gtk_label_new ("");
- gtk_label_set_markup (GTK_LABEL (music_view->details->playtime), "<span size=\"x-large\">--:--</span>");
-
- gtk_label_set_justify (GTK_LABEL (music_view->details->playtime), GTK_JUSTIFY_LEFT);
-
- gtk_misc_set_alignment (GTK_MISC (music_view->details->playtime), 0.0, 0.0);
- gtk_widget_show (music_view->details->playtime);
- gtk_box_pack_start (GTK_BOX (hbox), music_view->details->playtime, FALSE, FALSE, 0);
-
- /* Buttons */
- hbox = gtk_hbox_new (0, 0);
- gtk_box_pack_end (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
- gtk_widget_show (hbox);
-
- /* previous track button */
- box = xpm_label_box (music_view, prev_xpm);
- gtk_widget_show (box);
- music_view->details->previous_track_button = gtk_button_new ();
- gtk_tooltips_set_tip (GTK_TOOLTIPS (tooltips), music_view->details->previous_track_button, _("Previous"), NULL);
- gtk_container_add (GTK_CONTAINER (music_view->details->previous_track_button), box);
- g_signal_connect_object (music_view->details->previous_track_button, "clicked",
- G_CALLBACK (prev_button_callback), music_view, 0);
- gtk_widget_set_sensitive (music_view->details->previous_track_button, TRUE);
- gtk_button_set_relief (GTK_BUTTON (music_view->details->previous_track_button), GTK_RELIEF_NORMAL);
- gtk_box_pack_start (GTK_BOX (hbox), music_view->details->previous_track_button, FALSE, FALSE, 0);
- gtk_widget_show (music_view->details->previous_track_button);
-
- /* play button */
- box = xpm_dual_label_box (music_view, play_xpm, play_green_xpm,
- &music_view->details->inactive_play_pixwidget,
- &music_view->details->active_play_pixwidget);
- gtk_widget_show (box);
- button = gtk_button_new ();
- gtk_tooltips_set_tip (GTK_TOOLTIPS (tooltips), button, _("Play"), NULL);
- gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NORMAL);
- gtk_container_add (GTK_CONTAINER (button), box);
- gtk_widget_set_sensitive (button, TRUE);
- g_signal_connect_object (button, "clicked", G_CALLBACK (play_button_callback), music_view, 0);
- gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
- gtk_widget_show (button);
-
- /* pause button */
- box = xpm_dual_label_box (music_view, pause_xpm, pause_green_xpm,
- &music_view->details->inactive_pause_pixwidget,
- &music_view->details->active_pause_pixwidget);
- gtk_widget_show (box);
- music_view->details->pause_button = gtk_button_new ();
- gtk_tooltips_set_tip (GTK_TOOLTIPS (tooltips), music_view->details->pause_button, _("Pause"), NULL);
- gtk_button_set_relief (GTK_BUTTON (music_view->details->pause_button), GTK_RELIEF_NORMAL);
- gtk_container_add (GTK_CONTAINER (music_view->details->pause_button), box);
- gtk_widget_set_sensitive (music_view->details->pause_button, TRUE);
-
- g_signal_connect_object (music_view->details->pause_button, "clicked",
- G_CALLBACK (pause_button_callback), music_view, 0);
- gtk_box_pack_start (GTK_BOX (hbox), music_view->details->pause_button, FALSE, FALSE, 0);
- gtk_widget_show (music_view->details->pause_button);
-
- /* stop button */
- box = xpm_label_box (music_view, stop_xpm);
- gtk_widget_show (box);
- music_view->details->stop_button = gtk_button_new ();
- gtk_tooltips_set_tip (GTK_TOOLTIPS (tooltips), music_view->details->stop_button, _("Stop"), NULL);
- gtk_button_set_relief (GTK_BUTTON (music_view->details->stop_button), GTK_RELIEF_NORMAL);
- gtk_container_add (GTK_CONTAINER (music_view->details->stop_button), box);
- gtk_widget_set_sensitive (music_view->details->stop_button, TRUE);
-
- g_signal_connect_object (music_view->details->stop_button, "clicked",
- G_CALLBACK (stop_button_callback), music_view, 0);
- gtk_box_pack_start (GTK_BOX (hbox), music_view->details->stop_button, FALSE, FALSE, 0);
- gtk_widget_show (music_view->details->stop_button);
-
- /* next button */
- box = xpm_label_box (music_view, next_xpm);
- gtk_widget_show (box);
- music_view->details->next_track_button = gtk_button_new();
- gtk_tooltips_set_tip (GTK_TOOLTIPS (tooltips), music_view->details->next_track_button, _("Next"), NULL);
- gtk_button_set_relief (GTK_BUTTON (music_view->details->next_track_button), GTK_RELIEF_NORMAL);
- gtk_container_add (GTK_CONTAINER (music_view->details->next_track_button), box);
- gtk_widget_set_sensitive (music_view->details->next_track_button, TRUE);
-
- g_signal_connect_object (music_view->details->next_track_button, "clicked",
- G_CALLBACK (next_button_callback), music_view, 0);
- gtk_box_pack_start (GTK_BOX (hbox), music_view->details->next_track_button, FALSE, FALSE, 0);
- gtk_widget_show (music_view->details->next_track_button);
-
- /* Song title label */
- music_view->details->song_label = gtk_label_new ("");
- gtk_label_set_justify (GTK_LABEL (music_view->details->song_label), GTK_JUSTIFY_LEFT);
- gtk_box_pack_end (GTK_BOX (vbox), music_view->details->song_label, FALSE, FALSE, 2);
- gtk_widget_show (music_view->details->song_label);
-}
-
-/* set the album image, or hide it if none */
-static void
-nautilus_music_view_set_album_image (NautilusMusicView *music_view, const char *image_path_uri)
-{
- char* image_path;
- GdkPixbuf *pixbuf;
- GdkPixbuf *scaled_pixbuf;
-
- if (image_path_uri != NULL) {
- image_path = gnome_vfs_get_local_path_from_uri (image_path_uri);
- pixbuf = gdk_pixbuf_new_from_file (image_path, NULL);
-
- if (pixbuf != NULL) {
- scaled_pixbuf = eel_gdk_pixbuf_scale_down_to_fit (pixbuf, SCALED_IMAGE_WIDTH, SCALED_IMAGE_HEIGHT);
- g_object_unref (pixbuf);
-
- if (music_view->details->album_image == NULL) {
- music_view->details->album_image = gtk_image_new_from_pixbuf (scaled_pixbuf);
- gtk_box_pack_start (GTK_BOX (music_view->details->image_box),
- music_view->details->album_image, FALSE, FALSE, 2);
- eel_accessibility_set_name (music_view->details->album_image,
- _("cover image"));
- } else {
- gtk_image_set_from_pixbuf (GTK_IMAGE (music_view->details->album_image), scaled_pixbuf);
- }
-
- g_object_unref (scaled_pixbuf);
-
- gtk_widget_show (music_view->details->album_image);
-
- g_free (image_path);
- }
- } else if (music_view->details->album_image != NULL) {
- gtk_widget_hide (music_view->details->album_image);
- }
-}
-
-/* handle callback that's invoked when file metadata is available */
-static void
-metadata_callback (NautilusFile *file, gpointer callback_data)
-{
- char *album_image_path;
- NautilusMusicView *music_view;
-
- music_view = NAUTILUS_MUSIC_VIEW (callback_data);
-
- album_image_path = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_CUSTOM_ICON, NULL);
- if (album_image_path != NULL) {
- nautilus_music_view_set_album_image (music_view, album_image_path);
- g_free (album_image_path);
- }
-}
-
-
-/* here's where we do most of the real work of populating the view with info from the new uri */
-static void
-nautilus_music_view_update (NautilusMusicView *music_view)
-{
- GnomeVFSResult result;
- GnomeVFSFileInfo *current_file_info;
- GList *list, *node;
-
- char *uri;
- GList *p;
- GList *song_list, *attributes;
- SongInfo *info;
- char *path_uri, *escaped_name;
- char *image_path_uri;
- char *path, *message;
- GtkTreeIter iter;
-
- int file_index;
- int image_count;
-
- uri = nautilus_file_get_uri (music_view->details->file);
-
- song_list = NULL;
- image_path_uri = NULL;
- file_index = 1;
- image_count = 0;
-
- /* connect the music view background to directory metadata */
- nautilus_connect_background_to_file_metadata (GTK_WIDGET (music_view->details->event_box),
- music_view->details->file);
- nautilus_connect_background_to_file_metadata (GTK_WIDGET (music_view->details->tree_view),
- music_view->details->file);
- /* iterate through the directory, collecting mp3 files and extracting id3 data if present */
- result = gnome_vfs_directory_list_load (&list, uri,
- GNOME_VFS_FILE_INFO_GET_MIME_TYPE
- | GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
- if (result != GNOME_VFS_OK) {
- path = gnome_vfs_get_local_path_from_uri (uri);
- message = g_strdup_printf (_("Sorry, but there was an error reading %s."), path);
- eel_show_error_dialog (message, _("Can't Read Folder"),
- GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (music_view->details->event_box))));
- g_free (path);
- g_free (message);
- g_free (uri);
- return;
- }
-
- for (node = list; node != NULL; node = node->next) {
- current_file_info = node->data;
-
- /* skip invisible files, for now */
- if (current_file_info->name[0] == '.') {
- continue;
- }
-
- escaped_name = gnome_vfs_escape_string (current_file_info->name);
- path_uri = g_build_filename (uri, escaped_name, NULL);
- g_free (escaped_name);
-
- /* fetch info and queue it if it's an mp3 file */
- info = fetch_song_info (path_uri, current_file_info, file_index);
- if (info) {
- info->path_uri = path_uri;
- file_index += 1;
- song_list = g_list_prepend (song_list, info);
- } else {
- /* it's not an mp3 file, so see if it's an image */
- const char *mime_type = gnome_vfs_file_info_get_mime_type (current_file_info);
- if (eel_istr_has_prefix (mime_type, "image/")) {
- /* for now, just keep the first image */
- if (image_path_uri == NULL) {
- image_path_uri = g_strdup (path_uri);
- }
- image_count += 1;
- }
-
- g_free (path_uri);
- }
-
- }
- gnome_vfs_file_info_list_free (list);
-
- song_list = g_list_reverse (song_list);
-
- /* populate the list */
- gtk_list_store_clear (music_view->details->list_store);
-
- for (p = song_list; p != NULL; p = p->next) {
- info = (SongInfo *) p->data;
-
- gtk_list_store_append (music_view->details->list_store,
- &iter);
- gtk_list_store_set (music_view->details->list_store,
- &iter,
- TRACK_NUMBER_COLUMN, info->track_number,
- TITLE_COLUMN, g_strdup (info->title),
- ARTIST_COLUMN, g_strdup (info->artist),
- BITRATE_COLUMN, info->bitrate,
- TIME_COLUMN, info->track_time,
- SAMPLE_RATE_COLUMN, info->samprate,
- YEAR_COLUMN, g_strdup (info->year),
- COMMENT_COLUMN, g_strdup (info->comment),
- PATH_URI_COLUMN, g_strdup (info->path_uri),
- -1);
-
- }
-
- /* if there was more than one image in the directory, don't use any */
- if (image_count > 1) {
- g_free (image_path_uri);
- image_path_uri = NULL;
- }
-
- /* set up the image (including hiding the widget if there isn't one */
- nautilus_music_view_set_album_image (music_view, image_path_uri);
- g_free (image_path_uri);
-
- /* Check if one is specified in metadata; if so, it will be set by the callback */
- attributes = g_list_prepend (NULL, NAUTILUS_FILE_ATTRIBUTE_CUSTOM_ICON);
- nautilus_file_call_when_ready (music_view->details->file, attributes, metadata_callback, music_view);
- g_list_free (attributes);
-
- /* determine the album title/artist line */
- if (music_view->details->album_title) {
- char *basename, *album_name, *artist_name, *temp_str;
- char *escaped_album_name, *escaped_artist_name;
-
- album_name = determine_attribute (song_list, FALSE);
- if (album_name == NULL) {
- album_name = gnome_vfs_unescape_string_for_display (
- basename = g_path_get_basename (uri));
- g_free (basename);
- }
-
- escaped_album_name = g_markup_escape_text (album_name, -1);
- artist_name = determine_attribute (song_list, TRUE);
- if (artist_name != NULL) {
- escaped_artist_name = g_markup_escape_text (artist_name, -1);
-
- temp_str = g_strdup_printf (_("<span size=\"xx-large\">%s - %s</span>"), escaped_album_name, escaped_artist_name);
- g_free (escaped_artist_name);
- g_free (artist_name);
- } else {
- temp_str = g_strdup_printf ("<span size=\"xx-large\">%s</span>", escaped_album_name);
- }
- g_free (escaped_album_name);
- gtk_label_set_markup (GTK_LABEL (music_view->details->album_title), temp_str);
-
- g_free (temp_str);
- g_free (album_name);
- }
-
- /* allocate the play controls if necessary */
- if (music_view->details->play_control_box == NULL) {
- add_play_controls (music_view);
- }
-
- music_view_set_selected_song_title (music_view, 0);
-
- /* release the song list */
- eel_g_list_free_deep_custom (song_list, (GFunc) song_info_free, NULL);
-
- g_free (uri);
-}
-
-static void
-detach_file (NautilusMusicView *music_view)
-{
- if (music_view->details->file != NULL) {
- nautilus_file_cancel_call_when_ready (music_view->details->file,
- metadata_callback, music_view);
- nautilus_file_unref (music_view->details->file);
- music_view->details->file = NULL;
- }
-}
-
-void
-nautilus_music_view_load_uri (NautilusMusicView *music_view, const char *uri)
-{
- stop_playing_file (music_view);
- detach_file (music_view);
- music_view->details->file = nautilus_file_get (uri);
- nautilus_music_view_update (music_view);
-
- update_play_controls_status (music_view, get_player_state (music_view));
-}
-
-static void
-music_view_background_appearance_changed_callback (EelBackground *background, NautilusMusicView *music_view)
-{
- GdkColor color;
-
- color = eel_gdk_rgb_to_color (eel_background_is_dark (background) ? EEL_RGB_COLOR_WHITE : EEL_RGB_COLOR_BLACK);
-
- if (music_view->details->album_title != NULL) {
- gtk_widget_modify_fg (music_view->details->album_title,
- GTK_STATE_NORMAL, &color);
- }
- if (music_view->details->song_label != NULL) {
- gtk_widget_modify_fg (music_view->details->song_label,
- GTK_STATE_NORMAL, &color);
- }
- if (music_view->details->playtime != NULL) {
- gtk_widget_modify_fg (music_view->details->playtime,
- GTK_STATE_NORMAL, &color);
- }
-}
-
-static void
-music_view_load_location_callback (NautilusView *view,
- const char *location,
- NautilusMusicView *music_view)
-{
- nautilus_view_report_load_underway (NAUTILUS_VIEW (music_view));
- nautilus_music_view_load_uri (music_view, location);
- nautilus_view_report_load_complete (NAUTILUS_VIEW (music_view));
-}
-
-/* handle receiving dropped objects */
-static void
-nautilus_music_view_drag_data_received (GtkWidget *widget, GdkDragContext *context,
- int x, int y,
- GtkSelectionData *selection_data,
- guint info, guint time,
- gpointer user_data)
-{
- char **uris;
-
- g_return_if_fail (NAUTILUS_IS_MUSIC_VIEW (user_data));
-
- uris = g_strsplit (selection_data->data, "\r\n", 0);
-
- switch (info) {
- case TARGET_GNOME_URI_LIST:
- case TARGET_URI_LIST:
- /* FIXME bugzilla.gnome.org 42406:
- * the music view should accept mp3 files.
- */
- break;
-
- case TARGET_COLOR:
- /* Let the background change based on the dropped color. */
- eel_background_receive_dropped_color
- (eel_get_widget_background (widget),
- widget, x, y, selection_data);
- break;
-
- case TARGET_BGIMAGE:
- eel_background_receive_dropped_background_image
- (eel_get_widget_background (widget),
- uris[0]);
- break;
-
- default:
- g_warning ("unknown drop type");
- break;
- }
-
- g_strfreev (uris);
-}
-
-static void
-start_playing_file (NautilusMusicView *music_view, const char *file_name)
-{
- set_player_state (music_view, PLAYER_PLAYING);
- mpg123_play_file (file_name);
-}
-
-static void
-stop_playing_file (NautilusMusicView *music_view)
-{
- PlayerState state;
-
- state = get_player_state (music_view);
-
- if (state == PLAYER_PLAYING || state == PLAYER_PAUSED) {
- set_player_state (music_view, PLAYER_STOPPED);
- mpg123_stop ();
- }
-}
-
-static PlayerState
-get_player_state (NautilusMusicView *music_view)
-{
- return music_view->details->player_state;
-}
-
-static void
-set_player_state (NautilusMusicView *music_view, PlayerState state)
-{
- music_view->details->player_state = state;
-}
diff --git a/components/music/nautilus-music-view.h b/components/music/nautilus-music-view.h
deleted file mode 100644
index 8edeface4..000000000
--- a/components/music/nautilus-music-view.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/*
- * Copyright (C) 2000 Eazel, Inc
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: Andy Hertzfeld
- */
-
-/* header file for the music view component */
-
-#ifndef NAUTILUS_MUSIC_VIEW_H
-#define NAUTILUS_MUSIC_VIEW_H
-
-#include <libnautilus/nautilus-view.h>
-
-
-typedef struct NautilusMusicView NautilusMusicView;
-typedef struct NautilusMusicViewClass NautilusMusicViewClass;
-
-#define NAUTILUS_TYPE_MUSIC_VIEW (nautilus_music_view_get_type ())
-#define NAUTILUS_MUSIC_VIEW(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_MUSIC_VIEW, NautilusMusicView))
-#define NAUTILUS_MUSIC_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_MUSIC_VIEW, NautilusMusicViewClass))
-#define NAUTILUS_IS_MUSIC_VIEW(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_MUSIC_VIEW))
-#define NAUTILUS_IS_MUSIC_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_MUSIC_VIEW))
-
-typedef struct NautilusMusicViewDetails NautilusMusicViewDetails;
-
-struct NautilusMusicView {
- NautilusView base;
- NautilusMusicViewDetails *details;
-};
-
-struct NautilusMusicViewClass {
- NautilusViewClass base;
-};
-
-
-
-/* GObject support */
-GType nautilus_music_view_get_type (void);
-
-#endif /* NAUTILUS_MUSIC_VIEW_H */
diff --git a/components/music/pixmaps.h b/components/music/pixmaps.h
deleted file mode 100644
index 9a5e2b8ae..000000000
--- a/components/music/pixmaps.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/* XPM */
-static char * play_xpm[] = {
-"13 15 5 1",
-" c None",
-". c #949594",
-"+ c #000000",
-"@ c #8E8E8E",
-"# c #FFFFFF",
-"...... ",
-".+++++. ",
-".++++++. ",
-".+++++++. ",
-".++++++++. ",
-".+++++++++. ",
-".++++++++++. ",
-".++++++++++@#",
-".+++++++++@# ",
-".++++++++@# ",
-".+++++++@# ",
-".++++++@# ",
-".+++++@# ",
-".+@@@@# ",
-".##### "};
-static char * next_xpm[] = {
-"16 15 5 1",
-" c None",
-". c #949594",
-"+ c #000000",
-"@ c #8E8E8E",
-"# c #FFFFFF",
-".. ......",
-".+. .+++@#",
-".++. .+++@#",
-".+++. .+++@#",
-".++++. .+++@#",
-".+++++. .+++@#",
-".++++++. .+++@#",
-".++++++@# .+++@#",
-".+++++@# .+++@#",
-".++++@# .+++@#",
-".+++@# .+++@#",
-".++@# .+++@#",
-".+@# .+++@#",
-".+# .+@@@#",
-".# .#####"};
-static char * prev_xpm[] = {
-"16 15 5 1",
-" c None",
-". c #949594",
-"+ c #000000",
-"@ c #8E8E8E",
-"# c #FFFFFF",
-"...... ..",
-".+++@# .+#",
-".+++@# .+@#",
-".+++@# .++@#",
-".+++@# .+++@#",
-".+++@# .++++@#",
-".+++@# .+++++@#",
-".+++@# .++++++@#",
-".+++@# .+++++@#",
-".+++@# .++++@#",
-".+++@# .+++@#",
-".+++@# .++@#",
-".+++@# .+@#",
-".+@@@# .+#",
-".##### .#"};
-static char * pause_xpm[] = {
-"13 15 5 1",
-" c None",
-". c #949594",
-"+ c #000000",
-"@ c #8E8E8E",
-"# c #FFFFFF",
-"...... ......",
-".+++@# .+++@#",
-".+++@# .+++@#",
-".+++@# .+++@#",
-".+++@# .+++@#",
-".+++@# .+++@#",
-".+++@# .+++@#",
-".+++@# .+++@#",
-".+++@# .+++@#",
-".+++@# .+++@#",
-".+++@# .+++@#",
-".+++@# .+++@#",
-".+++@# .+++@#",
-".+@@@# .+@@@#",
-".##### .#####"};
-static char * stop_xpm[] = {
-"13 15 5 1",
-" c None",
-". c #949594",
-"+ c #000000",
-"@ c #8E8E8E",
-"# c #FFFFFF",
-".............",
-".++++++++++@#",
-".++++++++++@#",
-".++++++++++@#",
-".++++++++++@#",
-".++++++++++@#",
-".++++++++++@#",
-".++++++++++@#",
-".++++++++++@#",
-".++++++++++@#",
-".++++++++++@#",
-".++++++++++@#",
-".++++++++++@#",
-".+@@@@@@@@@@#",
-".############"};
-
-static char * play_green_xpm[] = {
-"13 15 5 1",
-" c None",
-". c #949594",
-"+ c #00F000",
-"@ c #8E8E8E",
-"# c #FFFFFF",
-"...... ",
-".+++++. ",
-".++++++. ",
-".+++++++. ",
-".++++++++. ",
-".+++++++++. ",
-".++++++++++. ",
-".++++++++++@#",
-".+++++++++@# ",
-".++++++++@# ",
-".+++++++@# ",
-".++++++@# ",
-".+++++@# ",
-".+@@@@# ",
-".##### "};
-static char * pause_green_xpm[] = {
-"13 15 5 1",
-" c None",
-". c #949594",
-"+ c #00F000",
-"@ c #8E8E8E",
-"# c #FFFFFF",
-"...... ......",
-".+++@# .+++@#",
-".+++@# .+++@#",
-".+++@# .+++@#",
-".+++@# .+++@#",
-".+++@# .+++@#",
-".+++@# .+++@#",
-".+++@# .+++@#",
-".+++@# .+++@#",
-".+++@# .+++@#",
-".+++@# .+++@#",
-".+++@# .+++@#",
-".+++@# .+++@#",
-".+@@@# .+@@@#",
-".##### .#####"};
diff --git a/components/music/tabinit.c b/components/music/tabinit.c
deleted file mode 100644
index 8f0ed3f44..000000000
--- a/components/music/tabinit.c
+++ /dev/null
@@ -1,103 +0,0 @@
-
-#include <stdlib.h>
-
-#include "mpg123.h"
-
-real mpg123_decwin[512 + 32];
-static real cos64[16], cos32[8], cos16[4], cos8[2], cos4[1];
-real *mpg123_pnts[] =
-{cos64, cos32, cos16, cos8, cos4};
-
-static unsigned char *mpg123_conv16to8_buf = NULL;
-unsigned char *mpg123_conv16to8;
-
-static long intwinbase[] =
-{
- 0, -1, -1, -1, -1, -1, -1, -2, -2, -2,
- -2, -3, -3, -4, -4, -5, -5, -6, -7, -7,
- -8, -9, -10, -11, -13, -14, -16, -17, -19, -21,
- -24, -26, -29, -31, -35, -38, -41, -45, -49, -53,
- -58, -63, -68, -73, -79, -85, -91, -97, -104, -111,
- -117, -125, -132, -139, -147, -154, -161, -169, -176, -183,
- -190, -196, -202, -208, -213, -218, -222, -225, -227, -228,
- -228, -227, -224, -221, -215, -208, -200, -189, -177, -163,
- -146, -127, -106, -83, -57, -29, 2, 36, 72, 111,
- 153, 197, 244, 294, 347, 401, 459, 519, 581, 645,
- 711, 779, 848, 919, 991, 1064, 1137, 1210, 1283, 1356,
- 1428, 1498, 1567, 1634, 1698, 1759, 1817, 1870, 1919, 1962,
- 2001, 2032, 2057, 2075, 2085, 2087, 2080, 2063, 2037, 2000,
- 1952, 1893, 1822, 1739, 1644, 1535, 1414, 1280, 1131, 970,
- 794, 605, 402, 185, -45, -288, -545, -814, -1095, -1388,
- -1692, -2006, -2330, -2663, -3004, -3351, -3705, -4063, -4425, -4788,
- -5153, -5517, -5879, -6237, -6589, -6935, -7271, -7597, -7910, -8209,
- -8491, -8755, -8998, -9219, -9416, -9585, -9727, -9838, -9916, -9959,
- -9966, -9935, -9863, -9750, -9592, -9389, -9139, -8840, -8492, -8092,
- -7640, -7134, -6574, -5959, -5288, -4561, -3776, -2935, -2037, -1082,
- -70, 998, 2122, 3300, 4533, 5818, 7154, 8540, 9975, 11455,
- 12980, 14548, 16155, 17799, 19478, 21189, 22929, 24694, 26482, 28289,
- 30112, 31947, 33791, 35640, 37489, 39336, 41176, 43006, 44821, 46617,
- 48390, 50137, 51853, 53534, 55178, 56778, 58333, 59838, 61289, 62684,
- 64019, 65290, 66494, 67629, 68692, 69679, 70590, 71420, 72169, 72835,
- 73415, 73908, 74313, 74630, 74856, 74992, 75038};
-
-void mpg123_make_decode_tables(long scaleval)
-{
- int i, j, k, kr, divv;
- real *table, *costab;
-
- for (i = 0; i < 5; i++)
- {
- kr = 0x10 >> i;
- divv = 0x40 >> i;
- costab = mpg123_pnts[i];
- for (k = 0; k < kr; k++)
- costab[k] = 1.0 / (2.0 * cos(M_PI * ((double) k * 2.0 + 1.0) / (double) divv));
- }
-
- table = mpg123_decwin;
- scaleval = -scaleval;
- for (i = 0, j = 0; i < 256; i++, j++, table += 32)
- {
- if (table < mpg123_decwin + 512 + 16)
- table[16] = table[0] = (double) intwinbase[j] / 65536.0 * (double) scaleval;
- if (i % 32 == 31)
- table -= 1023;
- if (i % 64 == 63)
- scaleval = -scaleval;
- }
-
- for ( /* i=256 */ ; i < 512; i++, j--, table += 32)
- {
- if (table < mpg123_decwin + 512 + 16)
- table[16] = table[0] = (double) intwinbase[j] / 65536.0 * (double) scaleval;
- if (i % 32 == 31)
- table -= 1023;
- if (i % 64 == 63)
- scaleval = -scaleval;
- }
-}
-
-void mpg123_make_conv16to8_table(void)
-{
- int i;
-
- /*
- * ????: 8.0 is right but on SB cards '2.0' is a better value ???
- */
-
- if (!mpg123_conv16to8_buf)
- {
- mpg123_conv16to8_buf = (unsigned char *) malloc(8192);
- if (!mpg123_conv16to8_buf)
- {
- fprintf(stderr, "Can't allocate 16 to 8 converter table!\n");
-/* exit(1); */
- }
- mpg123_conv16to8 = mpg123_conv16to8_buf + 4096;
- }
-
- for (i = -4096; i < 4096; i++)
- {
- mpg123_conv16to8[i] = (i >> 5) + 128;
- }
-}
diff --git a/components/news/nautilus-news.c b/components/news/nautilus-news.c
index 6fbb5c754..93710e608 100644
--- a/components/news/nautilus-news.c
+++ b/components/news/nautilus-news.c
@@ -1755,11 +1755,13 @@ add_site_from_fields (GtkWidget *widget, News *news)
/* make sure there's something in the fields */
if (site_name == NULL || strlen (site_name) == 0) {
- eel_show_error_dialog (_("Sorry, but you have not specified a name for the site!"), _("Missing Site Name Error"), NULL);
+ eel_show_error_dialog (_("Sorry, but you have not specified a name for the site."),
+ _("Please specify a name and try again."), _("Missing Site Name Error"), NULL);
return;
}
if (site_location == NULL || strlen (site_location) == 0) {
- eel_show_error_dialog (_("Sorry, but you have not specified a URL for the site!"), _("Missing URL Error"), NULL);
+ eel_show_error_dialog (_("Sorry, but you have not specified a URL for the site."),
+ _("Please specify a URL and try again."), _("Missing URL Error"), NULL);
return;
}
@@ -1776,7 +1778,8 @@ add_site_from_fields (GtkWidget *widget, News *news)
g_free (buffer);
if (!got_xml_file) {
g_free (site_uri);
- eel_show_error_dialog (_("Sorry, but the specified url doesn't seem to be a valid RSS file!"), _("Invalid RSS URL"), NULL);
+ eel_show_error_dialog (_("Sorry, but the specified url doesn't seem to be a valid RSS file."),
+ _("Please check the spelling of the url."), _("Invalid RSS URL"), NULL);
return;
}
diff --git a/components/text/Makefile.am b/components/text/Makefile.am
index b3299bdf5..3e0262933 100644
--- a/components/text/Makefile.am
+++ b/components/text/Makefile.am
@@ -1,7 +1,5 @@
NULL =
-SUBDIRS = services
-
INCLUDES = \
-DG_LOG_DOMAIN=\"Nautilus-Text\" \
-DDATADIR=\""$(datadir)"\" \
diff --git a/components/text/services/.cvsignore b/components/text/services/.cvsignore
deleted file mode 100644
index 282522db0..000000000
--- a/components/text/services/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-Makefile
-Makefile.in
diff --git a/components/text/services/Makefile.am b/components/text/services/Makefile.am
deleted file mode 100644
index d4a4cc36c..000000000
--- a/components/text/services/Makefile.am
+++ /dev/null
@@ -1,10 +0,0 @@
-NULL=
-
-servicesdir = $(datadir)/nautilus/services/text
-
-services_DATA = \
- google.xml \
- webster.xml \
- $(NULL)
-
-EXTRA_DIST = $(services_DATA)
diff --git a/components/text/services/google.xml b/components/text/services/google.xml
deleted file mode 100644
index 8610c35f6..000000000
--- a/components/text/services/google.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<?xml version="1.0"?>
-<service _label="Search Google for Selected Text" source="selection"
- template="http://www.google.com/search?q=%s" _tooltip="Use Google to search the web for the selected text"/>
diff --git a/components/text/services/webster.xml b/components/text/services/webster.xml
deleted file mode 100644
index 715605c81..000000000
--- a/components/text/services/webster.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<?xml version="1.0"?>
-<service _label="Look Up Selected Text in Dictionary" source="selection"
- template="http://www.m-w.com/cgi-bin/dictionary?va=%s" _tooltip="Look up the selected text in the Merriam-Webster dictionary"/>
diff --git a/components/tree/Makefile.am b/components/tree/Makefile.am
deleted file mode 100644
index 2a04acf19..000000000
--- a/components/tree/Makefile.am
+++ /dev/null
@@ -1,41 +0,0 @@
-NULL =
-
-INCLUDES = \
- -DGNOMELOCALEDIR=\""$(prefix)/${DATADIRNAME}/locale"\" \
- -DG_LOG_DOMAIN=\"Nautilus-Tree\" \
- -I$(top_srcdir) \
- $(DISABLE_DEPRECATED_CFLAGS) \
- $(COMPONENT_CFLAGS) \
- $(NULL)
-
-TREE_VIEW_COMMON_SOURCES = \
- nautilus-tree-model.c \
- nautilus-tree-model.h \
- nautilus-tree-view.c \
- nautilus-tree-view.h \
- nautilus-tree-view-iids.h \
- $(NULL)
-
-bonobodir = $(libdir)/bonobo
-bonobo_LTLIBRARIES = libnautilus-tree-view.la
-
-libnautilus_tree_view_la_SOURCES = $(TREE_VIEW_COMMON_SOURCES) libmain.c
-
-libnautilus_tree_view_la_LDFLAGS = -module -avoid-version -no-undefined
-
-libnautilus_tree_view_la_LIBADD = \
- $(top_builddir)/libnautilus/libnautilus.la \
- $(top_builddir)/libnautilus-private/libnautilus-private.la \
- $(COMPONENT_LIBS)
- $(NULL)
-
-server_in_files = Nautilus_View_tree.server.in.in
-
-serverdir = $(libdir)/bonobo/servers
-server_DATA = $(server_in_files:.server.in.in=.server)
-$(server_in_files:.server.in.in=.server.in): $(server_in_files)
- sed -e "s|\@BONOBODIR\@|$(bonobodir)|" $< > $@
-@INTLTOOL_SERVER_RULE@
-
-EXTRA_DIST = $(server_in_files)
-CLEANFILES = $(server_DATA) $(server_DATA).in
diff --git a/components/tree/Nautilus_View_tree.server.in.in b/components/tree/Nautilus_View_tree.server.in.in
deleted file mode 100644
index a9b29cb04..000000000
--- a/components/tree/Nautilus_View_tree.server.in.in
+++ /dev/null
@@ -1,15 +0,0 @@
-<oaf_info>
-
-<oaf_server iid="OAFIID:Nautilus_Tree_View"
- type="shlib" location="@BONOBODIR@/libnautilus-tree-view">
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:Bonobo/Unknown:1.0"/>
- <item value="IDL:Bonobo/Control:1.0"/>
- <item value="IDL:Nautilus/View:1.0"/>
- </oaf_attribute>
- <oaf_attribute name="name" type="string" _value="Nautilus Tree view"/>
- <oaf_attribute name="description" type="string" _value="Nautilus Tree side pane"/>
- <oaf_attribute name="nautilus:sidebar_panel_name" type="string" _value="Tree"/>
-</oaf_server>
-
-</oaf_info>
diff --git a/components/tree/libmain.c b/components/tree/libmain.c
deleted file mode 100644
index 7f7f4d9c6..000000000
--- a/components/tree/libmain.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/*
- * Copyright (C) 2000, 2001 Eazel, Inc
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: Maciej Stachowiak
- */
-
-/* libmain.c - object activation infrastructure for shared library
- version of tree view. */
-
-#include <config.h>
-#include <string.h>
-#include "nautilus-tree-view-iids.h"
-#include "nautilus-tree-view.h"
-#include <bonobo.h>
-#include <bonobo-activation/bonobo-activation.h>
-#include <libnautilus-private/nautilus-bonobo-extensions.h>
-
-static gboolean shortcut_registered = FALSE;
-
-static CORBA_Object
-create_object (const char *iid,
- gpointer callback_data)
-{
- NautilusTreeView *view;
-
- if (strcmp (iid, TREE_VIEW_IID) != 0) {
- return CORBA_OBJECT_NIL;
- }
-
- view = NAUTILUS_TREE_VIEW (g_object_new (NAUTILUS_TYPE_TREE_VIEW, NULL));
-
- return CORBA_Object_duplicate (BONOBO_OBJREF (view), NULL);
-}
-
-static CORBA_Object
-tree_shlib_make_object (PortableServer_POA poa,
- const char *iid,
- gpointer impl_ptr,
- CORBA_Environment *ev)
-{
- NautilusTreeView *view;
-
- if (!shortcut_registered) {
- nautilus_bonobo_register_activation_shortcut (TREE_VIEW_IID,
- create_object, NULL);
- shortcut_registered = TRUE;
- }
-
- if (strcmp (iid, TREE_VIEW_IID) != 0) {
- return CORBA_OBJECT_NIL;
- }
-
- view = NAUTILUS_TREE_VIEW (g_object_new (NAUTILUS_TYPE_TREE_VIEW, NULL));
-
- bonobo_activation_plugin_use (poa, impl_ptr);
-
- return CORBA_Object_duplicate (BONOBO_OBJREF (view), ev);
-}
-
-static const BonoboActivationPluginObject tree_plugin_list[] = {
- { TREE_VIEW_IID, tree_shlib_make_object },
- { NULL }
-};
-
-const BonoboActivationPlugin Bonobo_Plugin_info = {
- tree_plugin_list,
- "Nautilus Tree Sidebar Panel"
-};
diff --git a/components/tree/nautilus-tree-model.c b/components/tree/nautilus-tree-model.c
deleted file mode 100644
index fe539fde5..000000000
--- a/components/tree/nautilus-tree-model.c
+++ /dev/null
@@ -1,1797 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/*
- * Copyright C) 2000, 2001 Eazel, Inc
- * Copyright (C) 2002 Anders Carlsson
- * Copyright (C) 2002 Bent Spoon Software
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Authors: Anders Carlsson <andersca@gnu.org>
- * Darin Adler <darin@bentspoon.com>
- */
-
-/* nautilus-tree-model.c - model for the tree view */
-
-#include <config.h>
-#include "nautilus-tree-model.h"
-
-#include <eel/eel-glib-extensions.h>
-#include <libgnome/gnome-i18n.h>
-#include <libnautilus-private/nautilus-directory.h>
-#include <libnautilus-private/nautilus-file-attributes.h>
-#include <libnautilus-private/nautilus-file.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
-#include <string.h>
-
-enum {
- ROW_LOADED,
- LAST_SIGNAL
-};
-
-static guint tree_model_signals[LAST_SIGNAL] = { 0 };
-
-typedef gboolean (* FilePredicate) (NautilusFile *);
-
-/* The user_data of the GtkTreeIter is the TreeNode pointer.
- * It's NULL for the dummy node. If it's NULL, then user_data2
- * is the TreeNode pointer to the parent.
- */
-
-typedef struct TreeNode TreeNode;
-typedef struct NautilusTreeModelRoot NautilusTreeModelRoot;
-
-struct TreeNode {
- /* part of this node for the file itself */
- int ref_count;
-
- NautilusFile *file;
- char *display_name;
- char *icon_name;
- GdkPixbuf *closed_pixbuf;
- GdkPixbuf *open_pixbuf;
-
- NautilusTreeModelRoot *root;
-
- TreeNode *parent;
- TreeNode *next;
- TreeNode *prev;
-
- /* part of the node used only for directories */
- int dummy_child_ref_count;
- int all_children_ref_count;
-
- NautilusDirectory *directory;
- guint done_loading_id;
- guint files_added_id;
- guint files_changed_id;
-
- TreeNode *first_child;
-
- /* misc. flags */
- guint done_loading : 1;
- guint inserting_first_child : 1;
- guint inserted : 1;
-};
-
-struct NautilusTreeModelDetails {
- int stamp;
-
- TreeNode *root_node;
-
- guint monitoring_update_idle_id;
-
- gboolean show_hidden_files;
- gboolean show_backup_files;
- gboolean show_only_directories;
-};
-
-struct NautilusTreeModelRoot {
- NautilusTreeModel *model;
-
- /* separate hash table for each root node needed */
- GHashTable *file_to_node_map;
-
- TreeNode *root_node;
-
- gulong changed_handler_id;
-};
-
-typedef struct {
- NautilusDirectory *directory;
- NautilusTreeModel *model;
-} DoneLoadingParameters;
-
-static GObjectClass *parent_class;
-
-static void schedule_monitoring_update (NautilusTreeModel *model);
-static void destroy_node_without_reporting (NautilusTreeModel *model,
- TreeNode *node);
-static void report_node_contents_changed (NautilusTreeModel *model,
- TreeNode *node);
-
-static guint
-nautilus_tree_model_get_flags (GtkTreeModel *tree_model)
-{
- return GTK_TREE_MODEL_ITERS_PERSIST;
-}
-
-static void
-object_unref_if_not_NULL (gpointer object)
-{
- if (object == NULL) {
- return;
- }
- g_object_unref (object);
-}
-
-static NautilusTreeModelRoot *
-tree_model_root_new (NautilusTreeModel *model)
-{
- NautilusTreeModelRoot *root;
-
- root = g_new0 (NautilusTreeModelRoot, 1);
- root->model = model;
- root->file_to_node_map = g_hash_table_new (NULL, NULL);
-
- return root;
-}
-
-static TreeNode *
-tree_node_new (NautilusFile *file, NautilusTreeModelRoot *root)
-{
- TreeNode *node;
-
- node = g_new0 (TreeNode, 1);
- node->file = nautilus_file_ref (file);
- node->root = root;
- return node;
-}
-
-static void
-tree_node_unparent (NautilusTreeModel *model, TreeNode *node)
-{
- TreeNode *parent, *next, *prev;
-
- parent = node->parent;
- next = node->next;
- prev = node->prev;
-
- if (parent == NULL &&
- node == model->details->root_node) {
- /* it's the first root node -> if there is a next then let it be the first root node */
- model->details->root_node = next;
- }
-
- if (next != NULL) {
- next->prev = prev;
- }
- if (prev == NULL && parent != NULL) {
- g_assert (parent->first_child == node);
- parent->first_child = next;
- } else if (prev != NULL) {
- prev->next = next;
- }
-
- node->parent = NULL;
- node->next = NULL;
- node->prev = NULL;
- node->root = NULL;
-}
-
-static void
-tree_node_destroy (NautilusTreeModel *model, TreeNode *node)
-{
- g_assert (node->first_child == NULL);
- g_assert (node->ref_count == 0);
-
- tree_node_unparent (model, node);
-
- g_object_unref (node->file);
- g_free (node->display_name);
- g_free (node->icon_name);
- object_unref_if_not_NULL (node->closed_pixbuf);
- object_unref_if_not_NULL (node->open_pixbuf);
-
- g_assert (node->done_loading_id == 0);
- g_assert (node->files_added_id == 0);
- g_assert (node->files_changed_id == 0);
- object_unref_if_not_NULL (node->directory);
-
- g_free (node);
-}
-
-static void
-tree_node_parent (TreeNode *node, TreeNode *parent)
-{
- TreeNode *first_child;
-
- g_assert (parent != NULL);
- g_assert (node->parent == NULL);
- g_assert (node->prev == NULL);
- g_assert (node->next == NULL);
-
- first_child = parent->first_child;
-
- node->parent = parent;
- node->root = parent->root;
- node->next = first_child;
-
- if (first_child != NULL) {
- g_assert (first_child->prev == NULL);
- first_child->prev = node;
- }
-
- parent->first_child = node;
-}
-
-static GdkPixbuf *
-tree_node_get_pixbuf_from_factory (TreeNode *node,
- const char *modifier)
-{
- if (node->parent == NULL) {
- return nautilus_icon_factory_get_pixbuf_from_name
- (node->icon_name, NULL,
- NAUTILUS_ICON_SIZE_FOR_MENUS, NULL);
- }
- return nautilus_icon_factory_get_pixbuf_for_file
- (node->file, modifier, NAUTILUS_ICON_SIZE_FOR_MENUS);
-}
-
-static gboolean
-tree_node_update_pixbuf (TreeNode *node,
- GdkPixbuf **pixbuf_storage,
- const char *modifier)
-{
- GdkPixbuf *pixbuf;
-
- if (*pixbuf_storage == NULL) {
- return FALSE;
- }
- pixbuf = tree_node_get_pixbuf_from_factory (node, modifier);
- if (pixbuf == *pixbuf_storage) {
- g_object_unref (pixbuf);
- return FALSE;
- }
- g_object_unref (*pixbuf_storage);
- *pixbuf_storage = pixbuf;
- return TRUE;
-}
-
-static gboolean
-tree_node_update_closed_pixbuf (TreeNode *node)
-{
- return tree_node_update_pixbuf (node, &node->closed_pixbuf, NULL);
-}
-
-static gboolean
-tree_node_update_open_pixbuf (TreeNode *node)
-{
- return tree_node_update_pixbuf (node, &node->open_pixbuf, "accept");
-}
-
-static gboolean
-tree_node_update_display_name (TreeNode *node)
-{
- char *display_name;
-
- if (node->display_name == NULL) {
- return FALSE;
- }
- /* don't update root node display names */
- if (node->parent == NULL) {
- return FALSE;
- }
- display_name = nautilus_file_get_display_name (node->file);
- if (strcmp (display_name, node->display_name) == 0) {
- g_free (display_name);
- return FALSE;
- }
- g_free (node->display_name);
- node->display_name = NULL;
- return TRUE;
-}
-
-static GdkPixbuf *
-tree_node_get_closed_pixbuf (TreeNode *node)
-{
- if (node->closed_pixbuf == NULL) {
- node->closed_pixbuf = tree_node_get_pixbuf_from_factory (node, NULL);
- }
- return node->closed_pixbuf;
-}
-
-static GdkPixbuf *
-tree_node_get_open_pixbuf (TreeNode *node)
-{
- if (node->open_pixbuf == NULL) {
- node->open_pixbuf = tree_node_get_pixbuf_from_factory (node, "accept");
- }
- return node->open_pixbuf;
-}
-
-static const char *
-tree_node_get_display_name (TreeNode *node)
-{
- if (node->display_name == NULL) {
- node->display_name = nautilus_file_get_display_name (node->file);
- }
- return node->display_name;
-}
-
-static gboolean
-tree_node_has_dummy_child (TreeNode *node)
-{
- return node->directory != NULL
- && (!node->done_loading
- || node->first_child == NULL
- || node->inserting_first_child);
-}
-
-static int
-tree_node_get_child_index (TreeNode *parent, TreeNode *child)
-{
- int i;
- TreeNode *node;
-
- if (child == NULL) {
- g_assert (tree_node_has_dummy_child (parent));
- return 0;
- }
-
- i = tree_node_has_dummy_child (parent) ? 1 : 0;
- for (node = parent->first_child; node != NULL; node = node->next, i++) {
- if (child == node) {
- return i;
- }
- }
-
- g_assert_not_reached ();
- return 0;
-}
-
-static gboolean
-make_iter_invalid (GtkTreeIter *iter)
-{
- iter->stamp = 0;
- iter->user_data = NULL;
- iter->user_data2 = NULL;
- iter->user_data3 = NULL;
- return FALSE;
-}
-
-static gboolean
-make_iter_for_node (TreeNode *node, GtkTreeIter *iter, int stamp)
-{
- if (node == NULL) {
- return make_iter_invalid (iter);
- }
- iter->stamp = stamp;
- iter->user_data = node;
- iter->user_data2 = NULL;
- iter->user_data3 = NULL;
- return TRUE;
-}
-
-static gboolean
-make_iter_for_dummy_row (TreeNode *parent, GtkTreeIter *iter, int stamp)
-{
- g_assert (tree_node_has_dummy_child (parent));
- g_assert (parent != NULL);
- iter->stamp = stamp;
- iter->user_data = NULL;
- iter->user_data2 = parent;
- iter->user_data3 = NULL;
- return TRUE;
-}
-
-static TreeNode *
-get_node_from_file (NautilusTreeModelRoot *root, NautilusFile *file)
-{
- return g_hash_table_lookup (root->file_to_node_map, file);
-}
-
-static TreeNode *
-get_parent_node_from_file (NautilusTreeModelRoot *root, NautilusFile *file)
-{
- NautilusFile *parent_file;
- TreeNode *parent_node;
-
- parent_file = nautilus_file_get_parent (file);
- parent_node = get_node_from_file (root, parent_file);
- nautilus_file_unref (parent_file);
- return parent_node;
-}
-
-static TreeNode *
-create_node_for_file (NautilusTreeModelRoot *root, NautilusFile *file)
-{
- TreeNode *node;
-
- g_assert (get_node_from_file (root, file) == NULL);
- node = tree_node_new (file, root);
- g_hash_table_insert (root->file_to_node_map, node->file, node);
- return node;
-}
-
-#if LOG_REF_COUNTS
-
-static char *
-get_node_uri (GtkTreeIter *iter)
-{
- TreeNode *node, *parent;
- char *parent_uri, *node_uri;
-
- node = iter->user_data;
- if (node != NULL) {
- return nautilus_file_get_uri (node->file);
- }
-
- parent = iter->user_data2;
- parent_uri = nautilus_file_get_uri (parent->file);
- node_uri = g_strconcat (parent_uri, " -- DUMMY", NULL);
- g_free (parent_uri);
- return node_uri;
-}
-
-#endif
-
-static void
-decrement_ref_count (NautilusTreeModel *model, TreeNode *node, int count)
-{
- node->all_children_ref_count -= count;
- if (node->all_children_ref_count == 0) {
- schedule_monitoring_update (model);
- }
-}
-
-static void
-abandon_node_ref_count (NautilusTreeModel *model, TreeNode *node)
-{
- if (node->parent != NULL) {
- decrement_ref_count (model, node->parent, node->ref_count);
-#if LOG_REF_COUNTS
- if (node->ref_count != 0) {
- char *uri;
-
- uri = nautilus_file_get_uri (node->file);
- g_message ("abandoning %d ref of %s, count is now %d",
- node->ref_count, uri, node->parent->all_children_ref_count);
- g_free (uri);
- }
-#endif
- }
- node->ref_count = 0;
-}
-
-static void
-abandon_dummy_row_ref_count (NautilusTreeModel *model, TreeNode *node)
-{
- decrement_ref_count (model, node, node->dummy_child_ref_count);
- if (node->dummy_child_ref_count != 0) {
-#if LOG_REF_COUNTS
- char *uri;
-
- uri = nautilus_file_get_uri (node->file);
- g_message ("abandoning %d ref of %s -- DUMMY, count is now %d",
- node->dummy_child_ref_count, uri, node->all_children_ref_count);
- g_free (uri);
-#endif
- }
- node->dummy_child_ref_count = 0;
-}
-
-static void
-report_row_inserted (NautilusTreeModel *model, GtkTreeIter *iter)
-{
- GtkTreePath *path;
-
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), iter);
- gtk_tree_model_row_inserted (GTK_TREE_MODEL (model), path, iter);
- gtk_tree_path_free (path);
-}
-
-static void
-report_row_contents_changed (NautilusTreeModel *model, GtkTreeIter *iter)
-{
- GtkTreePath *path;
-
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), iter);
- gtk_tree_model_row_changed (GTK_TREE_MODEL (model), path, iter);
- gtk_tree_path_free (path);
-}
-
-static void
-report_row_has_child_toggled (NautilusTreeModel *model, GtkTreeIter *iter)
-{
- GtkTreePath *path;
-
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), iter);
- gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (model), path, iter);
- gtk_tree_path_free (path);
-}
-
-static GtkTreePath *
-get_node_path (NautilusTreeModel *model, TreeNode *node)
-{
- GtkTreeIter iter;
-
- make_iter_for_node (node, &iter, model->details->stamp);
- return gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
-}
-
-static void
-report_dummy_row_inserted (NautilusTreeModel *model, TreeNode *parent)
-{
- GtkTreeIter iter;
-
- if (!parent->inserted) {
- return;
- }
- make_iter_for_dummy_row (parent, &iter, model->details->stamp);
- report_row_inserted (model, &iter);
-}
-
-static void
-report_dummy_row_deleted (NautilusTreeModel *model, TreeNode *parent)
-{
- GtkTreeIter iter;
- GtkTreePath *path;
-
- abandon_dummy_row_ref_count (model, parent);
- if (!parent->inserted) {
- return;
- }
- make_iter_for_node (parent, &iter, model->details->stamp);
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
- gtk_tree_path_append_index (path, 0);
- gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
- gtk_tree_path_free (path);
-}
-
-static void
-report_node_inserted (NautilusTreeModel *model, TreeNode *node)
-{
- GtkTreeIter iter;
-
- make_iter_for_node (node, &iter, model->details->stamp);
- report_row_inserted (model, &iter);
- node->inserted = TRUE;
-
- if (node->directory != NULL) {
- report_row_has_child_toggled (model, &iter);
- }
- if (tree_node_has_dummy_child (node)) {
- report_dummy_row_inserted (model, node);
- }
-}
-
-static void
-report_node_contents_changed (NautilusTreeModel *model, TreeNode *node)
-{
- GtkTreeIter iter;
-
- if (!node->inserted) {
- return;
- }
- make_iter_for_node (node, &iter, model->details->stamp);
- report_row_contents_changed (model, &iter);
-}
-
-static void
-report_node_has_child_toggled (NautilusTreeModel *model, TreeNode *node)
-{
- GtkTreeIter iter;
-
- if (!node->inserted) {
- return;
- }
- make_iter_for_node (node, &iter, model->details->stamp);
- report_row_has_child_toggled (model, &iter);
-}
-
-static void
-report_dummy_row_contents_changed (NautilusTreeModel *model, TreeNode *parent)
-{
- GtkTreeIter iter;
-
- if (!parent->inserted) {
- return;
- }
- make_iter_for_dummy_row (parent, &iter, model->details->stamp);
- report_row_contents_changed (model, &iter);
-}
-
-static void
-stop_monitoring_directory (NautilusTreeModel *model, TreeNode *node)
-{
- NautilusDirectory *directory;
-
- if (node->done_loading_id == 0) {
- g_assert (node->files_added_id == 0);
- g_assert (node->files_changed_id == 0);
- return;
- }
-
- directory = node->directory;
-
- g_signal_handler_disconnect (node->directory, node->done_loading_id);
- g_signal_handler_disconnect (node->directory, node->files_added_id);
- g_signal_handler_disconnect (node->directory, node->files_changed_id);
-
- node->done_loading_id = 0;
- node->files_added_id = 0;
- node->files_changed_id = 0;
-
- nautilus_directory_file_monitor_remove (node->directory, model);
-}
-
-static void
-destroy_children_without_reporting (NautilusTreeModel *model, TreeNode *parent)
-{
- while (parent->first_child != NULL) {
- destroy_node_without_reporting (model, parent->first_child);
- }
-}
-
-static void
-destroy_node_without_reporting (NautilusTreeModel *model, TreeNode *node)
-{
- abandon_node_ref_count (model, node);
- stop_monitoring_directory (model, node);
- node->inserted = FALSE;
- destroy_children_without_reporting (model, node);
- g_hash_table_remove (node->root->file_to_node_map, node->file);
- tree_node_destroy (model, node);
-}
-
-static void
-destroy_node (NautilusTreeModel *model, TreeNode *node)
-{
- TreeNode *parent;
- gboolean parent_had_dummy_child;
- GtkTreePath *path;
-
- parent = node->parent;
- parent_had_dummy_child = tree_node_has_dummy_child (parent);
-
- path = get_node_path (model, node);
-
- destroy_node_without_reporting (model, node);
-
- gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
- gtk_tree_path_free (path);
-
- if (tree_node_has_dummy_child (parent)) {
- if (!parent_had_dummy_child) {
- report_dummy_row_inserted (model, parent);
- }
- } else {
- g_assert (!parent_had_dummy_child);
- }
-}
-
-static void
-destroy_children (NautilusTreeModel *model, TreeNode *parent)
-{
- while (parent->first_child != NULL) {
- destroy_node (model, parent->first_child);
- }
-}
-
-static void
-destroy_children_by_function (NautilusTreeModel *model, TreeNode *parent, FilePredicate f)
-{
- TreeNode *child, *next;
-
- for (child = parent->first_child; child != NULL; child = next) {
- next = child->next;
- if (f (child->file)) {
- destroy_node (model, child);
- } else {
- destroy_children_by_function (model, child, f);
- }
- }
-}
-
-static void
-destroy_by_function (NautilusTreeModel *model, FilePredicate f)
-{
- TreeNode *node;
- for (node = model->details->root_node; node != NULL; node = node->next) {
- destroy_children_by_function (model, node, f);
- }
-}
-
-static gboolean
-update_node_without_reporting (NautilusTreeModel *model, TreeNode *node)
-{
- gboolean changed;
-
- changed = FALSE;
-
- if (node->directory == NULL && nautilus_file_is_directory (node->file)) {
- node->directory = nautilus_directory_get_for_file (node->file);
- } else if (node->directory != NULL && !nautilus_file_is_directory (node->file)) {
- stop_monitoring_directory (model, node);
- destroy_children (model, node);
- nautilus_directory_unref (node->directory);
- node->directory = NULL;
- }
-
- changed |= tree_node_update_display_name (node);
- changed |= tree_node_update_closed_pixbuf (node);
- changed |= tree_node_update_open_pixbuf (node);
-
- return changed;
-}
-
-static void
-insert_node (NautilusTreeModel *model, TreeNode *parent, TreeNode *node)
-{
- gboolean parent_empty;
-
- parent_empty = parent->first_child == NULL;
- if (parent_empty) {
- parent->inserting_first_child = TRUE;
- }
-
- tree_node_parent (node, parent);
-
- update_node_without_reporting (model, node);
- report_node_inserted (model, node);
-
- if (parent_empty) {
- parent->inserting_first_child = FALSE;
- if (!tree_node_has_dummy_child (parent)) {
- report_dummy_row_deleted (model, parent);
- }
- }
-}
-
-static void
-reparent_node (NautilusTreeModel *model, TreeNode *node)
-{
- GtkTreePath *path;
- TreeNode *new_parent;
-
- new_parent = get_parent_node_from_file (node->root, node->file);
- if (new_parent == NULL || new_parent->directory == NULL) {
- destroy_node (model, node);
- return;
- }
-
- path = get_node_path (model, node);
-
- abandon_node_ref_count (model, node);
- tree_node_unparent (model, node);
-
- gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
- gtk_tree_path_free (path);
-
- insert_node (model, new_parent, node);
-}
-
-static gboolean
-should_show_file (NautilusTreeModel *model, NautilusFile *file)
-{
- gboolean should;
- TreeNode *node;
-
- should = nautilus_file_should_show (file,
- model->details->show_hidden_files,
- model->details->show_backup_files);
-
- if (should
- && model->details->show_only_directories
- &&! nautilus_file_is_directory (file)) {
- should = FALSE;
- }
-
- if (should && nautilus_file_is_gone (file)) {
- should = FALSE;
- }
-
- for (node = model->details->root_node; node != NULL; node = node->next) {
- if (!should && node != NULL && file == node->file) {
- should = TRUE;
- }
- }
-
- return should;
-}
-
-static void
-update_node (NautilusTreeModel *model, TreeNode *node)
-{
- gboolean had_dummy_child, has_dummy_child;
- gboolean had_directory, has_directory;
- gboolean changed;
-
- if (!should_show_file (model, node->file)) {
- destroy_node (model, node);
- return;
- }
-
- if (node->parent != NULL && node->parent->directory != NULL
- && !nautilus_directory_contains_file (node->parent->directory, node->file)) {
- reparent_node (model, node);
- return;
- }
-
- had_dummy_child = tree_node_has_dummy_child (node);
- had_directory = node->directory != NULL;
-
- changed = update_node_without_reporting (model, node);
-
- has_dummy_child = tree_node_has_dummy_child (node);
- has_directory = node->directory != NULL;
-
- if (had_dummy_child != has_dummy_child) {
- if (has_dummy_child) {
- report_dummy_row_inserted (model, node);
- } else {
- report_dummy_row_deleted (model, node);
- }
- }
- if (had_directory != has_directory) {
- report_node_has_child_toggled (model, node);
- }
-
- if (changed) {
- report_node_contents_changed (model, node);
- }
-}
-
-static void
-process_file_change (NautilusTreeModelRoot *root,
- NautilusFile *file)
-{
- TreeNode *node, *parent;
-
- node = get_node_from_file (root, file);
- if (node != NULL) {
- update_node (root->model, node);
- return;
- }
-
- if (!should_show_file (root->model, file)) {
- return;
- }
-
- parent = get_parent_node_from_file (root, file);
- if (parent == NULL) {
- return;
- }
-
- insert_node (root->model, parent, create_node_for_file (root, file));
-}
-
-static void
-files_changed_callback (NautilusDirectory *directory,
- GList *changed_files,
- gpointer callback_data)
-{
- NautilusTreeModelRoot *root;
- GList *node;
-
- root = (NautilusTreeModelRoot *) (callback_data);
-
- for (node = changed_files; node != NULL; node = node->next) {
- process_file_change (root, NAUTILUS_FILE (node->data));
- }
-}
-
-static void
-set_done_loading (NautilusTreeModel *model, TreeNode *node, gboolean done_loading)
-{
- gboolean had_dummy;
-
- if (node == NULL || node->done_loading == done_loading) {
- return;
- }
-
- had_dummy = tree_node_has_dummy_child (node);
-
- node->done_loading = done_loading;
-
- if (tree_node_has_dummy_child (node)) {
- if (had_dummy) {
- report_dummy_row_contents_changed (model, node);
- } else {
- report_dummy_row_inserted (model, node);
- }
- } else {
- if (had_dummy) {
- report_dummy_row_deleted (model, node);
- } else {
- g_assert_not_reached ();
- }
- }
-}
-
-static void
-done_loading_callback (NautilusDirectory *directory,
- NautilusTreeModelRoot *root)
-{
- NautilusFile *file;
- TreeNode *node;
- GtkTreeIter iter;
-
- file = nautilus_directory_get_corresponding_file (directory);
- node = get_node_from_file (root, file);
- g_assert (node != NULL);
- set_done_loading (root->model, node, TRUE);
- nautilus_file_unref (file);
-
- make_iter_for_node (node, &iter, root->model->details->stamp);
- g_signal_emit_by_name (root->model, "row_loaded", &iter);
-}
-
-static NautilusFileAttributes
-get_tree_monitor_attributes (void)
-{
- NautilusFileAttributes attributes;
-
- attributes = nautilus_icon_factory_get_required_file_attributes ();
- attributes |= NAUTILUS_FILE_ATTRIBUTE_IS_DIRECTORY |
- NAUTILUS_FILE_ATTRIBUTE_DISPLAY_NAME;
-
- return attributes;
-}
-
-static void
-start_monitoring_directory (NautilusTreeModel *model, TreeNode *node)
-{
- NautilusDirectory *directory;
- NautilusFileAttributes attributes;
-
- if (node->done_loading_id != 0) {
- return;
- }
-
- g_assert (node->files_added_id == 0);
- g_assert (node->files_changed_id == 0);
-
- directory = node->directory;
-
- node->done_loading_id = g_signal_connect
- (directory, "done_loading",
- G_CALLBACK (done_loading_callback), node->root);
- node->files_added_id = g_signal_connect
- (directory, "files_added",
- G_CALLBACK (files_changed_callback), node->root);
- node->files_changed_id = g_signal_connect
- (directory, "files_changed",
- G_CALLBACK (files_changed_callback), node->root);
-
- set_done_loading (model, node, nautilus_directory_are_all_files_seen (directory));
-
- attributes = get_tree_monitor_attributes ();
- nautilus_directory_file_monitor_add (directory, model,
- model->details->show_hidden_files,
- model->details->show_backup_files,
- attributes, files_changed_callback, node->root);
-}
-
-static int
-nautilus_tree_model_get_n_columns (GtkTreeModel *model)
-{
- return NAUTILUS_TREE_MODEL_NUM_COLUMNS;
-}
-
-static GType
-nautilus_tree_model_get_column_type (GtkTreeModel *model, int index)
-{
- switch (index) {
- case NAUTILUS_TREE_MODEL_DISPLAY_NAME_COLUMN:
- return G_TYPE_STRING;
- case NAUTILUS_TREE_MODEL_CLOSED_PIXBUF_COLUMN:
- return GDK_TYPE_PIXBUF;
- case NAUTILUS_TREE_MODEL_OPEN_PIXBUF_COLUMN:
- return GDK_TYPE_PIXBUF;
- case NAUTILUS_TREE_MODEL_FONT_STYLE_COLUMN:
- return PANGO_TYPE_STYLE;
- case NAUTILUS_TREE_MODEL_FONT_WEIGHT_COLUMN:
- return PANGO_TYPE_WEIGHT;
- default:
- g_assert_not_reached ();
- }
-
- return G_TYPE_INVALID;
-}
-
-static gboolean
-iter_is_valid (NautilusTreeModel *model, const GtkTreeIter *iter)
-{
- TreeNode *node, *parent;
-
- if (iter->stamp != model->details->stamp) {
- return FALSE;
- }
-
- node = iter->user_data;
- parent = iter->user_data2;
- if (node == NULL) {
- if (parent != NULL) {
- if (!NAUTILUS_IS_FILE (parent->file)) {
- return FALSE;
- }
- if (!tree_node_has_dummy_child (parent)) {
- return FALSE;
- }
- }
- } else {
- if (!NAUTILUS_IS_FILE (node->file)) {
- return FALSE;
- }
- if (parent != NULL) {
- return FALSE;
- }
- }
- if (iter->user_data3 != NULL) {
- return FALSE;
- }
- return TRUE;
-}
-
-static gboolean
-nautilus_tree_model_get_iter (GtkTreeModel *model, GtkTreeIter *iter, GtkTreePath *path)
-{
- int *indices;
- GtkTreeIter parent;
- int depth, i;
-
- indices = gtk_tree_path_get_indices (path);
- depth = gtk_tree_path_get_depth (path);
-
- if (! gtk_tree_model_iter_nth_child (model, iter, NULL, indices[0])) {
- return FALSE;
- }
-
- for (i = 1; i < depth; i++) {
- parent = *iter;
-
- if (! gtk_tree_model_iter_nth_child (model, iter, &parent, indices[i])) {
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-static GtkTreePath *
-nautilus_tree_model_get_path (GtkTreeModel *model, GtkTreeIter *iter)
-{
- NautilusTreeModel *tree_model;
- TreeNode *node, *parent, *cnode;
- GtkTreePath *path;
- GtkTreeIter parent_iter;
- int i;
-
- g_return_val_if_fail (NAUTILUS_IS_TREE_MODEL (model), NULL);
- tree_model = NAUTILUS_TREE_MODEL (model);
- g_return_val_if_fail (iter_is_valid (tree_model, iter), NULL);
-
- node = iter->user_data;
- if (node == NULL) {
- parent = iter->user_data2;
- if (parent == NULL) {
- return gtk_tree_path_new ();
- }
- } else {
- parent = node->parent;
- if (parent == NULL) {
- i = 0;
- for (cnode = tree_model->details->root_node; cnode != node; cnode = cnode->next) {
- i++;
- }
- path = gtk_tree_path_new ();
- gtk_tree_path_append_index (path, i);
- return path;
- }
- }
-
- parent_iter.stamp = iter->stamp;
- parent_iter.user_data = parent;
- parent_iter.user_data2 = NULL;
- parent_iter.user_data3 = NULL;
-
- path = nautilus_tree_model_get_path (model, &parent_iter);
-
- gtk_tree_path_append_index (path, tree_node_get_child_index (parent, node));
-
- return path;
-}
-
-static void
-nautilus_tree_model_get_value (GtkTreeModel *model, GtkTreeIter *iter, int column, GValue *value)
-{
- TreeNode *node, *parent;
-
- g_return_if_fail (NAUTILUS_IS_TREE_MODEL (model));
- g_return_if_fail (iter_is_valid (NAUTILUS_TREE_MODEL (model), iter));
-
- node = iter->user_data;
-
- switch (column) {
- case NAUTILUS_TREE_MODEL_DISPLAY_NAME_COLUMN:
- g_value_init (value, G_TYPE_STRING);
- if (node == NULL) {
- parent = iter->user_data2;
- g_value_set_static_string (value, parent->done_loading
- ? _("(Empty)") : _("Loading..."));
- } else {
- g_value_set_string (value, tree_node_get_display_name (node));
- }
- break;
- case NAUTILUS_TREE_MODEL_CLOSED_PIXBUF_COLUMN:
- g_value_init (value, GDK_TYPE_PIXBUF);
- g_value_set_object (value, node == NULL ? NULL : tree_node_get_closed_pixbuf (node));
- break;
- case NAUTILUS_TREE_MODEL_OPEN_PIXBUF_COLUMN:
- g_value_init (value, GDK_TYPE_PIXBUF);
- g_value_set_object (value, node == NULL ? NULL : tree_node_get_open_pixbuf (node));
- break;
- case NAUTILUS_TREE_MODEL_FONT_STYLE_COLUMN:
- g_value_init (value, PANGO_TYPE_STYLE);
- if (node == NULL) {
- g_value_set_enum (value, PANGO_STYLE_ITALIC);
- } else {
- g_value_set_enum (value, PANGO_STYLE_NORMAL);
- }
- break;
- case NAUTILUS_TREE_MODEL_FONT_WEIGHT_COLUMN:
- g_value_init (value, PANGO_TYPE_STYLE);
- if (node != NULL && node->parent == NULL) {
- g_value_set_enum (value, PANGO_WEIGHT_BOLD);
- } else {
- g_value_set_enum (value, PANGO_WEIGHT_NORMAL);
- }
- break;
- default:
- g_assert_not_reached ();
- }
-}
-
-static gboolean
-nautilus_tree_model_iter_next (GtkTreeModel *model, GtkTreeIter *iter)
-{
- TreeNode *node, *parent, *next;
-
- g_return_val_if_fail (NAUTILUS_IS_TREE_MODEL (model), FALSE);
- g_return_val_if_fail (iter_is_valid (NAUTILUS_TREE_MODEL (model), iter), FALSE);
-
- node = iter->user_data;
-
- if (node == NULL) {
- parent = iter->user_data2;
- next = parent->first_child;
- } else {
- next = node->next;
- }
-
- return make_iter_for_node (next, iter, iter->stamp);
-}
-
-static gboolean
-nautilus_tree_model_iter_children (GtkTreeModel *model, GtkTreeIter *iter, GtkTreeIter *parent_iter)
-{
- TreeNode *parent;
-
- g_return_val_if_fail (NAUTILUS_IS_TREE_MODEL (model), FALSE);
- g_return_val_if_fail (iter_is_valid (NAUTILUS_TREE_MODEL (model), parent_iter), FALSE);
-
- parent = parent_iter->user_data;
- if (parent == NULL) {
- return make_iter_invalid (iter);
- }
-
- if (tree_node_has_dummy_child (parent)) {
- return make_iter_for_dummy_row (parent, iter, parent_iter->stamp);
- }
- return make_iter_for_node (parent->first_child, iter, parent_iter->stamp);
-}
-
-static gboolean
-nautilus_tree_model_iter_parent (GtkTreeModel *model, GtkTreeIter *iter, GtkTreeIter *child_iter)
-{ TreeNode *child, *parent;
-
- g_return_val_if_fail (NAUTILUS_IS_TREE_MODEL (model), FALSE);
- g_return_val_if_fail (iter_is_valid (NAUTILUS_TREE_MODEL (model), child_iter), FALSE);
-
- child = child_iter->user_data;
-
- if (child == NULL) {
- parent = child_iter->user_data2;
- } else {
- parent = child->parent;
- }
-
- return make_iter_for_node (parent, iter, child_iter->stamp);
-}
-
-static gboolean
-nautilus_tree_model_iter_has_child (GtkTreeModel *model, GtkTreeIter *iter)
-{
- gboolean has_child;
- TreeNode *node;
-
- g_return_val_if_fail (NAUTILUS_IS_TREE_MODEL (model), FALSE);
- g_return_val_if_fail (iter_is_valid (NAUTILUS_TREE_MODEL (model), iter), FALSE);
-
- node = iter->user_data;
-
- has_child = node != NULL && node->directory != NULL;
-
-#if 0
- g_warning ("Node '%s' %s",
- node && node->file ? nautilus_file_get_uri (node->file) : "no name",
- has_child ? "has child" : "no child");
-#endif
-
- return has_child;
-}
-
-static int
-nautilus_tree_model_iter_n_children (GtkTreeModel *model, GtkTreeIter *iter)
-{
- NautilusTreeModel *tree_model;
- TreeNode *parent, *node;
- int n;
-
- g_return_val_if_fail (NAUTILUS_IS_TREE_MODEL (model), FALSE);
- g_return_val_if_fail (iter == NULL || iter_is_valid (NAUTILUS_TREE_MODEL (model), iter), FALSE);
-
- tree_model = NAUTILUS_TREE_MODEL (model);
-
- if (iter == NULL) {
- return 1;
- }
-
- parent = iter->user_data;
- if (parent == NULL) {
- return 0;
- }
-
- n = tree_node_has_dummy_child (parent) ? 1 : 0;
- for (node = parent->first_child; node != NULL; node = node->next) {
- n++;
- }
-
- return n;
-}
-
-static gboolean
-nautilus_tree_model_iter_nth_child (GtkTreeModel *model, GtkTreeIter *iter,
- GtkTreeIter *parent_iter, int n)
-{
- NautilusTreeModel *tree_model;
- TreeNode *parent, *node;
- int i;
-
- g_return_val_if_fail (NAUTILUS_IS_TREE_MODEL (model), FALSE);
- g_return_val_if_fail (parent_iter == NULL
- || iter_is_valid (NAUTILUS_TREE_MODEL (model), parent_iter), FALSE);
-
- tree_model = NAUTILUS_TREE_MODEL (model);
-
- if (parent_iter == NULL) {
- node = tree_model->details->root_node;
- for (i = 0; i < n && node != NULL; i++, node = node->next);
- return make_iter_for_node (node, iter,
- tree_model->details->stamp);
- }
-
- parent = parent_iter->user_data;
- if (parent == NULL) {
- return make_iter_invalid (iter);
- }
-
- i = tree_node_has_dummy_child (parent) ? 1 : 0;
- if (n == 0 && i == 1) {
- return make_iter_for_dummy_row (parent, iter, parent_iter->stamp);
- }
- for (node = parent->first_child; i != n; i++, node = node->next) {
- if (node == NULL) {
- return make_iter_invalid (iter);
- }
- }
-
- return make_iter_for_node (node, iter, parent_iter->stamp);
-}
-
-static void
-update_monitoring (NautilusTreeModel *model, TreeNode *node)
-{
- TreeNode *child;
-
- if (node->all_children_ref_count == 0) {
- stop_monitoring_directory (model, node);
- destroy_children (model, node);
- } else {
- for (child = node->first_child; child != NULL; child = child->next) {
- update_monitoring (model, child);
- }
- start_monitoring_directory (model, node);
- }
-}
-
-static gboolean
-update_monitoring_idle_callback (gpointer callback_data)
-{
- NautilusTreeModel *model;
- TreeNode *node;
-
- model = NAUTILUS_TREE_MODEL (callback_data);
- model->details->monitoring_update_idle_id = 0;
- for (node = model->details->root_node; node != NULL; node = node->next) {
- update_monitoring (model, node);
- }
- return FALSE;
-}
-
-static void
-schedule_monitoring_update (NautilusTreeModel *model)
-{
- if (model->details->monitoring_update_idle_id == 0) {
- model->details->monitoring_update_idle_id =
- g_idle_add (update_monitoring_idle_callback, model);
- }
-}
-
-static void
-stop_monitoring_directory_and_children (NautilusTreeModel *model, TreeNode *node)
-{
- TreeNode *child;
-
- stop_monitoring_directory (model, node);
- for (child = node->first_child; child != NULL; child = child->next) {
- stop_monitoring_directory_and_children (model, child);
- }
-}
-
-static void
-stop_monitoring (NautilusTreeModel *model)
-{
- TreeNode *node;
-
- for (node = model->details->root_node; node != NULL; node = node->next) {
- stop_monitoring_directory_and_children (model, node);
- }
-}
-
-static void
-nautilus_tree_model_ref_node (GtkTreeModel *model, GtkTreeIter *iter)
-{
- TreeNode *node, *parent;
-#if LOG_REF_COUNTS
- char *uri;
-#endif
-
- g_return_if_fail (NAUTILUS_IS_TREE_MODEL (model));
- g_return_if_fail (iter_is_valid (NAUTILUS_TREE_MODEL (model), iter));
-
- node = iter->user_data;
- if (node == NULL) {
- parent = iter->user_data2;
- g_assert (parent->dummy_child_ref_count >= 0);
- ++parent->dummy_child_ref_count;
- } else {
- parent = node->parent;
- g_assert (node->ref_count >= 0);
- ++node->ref_count;
- }
-
- if (parent != NULL) {
- g_assert (parent->all_children_ref_count >= 0);
- if (++parent->all_children_ref_count == 1) {
- if (parent->first_child == NULL) {
- parent->done_loading = FALSE;
- }
- schedule_monitoring_update (NAUTILUS_TREE_MODEL (model));
- }
-#if LOG_REF_COUNTS
- uri = get_node_uri (iter);
- g_message ("ref of %s, count is now %d",
- uri, parent->all_children_ref_count);
- g_free (uri);
-#endif
- }
-}
-
-static void
-nautilus_tree_model_unref_node (GtkTreeModel *model, GtkTreeIter *iter)
-{
- TreeNode *node, *parent;
-#if LOG_REF_COUNTS
- char *uri;
-#endif
-
- g_return_if_fail (NAUTILUS_IS_TREE_MODEL (model));
- g_return_if_fail (iter_is_valid (NAUTILUS_TREE_MODEL (model), iter));
-
- node = iter->user_data;
- if (node == NULL) {
- parent = iter->user_data2;
- g_assert (parent->dummy_child_ref_count > 0);
- --parent->dummy_child_ref_count;
- } else {
- parent = node->parent;
- g_assert (node->ref_count > 0);
- --node->ref_count;
- }
-
- if (parent != NULL) {
- g_assert (parent->all_children_ref_count > 0);
-#if LOG_REF_COUNTS
- uri = get_node_uri (iter);
- g_message ("unref of %s, count is now %d",
- uri, parent->all_children_ref_count - 1);
- g_free (uri);
-#endif
- if (--parent->all_children_ref_count == 0) {
- schedule_monitoring_update (NAUTILUS_TREE_MODEL (model));
- }
- }
-}
-
-static void
-root_node_file_changed_callback (NautilusFile *file, NautilusTreeModelRoot *root)
-{
- if (root->root_node != NULL) {
- update_node (root->model, root->root_node);
- }
-}
-
-void
-nautilus_tree_model_add_root_uri (NautilusTreeModel *model, const char *root_uri, const char *display_name, const char *icon_name)
-{
- NautilusFile *file;
- TreeNode *node, *cnode;
- NautilusFileAttributes attributes;
- NautilusTreeModelRoot *newroot;
-
- file = nautilus_file_get (root_uri);
-
- newroot = tree_model_root_new (model);
- node = create_node_for_file (newroot, file);
- node->display_name = g_strdup (display_name);
- node->icon_name = g_strdup (icon_name);
- newroot->root_node = node;
- node->parent = NULL;
- if (model->details->root_node == NULL) {
- model->details->root_node = node;
- } else {
- /* append it */
- for (cnode = model->details->root_node; cnode->next != NULL; cnode = cnode->next);
- cnode->next = node;
- node->prev = cnode;
- }
-
- newroot->changed_handler_id = g_signal_connect (node->file, "changed",
- G_CALLBACK (root_node_file_changed_callback),
- node->root);
-
- attributes = get_tree_monitor_attributes ();
- nautilus_file_monitor_add (file, model, attributes);
-
- nautilus_file_unref (file);
-
- update_node_without_reporting (model, node);
- report_node_inserted (model, node);
-}
-
-void
-nautilus_tree_model_remove_root_uri (NautilusTreeModel *model, const char *uri)
-{
- TreeNode *node;
- GtkTreePath *path;
- NautilusTreeModelRoot *root;
- NautilusFile *file;
-
- file = nautilus_file_get (uri);
- for (node = model->details->root_node; node != NULL; node = node->next) {
- if (file == node->file) {
- break;
- }
- }
- nautilus_file_unref (file);
-
- if (node) {
- /* remove the node */
- nautilus_file_monitor_remove (node->file, model);
- path = get_node_path (model, node);
-
- if (node->prev) {
- node->prev->next = node->next;
- }
- if (node->next) {
- node->next->prev = node->prev;
- }
- if (node == model->details->root_node) {
- model->details->root_node = node->next;
- }
-
- /* destroy the root identifier */
- root = node->root;
- destroy_node_without_reporting (model, node);
- g_hash_table_destroy (root->file_to_node_map);
- g_free (root);
- gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
- gtk_tree_path_free (path);
- }
-}
-
-NautilusTreeModel *
-nautilus_tree_model_new (void)
-{
- NautilusTreeModel *model;
-
- model = g_object_new (NAUTILUS_TYPE_TREE_MODEL, NULL);
-
- return model;
-}
-
-static void
-set_theme (TreeNode *node, NautilusTreeModel *model)
-{
- TreeNode *child;
-
- tree_node_update_closed_pixbuf (node);
- tree_node_update_open_pixbuf (node);
-
- report_node_contents_changed (model, node);
-
- for (child = node->first_child; child != NULL; child = child->next) {
- set_theme (child, model);
- }
-}
-
-void
-nautilus_tree_model_set_theme (NautilusTreeModel *model)
-{
- TreeNode *node;
-
- g_return_if_fail (NAUTILUS_IS_TREE_MODEL (model));
-
- node = model->details->root_node;
- while (node != NULL) {
- set_theme (node, model);
- node = node->next;
- }
-}
-
-
-void
-nautilus_tree_model_set_show_hidden_files (NautilusTreeModel *model,
- gboolean show_hidden_files)
-{
- g_return_if_fail (NAUTILUS_IS_TREE_MODEL (model));
- g_return_if_fail (show_hidden_files == FALSE || show_hidden_files == TRUE);
-
- show_hidden_files = show_hidden_files != FALSE;
- if (model->details->show_hidden_files == show_hidden_files) {
- return;
- }
- model->details->show_hidden_files = show_hidden_files;
- stop_monitoring (model);
- if (!show_hidden_files) {
- destroy_by_function (model, nautilus_file_is_hidden_file);
- }
- schedule_monitoring_update (model);
-}
-
-void
-nautilus_tree_model_set_show_backup_files (NautilusTreeModel *model,
- gboolean show_backup_files)
-{
- g_return_if_fail (NAUTILUS_IS_TREE_MODEL (model));
- g_return_if_fail (show_backup_files == FALSE || show_backup_files == TRUE);
-
- show_backup_files = show_backup_files != FALSE;
- if (model->details->show_backup_files == show_backup_files) {
- return;
- }
- model->details->show_backup_files = show_backup_files;
- stop_monitoring (model);
- if (!show_backup_files) {
- destroy_by_function (model, nautilus_file_is_backup_file);
- }
- schedule_monitoring_update (model);
-}
-
-static gboolean
-file_is_not_directory (NautilusFile *file)
-{
- return !nautilus_file_is_directory (file);
-}
-
-void
-nautilus_tree_model_set_show_only_directories (NautilusTreeModel *model,
- gboolean show_only_directories)
-{
- g_return_if_fail (NAUTILUS_IS_TREE_MODEL (model));
- g_return_if_fail (show_only_directories == FALSE || show_only_directories == TRUE);
-
- show_only_directories = show_only_directories != FALSE;
- if (model->details->show_only_directories == show_only_directories) {
- return;
- }
- model->details->show_only_directories = show_only_directories;
- stop_monitoring (model);
- if (show_only_directories) {
- destroy_by_function (model, file_is_not_directory);
- }
- schedule_monitoring_update (model);
-}
-
-NautilusFile *
-nautilus_tree_model_iter_get_file (NautilusTreeModel *model, GtkTreeIter *iter)
-{
- TreeNode *node;
-
- g_return_val_if_fail (NAUTILUS_IS_TREE_MODEL (model), 0);
- g_return_val_if_fail (iter_is_valid (NAUTILUS_TREE_MODEL (model), iter), 0);
-
- node = iter->user_data;
- return node == NULL ? NULL : nautilus_file_ref (node->file);
-}
-
-gboolean
-nautilus_tree_model_iter_is_root (NautilusTreeModel *model, GtkTreeIter *iter)
-{
- TreeNode *node;
-
- g_return_val_if_fail (NAUTILUS_IS_TREE_MODEL (model), 0);
- g_return_val_if_fail (iter_is_valid (model, iter), 0);
- node = iter->user_data;
- if (node == NULL) {
- return FALSE;
- } else {
- return (node->parent == NULL);
- }
-}
-
-gboolean
-nautilus_tree_model_file_get_iter (NautilusTreeModel *model,
- GtkTreeIter *iter,
- NautilusFile *file,
- GtkTreeIter *current_iter)
-{
- TreeNode *node, *root_node;
-
- if (current_iter != NULL && current_iter->user_data != NULL) {
- node = get_node_from_file (((TreeNode *) current_iter->user_data)->root, file);
- return make_iter_for_node (node, iter, model->details->stamp);
- }
-
- for (root_node = model->details->root_node; root_node != NULL; root_node = root_node->next) {
- node = get_node_from_file (root_node->root, file);
- if (node != NULL) {
- return make_iter_for_node (node, iter, model->details->stamp);
- }
- }
- return FALSE;
-}
-
-static void
-nautilus_tree_model_init (NautilusTreeModel *model)
-{
- model->details = g_new0 (NautilusTreeModelDetails, 1);
-
- do {
- model->details->stamp = g_random_int ();
- } while (model->details->stamp == 0);
-}
-
-static void
-nautilus_tree_model_finalize (GObject *object)
-{
- NautilusTreeModel *model;
- TreeNode *root_node, *next_root;
- NautilusTreeModelRoot *root;
-
- model = NAUTILUS_TREE_MODEL (object);
-
- for (root_node = model->details->root_node; root_node != NULL; root_node = next_root) {
- next_root = root_node->next;
- root = root_node->root;
- g_signal_handler_disconnect (root_node->file, root->changed_handler_id);
- nautilus_file_monitor_remove (root_node->file, model);
- destroy_node_without_reporting (model, root_node);
- g_hash_table_destroy (root->file_to_node_map);
- g_free (root);
- }
-
- if (model->details->monitoring_update_idle_id != 0) {
- g_source_remove (model->details->monitoring_update_idle_id);
- }
-
- g_free (model->details);
-
- parent_class->finalize (object);
-}
-
-static void
-nautilus_tree_model_class_init (NautilusTreeModelClass *class)
-{
- parent_class = g_type_class_peek_parent (class);
-
- G_OBJECT_CLASS (class)->finalize = nautilus_tree_model_finalize;
-
- tree_model_signals[ROW_LOADED] =
- g_signal_new ("row_loaded",
- NAUTILUS_TYPE_TREE_MODEL,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (NautilusTreeModelClass, row_loaded),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOXED,
- G_TYPE_NONE, 1,
- GTK_TYPE_TREE_ITER);
-}
-
-static void
-nautilus_tree_model_tree_model_init (GtkTreeModelIface *iface)
-{
- iface->get_flags = nautilus_tree_model_get_flags;
- iface->get_n_columns = nautilus_tree_model_get_n_columns;
- iface->get_column_type = nautilus_tree_model_get_column_type;
- iface->get_iter = nautilus_tree_model_get_iter;
- iface->get_path = nautilus_tree_model_get_path;
- iface->get_value = nautilus_tree_model_get_value;
- iface->iter_next = nautilus_tree_model_iter_next;
- iface->iter_children = nautilus_tree_model_iter_children;
- iface->iter_has_child = nautilus_tree_model_iter_has_child;
- iface->iter_n_children = nautilus_tree_model_iter_n_children;
- iface->iter_nth_child = nautilus_tree_model_iter_nth_child;
- iface->iter_parent = nautilus_tree_model_iter_parent;
- iface->ref_node = nautilus_tree_model_ref_node;
- iface->unref_node = nautilus_tree_model_unref_node;
-}
-
-GType
-nautilus_tree_model_get_type (void)
-{
- static GType object_type = 0;
-
- if (object_type == 0) {
- static const GTypeInfo object_info = {
- sizeof (NautilusTreeModelClass),
- NULL,
- NULL,
- (GClassInitFunc) nautilus_tree_model_class_init,
- NULL,
- NULL,
- sizeof (NautilusTreeModel),
- 0,
- (GInstanceInitFunc) nautilus_tree_model_init,
- };
-
- static const GInterfaceInfo tree_model_info = {
- (GInterfaceInitFunc) nautilus_tree_model_tree_model_init,
- NULL,
- NULL
- };
-
- object_type = g_type_register_static (G_TYPE_OBJECT, "NautilusTreeModel", &object_info, 0);
- g_type_add_interface_static (object_type,
- GTK_TYPE_TREE_MODEL,
- &tree_model_info);
- }
-
- return object_type;
-}
diff --git a/components/tree/nautilus-tree-model.h b/components/tree/nautilus-tree-model.h
deleted file mode 100644
index f41a05740..000000000
--- a/components/tree/nautilus-tree-model.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/*
- * Copyright (C) 2002 Anders Carlsson
- * Copyright (C) 2002 Bent Spoon Software
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: Anders Carlsson <andersca@gnu.org>
- */
-
-/* nautilus-tree-model.h - Model for the tree view */
-
-#ifndef NAUTILUS_TREE_MODEL_H
-#define NAUTILUS_TREE_MODEL_H
-
-#include <glib-object.h>
-#include <gtk/gtktreemodel.h>
-#include <libnautilus-private/nautilus-file.h>
-
-#define NAUTILUS_TYPE_TREE_MODEL (nautilus_tree_model_get_type ())
-#define NAUTILUS_TREE_MODEL(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_TREE_MODEL, NautilusTreeModel))
-#define NAUTILUS_TREE_MODEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_TREE_MODEL, NautilusTreeModelClass))
-#define NAUTILUS_IS_TREE_MODEL(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_TREE_MODEL))
-#define NAUTILUS_IS_TREE_MODEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_TREE_MODEL))
-
-enum {
- NAUTILUS_TREE_MODEL_DISPLAY_NAME_COLUMN,
- NAUTILUS_TREE_MODEL_CLOSED_PIXBUF_COLUMN,
- NAUTILUS_TREE_MODEL_OPEN_PIXBUF_COLUMN,
- NAUTILUS_TREE_MODEL_FONT_STYLE_COLUMN,
- NAUTILUS_TREE_MODEL_FONT_WEIGHT_COLUMN,
- NAUTILUS_TREE_MODEL_NUM_COLUMNS
-};
-
-typedef struct NautilusTreeModelDetails NautilusTreeModelDetails;
-
-typedef struct {
- GObject parent;
- NautilusTreeModelDetails *details;
-} NautilusTreeModel;
-
-typedef struct {
- GObjectClass parent_class;
-
- void (* row_loaded) (NautilusTreeModel *tree_model,
- GtkTreeIter *iter);
-} NautilusTreeModelClass;
-
-GType nautilus_tree_model_get_type (void);
-NautilusTreeModel *nautilus_tree_model_new (void);
-void nautilus_tree_model_set_show_hidden_files (NautilusTreeModel *model,
- gboolean show_hidden_files);
-void nautilus_tree_model_set_show_backup_files (NautilusTreeModel *model,
- gboolean show_backup_files);
-void nautilus_tree_model_set_show_only_directories (NautilusTreeModel *model,
- gboolean show_only_directories);
-NautilusFile * nautilus_tree_model_iter_get_file (NautilusTreeModel *model,
- GtkTreeIter *iter);
-void nautilus_tree_model_add_root_uri (NautilusTreeModel *model,
- const char *root_uri,
- const char *display_name,
- const char *icon_name);
-void nautilus_tree_model_remove_root_uri (NautilusTreeModel *model,
- const char *root_uri);
-gboolean nautilus_tree_model_iter_is_root (NautilusTreeModel *model,
- GtkTreeIter *iter);
-gboolean nautilus_tree_model_file_get_iter (NautilusTreeModel *model,
- GtkTreeIter *iter,
- NautilusFile *file,
- GtkTreeIter *currentIter);
-
-void nautilus_tree_model_set_theme (NautilusTreeModel *model);
-
-#endif /* NAUTILUS_TREE_MODEL_H */
diff --git a/components/tree/nautilus-tree-view-iids.h b/components/tree/nautilus-tree-view-iids.h
deleted file mode 100644
index e9309a6d5..000000000
--- a/components/tree/nautilus-tree-view-iids.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/*
- * Copyright (C) 2000 Eazel, Inc
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: Maciej Stachowiak <mjs@eazel.com>
- */
-
-/* nautilus-tree-view-iids.h - IIDs for tree view */
-
-#ifndef NAUTILUS_TREE_VIEW_IIDS_H
-#define NAUTILUS_TREE_VIEW_IIDS_H
-
-#define TREE_VIEW_IID "OAFIID:Nautilus_Tree_View"
-#define TREE_VIEW_FACTORY_IID "OAFIID:Nautilus_Tree_View_Factory"
-
-#endif /* NAUTILUS_TREE_VIEW_IIDS_H */
diff --git a/components/tree/nautilus-tree-view.c b/components/tree/nautilus-tree-view.c
deleted file mode 100644
index 6c64df02f..000000000
--- a/components/tree/nautilus-tree-view.c
+++ /dev/null
@@ -1,743 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/*
- * Copyright (C) 2000, 2001 Eazel, Inc
- * Copyright (C) 2002 Anders Carlsson
- * Copyright (C) 2002 Darin Adler
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Authors:
- * Maciej Stachowiak <mjs@eazel.com>
- * Anders Carlsson <andersca@gnu.org>
- * Darin Adler <darin@bentspoon.com>
- */
-
-/* nautilus-tree-view.c - tree sidebar panel
- */
-
-#include <config.h>
-#include "nautilus-tree-view.h"
-
-#include "nautilus-tree-model.h"
-#include <eel/eel-glib-extensions.h>
-#include <eel/eel-preferences.h>
-#include <eel/eel-string.h>
-#include <gtk/gtkcellrendererpixbuf.h>
-#include <gtk/gtkcellrenderertext.h>
-#include <gtk/gtkscrolledwindow.h>
-#include <gtk/gtktreemodelsort.h>
-#include <gtk/gtktreeselection.h>
-#include <gtk/gtktreeview.h>
-#include <libgnome/gnome-i18n.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-volume-monitor.h>
-#include <libnautilus-private/nautilus-file-attributes.h>
-#include <libnautilus-private/nautilus-file-operations.h>
-#include <libnautilus-private/nautilus-global-preferences.h>
-#include <libnautilus-private/nautilus-program-choosing.h>
-#include <libnautilus-private/nautilus-tree-view-drag-dest.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
-
-struct NautilusTreeViewDetails {
- GtkWidget *scrolled_window;
- GtkTreeView *tree_widget;
- GtkTreeModelSort *sort_model;
- NautilusTreeModel *child_model;
-
- NautilusFile *activation_file;
-
- NautilusTreeViewDragDest *drag_dest;
-
- char *selection_location;
- gboolean selecting;
-
- guint show_selection_idle_id;
-};
-
-typedef struct {
- GList *uris;
- NautilusTreeView *view;
-} PrependURIParameters;
-
-BONOBO_CLASS_BOILERPLATE (NautilusTreeView, nautilus_tree_view,
- NautilusView, NAUTILUS_TYPE_VIEW)
-
-static gboolean
-show_iter_for_file (NautilusTreeView *view, NautilusFile *file, GtkTreeIter *iter)
-{
- GtkTreeModel *model;
- NautilusFile *parent_file;
- GtkTreeIter parent_iter;
- GtkTreePath *path, *sort_path;
- GtkTreeIter cur_iter;
-
- if (view->details->child_model == NULL) {
- return FALSE;
- }
- model = GTK_TREE_MODEL (view->details->child_model);
-
- /* check if file is visible in the same root as the currently selected folder is */
- gtk_tree_view_get_cursor (view->details->tree_widget, &path, NULL);
- if (path != NULL) {
- if (gtk_tree_model_get_iter (model, &cur_iter, path)) {
- if (nautilus_tree_model_file_get_iter (view->details->child_model,
- iter, file, &cur_iter)) {
- return TRUE;
- }
- }
- }
- /* check if file is visible at all */
- if (nautilus_tree_model_file_get_iter (view->details->child_model,
- iter, file, NULL)) {
- return TRUE;
- }
-
- parent_file = nautilus_file_get_parent (file);
-
- if (parent_file == NULL) {
- return FALSE;
- }
- if (!show_iter_for_file (view, parent_file, &parent_iter)) {
- nautilus_file_unref (parent_file);
- return FALSE;
- }
- nautilus_file_unref (parent_file);
-
- if (parent_iter.user_data == NULL || parent_iter.stamp == 0) {
- return FALSE;
- }
- path = gtk_tree_model_get_path (model, &parent_iter);
- sort_path = gtk_tree_model_sort_convert_child_path_to_path
- (view->details->sort_model, path);
- gtk_tree_path_free (path);
- gtk_tree_view_expand_row (view->details->tree_widget, sort_path, FALSE);
- gtk_tree_path_free (sort_path);
-
- return FALSE;
-}
-
-static gboolean
-show_selection_idle_callback (gpointer callback_data)
-{
- NautilusTreeView *view;
- NautilusFile *file, *old_file;
- GtkTreeIter iter;
- GtkTreePath *path, *sort_path;
-
- view = NAUTILUS_TREE_VIEW (callback_data);
-
- view->details->show_selection_idle_id = 0;
-
- file = nautilus_file_get (view->details->selection_location);
- if (file == NULL) {
- return FALSE;
- }
-
- if (!nautilus_file_is_directory (file)) {
- old_file = file;
- file = nautilus_file_get_parent (file);
- nautilus_file_unref (old_file);
- if (file == NULL) {
- return FALSE;
- }
- }
-
- view->details->selecting = TRUE;
- if (!show_iter_for_file (view, file, &iter)) {
- nautilus_file_unref (file);
- return FALSE;
- }
- view->details->selecting = FALSE;
-
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->details->child_model), &iter);
- sort_path = gtk_tree_model_sort_convert_child_path_to_path
- (view->details->sort_model, path);
- gtk_tree_path_free (path);
- gtk_tree_view_set_cursor (view->details->tree_widget, sort_path, NULL, FALSE);
- gtk_tree_view_scroll_to_cell (view->details->tree_widget, sort_path, NULL, FALSE, 0, 0);
- gtk_tree_path_free (sort_path);
-
- nautilus_file_unref (file);
-
- return FALSE;
-}
-
-static void
-schedule_show_selection (NautilusTreeView *view)
-{
- if (view->details->show_selection_idle_id == 0) {
- view->details->show_selection_idle_id = g_idle_add (show_selection_idle_callback, view);
- }
-}
-
-static void
-row_loaded_callback (GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- NautilusTreeView *view)
-{
- NautilusFile *file, *tmp_file, *selection_file;
-
- if (view->details->selection_location == NULL
- || !view->details->selecting
- || iter->user_data == NULL || iter->stamp == 0) {
- return;
- }
-
- file = nautilus_tree_model_iter_get_file (view->details->child_model, iter);
- if (file == NULL) {
- return;
- }
- if (!nautilus_file_is_directory (file)) {
- nautilus_file_unref(file);
- return;
- }
-
- /* if iter is ancestor of wanted selection_location then update selection */
- selection_file = nautilus_file_get (view->details->selection_location);
- while (selection_file != NULL) {
- if (file == selection_file) {
- nautilus_file_unref (file);
- nautilus_file_unref (selection_file);
-
- schedule_show_selection (view);
- return;
- }
- tmp_file = nautilus_file_get_parent (selection_file);
- nautilus_file_unref (selection_file);
- selection_file = tmp_file;
- }
- nautilus_file_unref (file);
-}
-
-static NautilusFile *
-sort_model_iter_to_file (NautilusTreeView *view, GtkTreeIter *iter)
-{
- GtkTreeIter child_iter;
-
- gtk_tree_model_sort_convert_iter_to_child_iter (view->details->sort_model, &child_iter, iter);
- return nautilus_tree_model_iter_get_file (view->details->child_model, &child_iter);
-}
-
-static NautilusFile *
-sort_model_path_to_file (NautilusTreeView *view, GtkTreePath *path)
-{
- GtkTreeIter iter;
-
- if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (view->details->sort_model), &iter, path)) {
- return NULL;
- }
- return sort_model_iter_to_file (view, &iter);
-}
-
-static void
-got_activation_uri_callback (NautilusFile *file, gpointer callback_data)
-{
- char *uri, *file_uri;
- NautilusTreeView *view;
- GdkScreen *screen;
-
- view = NAUTILUS_TREE_VIEW (callback_data);
-
- screen = gtk_widget_get_screen (GTK_WIDGET (view->details->tree_widget));
-
- g_assert (file == view->details->activation_file);
-
- /* FIXME: reenable && !eel_uris_match_ignore_fragments (view->details->current_main_view_uri, uri) */
-
- uri = nautilus_file_get_activation_uri (file);
- if (uri != NULL
- && eel_str_has_prefix (uri, NAUTILUS_COMMAND_SPECIFIER)) {
-
- uri += strlen (NAUTILUS_COMMAND_SPECIFIER);
- nautilus_launch_application_from_command (screen, NULL, uri, NULL, FALSE);
-
- } else if (uri != NULL
- && eel_str_has_prefix (uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
-
- file_uri = nautilus_file_get_uri (file);
- nautilus_launch_desktop_file (screen, file_uri, NULL, NULL);
- g_free (file_uri);
-
- } else if (uri != NULL
- && nautilus_file_is_executable (file)
- && nautilus_file_can_execute (file)
- && !nautilus_file_is_directory (file)) {
-
- file_uri = gnome_vfs_get_local_path_from_uri (uri);
-
- /* Non-local executables don't get launched. They act like non-executables. */
- if (file_uri == NULL) {
- nautilus_view_open_location
- (NAUTILUS_VIEW (view),
- uri,
- Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE,
- 0,
- NULL);
- } else {
- nautilus_launch_application_from_command (screen, NULL, file_uri, NULL, FALSE);
- g_free (file_uri);
- }
-
- } else if (uri != NULL) {
- if (view->details->selection_location == NULL ||
- strcmp (uri, view->details->selection_location) != 0) {
- if (view->details->selection_location != NULL) {
- g_free (view->details->selection_location);
- }
- view->details->selection_location = g_strdup (uri);
- nautilus_view_open_location
- (NAUTILUS_VIEW (view),
- uri,
- Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE,
- 0,
- NULL);
- }
- }
-
- g_free (uri);
- nautilus_file_unref (view->details->activation_file);
- view->details->activation_file = NULL;
-}
-
-static void
-cancel_activation (NautilusTreeView *view)
-{
- if (view->details->activation_file == NULL) {
- return;
- }
-
- nautilus_file_cancel_call_when_ready
- (view->details->activation_file,
- got_activation_uri_callback, view);
- nautilus_file_unref (view->details->activation_file);
- view->details->activation_file = NULL;
-}
-
-static void
-row_activated_callback (GtkTreeView *treeview, GtkTreePath *path,
- GtkTreeViewColumn *column, NautilusTreeView *view)
-{
- if (gtk_tree_view_row_expanded (view->details->tree_widget, path)) {
- gtk_tree_view_collapse_row (view->details->tree_widget, path);
- } else {
- gtk_tree_view_expand_row (view->details->tree_widget,
- path, FALSE);
- }
-}
-
-
-static void
-selection_changed_callback (GtkTreeSelection *selection,
- NautilusTreeView *view)
-{
- NautilusFileAttributes attributes;
- GtkTreeIter iter;
-
- cancel_activation (view);
-
- if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) {
- return;
- }
-
- view->details->activation_file = sort_model_iter_to_file (view, &iter);
- if (view->details->activation_file == NULL) {
- return;
- }
-
- attributes = NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI;
- nautilus_file_call_when_ready (view->details->activation_file, attributes,
- got_activation_uri_callback, view);
-}
-
-static int
-compare_rows (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer callback_data)
-{
- NautilusFile *file_a, *file_b;
- int result;
-
- if (a->user_data == NULL) {
- return -1;
- }
- else if (b->user_data == NULL) {
- return -1;
- }
-
- /* don't sort root nodes */
- if (nautilus_tree_model_iter_is_root (NAUTILUS_TREE_MODEL (model), a)
- || nautilus_tree_model_iter_is_root (NAUTILUS_TREE_MODEL (model), b)) {
- return 0;
- }
-
- file_a = nautilus_tree_model_iter_get_file (NAUTILUS_TREE_MODEL (model), a);
- file_b = nautilus_tree_model_iter_get_file (NAUTILUS_TREE_MODEL (model), b);
-
- if (file_a == file_b) {
- result = 0;
- } else if (file_a == NULL) {
- result = -1;
- } else if (file_b == NULL) {
- result = +1;
- } else {
- result = nautilus_file_compare_for_sort (file_a, file_b,
- NAUTILUS_FILE_SORT_BY_DISPLAY_NAME,
- FALSE, FALSE);
- }
-
- nautilus_file_unref (file_a);
- nautilus_file_unref (file_b);
-
- return result;
-}
-
-
-static char *
-get_root_uri_callback (NautilusTreeViewDragDest *dest,
- gpointer user_data)
-{
- NautilusTreeView *view;
-
- view = NAUTILUS_TREE_VIEW (user_data);
-
- /* Don't allow drops on background */
- return NULL;
-}
-
-static NautilusFile *
-get_file_for_path_callback (NautilusTreeViewDragDest *dest,
- GtkTreePath *path,
- gpointer user_data)
-{
- NautilusTreeView *view;
-
- view = NAUTILUS_TREE_VIEW (user_data);
-
- return sort_model_path_to_file (view, path);
-}
-
-static void
-move_copy_items_callback (NautilusTreeViewDragDest *dest,
- const GList *item_uris,
- const char *target_uri,
- guint action,
- int x,
- int y,
- gpointer user_data)
-{
- NautilusTreeView *view;
-
- view = NAUTILUS_TREE_VIEW (user_data);
-
- nautilus_file_operations_copy_move
- (item_uris,
- NULL,
- target_uri,
- action,
- GTK_WIDGET (view->details->tree_widget),
- NULL, NULL);
-}
-
-static void
-theme_changed_callback (GObject *icon_factory, gpointer callback_data)
-{
- NautilusTreeView *view;
-
- view = NAUTILUS_TREE_VIEW (callback_data);
- if (view->details->child_model != NULL) {
- nautilus_tree_model_set_theme (NAUTILUS_TREE_MODEL (view->details->child_model));
- }
-}
-
-static void
-add_root_for_volume (NautilusTreeView *view,
- GnomeVFSVolume *volume)
-{
- char *icon, *mount_uri, *name;
-
- if (!gnome_vfs_volume_is_user_visible (volume)) {
- return;
- }
-
- icon = gnome_vfs_volume_get_icon (volume);
- mount_uri = gnome_vfs_volume_get_activation_uri (volume);
- name = gnome_vfs_volume_get_display_name (volume);
-
- nautilus_tree_model_add_root_uri (view->details->child_model,
- mount_uri, name, icon);
-
- g_free (icon);
- g_free (name);
- g_free (mount_uri);
-
-}
-
-static void
-volume_mounted_callback (GnomeVFSVolumeMonitor *volume_monitor,
- GnomeVFSVolume *volume,
- NautilusTreeView *view)
-{
- add_root_for_volume (view, volume);
-}
-
-static void
-volume_unmounted_callback (GnomeVFSVolumeMonitor *volume_monitor,
- GnomeVFSVolume *volume,
- NautilusTreeView *view)
-{
- char *mount_uri;
-
- mount_uri = gnome_vfs_volume_get_activation_uri (volume);
- nautilus_tree_model_remove_root_uri (view->details->child_model,
- mount_uri);
- g_free (mount_uri);
-}
-
-
-static void
-create_tree (NautilusTreeView *view)
-{
- GtkCellRenderer *cell;
- GtkTreeViewColumn *column;
- GnomeVFSVolumeMonitor *volume_monitor;
- char *home_uri;
- GList *volumes, *l;
-
- view->details->child_model = nautilus_tree_model_new ();
- view->details->sort_model = GTK_TREE_MODEL_SORT
- (gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (view->details->child_model)));
- view->details->tree_widget = GTK_TREE_VIEW
- (gtk_tree_view_new_with_model (GTK_TREE_MODEL (view->details->sort_model)));
- g_object_unref (view->details->sort_model);
- g_signal_connect_object
- (view->details->child_model, "row_loaded",
- G_CALLBACK (row_loaded_callback),
- view, G_CONNECT_AFTER);
- home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
- nautilus_tree_model_add_root_uri (view->details->child_model, home_uri, _("Home Folder"), "gnome-home");
- g_free (home_uri);
- nautilus_tree_model_add_root_uri (view->details->child_model, "file:///", _("Filesystem"), "gnome-folder");
-#ifdef NOT_YET_USABLE
- nautilus_tree_model_add_root_uri (view->details->child_model, "network:///", _("Network Neighbourhood"), "gnome-fs-network");
-#endif
-
- volume_monitor = gnome_vfs_get_volume_monitor ();
- volumes = gnome_vfs_volume_monitor_get_mounted_volumes (volume_monitor);
- for (l = volumes; l != NULL; l = l->next) {
- add_root_for_volume (view, l->data);
- gnome_vfs_volume_unref (l->data);
- }
- g_list_free (volumes);
-
- g_signal_connect_object (volume_monitor, "volume_mounted",
- G_CALLBACK (volume_mounted_callback), view, 0);
- g_signal_connect_object (volume_monitor, "volume_unmounted",
- G_CALLBACK (volume_unmounted_callback), view, 0);
-
- g_object_unref (view->details->child_model);
-
- gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (view->details->sort_model),
- compare_rows, view, NULL);
-
- gtk_tree_view_set_headers_visible (view->details->tree_widget, FALSE);
-
- view->details->drag_dest =
- nautilus_tree_view_drag_dest_new (view->details->tree_widget);
- g_signal_connect_object (view->details->drag_dest,
- "get_root_uri",
- G_CALLBACK (get_root_uri_callback),
- view, 0);
- g_signal_connect_object (view->details->drag_dest,
- "get_file_for_path",
- G_CALLBACK (get_file_for_path_callback),
- view, 0);
- g_signal_connect_object (view->details->drag_dest,
- "move_copy_items",
- G_CALLBACK (move_copy_items_callback),
- view, 0);
-
- /* Create column */
- column = gtk_tree_view_column_new ();
-
- cell = gtk_cell_renderer_pixbuf_new ();
- gtk_tree_view_column_pack_start (column, cell, FALSE);
- gtk_tree_view_column_set_attributes (column, cell,
- "pixbuf", NAUTILUS_TREE_MODEL_CLOSED_PIXBUF_COLUMN,
- "pixbuf_expander_closed", NAUTILUS_TREE_MODEL_CLOSED_PIXBUF_COLUMN,
- "pixbuf_expander_open", NAUTILUS_TREE_MODEL_OPEN_PIXBUF_COLUMN,
- NULL);
-
- cell = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (column, cell, TRUE);
- gtk_tree_view_column_set_attributes (column, cell,
- "text", NAUTILUS_TREE_MODEL_DISPLAY_NAME_COLUMN,
- "style", NAUTILUS_TREE_MODEL_FONT_STYLE_COLUMN,
- "weight", NAUTILUS_TREE_MODEL_FONT_WEIGHT_COLUMN,
- NULL);
-
- gtk_tree_view_append_column (view->details->tree_widget, column);
-
- gtk_widget_show (GTK_WIDGET (view->details->tree_widget));
-
- gtk_container_add (GTK_CONTAINER (view->details->scrolled_window),
- GTK_WIDGET (view->details->tree_widget));
-
- g_signal_connect_object (gtk_tree_view_get_selection (GTK_TREE_VIEW (view->details->tree_widget)), "changed",
- G_CALLBACK (selection_changed_callback), view, 0);
-
- g_signal_connect (G_OBJECT (view->details->tree_widget),
- "row-activated", G_CALLBACK (row_activated_callback),
- view);
-
- schedule_show_selection (view);
-}
-
-static void
-update_filtering_from_preferences (NautilusTreeView *view)
-{
- if (view->details->child_model == NULL) {
- return;
- }
-
- nautilus_tree_model_set_show_hidden_files
- (view->details->child_model,
- eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES));
- nautilus_tree_model_set_show_backup_files
- (view->details->child_model,
- eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES));
- nautilus_tree_model_set_show_only_directories
- (view->details->child_model,
- eel_preferences_get_boolean (NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES));
-}
-
-static void
-tree_activate_callback (BonoboControl *control, gboolean activating, gpointer user_data)
-{
- NautilusTreeView *view;
-
- view = NAUTILUS_TREE_VIEW (user_data);
-
- if (activating && view->details->tree_widget == NULL) {
- create_tree (view);
- update_filtering_from_preferences (view);
- }
-}
-
-static void
-filtering_changed_callback (gpointer callback_data)
-{
- update_filtering_from_preferences (NAUTILUS_TREE_VIEW (callback_data));
-}
-
-static void
-load_location_callback (NautilusTreeView *view, char *location)
-{
- if (view->details->selection_location != NULL) {
- g_free (view->details->selection_location);
- }
- view->details->selection_location = g_strdup (location);
-
- schedule_show_selection (view);
-}
-
-static void
-nautilus_tree_view_instance_init (NautilusTreeView *view)
-{
- BonoboControl *control;
-
- view->details = g_new0 (NautilusTreeViewDetails, 1);
-
- view->details->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
-
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (view->details->scrolled_window),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
-
- gtk_widget_show (view->details->scrolled_window);
-
- control = bonobo_control_new (view->details->scrolled_window);
- g_signal_connect_object (control, "activate",
- G_CALLBACK (tree_activate_callback), view, 0);
-
- nautilus_view_construct_from_bonobo_control (NAUTILUS_VIEW (view), control);
-
- view->details->selection_location = NULL;
- g_signal_connect_object (view, "load_location",
- G_CALLBACK (load_location_callback), view, 0);
- view->details->selecting = FALSE;
-
- eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES,
- filtering_changed_callback, view);
- eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES,
- filtering_changed_callback, view);
- eel_preferences_add_callback (NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES,
- filtering_changed_callback, view);
-
- g_signal_connect_object (nautilus_icon_factory_get(), "icons_changed",
- G_CALLBACK (theme_changed_callback), view, 0);
-
-}
-
-static void
-nautilus_tree_view_dispose (GObject *object)
-{
- NautilusTreeView *view;
-
- view = NAUTILUS_TREE_VIEW (object);
-
- if (view->details->drag_dest) {
- g_object_unref (view->details->drag_dest);
- view->details->drag_dest = NULL;
- }
-
- if (view->details->show_selection_idle_id) {
- g_source_remove (view->details->show_selection_idle_id);
- view->details->show_selection_idle_id = 0;
- }
-
- G_OBJECT_CLASS (parent_class)->dispose (object);
-}
-
-static void
-nautilus_tree_view_finalize (GObject *object)
-{
- NautilusTreeView *view;
-
- view = NAUTILUS_TREE_VIEW (object);
-
- eel_preferences_remove_callback (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES,
- filtering_changed_callback, view);
- eel_preferences_remove_callback (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES,
- filtering_changed_callback, view);
- eel_preferences_remove_callback (NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES,
- filtering_changed_callback, view);
-
- cancel_activation (view);
-
- if (view->details->selection_location != NULL) {
- g_free (view->details->selection_location);
- }
-
- g_free (view->details);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
-nautilus_tree_view_class_init (NautilusTreeViewClass *class)
-{
- G_OBJECT_CLASS (class)->dispose = nautilus_tree_view_dispose;
- G_OBJECT_CLASS (class)->finalize = nautilus_tree_view_finalize;
-}
diff --git a/components/tree/nautilus-tree-view.h b/components/tree/nautilus-tree-view.h
deleted file mode 100644
index aef643080..000000000
--- a/components/tree/nautilus-tree-view.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/*
- * Copyright (C) 2000, 2001 Eazel, Inc
- * Copyright (C) 2002 Anders Carlsson
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Authors: Maciej Stachowiak <mjs@eazel.com>
- * Anders Carlsson <andersca@gnu.org>
- */
-
-/* nautilus-tree-view.h - tree view. */
-
-
-#ifndef NAUTILUS_TREE_VIEW_H
-#define NAUTILUS_TREE_VIEW_H
-
-#include <libnautilus/nautilus-view.h>
-
-#define NAUTILUS_TYPE_TREE_VIEW (nautilus_tree_view_get_type ())
-#define NAUTILUS_TREE_VIEW(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_TREE_VIEW, NautilusTreeView))
-#define NAUTILUS_TREE_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_TREE_VIEW, NautilusTreeViewClass))
-#define NAUTILUS_IS_TREE_VIEW(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_TREE_VIEW))
-#define NAUTILUS_IS_TREE_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_TREE_VIEW))
-
-typedef struct NautilusTreeViewDetails NautilusTreeViewDetails;
-
-typedef struct {
- NautilusView parent;
- NautilusTreeViewDetails *details;
-} NautilusTreeView;
-
-typedef struct {
- NautilusViewClass parent_class;
-} NautilusTreeViewClass;
-
-GType nautilus_tree_view_get_type (void);
-
-#endif /* NAUTILUS_TREE_VIEW_H */