After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 590768 - GstPulseSrc should allow swapping the device used by the stream
GstPulseSrc should allow swapping the device used by the stream
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other Linux
: Normal enhancement
: 1.1.4
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2009-08-04 18:41 UTC by Jonathan Tellier
Modified: 2013-08-22 19:17 UTC
See Also:
GNOME target: ---
GNOME version: 2.25/2.26


Attachments
Proposed patch (2.78 KB, patch)
2009-08-04 18:52 UTC, Jonathan Tellier
none Details | Review
Corrected patch (2.90 KB, patch)
2009-08-04 19:50 UTC, Jonathan Tellier
none Details | Review
Corrected patch (3.27 KB, patch)
2009-08-05 15:33 UTC, Jonathan Tellier
none Details | Review
Fixed patch (3.43 KB, patch)
2009-08-13 14:06 UTC, Jonathan Tellier
needs-work Details | Review
pulsesrc: Implement changing the device while playing (2.12 KB, patch)
2013-08-21 18:45 UTC, Olivier Crête
committed Details | Review
pulsesrc: De-duplicate code to get the current source output info (4.51 KB, patch)
2013-08-21 18:45 UTC, Olivier Crête
committed Details | Review
pulsesrc: Add property to find out the device currently in use (5.58 KB, patch)
2013-08-21 18:45 UTC, Olivier Crête
committed Details | Review

Description Jonathan Tellier 2009-08-04 18:41:47 UTC
It should be able to change the device used by a GstPulseSrc, even when the stream is playing.
Comment 1 Jonathan Tellier 2009-08-04 18:52:07 UTC
Created attachment 139890 [details] [review]
Proposed patch

By the way, I've made a typo in the bug description. I should have written "It should be possible..." not "It should be able..." :)
Comment 2 Jonathan Tellier 2009-08-04 19:50:33 UTC
Created attachment 139896 [details] [review]
Corrected patch

Tester made me realize that some locking was needed.
Comment 3 Marc-Andre Lureau 2009-08-05 00:17:25 UTC
What do you need the pa_stream for?

 "Changing device of stream %d to %s", pulsesrc->device, stream_index);
                            ^^^^^^^^
this is bogus.

Also, perhaps pulsesrc->device should be updated only when the moving is successful, dunno.
Comment 4 Jonathan Tellier 2009-08-05 13:00:44 UTC
> What do you need the pa_stream for?

An application that is using this new functionality will most likely want to interact with the pa_stream in order to work properly. For instance, it might want to call pa_stream_set_moved_callback() to see if the device switching went well. Exposing the pa_stream is the simplest way I found of addressing such an issue, but I'm open to suggestions.

> "Changing device of stream %d to %s", pulsesrc->device, stream_index);
>                            ^^^^^^^^
> this is bogus.

Well, it was useful to me when I was debugging, but I can always remove it.

> Also, perhaps pulsesrc->device should be updated only when the moving is
> successful, dunno.

Yeah, that makes sense. I'll change that too.
Comment 5 Jonathan Tellier 2009-08-05 15:33:41 UTC
Created attachment 139956 [details] [review]
Corrected patch
Comment 6 Marc-Andre Lureau 2009-08-13 09:45:06 UTC
(In reply to comment #4)
> > What do you need the pa_stream for?
> 
> An application that is using this new functionality will most likely want to
> interact with the pa_stream in order to work properly. For instance, it might
> want to call pa_stream_set_moved_callback() to see if the device switching went
> well. Exposing the pa_stream is the simplest way I found of addressing such an
> issue, but I'm open to suggestions.
> 

Right. Maybe you should have split the patch and say that.

> > "Changing device of stream %d to %s", pulsesrc->device, stream_index);
> >                            ^^^^^^^^
> > this is bogus.
> 
> Well, it was useful to me when I was debugging, but I can always remove it.
> 

That was not the point, it was about %d and %s being in wrong order.

> > Also, perhaps pulsesrc->device should be updated only when the moving is
> > successful, dunno.
> 
> Yeah, that makes sense. I'll change that too.
> 

I don't know if it's a common way in gstreamer - perhaps properties are just not the right interface for that.

You could avoid the double dup() and the lock() in case pulsesrc->stream is NULL. I would do it the same way it was done before.

otherwise, the patch looks ok to me
Comment 7 Jonathan Tellier 2009-08-13 14:06:49 UTC
Created attachment 140662 [details] [review]
Fixed patch

> That was not the point, it was about %d and %s being in wrong order.

Oh, I see! Well actually, it's the parameters who were in the wrong order. I've put it back then.

