Master audio output changes to None and not all devices are listed on ALSA in Linux

Bug #342005 reported by Sean M. Pappalardo
14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mixxx
Fix Released
Low
Phillip Whelan
1.7
Fix Released
Low
Phillip Whelan

Bug Description

(This has been an issue since at least 1.6.0.)

Normally, Mixxx lists quite a few audio devices using the ALSA API such as front, surround, iec958, the actual sound card, default, dmix, etc. (I normally choose "default.") Sometimes when I start Mixxx though, the list is much shorter, showing only "None," "spdif," "default," and "dmix." Since "default" is normally item #12 or so for me, Mixxx changes to "None" when this happens because there is no #12. I have to restart Mixxx three or four times before the correct list shows again. (If I instead choose "default" off the short list, when the list returns to normal size the wrong device is selected.)

So a quick fix would be to search for the device name rather than its index from the config file (since they're both stored there.) The real fix is to find out why this is happening at all. (_Might_ be related to bug #248202.)

I'm on Debian testing (squeeze).

description: updated
description: updated
Changed in mixxx:
importance: Undecided → Low
milestone: none → 1.6.2
status: New → Confirmed
description: updated
Revision history for this message
ironstorm (ironstorm-gmail) wrote :

I've the problem with sound devices being unavailable can happen a couple of different ways. I've seen it two ways:

1) In the pre-pulseaudio days, if you ran artsd --> there was a sound device timeout that needed to elapse after the last sound was played by artsd before portaudio+ALSA could acquire the handle to the device. I made the mistake of setting timeout to 0 (which actually made it never time out) and I lost the device from Mixxx's ALSA sound list until I set it to 1 second again (the default was more 5 seconds I think). You will still see digital devices in the list as long as artsd is not configured to use them.

2) In the post-pulseaudio days, you can get this situation if you run another non-PA application that requests the exclusive use of the device via ALSA or OSS... One such example is firefox with flash, if the flash plays sound, the device will be used until you close all firefox processes. Another way to reproduce this would be to start 2 copies of Mixxx, the first will bind the device, the second will fail to get that device in the list from portaudio. This is a bit non-obvious because PulseAudio will still play desktop sound effects even though flash has obtained control over the sound card (so there neat trick of software mixing going on there, though it sometimes crackles horribly on AMD64 so it is still much a work in progress).

In both cases it boils down to another device having the handle on primary sound device, and portaudio being unable to get that device when querying ALSA. So when you can't get the handle to that device, Mixxx will look at it and go, this device is gone -> set to None.

The issue is not so much how Mixxx saves the data, which it does as a string (unless your hw0,1 is changing to something else it should match regardless of the order it appears in the list), but rather that if "None" is selected then the primary sound device is not saved at all (which because it is now invalid according to the ALSA list we got back).

One approach to killing this bug would be to institute a message box dialog that pops up whenever the Sound Device is transitioned from "Some Sound Card (hw0,1)" to "None" at device open on start-up. I'm guessing if you put something to the effect:

"Mixxx was unable to bind to 'Some Sound Card (hw0,1)' at start-up, this could be because another application is using the sound device or the device is not plugged in (USB sound cards), would you like to *retry* after closing the other application or reconnected the sound device or *continue* into the Mixxx hardware prefs screen to select a new sound device. You can also read about this problem on our Wiki - [Retry] [Wiki] [Continue]"

When retry is hit, re-poll ALSA, look for the original device and try to re-init it.

description: updated
Revision history for this message
ironstorm (ironstorm-gmail) wrote :

I made one small change to sound manager to help with this:
http://mixxx.svn.sf.net/viewvc/mixxx/trunk/mixxx/src/soundmanager.cpp?r1=2501&r2=2737&sortby=date

It should trigger the sound prefs to open if a device could not be initialized on start-up.

Revision history for this message
Albert Santoni (gamegod) wrote : Re: [Bug 342005] Re: Master audio output changes to None and not all devices are listed on ALSA in Linux

If I can just throw my 2 cents in:

I don't think you want to hash on the device name because it causes
problems when you have two of the same soundcards (this isn't an
unheard of setup with vinyl control, I used to use it). IIRC I did
originally hash on the device name way back when I wrote the audio
code, but there were some issues that popped up that caused me to
change it to the device index. (I don't remember the specifics, they
might be in the SVN log.) I think John and I changed it.

Albert

On Tue, Mar 17, 2009 at 7:47 PM, ironstorm <email address hidden> wrote:
> I made one small change to sound manager to help with this:
> http://mixxx.svn.sf.net/viewvc/mixxx/trunk/mixxx/src/soundmanager.cpp?r1=2501&r2=2737&sortby=date
>
> It should trigger the sound prefs to open if a device could not be
> initialized on start-up.
>
> --
> Master audio output changes to None and not all devices are listed on ALSA in Linux
> https://bugs.launchpad.net/bugs/342005
> You received this bug notification because you are a member of Mixxx
> Development Team, which is subscribed to Mixxx.
>

Revision history for this message
Sean M. Pappalardo (pegasus-renegadetech) wrote :

Sounds like this and bug #276620 are related.

Revision history for this message
Albert Santoni (gamegod) wrote :

Sean: I agree. It looks like Garth's patch to trunk fixed 276620
(according to his post above). Does anyone want to try applying the
diff to release-1.6.2 and testing?

Thanks,
Albert

On Wed, Mar 18, 2009 at 1:23 PM, Pegasus <email address hidden> wrote:
> Sounds like this and bug #276620 are related.
>
> --
> Master audio output changes to None and not all devices are listed on ALSA in Linux
> https://bugs.launchpad.net/bugs/342005
> You received this bug notification because you are a member of Mixxx
> Development Team, which is subscribed to Mixxx.
>

Revision history for this message
Sean M. Pappalardo (pegasus-renegadetech) wrote :

Ok, it does cause Mixxx to pop up an error and bring up the preferences, so that's good for now. I discovered that it is in fact due to the system taking exclusive control over the sound hardware, so it's not likely anything we can fix within Mixxx. However, can we somehow have Mixxx detect when this happens and not save the sound card choice on that exit? (Otherwise a subsequent start will have silently chosen the wrong card.)

The permanent fix is for people to go into their sound manager preferences and change the auto-suspend feature to do so after just a second or so. (In KDE Control Center, go to Sound & Multimedia, Sound System, then at the bottom of the pane, change Auto-suspend if idle.)

Revision history for this message
Nick (kousu) wrote : Re: [Bug 342005] [NEW] Master audio output changes to None and not all devices are listed on ALSA in Linux

Dumb question: is there no way to get the list of all ALSA devices,
even the locked ones? Seems like a insane API if you can't.... We
should always show the same list; whether we can bind to a device or
not is already taken care of by a dialog box "could not open sound
device".

On 22/03/2009, Pegasus <email address hidden> wrote:
> Ok, it does cause Mixxx to pop up an error and bring up the preferences,
> so that's good for now. I discovered that it is in fact due to the
> system taking exclusive control over the sound hardware, so it's not
> likely anything we can fix within Mixxx. However, can we somehow have
> Mixxx detect when this happens and not save the sound card choice on
> that exit? (Otherwise a subsequent start will have silently chosen the
> wrong card.)
>
> The permanent fix is for people to go into their sound manager
> preferences and change the auto-suspend feature to do so after just a
> second or so. (In KDE Control Center, go to Sound & Multimedia, Sound
> System, then at the bottom of the pane, change Auto-suspend if idle.)
>
> --
> Master audio output changes to None and not all devices are listed on ALSA
> in Linux
> https://bugs.launchpad.net/bugs/342005
> You received this bug notification because you are a member of Mixxx
> Development Team, which is subscribed to Mixxx.
>

Revision history for this message
ironstorm (ironstorm-gmail) wrote :

The only call that looks like it's relevant is the one we are using -> Pa_GetDeviceCount. It may sound insane, but keep in mind that being multi-platform / multi-api PortAudio maybe stuck with the lowest common denominator across all of them. If one or more API doesn't implement that function then you get a broken result when you take your app there.

Revision history for this message
ironstorm (ironstorm-gmail) wrote :

I'm attaching a patch that is not finished yet... I need to sleep, but if others want to look and play this is what I'll be working on finishing off...

Revision history for this message
ironstorm (ironstorm-gmail) wrote :

