Re: [pulseaudio-discuss] Packagers: Xlib vs XCB

2010-08-17 Thread Rémi Denis-Courmont

On Mon, 16 Aug 2010 14:51:48 +0100, Colin Guthrie gm...@colin.guthr.ie
wrote:
 As some of you will have found out, there are some applications that
 have problems relating to Xlib usage (XCloseDisplay() IIRC) when
 combined with PA client libs (notably I've seen reports from VLC
 relating to this).

VLC media player proper works fine with Xlib and PulseAudio (although it
wouldn't to have a PulseAudio expert look at the PulseAudio support).

The Xlib problem can manifest itself in two different ways:

* If a process calls XInitThreads() _after_ XOpenDisplay(), then
XCloseDisplay() will crash trying to acquire a non-existent mutex. This is
typical if you use LibVLC but fail to call XInitThreads() early in your
main() function.

* If a multi-thread process uses Xlib from more than one thread but never
calls XInitThreads(), then depending on the phase of the moon, then race
conditions might trigger crashes (typically in the form of heap corruption
in my experience) depending on the phase of the moon.

As regards PulseAudio, the issue comes up if libpulse is used from a
different thread than Xlib. Calling XInitThreads() from main is the
official solution. Unfortunately, there are many scenarii where this does
not work. You might not have control over the main() function (e.g. the VLC
plugin for Mozilla). Also Xlib might be hidden deep beneath frameworks that
do not call XInitThreads, such as GTK or Qt.

Since libpulse does not really need any Xlib feature not found in XCB, I
humbly think switching to XCB is the best choice. XCB is thread-safe by
default. Thank you for that.

-- 
Rémi Denis-Courmont
http://www.remlab.net
http://fi.linkedin.com/in/remidenis

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Packagers: Xlib vs XCB

2010-08-17 Thread Colin Guthrie
'Twas brillig, and Rémi Denis-Courmont at 17/08/10 09:00 did gyre and
gimble:
 
 On Mon, 16 Aug 2010 14:51:48 +0100, Colin Guthrie gm...@colin.guthr.ie
 wrote:
 As some of you will have found out, there are some applications that
 have problems relating to Xlib usage (XCloseDisplay() IIRC) when
 combined with PA client libs (notably I've seen reports from VLC
 relating to this).
 
 VLC media player proper works fine with Xlib and PulseAudio (although it
 wouldn't to have a PulseAudio expert look at the PulseAudio support).
 
 The Xlib problem can manifest itself in two different ways:
 
 * If a process calls XInitThreads() _after_ XOpenDisplay(), then
 XCloseDisplay() will crash trying to acquire a non-existent mutex. This is
 typical if you use LibVLC but fail to call XInitThreads() early in your
 main() function.
 
 * If a multi-thread process uses Xlib from more than one thread but never
 calls XInitThreads(), then depending on the phase of the moon, then race
 conditions might trigger crashes (typically in the form of heap corruption
 in my experience) depending on the phase of the moon.
 
 As regards PulseAudio, the issue comes up if libpulse is used from a
 different thread than Xlib. Calling XInitThreads() from main is the
 official solution. Unfortunately, there are many scenarii where this does
 not work. You might not have control over the main() function (e.g. the VLC
 plugin for Mozilla). Also Xlib might be hidden deep beneath frameworks that
 do not call XInitThreads, such as GTK or Qt.
 
 Since libpulse does not really need any Xlib feature not found in XCB, I
 humbly think switching to XCB is the best choice. XCB is thread-safe by
 default. Thank you for that.

Thanks Rémi for the detailed description :)

Col

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Volume control interactions

2010-08-17 Thread Jan Braun
Tanu Kaskinen schrob:
 On Sun, 2010-08-15 at 21:32 +0200, Jan Braun wrote:
  What I'd want and expect is a (per-soundcard) master volume that's
  persistent and affects ALL streams on that device, [...]
 
 Yes, your master volume is the reference volume. And the UI logic
 has been changed after that message you linked - nowadays the UI shows
 the reference volume. Terminology wise, virtual volume has been
 renamed to real volume (due to the fact that the volume reflects the
 hardware volume that the device actually uses). The real volume is not
 visible to users unless they use e.g. alsamixer to check what's
 happening.

Ah, thanks. I tested, and it does indeed seem to work as described.
Sorry for not re-testing before sending my mail, I remembered different
behaviour.

Jan
-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments


signature.asc
Description: Digital signature
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH] Do not use tsched watermark if tsched is disabled

2010-08-17 Thread David Henningsson
The tsched watermark variable was incorrectly used even for sinks
with timer scheduling disabled, causing XRUNs on every rewind. This
patch sets a fixed margin of 20 msec for such rewinds, thus avoiding
the underrun.

One could argue that the margin should be adjustable somehow (or based
on fragment-size, or something else), but this patch at least fixes the
immediate problem, causing crackling output on (at least) one machine.

-- 
David Henningsson, Canonical Ltd.
http://launchpad.net/~diwic
From 87e8a04f029c18cdb5abebb4f3f3c2100d42107a Mon Sep 17 00:00:00 2001
From: David Henningsson david.hennings...@canonical.com
Date: Tue, 17 Aug 2010 19:37:51 +0200
Subject: [PATCH] Do not use tsched watermark if tsched is disabled

