Commit graph

145 commits

Author SHA1 Message Date
Tanu Kaskinen
59f2b4436a sink: Add casts to some printf arguments to get rid of compiler warnings. 2011-02-28 09:56:08 +00:00
Tanu Kaskinen
0d8bbaf40d sink: Don't send unnecessary PA_SINK_MESSAGE_SET_SHARED_VOLUME messages.
If send_msg is false, the message will be sent by the caller.
2011-02-28 09:55:01 +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
Kim Therkelsen
9379d4015c core: Added new hooks: PA_CORE_HOOK_SOURCE_PORT_CHANGED and PA_CORE_HOOK_SINK_PORT_CHANGED
This allows modules to know when certain ports are changed.
This will allow e.g. a filter module (or LADSAP) to only load
when a certain port is used on the device (e.g. to only filter
headphones and not normal speakers).

(Comment from Colin Guthrie: This may also have use in UCM)
2011-02-25 10:04:07 +00:00
Tanu Kaskinen
969c7c80fe core: Link virtual sinks and sources to their streams.
This change doesn't add any functionality in itself, but it will be useful in
the future for operating on chains of sinks or sources that are piggy-backing
on each other.

For example, the PA_PROP_DEVICE_MASTER_DEVICE property could
be handled in the core so that each virtual device doesn't have to maintain it
separately. By using the origin_sink and destination_source pointers the core
is able to see at stream creation time that the stream is created by a virtual
device, and then update that device's property list using the name of the
master device that the stream is being connected to. The same thing can be done
also when the stream is being moved from a device to another, in which case the
_MASTER_DEVICE property needs updating.
2011-02-22 10:10:48 +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
Jyri Sarha
3d83a0cf52 core: Use pa_sink_get_latency_within_thread() in sync-volume code 2011-01-15 13:24:40 +00:00
Jyri Sarha
6fd138f669 core: Use volume_change_safety_margin when rewinding sync-volume events
After this patch the volume changes are applied immediately after
sink rewind before processing streams and monitor source.
2011-01-15 13:23:02 +00:00
Colin Guthrie
13278bf234 intended-roles: Mark devices with a form factor of 'headset' as being appropriate for 'phone' streams
This was a result a report by Patrick Ben Koetter relating to his
Logitech Wireless Headset.
2010-10-16 12:26:47 +01:00
Jyri Sarha
3e53e3bba3 daemon-conf: Add sync volume parameters to daemon-conf
Signed-off-by: Jyri Sarha <jyri.sarha@nokia.com>
Reviewed-by: Tanu Kaskinen <tanu.kaskinen@digia.com>
Reviewd-by: Colin Guthrie <cguthrie@mandriva.org>
2010-10-16 11:53:39 +01:00
Jyri Sarha
5391daf8df core: Add infrastructure for synchronizing HW and SW volume changes
To make concurrent use of SW and HW volume glitchles their application
needs to be synchronized. For accurate synchronization the HW volume
needs to be applied in IO thread. This patch adds infrastructure to
delay the applying of HW volume to match with SW volume timing. To
avoid synchronization problems this patch moves many of the volume and
mute related functions from main thread to IO thread. All these
changes become active only if the sync volume flag for a sink has been
set. So, for this patch to have any effect it needs to be taken into
use by sink implementor.

Signed-off-by: Jyri Sarha <jyri.sarha@nokia.com>
Reviewed-by: Tanu Kaskinen <tanu.kaskinen@digia.com>
Reviewd-by: Colin Guthrie <cguthrie@mandriva.org>
2010-10-16 11:53:38 +01:00
Colin Guthrie
d195a54979 suspend: Do not assert when checking for device suspended status and a stream is not linked.
When looping through the streams on a given device checking to see if the
stream is 'active' there should be no assert if the stream is not linked, it
should simply be ignored.

This assert can be hit if a sink and a sink input are both created and setup
but the final put calls are left to the end as is done in module-ladspa-sink.

While the order of the calls in module-ladspa-sink could be altered, we should
deal gracefully with the way it is now and not complain about ending up
in this state.

A trigger case was trivial:
 1. Load a ladspa-sink.
 2. Play a stream and move it to it.
 3. Unload the module, then reload it.
 4. Due to module-stream-restore and module-suspend-on-idle, the hook callbacks
    will ultimately hit this assert.

Thanks to Kim Therkelsen for highlighting this issue.
2010-10-01 01:39:35 +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
616a8997b3 core: rework how stream volumes affect sink volumes 2010-02-23 18:41:18 +01:00
Lennart Poettering
4d62f159a7 Merge remote branch 'origin/merge-queue'
Conflicts:
	src/pulsecore/sink-input.c
	src/pulsecore/sink.c
2009-11-05 22:54:42 +01:00
Wim Taymans
8a49514f74 sink: simplify silence checks 2009-10-30 05:09:05 +01:00
Lennart Poettering
65e7bc18a9 use cloexec wrappers wherever applicable 2009-10-30 03:32:38 +01:00
Lennart Poettering
14a9771689 core: drop unnecessary variable initialization 2009-09-03 00:21:19 +02:00
Lennart Poettering
1200a0b143 sink: simplify pa_sink_render_full() by replacing it by a pa_sink_render() plus a couple of pa_sink_render_full() 2009-09-02 00:54:22 +02:00
Lennart Poettering
45513a2077 core: fill up memblock with pa_sink_render_into_full() in pa_sink_render_full() instead of doing our own loop 2009-09-01 22:19:30 +02:00
Lennart Poettering
17f609ac83 core: handle suspended state in pa_sink_render_full() similar to the other render functions 2009-09-01 22:18:55 +02:00
Lennart Poettering
ce6dff4ee0 core: add missing sink_unref() 2009-09-01 22:18:01 +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
8bf2e3fe94 core: initialize sink/source priorities automatically based on their proplists 2009-08-29 04:31:33 +02:00
Lennart Poettering
3b54849a08 core: add priority field to pa_sink/pa_source 2009-08-28 23:31:05 +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
9f97b7cbe1 sink-input: add callbacks that are called whenever the mute/volume changes 2009-08-21 02:56:17 +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
8dd0d871a7 core: add to FIXMEs 2009-08-16 00:45:56 +02:00
Lennart Poettering
0c08dbd9b9 core: introduce pa_{sink|source}_update_flags() 2009-08-15 03:41:13 +02:00
Lennart Poettering
3c271ae060 core: document difference between IO and main thread view on requested latency 2009-08-15 00:54:25 +02:00
Lennart Poettering
c6080d8c61 core: don't update latency range if not changed 2009-08-15 00:54:02 +02:00
Lennart Poettering
3f9c67a7fb core: call pa_sink_get_latency_within_thread() instead of going directly via process_msg() 2009-08-15 00:52:50 +02:00
Lennart Poettering
350a2bc846 core: make fixed latency dynamically changeable
This of course makes the name 'fixed' a bit of a misnomer. However the
definitions are now like this:

fixed latency: the latency may change during runtime, but is solely
controlled by the backend, the client has no influence.

dynamic latency: the latency may change during runtime, influenced by
the requests of the clients.

i.e. fixed vs. dynamic is from the perspective of the client.
2009-08-15 00:48:14 +02:00
Lennart Poettering
4eb59fb90e core: move rtpoll to thread_info sub structure 2009-08-15 00:26:00 +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
0989be13f6 core: introduce pa_{sink_input|source_output}_fail_move() 2009-08-15 00:03:50 +02:00
Lennart Poettering
9a95fe49c8 core: add assert macros for verifying calling context
This adds pa_assert_io_context() and pa_assert_ctl_context() in addition
to a few related macros. When called they will fail when the current execution
context is not IO resp. not control context. (aka 'thread' context vs.
'main' context)
2009-08-13 02:14:19 +02:00
Lennart Poettering
7d4916379b ladspa/remap: make sure we process all requested rewinds unconditionally
In some situations a rewind request travelling downstream might be
optimized away on its way and an upstream rewind processing might never
come back. Hence, call _process_rewind() before each _render()just to
make sure we processed them all.
2009-08-07 23:58:45 +02:00
Lennart Poettering
51b3899348 core: save volume/mute changes coming from the hardware automatically
Volume changes coming from the lower layers are most likely changes
triggered by the user, so let's save them automatically.
2009-08-07 23:55:06 +02:00
zbt
897ef86b7f Add volume ramping feature - sink modification 2009-08-05 20:10:47 +02:00
Lennart Poettering
8fe50b0d7c alsa,core: include mapping name in description strings 2009-06-18 04:38:59 +02:00
Lennart Poettering
39b37a2bac core: be a bit more verbose when registering a sink/source fails 2009-06-18 03:40:47 +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
f13bbd576f prop: introduce new PA_PROP_DEVICE_INTENDED_ROLES property 2009-06-08 16:58:45 +02:00
Lennart Poettering
e7a6d53118 core: replace tabs by spaces 2009-06-08 00:12:20 +02:00
Lennart Poettering
587fc2ab1c core: make sure soft mute status stays in sync with hw mute status
This should close rhbz #494851, mandriva bz #51234.

Probably the same as our own #572, launchpad #352732.
2009-06-08 00:02:15 +02:00
Jyri Sarha
8eaea3aa64 optimization: Optimized pa_sink_render_full.
This is finally the latest version of the patch.
2009-06-07 02:06:44 +02:00
Lennart Poettering
d1646f78af core: monitor sources need to inherit the suspend cause from their sinks 2009-06-06 15:32:45 +02:00
Lennart Poettering
69eab1e057 core: suppress suspending/resume when we are already in the right state 2009-06-06 15:31:46 +02:00