Commit graph

199 commits

Author SHA1 Message Date
Peter Meerwald
f390e6e974 Cleanup !! for bool
!!x makes no sense if x is bool (this is a leftover from the
convertion pa_bool_t -> bool, d806b197)

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2014-10-28 17:36:22 +01:00
Tanu Kaskinen
f480fb38a7 sink-input, source-output: Assign to reference_ratio from a single place
This makes it easy to log a message every time the reference ratio
changes. I also need to add a hook for reference ratio changes, but
that need will go away if the stream relative volume controls will be
created by the core in the future.
2014-08-17 08:17:59 +03:00
Tanu Kaskinen
c12aa68e02 sink-input, source-output: Add hooks for mute changes 2014-05-02 16:00:56 +03:00
Tanu Kaskinen
415dd6306a sink-input, source-output: Add hooks for volume changes 2014-05-02 16:00:56 +03:00
Tanu Kaskinen
ef4ae785aa sink-input, source-output: Remove redundant get_mute() functions
The functions just return the muted value. Callers can as well read
the struct field directly, it's simpler that way.
2014-05-02 16:00:56 +03:00
Tanu Kaskinen
080bdf1b6b sink-input, source-output: Add logging to set_mute() 2014-05-02 15:50:15 +03:00
Tanu Kaskinen
7ac850d3b7 sink-input, source-output: Assign to volume from only one place
Forcing all volume changes to go through set_volume_direct() makes
it easier to check where the stream volume is changed, and it also
allows us to have only one place where notifications for changed
volume are sent.
2014-05-02 15:50:15 +03:00
Tanu Kaskinen
fb70fa22c3 sink, source: Assign to reference_volume from only one place
Forcing all reference volume changes to go through
set_reference_volume_direct() makes it easier to check where the
reference volume is changed, and it also allows us to have only one
place where notifications for changed reference volume are sent.
2014-05-02 15:50:15 +03:00
Tanu Kaskinen
cd2db42a6a sink-input, source-output: Fix mute saving
"i->save_muted = i->save_muted || mute" makes no sense. The intention
was most likely to use "save" instead of "mute" in the assignment.
This line originates from reverting the volume ramping code, commit
8401572fd5.

The idea of "i->save_muted |= save" is that even if the mute state
doesn't change, save_muted should still be updated, but only if the
transition is from "don't save" to "save".

Changing "!i->muted == !mute" to "mute == i->muted" is cosmetic only.
The rationale behind the old form was probably that when we still had
pa_bool_t, booleans could in theory be defined as int, so comparing
the values without the ! operator was not entirely safe. That's
unnecessary now that we use the standard bool type, which can only
have values 0 or 1.
2014-04-26 11:30:01 +03:00
Tanu Kaskinen
eca082a93f Use pa_hashmap_remove_and_free() where appropriate 2014-04-17 10:06:23 +03:00
Peter Meerwald
679eed5340 doc: Fix a couple of 'to to' typos
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2014-03-06 15:47:33 +01:00
David Henningsson
732348c9d9 sink-input/source-output: Fix LFE remixing suddenly enabled
Steps to reproduce:
 1) Leave LFE remixing disabled (the default)
 2) Start playback of stereo material on e g 5.1 surround, notice nothing in LFE
 3) Now change profile to e g 4.0 surround and then back to 5.1 surround
 4) Notice that LFE channel is now remixed

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2014-02-28 13:42:45 +01:00
Tanu Kaskinen
ee1a964994 sink-input, source-output: Don't crash if format negotiation fails
A segfault was reported on this line:

pa_return_val_if_fail(PA_SINK_IS_LINKED(pa_sink_get_state(data->sink)), -PA_ERR_BADSTATE);

After expanding the pa_sink_get_state() macro, the line looks like
this:

pa_return_val_if_fail(PA_SINK_IS_LINKED(data->sink->state), -PA_ERR_BADSTATE);

