void set_volume (cli_infos_t *infos, gchar *channel, gint volume) { xmmsc_result_t *res; xmmsv_t *val; GList *it, *channels = NULL; if (!channel) { /* get all channels */ res = xmmsc_playback_volume_get (infos->sync); xmmsc_result_wait (res); val = xmmsc_result_get_value (res); xmmsv_dict_foreach (val, dict_keys, &channels); xmmsc_result_unref (res); } else { channels = g_list_prepend (channels, g_strdup (channel)); } /* set volumes for channels in list */ for (it = g_list_first (channels); it != NULL; it = g_list_next (it)) { res = xmmsc_playback_volume_set (infos->sync, it->data, volume); xmmsc_result_wait (res); xmmsc_result_unref (res); /* free channel string */ g_free (it->data); } g_list_free (channels); cli_infos_loop_resume (infos); }
/* * call-seq: * xc.playback_volume_set(channel, volume) -> result * * Sets playback volume for _channel_ to _volume_. */ static VALUE c_playback_volume_set (VALUE self, VALUE channel, VALUE volume) { RbXmmsClient *xmms = NULL; xmmsc_result_t *res; Data_Get_Struct (self, RbXmmsClient, xmms); CHECK_DELETED (xmms); Check_Type (channel, T_SYMBOL); Check_Type (volume, T_FIXNUM); res = xmmsc_playback_volume_set (xmms->real, rb_id2name (SYM2ID (channel)), NUM2INT (volume)); return TO_XMMS_CLIENT_RESULT (self, res); }