Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1016528pxb; Fri, 22 Apr 2022 16:54:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweVxW2YpkQHdXvFA44zPYmy9hqY27Z670s6aTQJdY5/AsUwt8rEIqbpejvukUTRhEI4g2y X-Received: by 2002:a05:6a00:140b:b0:4e1:2cbd:30ba with SMTP id l11-20020a056a00140b00b004e12cbd30bamr7532580pfu.46.1650671645617; Fri, 22 Apr 2022 16:54:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650671645; cv=none; d=google.com; s=arc-20160816; b=AjTs+GrEpqNa98zh13zOaHwWGL8FM3scp1A1BcbxxjI/Uzhl3CBavQC5Tw2DBCFjGb YDqV8LHoF6IELzyOX75Tn+9sKaK+Cdn7vhD/hdoratpUlqRrvMalKa0qsACdbfnlhQsh zzWWpNsNWH0QEceXvaVSnE/ceBIHS3B7OvTHEqvzjEXn6nNJlS7W2sbMJTG/OwZEXeA8 k3KFNQJYdJVWRGjCB/uO0HeOSru7xYloO5dEbYRlWsI8+XW2i4RfkkX8m5J2hVG2mkkr 6XhvsazOxT2CucXMJWWErgK57E1bO+4wAowMz9N3VoXnOR2ynI6D9vWBfbNuzvYrHloA 41eQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=VwXztr1Qvr5PubM1CiKYb4IekDbtGYFCPUSjoXnS6NQ=; b=gXMz/awcDpVQbF7PWSXMkDR79a1h1ComOorLGPnUUjI8PfxNZowfDHjHibijCrcgpo +y6qrvqGibaMwFpG8HNw+xUlcQDOlSkn8QkFfAc0ouXnYWOFMp1gwu4rxpB3xzy371MB tLEsQ5pqtxCyGL511mILZa72b9JWcNPlgtuiXtdNUlfj1kqrRO7IhmCFcX8npwAyy01N tIItjrFBZaufmNoi3l7w7ICAc4a/3aBBPGd7jKKquqQjRI7CWaOxF12E9l5AxR/jE+aV F7gRAZ7+SC6+bcDGE/F7IlrSVRad2lF4nG8HsSxMowE7O+G2sHWHXNTMLByL81U6V5yM 82wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=W9yX9OmA; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id r123-20020a632b81000000b0039ce0b69438si9559645pgr.370.2022.04.22.16.54.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 16:54:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=W9yX9OmA; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BBED2303; Fri, 22 Apr 2022 16:24:00 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229631AbiDVX0l (ORCPT + 99 others); Fri, 22 Apr 2022 19:26:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229580AbiDVX03 (ORCPT ); Fri, 22 Apr 2022 19:26:29 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D484E81199 for ; Fri, 22 Apr 2022 16:02:40 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id x80so9316452pfc.1 for ; Fri, 22 Apr 2022 16:02:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=VwXztr1Qvr5PubM1CiKYb4IekDbtGYFCPUSjoXnS6NQ=; b=W9yX9OmAEBA6BP7lApI4u+rax2bGXZ8gaKsj8d4DHQfb08lWKXXq8oz3L034iDmITP Ou2h/cexc/0bJtTz6G+VPfQAvIE5OHud4NbeBfUozQXzqTlxdOPc09jvKSQPqTjd95QK Kf7oswybsmGS7kgs4Y8iNmmMEvPAjAkzdjYtFd8j+XD3Z1pzt+OzwKWv6rNlfxXfppHn S1AAppRou5yw2ovqsFjnLR6MR8y6Sq1k3uduihC6wmYapdJywWB1ubHHK65jlbknQ+X3 Ryqb7utc7KXtHz30sAi9fKqnO+IfOXJCkWOpJl4HWgUgLDGppjQHM0XZEPdB+ysafhhd gjUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=VwXztr1Qvr5PubM1CiKYb4IekDbtGYFCPUSjoXnS6NQ=; b=nF/0Ap9G1ji5s4EGxc7zdLDE5f29VACNRj3sPCAj1kwDoMy0qqqdnnXY4dT4y+EaeS 0zYQyRq7qVylldXWam59C89TtsqSZYhi8pHhi+y/zusu3yBs7iDylV3157tM9rqx5zTn q02iPOVxnRabQMI0flReajG1Y3uiA48rPwOHsdEhhWhIW/DY/+LSss0dMU+wO8mwDEJ0 ihReqTQJE9nYZwnrQTqj8bk3PyqByRlwlLe7l3FMsOH7P9ZbC+pbj1sJijAJawUVz7sV UNkW8K5VleePvMwOGbmnIpncQbVgrq/MdmzwcYI6W0ijaBpmG81BRvVAKELu6Bc+Tf1v m+Sg== X-Gm-Message-State: AOAM532P6pDQ0nmQNXfFacAY4Z8zoNXdyiMFfLhqm2EOgdWxEe84pGV5 Rgmj4EO0hhzXUb/GLW6v5ufEFKz89d0= X-Received: by 2002:a05:6a00:1895:b0:50a:6a91:e833 with SMTP id x21-20020a056a00189500b0050a6a91e833mr7373793pfh.26.1650668559966; Fri, 22 Apr 2022 16:02:39 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id q9-20020a056a00088900b004fe1a045e97sm3679497pfj.118.2022.04.22.16.02.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 16:02:39 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ] client/player: Add transport.volume command Date: Fri, 22 Apr 2022 16:02:38 -0700 Message-Id: <20220422230238.3836087-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This adds transport.volume command: Get/Set transport volume Usage: volume [value] --- client/player.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/client/player.c b/client/player.c index 127b55c1f..315cde712 100644 --- a/client/player.c +++ b/client/player.c @@ -572,11 +572,13 @@ static void print_iter(const char *label, const char *name, break; case DBUS_TYPE_UINT32: dbus_message_iter_get_basic(iter, &valu32); - bt_shell_printf("%s%s: 0x%06x\n", label, name, valu32); + bt_shell_printf("%s%s: 0x%08x (%u)\n", label, name, valu32, + valu32); break; case DBUS_TYPE_UINT16: dbus_message_iter_get_basic(iter, &valu16); - bt_shell_printf("%s%s: 0x%04x\n", label, name, valu16); + bt_shell_printf("%s%s: 0x%04x (%u)\n", label, name, valu16, + valu16); break; case DBUS_TYPE_INT16: dbus_message_iter_get_basic(iter, &vals16); @@ -2525,6 +2527,51 @@ static void cmd_send_transport(int argc, char *argv[]) return bt_shell_noninteractive_quit(EXIT_SUCCESS); } +static void volume_callback(const DBusError *error, void *user_data) +{ + if (dbus_error_is_set(error)) { + bt_shell_printf("Failed to set Volume: %s\n", error->name); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + bt_shell_printf("Changing Volume succeeded\n"); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_volume_transport(int argc, char *argv[]) +{ + GDBusProxy *proxy; + char *endptr = NULL; + int volume; + + proxy = g_dbus_proxy_lookup(transports, NULL, argv[1], + BLUEZ_MEDIA_TRANSPORT_INTERFACE); + if (!proxy) { + bt_shell_printf("Transport %s not found\n", argv[1]); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + + if (argc == 2) { + print_property(proxy, "Volume"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + volume = strtol(argv[2], &endptr, 0); + if (!endptr || *endptr != '\0' || volume > UINT16_MAX) { + bt_shell_printf("Invalid argument: %s\n", argv[2]); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!g_dbus_proxy_set_property_basic(proxy, "Volume", DBUS_TYPE_UINT16, + &volume, volume_callback, + NULL, NULL)) { + bt_shell_printf("Failed release transport\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } +} + static const struct bt_shell_menu transport_menu = { .name = "transport", .desc = "Media Transport Submenu", @@ -2542,6 +2589,9 @@ static const struct bt_shell_menu transport_menu = { transport_generator }, { "send", "", cmd_send_transport, "Send contents of a file" }, + { "volume", " [value]", cmd_volume_transport, + "Get/Set transport volume", + transport_generator }, {} }, }; -- 2.35.1