Commit graph

164 commits

Author SHA1 Message Date
Stefan Kost
f6892b81ae pulsesink: code cleanups
Use g_slist_prepend as we don't care about the order. Check for list == NULL
instead of iterating the list to see if it is empty. Move ctx allocation down
to prevent leak in case of failure.
2010-09-08 14:19:34 +03:00
Wim Taymans
2148b2db0a pulsesink: simplify clock provide code
Don't leak the pulsesink element by having the clock keep a ref to the sink.
Create the clock only once in the constructor and use the baseaudiosink clock
cleanup code.
2010-09-07 19:03:33 +02:00
Stefan Kost
7fd77c07d5 pulsesink: move the context table init to _get_type phase
This seems to fix the invalid reads on context shutdown better, altough
I can't really explain.
2010-09-07 18:09:28 +03:00
Stefan Kost
f604e20499 pulse: allow setting stream properties
Add a "properties" property to the elements to allow setting extra stream
properties.

Fixes #537544
2010-09-07 14:20:21 +03:00
Stefan Kost
a313bc7524 pulsesink: don't free the context multiple times
Apparently the close function of the ring-buffer can be called multiple times.
2010-09-07 00:27:07 +03:00
Stefan Kost
fc73dd210d pulsesink: add since docs for new property. 2010-09-06 09:57:58 +03:00
Sebastian Dröge
37ee281d13 pulsesink: Fail gracefully if no threaded PA mainloop can be created
Fixes bug #628020.
2010-09-04 14:52:09 +02:00
Sebastian Dröge
998adeb974 pulsesink: Only include the server name in the context name if it's not NULL 2010-09-04 14:52:07 +02:00
Philippe Normand
7116fff3c5 pulsesink: Add "client" property to set the PA client name
Allows the application to modify the client name used to connect when
connecting to the PulseAudio daemon. Note however that updating the
property after the element reached the READY state will have no
effect until the next NULL->READY transition.

Fixes bug #627174.
2010-09-04 14:52:07 +02:00
Sebastian Dröge
03f2e81f69 pulsesink: Free the clock on state change failures too 2010-09-04 14:52:07 +02:00
Sebastian Dröge
bc5345bbd3 pulsesink: Free the GstPulseContext after usage 2010-09-04 14:52:06 +02:00
Philippe Normand
69a397c32f pulsesink: share the PA context between all clients with the same name
Avoid to create a new PA context for each new client by using a hash
table containing the list of ring-buffers and the shared PA context
for each client. Doing this will improve application memory usage in
the cases where multiple pipelines involving multiple pulsesink
elements are used.

Fixes bug #624338.
2010-09-04 14:52:06 +02:00
Philippe Normand
2c5976d355 pulsesink: clear the PA mainloop if baseaudiosink failed to open the ring_buffer
If the application requests a state-change and pulsesink fails to open
the ring_buffer device the mainloop attribute of the sink should be
cleaned up to avoid future state-change (NULL->READY) failures.
2010-09-04 14:52:06 +02:00
Tim-Philipp Müller
74b2af63fd pulse: fix printf format in some debugging messages 2010-08-09 00:36:36 +01:00
Philippe Normand
864a52d8aa pulsesink: use G_TYPE_DEFINE to define ring buffer type
The existing get_type() implementation is racy, and the
g_type_class_ref() workaround didn't actually work because
it was in the wrong function. Since class creation in GObject
is thread-safe these days (since 2.16), the class_ref workaround
is no longer needed and it is sufficient to ensure the _get_type()
function is thread-safe, which G_TYPE_DEFINE does.

