[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, stable-queue, updated. v0.9.21-24-gfa64230
Lennart Poettering
gitmailer-noreply at 0pointer.de
Thu Jan 14 16:27:08 PST 2010
This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.
The stable-queue branch has been updated
from e129f8577a405266a5b7d4a7ee75bd56dd43953e (commit)
- Log -----------------------------------------------------------------
fa64230 client: implement $PULSE_LATENCY_MSEC
27df027 pacat: allow configuration of latency in msec
-----------------------------------------------------------------------
Summary of changes:
man/pacat.1.xml.in | 96 +++++++++++++++++++++++++++++++++++++++++++--------
src/pulse/stream.c | 37 +++++++++++++++++---
src/utils/pacat.c | 46 ++++++++++++++++++++-----
3 files changed, 149 insertions(+), 30 deletions(-)
-----------------------------------------------------------------------
commit 27df02779a26e0356497a39bee04a28138ba52af
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Jan 15 01:25:21 2010 +0100
pacat: allow configuration of latency in msec
diff --git a/man/pacat.1.xml.in b/man/pacat.1.xml.in
index 68a3a12..2e27450 100644
--- a/man/pacat.1.xml.in
+++ b/man/pacat.1.xml.in
@@ -21,18 +21,22 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA.
-->
-<manpage name="pacat" section="1" desc="Play back or record raw audio streams on a PulseAudio sound server">
+<manpage name="pacat" section="1" desc="Play back or record raw or encoded audio streams on a PulseAudio sound server">
<synopsis>
+ <cmd>paplay [<arg>options</arg>] [<arg>FILE</arg>]</cmd>
+ <cmd>parecord [<arg>options</arg>] [<arg>FILE</arg>]</cmd>
<cmd>pacat [<arg>options</arg>] [<arg>FILE</arg>]</cmd>
<cmd>parec [<arg>options</arg>] [<arg>FILE</arg>]</cmd>
- <cmd>paplay <opt>--help</opt></cmd>
- <cmd>paplay <opt>--version</opt></cmd>
+ <cmd>pamon [<arg>options</arg>] [<arg>FILE</arg>]</cmd>
+ <cmd>pacat <opt>--help</opt></cmd>
+ <cmd>pacat <opt>--version</opt></cmd>
</synopsis>
<description>
<p><file>pacat</file> is a simple tool for playing back or
- capturing raw audio files on a PulseAudio sound server.</p>
+ capturing raw or encoded audio files on a PulseAudio sound
+ server.</p>
</description>
<options>
@@ -52,13 +56,13 @@ USA.
<option>
<p><opt>-r | --record</opt></p>
- <optdesc><p>Capture raw audio data and write it to the specified file or to STDOUT if none is specified. If the tool is called under the name <file>parec</file> this is the default.</p></optdesc>
+ <optdesc><p>Capture audio data and write it to the specified file or to STDOUT if none is specified. If the tool is called under the name <file>parec</file> this is the default.</p></optdesc>
</option>
<option>
<p><opt>-p | --playback</opt></p>
- <optdesc><p>Read raw audio data from the specified file or STDIN if none is specified, and play it back. If the tool is called under the name <file>pacat</file> this is the default.</p></optdesc>
+ <optdesc><p>Read audio data from the specified file or STDIN if none is specified, and play it back. If the tool is called under the name <file>pacat</file> this is the default.</p></optdesc>
</option>
<option>
@@ -108,14 +112,17 @@ USA.
<optdesc><p>Capture or play back audio with the specified sample
format. Specify one of <opt>u8</opt>, <opt>s16le</opt>,
- <opt>s16be</opt>, <opt>s32le</opt>,
- <opt>s32be</opt>, <opt>float32le</opt>, <opt>float32be</opt>,
- <opt>ulaw</opt>, <opt>alaw</opt>. Depending on the endianess of
- the CPU the
- formats <opt>s16ne</opt>, <opt>s16re</opt>, <opt>s32ne</opt>, <opt>s32re</opt>,
- <opt>float32ne</opt>, <opt>float32re</opt> (for native,
- resp. reverse endian) are available as aliases. Defaults to
- s16ne.</p></optdesc>
+ <opt>s16be</opt>, <opt>s32le</opt>, <opt>s32be</opt>,
+ <opt>float32le</opt>, <opt>float32be</opt>, <opt>ulaw</opt>,
+ <opt>alaw</opt>, <opt>s32le</opt>, <opt>s32be</opt>,
+ <opt>s24le</opt>, <opt>s24be</opt>, <opt>s24-32le</opt>,
+ <opt>s24-32be</opt>. Depending on the endianess of the CPU the
+ formats <opt>s16ne</opt>, <opt>s16re</opt>, <opt>s32ne</opt>,
+ <opt>s32re</opt>, <opt>float32ne</opt>, <opt>float32re</opt>,
+ <opt>s32ne</opt>, <opt>s32re</opt>, <opt>s24ne</opt>,
+ <opt>s24re</opt>, <opt>s24-32ne</opt>, <opt>s24-32re</opt> (for
+ native, resp. reverse endian) are available as aliases. Defaults
+ to s16ne.</p></optdesc>
</option>
<option>
@@ -170,6 +177,65 @@ USA.
<optdesc><p>Never remap channels. Instead of mapping channels by their name this will match them solely by their index/order.</p></optdesc>
</option>
+ <option>
+ <p><opt>--latency</opt><arg>=BYTES</arg></p>
+ <optdesc><p>Explicitly configure the latency, with a time
+ specified in bytes in the selected sample format. If left out
+ the server will pick the latency, usually relatively high for
+ power saving reasons. Use either this option or
+ <opt>--latency-msec</opt>, but not both.</p></optdesc>
+ </option>
+
+ <option>
+ <p><opt>--latency-msec</opt><arg>=MSEC</arg></p>
+ <optdesc><p>Explicitly configure the latency, with a time
+ specified in miliseconds. If left out the server will pick the
+ latency, usually relatively high for power saving reasons. Use
+ either this option or <opt>--latency</opt>, but not
+ both.</p></optdesc>
+ </option>
+
+ <option>
+ <p><opt>--process-time</opt><arg>=BYTES</arg></p>
+ <optdesc><p>Explicitly configure the process time, with a time
+ specified in bytes in the selected sample format. If left out
+ the server will pick the process time. Use either this option or
+ <opt>--process-time-msec</opt>, but not both.</p></optdesc>
+ </option>
+
+ <option>
+ <p><opt>--process-time-msec</opt><arg>=MSEC</arg></p>
+ <optdesc><p>Explicitly configure the process time, with a time
+ specified in miliseconds. If left out the server will pick the
+ process time. Use either this option or <opt>--process-time</opt>,
+ but not both.</p></optdesc>
+ </option>
+
+ <option>
+ <p><opt>--property</opt><arg>=PROPERTY=VALUE</arg></p>
+ <optdesc><p>Attach a property to the client and stream. May be
+ used multiple times</p></optdesc>
+ </option>
+
+ <option>
+ <p><opt>--raw</opt></p>
+ <optdesc><p>Play/record raw audio data. This is the default if
+ this program is invoked as <cmd>pacat</cmd>, <cmd>parec</cmd> or
+ <cmd>pamon</cmd>.</p></optdesc>
+ </option>
+
+ <option>
+ <p><opt>--file-format</opt><arg>[=FFORMAT]</arg></p>
+ <optdesc><p>Play/record encoded audio data in the file format
+ specified. This is the default if this program is invoked as
+ <cmd>paplay</cmd> and <cmd>parecord</cmd>.</p></optdesc>
+ </option>
+
+ <option>
+ <p><opt>--list-file-formats</opt></p>
+ <optdesc><p>List supported file formats.</p></optdesc>
+ </option>
+
</options>
<section name="Authors">
@@ -178,7 +244,7 @@ USA.
<section name="See also">
<p>
- <manref name="pulseaudio" section="1"/>, <manref name="paplay" section="1"/>
+ <manref name="pulseaudio" section="1"/>, <manref name="pactl" section="1"/>
</p>
</section>
diff --git a/src/utils/pacat.c b/src/utils/pacat.c
index 5f29ba3..a5d2e9a 100644
--- a/src/utils/pacat.c
+++ b/src/utils/pacat.c
@@ -45,6 +45,7 @@
#include <pulsecore/core-util.h>
#include <pulsecore/log.h>
#include <pulsecore/sndfile-util.h>
+#include <pulsecore/core-util.h>
#define TIME_EVENT_USEC 50000
@@ -86,6 +87,7 @@ static sf_count_t (*writef_function)(SNDFILE *_sndfile, const void *ptr, sf_coun
static pa_stream_flags_t flags = 0;
static size_t latency = 0, process_time = 0;
+static int32_t latency_msec = 0, process_time_msec = 0;
static pa_bool_t raw = TRUE;
static int file_format = -1;
@@ -434,19 +436,25 @@ static void context_state_callback(pa_context *c, void *userdata) {
buffer_attr.maxlength = (uint32_t) -1;
buffer_attr.prebuf = (uint32_t) -1;
- if (latency > 0) {
+ if (latency_msec > 0) {
+ buffer_attr.fragsize = buffer_attr.tlength = pa_usec_to_bytes(latency_msec * PA_USEC_PER_MSEC, &sample_spec);
+ flags |= PA_STREAM_ADJUST_LATENCY;
+ } else if (latency > 0) {
buffer_attr.fragsize = buffer_attr.tlength = (uint32_t) latency;
- buffer_attr.minreq = (uint32_t) process_time;
flags |= PA_STREAM_ADJUST_LATENCY;
- } else {
- buffer_attr.tlength = (uint32_t) -1;
+ } else
+ buffer_attr.fragsize = buffer_attr.tlength = (uint32_t) -1;
+
+ if (process_time_msec > 0) {
+ buffer_attr.minreq = pa_usec_to_bytes(process_time_msec * PA_USEC_PER_MSEC, &sample_spec);
+ } else if (process_time > 0)
+ buffer_attr.minreq = (uint32_t) process_time;
+ else
buffer_attr.minreq = (uint32_t) -1;
- buffer_attr.fragsize = (uint32_t) -1;
- }
if (mode == PLAYBACK) {
pa_cvolume cv;
- if (pa_stream_connect_playback(stream, device, latency > 0 ? &buffer_attr : NULL, flags, volume_is_set ? pa_cvolume_set(&cv, sample_spec.channels, volume) : NULL, NULL) < 0) {
+ if (pa_stream_connect_playback(stream, device, &buffer_attr, flags, volume_is_set ? pa_cvolume_set(&cv, sample_spec.channels, volume) : NULL, NULL) < 0) {
pa_log(_("pa_stream_connect_playback() failed: %s"), pa_strerror(pa_context_errno(c)));
goto fail;
}
@@ -634,9 +642,11 @@ static void help(const char *argv0) {
" --no-remap Map channels by index instead of name.\n"
" --latency=BYTES Request the specified latency in bytes.\n"
" --process-time=BYTES Request the specified process time per request in bytes.\n"
+ " --latency-msec=MSEC Request the specified latency in msec.\n"
+ " --process-time-msec=MSEC Request the specified process time per request in msec.\n"
" --property=PROPERTY=VALUE Set the specified property to the specified value.\n"
" --raw Record/play raw PCM data.\n"
- " --file-format=FFORMAT Record/play formatted PCM data.\n"
+ " --file-format[=FFORMAT] Record/play formatted PCM data.\n"
" --list-file-formats List available file formats.\n")
, argv0);
}
@@ -659,7 +669,9 @@ enum {
ARG_RAW,
ARG_PROPERTY,
ARG_FILE_FORMAT,
- ARG_LIST_FILE_FORMATS
+ ARG_LIST_FILE_FORMATS,
+ ARG_LATENCY_MSEC,
+ ARG_PROCESS_TIME_MSEC
};
int main(int argc, char *argv[]) {
@@ -695,6 +707,8 @@ int main(int argc, char *argv[]) {
{"raw", 0, NULL, ARG_RAW},
{"file-format", 2, NULL, ARG_FILE_FORMAT},
{"list-file-formats", 0, NULL, ARG_LIST_FILE_FORMATS},
+ {"latency-msec", 1, NULL, ARG_LATENCY_MSEC},
+ {"process-time-msec", 1, NULL, ARG_PROCESS_TIME_MSEC},
{NULL, 0, NULL, 0}
};
@@ -854,6 +868,20 @@ int main(int argc, char *argv[]) {
}
break;
+ case ARG_LATENCY_MSEC:
+ if (((latency_msec = (int32_t) atoi(optarg))) <= 0) {
+ pa_log(_("Invalid latency specification '%s'"), optarg);
+ goto quit;
+ }
+ break;
+
+ case ARG_PROCESS_TIME_MSEC:
+ if (((process_time_msec = (int32_t) atoi(optarg))) <= 0) {
+ pa_log(_("Invalid process time specification '%s'"), optarg);
+ goto quit;
+ }
+ break;
+
case ARG_PROPERTY: {
char *t;
commit fa64230107bd348ceda271dc9db74765c694d311
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Jan 15 01:25:42 2010 +0100
client: implement $PULSE_LATENCY_MSEC
This allows easy overriding of a clients latency setting for debugging
purposes.
http://pulseaudio.org/ticket/753
diff --git a/src/pulse/stream.c b/src/pulse/stream.c
index 79b2868..daeb53a 100644
--- a/src/pulse/stream.c
+++ b/src/pulse/stream.c
@@ -39,6 +39,7 @@
#include <pulsecore/hashmap.h>
#include <pulsecore/macro.h>
#include <pulsecore/core-rtclock.h>
+#include <pulsecore/core-util.h>
#include "fork-detect.h"
#include "internal.h"
@@ -855,10 +856,28 @@ static void create_stream_complete(pa_stream *s) {
check_smoother_status(s, TRUE, FALSE, FALSE);
}
-static void automatic_buffer_attr(pa_stream *s, pa_buffer_attr *attr, const pa_sample_spec *ss) {
+static void patch_buffer_attr(pa_stream *s, pa_buffer_attr *attr, pa_stream_flags_t *flags) {
+ const char *e;
+
pa_assert(s);
pa_assert(attr);
- pa_assert(ss);
+
+ if ((e = getenv("PULSE_LATENCY_MSEC"))) {
+ uint32_t ms;
+
+ if (pa_atou(e, &ms) < 0 || ms <= 0)
+ pa_log_debug("Failed to parse $PULSE_LATENCY_MSEC: %s", e);
+ else {
+ attr->maxlength = (uint32_t) -1;
+ attr->tlength = pa_usec_to_bytes(ms * PA_USEC_PER_MSEC, &s->sample_spec);
+ attr->minreq = (uint32_t) -1;
+ attr->prebuf = (uint32_t) -1;
+ attr->fragsize = attr->tlength;
+ }
+
+ if (flags)
+ *flags |= PA_STREAM_ADJUST_LATENCY;
+ }
if (s->context->version >= 13)
return;
@@ -873,7 +892,7 @@ static void automatic_buffer_attr(pa_stream *s, pa_buffer_attr *attr, const pa_s
attr->maxlength = 4*1024*1024; /* 4MB is the maximum queue length PulseAudio <= 0.9.9 supported. */
if (attr->tlength == (uint32_t) -1)
- attr->tlength = (uint32_t) pa_usec_to_bytes(250*PA_USEC_PER_MSEC, ss); /* 250ms of buffering */
+ attr->tlength = (uint32_t) pa_usec_to_bytes(250*PA_USEC_PER_MSEC, &s->sample_spec); /* 250ms of buffering */
if (attr->minreq == (uint32_t) -1)
attr->minreq = (attr->tlength)/5; /* Ask for more data when there are only 200ms left in the playback buffer */
@@ -1064,15 +1083,16 @@ static int create_stream(
pa_stream_ref(s);
s->direction = direction;
- s->flags = flags;
- s->corked = !!(flags & PA_STREAM_START_CORKED);
if (sync_stream)
s->syncid = sync_stream->syncid;
if (attr)
s->buffer_attr = *attr;
- automatic_buffer_attr(s, &s->buffer_attr, &s->sample_spec);
+ patch_buffer_attr(s, &s->buffer_attr, &flags);
+
+ s->flags = flags;
+ s->corked = !!(flags & PA_STREAM_START_CORKED);
if (flags & PA_STREAM_INTERPOLATE_TIMING) {
pa_usec_t x;
@@ -2412,6 +2432,7 @@ pa_operation* pa_stream_set_buffer_attr(pa_stream *s, const pa_buffer_attr *attr
pa_operation *o;
pa_tagstruct *t;
uint32_t tag;
+ pa_buffer_attr copy;
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
@@ -2435,6 +2456,10 @@ pa_operation* pa_stream_set_buffer_attr(pa_stream *s, const pa_buffer_attr *attr
&tag);
pa_tagstruct_putu32(t, s->channel);
+ copy = *attr;
+ patch_buffer_attr(s, ©, NULL);
+ attr = ©
+
pa_tagstruct_putu32(t, attr->maxlength);
if (s->direction == PA_STREAM_PLAYBACK)
--
hooks/post-receive
PulseAudio Sound Server
More information about the pulseaudio-commits
mailing list