Index: plugins/gstreamer0.10/roarsink.c
===================================================================
--- plugins/gstreamer0.10/roarsink.c	(revision 4661)
+++ plugins/gstreamer0.10/roarsink.c	(revision 4662)
@@ -57,5 +57,8 @@
 {
   PROP_0,
-  PROP_HOST
+  PROP_HOST,
+  PROP_ROLE,
+  PROP_VOLUME,
+  PROP_MUTE
 };
 
@@ -74,4 +77,12 @@
         "rate = (int) [ 1, MAX ], "
         "channels = (int) [ 1, " QM(ROAR_MAX_CHANNELS) " ]; "
+
+//        "audio/x-flac; "
+
+        "audio/x-gsm; "
+
+//        "application/ogg; "
+
+//        "audio/x-wav; "
 
 /*
@@ -175,12 +186,25 @@
   g_object_class_install_property(gobject_class, PROP_HOST,
       g_param_spec_string("host", "Host",
-          "The host running the RoarAudio daemon", NULL, G_PARAM_READWRITE));
+          "The server/host running the RoarAudio daemon", NULL, G_PARAM_READWRITE));
+  g_object_class_install_property(gobject_class, PROP_HOST,
+      g_param_spec_string("server", "Server",
+          "The server/host running the RoarAudio daemon", NULL, G_PARAM_READWRITE));
+  g_object_class_install_property(gobject_class, PROP_ROLE,
+      g_param_spec_string("role", "Role",
+          "The stream role", NULL, G_PARAM_READWRITE));
+  g_object_class_install_property(gobject_class, PROP_VOLUME,
+      g_param_spec_float("volume", "Volume",
+          "The stream volume (0.0 to 1.0)", 0.0, 1.0, 1.0, G_PARAM_READWRITE));
+  g_object_class_install_property(gobject_class, PROP_MUTE,
+      g_param_spec_boolean("mute", "Mute",
+          "The mute state of the stream", FALSE, G_PARAM_READWRITE));
 }
 
 static void gst_roarsink_init (GstRoarSink * roarsink, GstRoarSinkClass * klass) {
-  memset(&(roarsink->con), 0, sizeof(roarsink->con));
-  roar_connect_fh(&(roarsink->con), -1);
-  roarsink->fd     = -1;
+  roarsink->vss    = NULL;
   roarsink->host   = NULL;
+  roarsink->role   = NULL;
+  roarsink->volume = -1;
+  roarsink->mute   = ROAR_VS_ASK;
 }
 
@@ -191,4 +215,6 @@
   if ( roarsink->host != NULL )
    g_free(roarsink->host);
+  if ( roarsink->role != NULL )
+   g_free(roarsink->role);
 
   G_OBJECT_CLASS(parent_class)->finalize(object);
@@ -201,5 +227,5 @@
 
   /* no fd, we're done with the template caps */
