[pulseaudio-commits] 3 commits - src/modules src/pulse src/pulsecore
Tanu Kaskinen
tanuk at kemper.freedesktop.org
Sat Jan 14 07:05:03 PST 2012
src/modules/bluetooth/bluetooth-util.c | 11 ++++-------
src/pulse/def.h | 4 ++--
src/pulsecore/dbus-util.c | 14 ++++++++++++++
src/pulsecore/dbus-util.h | 8 ++++++++
4 files changed, 28 insertions(+), 9 deletions(-)
New commits:
commit 717701aa7135d0c1bc60e74a70e756d7bc0ef5ef
Author: Tanu Kaskinen <tanuk at iki.fi>
Date: Tue Dec 13 21:57:03 2011 +0200
bluetooth: When receiving D-Bus errors, print also the error message.
diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index c5befe3..15c544e 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -438,10 +438,7 @@ static void get_properties_reply(DBusPendingCall *pending, void *userdata) {
}
if (dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR) {
-
- if (!dbus_message_is_error(r, DBUS_ERROR_UNKNOWN_METHOD))
- pa_log("Error from GetProperties reply: %s", dbus_message_get_error_name(r));
-
+ pa_log("%s.GetProperties() failed: %s: %s", dbus_message_get_interface(p->message), dbus_message_get_error_name(r), pa_dbus_get_error_message(r));
goto finish;
}
@@ -548,7 +545,7 @@ static void register_endpoint_reply(DBusPendingCall *pending, void *userdata) {
}
if (dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR) {
- pa_log("Error from RegisterEndpoint reply: %s", dbus_message_get_error_name(r));
+ pa_log("org.bluez.Media.RegisterEndpoint() failed: %s: %s", dbus_message_get_error_name(r), pa_dbus_get_error_message(r));
goto finish;
}
@@ -584,7 +581,7 @@ static void list_devices_reply(DBusPendingCall *pending, void *userdata) {
}
if (dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR) {
- pa_log("Error from ListDevices reply: %s", dbus_message_get_error_name(r));
+ pa_log("org.bluez.Adapter.ListDevices() failed: %s: %s", dbus_message_get_error_name(r), pa_dbus_get_error_message(r));
goto finish;
}
@@ -689,7 +686,7 @@ static void list_adapters_reply(DBusPendingCall *pending, void *userdata) {
}
if (dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR) {
- pa_log("Error from ListAdapters reply: %s", dbus_message_get_error_name(r));
+ pa_log("org.bluez.Manager.ListAdapters() failed: %s: %s", dbus_message_get_error_name(r), pa_dbus_get_error_message(r));
goto finish;
}
commit bec34c428cca88e6afed134c070b6f1916d394ab
Author: Tanu Kaskinen <tanuk at iki.fi>
Date: Tue Dec 13 21:57:02 2011 +0200
dbus: New helper function: pa_dbus_get_error_message().
diff --git a/src/pulsecore/dbus-util.c b/src/pulsecore/dbus-util.c
index b79b752..3daf90f 100644
--- a/src/pulsecore/dbus-util.c
+++ b/src/pulsecore/dbus-util.c
@@ -452,6 +452,20 @@ void pa_dbus_free_pending_list(pa_dbus_pending **p) {
}
}
+const char *pa_dbus_get_error_message(DBusMessage *m) {
+ const char *message;
+
+ pa_assert(m);
+ pa_assert(dbus_message_get_type(m) == DBUS_MESSAGE_TYPE_ERROR);
+
+ if (dbus_message_get_signature(m)[0] != 's')
+ return "<no explanation>";
+
+ pa_assert_se(dbus_message_get_args(m, NULL, DBUS_TYPE_STRING, &message, DBUS_TYPE_INVALID));
+
+ return message;
+}
+
void pa_dbus_send_error(DBusConnection *c, DBusMessage *in_reply_to, const char *name, const char *format, ...) {
va_list ap;
char *message;
diff --git a/src/pulsecore/dbus-util.h b/src/pulsecore/dbus-util.h
index 347f9f3..e3d6e4f 100644
--- a/src/pulsecore/dbus-util.h
+++ b/src/pulsecore/dbus-util.h
@@ -67,6 +67,14 @@ void pa_dbus_sync_pending_list(pa_dbus_pending **p);
/* Free up a list of pa_dbus_pending_call objects */
void pa_dbus_free_pending_list(pa_dbus_pending **p);
+/* When receiving a DBusMessage with type DBUS_MESSAGE_TYPE_ERROR, the
+ * DBusMessage may or may not contain an error message (a human-readable
+ * explanation of what went wrong). Extracting the error message from the
+ * DBusMessage object is a bit tedious, so here's a helper function that does
+ * that. If the DBusMessage doesn't contain any error message,
+ * "<no explanation>" is returned. */
+const char *pa_dbus_get_error_message(DBusMessage *m);
+
/* Sends an error message as the reply to the given message. */
void pa_dbus_send_error(
DBusConnection *c,
commit 910bc7c2b4c56f0a8d0c1ed2f9ab98bb8f51d579
Author: Peter Meerwald <p.meerwald at bct-electronic.com>
Date: Mon Dec 12 10:59:46 2011 +0100
pulse: Turn the anonymous error code enum into pa_error_code_t.
The purpose is to make it possible to link to the
enumeration in doxygen.
diff --git a/src/pulse/def.h b/src/pulse/def.h
index 98d3651..7ca0c4b 100644
--- a/src/pulse/def.h
+++ b/src/pulse/def.h
@@ -399,7 +399,7 @@ typedef struct pa_buffer_attr {
} pa_buffer_attr;
/** Error values as used by pa_context_errno(). Use pa_strerror() to convert these values to human readable strings */
-enum {
+typedef enum pa_error_code {
PA_OK = 0, /**< No error */
PA_ERR_ACCESS, /**< Access failure */
PA_ERR_COMMAND, /**< Unknown command */
@@ -428,7 +428,7 @@ enum {
PA_ERR_IO, /**< An IO error happened. \since 0.9.16 */
PA_ERR_BUSY, /**< Device or resource busy. \since 0.9.17 */
PA_ERR_MAX /**< Not really an error but the first invalid error code */
-};
+} pa_error_code_t;
/** \cond fulldocs */
#define PA_OK PA_OK
More information about the pulseaudio-commits
mailing list