Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1700668rwb; Thu, 15 Dec 2022 13:16:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXuukYkK3Z0K/AbRMk+yH+hWJnp73cDNx+HMWv9GzAJks9mwmqEQPkdWq67JhYoViW6quLHc X-Received: by 2002:a05:6402:4491:b0:46f:7453:dd84 with SMTP id er17-20020a056402449100b0046f7453dd84mr7315769edb.40.1671139012645; Thu, 15 Dec 2022 13:16:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671139012; cv=none; d=google.com; s=arc-20160816; b=vt7VycaUPiCT4DfouixOeaUx5SiQs/tRnYDwb5Jy++A9w3ODcII8x5Y67YlNd/jjCL wbrIdViFIUXpS7qHeuRxDapXPbw25JXwIQ/Gnh472QHWNbPOQvVM1BUqr+kuKoknd0Vt JZaiCq1I75cVuwyRQAA+rSgTjfxU4BJA/DhblZU1DssZ01FfVATDx6khLHIZqa7z/88y kChcS23uWqjtz+xjabx4ECunRUNEaaai3UAe7zUeDgy+quGshqS0BRhNfFZZTXw32NuV HIMXNcM7gKCxKb27iAp3d/Qa9CRQDKt9F4j1XePI20ogxe0QqEkT/zLGxKaVyWsUYOAx rZ9A== 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 :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=pJsP1JYOTVWNXZaAAf4aqeAwsVljV5PglWKu2WbNtNs=; b=Ny5GDAcLumwQRho7W4GWm2GCSpv8y5uq+mP5tyMYLNvzXnaeb4yQW7DWEMcPNASBr4 U2ZIqu0x9156+ctejhmkx42cux4kAP9dA/CwLLcgePROm4c+V+ENKsan1KK9P9FBdHHV e4rKLLZt8aCqcglG8pab7tOWhaskP9Kgdv50HKG1WH0rtQlNM3memPOhsz713xF5GNVW L3DNIn/8KzW+WzBSGEadhqqtJ+dHFSHVBaTDuUjgOxkyYekMzHfNxGAfqrHHC/jLiLTC 8HPynabQPw1XKINr1MMoJoy/9og5bl8FTBuCvGbO5nAzyFn5z/D91/E8iM/yytijPoP3 LbPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qksuDV5s; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u14-20020a50c04e000000b0046b4156d18dsi425030edd.44.2022.12.15.13.16.27; Thu, 15 Dec 2022 13:16:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qksuDV5s; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229774AbiLOVLA (ORCPT + 99 others); Thu, 15 Dec 2022 16:11:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229926AbiLOVKp (ORCPT ); Thu, 15 Dec 2022 16:10:45 -0500 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D1AC5F7C for ; Thu, 15 Dec 2022 13:10:43 -0800 (PST) Received: by mail-pg1-x52c.google.com with SMTP id f3so480408pgc.2 for ; Thu, 15 Dec 2022 13:10:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=pJsP1JYOTVWNXZaAAf4aqeAwsVljV5PglWKu2WbNtNs=; b=qksuDV5s70pIDOLQbuzta6KXUN0qfb4UgqAl/Yu+70iyHmVcjlbBoH+ef2rQ0ZkJda WX88pVJv2HaGS1o9mP4uhvTebN8rGoxhjP0+OgmdoASayHVEuln7+GBenU2kCN32c1wn RLQNjq/KtHaN1yEL4zpzQjLM9EtA26p7yVDGCghZHaq8xPixZnBlNw61BNwTjFg+IyIV PzCBxV4G3FLVOnpEadHnHklLlf3CDIWKaXlAfFarLsw0OtO4vkPeD0wUySOFowWN94JP X8U1B/5Kxxa25tPjCFVWKgdmdZurkRxc8Nk/zy+YPC57NUNPEmn7EBhF8nRc3HnIYM4h X+6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pJsP1JYOTVWNXZaAAf4aqeAwsVljV5PglWKu2WbNtNs=; b=0hhu06FUo/OolriC2zGzQzhXgKNCTrsuc+pYfyS5EhUqk8qaQbQE+HQZroAJUL/33x gwAypXbowjccHH+p25aPJKpR1QZtgH6SY1qYnBOpNVnheYs9xoaiGr7Lkos4tvLeYzEq LvjKt5dKukGxkC+ap2E56J2I9b5Us2Oz8rmrzhJz/WDB1M08CKAsGBbyhpmf7kv3OAXs vStXLJBHgwAmug4p7YuZ4Wosco4NsU+AWvS9Fk0SqRd8vYo1uSo1UF6HPbN5lyEsE71d K86GADEaqw7CPsS69P1hdLP592IeNPB9NjJlHqFGlHpJ8j1F6jkCQtgMztaxfQ9T85A/ GmsQ== X-Gm-Message-State: ANoB5pmY2va9F47iRS2+EVmYCj6zneouWUvXlqKrak7bAOvO1ASLuoFV /KkUg6F0s4FF8uhqKFss+bo0w6hoE7z+EVQ4 X-Received: by 2002:a05:6a00:796:b0:577:3523:bd23 with SMTP id g22-20020a056a00079600b005773523bd23mr30721586pfu.27.1671138642218; Thu, 15 Dec 2022 13:10:42 -0800 (PST) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id c20-20020aa79534000000b005779110635asm54908pfp.51.2022.12.15.13.10.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 13:10:41 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v2 3/5] client/player: Use bt_shell_echo to print transfer progress Date: Thu, 15 Dec 2022 13:10:35 -0800 Message-Id: <20221215211037.2686489-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221215211037.2686489-1-luiz.dentz@gmail.com> References: <20221215211037.2686489-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 uses bt_shell_echo to print transfer progress. --- client/player.c | 12 ++++-------- src/shared/shell.c | 10 +++++----- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/client/player.c b/client/player.c index 1f10387f89ad..e73ed6ac925a 100644 --- a/client/player.c +++ b/client/player.c @@ -3000,11 +3000,11 @@ static bool transport_recv(struct io *io, void *user_data) return true; } - bt_shell_printf("[seq %d] recv: %u bytes\n", transport->seq, ret); + bt_shell_echo("[seq %d] recv: %u bytes", transport->seq, ret); transport->seq++; - if (transport->fd) { + if (transport->fd >= 0) { len = write(transport->fd, buf, ret); if (len < 0) bt_shell_printf("Unable to write: %s (%d)", @@ -3378,7 +3378,6 @@ static int transport_send_seq(struct transport *transport, int fd, uint32_t num) for (i = 0; i < num; i++, transport->seq++) { ssize_t ret; - int queued; int secs = 0, nsecs = 0; ret = read(fd, buf, transport->mtu[1]); @@ -3400,13 +3399,10 @@ static int transport_send_seq(struct transport *transport, int fd, uint32_t num) elapsed_time(!transport->seq, &secs, &nsecs); - ioctl(transport->sk, TIOCOUTQ, &queued); - - bt_shell_printf("[seq %d %d.%03ds] send: %zd bytes " - "(TIOCOUTQ %d bytes)\n", + bt_shell_echo("[seq %d %d.%03ds] send: %zd bytes ", transport->seq, secs, (nsecs + 500000) / 1000000, - ret, queued); + ret); } free(buf); diff --git a/src/shared/shell.c b/src/shared/shell.c index 3c0e61dbc414..3358b383e9e4 100644 --- a/src/shared/shell.c +++ b/src/shared/shell.c @@ -580,15 +580,15 @@ void bt_shell_echo(const char *fmt, ...) { va_list args; char *str; - int err; + int ret; va_start(args, fmt); - err = vasprintf(&str, fmt, args); - if (!err) - err = asprintf(&str, COLOR_HIGHLIGHT "%s#" COLOR_OFF, str); + ret = vasprintf(&str, fmt, args); + if (ret >= 0) + ret = asprintf(&str, COLOR_HIGHLIGHT "%s " COLOR_OFF "#", str); va_end(args); - if (err) + if (ret < 0) return; rl_save_prompt(); -- 2.37.3