-  if (roar_get_connection_fh(&(roarsink->con)) < 0 || roarsink->cur_caps == NULL) {
+  if (roarsink->vss == NULL || roarsink->cur_caps == NULL) {
     GST_LOG_OBJECT(roarsink, "getcaps called, returning template caps");
     return NULL;
@@ -222,9 +248,8 @@
 
   /* now try to connect to any existing/running sound daemons */
-  if ( roar_simple_connect(&(roarsink->con), roarsink->host, "gstreamer client") == -1 )
+  if ( (roarsink->vss = roar_vs_new(roarsink->host, "gstreamer client", NULL)) == NULL )
     goto couldnt_connect;
 
-  /* get server info */
-  if ( roar_server_oinfo(&(roarsink->con), &oinfo) == -1 )
+  if ( roar_server_oinfo(roar_vs_connection_obj(roarsink->vss, NULL), &oinfo) == -1 )
     goto no_server_info;
 
@@ -269,8 +294,6 @@
   gst_caps_replace(&roarsink->cur_caps, NULL);
 
-  roar_disconnect(&(roarsink->con));
-
-  if ( roarsink->fd != -1 )
-   close(roarsink->fd);
+  roar_vs_close(roarsink->vss, ROAR_VS_FALSE, NULL);
+  roarsink->vss = NULL;
 
   return TRUE;
@@ -279,6 +302,10 @@
 static gboolean gst_roarsink_prepare (GstAudioSink * asink, GstRingBufferSpec * spec) {
   GstRoarSink *roarsink = GST_ROARSINK(asink);
-  int codec = ROAR_CODEC_DEFAULT;
-  int bits  = spec->depth;
+  struct roar_audio_info info;
+
+  info.codec    = ROAR_CODEC_DEFAULT;
+  info.bits     = spec->depth;
+  info.rate     = spec->rate;
+  info.channels = spec->channels;
 
   GST_DEBUG_OBJECT(roarsink, "prepare");
@@ -292,6 +319,6 @@
       case TRUE:
         switch (spec->bigend) {
-         case TRUE:  codec = ROAR_CODEC_PCM_S_BE; break;
-         case FALSE: codec = ROAR_CODEC_PCM_S_LE; break;
+         case TRUE:  info.codec = ROAR_CODEC_PCM_S_BE; break;
+         case FALSE: info.codec = ROAR_CODEC_PCM_S_LE; break;
          default: return FALSE; break;
         }
@@ -299,6 +326,6 @@
       case FALSE:
         switch (spec->bigend) {
-         case TRUE:  codec = ROAR_CODEC_PCM_U_BE; break;
-         case FALSE: codec = ROAR_CODEC_PCM_U_LE; break;
+         case TRUE:  info.codec = ROAR_CODEC_PCM_U_BE; break;
+         case FALSE: info.codec = ROAR_CODEC_PCM_U_LE; break;
          default: return FALSE; break;
         }
@@ -308,10 +335,14 @@
     break;
    case GST_BUFTYPE_A_LAW:
-     codec = ROAR_CODEC_ALAW;
-     bits  = 8;
+     info.codec = ROAR_CODEC_ALAW;
+     info.bits  = 8;
     break;
    case GST_BUFTYPE_MU_LAW:
-     codec = ROAR_CODEC_MULAW;
-     bits  = 8;
+     info.codec = ROAR_CODEC_MULAW;
+     info.bits  = 8;
+    break;
+   case GST_BUFTYPE_GSM:
+     info.codec = ROAR_CODEC_GSM;
+     info.bits  = 0;
     break;
    default:
@@ -319,12 +350,16 @@
   }
 
-  roarsink->fd = roar_simple_new_stream(&(roarsink->con), spec->rate, spec->channels, bits,
-                                        codec, ROAR_DIR_PLAY);
-
-  if ( roarsink->fd == -1 )
+  if ( roar_vs_stream(roarsink->vss, &info, ROAR_DIR_PLAY, NULL) == -1 )
     goto cannot_open;
 
-  roarsink->rate = spec->rate;
-
+  // apply parameters:
+  if ( roarsink->mute != ROAR_VS_ASK && roar_vs_mute(roarsink->vss, roarsink->mute, NULL) == -1 ) {
+    goto cannot_open;
+  }
+  if ( roarsink->volume >= 0.0 && roar_vs_volume_mono(roarsink->vss, roarsink->volume, NULL) == -1 ) {
+    goto cannot_open;
+  }
+
+  /* get server info */
   spec->segsize  = ROAR_BUF_SIZE;
   spec->segtotal = (ROAR_MAX_WRITE_SIZE / spec->segsize);
@@ -332,5 +367,5 @@
   /* FIXME: this is wrong for signed ints (and the
    * audioringbuffers should do it for us anyway) */
-  spec->bytes_per_sample = spec->channels * bits / 8;
+  spec->bytes_per_sample = roar_info2framesize(&info) / 8;
   memset(&(spec->silence_sample), 0, sizeof(spec->silence_sample));
 
@@ -352,9 +387,9 @@
   GstRoarSink *roarsink = GST_ROARSINK(asink);
 
-  if ((roarsink->fd == -1) && (roar_get_connection_fh(&(roarsink->con)) == -1))
+  if (roarsink->vss == NULL)
     return TRUE;
 
-  close(roarsink->fd);
-  roarsink->fd = -1;
+  roar_vs_close(roarsink->vss, ROAR_VS_FALSE, NULL);
+  roarsink->vss = NULL;
 
   GST_INFO_OBJECT(roarsink, "closed sound device");
@@ -371,7 +406,7 @@
 
   while (to_write > 0) {
-    int done;
-
-    done = write(roarsink->fd, data, to_write);
+    ssize_t done;
+
+    done = roar_vs_write(roarsink->vss, data, to_write, NULL);
 
     if (done < 0)
@@ -418,4 +453,29 @@
       roarsink->host = g_value_dup_string(value);
      break;
+    case PROP_ROLE:
+      if ( roarsink->role != NULL )
+       g_free(roarsink->role);
+      roarsink->role = g_value_dup_string(value);
+     break;
+    case PROP_VOLUME:
+      roarsink->volume = (float)g_value_get_float(value);
+
+      if ( roarsink->vss == NULL )
+       return;
+
+      roar_vs_volume_mono(roarsink->vss, roarsink->volume, NULL);
+     break;
+    case PROP_MUTE:
+      if ( g_value_get_boolean(value) ) {
+       roarsink->mute = ROAR_VS_TRUE;
+      } else {
+       roarsink->mute = ROAR_VS_FALSE;
+      }
+
+      if ( roarsink->vss == NULL )
+       return;
+
+      roar_vs_mute(roarsink->vss, roarsink->mute, NULL);
+     break;
     default:
       break;
@@ -426,8 +486,31 @@
                                        GParamSpec * pspec) {
   GstRoarSink *roarsink = GST_ROARSINK(object);
+  float l, r;
+  int ret;
 
   switch (prop_id) {
     case PROP_HOST:
       g_value_set_string(value, roarsink->host);
+     break;
+    case PROP_ROLE:
+      g_value_set_string(value, roarsink->role);
+     break;
+    case PROP_VOLUME:
+      if ( roarsink->vss == NULL || roar_vs_volume_get(roarsink->vss, &l, &r, NULL) == -1 ) {
+       l = roarsink->volume >= 0.0 ? roarsink->volume : 1.0;
+      } else {
+       l = (l + r)/2;
+       roarsink->volume = l;
+      }
+      g_value_set_float(value, l);
+     break;
+    case PROP_MUTE:
+      if ( roarsink->vss == NULL || (ret = roar_vs_mute(roarsink->vss, ROAR_VS_ASK, NULL)) == -1 ) {
+       ret = roarsink->mute != ROAR_VS_ASK ? roarsink->mute : ROAR_VS_FALSE;
+      } else {
+       roarsink->mute = ret;
+      }
+
+      g_value_set_boolean(value, ret == ROAR_VS_TRUE ? TRUE : FALSE);
      break;
     default:
