Commit graph

158 commits

Author SHA1 Message Date
Jarkko Nikula
fbb13a0dc6 alsa: move pa_alsa_setting_select close to pa_alsa_path_select
Move pa_alsa_setting_select call just after the pa_alsa_path_select in
[sink | source]_set_port_cb functions as there is no dependency to volume
calculations that are done between these two calls. Idea here is to make
possible to merge these two functions since they are called together from
other places too.
2012-07-06 20:38:10 +03:00
Tanu Kaskinen
8417cac4f6 alsa-mixer: Implement a new path option: "mute-during-activation". 2012-07-06 20:38:03 +03:00
Tanu Kaskinen
1a6da64b16 sink, source: Always create a hashmap for ports.
Having the hashmap sometimes NULL requires a lot of checking
here and there, so ensuring that the hashmap is always
non-NULL simplifies the code.
2012-06-29 14:24:43 +03:00
Eero Nurkkala
79c0d52a39 alsa-sink: add missing header 'signal.h'
Compilation with -DDEBUG_TIMING fails due to a missing header:

modules/alsa/alsa-sink.c: In function 'check_left_to_play':
modules/alsa/alsa-sink.c:453:9: warning: implicit declaration of function 'raise' [-Wimplicit-function-declaration]
modules/alsa/alsa-sink.c:453:9: error: 'SIGTRAP' undeclared (first use in this function)

Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
2012-05-31 14:25:23 +02:00
David Henningsson
6961d3e1c7 alsa-sink/source: Make sure volumes are synchronised after fast user switching
Log in as user A, fast user switch to user B, let user B change
port, volume or mute status, then switch back to user A.

At this point we must make sure that the ALSA and PA volumes are
synchronised by writing to the ALSA mixer when the ALSA device
becomes available.

BugLink: https://bugs.launchpad.net/bugs/915035
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2012-04-12 00:13:11 +02:00
David Henningsson
87edc1ccb0 alsa-sink/source: Really set volumes on port change
If deferred volumes were activated, set_volume does not really set
the volume, and is probably only meant to be called from the main
thread.
As we're currently really setting the port and the mute here (i e
modifying ALSA), we should really modify the volume as well.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2012-04-04 14:36:43 +02:00
Tanu Kaskinen
5a26404f12 alsa: Fix SND_MIXER_SCHN_LAST related stuff.
Valid channel id range is from 0 to SND_MIXER_SCHN_LAST,
inclusive, so the size of the masks array in pa_alsa_element
has to be SND_MIXER_SCHN_LAST + 1. Similar "too small"
arrays were also in alsa-sink's and alsa-source's userdata,
but actually those arrays were not used at all so they were
removed.

element_is_subset() in alsa-mixer.c skipped the last channel
id when iterating the element masks array; that's now fixed
as well.