In the patch
+while (m_pConfig->getValueString(ConfigKey("[Soundcard]","DeviceMaster")).isEmpty() &&
should be
+while (!m_pConfig->getValueString(ConfigKey("[Soundcard]","DeviceMaster")).isEmpty() &&

Revision history for this message
Albert Santoni (gamegod) wrote : Re: [Bug 342005] Re: Master audio output changes to None and not all devices are listed on ALSA in Linux

Took a quick peek at your patch. My suggestion is that instead of
putting GUI code inside a purely non-GUI class (SoundManager), have
setupDevices() return a sensible error code to whatever calls it
(mixxx.cpp IIRC) and put that message box/GUI code there instead.

Thanks,
Albert

On Sun, Mar 22, 2009 at 11:04 PM, ironstorm <email address hidden> wrote:
> In the patch
> +while (m_pConfig->getValueString(ConfigKey("[Soundcard]","DeviceMaster")).isEmpty() &&
> should be
> +while (!m_pConfig->getValueString(ConfigKey("[Soundcard]","DeviceMaster")).isEmpty() &&
>
> --
> Master audio output changes to None and not all devices are listed on ALSA in Linux
> https://bugs.launchpad.net/bugs/342005
> You received this bug notification because you are a member of Mixxx
> Development Team, which is subscribed to Mixxx.
>

Revision history for this message
ironstorm (ironstorm-gmail) wrote :

yup definitely will do that. I may also may end up split setupDevices into setupOutputDevices and setupVinylDevices, have to see how it makes sense to do the refactoring as it ripples out.

Revision history for this message
Albert Santoni (gamegod) wrote : Re: [Bug 342005] [NEW] Master audio output changes to None and not all devices are listed on ALSA in Linux

Ok, thanks! I think I can foresee some problems with splitting up the
device opening code, because the input and output channels on a device
have to be opened simultaneously when you call Pa_StartStream (we can
only have one stream pointer per device)

On 3/23/09, ironstorm <email address hidden> wrote:
> yup definitely will do that. I may also may end up split setupDevices
> into setupOutputDevices and setupVinylDevices, have to see how it makes
> sense to do the refactoring as it ripples out.
>
> --
> Master audio output changes to None and not all devices are listed on ALSA
> in Linux
> https://bugs.launchpad.net/bugs/342005
> You received this bug notification because you are a member of Mixxx
> Development Team, which is subscribed to Mixxx.
>

--
Sent from my mobile device

Changed in mixxx:
assignee: nobody → ironstorm-gmail
status: Confirmed → In Progress
Changed in mixxx:
milestone: 1.7.0-moving → none
Revision history for this message
Sean M. Pappalardo (pegasus-renegadetech) wrote :

ironstorm: Can we get an update on your progress?

Changed in mixxx:
status: In Progress → Confirmed
Revision history for this message
Phillip Whelan (pwhelan) wrote :

Here is a patch to open a dialog at startup when there are errors with sound.

It allows you to:
    * Retry: so you can close applications or plug in your USB soundcard
    * Reconfigure: in case you have a better sound card anway you lucky... person
    * Help: get it, and quick from the amazing Mixxx Wiki!
    * Cancel: so you can swap in your neato PCI card (after rebooting of course) or just get out without saving prefs

I will also be spamming this on the mailing list. Have Fun!

Revision history for this message
ironstorm (ironstorm-gmail) wrote :

Thanks man, the patch looks good to me... my primary machine these days is a mac, but I'll see if I can't reproduce the issue and test this on the weekend on my eeepc (which I think is still running intrepid).

Revision history for this message
ironstorm (ironstorm-gmail) wrote :

Credit Phil with the kill!

Changed in mixxx:
assignee: ironstorm (ironstorm-gmail) → pwhelan (pwhelan)
status: Confirmed → Fix Committed
Changed in mixxx:
status: Fix Committed → Confirmed
RJ Skerry-Ryan (rryan)
Changed in mixxx:
status: Confirmed → Fix Committed
RJ Skerry-Ryan (rryan)
Changed in mixxx:
status: Fix Committed → Fix Released
Revision history for this message
Swiftb0y (swiftb0y) wrote :

Mixxx now uses GitHub for bug tracking. This bug has been migrated to:
https://github.com/mixxxdj/mixxx/issues/5113

lock status: Metadata changes locked and limited to project staff
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.