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 329922 - When recording multiple times, items in "record from input" gets duplicated
When recording multiple times, items in "record from input" gets duplicated
Status: RESOLVED FIXED
Product: gnome-media
Classification: Deprecated
Component: Gnome-Sound-Recorder
2.13.x
Other Linux
: Normal normal
: ---
Assigned To: gnome media maintainers
gnome media maintainers
: 333393 343462 463891 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-02-04 20:07 UTC by Vincent Untz
Modified: 2007-09-06 21:21 UTC
See Also:
GNOME target: ---
GNOME version: 2.13/2.14


Attachments
Fix the bug for me (1.30 KB, patch)
2006-05-13 10:29 UTC, Baptiste Mille-Mathias
none Details | Review
patch update (673 bytes, patch)
2006-08-18 14:42 UTC, Sebastien Bacher
committed Details | Review
Do not update input list when "Record" button hit (374 bytes, patch)
2007-07-31 04:25 UTC, Boris Dušek
none Details | Review
Check track name is not NULL before strcmp'ing it (1.18 KB, patch)
2007-07-31 06:38 UTC, Boris Dušek
committed Details | Review

Description Vincent Untz 2006-02-04 20:07:16 UTC
Open gnome-sound-recorder.
Click on the record button.
Click on the stop button.
Repeat the last two step 3 or 4 times.
Look at the "record from input" combo box and cry :-)

