From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 3229E1F54E for ; Sun, 14 Aug 2022 21:25:02 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; unprotected) header.d=80x24.org header.i=@80x24.org header.b="0siHyG2X"; dkim-atps=neutral Received: from localhost ([::1]:43028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNL6T-0001Rb-CQ for e@80x24.org; Sun, 14 Aug 2022 17:25:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40042) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNL6R-0001RS-Aq for dtas-all@nongnu.org; Sun, 14 Aug 2022 17:24:59 -0400 Received: from dcvr.yhbt.net ([173.255.242.215]:51950) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNL6P-0001p3-KK for dtas-all@nongnu.org; Sun, 14 Aug 2022 17:24:59 -0400 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id DCC761F54E for ; Sun, 14 Aug 2022 21:24:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1660512294; bh=aUJhQ7eSWxyGksH+h5fJjnEEUVJ+ta/8HRbfajWmTr0=; h=From:To:Subject:Date:From; b=0siHyG2XrilcU4XEn3mxmpd/KFm2Rn4brXx7oNSaPhNYNYdcqrJ0Xvps3DgUM8DMa HYwuczdeFFY/BbMduXRCXohJvFdB5oAO9xqnqi9/IrWuuAA7iPleL+NOTAeL9uOSau IwwRbUPwDdA+XeAalOFP4SEb1skKD1QuCziHnzeM= From: Eric Wong To: dtas-all@nongnu.org Subject: [PATCH] player: drain sinks completely before changing sink rate Date: Sun, 14 Aug 2022 21:24:54 +0000 Message-Id: <20220814212454.18022-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=173.255.242.215; envelope-from=e@80x24.org; helo=dcvr.yhbt.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: dtas-all@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: duct tape audio suite List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dtas-all-bounces+e=80x24.org@nongnu.org Sender: "dtas-all" For users of the CPU-saving bypass mode (e.g. "format rate=bypass"), this fixes a bug when enqueueing a 44.1kHz immediately after a 48kHz file (or vice-versa). Note: gapless playback with different rates/channels between tracks has never been supported with bypass mode enabled. Bypass only allows opportunistic gapless when sequential tracks have the same format. --- lib/dtas/player.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/dtas/player.rb b/lib/dtas/player.rb index 06ba788..6ea3aba 100644 --- a/lib/dtas/player.rb +++ b/lib/dtas/player.rb @@ -37,6 +37,7 @@ def initialize @paused = false @format = DTAS::Format.new @bypass = [] # %w(rate bits channels) (not worth Hash overhead) + @bypass_next = nil # source_spec @sinks = {} # { user-defined name => sink } @targets = [] # order matters @@ -331,6 +332,7 @@ def create_default_sink # called when the player is leaving idle state def spawn_sinks(source_spec) + @bypass_next = nil return true if @targets[0] @sinks.each_value do |sink| sink.active or next @@ -392,6 +394,8 @@ def next_source(source_spec) if ! @bypass.empty? && pending.respond_to?(:format) new_fmt = bypass_match!(@format.dup, pending.format) if new_fmt != @format + @bypass_next = source_spec + return if @sink_buf.inflight > 0 stop_sinks # we may fail to start below format_update!(new_fmt) end @@ -434,6 +438,7 @@ def drop_target(target) end def stop_sinks + @bypass_next = nil @targets.each { |t| drop_target(t) }.clear end @@ -458,7 +463,9 @@ def sink_iter end # nothing left inflight, stop the sinks until we have a source + bn = @bypass_next stop_sinks + next_source(bn) if bn # are we restarting for bypass? :ignore end