Previously, when a sample is "committed" from an upload stream,
its reference count is set to 1. This is problematic if,
when the sample is committed for a second time, there are
streams playing the sample as the reference count will go out
of sync.
The problem can be easily triggered, especially with longer samples:
pactl upload-sample a-long-sample.ogg
pactl play-sample a-long-sample
pactl play-sample a-long-sample
pactl upload-sample a-long-sample.ogg # while playing
When the first stream finishes playing, it will free the sample,
which can cause problems e.g. for the second stream playing the
sample at that very moment.
Fix that by decoupling the buffer from the sample and making
the buffer reference counted. And remove the reference counting
from the samples as it is no longer needed.
Futhermore, previously, the reference counts were ignored
when the removal of a sample was requested. That is fixed
as well.
The previous issue can be triggered easily as well:
pactl upload-sample a-long-sample.ogg
pactl play-sample a-long-sample
pactl remove-sample a-long-sample # while playing
Fixes#1953