The tsched watermark variable was incorrectly used even for sinks
with timer scheduling disabled, causing XRUNs on every rewind. This
patch sets a fixed margin of 20 msec for such rewinds, thus avoiding
the underrun.

Signed-off-by: David Henningsson david.hennings...@canonical.com
---
 src/modules/alsa/alsa-sink.c |8 +++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index a253cc5..9202883 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -63,6 +63,8 @@
 
 #define DEFAULT_DEVICE default
 
+#define NON_TSCHED_REWIND_MARGIN_USEC (20*PA_USEC_PER_MSEC)/* 20ms  -- Rewind margin for non-tsched devices */
+
 #define DEFAULT_TSCHED_BUFFER_USEC (2*PA_USEC_PER_SEC) /* 2s-- Overall buffer size */
 #define DEFAULT_TSCHED_WATERMARK_USEC (20*PA_USEC_PER_MSEC)/* 20ms  -- Fill up when only this much is left in the buffer */
 
@@ -1309,7 +1311,11 @@ static int process_rewind(struct userdata *u) {
 return -1;
 }
 
-unused_nbytes = u-tsched_watermark + (size_t) unused * u-frame_size;
+unused_nbytes = (size_t) unused * u-frame_size;
+if (u-use_tsched)
+unused_nbytes += u-tsched_watermark;
+else
+unused_nbytes += pa_usec_to_bytes(NON_TSCHED_REWIND_MARGIN_USEC, u-sink-sample_spec);
 
 if (u-hwbuf_size  unused_nbytes)
 limit_nbytes = u-hwbuf_size - unused_nbytes;
-- 
1.7.0.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] Do not use tsched watermark if tsched is disabled

2010-08-17 Thread Colin Guthrie
'Twas brillig, and David Henningsson at 17/08/10 19:00 did gyre and gimble:
 The tsched watermark variable was incorrectly used even for sinks
 with timer scheduling disabled, causing XRUNs on every rewind. This
 patch sets a fixed margin of 20 msec for such rewinds, thus avoiding
 the underrun.
 
 One could argue that the margin should be adjustable somehow (or based
 on fragment-size, or something else), but this patch at least fixes the
 immediate problem, causing crackling output on (at least) one machine.

/me wonders if this fixes

https://bugzilla.redhat.com/show_bug.cgi?id=537378

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] Do not use tsched watermark if tsched is disabled

2010-08-17 Thread Colin Guthrie
'Twas brillig, and Colin Guthrie at 17/08/10 19:03 did gyre and gimble:
 'Twas brillig, and David Henningsson at 17/08/10 19:00 did gyre and gimble:
 The tsched watermark variable was incorrectly used even for sinks
 with timer scheduling disabled, causing XRUNs on every rewind. This
 patch sets a fixed margin of 20 msec for such rewinds, thus avoiding
 the underrun.

 One could argue that the margin should be adjustable somehow (or based
 on fragment-size, or something else), but this patch at least fixes the
 immediate problem, causing crackling output on (at least) one machine.
 
 /me wonders if this fixes
 
 https://bugzilla.redhat.com/show_bug.cgi?id=537378

Hmm, it seems to in my tests :)

Col

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] Do not use tsched watermark if tsched is disabled

2010-08-17 Thread David Henningsson
2010-08-17 20:03, Colin Guthrie skrev:
 'Twas brillig, and David Henningsson at 17/08/10 19:00 did gyre and gimble:
 The tsched watermark variable was incorrectly used even for sinks
 with timer scheduling disabled, causing XRUNs on every rewind. This
 patch sets a fixed margin of 20 msec for such rewinds, thus avoiding
 the underrun.

 One could argue that the margin should be adjustable somehow (or based
 on fragment-size, or something else), but this patch at least fixes the
 immediate problem, causing crackling output on (at least) one machine.
 
 /me wonders if this fixes
 
 https://bugzilla.redhat.com/show_bug.cgi?id=537378
 

It seems likely to me. I got a feeling that it isn't the whole story
though, that there could be some additional bug in ALSA causing sound to
remain distorted, if the XRUN is merely touched and afterwards
immediately resolved by writing more data. So it could have been a
combination of these two bugs causing the crackling sound, and by
resolving the PA bug the problem does not appear anymore.

According to what you say in that bug, you could reproduce it yourself
by setting tsched=0, so I'm eager to hear if this fix fixes your issue
as well.

-- 
David Henningsson, Canonical Ltd.
http://launchpad.net/~diwic
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] Do not use tsched watermark if tsched is disabled

2010-08-17 Thread Colin Guthrie
'Twas brillig, and David Henningsson at 17/08/10 19:20 did gyre and gimble:
 According to what you say in that bug, you could reproduce it yourself
 by setting tsched=0, so I'm eager to hear if this fix fixes your issue
 as well.

Yeah I was able to reproduce it pretty easily with the chordtest.sh
script attached to the bug. After the third tone, it started to sound
terribly distored.

After applying your patch, I tried several times and got a perfect run
each time :)

Col


-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss