Commit graph

164 commits

Author SHA1 Message Date
Arun Raghavan
0ac2cfce6d core: Add extended stream API to support compressed formats
This is the beginning of work to support compressed formats natively in
PulseAudio. This adds a pa_stream_new_extended() that takes a format
structure, sends it to the server (=> protocol extension) and has the
server negotiate with the appropropriate sink to figure out what format
it should use.

This is work in progress, and works only with PCM streams. Actual
compressed format support in some sink needs to be implemented, and
extensive testing is required.

More details on how this is supposed to work is available at:
http://pulseaudio.org/wiki/PassthroughSupport
2011-05-02 11:54:43 +05:30
Tanu Kaskinen
e72e75570c sink-input: Add volume_writable to pa_sink_input.
This is pretty cosmetic change; there's no actual functionality added.
Previously the volume_writable information was available through the
pa_sink_input_is_volume_writable() function, but I find it cleaner to have a
real variable.

The sink input introspection variable name was also changed from
read_only_volume to volume_writable for consistency.
2011-03-29 21:18:06 +01:00
Maarten Bosmans
684b89c639 Fix up some double spaces 2011-03-18 09:20:07 +00:00
Maarten Bosmans
ecf09f2cd6 Fix up according to Coding Style
Only whitespace changes in here
2011-03-11 11:49:35 +00:00
Tanu Kaskinen
c9c88fb8dc Implement the "volume sharing" feature.
When we have a filter sink that does some processing, currently the
benefits of the flat volume feature are not really available. That's
because if you have a music player that is connected to the filter sink,
the hardware sink doesn't have any idea of the music player's stream
volume.

This problem is solved by this "volume sharing" feature. The volume
sharing feature works so that the filter sinks that want to avoid the
previously described problem declare that they don't want to have
independent volume, but they follow the master sink volume instead.
The PA_SINK_SHARE_VOLUME_WITH_MASTER sink flag is used for that
declaration. Then the volume logic is changed so that the hardware
sink calculates its real volume using also the streams connected to the
filter sink in addition to the streams that are connected directly to
the hardware sink. Basically we're trying to create an illusion that
from volume point of view all streams are connected directly to the
hardware sink.

For that illusion to work, the volumes of the filter sinks and their
virtual streams have to be managed carefully according to a set of
rules:

If a filter sink follows the hardware sink volume, then the filter sink's
 * reference_volume always equals the hw sink's reference_volume
 * real_volume always equals the hw sink's real_volume
 * soft_volume is always 0dB (ie. no soft volume)

If a filter sink doesn't follow the hardware sink volume, then the filter
sink's
 * reference_volume can be whatever (completely independent from the hw sink)
 * real_volume always equals reference_volume
 * soft_volume always equals real_volume (and reference_volume)

If a filter sink follows the hardware sink volume, and the hardware sink
supports flat volume, then the filter sink's virtual stream's
 * volume always equals the hw sink's real_volume
 * reference_ratio is calculated normally from the stream volume and the hw
   sink's reference_volume
 * real_ratio always equals 0dB (follows from the first point)
 * soft_volume always equals volume_factor (follows from the previous point)

If a filter sink follows the hardware sink volume, and the hardware sink
doesn't support flat volume, then the filter sink's virtual stream's
 * volume is always 0dB
 * reference_ratio is always 0dB
 * real_ratio is always 0dB
 * soft_volume always equals volume_factor

If a filter sink doesn't follow the hardware sink volume, then the filter
sink's virtual stream is handled as a regular stream.

