Index: plugins/audacious/all.h
===================================================================
--- plugins/audacious/all.h	(revision 1592)
+++ plugins/audacious/all.h	(revision 1592)
@@ -0,0 +1,96 @@
+//all.h:
+
+/*
+ *      Copyright (C) Philipp 'ph3-der-loewe' Schafft    - 2008,
+ *                    Daniel Duntemann <dauxx@dauxx.org> - 2009
+ *
+ *  This file is part of the XMMS RoarAudio output plugin a part of RoarAudio,
+ *  a cross-platform sound system for both, home and professional use.
+ *  See README for details.
+ *
+ *  This file is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 3
+ *  as published by the Free Software Foundation.
+ *
+ *  RoarAudio 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 software; see the file COPYING.  If not, write to
+ *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _ALL_H_
+#define _ALL_H_
+
+#include <roaraudio.h>
+
+//#include "xmms/i18n.h"
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <audacious/configdb.h>
+#include <audacious/util.h>
+#include <audacious/plugin.h>
+#include <audacious/audctrl.h>
+/* #include <audacious/dirbrowser.h> */
+
+
+
+#define _(x) (x)
+
+gint ctrlsocket_get_session_id(void);
+
+void roar_init(void);
+void roar_about(void);
+void roar_configure(void);
+
+void roar_get_volume(int *l, int *r);
+void roar_set_volume(int l, int r);
+void roar_mixer_init(void);
+void roar_mixer_init_vol(int l, int r);
+
+int roar_playing(void);
+int roar_free(void);
+void roar_write(void *ptr, int length);
+void roar_close(void);
+void roar_flush(int time);
+void roar_pause(short p);
+int roar_open(AFormat fmt, int rate, int nch);
+int roar_get_output_time(void);
+int roar_get_written_time(void);
+
+int roar_update_metadata(void);
+int roar_chk_metadata(void);
+
+#define STATE_CONNECTED   1
+#define STATE_PLAYING     2
+#define STATE_NORECONNECT 4
+
+struct xmms_roar_out {
+ int                 state;
+ char              * server;
+ struct roar_connection con;
+ struct roar_stream     stream;
+ int                 data_fh;
+ long unsigned int   written;
+ long unsigned int   bps;
+ int                 session;
+ int                 pause;
+ struct {
+  int                server_type;
+  int                port;
+  int              * proxy_type;
+  char             * proxy;
+  char             * player_name;
+ } cfg;
+} g_inst;
+
+#endif
+
+//ll
Index: plugins/audacious/gui.c
===================================================================
--- plugins/audacious/gui.c	(revision 1592)
+++ plugins/audacious/gui.c	(revision 1592)
@@ -0,0 +1,338 @@
+//gui.c:
+
+/*
+ *      Copyright (C) Philipp 'ph3-der-loewe' Schafft    - 2008,
+ *                    Daniel Duntemann <dauxx@dauxx.org> - 2009
+ *
+ *  This file is part of the XMMS RoarAudio output plugin a part of RoarAudio,
+ *  a cross-platform sound system for both, home and professional use.
+ *  See README for details.
+ *
+ *  This file is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 3
+ *  as published by the Free Software Foundation.
+ *
+ *  RoarAudio 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 software; see the file COPYING.  If not, write to
+ *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include "all.h"
+
+// ABOUT:
+
+void roar_about(void) {
+ static GtkWidget *dialog;
+
+ if (dialog != NULL)
+  return;
+
+ dialog = audacious_info_dialog(
+                _("About RoarAudio Plugin"),
+                _("RoarAudio Audacious Plugin..."
+                 ), _("OK"), FALSE, NULL, NULL);
+ gtk_signal_connect(GTK_OBJECT(dialog), "destroy",
+                    GTK_SIGNAL_FUNC(gtk_widget_destroyed),
+                    &dialog);
+}
+
+// CONFIG:
+
+void on_button_ok_enter(GtkButton * button, gpointer user_data) {
+}
+
+void roar_configure(void) {
+  GtkWidget *config_win;
+  GtkWidget *vbox_main;
+  GtkWidget *tabs_main;
+  GtkWidget *frame_server;
+  GtkWidget *alignment_server;
+  GtkWidget *table1;
+  GtkWidget *label_server_type;
+  GtkWidget *label_server_host;
+  GtkWidget *label_server_port;
+  GtkObject *input_server_port_adj;
+  GtkWidget *input_server_port;
+  GtkWidget *input_server_host;
+  GtkWidget *input_server_type;
+  GtkWidget *label_host;
+  GtkWidget *label_server;
+  GtkWidget *frame_proxy;
+  GtkWidget *alignment_proxy;
+  GtkWidget *table2;
+  GtkWidget *label_proxy_type;
+  GtkWidget *label_proxy_addr;
+  GtkWidget *input_proxy_host;
+  GtkWidget *input_proxy_type;
+  GtkWidget *label_frame_proxy;
+  GtkWidget *label_proxy;
+  GtkWidget *vbox_meta;
+  GtkWidget *frame_meta_player;
+  GtkWidget *alignment1;
+  GtkWidget *hbox_meta_player;
+  GtkWidget *label_player_name;
+  GtkWidget *input_meta_player_name;
+  GtkWidget *label_player;
+  GtkWidget *frame_meta_title;
+  GtkWidget *alignment2;
+  GtkWidget *hbox_meta_title;
+  GtkWidget *input_meta_send_title;
+  GtkWidget *input_meta_send_filename;
+  GtkWidget *label_meta_title;
+  GtkWidget *label_meta;
+  GtkWidget *hbox_buttons;
+  GtkWidget *button_ok;
+  GtkWidget *button_cancel;
+
+  config_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+  gtk_window_set_title(GTK_WINDOW(config_win), _("RoarAudio Plugin - Configuration"));
+//  gtk_window_set_destroy_with_parent(GTK_WINDOW(config_win), TRUE);
+//  gtk_window_set_icon_name(GTK_WINDOW(config_win), "gtk-preferences");
+
+  gtk_widget_show (config_win);
+
+  vbox_main = gtk_vbox_new (FALSE, 0);
+  gtk_widget_show (vbox_main);
+  gtk_container_add (GTK_CONTAINER (config_win), vbox_main);
+
+  tabs_main = gtk_notebook_new ();
+  gtk_widget_show (tabs_main);
+  gtk_box_pack_start (GTK_BOX (vbox_main), tabs_main, TRUE, TRUE, 0);
+
+  frame_server = gtk_frame_new (NULL);
+  gtk_widget_show (frame_server);
+  gtk_container_add (GTK_CONTAINER (tabs_main), frame_server);
+  gtk_frame_set_shadow_type (GTK_FRAME (frame_server), GTK_SHADOW_NONE);
+
+  alignment_server = gtk_alignment_new (0.5, 0.5, 1, 1);
+  gtk_widget_show (alignment_server);
+  gtk_container_add (GTK_CONTAINER (frame_server), alignment_server);
+//  gtk_alignment_set_padding (GTK_ALIGNMENT (alignment_server), 0, 0, 12, 0);
+
+  table1 = gtk_table_new (3, 2, FALSE);
+  gtk_widget_show (table1);
+  gtk_container_add (GTK_CONTAINER (alignment_server), table1);
+
+  label_server_type = gtk_label_new (_("Server Type:"));
+  gtk_widget_show (label_server_type);
+  gtk_table_attach (GTK_TABLE (table1), label_server_type, 0, 1, 0, 1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_misc_set_alignment (GTK_MISC (label_server_type), 0, 0.5);
+
+  label_server_host = gtk_label_new (_("Host or Path:"));
+  gtk_widget_show (label_server_host);
+  gtk_table_attach (GTK_TABLE (table1), label_server_host, 0, 1, 1, 2,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_misc_set_alignment (GTK_MISC (label_server_host), 0, 0.5);
+
+  label_server_port = gtk_label_new (_("Port:"));
+  gtk_widget_show (label_server_port);
+  gtk_table_attach (GTK_TABLE (table1), label_server_port, 0, 1, 2, 3,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_misc_set_alignment (GTK_MISC (label_server_port), 0, 0.5);
+
+  input_server_port_adj = gtk_adjustment_new (16002, 0, 65535, 1, 10, 10);
+  input_server_port = gtk_spin_button_new (GTK_ADJUSTMENT (input_server_port_adj), 1, 0);
+  gtk_widget_show (input_server_port);
+  gtk_table_attach (GTK_TABLE (table1), input_server_port, 1, 2, 2, 3,
+                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+
+  input_server_host = gtk_entry_new ();
+  gtk_widget_show (input_server_host);
+  gtk_table_attach (GTK_TABLE (table1), input_server_host, 1, 2, 1, 2,
+                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+
+/*
+  input_server_type = gtk_combo_box_entry_new_text ();
+  gtk_widget_show (input_server_type);
+  gtk_table_attach (GTK_TABLE (table1), input_server_type, 1, 2, 0, 1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (GTK_FILL), 0, 0);
+  gtk_combo_box_append_text (GTK_COMBO_BOX (input_server_type), _("Local"));
+  gtk_combo_box_append_text (GTK_COMBO_BOX (input_server_type), _("TCP/IP"));
+  gtk_combo_box_append_text (GTK_COMBO_BOX (input_server_type), _("DECnet"));
+  gtk_combo_box_append_text (GTK_COMBO_BOX (input_server_type), _("Fork"));
+*/
+  label_host = gtk_label_new (_("<b>Host:</b>"));
+  gtk_widget_show (label_host);
+//  gtk_frame_set_label_widget (GTK_FRAME (frame_server), label_host);
+//  gtk_label_set_use_markup (GTK_LABEL (label_host), TRUE);
+
+  label_server = gtk_label_new (_("Server & Network"));
+  gtk_widget_show (label_server);
+  gtk_notebook_set_tab_label (GTK_NOTEBOOK (tabs_main), gtk_notebook_get_nth_page (GTK_NOTEBOOK (tabs_main), 0), label_server);
+
+  frame_proxy = gtk_frame_new (NULL);
+  gtk_widget_show (frame_proxy);
+  gtk_container_add (GTK_CONTAINER (tabs_main), frame_proxy);
+  gtk_frame_set_shadow_type (GTK_FRAME (frame_proxy), GTK_SHADOW_NONE);
+
+  alignment_proxy = gtk_alignment_new (0.5, 0.5, 1, 1);
+  gtk_widget_show (alignment_proxy);
+  gtk_container_add (GTK_CONTAINER (frame_proxy), alignment_proxy);
+//  gtk_alignment_set_padding (GTK_ALIGNMENT (alignment_proxy), 0, 0, 12, 0);
+
+  table2 = gtk_table_new (2, 2, FALSE);
+  gtk_widget_show (table2);
+  gtk_container_add (GTK_CONTAINER (alignment_proxy), table2);
+
+  label_proxy_type = gtk_label_new (_("Type:"));
+  gtk_widget_show (label_proxy_type);
+  gtk_table_attach (GTK_TABLE (table2), label_proxy_type, 0, 1, 0, 1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_misc_set_alignment (GTK_MISC (label_proxy_type), 0, 0.5);
+
+  label_proxy_addr = gtk_label_new (_("Proxy Address"));
+  gtk_widget_show (label_proxy_addr);
+  gtk_table_attach (GTK_TABLE (table2), label_proxy_addr, 0, 1, 1, 2,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_misc_set_alignment (GTK_MISC (label_proxy_addr), 0, 0.5);
+
+  input_proxy_host = gtk_entry_new ();
+  gtk_widget_show (input_proxy_host);
+  gtk_table_attach (GTK_TABLE (table2), input_proxy_host, 1, 2, 1, 2,
+                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+
+/*
+  input_proxy_type = gtk_combo_box_entry_new_text ();
+  gtk_widget_show (input_proxy_type);
+  gtk_table_attach (GTK_TABLE (table2), input_proxy_type, 1, 2, 0, 1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (GTK_FILL), 0, 0);
+  gtk_combo_box_append_text (GTK_COMBO_BOX (input_proxy_type), _("None"));
+  gtk_combo_box_append_text (GTK_COMBO_BOX (input_proxy_type), _("SOCKS4"));
+  gtk_combo_box_append_text (GTK_COMBO_BOX (input_proxy_type), _("SOCKS4a"));
+  gtk_combo_box_append_text (GTK_COMBO_BOX (input_proxy_type), _("SOCKS4d"));
+  gtk_combo_box_append_text (GTK_COMBO_BOX (input_proxy_type), _("HTTP Connect"));
+  gtk_combo_box_append_text (GTK_COMBO_BOX (input_proxy_type), _("SSH"));
+*/
+
+  label_frame_proxy = gtk_label_new (_("<b>Proxy</b>"));
+  gtk_widget_show (label_frame_proxy);
+/*
+  gtk_frame_set_label_widget (GTK_FRAME (frame_proxy), label_frame_proxy);
+  gtk_label_set_use_markup (GTK_LABEL (label_frame_proxy), TRUE);
+*/
+
+  label_proxy = gtk_label_new (_("Proxy"));
+  gtk_widget_show (label_proxy);
+  gtk_notebook_set_tab_label (GTK_NOTEBOOK (tabs_main), gtk_notebook_get_nth_page (GTK_NOTEBOOK (tabs_main), 1), label_proxy);
+
+  vbox_meta = gtk_vbox_new (FALSE, 0);
+  gtk_widget_show (vbox_meta);
+  gtk_container_add (GTK_CONTAINER (tabs_main), vbox_meta);
+
+  frame_meta_player = gtk_frame_new (NULL);
+  gtk_widget_show (frame_meta_player);
+  gtk_box_pack_start (GTK_BOX (vbox_meta), frame_meta_player, TRUE, TRUE, 0);
+  gtk_frame_set_shadow_type (GTK_FRAME (frame_meta_player), GTK_SHADOW_NONE);
+
+  alignment1 = gtk_alignment_new (0.5, 0.5, 1, 1);
+  gtk_widget_show (alignment1);
+  gtk_container_add (GTK_CONTAINER (frame_meta_player), alignment1);
+//  gtk_alignment_set_padding (GTK_ALIGNMENT (alignment1), 0, 0, 12, 0);
+
+  hbox_meta_player = gtk_hbox_new (FALSE, 0);
+  gtk_widget_show (hbox_meta_player);
+  gtk_container_add (GTK_CONTAINER (alignment1), hbox_meta_player);
+
+  label_player_name = gtk_label_new (_("Player Name:"));
+  gtk_widget_show (label_player_name);
+  gtk_box_pack_start (GTK_BOX (hbox_meta_player), label_player_name, FALSE, FALSE, 0);
+
+  input_meta_player_name = gtk_entry_new ();
+  gtk_widget_show (input_meta_player_name);
+  gtk_box_pack_start (GTK_BOX (hbox_meta_player), input_meta_player_name, TRUE, TRUE, 0);
+  gtk_entry_set_text (GTK_ENTRY (input_meta_player_name), _("Audacious"));
+
+  label_player = gtk_label_new (_("<b>Player</b>"));
+  gtk_widget_show (label_player);
+/*
+  gtk_frame_set_label_widget (GTK_FRAME (frame_meta_player), label_player);
+  gtk_label_set_use_markup (GTK_LABEL (label_player), TRUE);
+*/
+
+  frame_meta_title = gtk_frame_new (NULL);
+  gtk_widget_show (frame_meta_title);
+  gtk_box_pack_start (GTK_BOX (vbox_meta), frame_meta_title, TRUE, TRUE, 0);
+  gtk_frame_set_shadow_type (GTK_FRAME (frame_meta_title), GTK_SHADOW_NONE);
+
+  alignment2 = gtk_alignment_new (0.5, 0.5, 1, 1);
+  gtk_widget_show (alignment2);
+  gtk_container_add (GTK_CONTAINER (frame_meta_title), alignment2);
+//  gtk_alignment_set_padding (GTK_ALIGNMENT (alignment2), 0, 0, 12, 0);
+
+  hbox_meta_title = gtk_hbox_new (FALSE, 0);
+  gtk_widget_show (hbox_meta_title);
+  gtk_container_add (GTK_CONTAINER (alignment2), hbox_meta_title);
+
+/*
+  input_meta_send_title = gtk_check_button_new_with_mnemonic (_("Send song title to server"));
+  gtk_widget_show (input_meta_send_title);
+  gtk_box_pack_start (GTK_BOX (hbox_meta_title), input_meta_send_title, FALSE, FALSE, 0);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (input_meta_send_title), TRUE);
+
+  input_meta_send_filename = gtk_check_button_new_with_mnemonic (_("Send song filename to server"));
+  gtk_widget_show (input_meta_send_filename);
+  gtk_box_pack_start (GTK_BOX (hbox_meta_title), input_meta_send_filename, FALSE, FALSE, 0);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (input_meta_send_filename), TRUE);
+*/
+
+  label_meta_title = gtk_label_new (_("<b>Current Song</b>"));
+  gtk_widget_show (label_meta_title);
+/*
+  gtk_frame_set_label_widget (GTK_FRAME (frame_meta_title), label_meta_title);
+  gtk_label_set_use_markup (GTK_LABEL (label_meta_title), TRUE);
+*/
+
+  label_meta = gtk_label_new (_("Meta Data"));
+  gtk_widget_show (label_meta);
+  gtk_notebook_set_tab_label (GTK_NOTEBOOK (tabs_main), gtk_notebook_get_nth_page (GTK_NOTEBOOK (tabs_main), 2), label_meta);
+
+  hbox_buttons = gtk_hbox_new (FALSE, 0);
+  gtk_widget_show (hbox_buttons);
+  gtk_box_pack_start (GTK_BOX (vbox_main), hbox_buttons, TRUE, TRUE, 0);
+
+
+  button_ok = gtk_button_new_with_label(_("OK"));
+  gtk_box_pack_start (GTK_BOX (hbox_buttons), button_ok, FALSE, FALSE, 0);
+
+  button_cancel = gtk_button_new_with_label(_("Cancel"));
+  gtk_signal_connect_object(GTK_OBJECT(button_cancel), "clicked",
+                            GTK_SIGNAL_FUNC(gtk_widget_destroy),
+                            GTK_OBJECT(config_win));
+  gtk_box_pack_start (GTK_BOX (hbox_buttons), button_cancel, FALSE, FALSE, 0);
+
+/*
+  button_ok = gtk_button_new_from_stock ("gtk-ok");
+  gtk_widget_show (button_ok);
+  gtk_box_pack_start (GTK_BOX (hbox_buttons), button_ok, FALSE, FALSE, 0);
+
+  button_cancel = gtk_button_new_from_stock ("gtk-cancel");
+  gtk_widget_show (button_cancel);
+  gtk_box_pack_start (GTK_BOX (hbox_buttons), button_cancel, FALSE, FALSE, 0);
+
+  g_signal_connect_swapped ((gpointer) button_ok, "clicked",
+                            G_CALLBACK (on_button_ok_enter),
+                            GTK_OBJECT (config_win));
+  g_signal_connect_swapped ((gpointer) button_cancel, "clicked",
+                            G_CALLBACK (gtk_widget_destroy),
+                            GTK_OBJECT (config_win));
+*/
+}
+
+//ll
Index: plugins/audacious/roar.c
===================================================================
--- plugins/audacious/roar.c	(revision 1592)
+++ plugins/audacious/roar.c	(revision 1592)
@@ -0,0 +1,411 @@
+//roar.c:
+
+/*
+ *      Copyright (C) Philipp 'ph3-der-loewe' Schafft    - 2008,
+ *                    Daniel Duntemann <dauxx@dauxx.org> - 2009
+ *
+ *  This file is part of the Audacious RoarAudio output plugin a part of RoarAudio,
+ *  a cross-platform sound system for both, home and professional use.
+ *  See README for details.
+ *
+ *  This file is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 3
+ *  as published by the Free Software Foundation.
+ *
+ *  RoarAudio 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 software; see the file COPYING.  If not, write to
+ *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include "all.h"
+gint ctrlsocket_get_session_id(void)
+{
+
+}
+OutputPlugin roar_op = {
+    .description = "RoarAudio Output Plugin",         
+    .init = roar_init,
+    .cleanup = NULL,
+    .about = roar_about,
+    .configure = roar_configure,  
+    .get_volume = roar_get_volume,
+    .set_volume = roar_set_volume,
+    .open_audio = roar_open,  
+    .write_audio = roar_write,
+    .close_audio = roar_close,
+    .flush = roar_flush,
+    .pause = roar_pause,
+    .buffer_free = roar_free,
+    .buffer_playing = roar_playing,
+    .output_time = roar_get_output_time,  
+    .written_time = roar_get_written_time,
+    .tell_audio = NULL
+};
+
+OutputPlugin *roar_oplist[] = { &roar_op, NULL };
+
+
+SIMPLE_OUTPUT_PLUGIN("RoarAudio Audacious Plugin",roar_oplist);
+
+OutputPlugin *get_oplugin_info(void) {
+ return &roar_op;
+}
+
+void roar_init(void) {
+ mcs_handle_t * cfgfile;
+
+ cfgfile = aud_cfg_db_open();;
+
+ g_inst.state = 0;
+ g_inst.server = NULL;
+ g_inst.session = ctrlsocket_get_session_id();
+
+ aud_cfg_db_get_string(cfgfile, "ROAR", "server", &g_inst.server);
+
+ aud_cfg_db_get_string(cfgfile, "ROAR", "player_name", &g_inst.cfg.player_name);
+
+ aud_cfg_db_close(cfgfile);
+
+ if ( g_inst.cfg.player_name == NULL )
+  g_inst.cfg.player_name = "Audacious";
+
+ ROAR_DBG("roar_init(*) = (void)");
+}
+
+int roar_playing(void) {
+ return FALSE;
+}
+
+void roar_write(void *ptr, int length) {
+ int r;
+
+ if ( g_inst.pause )
+  return;
+
+ ROAR_DBG("roar_write(ptr=%p, length=%i) = (void)", ptr, length);
+
+ while (length) {
+  if ( (r = write(g_inst.data_fh, ptr, length >= 17640 ? 17640 : length)) != -1 ) {
+   g_inst.written   += r;
+   ptr              += r;
+   length           -= r;
+  } else {
+   return;
+  }
+ }
+}
+
+int roar_open(AFormat fmt, int rate, int nch) {
+ int codec = ROAR_CODEC_DEFAULT;
+ int bits;
+
+ if ( !(g_inst.state & STATE_CONNECTED) ) {
+  if ( roar_simple_connect(&(g_inst.con), g_inst.server, g_inst.cfg.player_name) == -1 ) {
+   return FALSE;
+  }
+  g_inst.state |= STATE_CONNECTED;
+ }
+
+  bits = 16;
+  switch (fmt) {
+   case FMT_S8:
+     bits = 8;
+     codec = ROAR_CODEC_DEFAULT;
+    break;
+   case FMT_U8:
+     bits = 8;
+     codec = ROAR_CODEC_PCM_U_LE; // _LE, _BE, _PDP,... all the same for 8 bit output
+    break;
+   case FMT_U16_LE:
+     codec = ROAR_CODEC_PCM_U_LE;
+    break;
+   case FMT_U16_BE:
+     codec = ROAR_CODEC_PCM_U_BE;
+    break;
+   case FMT_U16_NE:
+#if BYTE_ORDER == BIG_ENDIAN
+     codec = ROAR_CODEC_PCM_U_BE;
+#elif BYTE_ORDER == LITTLE_ENDIAN
+     codec = ROAR_CODEC_PCM_U_LE;
+#else
+     codec = ROAR_CODEC_PCM_U_PDP;
+#endif
+    break;
+   case FMT_S16_LE:
+     codec = ROAR_CODEC_PCM_S_LE;
+    break;
+   case FMT_S16_BE:
+     codec = ROAR_CODEC_PCM_S_BE;
+    break;
+   case FMT_S16_NE:
+     codec = ROAR_CODEC_DEFAULT;
+    break;
+    case FMT_U24_LE: /* stored in lower 3 bytes of 32-bit value, highest byte must be 0 */
+     codec = ROAR_CODEC_PCM_U_LE;
+     bits = 24;
+     break;
+    case FMT_U24_BE:
+     codec = ROAR_CODEC_PCM_U_BE;
+     bits = 24;
+     break;
+    case FMT_U24_NE:
+     bits = 24;
+#if BYTE_ORDER == BIG_ENDIAN
+     codec = ROAR_CODEC_PCM_U_BE;
+#elif BYTE_ORDER == LITTLE_ENDIAN
+     codec = ROAR_CODEC_PCM_U_LE;
+#else
+     codec = ROAR_CODEC_PCM_U_PDP;
+#endif     
+     break;
+    case FMT_S24_LE:
+     bits = 24;
+     codec = ROAR_CODEC_PCM_S_LE;
+     break;
+    case FMT_S24_BE:
+     bits = 24;
+     codec = ROAR_CODEC_PCM_S_BE;
+     break;
+    case FMT_S24_NE:
+     codec = ROAR_CODEC_DEFAULT;
+     bits= 24;
+     break;
+    case FMT_U32_LE: /* highest byte must be 0 */
+     codec = ROAR_CODEC_PCM_U_LE;
+     bits = 32;
+     break;
+    case FMT_U32_BE:
+     codec = ROAR_CODEC_PCM_U_BE;
+     bits = 32;
+     break;
+    case FMT_U32_NE:
+     bits = 32;
+#if BYTE_ORDER == BIG_ENDIAN
+     codec = ROAR_CODEC_PCM_U_BE;
+#elif BYTE_ORDER == LITTLE_ENDIAN
+     codec = ROAR_CODEC_PCM_U_LE;
+#else
+     codec = ROAR_CODEC_PCM_U_PDP;
+#endif     
+     break;
+    case FMT_S32_LE:
+     bits = 32;
+     codec = ROAR_CODEC_PCM_S_LE;
+     break;
+    case FMT_S32_BE:
+     bits = 32;
+     codec = ROAR_CODEC_PCM_S_BE;
+     break;
+    case FMT_S32_NE:
+     codec = ROAR_CODEC_DEFAULT;
+     bits= 32;
+     break;
+    case FMT_FLOAT:
+    ROAR_DBG("FMT_FLOAT");
+    break;
+    case FMT_FIXED32:
+     ROAR_DBG("FMT_FIXED32");
+     break;
+     
+ }
+ROAR_DBG("fmt %i",fmt);
+ g_inst.bps       = nch * rate * bits / 8;
+
+ roar_close();
+
+ if ( (g_inst.data_fh = roar_simple_new_stream_obj(&(g_inst.con), &(g_inst.stream),
+                              rate, nch, bits, codec, ROAR_DIR_PLAY)) == -1) {
+  roar_disconnect(&(g_inst.con));
+  g_inst.state |= STATE_CONNECTED;
+  g_inst.state -= STATE_CONNECTED;
+  if ( !(g_inst.state & STATE_NORECONNECT) ) {
+   g_inst.state |= STATE_NORECONNECT;
+   usleep(100000);
+   return roar_open(fmt, rate, nch);
+  } else {
+   g_inst.state -= STATE_NORECONNECT;
+   return FALSE;
+  }
+ }
+ g_inst.state |= STATE_PLAYING;
+
+ g_inst.written = 0;
+ g_inst.pause   = 0;
+
+ roar_update_metadata();
+
+ return TRUE;
+}
+
+void roar_close(void) {
+ if ( g_inst.data_fh != -1 )
+  close(g_inst.data_fh);
+ g_inst.data_fh = -1;
+ g_inst.state |= STATE_PLAYING;
+ g_inst.state -= STATE_PLAYING;
+ g_inst.written = 0;
+ ROAR_DBG("roar_close(void) = (void)");
+}
+
+void roar_pause(short p) {
+ g_inst.pause = p;
+}
+
+int roar_free(void) {
+ if ( g_inst.pause )
+  return 0;
+ else
+  return 1000000; // ???
+}
+
+void roar_flush(int time) {
+ gint64 r = time;
+
+ r *= g_inst.bps;
+ r /= 1000;
+
+ g_inst.written = r;
+}
+
+int roar_get_output_time(void) {
+ return roar_get_written_time();
+}
+
+int roar_get_written_time(void) {
+ gint64 r;
+
+ if ( !g_inst.bps ) {
+  ROAR_DBG("roar_get_written_time(void) = 0");
+  return 0;
+ }
+
+ r  = g_inst.written;
+ r *= 1000; // sec -> msec
+ r /= g_inst.bps;
+ ROAR_DBG("roar_get_written_time(void) = %lu", r);
+
+ return r;
+}
+
+
+// META DATA:
+
+int roar_update_metadata(void) {
+ struct roar_meta   meta;
+ char empty = 0;
+ char * info;
+ int pos;
+
+ pos     = audacious_remote_get_playlist_pos(g_inst.session);
+
+ meta.value = &empty;
+ meta.key[0] = 0;
+ meta.type = ROAR_META_TYPE_NONE;
+
+ roar_stream_meta_set(&(g_inst.con), &(g_inst.stream), ROAR_META_MODE_CLEAR, &meta);
+
+ info = audacious_remote_get_playlist_file(g_inst.session, pos);
+
+ if ( info ) {
+  if ( strncmp(info, "http:", 5) == 0 )
+   meta.type = ROAR_META_TYPE_FILEURL;
+  else
+   meta.type = ROAR_META_TYPE_FILENAME;
+
+  meta.value = info;
+  ROAR_DBG("roar_update_metadata(*): setting meta data: type=%i, strlen(value)=%i", meta.type, strlen(info));
+  roar_stream_meta_set(&(g_inst.con), &(g_inst.stream), ROAR_META_MODE_SET, &meta);
+
+  free(info);
+ }
+
+ info = audacious_remote_get_playlist_title(g_inst.session, pos);
+ if ( info ) {
+  meta.type = ROAR_META_TYPE_TITLE;
+
+  meta.value = info;
+  roar_stream_meta_set(&(g_inst.con), &(g_inst.stream), ROAR_META_MODE_SET, &meta);
+
+  free(info);
+ }
+
+ meta.value = &empty;
+ meta.type = ROAR_META_TYPE_NONE;
+ roar_stream_meta_set(&(g_inst.con), &(g_inst.stream), ROAR_META_MODE_FINALIZE, &meta);
+
+ return 0;
+}
+
+int roar_chk_metadata(void) {
+ static int    old_pos = -1;
+ static char * old_title = "NEW TITLE";
+ int pos;
+ char * title;
+ int need_update = 0;
+
+ pos     = audacious_remote_get_playlist_pos(g_inst.session);
+
+ if ( pos != old_pos ) {
+  old_pos = pos;
+  need_update = 1;
+ } else {
+  title = audacious_remote_get_playlist_title(g_inst.session, pos);
+
+  if ( strcmp(title, old_title) ) {
+   free(old_title);
+   old_title = title;
+   need_update = 1;
+  } else {
+   free(title);
+  }
+ }
+
+ if ( need_update ) {
+  roar_update_metadata();
+ }
+
+ return 0;
+}
+
+// MIXER:
+
+
+void roar_get_volume(int *l, int *r) {
+ int channels;
+ struct roar_mixer_settings mixer;
+
+ if ( !(g_inst.state & STATE_CONNECTED) )
+  return;
+
+ if ( roar_get_vol(&(g_inst.con), g_inst.stream.id, &mixer, &channels) == -1 ) {
+  *l = *r = 100;
+  return;
+ }
+
+ if ( channels == 1 ) {
+  *l = *r = mixer.mixer[0]/655.35;
+ } else {
+  *l = mixer.mixer[0]/655.35;
+  *r = mixer.mixer[1]/655.35;
+ }
+}
+
+void roar_set_volume(int l, int r) {
+ struct roar_mixer_settings mixer;
+
+ if ( !(g_inst.state & STATE_CONNECTED) )
+  return;
+
+ mixer.mixer[0] = l * 655.35;
+ mixer.mixer[1] = r * 655.35;
+
+ roar_set_vol(&(g_inst.con), g_inst.stream.id, &mixer, 2);
+}
+
+//ll
