diff options
Diffstat (limited to 'audio')
-rw-r--r-- | audio/a2dp.c | 6 | ||||
-rw-r--r-- | audio/avdtp.c | 50 | ||||
-rw-r--r-- | audio/avdtp.h | 10 | ||||
-rw-r--r-- | audio/sink.c | 4 | ||||
-rw-r--r-- | audio/source.c | 4 |
5 files changed, 32 insertions, 42 deletions
diff --git a/audio/a2dp.c b/audio/a2dp.c index 323ef8722..84fd0775c 100644 --- a/audio/a2dp.c +++ b/audio/a2dp.c @@ -180,7 +180,7 @@ static gboolean finalize_config_errno(struct a2dp_setup *s, int err) { struct avdtp_error avdtp_err; - avdtp_error_init(&avdtp_err, AVDTP_ERROR_ERRNO, -err); + avdtp_error_init(&avdtp_err, AVDTP_ERRNO, -err); s->err = err ? &avdtp_err : NULL; return finalize_config(s); @@ -230,7 +230,7 @@ static gboolean finalize_suspend_errno(struct a2dp_setup *s, int err) { struct avdtp_error avdtp_err; - avdtp_error_init(&avdtp_err, AVDTP_ERROR_ERRNO, -err); + avdtp_error_init(&avdtp_err, AVDTP_ERRNO, -err); s->err = err ? &avdtp_err : NULL; return finalize_suspend(s); @@ -899,7 +899,7 @@ static void suspend_cfm(struct avdtp *session, struct avdtp_local_sep *sep, } else if (avdtp_start(session, a2dp_sep->stream) < 0) { struct avdtp_error start_err; error("avdtp_start failed"); - avdtp_error_init(&start_err, AVDTP_ERROR_ERRNO, EIO); + avdtp_error_init(&start_err, AVDTP_ERRNO, EIO); setup->err = err; finalize_suspend(setup); } diff --git a/audio/avdtp.c b/audio/avdtp.c index 6a0d60cb0..5d5d51f24 100644 --- a/audio/avdtp.c +++ b/audio/avdtp.c @@ -690,33 +690,30 @@ static void set_disconnect_timer(struct avdtp *session) session); } -void avdtp_error_init(struct avdtp_error *err, uint8_t type, int id) +void avdtp_error_init(struct avdtp_error *err, uint8_t category, int id) { - err->type = type; - switch (type) { - case AVDTP_ERROR_ERRNO: + err->category = category; + + if (category == AVDTP_ERRNO) err->err.posix_errno = id; - break; - case AVDTP_ERROR_ERROR_CODE: + else err->err.error_code = id; - break; - } } -avdtp_error_type_t avdtp_error_type(struct avdtp_error *err) +uint8_t avdtp_error_category(struct avdtp_error *err) { - return err->type; + return err->category; } int avdtp_error_error_code(struct avdtp_error *err) { - assert(err->type == AVDTP_ERROR_ERROR_CODE); + assert(err->category != AVDTP_ERRNO); return err->err.error_code; } int avdtp_error_posix_errno(struct avdtp_error *err) { - assert(err->type == AVDTP_ERROR_ERRNO); + assert(err->category == AVDTP_ERRNO); return err->err.posix_errno; } @@ -851,7 +848,7 @@ static void handle_transport_connect(struct avdtp *session, GIOChannel *io, if (io == NULL) { if (!stream->open_acp && sep->cfm && sep->cfm->open) { struct avdtp_error err; - avdtp_error_init(&err, AVDTP_ERROR_ERRNO, EIO); + avdtp_error_init(&err, AVDTP_ERRNO, EIO); sep->cfm->open(session, sep, NULL, &err, sep->user_data); } @@ -919,7 +916,7 @@ static void handle_unanswered_req(struct avdtp *session, req = session->req; session->req = NULL; - avdtp_error_init(&err, AVDTP_ERROR_ERRNO, EIO); + avdtp_error_init(&err, AVDTP_ERRNO, EIO); lsep = stream->lsep; @@ -979,7 +976,7 @@ static void avdtp_sep_set_state(struct avdtp *session, } if (sep->state == state) { - avdtp_error_init(&err, AVDTP_ERROR_ERRNO, EIO); + avdtp_error_init(&err, AVDTP_ERRNO, EIO); DBG("stream state change failed: %s", avdtp_strerror(&err)); err_ptr = &err; } else { @@ -1041,7 +1038,7 @@ static void finalize_discovery(struct avdtp *session, int err) { struct avdtp_error avdtp_err; - avdtp_error_init(&avdtp_err, AVDTP_ERROR_ERRNO, err); + avdtp_error_init(&avdtp_err, AVDTP_ERRNO, err); if (!session->discov_cb) return; @@ -2450,7 +2447,7 @@ static int cancel_request(struct avdtp *session, int err) req = session->req; session->req = NULL; - avdtp_error_init(&averr, AVDTP_ERROR_ERRNO, err); + avdtp_error_init(&averr, AVDTP_ERRNO, err); seid = req_get_seid(req); if (seid) @@ -2890,23 +2887,20 @@ static gboolean seid_rej_to_err(struct seid_rej *rej, unsigned int size, return FALSE; } - avdtp_error_init(err, AVDTP_ERROR_ERROR_CODE, rej->error); + avdtp_error_init(err, 0x00, rej->error); return TRUE; } static gboolean conf_rej_to_err(struct conf_rej *rej, unsigned int size, - struct avdtp_error *err, uint8_t *category) + struct avdtp_error *err) { if (size < sizeof(struct conf_rej)) { error("Too small packet for conf_rej"); return FALSE; } - avdtp_error_init(err, AVDTP_ERROR_ERROR_CODE, rej->error); - - if (category) - *category = rej->category; + avdtp_error_init(err, rej->category, rej->error); return TRUE; } @@ -2920,7 +2914,7 @@ static gboolean stream_rej_to_err(struct stream_rej *rej, unsigned int size, return FALSE; } - avdtp_error_init(err, AVDTP_ERROR_ERROR_CODE, rej->error); + avdtp_error_init(err, 0x00, rej->error); if (acp_seid) *acp_seid = rej->acp_seid; @@ -2934,7 +2928,7 @@ static gboolean avdtp_parse_rej(struct avdtp *session, void *buf, int size) { struct avdtp_error err; - uint8_t acp_seid, category; + uint8_t acp_seid; struct avdtp_local_sep *sep = stream ? stream->lsep : NULL; switch (signal_id) { @@ -2961,7 +2955,7 @@ static gboolean avdtp_parse_rej(struct avdtp *session, sep->user_data); return TRUE; case AVDTP_SET_CONFIGURATION: - if (!conf_rej_to_err(buf, size, &err, &category)) + if (!conf_rej_to_err(buf, size, &err)) return FALSE; error("SET_CONFIGURATION request rejected: %s (%d)", avdtp_strerror(&err), err.err.error_code); @@ -2970,7 +2964,7 @@ static gboolean avdtp_parse_rej(struct avdtp *session, &err, sep->user_data); return TRUE; case AVDTP_RECONFIGURE: - if (!conf_rej_to_err(buf, size, &err, &category)) + if (!conf_rej_to_err(buf, size, &err)) return FALSE; error("RECONFIGURE request rejected: %s (%d)", avdtp_strerror(&err), err.err.error_code); @@ -3639,7 +3633,7 @@ static GIOChannel *avdtp_server_socket(const bdaddr_t *src, gboolean master) const char *avdtp_strerror(struct avdtp_error *err) { - if (err->type == AVDTP_ERROR_ERRNO) + if (err->category == AVDTP_ERRNO) return strerror(err->err.posix_errno); switch(err->err.error_code) { diff --git a/audio/avdtp.h b/audio/avdtp.h index bf10a2f90..91c3f5ca0 100644 --- a/audio/avdtp.h +++ b/audio/avdtp.h @@ -23,11 +23,6 @@ */ typedef enum { - AVDTP_ERROR_ERRNO, - AVDTP_ERROR_ERROR_CODE -} avdtp_error_type_t; - -typedef enum { AVDTP_SESSION_STATE_DISCONNECTED, AVDTP_SESSION_STATE_CONNECTING, AVDTP_SESSION_STATE_CONNECTED @@ -38,7 +33,7 @@ struct avdtp_stream; struct avdtp_local_sep; struct avdtp_remote_sep; struct avdtp_error { - avdtp_error_type_t type; + uint8_t category; union { uint8_t error_code; int posix_errno; @@ -54,6 +49,7 @@ struct avdtp_error { #define AVDTP_MULTIPLEXING 0x06 #define AVDTP_MEDIA_CODEC 0x07 #define AVDTP_DELAY_REPORTING 0x08 +#define AVDTP_ERRNO 0xff /* AVDTP error definitions */ #define AVDTP_BAD_HEADER_FORMAT 0x01 @@ -299,7 +295,7 @@ avdtp_state_t avdtp_sep_get_state(struct avdtp_local_sep *sep); void avdtp_error_init(struct avdtp_error *err, uint8_t type, int id); const char *avdtp_strerror(struct avdtp_error *err); -avdtp_error_type_t avdtp_error_type(struct avdtp_error *err); +uint8_t avdtp_error_category(struct avdtp_error *err); int avdtp_error_error_code(struct avdtp_error *err); int avdtp_error_posix_errno(struct avdtp_error *err); diff --git a/audio/sink.c b/audio/sink.c index eb90c2175..730faf1db 100644 --- a/audio/sink.c +++ b/audio/sink.c @@ -303,7 +303,7 @@ static void stream_setup_complete(struct avdtp *session, struct a2dp_sep *sep, avdtp_unref(sink->session); sink->session = NULL; - if (avdtp_error_type(err) == AVDTP_ERROR_ERRNO + if (avdtp_error_category(err) == AVDTP_ERRNO && avdtp_error_posix_errno(err) != EHOSTDOWN) { DBG("connect:connect XCASE detected"); sink->retry_id = g_timeout_add_seconds(STREAM_SETUP_RETRY_TIMER, @@ -356,7 +356,7 @@ static void discovery_complete(struct avdtp *session, GSList *seps, struct avdtp if (err) { avdtp_unref(sink->session); sink->session = NULL; - if (avdtp_error_type(err) == AVDTP_ERROR_ERRNO + if (avdtp_error_category(err) == AVDTP_ERRNO && avdtp_error_posix_errno(err) != EHOSTDOWN) { DBG("connect:connect XCASE detected"); sink->retry_id = diff --git a/audio/source.c b/audio/source.c index e8671ed5c..8258fcd30 100644 --- a/audio/source.c +++ b/audio/source.c @@ -266,7 +266,7 @@ static void stream_setup_complete(struct avdtp *session, struct a2dp_sep *sep, avdtp_unref(source->session); source->session = NULL; - if (avdtp_error_type(err) == AVDTP_ERROR_ERRNO + if (avdtp_error_category(err) == AVDTP_ERRNO && avdtp_error_posix_errno(err) != EHOSTDOWN) { DBG("connect:connect XCASE detected"); source->retry_id = g_timeout_add_seconds(STREAM_SETUP_RETRY_TIMER, @@ -323,7 +323,7 @@ static void discovery_complete(struct avdtp *session, GSList *seps, struct avdtp if (err) { avdtp_unref(source->session); source->session = NULL; - if (avdtp_error_type(err) == AVDTP_ERROR_ERRNO + if (avdtp_error_category(err) == AVDTP_ERRNO && avdtp_error_posix_errno(err) != EHOSTDOWN) { DBG("connect:connect XCASE detected"); source->retry_id = |