Mercurial > audlegacy
changeset 3915:86c9abc83fbd
audacious remote functions:
- functions for equalizer manipulation have been implemented.
audtool:
- test suite for equalizer manipulation has been implemented.
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Wed, 07 Nov 2007 23:18:29 +0900 |
parents | 1a4add0eba07 |
children | 92c12d945d99 |
files | src/audacious/dbus-service.h src/audacious/dbus.c src/audacious/objects.xml src/audacious/ui_equalizer.c src/audtool/audtool.h src/audtool/audtool_handlers_test.c src/audtool/audtool_main.c src/libaudclient/audctrl.c src/libaudclient/audctrl.h |
diffstat | 9 files changed, 279 insertions(+), 64 deletions(-) [+] |
line wrap: on
line diff
--- a/src/audacious/dbus-service.h Tue Nov 06 20:46:19 2007 -0600 +++ b/src/audacious/dbus-service.h Wed Nov 07 23:18:29 2007 +0900 @@ -201,10 +201,15 @@ gboolean audacious_rc_playqueue_clear(RemoteObject *obj, GError **error); gboolean audacious_rc_playqueue_is_queued(RemoteObject *obj, gint pos, gboolean *is_queued, GError **error); gboolean audacious_rc_playlist_ins_url_string(RemoteObject *obj, gchar *url, gint pos, GError **error); - +gboolean audacious_rc_playlist_enqueue_to_temp(RemoteObject *obj, gchar *url, GError **error); +gboolean audacious_rc_playlist_add(RemoteObject *obj, gpointer list, GError **error); -/* in progress */ -gboolean audacious_rc_playlist_add(RemoteObject *obj, gpointer list, GError **error); -gboolean audacious_rc_playlist_enqueue_to_temp(RemoteObject *obj, gchar *url, GError **error); +/* new on nov 7 */ +gboolean audacious_rc_get_eq(RemoteObject *obj, gdouble *preamp, GArray **bands, GError **error); +gboolean audacious_rc_get_eq_preamp(RemoteObject *obj, gdouble *preamp, GError **error); +gboolean audacious_rc_get_eq_band(RemoteObject *obj, gint band, gdouble *value, GError **error); +gboolean audacious_rc_set_eq(RemoteObject *obj, gdouble preamp, GArray *bands, GError **error); +gboolean audacious_rc_set_eq_preamp(RemoteObject *obj, gdouble preamp, GError **error); +gboolean audacious_rc_set_eq_band(RemoteObject *obj, gint band, gdouble value, GError **error); #endif // !_DBUS_SERVICE_H
--- a/src/audacious/dbus.c Tue Nov 06 20:46:19 2007 -0600 +++ b/src/audacious/dbus.c Wed Nov 07 23:18:29 2007 +0900 @@ -854,7 +854,7 @@ return TRUE; } -/* New on Oct9: Queue */ +/* New on Oct 9: Queue */ gboolean audacious_rc_playqueue_add(RemoteObject *obj, gint pos, GError **error) { if (pos < (guint)playlist_get_length(playlist_get_active())) playlist_queue_position(playlist_get_active(), pos); @@ -935,9 +935,60 @@ return TRUE; } +/* New on Nov 7: Equalizer */ +gboolean audacious_rc_get_eq(RemoteObject *obj, gdouble *preamp, GArray **bands, GError **error) +{ + int i; + *preamp = (gdouble)equalizerwin_get_preamp(); + *bands = g_array_sized_new(FALSE, FALSE, sizeof(gdouble), 10); + + for(i=0; i<10; i++){ + gdouble val = (gdouble)equalizerwin_get_band(i); + g_array_append_val(*bands, val); + } + + return TRUE; +} + +gboolean audacious_rc_get_eq_preamp(RemoteObject *obj, gdouble *preamp, GError **error) +{ + *preamp = (gdouble)equalizerwin_get_preamp(); + return TRUE; +} -/********************************************************************************/ +gboolean audacious_rc_get_eq_band(RemoteObject *obj, gint band, gdouble *value, GError **error) +{ + *value = (gdouble)equalizerwin_get_band(band); + return TRUE; +} + +gboolean audacious_rc_set_eq(RemoteObject *obj, gdouble preamp, GArray *bands, GError **error) +{ + gdouble element; + int i; + + equalizerwin_set_preamp((gfloat)preamp); + + for (i = 0; i < 10; i++) { + element = g_array_index(bands, gdouble, i); + equalizerwin_set_band(i, (gfloat)element); + } + + return TRUE; +} + +gboolean audacious_rc_set_eq_preamp(RemoteObject *obj, gdouble preamp, GError **error) +{ + equalizerwin_set_preamp((gfloat)preamp); + return TRUE; +} + +gboolean audacious_rc_set_eq_band(RemoteObject *obj, gint band, gdouble value, GError **error) +{ + equalizerwin_set_band(band, (gfloat)value); + return TRUE; +} DBusGProxy *audacious_get_dbus_proxy(void) {
--- a/src/audacious/objects.xml Tue Nov 06 20:46:19 2007 -0600 +++ b/src/audacious/objects.xml Wed Nov 07 23:18:29 2007 +0900 @@ -77,17 +77,18 @@ CMD_PLAYLIST_INS_URL_STRING CMD_PLAYLIST_ENQUEUE_TO_TEMP CMD_PLAYLIST_ADD + CMD_GET_EQ //CHANGED: now these functions use double due to dbus-glib restriction + CMD_GET_EQ_PREAMP + CMD_GET_EQ_BAND //NOTE: GArray is used for bands + CMD_SET_EQ + CMD_SET_EQ_PREAMP + CMD_SET_EQ_BAND - Remaining: + Obsolete: CMD_PLAYLIST_INS //unnecessary? CMD_GET_EQ_DATA //obsolete CMD_SET_EQ_DATA //obsolete - CMD_GET_EQ - CMD_GET_EQ_PREAMP - CMD_GET_EQ_BAND - CMD_SET_EQ - CMD_SET_EQ_PREAMP - CMD_SET_EQ_BAND + --> <node name="/"> @@ -461,5 +462,38 @@ <arg type="s" name="url"/> </method> + <!-- equalizer --> + <method name="GetEq"> + <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/> + <arg type="d" direction="out" name="preamp"/> + <arg type="ad" direction="out" name="bands"/> + </method> + + <method name="GetEqPreamp"> + <arg type="d" direction="out" name="preamp"/> + </method> + + <method name="GetEqBand"> + <arg type="i" name="band"/> + <arg type="d" direction="out" name="value"/> + </method> + + <method name="SetEq"> + <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/> + <arg type="d" name="preamp"/> + <arg type="ad" name="bands"/> + </method> + + <method name="SetEqPreamp"> + <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/> + <arg type="d" name="preamp"/> + </method> + + <method name="SetEqBand"> + <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/> + <arg type="i" name="band"/> + <arg type="d" name="value"/> + </method> + </interface> </node>
--- a/src/audacious/ui_equalizer.c Tue Nov 06 20:46:19 2007 -0600 +++ b/src/audacious/ui_equalizer.c Wed Nov 07 23:18:29 2007 +0900 @@ -1282,7 +1282,7 @@ gfloat equalizerwin_get_band(gint band) { - g_return_val_if_fail(band >= 0 && band < 10, 0); + g_return_val_if_fail(band >= 0 && band < 10, 0.0); return ui_skinned_equalizer_slider_get_position(equalizerwin_bands[band]); }
--- a/src/audtool/audtool.h Tue Nov 06 20:46:19 2007 -0600 +++ b/src/audtool/audtool.h Wed Nov 07 23:18:29 2007 +0900 @@ -123,4 +123,11 @@ extern void test_ins_url_string(gint argc, gchar **argv); extern void test_get_version(gint argc, gchar **argv); +extern void test_get_eq(gint argc, gchar **argv); +extern void test_get_eq_preamp(gint argc, gchar **argv); +extern void test_get_eq_band(gint argc, gchar **argv); +extern void test_set_eq(gint argc, gchar **argv); +extern void test_set_eq_preamp(gint argc, gchar **argv); +extern void test_set_eq_band(gint argc, gchar **argv); + #endif
--- a/src/audtool/audtool_handlers_test.c Tue Nov 06 20:46:19 2007 -0600 +++ b/src/audtool/audtool_handlers_test.c Wed Nov 07 23:18:29 2007 +0900 @@ -44,24 +44,24 @@ void test_enqueue_to_temp(gint argc, gchar **argv) { - if (argc < 2) - { - audtool_whine("invalid parameters for %s.", argv[0]); - audtool_whine("syntax: %s <url>", argv[0]); - exit(1); - } + if (argc < 2) + { + audtool_whine("invalid parameters for %s.", argv[0]); + audtool_whine("syntax: %s <url>", argv[0]); + exit(1); + } audacious_remote_playlist_enqueue_to_temp(dbus_proxy, argv[1]); } void test_toggle_aot(gint argc, gchar **argv) { - if (argc < 2) - { - audtool_whine("invalid parameters for %s.", argv[0]); - audtool_whine("syntax: %s <on/off>", argv[0]); - exit(1); - } + if (argc < 2) + { + audtool_whine("invalid parameters for %s.", argv[0]); + audtool_whine("syntax: %s <on/off>", argv[0]); + exit(1); + } if (!g_ascii_strcasecmp(argv[1], "on")) { audacious_remote_toggle_aot(dbus_proxy, TRUE); @@ -83,12 +83,12 @@ void test_set_skin(gint argc, gchar **argv) { - if (argc < 2) - { - audtool_whine("invalid parameters for %s.", argv[0]); - audtool_whine("syntax: %s <skin>", argv[0]); - exit(1); - } + if (argc < 2) + { + audtool_whine("invalid parameters for %s.", argv[0]); + audtool_whine("syntax: %s <skin>", argv[0]); + exit(1); + } if(!argv[1] || !strcmp(argv[1], "")) return; @@ -108,12 +108,12 @@ { gint pos = -1; - if (argc < 3) - { - audtool_whine("invalid parameters for %s.", argv[0]); - audtool_whine("syntax: %s <url> <position>", argv[0]); - exit(1); - } + if (argc < 3) + { + audtool_whine("invalid parameters for %s.", argv[0]); + audtool_whine("syntax: %s <url> <position>", argv[0]); + exit(1); + } pos = atoi(argv[2]) - 1; if(pos >= 0) @@ -128,3 +128,104 @@ audtool_report("Audacious %s", version); g_free(version); } + +void test_get_eq(gint argc, gchar **argv) +{ + double preamp; + GArray *bands; + int i; + + audacious_remote_get_eq(dbus_proxy, &preamp, &bands); + + audtool_report("preamp = %.2f", preamp); + for(i=0; i<10; i++){ + printf("%.2f ", g_array_index(bands, gdouble, i)); + } + printf("\n"); + g_array_free(bands, TRUE); +} + +void test_get_eq_preamp(gint argc, gchar **argv) +{ + audtool_report("preamp = %.2f", audacious_remote_get_eq_preamp(dbus_proxy)); +} + +void test_get_eq_band(gint argc, gchar **argv) +{ + int band; + + if (argc < 2) + { + audtool_whine("invalid parameters for %s.", argv[0]); + audtool_whine("syntax: %s <band>", argv[0]); + exit(1); + } + + band = atoi(argv[1]); + + if (band < 0 || band > 9) + { + audtool_whine("band number out of range"); + exit(1); + } + + audtool_report("band %d = %.2f", band, audacious_remote_get_eq_band(dbus_proxy, band)); + +} + +void test_set_eq(gint argc, gchar **argv) +{ + gdouble preamp; + GArray *bands = g_array_sized_new(FALSE, FALSE, sizeof(gdouble), 10); + int i; + + if (argc < 12) + { + audtool_whine("invalid parameters for %s.", argv[0]); + audtool_whine("syntax: %s <preamp> <band0> <band1> <band2> <band3> <band4> <band5> <band6> <band7> <band8> <band9>", argv[0]); + exit(1); + } + + preamp = atof(argv[1]); + + for(i=0; i<10; i++){ + gdouble val = atof(argv[i+2]); + g_array_append_val(bands, val); + } + + audacious_remote_set_eq(dbus_proxy, preamp, bands); +} + +void test_set_eq_preamp(gint argc, gchar **argv) +{ + gdouble preamp; + + if (argc < 2) + { + audtool_whine("invalid parameters for %s.", argv[0]); + audtool_whine("syntax: %s <preamp>", argv[0]); + exit(1); + } + + preamp = atof(argv[1]); + + audacious_remote_set_eq_preamp(dbus_proxy, preamp); +} + +void test_set_eq_band(gint argc, gchar **argv) +{ + int band; + gdouble preamp; + + if (argc < 3) + { + audtool_whine("invalid parameters for %s.", argv[0]); + audtool_whine("syntax: %s <band> <value>", argv[0]); + exit(1); + } + + band = atoi(argv[1]); + preamp = atof(argv[2]); + + audacious_remote_set_eq_band(dbus_proxy, band, preamp); +}
--- a/src/audtool/audtool_main.c Tue Nov 06 20:46:19 2007 -0600 +++ b/src/audtool/audtool_main.c Wed Nov 07 23:18:29 2007 +0900 @@ -119,6 +119,14 @@ {"playlist-insurl", test_ins_url_string, "inserts a url at specified position in the playlist", 2}, {"get-version", test_get_version, "get version of audacious", 0}, + /* test suite for equalizer */ + {"get-eq", test_get_eq, "get equalizer", 0}, + {"get-eq-preamp", test_get_eq_preamp, "get equalizer pre-amplitude", 0}, + {"get-eq-band", test_get_eq_band, "get equalizer bands", 1}, + {"set-eq", test_set_eq, "set equalizer", 11}, + {"set-eq-preamp", test_set_eq_preamp, "set equalizer pre-amplitude", 1}, + {"set-eq-band", test_set_eq_band, "set equalizer bands", 2}, + {NULL, NULL, NULL, 0} };
--- a/src/libaudclient/audctrl.c Tue Nov 06 20:46:19 2007 -0600 +++ b/src/libaudclient/audctrl.c Wed Nov 07 23:18:29 2007 +0900 @@ -367,7 +367,7 @@ **/ gchar *audacious_remote_get_skin(DBusGProxy *proxy) { gchar *skin = NULL; - org_atheme_audacious_get_skin (proxy, &skin, &error); // xxx + org_atheme_audacious_get_skin (proxy, &skin, &error); g_clear_error(&error); return skin; } @@ -688,9 +688,9 @@ * * Queries audacious about the equalizer settings. **/ -void audacious_remote_get_eq(DBusGProxy *proxy, gfloat *preamp, - gfloat **bands) { -//XXX +void audacious_remote_get_eq(DBusGProxy *proxy, gdouble *preamp, GArray **bands) { + org_atheme_audacious_get_eq(proxy, preamp, bands, &error); + g_clear_error(&error); } /** @@ -701,9 +701,13 @@ * * Return value: The equalizer preamp's setting. **/ -gfloat audacious_remote_get_eq_preamp(DBusGProxy *proxy) { -//XXX - return 0.0; +gdouble audacious_remote_get_eq_preamp(DBusGProxy *proxy) { + gdouble preamp = 0.0; + + org_atheme_audacious_get_eq_preamp(proxy, &preamp, &error); + g_clear_error(&error); + + return preamp; } /** @@ -715,9 +719,13 @@ * * Return value: The equalizer band's value. **/ -gfloat audacious_remote_get_eq_band(DBusGProxy *proxy, gint band) { -//XXX - return 0.0; +gdouble audacious_remote_get_eq_band(DBusGProxy *proxy, gint band) { + gdouble value = 0.0; + + org_atheme_audacious_get_eq_band(proxy, band, &value, &error); + g_clear_error(&error); + + return value; } /** @@ -728,9 +736,9 @@ * * Tells audacious to set the equalizer up using the provided values. **/ -void audacious_remote_set_eq(DBusGProxy *proxy, gfloat preamp, - gfloat *bands) { -//XXX +void audacious_remote_set_eq(DBusGProxy *proxy, gdouble preamp, GArray *bands) { + org_atheme_audacious_set_eq(proxy, preamp, bands, &error); + g_clear_error(&error); } /** @@ -740,8 +748,9 @@ * * Tells audacious to set the equalizer's preamp setting. **/ -void audacious_remote_set_eq_preamp(DBusGProxy *proxy, gfloat preamp) { -//XXX +void audacious_remote_set_eq_preamp(DBusGProxy *proxy, gdouble preamp) { + org_atheme_audacious_set_eq_preamp(proxy, preamp, &error); + g_clear_error(&error); } /** @@ -752,9 +761,9 @@ * * Tells audacious to set an equalizer band's setting. **/ -void audacious_remote_set_eq_band(DBusGProxy *proxy, gint band, - gfloat value) { -//XXX +void audacious_remote_set_eq_band(DBusGProxy *proxy, gint band, gdouble value) { + org_atheme_audacious_set_eq_band(proxy, band, value, &error); + g_clear_error(&error); } /**
--- a/src/libaudclient/audctrl.h Tue Nov 06 20:46:19 2007 -0600 +++ b/src/libaudclient/audctrl.h Wed Nov 07 23:18:29 2007 +0900 @@ -74,15 +74,15 @@ void audacious_remote_toggle_shuffle(DBusGProxy *proxy); gboolean audacious_remote_is_repeat(DBusGProxy *proxy); gboolean audacious_remote_is_shuffle(DBusGProxy *proxy); - void audacious_remote_get_eq(DBusGProxy *proxy, gfloat *preamp, - gfloat **bands); - gfloat audacious_remote_get_eq_preamp(DBusGProxy *proxy); - gfloat audacious_remote_get_eq_band(DBusGProxy *proxy, gint band); - void audacious_remote_set_eq(DBusGProxy *proxy, gfloat preamp, - gfloat *bands); - void audacious_remote_set_eq_preamp(DBusGProxy *proxy, gfloat preamp); + void audacious_remote_get_eq(DBusGProxy *proxy, gdouble *preamp, + GArray **bands); + gdouble audacious_remote_get_eq_preamp(DBusGProxy *proxy); + gdouble audacious_remote_get_eq_band(DBusGProxy *proxy, gint band); + void audacious_remote_set_eq(DBusGProxy *proxy, gdouble preamp, + GArray *bands); + void audacious_remote_set_eq_preamp(DBusGProxy *proxy, gdouble preamp); void audacious_remote_set_eq_band(DBusGProxy *proxy, gint band, - gfloat value); + gdouble value); /* Added in XMMS 1.2.1 */ void audacious_remote_quit(DBusGProxy *proxy);