Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3113049rwb; Fri, 9 Dec 2022 10:06:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf6p8GAUbvYO+AQkCEBeKxIlsf9EVbADSB5UQODiCHb/6D6PyRuYde4nGWAJS2W006g4p8YR X-Received: by 2002:a17:907:b60c:b0:7c0:54f2:af9d with SMTP id vl12-20020a170907b60c00b007c054f2af9dmr6914578ejc.37.1670609169819; Fri, 09 Dec 2022 10:06:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670609169; cv=none; d=google.com; s=arc-20160816; b=BqmEcmWPRU3Hjj8T4lFXqBSLNKu48pKMUU8cgj+JGk3GDGpos4MDkE8cRKzLNVg9A0 6f3RwFm/TSwZmiMg1pDhYysMtorFF8Ofa4vxgDSt5xGGL6ZPhbMRd2P9AY55teZzOt3k WRG6h+KdGGz2WIHqI1TpNbxaGrt5ugUZUWKJXT+FbxY0ScXJGAvHmwgmX3zcVyDCa3OX l6d0m/7BeduQ9gB5HsxOuMErOQpYyGrnltkLbgEXIogXQv54r+YdjKteUH30BKPbQLIF o7ZQLFBkiF2SkSsiqUhQS6dIsixeDB+ZzsYoigsavSX9kj9EuulNGZDuOW5dqPRCe0i+ gEcg== 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=kSetUCUMxZWbbkY9msnTdiscaYEHXzWRi+YepCkqHbA=; b=oMBHi9OoZUS+ueEkZybOjEZPKohybOfrhYElkVW2RdiwOi3mjCUMSy+bjsTIWpHVIQ NUBji4K2q+ys4Nlir1+LIler0JHGR5EF3s6YACN5+dnVg9eisCFalLPWivxTgs2w0D5Q HYylgp7Cfm4qGGnbLpnycpzTERzB6U8NRHkVgUdT2RwLKvTUT0F+oOH0TOyI4b3uTfQB QU2AFUp5n9tajv68sFDIy16MPZPlb9E7pjSt3yuJVPQX3VCWJf18JNk9Sz1IgsyUrvta go9qyXSrwy3rCyoUpjY+PBDmmNX5oyVN3wj4lXMueG7O87vTnhgZFrZKAEWNxUb/iOi2 C8sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=AKLIYKzL; 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 gw18-20020a170906f15200b007ae87dde2c7si229371ejb.830.2022.12.09.10.05.31; Fri, 09 Dec 2022 10:06:09 -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=AKLIYKzL; 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 S229840AbiLISDT (ORCPT + 99 others); Fri, 9 Dec 2022 13:03:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229913AbiLISDQ (ORCPT ); Fri, 9 Dec 2022 13:03:16 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2A212FC20 for ; Fri, 9 Dec 2022 10:03:15 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id v13-20020a17090a6b0d00b00219c3be9830so5733517pjj.4 for ; Fri, 09 Dec 2022 10:03:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=kSetUCUMxZWbbkY9msnTdiscaYEHXzWRi+YepCkqHbA=; b=AKLIYKzLEPXazncfCqVuYwBP5rXeOeKSx+wvFOnx7/q0T2bnRyHkHS0cycdQTOI10W 4x2ou3NZHyIJo3svIfyIQqxBGhdGl6NYhREB/pXex+Hm5KWDQAYb6P4z709hgOvqz8gh HsnHnFZjYT8RmMgpqFc6fbbkC0V7nAWTU3oXb8R/g2z4wvFY8QonFjJ6nMkwdBCXmg7a vkHBg87fPvAKmzsh8qmoylwAmJWZNIYoQmjXl1mUNNFNdk55cAPiUnwQVd1YRMv4nruH dYo+OaWQG3au9KHvCtLBH41aUiJESgNdOVZXBulNYTZ1/2TISgTSOvpTznNhWJqfo7Ho x5DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kSetUCUMxZWbbkY9msnTdiscaYEHXzWRi+YepCkqHbA=; b=UA94UaZV1HP1/6+nsmyF/2RmqimVoMLT08P7ymHBVOPYPAAW221wLGS/hIu3inw75Z Sij9eO5pyR6M6oUQ0F/JRc6yknjATsvh3oN6/vQJyURNjpxAwiQSKISIsLt/UVN+o+St nvJzySSSij9jvcoyyOcv+9zC6FCGkveSyi6/fS6HPXc3pohrIvB21ZuUm6IL2n/XVVid TJKWd5EbgvTlREBjmhXunAhJ5ejW5n1XoONw/T7vVwZY493/Mn6tDavbdPs1govX64CK q6Gl6k7QPSuIPSwkIyLURlPj64EkcS+srUCBHS0muiSENBDca45LU96R88rRhQSWIjpY SqVw== X-Gm-Message-State: ANoB5pkjH8ZxtwDERWrXpbjxqqbsuYaycLMG//hpvFaQFjTlGoMsteFx tGMAAd67+t7qlv/WZhv/rwfow+1BP5NXX4iX X-Received: by 2002:a17:90a:4a97:b0:213:d3e4:67b3 with SMTP id f23-20020a17090a4a9700b00213d3e467b3mr6365342pjh.21.1670608994431; Fri, 09 Dec 2022 10:03:14 -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 d26-20020a630e1a000000b0047702d44861sm1234442pgl.18.2022.12.09.10.03.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 10:03:13 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ] client/player: Fix not calculating time to wait Date: Fri, 9 Dec 2022 10:03:12 -0800 Message-Id: <20221209180312.938166-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.37.3 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 The difference of time start and current time may have advanced just enough to add a second leaving start nanoseconds to be bigger. --- client/player.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/player.c b/client/player.c index 7f2b26b8791a..95309e101148 100644 --- a/client/player.c +++ b/client/player.c @@ -3396,6 +3396,10 @@ static void send_wait(struct timespec *t_start, uint32_t us) } t_diff.tv_sec = t_now.tv_sec - t_start->tv_sec; + if (t_start->tv_nsec > t_now.tv_nsec) { + t_diff.tv_sec--; + t_now.tv_nsec += 1000000000L; + } t_diff.tv_nsec = t_now.tv_nsec - t_start->tv_nsec; delta_us = us - TS_USEC(&t_diff); -- 2.37.3