So data->sink was apparently NULL. That could happen if we try to fall
back to the default sink, but format negotiation fails.

This bug was introduced in commit
71816ecb7f.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=74646
2014-02-14 16:04:32 +02:00
Tanu Kaskinen
f41650a550 sink-input, source-output: Interpret missing PCM parameters in format info as a request to decide those parameters at the server end
The "fix flags" (PA_SINK_INPUT_FIX_FORMAT etc.) don't work properly
with the pa_stream_new_extended() interface. This patch fixes it so
that the same effect can be achieved by leaving some of the PCM
parameters unspecified in format info objects. Also, when converting
a sample spec to a format info when using the old pa_stream_new()
interface, the "fix flags" are taken into account in that conversion.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=68952
2014-01-08 21:26:40 +02:00
Tanu Kaskinen
71816ecb7f sink-input, source-output: Do routing related validity checks immediately after routing
It's more logical that way.
2014-01-08 21:26:40 +02:00
Tanu Kaskinen
5d2d9e5700 sink-input: Fix volume_factor_sink initialization
Source outputs handle volume_factor_source in a bit different way,
which is why this bug doesn't affect source outputs.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=72879
2013-12-20 16:10:53 +02:00
Peter Meerwald
e8ea0b8a79 core: Use after free in pa_sink_input_new_data_set_formats() and pa_source_output_new_data_set_formats()
intention is to free old data_req->formats before assigning
new formats, discovered by coverity

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2013-12-20 12:55:17 +01:00
Tanu Kaskinen
49dd827373 sink-input, source-output: Don't assume that proplist has been initialized in free()
It's bad form to assume in free() that any member of the struct has
been initialized. I ran into problems with this when I reordered
things in pa_sink_input_new() and pa_source_output_new().
2013-11-14 15:17:17 +02:00
Arun Raghavan
6825df8cec hashmap: Add the ability to free keys
Since the hashmap stores a pointer to the key provided at pa_hashmap_put()
time, it make sense to allow the hashmap to be given ownership of the key and
have it free it at pa_hashmap_remove/free time.

To do this cleanly, we now provide the key and value free functions at hashmap
creation time with a pa_hashmap_new_full. With this, we do away with the free
function that was provided at remove/free time for freeing the value.
2013-09-17 18:01:22 +05:30
Tanu Kaskinen
441a5a422c sink, source: Fix error reporting style for rate updates 2013-08-27 15:34:33 +03:00
Arun Raghavan
f8f0d4c26b sink-input: Don't assert when removing non-existent volume factor
This makes it easier for users of this API to add/updated a volume
factor by doing a _remove_volume_factor() followed by an
add_volume_factor(), rather than having to either remember whether this
is the first set operation or have an API to query whether a factor has
already been set.
2013-08-08 11:58:22 +05:30
Tanu Kaskinen
8e0e2617fb sink-input: Keep reference ratio up-to-date
The reference ratio should always be kept up-to-date. If the reference
ratio is not updated when the input volume changes, the stale
reference ratio ends up being used as the new input volume when the
input is moved.
2013-07-09 17:40:38 +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
poljar (Damir Jelić)
97da92d894 Whitespace cleanup: Remove all multiple newlines
This patch removes all occurrences of double and triple
newlines.

Command used for this:
find .  -type d \( -name ffmpeg \) -prune -o \
        -regex '\(.*\.[hc]\|.*\.cc\)' \
        -a -not -name 'adrian-aec.*' -a -not \
        -name reserve.c -a -not -name 'rtkit.*' \
        -exec sed -i -e '/^$/{N;s/^\n$//}' {} \;