https://bugzilla.gnome.org/show_bug.cgi?id=624338
2010-08-04 16:19:09 +01:00
Sebastian Dröge
f6240a4773 pulsesink: Post CLOCK-LOST/CLOCK-PROVIDE when going to/from READY
Otherwise the clocks are redistributed every time the pipeline
goes to PAUSED, which is quite expensive.
2010-08-04 15:21:26 +02:00
Tim-Philipp Müller
7055264e2e pulsesink: correctly check what version of gst-plugins-base we're compiling against
We need to check the gst-plugins-base version, not the core version
(even if both should be the same in any sane setup).
2010-07-26 18:18:02 +02:00
Sebastian Dröge
10424a4064 pulsesink: Only use gst_audio_clock_new() when compiling against newer base 2010-07-16 17:53:55 +02:00
Sebastian Dröge
9e92bd7b1a pulsesink: Post clock-provide/clock-lost when going to/from PAUSED
Also use gst_audio_clock_new_full() to prevent crashes when the
clock is used after the element was destroyed.
2010-07-16 17:45:38 +02:00
Sebastian Dröge
4113a1dad1 pulsesink: Don't request more shared memory than needed 2010-06-09 20:53:06 +02:00
Sebastian Dröge
bd5987a3d2 pulsesink: Flush shm buffer immediately if it's full 2010-06-09 16:22:27 +02:00
Sebastian Dröge
57813d469f pulsesink: Fix writing of buffers larger than segsize
Fixes bug #620540.
2010-06-09 16:21:55 +02:00
Sebastian Dröge
b78a27beb2 pulsesink: Fix playback if PA doesn't give us a large enough shared memory buffer 2010-06-09 15:46:59 +02:00
Tim-Philipp Müller
3486f49808 pulse: log message printf format fixes 2010-06-06 17:25:36 +01:00
Sebastian Dröge
dcae55852e ext: Don't use GST_DEBUG_FUNCPTR for GObject vfuncs 2010-06-06 18:00:22 +02:00
Sebastian Dröge
5072c47624 Revert "pulsesink: Add comments to remove the provide-clock message posting once we depend on base 0.10.30"
This reverts commit 8f3708f38a.

The baseaudiosink commit was reverted
2010-06-03 13:45:32 +02:00
Sebastian Dröge
8f3708f38a pulsesink: Add comments to remove the provide-clock message posting once we depend on base 0.10.30
baseaudiosink does all this for us now.
2010-06-03 10:28:08 +02:00
Pierre-Louis Bossart
66a76d1f65 pulsesink: optimize communication with PulseAudio using pa_stream_begin_write 2010-06-02 13:47:06 +02:00
Sebastian Dröge
f5057a9fae pulsesink: Post provide-clock message on the bus if the clock appears/disappears
Fixes bug #620277.
2010-06-02 10:52:56 +02:00
Sebastian Dröge
a8103facc5 pulse: Don't lock the mainloop in NULL 2010-05-17 17:17:01 +02:00
Sebastian Dröge
e69ba0f94f pulsesink: Allocate and free the custom clock in NULL<->READY 2010-05-06 13:57:01 +02:00
Sebastian Dröge
5332287e2d pulsesink: Create and free the PA mainloop in NULL->READY/READY->NULL
This fixes a race condition, when stopping the mainloop during finalization
is done from a mainloop callback.

Fixes bugs #614765 and #590662.
2010-05-06 13:51:59 +02:00
Stefan Kost
7cf9967e0b pulsesink: fix racy shutdown
Keep a ref of pulsesink for deferred mainloop invocation. Fixes #614765
2010-04-06 17:22:03 +02:00
Mark Nauwelaerts
5a082af3aa pulse: use #ifdef rather than #if conditionals 2010-03-18 12:44:53 +01:00
Philippe Normand
3ab666762f pulsesink: gst_pulsesink_get_mute: set result earlier.
In the cases where no buffer was process yet or the index is not
available, get_pulsesink_get_mute() would unconditionally return
FALSE.

https://bugzilla.gnome.org/show_bug.cgi?id=610337
2010-02-22 20:49:03 +01:00
Tim-Philipp Müller
3f2a803c48 pulsesink: add comment for translators for 'x by y' message
Fixes #609724.
2010-02-15 00:45:51 +00:00
Wim Taymans
55b5e2e3f3 pulsesink: avoid segfault when shutting down
when we are shutting down, we might still receive state updates from pulseaudio
but since we are unparented we should not do anything with the NULL parent
anymore.
2010-02-12 13:53:57 +01:00
Wim Taymans
0694be2a82 pulsesink: use acquired flag when checking valid state
Use the acquired field of the ringbuffer in get_time to know when we are in an
invalid state. We don't clear the rate flag when releasing the ringbuffer so
this values is not usable.