All items seem to be added again when you click on record, or stop.
Comment 1 Teppo Turtiainen 2006-02-26 19:05:06 UTC
Confirmed with Sound Recorder 2.13.92 on Ubuntu Dapper.
Comment 2 Peter Shinners 2006-03-04 18:57:55 UTC
*** Bug 333393 has been marked as a duplicate of this bug. ***
Comment 3 Miguel Gaspar 2006-04-29 13:32:23 UTC
(I filled a bug on this in ubuntu launchpad https://launchpad.net/distros/ubuntu/+source/gnome-media/+bug/42022/+index)

I looked at the source for grecord, in gsr-window.c the callback for the record action calls fill_record_input():

static void
record_cb (GtkAction *action,
    GSRWindow *window)
{
 GSRWindowPrivate *priv = window->priv;

 if (priv->record) {
  shutdown_pipeline (priv->record);
  if (!make_record_source (window)) exit (1);
  fill_record_input (window);
 }

 if ((priv->record = make_record_pipeline (window))) {
  window->priv->len_secs = 0;
  window->priv->saved = FALSE;

  g_object_set (G_OBJECT (priv->record->sink),
         "location", priv->record_filename,
         NULL);

  gst_element_set_state (priv->record->pipeline, GST_STATE_PLAYING);
 }
}

But fill_record_input() appends to the combo-box:

static void
fill_record_input (GSRWindow *window)
{
 GstElement *e;
 const GList *l;
 int i = 0;

 g_return_if_fail (GST_IS_MIXER (window->priv->mixer));

 for (l = gst_mixer_list_tracks (window->priv->mixer); l != NULL; l = l->next) {
  GstMixerTrack *t = l->data;
  if (t->flags & GST_MIXER_TRACK_INPUT) {
   gtk_combo_box_append_text (GTK_COMBO_BOX (window->priv->input), t->label);
   ++i;
  }
  if (t->flags & GST_MIXER_TRACK_RECORD) {
   gtk_combo_box_set_active (GTK_COMBO_BOX (window->priv->input), i - 1);
  }
 }
}

Comment 4 Duncan Lithgow 2006-05-06 18:10:10 UTC
I just want to confirm the same behaviour here. Is it useful me mentioning I have the same problem?
Comment 5 Baptiste Mille-Mathias 2006-05-12 10:18:46 UTC
cc me
Comment 6 Baptiste Mille-Mathias 2006-05-12 20:07:20 UTC
From what I understand with my small knowledge, we have two solutions :
- remove the call to fill_record_input() from function record_cb(), but we loose the can't discover new input without restarting gnome-sound-recorder (1 line fix)
- clear the Combobox entries at the beginning of fill_record_input() (no idea)

Correct me if I'm wrong.
Anyway I'll try to contact a gnome-media maintainer.
Comment 7 Baptiste Mille-Mathias 2006-05-13 10:29:55 UTC
Created attachment 65375 [details] [review]
Fix the bug for me

The patch.
It works for me.
Comment 8 Germán Poo-Caamaño 2006-05-31 01:55:55 UTC
*** Bug 343462 has been marked as a duplicate of this bug. ***
Comment 9 Germán Poo-Caamaño 2006-05-31 02:09:23 UTC
The patch looks fine, it solves a real problem easy to fix.

grecord seems a little orphan, 6 months without an entry.

May I apply the patch?

Comment 10 Vincent Untz 2006-05-31 05:42:58 UTC
(I don't think "commented-on" is the right status for the patch since it generally means it's not sure it's okay)
Comment 11 Germán Poo-Caamaño 2006-05-31 14:43:47 UTC
If the patch is not ok, the status should be 'needs-work'.  IMHO.

Even If I'd tested the patch, which it is, 'commented-on' is the only status that can give some information the patch has been reviewed.  

Now that you say it, it seems useless.
Comment 12 Sebastien Bacher 2006-08-16 11:04:36 UTC
could a maintainer comment on that patch? 
Comment 13 Tim-Philipp Müller 2006-08-16 11:21:14 UTC
I'm not the maintainer, but some comment nevertheless:

 - clearing and re-filling the store might affect the selection and
   have unexpected side-effects through actions triggered on selection
   change; something to at least double-check before applying this
   patch IMHO

 - minor issue: one shouldn't first cast the model to a list store
   using the cast macros and only then check that the list store is
   non-NULL, since the cast macro will trigger a critical warning
   if the model is actually NULL. Better to do
      if (model) { ... }
Comment 14 Ronald Bultje 2006-08-16 12:09:02 UTC
I'm sorry, I've had notifications disabled halfway the semester (for obvious reasons) and missed this. Tim's comments are right, the variable should be checked for NULL before casting (so if (model != NULL) { call_function (GTK_LIST_STORE (model)); }

As for the second comment, the code takes that into account, so it should be OK. Please apply with the above small modification.
Comment 15 Sebastien Bacher 2006-08-18 14:42:34 UTC
Created attachment 71151 [details] [review]
patch update
Comment 16 Sebastien Bacher 2006-08-18 14:44:50 UTC
I've commited the "patch update" version for Baptiste, let me know if there is something not correct about it ;)

2006-08-18  Sebastien Bacher  <seb128@debian.org>

	* src/gsr-window.c: (fill_record_input): 
	"Clear combo_box first before add inputs", patch based on the work 
	from Baptiste Mille-Mathias <baptiste.millemathias@gmail.com>
	(Closes: #329922)
Comment 17 Boris Dušek 2007-07-30 04:36:26 UTC
This needs to be re-opened.

I am running Ubuntu Gutsy (7.10) Tribe 3 pre-release (gtk 2.11.6, glib 2.13.7, gstreamer 0.10.13).

The code from SVN:
 * works OK for revision {20060817}
 * crashes with revision {20060819} (see steps to reprocuce below)

which corresponds exactly to this patch applied.

It seems Tim's first point from comment #13 actually is valid since it's the reason why the program crashes in this situation:

Steps to reproduce
==================
1. Start gnome-sound-recorder
2. record->stop, then do whatever you want, but not record again
3. press record again - crashes immediately with segfault

Backtrace:

(gdb) bt
  • #0 strcmp
    from /lib/tls/i686/cmov/libc.so.6
  • #1 record_input_changed_cb
    at gsr-window.c line 1792
  • #2 g_cclosure_marshal_VOID__VOID
    from /usr/lib/libgobject-2.0.so.0
  • #3 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #4 ??
    from /usr/lib/libgobject-2.0.so.0
  • #5 ??
  • #6 ??

By adding custom debugging output, I discovered that the callback record_input_changed_cb which causes the segfault is triggered by line 1275, a.k.a. fill_record_input, which is called from record_cb, a.k.a. the callback called when user clicks the record button; but in this situation, record_input_changed_cb is not called as a result of user selecting a different input, but as a result of programmatic change of the input combobox, exactly as Tim has foreseen.

Ronald, you said that there is a code that should actually check for this condition and ensure this does not happen, could you please tell us which code? Maybe it got lost during subsequent SVN commits.

I am no expert in glib and gtk, but I have poked around a bit with the source code, so there are imho 2 solutions that I am aware of:

1. before fill_record_input (or at its start) disconnect the changed signal of combobox; after filling in of the combo box is done, reconnect it again. (or emulate this using something like "inside_fill_record_input" bool variable and check for it in record_input_changed_cb, and if it's true, record_input_changed_cd would return immediately.

2. remove this refilling. First, it seems very unprobable that a new source would be connected. Second, more correct would be for gstreamer to provide a signal for this purpose (track-added, track-removed), but at least by looking at docs, GstMixer does not provide this. From what I guess that such situation probably can't happen, since GStreamer would probably provide these if it was usable. (Does ALSA support it anyway? If I hotplugged USB microphone, would it be immediately available in mixer?)

Doing 1. correctly is not trivial. e.g. before refilling, we would have to store current input; when refilling, check if the current input from GstMixer is the same as the previous, and if yes, don't emit a signal, etc... And what is more, updating the inputs _after_ recording is started is IMHO not very usable.

I tried 2. (removing the line 1275) That fixes the crash for me.

This makes me think that we should support such a hotplug functionality when GStreamer does it itself.

I prefer 2., at least for now. (patch attached)

What do you think?
Comment 18 Boris Dušek 2007-07-30 05:03:44 UTC
strange things I discovered ... in Ubuntu Feisty Fawn (released in April 2007), this bug does not happen; when testing gnome-sound-recorder as in SVN as of 20060819 without the patch applied (= long before Feisty was released), and the latest version without the patch applied, the bug is there - maybe Ubuntu has some Ubuntu-specific fix to handle that?
Comment 19 Boris Dušek 2007-07-31 04:25:21 UTC
Created attachment 92757 [details] [review]
Do not update input list when "Record" button hit
Comment 20 Ronald Bultje 2007-07-31 05:17:23 UTC
Why are they duplicated anyway? Is that for device updates? Does that ever happen?

Boris, before we commit this, the strcmp() is triggered by this code, but is a bug in itself and needs fixing. Your fix may be right for another bug, which is the fact that we're updating, but I still want to see a patch for ths crasher in strcmp() here that actually fixes that issue, regardless of whether we call fill_inputs() unexpectedly or not in the code. Therefore, the patch is not good enough to fix this bug (for me).
Comment 21 Boris Dušek 2007-07-31 05:43:24 UTC
OK Ronald, I understand what you mean with fixing the "strcmp" part. I will try to have a look at it.
Comment 22 Boris Dušek 2007-07-31 06:38:37 UTC
Created attachment 92765 [details] [review]
Check track name is not NULL before strcmp'ing it

OK, I did the checking for strcmp. I do check both arguments to it for NULL'ness.

And I added 2 FIXME comments about code that gets never called, but probably had some purpose - but I feel not qualified enough to decide if the code actually has some purpose and if yes, how to enable it properly.

With this patch, my previous patch is not needed, but that does not mean that I don't think that the feature of refilling inputs after hitting record button is useful. It might be however useful with a special button "Reload available inputs". Should I implement that? (it should be fairly easy - just add a new button to the UI and add a callback for clicking it that would simply just call fill_record_input)

What I mean - 1. Does GStreamer even support hotplugging new inputs? 2. If yes, does it provide callbacks for notification of this?
If the answers are "1. Yes 2. No", then it would make sense to implement it with a button.
If the answers are "1. Yes 2. Yes", then it would be better to implement it using the callbacks.
And if the answers are "1. No 2. *", then I would suggest applying my previous patch to remove the refilling.
Comment 23 Boris Dušek 2007-08-07 00:15:42 UTC
Ronald,

could you please review my last patch (the NULL checking)?
I think it should be quite straightforward.

I hope this will get the chance to get in before Gnome 2.20 release.

Thanks,
Boris
Comment 24 Ronald Bultje 2007-08-07 04:14:47 UTC
I don't know about the refilling, I asked Tim about 10 times and never got an answer. It wasn't there originally. But code shouldn't be removed just because, it should be fixed. The second patch is ok, you can apply it.
Comment 25 Boris Dušek 2007-08-08 02:13:34 UTC
I don't have SVN write access = I can't commit the second patch.
Comment 26 Bastien Nocera 2007-09-06 19:16:44 UTC
I committed the second patch. I'm leaving this opened as the title of the bug is that entries get duplicated. I guess they still do now :)

2007-09-06  Bastien Nocera  <hadess@hadess.net>

        * src/gsr-window.c: (record_input_changed_cb): Patch from
        Boris Dušek <boris.dusek@gmail.com> to avoid crashing when
        strcmp'ing NULL strings (Helps: #329922)
Comment 27 Bastien Nocera 2007-09-06 19:17:14 UTC
*** Bug 463891 has been marked as a duplicate of this bug. ***
Comment 28 Boris Dušek 2007-09-06 21:05:32 UTC
(In reply to comment #26)
> I committed the second patch. I'm leaving this opened as the title of the bug
> is that entries get duplicated. I guess they still do now :)

The duplication problem got solved with commit in comment #16, I guess. At least during my testing, I did not see any duplication. I needed to reopen this bug since after this commit, a new crasher problem was introduced. My patch that you just commited fixes the introduced crasher. So I think it is right to close this bug now.

In the inprobable event that there are still some problems with this bug, anyone can at anytime reopen it. :-)
Comment 29 Bastien Nocera 2007-09-06 21:21:16 UTC
Cool, closing then.