> You could avoid the double dup() and the lock() in case pulsesrc->stream is
> NULL. I would do it the same way it was done before.

I don't know if I understand you correctly, but I don't think we can avoid the lock(). What if there's a race condition in which one thread is creating the stream and the other one is checking if it's NULL?

Regarding the double dup(), I've made some small modification which gets rid of it.
Comment 8 Tim-Philipp Müller 2009-10-21 11:47:44 UTC
I also think you should put the new property into a separate patch. Using g_param_spec_pointer() is quite nasty for bindings btw, we try to not use that at all.

You could post a message on the bus to let the app know that the device change went well or not (and/or a warning message if it didn't).
Comment 9 Stefan Sauer (gstreamer, gtkdoc dev) 2011-03-02 18:36:24 UTC
I would leave out the property part for now too. Jonathan, any chance for spitted patch.
Comment 10 Akhil Laddha 2011-07-01 06:19:39 UTC
Jonathan, will you be able to provide patches in the format requested in comment#8 and comment#9 ?
Comment 11 Guillaume Desmottes 2011-07-01 06:28:07 UTC
Jonathan is not working with us since a while. Someone has to take over this bug/patch.
Comment 12 Sebastian Dröge (slomo) 2013-08-21 18:17:49 UTC
Anybody still interested in this or let's just close this?
Comment 13 Tim-Philipp Müller 2013-08-21 18:25:28 UTC
I think I saw a patch by Olivier recently that does exactly this.
Comment 14 Olivier Crête 2013-08-21 18:45:36 UTC
Created attachment 252644 [details] [review]
pulsesrc: Implement changing the device while playing
Comment 15 Olivier Crête 2013-08-21 18:45:40 UTC
Created attachment 252645 [details] [review]
pulsesrc: De-duplicate code to get the current source output info
Comment 16 Olivier Crête 2013-08-21 18:45:43 UTC
Created attachment 252646 [details] [review]
pulsesrc: Add property to find out the device currently in use
Comment 17 Olivier Crête 2013-08-21 18:48:12 UTC
I happened to implement this while doing device monitors. I propose adding a "current-device" property as the device change change from under our feet at any time. So the "device" property is the desired device, while "current-device" is the device actually in use.
Comment 18 Sebastian Dröge (slomo) 2013-08-22 08:37:51 UTC
Review of attachment 252644 [details] [review]:

Maybe the same for pulsesink?
Comment 19 Olivier Crête 2013-08-22 17:38:47 UTC
Committed, pulsesink will follow

commit 691b04e5c949ba85aa8e6dc8f5259017c4f652af
Author: Olivier Crête <olivier.crete@collabora.com>
Date:   Sun Aug 18 23:32:22 2013 -0400

    pulsesrc: Add property to find out the device currently in use
    
    https://bugzilla.gnome.org/show_bug.cgi?id=590768

commit d56f4718c2349adade11adb0400e2ab8679fce7f
Author: Olivier Crête <olivier.crete@collabora.com>
Date:   Sun Aug 18 23:31:15 2013 -0400

    pulsesrc: De-duplicate code to get the current source output info
    
    https://bugzilla.gnome.org/show_bug.cgi?id=590768

commit c3642e3ecf925e24362e09d901d46ac9b0faacd3
Author: Olivier Crête <olivier.crete@collabora.com>
Date:   Sun Aug 18 22:27:37 2013 -0400

    pulsesrc: Implement changing the device while playing
    
    https://bugzilla.gnome.org/show_bug.cgi?id=590768
Comment 20 Olivier Crête 2013-08-22 19:17:43 UTC
And for pulsesink

commit e00b8f0a4abbffc9b6597848d95406f4d519592c
Author: Olivier Crête <olivier.crete@collabora.com>
Date:   Sun Aug 18 23:32:22 2013 -0400

    pulsesink: Add property to find out the device currently in use
    
    https://bugzilla.gnome.org/show_bug.cgi?id=590768

commit d379e237c1b4366111cddab718a554d87bcaf779
Author: Olivier Crête <olivier.crete@collabora.com>
Date:   Sun Aug 18 23:31:15 2013 -0400

    pulsesink: De-duplicate code to get the current sink input info
    
    https://bugzilla.gnome.org/show_bug.cgi?id=590768

commit 8f9fbfa99297bc54a20d964d5067490fd167b22f
Author: Olivier Crête <olivier.crete@collabora.com>
Date:   Sun Aug 18 22:27:37 2013 -0400

    pulsesink: Implement changing the device while playing
    
    https://bugzilla.gnome.org/show_bug.cgi?id=590768