Two passes were needed to remove triple newlines.
The excluded files are mirrored files from external sources.
2013-06-24 16:56:24 +03:00
Arun Raghavan
2c1dceeb58 sink-input: Log format negotiation better
This provides more details on format negotiation success and failure to
make debugging problems easier.
2013-06-15 09:42:57 +05:30
Arun Raghavan
ae9f6dc356 sink-input,source-output: Deal with FIX* flags and extended API
The sample spec fixup when FIX* flags are set was not being propagated
to the pa_format_info, causing the two to be out of sync when FIX* was
used.
2013-05-22 17:20:21 +05:30
David Henningsson
c0a4f81123 sink-input/source-output: Don't set save_volume if volume is not writable
This fixes a later assertion failure in module-stream-restore.

Buglink: https://bugs.launchpad.net/bugs/896602
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2013-05-20 15:01:43 +02:00
David Henningsson
2135b2b34f sink-input: Make sure the process_underrun callback is cleared
Otherwise sink unlinking could cause a segfault.

Reported-by: heftig
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2013-03-21 18:25:09 +01:00
David Henningsson
e87eb85474 core, alsa: Better drain reporting
Previously, a drain request was acknowledged up to two hw buffers
too late, causing unnecessary delays.

This implements a new chain of events called process_underrun
which triggers exactly when the sink input has finished playing,
so the drain can be acknowledged quicker.

It could later be improved to give better underrun reporting to
clients too.

Tested-by: Dmitri Paduchikh <dpaduchikh@gmail.com>
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2013-03-20 11:55:42 +01:00
Tanu Kaskinen
061878b5a4 idxset: Use pa_free_cb_t instead of pa_free2_cb_t
There were no users for the userdata pointer.
2013-02-16 01:15:27 +02:00
Tanu Kaskinen
8872c238ba hashmap: Use pa_free_cb_t instead of pa_free2_cb_t
The previous patch removed module-gconf's dependency on the userdata
pointer of the free callback, and that was the only place where the
userdata pointer of pa_free2_cb_t was used, so now there's no need for
pa_free2_cb_t in pa_hashmap_free(). Using pa_free_cb_t instead allows
removing a significant amount of repetitive code.
2013-02-16 01:12:21 +02:00
Peter Meerwald
95b64804ab core: Move pa_mix() into new file mix.c
idea is to allow optimized code path (similar to volume code)
and rework/specialize mixing cases to enable runtime performance improvements

no functionality changes in this patch

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2013-02-15 21:33:07 +02:00
Flavio Ceolin
9e2b6a0b5c sink-input: New volume_factor system
Implement setting of more than one volume factor.  The
real value of the volume_factor will be the multiplication of these
values.
2012-12-19 12:31:47 +02:00
Arun Raghavan
3effdfc16f sink-input, source-output: Check rate update success for passthrough
This makes sure we don't try to plug in a passthrough stream if the
final sink/source sample spec doesn't match what we want. In the future,
we might want to change rate updates to try a full sample spec update
for passthrough streams.

https://bugs.freedesktop.org/show_bug.cgi?id=50951
2012-11-19 13:10:36 +05:30
Arun Raghavan
cd1102cce0 sink, source: Prevent unnecessary rate update attempts
We don't need to try a rate update if the desired sample rate is the
same as the one the sink or source is already using.
2012-11-16 23:16:04 +05:30
Arun Raghavan
eeab4efa98 Revert "core: adjust playing_for and underrun_for at rewind"
This reverts commit 5bc6cadcb2.

I wasn't meaning to push this out - just merged for review / testing.
2012-11-03 10:29:20 +01:00
Uoti Urpala
5bc6cadcb2 core: adjust playing_for and underrun_for at rewind
A rewind may erase data that sink_input counted in playing_for or
underrun_for earlier. Add code adjusting those values after a rewind.