Thanks to David Henningsson for spotting the too small
arrays in alsa-sink and alsa-source and the
element_is_subset() problem.
2012-03-28 17:32:04 +03:00
David Henningsson
dedf1340c6 alsa: Jack detection kcontrol implementation
Support the new jack detection interface implemented in Linux 3.3
(and Ubuntu's 3.2 kernel).

Jacks are probed and detected using the snd_hctl_* commands, which
means we need to listen to them using fdlists. As this detection
needs to be active even if there is currently no sink for the jack,
so this polling is done on the card level.

Also add configuration support in paths, like this:
[Jack Headphone]
required-any = any

...where 'Jack Headphone' should match 'Headphone Jack' as given by
ALSA (as seen in e g 'amixer controls').
"Required", "required-any" and "required-absent" is supported. Using
required-any, one can have several ports even though there is no
other indication in the mixer that this path exists.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2012-03-11 12:23:46 +05:30
David Henningsson
c5dcf5723b alsa: Fix log message "synchronous volume" -> "deferred volume"
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2012-01-17 16:58:40 +05:30
David Henningsson
426daaf6bb alsa: add card ports and path probe cache
To be able to add ports to all profiles, we need to probe all
profiles at startup. To speed this up, we now have a cache of
probes paths which is owned by the profile set. Since paths
are now owned by the profile set, the path set must now have
a hashmap of paths instead of a linked list.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2011-12-01 21:49:17 +02:00
David Henningsson
47f28a5843 Notify port available status changes, and update protocol version
The recommended way of setting available status is to call
pa_device_port_set_available, which will send a subscription event
to the relevant card. It will also fire a hook.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2011-11-26 16:58:37 +02:00
Arun Raghavan
d320ae029b alsa: Minor debug code cleanup
Remove a trap on underrun and uncomment a couple of useful debug prints
(still enabled only when DEBUG_TIMING is defined).
2011-11-14 10:54:18 +05:30
Lars R. Damerow
7a387fed36 alsa: support fixed latency range in alsa modules
This adds a boolean module parameter to disable automatic dynamic
latency readjustments on underruns, but leaves automatic dynamic
watermark readjustments untouched.
2011-11-03 21:17:54 +01:00
Arun Raghavan
e67440e220 alsa: Probe sink/source sample rates
This probes sink and source sample rates and uses this information to
validate rate changes and check incoming passthrough formats.
2011-10-17 22:52:47 +05:30
Arun Raghavan
3555634e6e alsa: Remove unused variable 2011-10-17 21:16:23 +05:30
Arun Raghavan
ac469a25c0 sink,source: Add the ability to disable alternat sample rate switching
Setting the alternate sample rate to 0 in config disables this feature.
2011-10-17 20:16:37 +05:30
Pierre-Louis Bossart
b232fbd8f8 alsa: support for alternate sampling rate
This is where the actual changes happen.
Some additional checks would be required to make sure the
rate is actually supported
Tested with both PCM and passthrough streams

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
2011-10-17 20:09:50 +05:30
Tanu Kaskinen
a88b1d5cd4 alsa: New modarg "paths_dir" for module-alsa-card
The new module argument can be used to provide a custom
directory for loading alsa path configuration files. This is
useful for testing: no need to be root to create test
configuration files.
2011-10-17 12:54:23 +05:30
David Henningsson
ca6057316d Fix deferred volume not being applied if sink is closed
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2011-10-17 09:50:16 +05:30
Pierre-Louis Bossart
a103e82029 alsa: reset watermark to initial values on resume
Watermark level and latency values are not restored when
resuming, the values used prior to suspending are reused.
This leads to side effects when underruns happen and buffer
sizes are updated, PulseAudio can never meet lower latency
requirements.

Solution: keep track of watermark and latency values on sink or
source creation, and reapply them on resume to start with
a clean slate.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
2011-10-08 14:51:50 +05:30
Arun Raghavan
fc8702ee81 alsa: Give compressed formats preference over PCM
This makes set_formats() put PCM formats lower down the list than
compressed formats since we negotiate by picking the first format in
this list that is also in the client-provided list of possible formats
during sink input creation.

This will be incorrect if we ever decide to do encoding in PA (for
things like AC3/DTS encoding for multichannel output over S/PDIF).
2011-10-04 12:29:32 +05:30
David Henningsson
f8624a7876 sink,source: Avoid crash by not updating volume on shutdown
Sometimes the ALSA mixer can be modified during a point at shutdown
which causes a race condition trying to update the volume of an
unlinked sink.

Includes typo fix by our Chief Typo Spotter, Colin, and a clarifying
comment by me.

BugLink: http://bugs.launchpad.net/bugs/841968
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2011-09-14 15:47:17 +05:30
Colin Guthrie
aa3142ab20 volume: Rename 'sync volume' to 'deferred volume'.
This just covers Lennart's concern over the terminology used.

The majority of this change is simply the following command:
 grep -rli sync[-_]volume . | xargs sed -i 's/sync_volume/deferred_volume/g;s/PA_SINK_SYNC_VOLUME/PA_SINK_DEFERRED_VOLUME/g;s/PA_SOURCE_SYNC_VOLUME/PA_SOURCE_DEFERRED_VOLUME/g;s/sync-volume/deferred-volume/g'

Some minor tweaks were added on top to tidy up formatting and
a couple of phrases were clarified too.
2011-09-13 21:15:49 +01:00
Colin Guthrie
db704130d6 alsa: Tidy up argument descriptions 2011-09-07 21:16:03 +01:00
Maarten Bosmans
c5dca7cf2b More spelling fixes 2011-08-25 11:27:47 +01:00
Arun Raghavan
3179ed71c5 alsa: Fix bad function name
I've no idea how that slipped by.
2011-08-18 10:23:55 +05:30
Arun Raghavan
814c0371a4 alsa: Open iec958 device with NONAUDIO bit set in passthrough mode
This is required for E-AC3 streams, as well as to let receivers we're
sending non-PCM data (which avoids playing noise if the data is
incorrect for some reason).
2011-08-17 23:08:45 +05:30
Arun Raghavan
dde09c7fac alsa: Don't always suspend/unsuspend on sink-input removal
If the sink was already suspended, this avoids and assert when calling
suspend() again, and prevents an unnecessary unsuspend.
2011-08-17 13:33:50 +05:30
Arun Raghavan
e25e31fc80 alsa: Set SET_FORMATS flag when appropriate 2011-08-16 11:11:46 +05:30
Arun Raghavan
51fcee8902 alsa: Implement get/set_formats()
This implements the sink get_formats() and set_formats() API in
alsa-sink. Modules can use this to allow users to specify what formats
their receivers support.
2011-08-15 11:51:34 +05:30
Wang Xingchao
be3879e04e alsa: resets POLLOUT event
revents marked as POLLOUT|POLLERR|POLLWRNORM in "underrun" case that will
trigger unexpected log "ALSA woke us up to write new data to the device, but
there was acturally nothing to write...".

This patch avoids this log message.
2011-08-11 15:31:48 +02:00
Wang Xingchao
e564129b8f alsa: Update process_usec before going to sleep
During check_left_to_play/record(), the watermark may increase/decrease. So before
sleeping, update the actural sleep time based on latest watermark.
2011-08-11 15:30:27 +02: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
Colin Guthrie
6b1d9b8d6a alsa: Ensure that volumes are written to the h/w at startup.
If the device support SYNC_VOLUMES then we need to do an additional push
to get the actual change on to the h/w.
2011-08-11 10:36:11 +02:00
Colin Guthrie
c0470fd8c4 alsa: No need to go via sink/source to get the core. 2011-07-20 22:23:11 +01:00
Colin Guthrie
5c832a5b8a alsa-mixer: Detect and then drop pointless paths in the path set.
In order to try and avoid 'spamming' the user with port choices,
attempt to detect and remove any pointless paths in a path set. That is
any paths which are subsets of other paths.

This should solve a problem case with some USB Headsets which result in
two paths both involving the 'Speaker' element. When no 'Master' element
exists (which is quite common on head/handsets), then the first path
(analog-output) will contain the 'Speaker' in a way that completely fits
with in the use of the 'Speaker' element in the other path
(analog-output-speaker).
2011-07-20 22:23:11 +01:00
Colin Guthrie
6c6b50d6a8 alsa: Reinitialise the mixer on port change.
This allows us to flip from software to hardware volume control as the port's
mixer path dictates.
2011-07-20 22:23:10 +01:00
Colin Guthrie
a9cf320bc1 devices: Set certain sink/source flags automatically.
Some sink flags are really just a product of what callbacks
are set on the device. We still enforce a degree of sanity
that the flags match the callbacks set, but we also set the
flags automatically in our callback setter functions to
help ensure that a) people use them and b) flags & callbacks
are kept in sync.
2011-07-20 22:20:37 +01:00
Colin Guthrie
ded07a5898 devices: Use wrapper functions to set the *_volume and *_mute callbacks.
This is not currently useful but future commits will make further
changes concerning automatic setting of flags and event delivery
that makes this structure necessary.
2011-07-19 19:50:43 +01:00
Wu Fengguang
226ddb1d39 alsa-sink: fix mmap_write() work_done
mmap_write() work_done is wrongly initilized to TRUE. It ends up never
being FALSE. Fix it to reduce the costly update_smoother() calls.
2011-06-28 09:57:33 -07:00
Maarten Bosmans
dd9265ac78 Remove unnecessary #includes 2011-06-22 23:12:20 +01:00
Juho Hämäläinen
4eb513cbf4 alsa-mixer: select nearest alsa volume step in sync-volume mode 2011-06-22 22:45:27 +01:00
Colin Guthrie
dc6c272625 alsa-sink: Some trivial tidyups
Mostly typo fixes but also a change to make a function relating
to sink inputs use more generic variable names.
2011-06-22 21:53:19 +01:00
Arun Raghavan
4fb68b91ac core: Factor out passthrough checks into their own functions
Since we currently have two mechanisms to signal a passthrough
connection (non-PCM format or PA_SINK_INPUT_PASSTHROUGH flag), we move
all the related checks into functions and use those everywhere.

