Re: Annoying sounds with auvia and mpd

2009-01-20 Thread Jacob Meuser
On Sun, Dec 14, 2008 at 06:09:24PM +0100, Martin Toft wrote:
 A small follow-up:
 
 The problem only occurs when opening the audio device. If I queue a
 number of tracks in mpd's playlist and let it play, then it does not
 suddenly start making noise from one track to the next. It only happens
 when I manually start a track (and only sometimes). I suspect that mpd
 does not close the audio device between tracks if it is playing from its
 playlist, and that is probably why the problem does not occur in that
 setting.
 
 Martin
 

sorry for the delay.  can you see if this fixes the problem?

something of a guess, but the addition of S/PDIF support is the only
change that fits the timeline of when it was working and when
the problem started.  (and if you look at ac97.c just a few lines down
from this patch, you'll see the XXX-is-this-right? comment I added
when bringing in S/PDIF support from NetBSD ...)

-- 
jake...@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org

Index: ac97.c
===
RCS file: /home2/cvs/OpenBSD/src/sys/dev/ic/ac97.c,v
retrieving revision 1.70
diff -u -r1.70 ac97.c
--- ac97.c  23 Oct 2008 21:50:01 -  1.70
+++ ac97.c  19 Jan 2009 10:07:44 -
@@ -878,6 +878,13 @@
 