One visible symptom of this bug was problems recovering from an
underrun. When a client calls pa_stream_write() with a large block of
memory, the function can split that into smaller pieces before sending
it to the server. When receiving new data for a stream that had
silence queued due to underrun, the server would do a rewind to
replace the queued-but-not-played silence with the new data. Because
of the bug, this rewind itself would not change underrun_for. It's
possible for multiple rewinds to be done without filling the sink
buffer in between (which is what would eventually reset underrun_for).
In this case, the server rapidly processing the split packets would
rewind the stream for _each_ of them (as underrun_for would stay set),
erasing valid audio as a result.
2012-10-31 15:27:15 +05:30
Flavio Ceolin
2c8aa18b1d sink-input: Remove redundant check in pa_sink_input_request_rewind().
This bug is part of the problems spotted by Tanu.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=53923
2012-09-16 09:47:43 +03:00
Uoti Urpala
6031546f66 sink-input: Fix underrun_for calculation when resampling.
pa_sink_input_seek() calculates output lenth (slength) and
corresponding input length (ilength). During an underrun, the function
generates slength bytes of silence and adds ilength to the
underrun_for value. However, the ilength value may be shortened to
match resampler limits, and there's no corresponding adjustment to
slength. Thus, the length of the generated silence is longer than
resampler output would have been, and underrun_for should be increased
by more than the limited ilength. This error makes the user-visible
since_underrun field in struct pa_timing_info too small. Fix by using
the original value calculated before limiting in this case.
2012-08-30 12:00:35 +03:00
Tanu Kaskinen
352130f850 sink-input: Add a comment in pa_sink_input_request_rewind(). 2012-08-29 08:25:15 +03:00
Tanu Kaskinen
056bb3a39c sink-input: Fix comment: s/push/peek/ 2012-08-29 08:25:15 +03:00
Arun Raghavan
8f540c6e76 sink-input,source-output: Avoid unneccessary rate updates
This makes sure we only call sink/source update_rate() if the stream
being woken up has a sample spec that doesn't match the corresponding
device'.

https://bugs.freedesktop.org/show_bug.cgi?id=49875
2012-05-14 12:29:13 +05:30
David Henningsson
b7fab75fdd sink-input/source-output: Prevent filter sink/source cycles
Misbehaving clients can try to set a filter sink to output to
itself, leading to crashes later on. This patch protects us from that.

Thanks to Roman Beslik for testing and finding an error in the first
version of this patch.

Tested-by: Roman Beslik <rabeslik@gmail.com>
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=44397
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2012-03-28 13:19:47 +02:00
Arun Raghavan
a0706e7c84 format: Allow format->sample spec conversion for compressed formats
This allows clients to get a "fake" sample space for compressed formats
that we can support. This should make size/time conversion for things
like calculating buffer attributes simpler.
2012-03-05 20:30:33 +05:30
Arun Raghavan
c60f698f1e format: Expose pa_format_info<->pa_sample_spec conversion functions
These utility functions could be handy to clients.
pa_format_info_to_sample_spec_fake() isn't made public, but the return
value is changed to keep in sync with pa_format_info_to_sample_spec().
2012-03-05 20:00:31 +05:30
Arun Raghavan
0521db6cf7 sink-input,source-output: Handle devices going away in unlink hooks
If a *_UNLINK_POST hook causes a sink-input/source-output's sink/source
to go away, the subsequent attempt to update the sink/source status will
cause an assert. We deal with this by checking the sink/source status
before trying to update it.
2012-02-09 16:55:48 +05:30
Peter Meerwald
e33aeaa7fb core: fix typo in logging 2011-12-20 10:22:01 +05:30
Peter Meerwald
638b0264e0 core: sample_spec.rate is in Hz, not kHz; change logging output 2011-12-20 10:21:39 +05:30
Arun Raghavan
efbfe5fecb core: Make debugging a bit simpler
This takes out a bunch of commented debug prints and puts them in
defines. Makes it easier to turn them all on/off at a single point.
2011-11-10 12:43:09 +05:30
Arun Raghavan
a813e85503 sink,source: Update sample rate if possible on stream uncork
If a stream is being uncorked and no other stream is running, we try to
update the sink/source sample rate to match it and avoid resampling.
2011-11-07 15:38:31 +05:30