From owner-freebsd-multimedia@FreeBSD.ORG Wed May 16 17:30:13 2012 Return-Path: Delivered-To: freebsd-multimedia@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 416AA1065677 for ; Wed, 16 May 2012 17:30:13 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 0DA2E8FC12 for ; Wed, 16 May 2012 17:30:13 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q4GHUCk8077005 for ; Wed, 16 May 2012 17:30:12 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q4GHUChf076997; Wed, 16 May 2012 17:30:12 GMT (envelope-from gnats) Date: Wed, 16 May 2012 17:30:12 GMT Message-Id: <201205161730.q4GHUChf076997@freefall.freebsd.org> To: freebsd-multimedia@FreeBSD.org From: Dmitry Marakasov Cc: Subject: Re: ports/167971: [PATCH] audio/jack: ALSA driver is broken X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Dmitry Marakasov List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 May 2012 17:30:13 -0000 The following reply was made to PR ports/167971; it has been noted by GNATS. From: Dmitry Marakasov To: bug-followup@FreeBSD.org Cc: multimedia@FreeBSD.org Subject: Re: ports/167971: [PATCH] audio/jack: ALSA driver is broken Date: Wed, 16 May 2012 21:28:37 +0400 * Dmitry Marakasov (amdmi3@amdmi3.ru) wrote: > Since the second argument of clock_nanosleep (flags) is 0, ts still specifies a relative time, so theoretically the call may be replaced with simple nanosleep(&ts, NULL). I'm, however, unaware of differences between CLOCK_MONOTONIC and other clock types, as well as which of them is used by FreeBSD's nanosleep(), so it may have implications. NB: the same fix is used in multimedia/gavl file:///usr/ports/multimedia/gavl/files/patch-gavl-time.c and, judging from Linux man it should be safe: http://linux.die.net/man/2/nanosleep: --- POSIX.1 specifies that nanosleep() should measure time against the CLOCK_REALTIME clock. However, Linux measures the time using the CLOCK_MONOTONIC clock. This probably does not matter, since the POSIX.1 specification for clock_settime(2) says that discontinuous changes in CLOCK_REALTIME should not affect nanosleep() --- Thus, if FreeBSD nanosleep conforms to POSIX.1, it shouldn't matter for FreeBSD as well, so clock_nanosleep(CLOCK_MONOTONIC, 0, ...) -> nanosleep(...) replacement is safe. Thus, the PR is fixed by this patch (http://people.freebsd.org/~amdmi3/patch-drivers-alsa-midi-alsa_rawmidi.c): --- ./drivers/alsa-midi/alsa_rawmidi.c.orig 2008-05-29 16:26:07.000000000 +0400 +++ ./drivers/alsa-midi/alsa_rawmidi.c 2012-05-16 20:10:24.645166068 +0400 @@ -853,7 +853,7 @@ struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = wait_nanosleep; - clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, NULL); + nanosleep(&ts, NULL); } int res = poll((struct pollfd*)&pfds, npfds, poll_timeout); //debug_log("midi_thread(%s): poll exit: %d", str->name, res); -- Dmitry Marakasov . 55B5 0596 FF1E 8D84 5F56 9510 D35A 80DD F9D2 F77D amdmi3@amdmi3.ru ..: jabber: amdmi3@jabber.ru http://www.amdmi3.ru