Avoids some error messages being posted because the pulseaudio connection is
down.
2009-11-18 17:27:19 +01:00
Wim Taymans
f85cf3e200 pulsesink: implement some more callbacks
Implement some more callbacks for debugging purposes.
2009-11-18 12:01:52 +01:00
Tim-Philipp Müller
2270d3359a pulsesink: printf format fix 2009-11-05 23:46:58 +00:00
Sebastian Dröge
3f541452c4 pulsesink: Only set the volume on stream connection if pulse >= 0.9.20 is available
In older versions the volume set during stream connection had
no defined sematic and usually it was a relative volume. What
was needed for our use case is an absolute volume though, otherwise
the volume will be always decreased on stream connection if it's
less than 100%.
Since pulse 0.9.20 that volume is always an absolute volume if
flat volumes are used and relative otherwise, which is the same
as for pa_context_set_sink_input_volume().

Relevant pulse changesets:
http://git.0pointer.de/?p=pulseaudio.git;a=commit;h=f27a50691c8fe45bac7dd6b21fac91a359def3a1
http://git.0pointer.de/?p=pulseaudio.git;a=commit;h=2501687579e359d5032a4d165b2ffc8f5b1b8ba6
2009-10-30 09:27:59 +01:00
Bastien Nocera
a1ac55c7a5 Fix the StreamVolume interface not being advertised
gst_pulsesink_interface_supported() was missing a check for it.

https://bugzilla.gnome.org/show_bug.cgi?id=598933
2009-10-19 15:36:20 +01:00
Lennart Poettering
e4d6a2aa2c pulse: never apply volume more than once
Generally decisions on the volume of the stream should be done inside of
PA, not inside of Gst. Only PA knows how volumes translate between
devices and s on.

This patch makes sure that all volumes set via the volume property are
only applied *once* to the underlying stream. After applying them the
client side will not store them anymore. This should make sure that
really only user-triggered volume changes are forwarded to server, but
the client never tries to save/restore the volume internally.

Fixes bug #595231.
2009-10-18 10:15:59 +02:00
Lennart Poettering
89b0c2fc4f pulse: use 'performer' as a fallback for 'artist' tag 2009-10-17 08:48:23 +02:00
Lennart Poettering
76c8ca4b00 pulse: when constructing a stream title from tag data make sure it is translatable 2009-10-17 08:48:23 +02:00
Lennart Poettering
d64200f46b pulse: make a few things smaller by making them bitfields 2009-10-17 08:48:21 +02:00
René Stadler
f9274226e8 pulsesink: set desired minreq value to segsize/latency-time
If we let the daemon decide freely by passing -1, we end up always getting 20ms.
We want to set this value because in some cases we want to select a higher
latency-time in order to save power.

Fixes #597601
2009-10-14 12:05:14 +02:00
René Stadler
ccddf0643d pulse: rename pa_buffer_attr variables
Makes it much easier to see what is going on and is a lot less error prone.
2009-10-02 23:21:02 +03:00
David Henningsson
bb787f1030 pulsesink: Don't dereference NULL pointers
pa_stream_get_timing_info() can return NULL.

Fixes bug #595220.
2009-09-15 10:05:51 +02:00
Wim Taymans
ccda761562 pulsesink: handle stream events
Handle stream events and request a PAUSE/PLAY state change from the application
when we receive a CORK/UNCORK event.
2009-09-14 16:05:30 +02:00
Sebastian Dröge
0c50816aaa pulsesink: Implement GstStreamVolume interface 2009-09-11 16:38:03 +02:00
Sebastian Dröge
7fb6ad6d4c pulsesink: Implement mute property 2009-09-11 16:38:03 +02:00
Wim Taymans
42ee5e22a2 pulsesink: remove ringbuffer reset compensation
Remove the code to deal with a ringbuffer reset as this code is now in the base
class.
Bump the -base requirement as we need the new baseaudiosink code to function
properly.
2009-09-09 16:25:06 +02:00
Stefan Kost
e82e16480d pulsesink: also guard reseting subscribe callback with ifdefs
It is conditionaly set, so do the same when unsetting.
2009-09-02 23:14:20 +03:00
Wim Taymans
abee4f1d64 pulsesink: don't use relative seeks
Don't use relative seeks, it's too hard to track where we are after a flush
etc.