as-ac97_clock = AC97_STANDARD_CLOCK;
ac97_read(as, AC97_REG_EXT_AUDIO_ID, as-ext_id);
+
+   /* This VIA codec doesn't like the way we enable S/PDIF, so
+* pretend it doesn't have S/PDIF capabilities.
+*/
+   if (id == 56494182)
+   as-ext_id = ~(AC97_EXT_AUDIO_SPDIF); 
+
if (as-ext_id  (AC97_EXT_AUDIO_VRA | AC97_EXT_AUDIO_DRA
  | AC97_EXT_AUDIO_SPDIF | AC97_EXT_AUDIO_VRM
  | AC97_EXT_AUDIO_CDAC | AC97_EXT_AUDIO_SDAC



Re: Annoying sounds with auvia and mpd

2009-01-20 Thread Martin Toft
On Tue, Jan 20, 2009 at 11:08:30AM +, Jacob Meuser wrote:
 sorry for the delay.  can you see if this fixes the problem?
 
 something of a guess, but the addition of S/PDIF support is the only
 change that fits the timeline of when it was working and when
 the problem started.  (and if you look at ac97.c just a few lines down
 from this patch, you'll see the XXX-is-this-right? comment I added
 when bringing in S/PDIF support from NetBSD ...)

Yep, I see the comment, and I agree that it sure sounds like something
that could cause the problem that I experience.

My off-list reply to Jacob:

Hi and thanks for remembering me :-)

Unfortunately, it does not fix the problem. I'm still able to reproduce
the faulty situation (high pitched noise together with the music,
continueing after the music has been stopped) using mpd and mplayer.

Martin



Re: Annoying sounds with auvia and mpd

2008-12-15 Thread Alexey Suslikov

Jacob Meuser wrote:


On Sun, Dec 14, 2008 at 06:09:24PM +0100, Martin Toft wrote:

A small follow-up:

The problem only occurs when opening the audio device. If I queue a
number of tracks in mpd's playlist and let it play, then it does not
suddenly start making noise from one track to the next. It only happens
when I manually start a track (and only sometimes). I suspect that mpd
does not close the audio device between tracks if it is playing from its
playlist, and that is probably why the problem does not occur in that
setting.


thanks for this and your other response.


The issue I see regularly with azalia+vlc+jackd may be related maybe not.

nice jackd --silent --nozombies -t 1 -d sun -p 4096 21 1/dev/null 

- this is how I run jackd.

Here is the scenario:

- I start vlc and play something,
- I start heavy application (like Thunderbird/Firefox @ hw.setperf=0),
- sound stutters (threads blocking?),
- at this point, with ~20% probability, I hear cyclic audio fragment
which overlaps main sound,
- the issue can be remedied by restarting jack entirely or by starting
any heavy application again (~20% probability).

For me, it looks like a junk data somewhere in a buffer.

Our audio layer and NetBSD are different wrt buffers handling so I
took a deeper look and discovered the following commit

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/audio.c.diff?r1=1.184r2=1.184.2.27f=h

For me, the interesting part here is

...
/*
* used = cb-usedlow should be used  blksize ideally.
* Some HW drivers such as uaudio(4) does not call audio_pint()
* at accurate timing.  If used  blksize, uaudio(4) already
* request transfer of garbage data.
*/
if (used = cb-usedlow  !cb-copying  sc-sc_npfilters  0) {
/* we might have data in filter pipeline */
null_fetcher.fetch_to = null_fetcher_fetch_to;
fetcher = sc-sc_pfilters[sc-sc_npfilters - 1]-base;
sc-sc_pfilters[0]-set_fetcher(sc-sc_pfilters[0],
null_fetcher);
used = audio_stream_get_used(sc-sc_pustream);
cc = cb-s.end - cb-s.start;
fetcher-fetch_to(fetcher, cb-s, cc);
cb-fstamp += audio_stream_get_used(sc-sc_pustream) - used;
used = audio_stream_get_used(cb-s);
}
...

Also, I should mention I can even hear such a cyclic fragment over
the ~2 seconds *after* I press stop button in vlc.

Alexey



Re: Annoying sounds with auvia and mpd

2008-12-15 Thread Jacob Meuser
On Tue, Dec 16, 2008 at 01:30:02AM +0200, Alexey Suslikov wrote:
 Jacob Meuser wrote:

 On Sun, Dec 14, 2008 at 06:09:24PM +0100, Martin Toft wrote:
 A small follow-up:

 The problem only occurs when opening the audio device. If I queue a
 number of tracks in mpd's playlist and let it play, then it does not
 suddenly start making noise from one track to the next. It only happens
 when I manually start a track (and only sometimes). I suspect that mpd
 does not close the audio device between tracks if it is playing from its
 playlist, and that is probably why the problem does not occur in that
 setting.

 thanks for this and your other response.

 The issue I see regularly with azalia+vlc+jackd may be related maybe not.

 nice jackd --silent --nozombies -t 1 -d sun -p 4096 21 1/dev/null 

 - this is how I run jackd.

 Here is the scenario:

 - I start vlc and play something,
 - I start heavy application (like Thunderbird/Firefox @ hw.setperf=0),
 - sound stutters (threads blocking?),
 - at this point, with ~20% probability, I hear cyclic audio fragment
 which overlaps main sound,
 - the issue can be remedied by restarting jack entirely or by starting
 any heavy application again (~20% probability).

 For me, it looks like a junk data somewhere in a buffer.

probably jackd.  upstream bungled around with some releases.  I think
they are finally done.  I'll take a look at getting jack updated.

 Our audio layer and NetBSD are different wrt buffers handling so I
 took a deeper look and discovered the following commit

 http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/audio.c.diff?r1=1.184r2=1.184.2.27f=h

 For me, the interesting part here is

 ...
 /*
 * used = cb-usedlow should be used  blksize ideally.
 * Some HW drivers such as uaudio(4) does not call audio_pint()
 * at accurate timing.  If used  blksize, uaudio(4) already
 * request transfer of garbage data.
 */
 if (used = cb-usedlow  !cb-copying  sc-sc_npfilters  0) {
   /* we might have data in filter pipeline */
 ^^^
we have no such filer pipeline.

-- 
jake...@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org



Annoying sounds with auvia and mpd

2008-12-14 Thread Martin Toft
Hi

I'm using mpd and ncmpc to play music on my headless server equipped
with a VIA EN12000EG motherboard (auvia soundcard). It's running
-current built yesterday and the most recent mpd package from
ftp://mirrors.nic.funet.fi/pub/OpenBSD/snapshots/packages/i386
(mpd-0.13.2p2).

Sometimes when I play a song, some very loud shrieking sounds are heard
together with the chosen song. If I stop the player, the annoying sounds
sometimes keep on playing (forever). Stopping and starting a song a few
times helps and I'm eventually able to play a song without the shrieking
sounds.

I updated the machine yesterday, because I hoped the problem would go
away, i.e. I also had the problem with a one or two month old -current.

I will try mplayer tonight. I cannot install the mplayer package due to
wrong minor in stdc++, so I'll have to build the port. Before
upgrading, mplayer showed the same symptoms as mpd.

What can I do to diagnose the problem?

dmesg and list of installed packages are attached.

Thanks!

Martin


dmesg:

OpenBSD 4.4-current (GENERIC) #0: Sat Dec 13 23:57:32 CET 2008
r...@sprott.obsd.dk:/usr/src/sys/arch/i386/compile/GENERIC
cpu0: VIA Esther processor 1200MHz (CentaurHauls 686-class) 1.20 GHz
cpu0: 
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,CMOV,PAT,CFLUSH,ACPI,MMX,FXSR,SSE,SSE2,TM,SBF,SSE3,EST,TM2
cpu0: RNG AES AES-CTR SHA1 SHA256 RSA
real mem  = 469266432 (447MB)
avail mem = 445353984 (424MB)
mainbus0 at root
bios0 at mainbus0: AT/286+ BIOS, date 06/22/06, BIOS32 rev. 0 @ 0xf9360, SMBIOS 
rev. 2.3 @ 0xf0800 (25 entries)
apm0 at bios0: Power Management spec V1.2 (slowidle)
apm0: AC on, battery charge unknown
acpi at bios0 function 0x0 not configured
pcibios0 at bios0: rev 2.1 @ 0xf/0xc4f4
pcibios0: PCI IRQ Routing Table rev 1.0 @ 0xfc450/160 (8 entries)
pcibios0: bad IRQ table checksum
pcibios0: PCI BIOS has 8 Interrupt Routing table entries
pcibios0: PCI Exclusive IRQs: 5 10 11
pcibios0: PCI Interrupt Router at 000:17:0 (VIA VT8237 ISA rev 0x00)
pcibios0: PCI bus #1 is the last bus
bios0: ROM list: 0xc/0xfc00 0xd/0x8000! 0xd8000/0x1000
cpu0 at mainbus0: (uniprocessor)
cpu0: RNG AES AES-CTR SHA1 SHA256 RSA
cpu0: RNG AES AES-CTR SHA1 SHA256 RSA
cpu0: Enhanced SpeedStep 1200 MHz (860 mV): speeds: 1200, 1000, 800, 600, 400 
MHz
pci0 at mainbus0 bus 0: configuration mode 1 (no bios)
pchb0 at pci0 dev 0 function 0 VIA CN700 Host rev 0x00
viaagp0 at pchb0v3, 
agp0 at viaagp0: aperture at 0xe800, size 0x1000
pchb1 at pci0 dev 0 function 1 VIA CN700 Host rev 0x00
pchb2 at pci0 dev 0 function 2 VIA CN700 Host rev 0x00
pchb3 at pci0 dev 0 function 3 VIA PT890 Host rev 0x00
pchb4 at pci0 dev 0 function 4 VIA CN700 Host rev 0x00
pchb5 at pci0 dev 0 function 7 VIA CN700 Host rev 0x00
ppb0 at pci0 dev 1 function 0 VIA VT8377 AGP rev 0x00
pci1 at ppb0 bus 1
vga1 at pci1 dev 0 function 0 VIA S3 Unichrome PRO IGP rev 0x01
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
VIA VT6306 FireWire rev 0x80 at pci0 dev 13 function 0 not configured
vge0 at pci0 dev 14 function 0 VIA VT612x rev 0x11: irq 10, address 
00:40:63:e8:84:6d
ciphy0 at vge0 phy 1: CS8201 10/100/1000TX PHY, rev. 2
pciide0 at pci0 dev 15 function 0 VIA VT6420 SATA rev 0x80: DMA
pciide0: using irq 11 for native-PCI interrupt
wd0 at pciide0 channel 0 drive 0: SAMSUNG HD501LJ
wd0: 16-sector PIO, LBA48, 476940MB, 976773168 sectors
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 5
wd1 at pciide0 channel 1 drive 0: SAMSUNG HD501LJ
wd1: 16-sector PIO, LBA48, 476940MB, 976773168 sectors
wd1(pciide0:1:0): using PIO mode 4, Ultra-DMA mode 5
pciide1 at pci0 dev 15 function 1 VIA VT82C571 IDE rev 0x06: ATA133, channel 
0 configured to compatibility, channel 1 configured to compatibility
pciide1: channel 0 disabled (no drives)
pciide1: channel 1 disabled (no drives)
uhci0 at pci0 dev 16 function 0 VIA VT83C572 USB rev 0x81: irq 5
uhci1 at pci0 dev 16 function 1 VIA VT83C572 USB rev 0x81: irq 5
uhci2 at pci0 dev 16 function 2 VIA VT83C572 USB rev 0x81: irq 11
ehci0 at pci0 dev 16 function 4 VIA VT6202 USB rev 0x86: irq 10
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 VIA EHCI root hub rev 2.00/1.00 addr 1
viapm0 at pci0 dev 17 function 0 VIA VT8237 ISA rev 0x00
iic0 at viapm0
spdmem0 at iic0 addr 0x50: 512MB DDR2 SDRAM non-parity PC2-3200CL5
auvia0 at pci0 dev 17 function 5 VIA VT8233 AC97 rev 0x60: irq 10
ac97: codec id 0x56494182 (VIA Technologies 82)
ac97: codec features 18 bit DAC, 18 bit ADC, No 3D Stereo
audio0 at auvia0
skc0 at pci0 dev 20 function 0 D-Link Systems DGE-530T B1 rev 0x11, Yukon 
Lite (0x9): irq 11
sk0 at skc0 port A: address 00:17:9a:7b:c2:a1
eephy0 at sk0 phy 0: 88E1011 Gigabit PHY, rev. 5
usb1 at uhci0: USB revision 1.0
uhub1 at usb1 VIA UHCI root hub rev 1.00/1.00 addr 1
usb2 at uhci1: USB revision 1.0
uhub2 at usb2 VIA UHCI root hub rev 1.00/1.00 addr 1
usb3 at uhci2: USB revision 1.0
uhub3 at usb3 VIA UHCI root hub rev 1.00/1.00 addr 1

Re: Annoying sounds with auvia and mpd

2008-12-14 Thread Jacob Meuser
On Sun, Dec 14, 2008 at 11:00:47AM +0100, Martin Toft wrote:
 Hi
 
 I'm using mpd and ncmpc to play music on my headless server equipped
 with a VIA EN12000EG motherboard (auvia soundcard). It's running
 -current built yesterday and the most recent mpd package from
 ftp://mirrors.nic.funet.fi/pub/OpenBSD/snapshots/packages/i386
 (mpd-0.13.2p2).
 
 Sometimes when I play a song, some very loud shrieking sounds are heard
 together with the chosen song. If I stop the player, the annoying sounds
 sometimes keep on playing (forever). Stopping and starting a song a few
 times helps and I'm eventually able to play a song without the shrieking
 sounds.
 
 I updated the machine yesterday, because I hoped the problem would go
 away, i.e. I also had the problem with a one or two month old -current.
 
 I will try mplayer tonight. I cannot install the mplayer package due to
 wrong minor in stdc++, so I'll have to build the port. Before
 upgrading, mplayer showed the same symptoms as mpd.
 
 What can I do to diagnose the problem?

try the cat  /dev/audio  /dev/zero test in faq13

also try the regress test in src/regress/sys/dev/audio

see if those produce the shreiking sound

is this new(ish)?  you said you had the problem a month or two old
-current, but before that?

-- 
jake...@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org



Re: Annoying sounds with auvia and mpd

2008-12-14 Thread Martin Toft
On Sun, Dec 14, 2008 at 10:41:51AM +, Jacob Meuser wrote:
 try the cat  /dev/audio  /dev/zero test in faq13

  # cat  /dev/audio  /dev/zero  
  [1] 21502
  # audioctl play.{seek,samples,errors}
  play.seek=57600
  play.samples=652800
  play.errors=0
  # audioctl play.{seek,samples,errors}
  play.seek=57600
  play.samples=940800
  play.errors=0
  # audioctl play.{seek,samples,errors}
  play.seek=57600
  play.samples=1209600
  play.errors=0
  # audioctl play.{seek,samples,errors}
  play.seek=57600
  play.samples=1593600
  play.errors=0
  # audioctl play.{seek,samples,errors}
  play.seek=48000
  play.samples=1910400
  play.errors=0
  # kill %1
  # fg
  cat  /dev/audio  /dev/zero 
  Terminated 

Nothing but silence during the test. No shreiking sounds.

 also try the regress test in src/regress/sys/dev/audio

  # ./autest
  ulinear:8...mono(s 8000 c 8146 e 1.8%)...stereo(s 8000 c 8025 e 0.3%)
  mulaw:8*...mono(s 8000 c 4061 e 97.0%)...stereo(s 8000 c 4006 e 99.7%)
  alaw:8*...mono(s 8000 c 4061 e 97.0%)...stereo(s 8000 c 4006 e 99.7%)
  slinear:8*...mono(s 8000 c 8149 e 1.8%)...stereo(s 8000 c 8025 e 0.3%)
  slinear_le:16...mono(s 8000 c 8026 e 0.3%)...stereo(s 8000 c 8013 e 0.2%)
  ulinear_le:16*...mono(s 8000 c 8025 e 0.3%)...stereo(s 8000 c 8012 e 0.2%)
  slinear_be:16*...mono(s 8000 c 8025 e 0.3%)...stereo(s 8000 c 8012 e 0.2%)
  ulinear_be:16*...mono(s 8000 c 8026 e 0.3%)...stereo(s 8000 c 8013 e 0.2%)

The test produces a lot of different, noisy sounds. I guess that is the
expected behaviour. When it's done, the sound card keeps playing an
annoying, shreiking sound, like the sound I hear when trying to play
music with mpd. I was able to stop it by running

  # cat  /dev/audio  /dev/zero 
  [1] 27452
  # kill %1
  # fg
  cat  /dev/audio  /dev/zero 
  Terminated 

If I run the above commands a couple of times I'm able to get it into
the shreiking mode again.

 see if those produce the shreiking sound
 
 is this new(ish)?  you said you had the problem a month or two old
 -current, but before that?

Before running the old -current that I mentioned, I ran 4.3-stable on
the machine. The problem never occured with 4.3-stable.

I'm able to configure it to use all the ordinary rates:

  # audioctl play.rate  
  play.rate=48000
  # audioctl play.rate=44100
  play.rate: - 44100
  # audioctl play.rate=22050
  play.rate: - 22050
  # audioctl play.rate=8000 
  play.rate: - 8000

I remember that with 4.3-stable I was only able to use 48000 and had to
force mpd and mplayer to use 48000.

I've now built and installed mplayer, and the problem also exists with
mplayer. If I start mplayer 4-5 times (every time stopping it by typing
q after a few seconds), the sound card suddenly goes mad and plays
shreiking sounds together with the music. When I quit, the music stops
but the shreiking sounds continue. This is with and without -s 48000,
it makes no difference.

I'm ready to try anything you can think of :-)

Thanks in advance.

I might be a bit slow answering your mails, because I'm practically
living at the university at the moment, strugling to finish some project
work.

Martin


$ mixerctl -av
outputs.master=231,231 volume
outputs.master.mute=off  [ off on ]
outputs.mono=255 volume
outputs.mono.mute=off  [ off on ]
outputs.mono.source=mixerout  [ mixerout mic ]
outputs.surround=255,255 volume
outputs.surround.mute=on  [ off on ]
outputs.center=255 volume
outputs.center.mute=on  [ off on ]
outputs.lfe=255 volume
outputs.lfe.mute=on  [ off on ]
inputs.spkr=255 volume
inputs.spkr.mute=off  [ off on ]
inputs.phone=191 volume
inputs.phone.mute=on  [ off on ]
inputs.mic=191 volume
inputs.mic.mute=on  [ off on ]
inputs.mic.preamp=off  [ off on ]
inputs.mic.source=mic0  [ mic0 mic1 ]
inputs.line=191,191 volume
inputs.line.mute=on  [ off on ]
inputs.cd=191,191 volume
inputs.cd.mute=off  [ off on ]
inputs.video=255,255 volume
inputs.video.mute=off  [ off on ]
inputs.aux=191,191 volume
inputs.aux.mute=on  [ off on ]
inputs.dac=191,191 volume
inputs.dac.mute=off  [ off on ]
record.source=mic  [ mic cd video aux line mixerout mixeroutmono phone ]
record.volume=255,255 volume
record.volume.mute=off  [ off on ]
outputs.extamp=off  [ off on ]
outputs.spdif=off  [ off on ]



Re: Annoying sounds with auvia and mpd

2008-12-14 Thread Martin Toft
On Sun, Dec 14, 2008 at 04:58:34PM +0100, Martin Toft wrote:
...
 shreiking sounds together with the music. When I quit, the music stops
 but the shreiking sounds continue. This is with and without -s 48000,
 it makes no difference.

-srate 48000, of course.



Re: Annoying sounds with auvia and mpd

2008-12-14 Thread Martin Toft
A small follow-up:

The problem only occurs when opening the audio device. If I queue a
number of tracks in mpd's playlist and let it play, then it does not
suddenly start making noise from one track to the next. It only happens
when I manually start a track (and only sometimes). I suspect that mpd
does not close the audio device between tracks if it is playing from its
playlist, and that is probably why the problem does not occur in that
setting.

Martin



Re: Annoying sounds with auvia and mpd

2008-12-14 Thread Jacob Meuser
On Sun, Dec 14, 2008 at 06:09:24PM +0100, Martin Toft wrote:
 A small follow-up:
 
 The problem only occurs when opening the audio device. If I queue a
 number of tracks in mpd's playlist and let it play, then it does not
 suddenly start making noise from one track to the next. It only happens
 when I manually start a track (and only sometimes). I suspect that mpd
 does not close the audio device between tracks if it is playing from its
 playlist, and that is probably why the problem does not occur in that
 setting.

thanks for this and your other response.

-- 
jake...@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org