Since the volumes of the virtual streams are controlled by a set of rules,
the user is not allowed to change the virtual streams' volumes. It would
probably also make sense to forbid changing the filter sinks' volume, but
that's not strictly necessary, and currently changing a filter sink's volume
changes actually the hardware sink's volume, and from there it propagates to
all filter sinks ("funny" effects are expected when adjusting a single
channel in cases where all sinks don't have the same channel maps).

This patch is based on the work of Marc-André Lureau, who did the
initial implementation for Pulseaudio 0.9.15.
2011-02-26 10:37:20 +00:00
Tanu Kaskinen
99ddca89cd Allow read-only or non-existing sink input volume.
There are two known cases where read-only or non-existing sink input volume is
relevant: passthrough streams and the planned volume sharing logic.
Passthrough streams don't have volume at all, and the volume sharing logic
requires read-only sink input volume. This commit is primarily working towards
the volume sharing feature, but support for non-existing sink input volume is
also added, because it is so closely related to read-only volume.

Some unrelated refactoring in iface-stream.c creeped into this commit too (new
function: stream_to_string()).
2011-02-22 20:12:31 +00:00
David Henningsson
74eb4d8921 Fighting rewinds: Reduce calls to handle_seek
If many small blocks are in queue, handle_seek is being called
for every one of them, sometimes causing a rewind. Delay the
call until all blocks are handled, then call handle_seek only
once.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2011-01-31 11:38:26 +00:00
David Henningsson
fe7b972487 Fighting rewinds: Seek and write data in the same message
Allow a message in the queue to perform both a seek and a post data.
For clients that do not use PA_SEEK_RELATIVE (e g gstreamer), this
cuts the message count - and sometimes even the rewinds - in half.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2011-01-31 11:38:17 +00:00
Lennart Poettering
1250b5d735 ratelimit: fix log levels of log suppression messages
When logging a suppression message do so on the same log level as the
suppressed messages.

Cherry picked by Colin Guthrie from ec5a785712
with a couple of additional changes due to extra limiting in master
that was not present in stable-queue.
2011-01-31 11:36:24 +00:00
Colin Guthrie
3de129f3ac introspect: Include whether a stream is corked in the info callback. 2010-10-06 09:17:01 +01: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
dbdc666fb6 various modernizations 2010-02-23 01:23:41 +01:00
Lennart Poettering
b5e30764c4 native: improve logging for buffer_attrs 2010-02-22 04:57:21 +01:00
Lennart Poettering
66cfa72eb4 native: rework handling of seeks that depend on variables the client does not know anything about
All seeks/flushes that depend on the playback buffer read pointer cannot
be accounted for properly in the client since it does not know the
actual read pointer. Due to that the clients do not account for it at
all. We need do the same on the server side. And we did, but a little
bit too extreme. While we properly have not applied the changes to the
"request" counter we still do have to apply it to the "missing" counter.
This patch fixes that.
2010-02-09 22:45:59 +00:00
Lennart Poettering
699233fb47 native: fix request counter miscalculations
Do not subtract bytes the client sends us beyond what we requested from
our missing bytes counter.

This was mostly a thinko that caused servers asking for too little data
when the client initially sent more data than requested, because that
data sent too much was accounted for twice.

This commit fixes this miscalculation.

http://bugzilla.redhat.com/show_bug.cgi?id=534130
2010-02-09 22:29:20 +00:00
Wim Taymans
f3866f2635 protocol: use the right sample rate for sources
Use the correct sample rate for reporting about the timing.
2009-11-10 13:21:55 +01:00
Lennart Poettering
f27a50691c libpulse: introduce PA_STREAM_RELATIVE_VOLUME 2009-10-29 00:46:22 +01:00
Lennart Poettering
546bcf3f2f protocol-native: if a client set volume/mute/device store it since it is user input 2009-10-28 23:50:42 +01:00
Lennart Poettering
27c6a80ccb protocol-native: declare that user configured volumes are always absolute 2009-10-28 23:47:21 +01:00
Lennart Poettering
807f2a9923 native: send PA_COMMAND_PLAYBACK_BUFFER_ATTR_CHANGED messages only to clients that understand it 2009-09-10 02:15:12 +02:00
Lennart Poettering
31d1d9088e protocol-native: log explicitly when someone asks us to quit 2009-09-08 23:53:28 +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
2970c11902 core: always allow volume setting with single-channel pa_cvolume 2009-08-31 21:40:59 +02:00
Lennart Poettering
e1ce365cd9 native: make sure clients cannot trigger an assert by sending us invalid volume info 2009-08-29 06:11:02 +02:00
Lennart Poettering
a7b3125206 protocol-native: replace use of pa_namereg_is_valid_name() by pa_namereg_is_valid_name_or_wildcard() where applicable to allow use of @@ wildcards 2009-08-29 03:57:53 +02:00
Lennart Poettering
84eb6614eb core: move 'flags' field into 'pa_sink_input_new_data' structure so that hooks can access it 2009-08-28 23:24:09 +02:00
Lennart Poettering
c372b52a77 protocol-native: print more volume change debug messages to easy tracking down of feedback loops 2009-08-27 00:05:54 +02:00
Lennart Poettering
cab48d48d1 protocol-native: compare uint64_t variable with (uint64_t) -1 instead of (size_t) -1 for compat with 32bit archs 2009-08-27 00:04:33 +02:00
Lennart Poettering
9abc010c93 object: speed up type verification by not relying on strcmp()
Instead of using string contents for type identification use the address
of a constant string array. This should speed up type verifications a
little sind we only need to compare one machine word instead of a full
string. Also, this saves a few strings.

To make clear that types must be compared via address and not string
contents 'type_name' is now called 'type_id'.

This also simplifies the macros for declaring and defining public and
private subclasses.
2009-08-21 21:27:44 +02:00
Lennart Poettering
8c31974f56 sink: volume handling rework, new flat volume logic
- We now implement a logic where the sink maintains two distinct
  volumes: the 'reference' volume which is shown to the users, and the
  'real' volume, which is configured to the hardware. The latter is
  configured to the max of all streams. Volume changes on sinks are
  propagated back to the streams proportional to the reference volume
  change. Volume changes on sink inputs are forwarded to the sink by
  'pushing' the volume if necessary.

  This renames the old 'virtual_volume' to 'real_volume'. The
  'reference_volume' is now the one exposed to users.

  By this logic the sink volume visible to the user, will always be the
  "upper" boundary for everything that is played. Saved/restored stream
  volumes are measured relative to this boundary, the factor here is
  always < 1.0.

- introduce accuracy for sink volumes, similar to the accuracy we
  already have for source volumes.

- other cleanups.
2009-08-19 02:55:02 +02:00
Lennart Poettering
d7d86e32dd native-protocol: downgrade volume change log messages 2009-08-15 00:54:51 +02:00
Lennart Poettering
58d441f7ea log: place more rate limit invocations 2009-08-15 00:16:25 +02:00
Lennart Poettering
e4db56bf07 core: split of FAIL_ON_SUSPEND into KILL_ON_SUSPEND and NO_CREATE_ON_SUSPEND 2009-08-15 00:12:53 +02:00
Lennart Poettering
e53d2fc6b5 native: handle moving() callback with NULL destination properly 2009-08-15 00:05:17 +02:00
Lennart Poettering
72d2540e8d protocol-native: log explicitly each time a client triggers a volume change 2009-08-14 19:31:05 +02:00
Wim Taymans
3b01d3a53f protocol-native: use the right samplerate
The render_memblockq is expressed in the sample_spec of the sink, not of the
particular stream before resampling.
2009-07-23 13:57:42 +02:00
Lennart Poettering
a10b7cda4e native: don't hit assert when user uploads zero-sized sample 2009-07-01 14:25:13 +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
46b8ca21d1 native-protocol: allow enumerating ports 2009-06-17 23:17:37 +02:00
Lennart Poettering
6d7cf14dbf native: implement command to change sink/source port 2009-06-17 04:52:41 +02:00
Lennart Poettering
31575f7766 alsa: rework mixer logic
Completely rework mixer logic. This now allows controlling a full set of
elements from a single sink's volume slider/mute button.

This also introduces sink and source "ports" that can be used to choose
different input or output ports with the UI. (i.e. "mic"/"line-in" or
"speaker"/"headphones".

The mixer paths and device maps are now configered in external
configuration files and can be tweaked as necessary.
2009-06-17 03:45:14 +02:00
Lennart Poettering
00797b8b6e core: add a suspend cause flags field 2009-06-05 19:05:07 +02:00
Lennart Poettering
ad5a1f312a protocol-native,proplist-util: port to pa_get_{user|host}_name_malloc() 2009-04-29 01:56:02 +02:00
Lennart Poettering
fe8b10cc05 core: introduce new 'reference' volume for sinks
The reference volume is to be used as reference volume for stored stream
volumes. Previously if a new stream was created the relative volume was
taken relatively to the virtual device volume. Due to the flat volume
logic this could then be fed back to the virtual device volume.
Repeating the whole story over and over would result in a device volume
that would go lower, and lower and lower.

This patch introduces a 'reference' volume for each sink which stays
unmodified by stream volume changes even if flat volumes are used. It is
only modified if the sink volumes are modified directly by the user.

For further explanations see http://pulseaudio.org/wiki/InternalVolumes
2009-04-13 22:56:25 +02:00
Lennart Poettering
f8ebe8571c protocol-native: downgrade message if we receive pcm block for dead stream 2009-04-10 01:16:59 +02:00
Lennart Poettering
5b871966ab protocol-native: print underrun message only once for each underrun 2009-04-10 01:16:24 +02:00
Lennart Poettering
e61728e67a Make sure we don't get stuck when prebuf is too high
If prebuf is greater than tlength minus minreq we might end up waiting
for the buffer to fill up further however without ever asking for more
data from the client since less minreq bytes might be missing.

This fixes bug #440
2009-04-06 22:13:41 +02:00
Lennart Poettering
14e11e4533 Fix a couple of races in native protocol
Also make sure we account for recording memblock that are currently 'on
the fly' between the main and the IO thread.

Also makes a couple of timing calls that were done in different calls
in a single inter-thread call. That way there is a better guarantee that
they match up.
2009-04-05 02:59:02 +02:00
Lennart Poettering
373b5efe51 properly account for seeks in the requested_bytes counter 2009-04-01 23:05:09 +02:00
Lennart Poettering
75a8d18285 pass destination source/sink when moving streams so that we can access them 2009-04-01 03:04:39 +02:00