Commit graph

221 commits

Author SHA1 Message Date
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
Arun Raghavan
8616f82a67 sink-input,source-output: Add an update_rate() function
This factors out the resampler updating code from finish_move() and
makes a separate function for use from other points.
2011-11-07 15:38:30 +05:30
Pierre-Louis Bossart
f0ec495938 sink,source: support for rate update
Avoid resampling or use integer resampling when supported by the
sinks/sources

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
2011-10-17 20:09:46 +05:30
Tanu Kaskinen
666261ece8 memblockq: Improve debuggability by storing a name and a sample spec.
These are not used for anything at this point, but this
makes it easy to add ad-hoc debug prints that show the
memblockq name and to convert between bytes and usecs.
2011-10-01 13:25:16 +01:00
Arun Raghavan
cae3235369 sink,source: Handle missing in the shared volume case
This makes sure that when we're traversing the device chain for sources
and sinks with shared volume, we handle the case that a sink-input or
source-output of one of these might be unlinked (while unloading a
module, for example).
2011-09-21 23:00:02 +05:30
Arun Raghavan
0dea35a818 sink-input: Ensure no volumes are applied for passthrough streams
This forces passthrough sink-inputs and their corresponding sinks to 0dB
gain so that the data is sent unaltered to the receiver.
2011-08-18 12:46:46 +05:30
Arun Raghavan
b08237b6c6 passthrough: We must not plug in a resampler on stream move 2011-08-18 12:45:58 +05:30
Arun Raghavan
358d92170a formats: Fix bad passsthrough check
Fixes breakage from commit adbdb6259b
2011-08-18 10:10:22 +05:30
Arun Raghavan
adbdb6259b formats: Use correct API to check for passthrough streams 2011-08-17 23:08:37 +05:30
Wang Xingchao
2f55da5baa sink-input: Avoid fake rewind in corked state
sink_input_request_rewind() does nothing if we are in the corked state.
Thus do not set the new state untill we have issued the rewind request.
2011-08-15 09:41:55 +01:00
Colin Guthrie
a8f20e8d95 sink-input: Drop redundant assert (PA_SINK_INPUT_IS_LINKED() checked already) 2011-08-12 20:31:52 +02:00
Maarten Bosmans
dd9265ac78 Remove unnecessary #includes 2011-06-22 23:12:20 +01:00
Colin Guthrie
ec4fa4c668 esound,streams: Fix some crashes.
After the rework to the add pa_sink_input_new_data_set_sink() (and
the source equiv) calling with a NULL sink object will hit an assert.

This caused crashes with the esd protocol and there was the potential
(albeit unlikely) for a crash when creating a sink input without any
sinks available (module-always-sink mitigates this risk but it's still
a potential crasher).
2011-06-22 22:45:28 +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
Colin Guthrie
51d53016f3 streams: Fix the actual resampler method shown in debug messages. 2011-06-02 11:44:21 +02:00
Arun Raghavan
117c714594 format: Fix channel map handling
Channel map handling in the extended API was broken. Thanks for Milos_SD
for pointing this out on IRC.
2011-05-20 19:21:02 +05:30
Colin Guthrie
e59fc6c6bc sink-input: Fix memory leak of proplist when sending format-changed events 2011-05-16 09:59:19 +01:00
Arun Raghavan
62f56a9f6b sink-input: Provide more information to client when format is lost
When the sink format changes and we kill the stream, clients need a way
to know (a) what device they should reconnect to, and (b) what the
stream running time was when the stream got killed (pa_stream_get_time()
won't work after the stream has been killed). This adds these two bits
of information in the event callback's proplist parameter.
2011-05-15 10:09:35 +05:30
Arun Raghavan
53091cc5f0 sink-input: Add a format-lost event
This event is emitted if the sink-input could not be moved to a new sink
because it doesn't support the format of the sink-input. Clients can
reconnect their stream with a different format if they wish or
gracefully exit.
2011-05-15 10:09:34 +05:30
Arun Raghavan
cb3dcb14f8 sink-input: Don't restore volume for passthrough streams 2011-05-15 10:09:34 +05:30
Arun Raghavan
a199bfb765 sink-input: Don't print an error if a passthrough connection fails
The assertion message is misleading, since the passthrough connection
can fail for reasons the client has no control over (like other sink
inputs being connected).
2011-05-15 10:09:06 +05:30
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
f94bcae6bd core: Suspend monitor when a sink enters passthrough mode
In most cases it is expected that clients cannot consume compressed
data from monitor sources, so we suspend the monitor source when the
sink goes into passthrough mode.

Eventually, when the extended API includes client notifications for
changed formats, we should emit a notification on the monitor so that
clients can decide what they want to do when this happens (disconnect or
consume the data anyway).
2011-05-02 11:55:38 +05:30
Arun Raghavan
658a9153f0 sink-input: Kill passthrough streams if moving to an unsupported sink
This will eventually be replaced by a hook to let clients know that the
stream has moved so that they can gracefully reconnect and renegotiate a
supported format.
2011-05-02 11:54:48 +05:30
Arun Raghavan
e418e49ecb format: Avoid some code duplication
We frequently need to free an idxset containing pa_format_infos, so
define an internal free function that can be used directly with this
(instead of defining it once-per-file).
2011-05-02 11:54:48 +05:30
Arun Raghavan
13229fb39e sink-input: Don't assert on bad formats
Handles bad format input more gracefully and returns an error instead.
2011-05-02 11:54:48 +05:30
Arun Raghavan
8ec0548f5f sink-input: Return NOTSUPPORTED if format negotiation fails
This is easier for clients to grok than INVALID.
2011-05-02 11:54:48 +05:30
Arun Raghavan
5d5523604f sink-input: Minor cleanups
Removes a couple of warnings and simplifies the assertion logic that
verifies format negotiation was successful.
2011-05-02 11:54:48 +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