VLC does not resample correctly with JACK

Bug #987231 reported by Walter Oesch
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
VLC media player
Fix Released
Undecided
Rémi Denis-Courmont
vlc (Debian)
Fix Released
Unknown
vlc (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

When using the Jack output module audio gets distorted or does not play at all when playing a track with a samplerate other than the one specified in jack.

the (i hope) relevant part of VLC debug messages when starting playback is:

jack debug: JACK audio output initialized (6 channels, rate=48000)
main debug: using audio output module "jack"
main debug: TIMER module_need() : 207.535 ms - Total 207.535 ms / 1 intvls (Avg 207.535 ms)
main debug: output 'f32l' 48000 Hz 3F2R/LFE frame=1 samples/24 bytes
main debug: mixer 'f32l' 48000 Hz 3F2R/LFE frame=1 samples/24 bytes
main debug: filter(s) 'f32l'->'f32l' 48000 Hz->48000 Hz 3F2R/LFE->3F2R/LFE
main debug: conversion pipeline completed
main debug: looking for audio mixer module: 2 candidates
main debug: using audio mixer module "float32_mixer"
main debug: TIMER module_need() : 0.170 ms - Total 0.170 ms / 1 intvls (Avg 0.170 ms)
main debug: input 's24l' 96000 Hz 3F2R/LFE frame=1 samples/18 bytes
main debug: looking for audio filter module: 1 candidate
scaletempo debug: format: 96000 rate, 6 nch, 4 bps, fl32
scaletempo debug: params: 30 stride, 0.200 overlap, 14 search
scaletempo debug: 1.000 scale, 2880.000 stride_in, 2880 stride_out, 2304 standing, 576 overlap, 1344 search, 4800 queue, fl32 mode
main debug: using audio filter module "scaletempo"
main debug: TIMER module_need() : 0.208 ms - Total 0.208 ms / 1 intvls (Avg 0.208 ms)
main debug: filter(s) 's24l'->'f32l' 96000 Hz->96000 Hz 3F2R/LFE->3F2R/LFE
main debug: looking for audio filter module: 14 candidates
jack debug: JACK graph reordered. Our maximum latency=0.
audio_format debug: s24l->f32l, bits per sample: 24->32
main debug: using audio filter module "audio_format"
main debug: TIMER module_need() : 5.259 ms - Total 5.259 ms / 1 intvls (Avg 5.259 ms)
main debug: conversion pipeline completed
main debug: filter(s) 'f32l'->'f32l' 96000 Hz->96000 Hz 3F2R/LFE->3F2R/LFE
main debug: conversion pipeline completed
main debug: filter(s) 'f32l'->'f32l' 105600 Hz->48000 Hz 3F2R/LFE->3F2R/LFE
main debug: looking for audio filter module: 14 candidates
main debug: using audio filter module "samplerate"
main debug: TIMER module_need() : 0.567 ms - Total 0.567 ms / 1 intvls (Avg 0.567 ms)
main debug: conversion pipeline completed
main debug: End of audio preroll
main debug: Decoder buffering done in 214 ms
main warning: PTS is out of range (-7893), dropping buffer
main warning: audio output out of sync, adjusting dates (73547 us)
main warning: not synchronized (73548 us), resampling
main warning: buffer too late (73130), up-sampling
main warning: audio output out of sync, adjusting dates (64012 us)
main warning: not synchronized (64014 us), resampling
main warning: timing screwed, stopping resampling
main warning: buffer too late (137124), up-sampling
main warning: audio output out of sync, adjusting dates (63978 us)
main warning: not synchronized (63980 us), resampling
main warning: buffer way too late (201083), dropping buffer
main warning: audio output out of sync, adjusting dates (64026 us)
main warning: not synchronized (64028 us), resampling
main warning: buffer way too late (222444), dropping buffer
main warning: audio output out of sync, adjusting dates (64113 us)
main warning: not synchronized (64115 us), resampling
main warning: buffer way too late (243892), dropping buffer
main warning: buffer way too late (201226), dropping buffer
main warning: audio output out of sync, adjusting dates (63992 us)
main warning: not synchronized (63994 us), resampling
main warning: buffer way too late (222532), dropping buffer
main warning: audio output out of sync, adjusting dates (63984 us)
main warning: not synchronized (63986 us), resampling
main warning: buffer way too late (243851), dropping buffer
main warning: buffer way too late (201185), dropping buffer
main warning: audio output out of sync, adjusting dates (64004 us)
main warning: not synchronized (64005 us), resampling
main warning: buffer way too late (222502), dropping buffer
main warning: audio output out of sync, adjusting dates (63904 us)
main warning: not synchronized (63905 us), resampling
main warning: buffer way too late (243720), dropping buffer
main warning: buffer way too late (201054), dropping buffer
main warning: audio output out of sync, adjusting dates (106827 us)
main warning: not synchronized (106829 us), resampling
main warning: buffer way too late (265195), dropping buffer
main warning: buffer way too late (222528), dropping buffer
main warning: audio output out of sync, adjusting dates (127947 us)
main warning: not synchronized (127949 us), resampling
main warning: buffer way too late (307790), dropping buffer
main warning: buffer way too late (265123), dropping buffer
main warning: buffer way too late (222457), dropping buffer
main debug: audio output is too slow (21186 us): trashing 10667 us
main debug: audio output is too slow (10519 us): trashing 10666 us
....

When playing a track with higher samplerate the VLC output is flooded with:

main debug: audio output is too slow (1824148 us): trashing 10667 us
main debug: audio output is too slow (1856244 us): trashing 10666 us
main debug: audio output is too slow (1845578 us): trashing 10667 us
...

when playing a track with lower samplerate:

main debug: audio output is starving (-24525), playing silence
main debug: audio output is starving (-24066), playing silence
main debug: audio output is starving (-23354), playing silence
...

I made tests with different settings of samplerate and periode for jack but the result is always the same.

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: vlc-plugin-jack 2.0.1-4
ProcVersionSignature: Ubuntu 3.2.0-23.31-lowlatency 3.2.14
Uname: Linux 3.2.0-23-lowlatency i686
ApportVersion: 2.0.1-0ubuntu5
Architecture: i386
Date: Mon Apr 23 12:44:29 2012
InstallationMedia: Xubuntu 11.04 "Natty Narwhal" - Release i386 (20110426.1)
ProcEnviron:
 LANGUAGE=en_US:en
 TERM=xterm
 PATH=(custom, no user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: vlc
UpgradeStatus: Upgraded to precise on 2012-04-10 (13 days ago)

Revision history for this message
Walter Oesch (walteroesch) wrote :
summary: - does not resample to samplerate defined in jack
+ VLC does not resample to samplerate defined in jack
Revision history for this message
Rémi Denis-Courmont (rdenis) wrote : Re: VLC does not resample to samplerate defined in jack

Can you please retry with audio time stretching disabled in the preferences?

Revision history for this message
Walter Oesch (walteroesch) wrote :

I disabled audio time stretching but nothing changed.

Revision history for this message
Rémi Denis-Courmont (rdenis) wrote :

Does the problem happen if you delete /usr/lib/vlc/plugins/audio_filter/libsamplerate_plugin.so then restart VLC ? and /usr/lib/vlc/plugins/audio_filter/libspeex_resampler_plugin.so ?

(You can restore them afterward with the command 'apt-get install --reinstall vlc-nox')

What if you use the ALSA output directly, also at 96 kHz ?

Revision history for this message
Walter Oesch (walteroesch) wrote :

I tested removing libsamplerate_plugin.so or libspeex_resampler_plugin.so or both and none of it changed anything.

However playback directly to ALSA workes fine. I made test with various combinations of sample rates for my USB sound interface and the audio track and all of them worked flawlessly.

Revision history for this message
Walter Oesch (walteroesch) wrote :

I also checked that ALSA is really running on the sample rate specified on the audio interface with:
cat /proc/asound/card1/pcm0p/sub0/hw_params

Revision history for this message
Rémi Denis-Courmont (rdenis) wrote :

That was with scaletempo (time stretching) disabled?

I guess the JACK output is broken. It has not had a maintainer in some years.

summary: - VLC does not resample to samplerate defined in jack
+ VLC does not resample correctly with JACK
Revision history for this message
Walter Oesch (walteroesch) wrote :

I took a look at the code of the Jack output module and with some debugging and some luck i found the problem:

in modules/audio_output/jack.c on line 139:

aout_PacketInit is called with p_aout and this p_aout contains the wrong sample rate, because it is set later, on line 146. Moving line 146 up before the call to aout_PacketInit solved the problem.

Changed in vlc (Debian):
status: Unknown → New
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in vlc (Ubuntu):
status: New → Confirmed
Changed in vlc:
assignee: nobody → Rémi Denis-Courmont (rdenis)
milestone: none → 2.0.2
Changed in vlc:
status: New → Fix Released
Changed in vlc (Debian):
status: New → Confirmed
Benjamin Drung (bdrung)
Changed in vlc (Ubuntu):
status: Confirmed → Triaged
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package vlc - 2.0.2-1

---------------
vlc (2.0.2-1) unstable; urgency=medium

  [ Edward Wang ]
  * New upstream release (Closes: #679625, #664279, LP: #689122, #936488,
    #942126, #971106, #972615, #973051, #987231, #995003, #998538).
    - Fix Ogg Heap buffer overflow. Thanks to Hugo Beauzée-Luyssen
  * Add the crystalhd plugin to the vlc distribution.
  * libcaca_plugin.so now depends on X11 in this release, so it must
    be installed under vlc (versus vlc-nox).

  [ Reinhard Tartler ]
  * Urgency set to medium because a security issue is fixed in this release

  [ Benjamin Drung ]
  * Add new plugins to vlc-nox:
    - crystalhd (Linux amd64 and i386 only)
    - directfb
    - fbosd (Linux only)
    - omxil (Linux only)
  * Add build dependencies for new plugins.
  * Add new symbols to libvlccore5.
  * Switch to debhelper 8.

 -- Benjamin Drung <email address hidden> Sat, 30 Jun 2012 18:39:41 +0200

Changed in vlc (Ubuntu):
status: Triaged → Fix Released
Changed in vlc (Debian):
status: Confirmed → Fix Released
Revision history for this message
Brian Murray (brian-murray) wrote : Update Released

The verification of this Stable Release Update has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regresssions.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.