fixes #593015
2009-08-25 17:33:04 +02:00
Tim-Philipp Müller
a3c393248a pulsesink: don't do logic within g_assert() statements
Otherwise that code will just be expanded to nothing when compiled
-DG_DISABLE_ASSERT (PS: why is mainloop_start() called in the init
function and not when changing state to READY?)
2009-08-02 11:49:17 +01:00
Wim Taymans
9c341347ba pulse: conditionally compile newer stuff
configured_sink/source_usec in the timing_info is only since 0.9.11 so
conditionally compile this information.

fixes #590038
2009-07-29 12:13:20 +02:00
Wim Taymans
2308999849 pulsesink: avoid using ivalid stream indexes
when we get an invalid stream index from pulse because we were just starting,
avoid using it for getting and setting the volume.

Fixes #589365
2009-07-27 11:51:39 +02:00
Colin Guthrie
4efca7b68e pulsesink: Fix a couple error messages that mentioned incorrect function names.
Fixes #589459.
2009-07-23 10:54:45 +01:00
Wim Taymans
b3c55f5ce5 pulsesink: set some values to their defaults
Set the minreq and maxlength buffer attributes to -1 to let puleseaudio select a
sensible value.
2009-07-20 19:09:19 +02:00
Wim Taymans
8bfd80e5a2 pulsesink: don't wait for posted message
We can't wait for the ENTER/LEAVE messages to be be posted because the base
class sometimes calls the start method with the object lock, which would block
the message posting.
Instead, just assume that the message will be posted soon and continue. We'll
have to fix this in the base class.
2009-07-20 19:07:19 +02:00
Wim Taymans
e914f5254a pulsesink: use relative seeks
Use relative seeks because I was told that absolute seeks don't work.
2009-07-20 19:07:19 +02:00
Olivier Crête
dbb8a331de pulsesink: Emit stream-status leave message
Fixes #587695
2009-07-14 18:52:15 +02:00
Olivier Crête
b2e9f0a7c9 pulsesink: Emit stream-status enter message
Emit stream-status messages for the pulse thread.
Don't use our own GCond for signaling but simply use the pulse mainloop
mechanisms for synchronisation.
See #587695
2009-07-14 18:44:21 +02:00
Wim Taymans
b0643b745a pulsesink: debug the latency update values 2009-07-14 18:15:59 +02:00
Wim Taymans
ab3bed81a5 pulsesink: add 24bit sample formats
Add check for pulseaudio 0.9.15 and enable 24bits samples in that case.
2009-07-14 16:14:34 +02:00
Stefan Kost
6d0007372b pulsesink: include "1.0=100%" in volume and change upper limit
Upper volume limmit was 1000. That appear unneceasrily high. It would also cause
sever distortion if accidentialy used. Now its 10 (~ +15db) which is also in
sync with volume and playbin2.
2009-06-30 14:53:25 +03:00
Wim Taymans
1e98580204 pulsesink: clear ringbuffer when asked to
Since we map the ringbuffer to the pulseaudio internal ringbuffer, flush the
pulseaudio buffer when we are asked to clear the ringbuffer.
This avoids some leftover audio after a seek.
2009-06-29 15:21:37 +02:00
Wim Taymans
b8e88710e1 pulseink: don't leak device_description
don't leak the device_description.
some cleanups.
2009-06-19 16:00:51 +02:00
Tim-Philipp Müller
dea67f3d96 pulsesink: ref custom ring buffer class and type in class_init
Hack around thread-safety issues in GObject and our racy _get_type()
functions (we could easily fix the _get_type() functions, but we still
need to hack around the GObject class races until we require a newer
GLib version, I think).
2009-06-15 15:51:32 +01:00
Wim Taymans
0bd984c52f pulsesink: handle border cases in resampler 2009-06-11 19:18:52 +02:00
Stefan Kost
85ba1b3e6a pulsesink: only notify if all checks passed
Replace goto done: with return, as those are checks when we don't want to flag a
pending notify.
2009-06-04 17:43:15 +03:00
Stefan Kost
44956f98d7 pulsesink: check pointer before accessing
Move existing check a few lines up, so that we check before accessing fields.
2009-06-03 18:23:53 +03:00
Stefan Kost
f77650c024 pulsesink: rename gst_pulse_sink_get_time to gst_pulsesink_get_time
Rename internal method for consistency.
2009-06-03 18:21:12 +03:00
Stefan Kost
2af7977e1d pulsesink: use values from pa_stream_get_buffer_attr()
We were putting the requested values back into ringbuffer spec, instead of
using the queried values.
2009-06-03 18:19:22 +03:00
Jan Schmidt
cf584105c6 pulsesink: Convert an erroneous assertion
Occasionally, we get a change callback for an old stream, triggering
the assertion unnecessarily. Just ignore such callbacks.
2009-05-21 21:16:14 +01:00
Olivier Crête
ca25de8f77 pulse: Print a warning on under/overflows 2009-05-21 22:05:11 +02:00
Wim Taymans
28afc6e591 pulsesink: make sure we always signal waiters
Always signal the waiters in the async callbacks. Especially for the volume
callbacks since this might cause deadlocks.
2009-04-30 10:32:39 +02:00
Edward Hervey
4a9e80720a Remove unused variables in _class_init
Detected by LLVM's CLang static analyzer
2009-04-18 18:51:27 +02:00
Wim Taymans
c052906590 pulsesink: fix sample offset calculation again 2009-04-16 22:51:54 +02:00
Wim Taymans
776b0ae8cb pulsesink: handle NULL timing info
Don't crash when the timing info is not yet available.
2009-04-10 21:32:54 +02:00
Stefan Kost
b3d66d5e8d pulse: make it work on 0.9.12
First we ignore request to fill the ringbuffer which are less then a segment.
The small request where causing stutter.
Then we disable flushing the stream when running against pa 0.9.12 as this
triggers an assertiong in the sound server and terminates it. It does not happen
with 0.9.10 and 0.9.14.
2009-04-10 21:42:13 +03:00
Wim Taymans
963b343548 pulsesink: handle server disconnect in get_time
When the server is disconnected or when we are shut down, make our clock return
an invalid time instead of erroring out.
2009-04-10 14:18:48 +02:00
Wim Taymans
20a6908dfd pulsesink: bps is signed int to avoid overflow
Keep bps as gint instead of guint because we will be doing signed math with it
later on and we don't want weird results.
2009-04-10 12:01:27 +02:00
Wim Taymans
7d438518fb pulsesink: check for a stream
Don't try to change the stream volume (and other things) when we don't have a
stream yet. Just store the values for later.
2009-04-09 23:43:58 +02:00
Wim Taymans
ae83945349 pulsesink: fix compilation for newer pulseaudio 2009-04-09 18:07:38 +02:00
Wim Taymans
8d58de128d pulsesink: uncork fixes and use prebuf = 0
We can use prebuf = 0 to instruct pulse to not pause the stream on underflows.
This way we can remove the underflow callback. We however have to manually
uncork the stream now when we have no available space in the buffer or when we
are writing too far away from the current read_index.
2009-04-09 17:26:21 +02:00
Wim Taymans
d849340e64 pulsesink: handle write errors 2009-04-09 17:26:20 +02:00
Wim Taymans
81c5fb9e48 pulsesink: write silence on underflow
Start filling up the buffer with empty samples when an underflow happens. We
need to do this to keep pulseaudio reporting the right time for us.
2009-04-09 17:26:20 +02:00
Wim Taymans
2e2f1d73ca pulsesink: handle pull-based scheduling
Use the default basesink methods for implementing pull based scheduling, it
works fine for us.
2009-04-09 17:26:20 +02:00
Wim Taymans
8855ed90c0 pulsesink: add beginnings of pull-based scheduling 2009-04-09 17:26:20 +02:00
Wim Taymans
236baa5a13 pulsesink: keep track of clock reset
when we switch streams, the clock will reset to 0. Make sure that the provided
clock doesn't get stuck when this happens by keeping an initial offset. We also
need to make sure that we subtract this offset in samples when writing to the
ringbuffer.
2009-04-09 17:26:20 +02:00
Wim Taymans
6bc6cafcc6 pulsesink: rewrite pulsesink
Derive from BaseAudioSink and implement our custom ringbuffer that maps to the
internal pulseaudio ringbuffer.
2009-04-09 17:26:20 +02:00
Wim Taymans
39f59ea456 pulsesink: clean up the state change function
Make the state change function a bit more readable and only pause after the
parent had a change to pause first.
2009-03-23 11:22:08 +01:00
Jan Schmidt
b39d090a49 pulsesink: Track the corked/uncorked state ourselves
Use an instance variable to track whether the stream is corked or not,
instead of using PA API that was only introduced in 0.9.11
2009-03-20 13:27:59 +00:00
Jan Schmidt
120e6bfc5c pulse: Make sure the stream is uncorked in the write function
If the caps changes, the sink is reset without transitioning through
a PAUSED->PLAYING state change, resulting in a corked stream. This avoids
the problem by checking that the stream is uncorked when writing samples
to it.
2009-03-20 12:11:06 +00:00
Jan Schmidt
608d13d462 pulsesink: Wait until there is enough room to write an entire segment
When trying to write out a segment, wait until there is enough free space
for the entire segment. This helps to reduce ripple in the clock reporting,
where the app might query the playback position while only half a segment
has been written (and is therefore reported by _delay(), even though
the ring buffer has not yet been advanced)
2009-03-13 15:40:50 +00:00
Mark Nauwelaerts
7756d37531 pulsesink: Issue property change notification in streaming thread,
rather than PA thread.

