Index: libroaresd/esdctl.c
===================================================================
--- libroaresd/esdctl.c	(revision 6052)
+++ libroaresd/esdctl.c	(revision 0)
@@ -1,40 +1,3 @@
 //esdctl.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *  The code (may) include prototypes and comments (and maybe
- *  other code fragements) from EsounD.
- *  They are mostly copyrighted by Eric B. Mitchell (aka 'Ricdude)
- *  <ericmit@ix.netcom.com>. For more information see AUTHORS.esd.
- *
- *  This file is part of libroaresd 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, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- *  NOTE for everyone want's to change something and send patches:
- *  read README and HACKING! There a addition information on
- *  the license of this document you need to read before you send
- *  any patches.
- *
- *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
- *  or libpulse*:
- *  The libs libroaresd, libroararts and libroarpulse link this libroar
- *  and are therefore GPL. Because of this it may be illigal to use
- *  them with any software that uses libesd, libartsc or libpulse*.
- */
 
 #include "libroaresd.h"
@@ -45,11 +8,7 @@
 // so always return -1
 int esd_lock( int esd ) {
- (void)esd;
- errno = ENOSYS;
  return -1;
 }
 int esd_unlock( int esd ) {
- (void)esd;
- errno = ENOSYS;
  return -1;
 }
@@ -59,5 +18,5 @@
  struct roar_connection con;
 
- roar_connect_fh(&con, esd);
+ con.fh = esd;
 
  return roar_set_standby(&con, ROAR_STANDBY_ACTIVE);
@@ -67,29 +26,22 @@
  struct roar_connection con;
 
- roar_connect_fh(&con, esd);
+ con.fh = esd;
 
  return roar_set_standby(&con, ROAR_STANDBY_INACTIVE);
 }
 
-static void _format2str(char * buf, size_t len, esd_format_t format) {
-
- if ( (format & ESD_BITS16) == ESD_BITS16 ) {
-  roar_mm_strlcat(buf, "16 bit ", len);
- } else {
-  roar_mm_strlcat(buf, "8 bit ", len);
- }
-
- if ( (format & ESD_STEREO) == ESD_STEREO ) {
-  roar_mm_strlcat(buf, "stereo ", len);
- } else {
-  roar_mm_strlcat(buf, "mono ", len);
- }
-}
-
 /* print server into to stdout */
-void esd_print_server_info(esd_server_info_t *server_info ) {
+void esd_print_server_info( esd_server_info_t *server_info ) {
  char buf[80] = "";
 
- _format2str(buf, sizeof(buf), server_info->format);
+ if ( server_info->format & ESD_BITS8 )
+  strcat(buf, "8 bit ");
+ else
+  strcat(buf, "16 bit ");
+
+ if ( server_info->format & ESD_MONO )
+  strcat(buf, "stereo ");
+ else
+  strcat(buf, "mono ");
 
  printf("server version   = %i\n",        server_info->version);
@@ -98,8 +50,17 @@
 }
 
+
 void esd_print_player_info( esd_player_info_t *player_info ) {
  char buf[80] = "";
 
- _format2str(buf, sizeof(buf), player_info->format);
+ if ( player_info->format & ESD_BITS8 )
+  strcat(buf, "8 bit ");
+ else
+  strcat(buf, "16 bit ");
+
+ if ( player_info->format & ESD_MONO )
+  strcat(buf, "stereo ");
+ else
+  strcat(buf, "mono ");
 
  printf("player %i name    = %s\n",        player_info->source_id, player_info->name);
@@ -109,16 +70,5 @@
  printf("player %i right   = %i\n",        player_info->source_id, player_info->right_vol_scale );
 }
-
 void esd_print_sample_info( esd_sample_info_t *sample_info ) {
- char buf[80] = "";
-
- _format2str(buf, sizeof(buf), sample_info->format);
-
- printf("sample %i name    = %s\n",        sample_info->sample_id, sample_info->name);
- printf("sample %i format  = 0x%08x %s\n", sample_info->sample_id, sample_info->format, buf);
- printf("sample %i rate    = %i\n",        sample_info->sample_id, sample_info->rate);
- printf("sample %i left    = %i\n",        sample_info->sample_id, sample_info->left_vol_scale);
- printf("sample %i right   = %i\n",        sample_info->sample_id, sample_info->right_vol_scale);
- printf("sample %i length  = %i\n",        sample_info->sample_id, sample_info->length);
 }
 
@@ -154,5 +104,5 @@
  struct roar_message    m;
 
- r = roar_mm_malloc(sizeof(esd_server_info_t));
+ r = malloc(sizeof(esd_server_info_t));
 
  if ( r == NULL )
@@ -161,23 +111,20 @@
  r->version = 0; // seems to be static
 
- roar_connect_fh(&con, esd);
-
- memset(&m, 0, sizeof(m));
-
+ con.fh    = esd;
  m.cmd     = ROAR_CMD_SERVER_OINFO;
  m.datalen = 0;
 
  if ( roar_req(&con, &m, NULL) == -1 ) {
-  roar_mm_free(r);
+  free(r);
   return NULL;
  }
 
  if ( m.cmd != ROAR_CMD_OK ) {
-  roar_mm_free(r);
+  free(r);
   return NULL;
  }
 
  if ( roar_stream_m2s(&s, &m) == -1 ) {
-  roar_mm_free(r);
+  free(r);
   return NULL;
  }
@@ -200,6 +147,6 @@
 /* release all memory allocated for the server properties structure */
 void esd_free_server_info( esd_server_info_t *server_info ) {
- if (server_info != NULL)
-  roar_mm_free(server_info);
+ if (server_info)
+  free(server_info);
 }
 
@@ -213,12 +160,9 @@
  struct roar_stream s;
  struct roar_connection con[1];
- struct roar_mixer_settings mixer;
- int channels;
- float fs;
  esd_player_info_t * new_player, * cur = NULL; // = NULL to avoid gcc warning
 
- roar_connect_fh(con, esd);
-
- r = roar_mm_malloc(sizeof(esd_info_t));
+ con->fh = esd;
+
+ r = malloc(sizeof(esd_info_t));
 
  if ( r == NULL )
@@ -246,5 +190,5 @@
    }
 
