summaryrefslogtreecommitdiff
path: root/src/pulsecore/sink.c
AgeCommit message (Collapse)AuthorFilesLines
2016-06-22pulsecore: Don't allow unreferencing linked object.Juho Hämäläinen1-4/+2
Sink(-input) and source(-output) called unlink function when reference count dropped to zero. This would result in unlink hooks being called with an object having a reference count of zero, and this is not a situation we want modules to have to deal with. It is better to just remove the redundant unlinking code from sink(-input) and source(-output) and assert on reference count in unlink functions as well. It is expected that in well behaving code the owner of an object will always unlink the object before unreferencing. Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
2016-04-25don't move streams to devices that are going awayTanu Kaskinen1-3/+4
Before a device is unlinked, the unlink hook is fired, and it's possible that a routing module tries to move streams to the unlinked device in that hook, because it doesn't know that the device is being unlinked. Of course, the unlinking is obvious when the code is in an unlink hook callback, but it's possible that some other module does something in the unlink hook that in turn triggers some other hook, and it's this second hook where the routing module may get confused. This patch adds an "unlink_requested" flag that is set before the unlink hook is fired, and moving streams to a device with that flag set is prevented. This patch is motivated by seeing module-device-manager moving a stream to a sink that was being unlinked. It was a complex case where an alsa card was changing its profile, while an echo-cancel sink was connected to the old alsa sink. module-always-sink loaded a null sink in the middle of the profile change, and after a stream had been rescued to the null sink, module-device-manager decided to move it back to the old alsa sink that was being unlinked. That move made no sense, so I came up with this patch.
2015-11-17sink: Make early drain reporting propagate down to filtersArun Raghavan1-7/+31
The drain reporting improvements that were added to alsa-sink were only being applied to directly connected sink inputs. This patch makes the same logic also recurse down the filter hierarchy, so drains are acknowledged more accurately (and not late) even if there is a filter sink in between. Also does some minor reorganisation of the code and sprinkles in some comments as documentation.
2015-09-12sink, source: Do not dereference freed memory when freeing the next eventsFelipe Sateler1-1/+2
Coverity IDs: 1138197, 1138196
2015-06-12sink,source: Add a helper function to check whether this is a filterArun Raghavan1-1/+8
2015-05-27core: Work around -Wlogical-not-parentheses warningsPeter Meerwald1-1/+1
pulsecore/sink.c: In function 'pa_sink_put': pulsecore/sink.c:648:53: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses] pa_assert(!(s->flags & PA_SINK_DYNAMIC_LATENCY) == (s->thread_info.fixed_latency != 0)); ^ pulsecore/source.c: In function 'pa_source_put': pulsecore/source.c:599:55: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses] pa_assert(!(s->flags & PA_SOURCE_DYNAMIC_LATENCY) == (s->thread_info.fixed_latency != 0)); ^ rewrite expression to suppress warning: !(x & MASK) == (y != 0) <-> !(x & MASK) == !(y == 0) Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2015-03-31sink, source: Fix a volume change leakTanu Kaskinen1-0/+2
When a sink or source is freed, there may be pending volume changes that didn't get applied before the IO thread got torn down. Those pending changes need to be freed. The memory leak was reported here: http://thread.gmane.org/gmane.comp.audio.pulseaudio.general/23162/focus=23169 Reported-by: Alexander E. Patrakov <patrakov@gmail.com>
2015-01-14update FSF addresses to FSF web pageOndrej Holecek1-3/+1
FSF addresses used in PA sources are no longer valid and rpmlint generates numerous warnings during packaging because of this. This patch changes all FSF addresses to FSF web page according to the GPL how-to: https://www.gnu.org/licenses/gpl-howto.en.html Done automatically by sed-ing through sources.
2014-11-17core: Annotate variables only used within assert()s to be PA_UNUSEDPeter Meerwald1-1/+1
supresses a warning when compiling with NDEBUG: pulsecore/aupdate.c: In function 'pa_aupdate_read_end': pulsecore/aupdate.c:82:14: warning: variable 'n' set but not used [-Wunused-but-set-variable] unsigned n; pulsecore/sink-input.c: In function 'pa_sink_input_unlink': pulsecore/sink-input.c:648:27: warning: variable 'p' set but not used [-Wunused-but-set-variable] pa_source_output *o, *p = NULL; pulsecore/sink-input.c: In function 'find_filter_sink_input': pulsecore/sink-input.c:1523:14: warning: unused variable 'i' [-Wunused-variable] unsigned i = 0; pulsecore/sink-input.c: In function 'pa_sink_input_start_move': pulsecore/sink-input.c:1569:27: warning: variable 'p' set but not used [-Wunused-but-set-variable] pa_source_output *o, *p = NULL; CC pulsecore/libpulsecore_5.0_la-sink.lo pulsecore/sink.c: In function 'pa_sink_unlink': pulsecore/sink.c:673:24: warning: variable 'j' set but not used [-Wunused-but-set-variable] pa_sink_input *i, *j = NULL; pulsecore/source-output.c: In function 'find_filter_source_output': pulsecore/source-output.c:1179:9: warning: unused variable 'i' [-Wunused-variable] int i = 0; CC pulsecore/libpulsecore_5.0_la-source.lo pulsecore/source.c: In function 'pa_source_unlink': pulsecore/source.c:616:27: warning: variable 'j' set but not used [-Wunused-but-set-variable] pa_source_output *o, *j = NULL; Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2014-10-28Cleanup !! for boolPeter Meerwald1-1/+1
!!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-08-29sink/source: Fix restore of volume on devices without hw volumeDavid Henningsson1-1/+3
Module-device-restore sets reference_volume, but soft_volume remains at zero dB, so if a device only has soft_volume (i e no hw volume controls), its volume was not restored correctly. Reported-by: Richardo Salveti de Araujo <ricardo.salveti@canonical.com> Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2014-08-17sink-input, source-output: Assign to reference_ratio from a single placeTanu Kaskinen1-4/+7
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-06-05source, sink: Support weird sample ratesAlexander E. Patrakov1-18/+14
This fixes assertion failures that manifest themselves with cards that support only weird rates such as 37286Hz. Tested with snd-pcsp. Signed-off-by: Alexander E. Patrakov <patrakov@gmail.com> BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=48109
2014-05-02sink, source: Add hooks for mute changesTanu Kaskinen1-0/+1
2014-05-02sink, source: Add hooks for volume changesTanu Kaskinen1-0/+1
2014-05-02sink, source: Assign to s->muted from only one placeTanu Kaskinen1-16/+10
Forcing all mute changes to go through set_mute() makes it easier to check where the muted field is changed, and it also allows us to have only one place where notifications for changed mute are sent.
2014-05-02sink, source: Call set_mute() from mute_changed()Tanu Kaskinen1-7/+12
This refactoring reduces duplication, as mute_changed() used to do the same things as set_mute(). Other benefits are improved logging (set_mute() logs the mute change, mute_changed() used to not do that) and the soft mute state is kept up to date, because set_mute() sends the SET_MUTE message to the IO thread. The set_mute_in_progress flag is an extra precaution for preventing recursion in case a sink/source implementation's set_mute() callback causes mute_changed() to be called. Currently there are no such implementations, but I think that would be a valid thing to do, so some day there might be such implementation.
2014-05-02sink, source: Allow calling set_mute() during initializationTanu Kaskinen1-1/+3
Currently the alsa sink and source write directly to s->muted during initialization, but I think it's better to avoid direct writes, and use the set_mute() function instead, because that makes it easier to figure out where s->muted is modified. This patch prevents the set_mute() call from crashing in the state assertion.
2014-05-02sink, source: Return early from set_mute()Tanu Kaskinen1-4/+9
This avoids redundant set_mute() callback calls. Some logging was added too.
2014-05-02sink-input, source-output: Assign to volume from only one placeTanu Kaskinen1-39/+14
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-02sink, source: Assign to reference_volume from only one placeTanu Kaskinen1-4/+26
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-04-17Use pa_hashmap_remove_and_free() where appropriateTanu Kaskinen1-5/+2
2014-03-28sink/source: Initialize port before fixate hook (fixes volume/mute not saved)David Henningsson1-17/+10
In case a port has not yet been saved, which is e g often the case if a sink/source has only one port, reading volume/mute will be done without port, whereas writing volume/mute will be done with port. Work around this by setting a default port before the fixate hook, so module-device-restore can read volume/mute for the correct port. BugLink: https://bugs.launchpad.net/bugs/1289515 Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2014-03-14alsa: Use card description in default sink/source prefix when availablePete Beardmore1-5/+10
When given an explicit device.description in card_properties, prefer this information over other default prefixes (e.g. 'Built-in Audio') when constructing sink/source descriptions. For example, if I manually configure the card description to be "FooBar", I then expect that the sinks and created by the card also have "FooBar" in their description instead of generic "Built-in Audio".
2014-03-07Fix a few "it's -> its" typosAlexander E. Patrakov1-1/+1
2014-01-15sink, source: Remove useless attach/detach stuffTanu Kaskinen1-30/+0
The removed stuff wasn't used anywhere.
2013-12-15Add pa_sample_rate_valid()Tanu Kaskinen1-2/+1
I think this makes the code a bit nicer to read and write. This also reduces the chances of off-by-one errors when checking the bounds of sample rate values.
2013-11-22sink/source: When picking the initial ports, prefer ones that are not ↵Colin Guthrie1-1/+10
unavailable. This does for sinks/source ports what f434087e42b did for card profiles.
2013-09-17hashmap: Add the ability to free keysArun Raghavan1-5/+6
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-08-27sink, source: Fix error reporting style for rate updatesTanu Kaskinen1-12/+12
2013-08-27sink, source: Return early from pa_*_update_rate(), if there's no need to do ↵Tanu Kaskinen1-0/+3
anything
2013-08-23sink, source: Small readability improvementTanu Kaskinen1-2/+1
2013-08-23sink, source: Fix default and alternate rate assertionsTanu Kaskinen1-2/+2
2013-08-23sink, source: Don't care about default and alternate rate in passthrough modeTanu Kaskinen1-2/+2
In passthrough mode the device rate is set to match the stream rate, and the default and alternate rates are ignored.
2013-08-22sink, source: Reduce indentation level in *_update_rate()Tanu Kaskinen1-60/+60
2013-07-16sink: Add missing curly bracesTanu Kaskinen1-1/+2
The missing braces didn't cause any practical problems, but obviously the intention was to reset the chunk only if the memblock was non-NULL.
2013-07-04Remove pa_bool_t and replace it with bool.poljar (Damir Jelić)1-115/+115
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-06-24Whitespace cleanup: Remove all multiple newlinespoljar (Damir Jelić)1-1/+0
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-24Style fix: Remove new lines from opening bracketspoljar (Damir Jelić)1-6/+3
This patch replaces every occurrence of ')\n{' with ') {'. Command used for this: find . -type d \( -name ffmpeg \) -prune -o \ -regex '\(.*\.[hc]\|.*\.cc\)' \ -a -not -name core-util.c -a -not \ -name adrian-aec.c -a -not -name g711.c \ -exec sed -i -e '/)$/{N;s/)\n{$/) {/}' {} \; The excluded files are mirrored files from external sources.
2013-06-04core: Add an "internal" suspend causeArun Raghavan1-3/+8
This lets us suspend devices from within the core for short periods without having to overload one of the existing suspend causes. https://bugs.freedesktop.org/show_bug.cgi?id=64118
2013-04-10sink, source: Send notifications when flags changeTanu Kaskinen1-0/+3
The hooks aren't currently used, but for example, the D-Bus protocol could use them if it implemented flag change signals.
2013-04-10sink, source: Really set the fixed latency in ↵Tanu Kaskinen1-0/+5
set_fixed_latency_within_thread(), always. The old assumption seemed to be that if a sink or source has the DYNAMIC_LATENCY flag set, it can never change, so the fixed latency will always be zero. This assumption doesn't hold with filter sinks and sources that are moved around. This fixes a crash with two module-virtual-sink instances on top of each other, when the bottom one is moved from a sink without dynamic latency to a sink with dynamic latency. What happened was that first the bottom virtual sink "updated" (due to this bug nothing was actually updated) its fixed latency to match the master sink (zero fixed latency), and then the top virtual sink updated its fixed latency to match the master sink. The master sink was the bottom virtual sink, whose fixed latency should have been set to zero, but it was not, so the pa_sink_set_fixed_latency_within_thread() failed in the assertion "latency == 0".
2013-04-10sink, source: Propagate flag changes to filtersTanu Kaskinen1-8/+26
An example: let's say that there's an alsa sink and two filter sinks on top of each other: alsa-sink <- filter1 <- filter2 With the old code, if filter1 gets moved to another sink, and the new sink doesn't have the LATENCY and DYNAMIC_LATENCY flags set (unlike alsa-sink), filter1's flags are updated fine in the moving() callback, but filter2 is not notified at all about the flag changes. With this patch, the flag changes are propagated to filter2 too.
2013-03-28sink: Fix flag name typoTanu Kaskinen1-1/+1
2013-03-20core, alsa: Better drain reportingDavid Henningsson1-0/+26
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-02-16idxset: Use pa_free_cb_t instead of pa_free2_cb_tTanu Kaskinen1-3/+3
There were no users for the userdata pointer.
2013-02-16device-port: Remove pa_device_port_hashmap_free()Tanu Kaskinen1-2/+2
2013-02-16hashmap: Use pa_free_cb_t instead of pa_free2_cb_tTanu Kaskinen1-6/+1
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-15core: Move pa_mix() into new file mix.cPeter Meerwald1-0/+1
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>
2012-12-19Log the reason for every suspend/resume.Tanu Kaskinen1-2/+7
I was looking at a log that showed that a suspend happened (at a strange time), but the log didn't tell me why the suspend was done. This patch tries to make sure that that won't happen again.