pa_threaded_mainloop_lock() (a.o.) and by extension get_property should
not be done from a PA thread, but the latter may occur as a result of a
property change notification.  Fixes #571204 (though current situation
not ideal, e.g. post message rather than signal).
2009-02-13 18:04:41 +01:00
Jan Schmidt
9795e95f39 Fix compile error in the last commit 2009-01-28 21:40:11 +00:00
Jan Schmidt
0037635bf2 Rewrite the pulse plugin, conditionally enabling new behaviour with
newer pulseaudio.

Fixes: #567794

* Hook pulsesink's volume property up with the stream volume -- not the
  sink volume in PA.

* Read the device description directly from the sink instead of going
  via the mixer.

* Properly implement _reset() methods for both sink and source to avoid
  deadlocks when shutting down a pipeline.

* Replace all simple pa_threaded_mainloop_wait() by proper loops to
  guarantee that we wait for the right event in case multiple events are
  fired.  While this is not strictly necessary in many cases it
  certainly is more correct and makes me sleep better at night.

* Replace CHECK_DEAD_GOTO macros with proper functions

* Extend the number of supported channels to 32 since that is the actual
  limit in PA.

* Get rid of _dispose() methods since we don't need them.

* Increase the volume property upper limit of the sink to 1000.

* Reset function pointers after we disconnect a stream/context. Better
  fix for bug 556986.

* Reset the state of the element properly if open/prepare fails

* Cork the PA stream when the pipeline is paused. This allows the PA
* daemon to
  close audio device on pause and thus save a bit of power.

* Set PA stream properties based on GST tags such as GST_TAG_TITLE,
  GST_TAG_ARTIST, and so on.

Signed-off-by: Lennart Poettering <lennart@poettering.net>
2009-01-28 20:34:40 +00:00