pacat --file-format option doesn't work

Bug #660504 reported by Thomas Horsten
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pulseaudio (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: pulseaudio

When I want to record audio with pacat I run a command like this:

$ pacat -r outfile

This works, but if I want the output file to have a specific format other than raw, e.g. WAV or AU format, the man page states that I can use "--file-format=FFORMAT". But this doesn't work, it always just creates an empty file and then prints "Failed to open audio file." Like this:

$ pacat -r --file-format=wav outfile.wav
Failed to open audio file.
$ ls -l outfile.wav
-rw-r--r-- 1 th th 0 2010-10-14 13:23 outfile.wav

Pretty useless error message too, if you ask me, because obviously it succeeded in opening the file (since it was created)..

ProblemType: Bug
DistroRelease: Ubuntu 10.10
Package: pulseaudio-utils 1:0.9.22~0.9.21+stable-queue-32-g8478-0ubuntu21
ProcVersionSignature: Ubuntu 2.6.35-22.33-generic 2.6.35.4
Uname: Linux 2.6.35-22-generic x86_64
NonfreeKernelModules: nvidia
AlsaVersion: Advanced Linux Sound Architecture Driver Version 1.0.23.
AplayDevices:
 **** List of PLAYBACK Hardware Devices ****
 card 0: Intel [HDA Intel], device 0: AD198x Analog [AD198x Analog]
   Subdevices: 1/1
   Subdevice #0: subdevice #0
Architecture: amd64
ArecordDevices:
 **** List of CAPTURE Hardware Devices ****
 card 0: Intel [HDA Intel], device 0: AD198x Analog [AD198x Analog]
   Subdevices: 2/2
   Subdevice #0: subdevice #0
   Subdevice #1: subdevice #1
AudioDevicesInUse:
 USER PID ACCESS COMMAND
 /dev/snd/controlC0: th 10977 F.... pulseaudio
Card0.Amixer.info:
 Card hw:0 'Intel'/'HDA Intel at 0xfdffc000 irq 45'
   Mixer name : 'Analog Devices AD1984'
   Components : 'HDA:11d41984,10280214,00100400'
   Controls : 21
   Simple ctrls : 14
Date: Thu Oct 14 12:20:28 2010
InstallationMedia: Ubuntu 10.04 "Lucid Lynx" - Release Candidate amd64 (20100419.1)
ProcEnviron:
 PATH=(custom, user)
 LANG=en_GB.utf8
 SHELL=/bin/bash
SourcePackage: pulseaudio
dmi.bios.date: 08/14/2008
dmi.bios.vendor: Dell Inc.
dmi.bios.version: A08
dmi.board.name: 0TP412
dmi.board.vendor: Dell Inc.
dmi.chassis.type: 7
dmi.chassis.vendor: Dell Inc.
dmi.modalias: dmi:bvnDellInc.:bvrA08:bd08/14/2008:svnDellInc.:pnPrecisionWorkStationT3400:pvr:rvnDellInc.:rn0TP412:rvr:cvnDellInc.:ct7:cvr:
dmi.product.name: Precision WorkStation T3400
dmi.sys.vendor: Dell Inc.

Revision history for this message
Thomas Horsten (thomas-horsten) wrote :
Revision history for this message
Luke Yelavich (themuso) wrote : Re: [Bug 660504] Re: pacat --file-format option doesn't work

I can verify this. Marking confirmed.

 affects ubuntu/pulseaudio
 status confirmed

Changed in pulseaudio (Ubuntu):
status: New → Confirmed
Daniel T Chen (crimsun)
Changed in pulseaudio (Ubuntu):
status: Confirmed → Triaged
Revision history for this message
Daniel T Chen (crimsun) wrote :

See lines 921 and 979 of src/utils/pacat.c. The call to pa_sndfile_format_from_string() at line 921 returns 20 when I use the command syntax given by the bug reporter. This value is later evaluated against <= 0, which will trivially fail, thus file_format retains the incorrect value of 20 instead of being assigned 65536 (which is SF_FORMAT_WAV, 0x10000). In turn, the call at line 991 to sf_open_fd() will return NULL, because sf_open_fd() calls psf_open_file(), the latter of which contains a conditional at line 2627 of SF_CONTAINER (psf->sf.format), which returns 0 because psf->sf.format does not contain a valid header because file_format was never correctly set to 0x10000, so psf_open_file() returns NULL, causing sf_open_fd() to return NULL, causing pacat's main() to bail.

The culprit is simple to see: line 979 of pacat.c is incorrectly checking against <= 0. What is not immediately clear is whether the value should be 20 instead of 0, because I have no way to verify the stability or semantics of this value. However, it is fairly easy to verify that changing that one line resolves the reporter's symptom.

The larger issue at hand is that the above description is only sufficient for WAV and WAVEX. It does not address the other file formats. It seems that there is a rather significant portion of code missing (bitrot?) from pacat.c to handle these conditions.

Revision history for this message
Luke Yelavich (themuso) wrote :

Pacat uses libsndfile. Whether its working properly with libsndfile is probably also open to question, in terms of the audio files that pacat shoudl be able to play.

Revision history for this message
Daniel T Chen (crimsun) wrote :

It turns out my analysis was off; the real culprit was in
pa_sndfile_format_from_string(). This bug has been fixed upstream in
12c3e97b (master) and in 84c8b23c (stable-queue).

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package pulseaudio - 1:0.9.22+stable-queue-18-geb966-0ubuntu1

---------------
pulseaudio (1:0.9.22+stable-queue-18-geb966-0ubuntu1) natty; urgency=low

  [ Daniel T Chen ]
  * debian/control: pulseaudio-module-zeroconf Depends on avahi-daemon
    (LP: #689093)
  * debian/patches/0101-update-stable-queue.patch: Apply 84c8b23c to
    resolve incorrect header being used for libsndfile seen with pacat
    --file-format (LP: #660504)
  * debian/patches/0104-Load-RAOP-Zeroconf-by-default.patch: Follow
    recommendation by Martin-Éric Racine to conditionally load support
    by default for streaming to an Apple Airport Express (LP: #688272)
  * debian/pulseaudio-utils.links: Also add pamon(1) and parecord(1)
    (Closes: #599696)

  [ David Henningsson ]
  * debian/pulse-alsa.conf: Add name hint for default pcm device,
    indicating that PulseAudio is active.

  [ Luke Yelavich ]
  * New upstream snapshot based on the stable queue branch:
    - eb966f7 (build-sys: Make --disable-dbus actually work.)
    - 8f8d247 (build-sys: Mention dbus support in the summary)
    - b3ff4f4 (build-sys: Put in specific warnings when there is no udev or
              DBUS support)
    - 862bbee (console-kit: Console Kit support is dependent on DBUS and is
              thus optional.)
    - 7cb1401 (padsp: wrap __open_2 and __open64_2)
    - 6f870f5 (fix bug about get source-output status)
    - 4269b05 (Fix typos)
    - 1c83b03 (Further clarify src- and speex- references in pulse-daemon.conf)
    - 84c8b23 (Fix return value of pa_sndfile_format_from_string)
    - d963b86 (core: Fix variable "has_whined" value bug)
    - 52e3268 (trivial: Mention speex as a resampler reference in
              pulse-daemon.conf)
    - 3e6af07 (module-loopback: Prevent an infinite loop when rate adjusting
              is disabled
  * 0101-update-stable-queue.patch and
    #0102-autoreconf.patch:
    - Disable for now, since latest stable queue are roled into the snapshot
      tarball
 -- Luke Yelavich <email address hidden> Fri, 14 Jan 2011 10:03:49 -0600

Changed in pulseaudio (Ubuntu):
status: Triaged → Fix Released
Revision history for this message
guest271314 (guest271314) wrote :
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Since this bug was closed 10 years ago it would be best to open a new open to track the problem in 20.04. Please run this command to open a new bug:

  ubuntu-bug pulseaudio

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.