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=-3.9 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS 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 5964B1F454 for ; Sat, 2 Nov 2019 21:17:02 +0000 (UTC) Received: from localhost ([::1]:50642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iR0lY-0004lY-9P for e@80x24.org; Sat, 02 Nov 2019 17:17:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48888) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iR0lV-0004lK-QE for dtas-all@nongnu.org; Sat, 02 Nov 2019 17:16:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iR0lU-0002VZ-MA for dtas-all@nongnu.org; Sat, 02 Nov 2019 17:16:57 -0400 Received: from dcvr.yhbt.net ([64.71.152.64]:35812) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iR0lU-0002OT-G9 for dtas-all@nongnu.org; Sat, 02 Nov 2019 17:16:56 -0400 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id B879F1F454; Sat, 2 Nov 2019 21:16:54 +0000 (UTC) Date: Sat, 2 Nov 2019 21:16:54 +0000 From: Eric Wong To: Rene Maurer Subject: [PATCH] player: automatically pause if last sink dies Message-ID: <20191102211654.GA17315@dcvr> References: <874l0kb9qm.fsf@loco10.cumparsita.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <874l0kb9qm.fsf@loco10.cumparsita.ch> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.71.152.64 X-BeenThere: dtas-all@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: duct tape audio suite List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dtas-all@nongnu.org Errors-To: dtas-all-bounces+e=80x24.org@nongnu.org Sender: "dtas-all" Attempting to play (and fail) every song in the queue or tracklist is not ideal when a the USB/HDMI cable to the sound device gets unplugged by accident. When tee-ing to multiple sinks, we will still gracefully continue if one goes dead and there are remaining sinks. Suggested-by: Rene Maurer Link: https://80x24.org/dtas-all/874l0kb9qm.fsf@loco10.cumparsita.ch/ --- lib/dtas/player.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/dtas/player.rb b/lib/dtas/player.rb index 37f2c96..61d29d2 100644 --- a/lib/dtas/player.rb +++ b/lib/dtas/player.rb @@ -282,7 +282,7 @@ def sink_death(sink, status) if deleted[0] warn("#{sink.name} died unexpectedly: #{status.inspect}") deleted.each { |t| drop_target(t) } - __current_drop unless @targets[0] + do_pause unless @targets[0] return # sink stays dead if it died unexpectedly end @@ -451,7 +451,7 @@ def __current_drop(src = @current) # pull data from sink_buf into @targets, source feeds into sink_buf def sink_iter wait_iter = broadcast_iter(@sink_buf, @targets) - __current_drop if nil == wait_iter # sink error, stop source + do_pause if nil == wait_iter # sink error, stop source return wait_iter if @current # no source left to feed sink_buf, drain the remaining data