Commit graph

89 commits

Author SHA1 Message Date
Rafael Fontenelle
10445e0fdd pacat: fix syntax error 2024-10-11 15:28:12 +00:00
Rafael Fontenelle
16600ce40c pacat: break --device option description in 100 chars 2024-10-11 15:10:42 +00:00
guest271314
4b996e2a7b pacat: Include the special default device names in documentation
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/684>
2022-01-26 17:13:53 +00:00
Martin Wilck
1a73fb9eb9 parecord: really fix recording OGG
432a91ed ("fix "Failed to open audio file" for FLAC and OGG)" claimed
to fix recording of OGG files with pacat, but it really fixed only
FLAC. This patch must be added on top to fix OGG, too.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/542>
2021-04-19 18:24:34 +02:00
Martin Wilck
432a91ed43 parecord: fix "Failed to open audio file" for FLAC and OGG
This patch fixes the following error:

$ pacat --file-format=ogg -r test.ogg
Failed to open audio file.
$ parecord sep.flac
Failed to open audio file.

libsndfile errors out if a WAV or OGG file is set to have anything but
SF_ENDIAN_FILE:

f4d1646e5c

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/526>
2021-04-19 13:35:48 +00:00
Tanu Kaskinen
36a4923f9b Point to SupportedAudioFormats wiki page where appropriate
I documented the supported PCM sample formats and compressed audio
encodings in the wiki, let's add some pointers to the new documentation.
2020-04-23 15:24:24 +00:00
Stefan Huber
4f831e0d7a pacat: Fix code style 2018-08-11 13:36:51 +03:00
Denis Shulyaka
7ebe7b8a35 pacat: fix a memory issue
If only part of the buffer is written into stdout by stdout_callback,
the buffer_index variable is increased by the number of written bytes,
buffer_length variable is decreased while the allocated buffer size
remains the same. That suggests that the current allocated size is
calculated as (buffer_index + buffer_length). However the current
stream_read_callback implementation writes new data to the start of the
buffer and allocates too little space, so that (buffer + buffer_index +
buffer_length - 1) could actully point outside of the allocated buffer.
2017-07-31 04:41:10 +03:00
Ahmed S. Darwish
f7b8df50c7 pacat: Write to stream only in frame-sized chunks
Current pacat code reads whatever available from STDIN and writes
it directly to the playback stream. A minimal buffer is created
for each read operation; no further reads are then allowed unless
earlier read buffer has been fully consumed by a stream write.

While quite simple, this model breaks upon the new requirements of
writing only frame-aligned data to the stream (commits #1 and #2).
The kernel read syscall can return a length much smaller than the
frame-aligned size requested, leading to invalid unaligned writes.

This can easily be reproduced by choosing a starved STDIN backend:

  pacat /dev/random    pa_stream_write() failed: EINVAL
  echo 1234 | pacat    pa_stream_write() failed: EINVAL

or by playing an incomplete WAV file in raw, non-paplay, mode.

So guard against such incomplete kernel reads by writing only in
frame-aligned sizes, while caching any trailing partial frame for
subsequent writes.

Other operation modes are not affected. Non-raw paplay playback is
handled by libsndfile, ensuring complete reads, and recording mode
just writes to the STDOUT fd without any special needs.

CommitReference #1: 22827a5e1e
CommitReference #2: 150ace90f3
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=98475
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=77595

Suggested-by: David Henningsson <diwic@ubuntu.com>
Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
2016-12-20 19:59:08 +02:00
Ahmed S. Darwish
f5315113a5 pacat: Synchronize STDIN and "write stream ready" events
Users reported pacat crashes when playing certain multi-channel
audio. For example:

  pacat --channels=2 /dev/zero    works
  pacat --channels=3 /dev/zero    pa_stream_write() failed: EINVAL
  pacat --channels=4 /dev/zero    works
  pacat --channels=5 /dev/zero    pa_stream_write() failed: EINVAL

pacat audio playback is pipe-like, from STDIN to PA write stream.
Meanwhile STDIN "ready to read" events got regularly triggered
before the write stream was even created, or at moments where the
stream could not accept any more audio.

In these out-of-sync cases, the write stream could not report the
appropriate buffer lengths it accepts, thus a default of 4K bytes
was chosen -- compatible by luck with some channel counts and
incompatible with others.

Instead of choosing a faulty default in these scenarios, mute the
the STDIN events until the write stream is available & queriable.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=98475
Reported-by: Tanu Kaskinen <tanuk@iki.fi>
Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
2016-11-24 20:40:04 +02:00
Deepak Srivastava
a3bf429efd Removed exclamation marks from user-visible messages.
<EP-E358F00C1D9A449EAE69225B9D2530F8>
According to rationale-"http://techbase.kde.org/Projects/Usability/HIG/Exclamation_points" as suggested in reported bug.
Component: misc

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=78563

Signed-off-by: Deepak Srivastava <srivastava.d@samsung.com>
2015-08-14 12:17:02 +03:00
Peter Meerwald
ebee1a6306 pacat: Fix comment wording
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2015-02-26 23:30:25 +01:00
Peter Meerwald
8a08e7e38a pacat: State purpose of program depending how it was invoked
see https://bugs.freedesktop.org/show_bug.cgi?id=68135

state purpose of paplay/parec/pamon/parecord/pacat when invoked with -h

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2015-02-12 20:36:58 +01:00
Ondrej Holecek
5effc83479 update FSF addresses to FSF web page
FSF addresses used in PA sources are no longer valid and rpmlint
generates numerous warnings during packaging because of this.
This patch changes all FSF addresses to FSF web page according to
the GPL how-to: https://www.gnu.org/licenses/gpl-howto.en.html

Done automatically by sed-ing through sources.
2015-01-14 22:20:40 +02:00
Peter Meerwald
f975aad1d3 pacat: Mention source in addition to sink where applicable in help
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2014-04-27 22:04:22 +02:00
Tanu Kaskinen
568702f44e pacat: Fix partially translated message
The word "not" was not translated.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=76529
2014-03-24 09:22:20 +02:00
Magnus Ekhall
49f93eb2b0 pacat: Added support for recording from one specific sink input
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=66326
2013-08-14 16:09:54 +03:00
poljar (Damir Jelić)
d806b19714 Remove pa_bool_t and replace it with bool.
commands used for this (executed from the pulseaudio/src directory):
    find . -regex '\(.*\.[hc]\|.*\.cc\|.*\.m4\)' -not -name 'macro.h' \
        -a -not -name 'reserve.[ch]' -a -not -name 'reserve-monitor.[ch]' \
        -a -not -name 'glib-mainloop.c' -a -not -name 'gkt-test.c' \
        -a -not -name 'glib-mainloop.c' -a -not -name 'gkt-test.c' \
        -a -not -name 'poll-win32.c' -a -not -name 'thread-win32.c' \
        -a -not -name 'dllmain.c' -a -not -name 'gconf-helper.c' \
        -exec sed -i -e 's/\bpa_bool_t\b/bool/g' \
        -e 's/\bTRUE\b/true/g' -e 's/\bFALSE\b/false/g' {} \;

and:
    sed -i -e '181,194!s/\bpa_bool_t\b/bool/' \
        -e '181,194!s/\bTRUE\b/true/' -e \
        '181,194!s/\bFALSE\b/false/' pulsecore/macro.h
2013-07-04 12:25:30 +03:00
Tanu Kaskinen
a560cf3b67 pacat: Fix mode detection for parecord
Due to the missing "else", parecord was interpreted as parec, causing
the raw flag to be set when it shouldn't have been set.
2013-03-21 12:35:07 +02:00
Tanu Kaskinen
8cb34c6960 pacat: Handle holes in recording streams.
pa_silence_memory() pulls sample-util as a dependency, so it had to
be moved from libpulsecore to libpulsecommon. sample-util in turn
pulls some more stuff.
2013-02-04 12:07:39 +02:00
Thomas Martitz
b342daded9 pacat: Replace read(), write() with pa_* equivalent.
Calling pa_read() and pa_write() seems more appropriate since they deal better
with platform specific issues. This doesn't actually fix any open issue since
only stdio is affected but it seems more future proof.
2012-10-23 12:12:37 +05:30
Thomas Martitz
c1637652ea pacat: Enable binary mode on Windows.
Without this reading from stdin will eventually end with EOF (if there happens
to be a newline sign in the stream), because read() returns 0.

This patch fixes raw data input and piping to pacat on Windows.
2012-10-23 11:57:08 +05:30
Arun Raghavan
87e6f489a9 utils: Fixes for building without NLS 2011-12-13 09:10:08 +05:30
Maarten Bosmans
3c4d43d9dc pacat: Fail early if the media name cannot be set
Otherwise you get an "invalid argument" error from pa_stream_new later.
2011-10-11 22:48:25 +05:30
Lu Guanqun
cef16430d0 pacat: make pacat respond to cork/uncork events
Pacat remembers the number of cork requests, and then cork/uncork the stream
accordingly.

With this change, it makes below test script work correctly:

	pacat -p --property=media.role="music" <long-sound> &
	sleep 2
	pacat -p --property=media.role="phone" <short-sound>
	wait

Initial idea by Lu Guanqun, but modified by Colin Guthrie (so blame
me if it's broken)
2011-08-29 10:31:46 +01:00
Maarten Bosmans
c5dca7cf2b More spelling fixes 2011-08-25 11:27:47 +01:00
Maarten Bosmans
b4e938e194 Move i18n.[ch] to src/pulsecore
The header is used in files troughout the tree and is not included in the public api,
so it belongs in pulsecore, not in pulse.
2011-08-11 13:23:42 +02:00
Maarten Bosmans
aa7bc322e2 parecord: Automatically detect file format from extension
And fix a small bug in pa_sndfile_format_from_string.
2011-06-27 09:59:56 +01:00
Tanu Kaskinen
983d4c238d pacat: Fix memory leak when draining the context. 2011-03-11 13:37:49 +02:00
Maarten Bosmans
53695b83dc Get rid of some unused-function compiler warnings 2011-03-02 14:52:46 +00:00
Pierre-Louis Bossart
9b6c84ad6e AC3 passthrough support
Second version after Tanu's feedback

TODO:
    - notify client that volume control is disabled
    - change sink rate in passthrough mode if needed
    - automatic detection of passthrough mode instead of hard
    coded profile names

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@intel.com>
2010-08-12 18:20:27 +01:00
Lennart Poettering
0a7fccdb3d pacat: pass buffer_attr to recording streams too
Pointed out by Colin Guthrie.

https://tango.0pointer.de/pipermail/pulseaudio-discuss/2010-February/006698.html
2010-02-21 21:09:26 +01:00
Lennart Poettering
d57ba82414 pacat: always fully fulfill write requests
Make sure we always fulfill write requests from the server. If we don't
the server won't ask us again and playback will stay stuck.

https://tango.0pointer.de/pipermail/pulseaudio-discuss/2010-February/006611.html
2010-02-21 17:47:44 +01:00
Lennart Poettering
f6f957b53c Revert "pacat: Don't use any buffer attr if we don't set any latency/process time params"
This reverts commit ff2091b2c4.
2010-02-21 17:40:44 +01:00
Colin Guthrie
ff2091b2c4 pacat: Don't use any buffer attr if we don't set any latency/process time params 2010-02-11 23:33:19 +00:00
Lennart Poettering
fb55798a3e pacat: allow configuration of latency in msec 2010-02-09 22:44:30 +00:00
Lennart Poettering
65e7bc18a9 use cloexec wrappers wherever applicable 2009-10-30 03:32:38 +01:00
Lennart Poettering
1a6974a1e2 pacat: use fully automatic buffer sizes if possible 2009-09-17 01:22:48 +02:00
Lennart Poettering
b51f5e58cc pacat: don't convert stream name twice (llvm-clang-analyzer) 2009-09-08 23:54:31 +02:00
Lennart Poettering
f5046759cd llvm-clang-analyzer: drop a few unnecessary assignments and other trivial fixes 2009-09-08 23:46:23 +02:00
Lennart Poettering
b2606cf641 i18n: move \r out of translatable string
https://bugzilla.redhat.com/show_bug.cgi?id=521552
2009-09-07 23:34:31 +02:00
Lennart Poettering
a81244a726 pacat: use zero-copy write calls when playing audio file 2009-07-23 20:01:40 +02:00
Marc-André Lureau
0955e3d45b Base mainloop on pa_rtclock_now()
Move the mainloop to monotonic based time events.

Introduces 4 helper functions:
pa_{context,core}_rttime_{new,restart}(), that fill correctly a
timeval with the rtclock flag set if the mainloop supports it.

Both mainloop-test and mainloop-test-glib works with rt and timeval
based time events. PulseAudio and clients should be fully functional.

This patch has received several iterations, and this one as been
largely untested.

Signed-off-by: Marc-André Lureau <marca-andre.lureau@nokia.com>
2009-06-20 17:29:31 +03:00
Lennart Poettering
5c10b84e0f sndfile: big rework of libsndfile interfacing code
This adds proper channel map handling when reading/writing audio files.
This allows surround .WAV files to be played with the right channel
setup automatically.

This also merges paplay into pacat and adds recording into formatted
files to pacat.
2009-05-26 00:05:28 +02:00
Lennart Poettering
2d94c93957 pacat: add missing newline 2009-04-14 01:03:34 +02:00
Lennart Poettering
aa1ad0df18 in verbose mode log buffer attr changes 2009-04-01 00:35:37 +02:00
Colin Guthrie
86dee05aec Use LGPL 2.1 on all files previously using LGPL 2 2009-03-03 20:23:02 +00:00
Marc-André Lureau
67b0baecc4 pacat: remove unused variable 2009-02-19 04:55:11 +01:00
Lennart Poettering
823431e447 allow sending meta/policy events to clients 2009-02-12 03:18:05 +01:00
Lennart Poettering
b9e96e00cf for record streams fill in the latency as the fragsize 2009-01-12 19:34:12 +01:00