GNOME Bugzilla – Bug 678306
decodebin: improve element instance handling
Last modified: 2018-05-05 15:41:15 UTC
decodebin2 behaviour upon a "channel switch" (like switching in a chained ogg) is currently as follows: * new pads are added, for which new chains with new element (codec) instances are created * old pads are eos-ed and removed, upon which the old chains are 'hidden'. This only entails a partial cleanup, and in particular the old element instances are kept around even in PLAYING state. At least 2 improvements/fixes seem to apply here: * arrange for the old element instances to be taken down to e.g. READY * put the old elements in some cached-element list so they can be re-used next time some such element is needed in a chain (like for example a subsequent channel switch). [note that keeping the old ones around in READY allows to re-use some global setup performed when going to READY]
(In reply to comment #0) > [...] > At least 2 improvements/fixes seem to apply here: > * arrange for the old element instances to be taken down to e.g. READY > * put the old elements in some cached-element list so they can be re-used next > time some such element is needed in a chain (like for example a subsequent > channel switch). > > [note that keeping the old ones around in READY allows to re-use some global > setup performed when going to READY] For this see e2a038acee2969ed0b558093fa1c8b7422073e40 in base too (which was reverted later because it wasn't optimal). Switching elements to READY is not trivial here, especially if you want to re-use the elements for the next group already. (But you can switch them to READY from the streaming thread(s) of the next group as far as I see it) Would you keep elements cached for the whole lifetime of decodebin or would they be removed once the new group is exposed and they're not needed?
It would not be the intention here to re-use these for the (already setup) next group (but they could be for the next one that comes along). I suppose they would remain cached for the lifetime of decodebin, as it seems to be the case also now. Also, what makes switching to READY not trivial here (dead-locking or ???) ?
Created attachment 294698 [details] [review] free old groups when switching groups A patch to free old groups with one switch's time delay. See https://bugzilla.gnome.org/show_bug.cgi?id=731404 for the bug which led to this.
commit 6ab711f3f102da0fa8d4f9feabfe7f3f4e8a0d6e Author: Vincent Penquerc'h <vincent.penquerch@collabora.co.uk> Date: Fri Jan 16 15:21:14 2015 +0000 decodebin: free old groups when switching groups Old groups are freed with one switch's delay when switching groups. They're freed in a scratch thread to avoid delaying the switch.
That was commited.