-   if ( (new_player = roar_mm_malloc(sizeof(esd_player_info_t))) == NULL ) {
+   if ( (new_player = malloc(sizeof(esd_player_info_t))) == NULL ) {
     ROAR_ERR("esd_get_all_info(*): can not alloc memory for new player! BAD");
     continue;
@@ -261,21 +205,5 @@
 
    new_player->server         = r->server;
-
-   if ( roar_get_vol(con, c.execed, &mixer, &channels) == -1 ) {
-    ROAR_ERR("esd_get_all_info(*): can not get stream mixer info");
-    new_player->left_vol_scale = new_player->right_vol_scale = 256;
-   } else {
-    fs = mixer.scale / 257;
-    if ( channels == 1 ) {
-     new_player->left_vol_scale = new_player->right_vol_scale = mixer.mixer[0] == mixer.scale ? 256 : mixer.mixer[0] / fs;
-    } else {
-     if ( channels != 2 ) {
-      ROAR_ERR("esd_get_all_info(*): server seems to run in > 2 channel mode. ignoring any but the first two channels!");
-     }
-     new_player->left_vol_scale  = mixer.mixer[0] == mixer.scale ? 256 : mixer.mixer[0] / fs;
-     new_player->right_vol_scale = mixer.mixer[1] == mixer.scale ? 256 : mixer.mixer[1] / fs;
-    }
-   }
-
+   new_player->left_vol_scale = new_player->right_vol_scale = 256; // TODO: add data from the mixer
 
    if ( r->player_list == NULL ) {
@@ -293,23 +221,10 @@
 
 /* retrieve all information from server, and update until unsubsribed or closed */
-esd_info_t *esd_subscribe_all_info( int esd ) {
- (void)esd;
- errno = ENOSYS;
- return NULL; // Not yet implemented in upstream esd
-}
+esd_info_t *esd_subscribe_all_info( int esd );
 
 /* call to update the info structure with new information, and call callbacks */
 esd_info_t *esd_update_info( int esd, esd_info_t *info,
-                             esd_update_info_callbacks_t *callbacks ) {
- (void)esd, (void)info, (void)callbacks;
- errno = ENOSYS;
- return NULL; // Not yet implemented in upstream esd
-}
-
-esd_info_t *esd_unsubscribe_info( int esd ) {
- (void)esd;
- errno = ENOSYS;
- return NULL; // Not yet implemented in upstream esd
-}
+                             esd_update_info_callbacks_t *callbacks );
+esd_info_t *esd_unsubscribe_info( int esd );
 
 /* release all memory allocated for the esd info structure */
@@ -338,9 +253,9 @@
  player = info->player_list;
 
- while (player != NULL) {
+ while (player) {
   oplayer = player;
   player  = player->next;
 
-  roar_mm_free(oplayer);
+  free(oplayer);
  }
 
@@ -351,8 +266,8 @@
   sample  = sample->next;
 
-  roar_mm_free(osample);
- }
-
-  roar_mm_free(info);
+  free(osample);
+ }
+
+  free(info);
  }
 }
@@ -362,17 +277,5 @@
 int esd_set_stream_pan( int esd, int stream_id,
                         int left_scale, int right_scale ) {
- struct roar_connection con;
- struct roar_mixer_settings mixer;
-
- roar_connect_fh(&con, esd);
-
- mixer.scale    = 256;
- mixer.mixer[0] = left_scale;
- mixer.mixer[1] = right_scale;
-
- ROAR_DBG("esd_set_stream_pan(esd=%i, stream_id=%i, left_scale=%i, right_scale=%i) = ?", 
-                esd, stream_id, left_scale, right_scale);
-
- return roar_set_vol(&con, stream_id, &mixer, 2, ROAR_SET_VOL_UNMAPPED);
+ return -1;
 }
 
@@ -380,7 +283,4 @@
 int esd_set_default_sample_pan( int esd, int sample_id,
                                 int left_scale, int right_scale ) {
- // this is not yet implemented by the RA protocol.
- (void)esd, (void)sample_id, (void)left_scale, (void)right_scale;
- errno = ENOSYS;
  return -1;
 }
@@ -388,10 +288,5 @@
 /* see if the server is in stnaby, autostandby, etc */
 esd_standby_mode_t esd_get_standby_mode( int esd ) {
- struct roar_connection con;
-
- if ( roar_connect_fh(&con, esd) == -1 )
-  return -1;
-
- return roar_get_standby(&con);
+ return roar_simple_get_standby(esd);
 }
 