This makes things more consistent, and should we decide to get rid of
the flag, we only need to change pa_sink_input_*_is_passthrough()
accordingly.
2011-05-02 11:55:39 +05:30
Arun Raghavan
49b10ba694 alsa: Reconfigure sink sample rate for passthrough inputs
When a passthrough sink-input is added, we need to reconfigure the
sink's sample rate since no resampling occurs. We revert to the original
rate when the passthrough sink-input is removed.
2011-05-02 11:55:38 +05:30
Arun Raghavan
71ec9577cf sink: Remove PASSTHROUGH flag
This removes the passthrough flag from sinks since we will drop
exclusively passthrough sinks in favour of providing a list of formats
supported by each sink. We can still determine whether a sink is in
passthrough mode by checking if any non-PCM streams are attached to it.
2011-05-02 11:54:48 +05:30
Tanu Kaskinen
b14f0d79f6 alsa: Fix log output to inform about positive base volumes correctly.
This fix was done for _set_port_cb() already, but the first fix didn't fix
setup_mixer(). Now that's done too.
2011-04-04 13:34:18 +01: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
aefa94f052 alsa-sink: Don't assume we were able to enable hw-volume or sync-volume (v1.1)
This patch also disables mixer callback code if we do not have neither
HW-volume or HW-mute.
2011-01-15 13:26:21 +00:00
Jyri Sarha
98db3dffb6 alsa-sink: Fix double use of string 2011-01-15 13:26:07 +00:00