~ubuntu-branches/ubuntu/oneiric/bluez/oneiric-201105191013

« back to all changes in this revision

Viewing changes to audio/control.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2010-12-20 16:08:47 UTC
  • mfrom: (1.1.24 upstream)
  • Revision ID: james.westby@ubuntu.com-20101220160847-wc1907sgz6x3vjz7
Tags: 4.82-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
973
973
        struct avctp_header *avctp = (void *) buf;
974
974
        struct avrcp_header *avrcp = (void *) &buf[AVCTP_HEADER_LENGTH];
975
975
        uint8_t *operands = &buf[AVCTP_HEADER_LENGTH + AVRCP_HEADER_LENGTH];
976
 
        int err, sk = g_io_channel_unix_get_fd(control->io);
 
976
        int sk = g_io_channel_unix_get_fd(control->io);
977
977
        static uint8_t transaction = 0;
978
978
 
979
979
        memset(buf, 0, sizeof(buf));
990
990
        operands[0] = op & 0x7f;
991
991
        operands[1] = 0;
992
992
 
993
 
        err = write(sk, buf, sizeof(buf));
994
 
        if (err < 0)
995
 
                return err;
 
993
        if (write(sk, buf, sizeof(buf)) < 0)
 
994
                return -errno;
996
995
 
997
996
        /* Button release */
998
997
        avctp->transaction = transaction++;
999
998
        operands[0] |= 0x80;
1000
999
 
1001
 
        return write(sk, buf, sizeof(buf));
 
1000
        if (write(sk, buf, sizeof(buf)) < 0)
 
1001
                return -errno;
 
1002
 
 
1003
        return 0;
1002
1004
}
1003
1005
 
1004
1006
static DBusMessage *volume_up(DBusConnection *conn, DBusMessage *msg,
1014
1016
                return NULL;
1015
1017
 
1016
1018
        if (control->state != AVCTP_STATE_CONNECTED)
1017
 
                return g_dbus_create_error(msg,
1018
 
                                        ERROR_INTERFACE ".NotConnected",
1019
 
                                        "Device not Connected");
 
1019
                return btd_error_not_connected(msg);
1020
1020
 
1021
1021
        if (!control->target)
1022
 
                return g_dbus_create_error(msg,
1023
 
                                        ERROR_INTERFACE ".NotSupported",
1024
 
                                        "AVRCP Target role not supported");
 
1022
                return btd_error_not_supported(msg);
1025
1023
 
1026
1024
        err = avctp_send_passthrough(control, VOL_UP_OP);
1027
1025
        if (err < 0)
1028
 
                return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
1029
 
                                                        "%s", strerror(-err));
 
1026
                return btd_error_failed(msg, strerror(-err));
1030
1027
 
1031
1028
        return dbus_message_new_method_return(msg);
1032
1029
}
1044
1041
                return NULL;
1045
1042
 
1046
1043
        if (control->state != AVCTP_STATE_CONNECTED)
1047
 
                return g_dbus_create_error(msg,
1048
 
                                        ERROR_INTERFACE ".NotConnected",
1049
 
                                        "Device not Connected");
 
1044
                return btd_error_not_connected(msg);
1050
1045
 
1051
1046
        if (!control->target)
1052
 
                return g_dbus_create_error(msg,
1053
 
                                        ERROR_INTERFACE ".NotSupported",
1054
 
                                        "AVRCP Target role not supported");
 
1047
                return btd_error_not_supported(msg);
1055
1048
 
1056
1049
        err = avctp_send_passthrough(control, VOL_DOWN_OP);
1057
1050
        if (err < 0)
1058
 
                return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
1059
 
                                                        "%s", strerror(-err));
 
1051
                return btd_error_failed(msg, strerror(-err));
1060
1052
 
1061
1053
        return dbus_message_new_method_return(msg);
1062
1054
}