Skip to content

OS X: Ignores when USB headset is plugged in #481

Closed

Description

@nathanl

If cmus is open and I plug in a USB headset, it does not detect and use it, despite the fact that it is set to be preferred in System Preferences -> Sound -> Output. To use the headset, I must restart cmus. On the other hand, if cmus is open and I unplug the headset, it does detect this and switch to the laptop speakers correctly.

By contrast, audio from (eg) the browser will switch back and forth anytime I plug or unplug the headset.

(The headset I'm using is a Logitech USB - sorry, model unknown.)


  1. uname -a:
Darwin Nathans-MBP-2 15.5.0 Darwin Kernel Version 15.5.0: Tue Apr 19 18:36:36 PDT 2016; root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64
  1. cmus --version:
cmus v2.7.1
  1. cmus --plugins:
Input Plugins: /usr/local/Cellar/cmus/2.7.1_1/lib/cmus/ip
  mad:
    Priority: 55
    File Types: mp3 mp2
    MIME Types: audio/mpeg audio/x-mp3 audio/x-mpeg
  aac:
    Priority: 50
    File Types: aac
    MIME Types: audio/aac audio/aacp
  cue:
    Priority: 50
    File Types:
    MIME Types: application/x-cue
  flac:
    Priority: 50
    File Types: flac fla
    MIME Types:
  mp4:
    Priority: 50
    File Types: mp4 m4a m4b
    MIME Types:
  vorbis:
    Priority: 50
    File Types: ogg oga ogx
    MIME Types: application/ogg audio/x-ogg
  wav:
    Priority: 50
    File Types: wav
    MIME Types:

Output Plugins: /usr/local/Cellar/cmus/2.7.1_1/lib/cmus/op
  ao

Activity

  1. flyingmutant commented on Jul 6, 2016

    @flyingmutant
    Member

    Is the issue present when using CoreAudio output plugin? (You'll need to compile HEAD version of cmus for that).

  2. nathanl commented on Jul 13, 2016

    @nathanl
    Author

    Hmm, I can't get that to run at all.

    I downloaded a zip of master (currently 9d37708), unzipped it, and ran

    ./configure CONFIG_COREAUDIO=y && make install DESTDIR=/Users/nathanl/tmp/cmus.
    

    It appeared to run without errors (output below), but when I cd to ~/tmp/cmus/usr/local/bin and run ./cmus, I see only zsh: segmentation fault ./cmus.

    Here's the output when I configure and make:

    ~/Downloads/cmus-master: ./configure CONFIG_COREAUDIO=y && make install DESTDIR=/Users/nathanl/tmp/cmus
    checking for program gcc... /usr/bin/gcc
    checking for program gcc... /usr/bin/gcc
    checking for CFLAGS -std=gnu99 -pipe -Wall -Wshadow -Wcast-align -Wpointer-arith -Wwrite-strings -Wundef -Wmissing-prototypes -Wredundant-decls -Wextra -Wno-sign-compare -Wformat-security... yes
    checking for CFLAGS -Wold-style-definition... yes
    checking for CFLAGS -Wno-pointer-sign... yes
    checking for CFLAGS -Werror-implicit-function-declaration... yes
    checking for CFLAGS -Wno-unused-parameter... yes
    checking if CC can generate dependency information... yes
    checking byte order... little-endian
    checking for DL_LIBS (-ldl -Wl,--export-dynamic)... no
    checking for DL_LIBS (-ldl -rdynamic)... yes
    checking for PTHREAD_LIBS (-lpthread)... yes
    checking for realtime scheduling... yes
    checking for program pkg-config... no
    checking for NCURSES_LIBS (pkg-config)... no
    checking for NCURSES_LIBS (-lncursesw)... no
    checking for NCURSES_LIBS (pkg-config)... no
    checking for NCURSES_LIBS (-lncurses)... yes
    *** Your ncurses does not support wide characters!
    *** Install ncursesw if you need wide character support,
    *** you can ignore this warning otherwise.
    checking for working ncurses setup... yes
    checking for function resizeterm... yes
    checking for function use_default_colors... yes
    checking for ICONV_LIBS (-liconv)... yes
    taking iconv from libiconv
    checking for working iconv... yes
    checking for header <byteswap.h>... no
    checking for function strdup... yes
    checking for function strndup... yes
    checking for CDDB_LIBS (pkg-config)... no
    checking for CDDB_LIBS (-lcddb)... no
    checking for CDIO_LIBS (pkg-config)... no
    checking for CDIO_LIBS (-lcdio_cdio -lcdio -lm)... no
    checking for FLAC_LIBS (pkg-config)... no
    checking for FLAC_LIBS (-lFLAC -lm)... yes
    checking for MAD_LIBS (pkg-config)... no
    checking for MAD_LIBS (-lmad -lm)... yes
    checking for MODPLUG_LIBS (pkg-config)... no
    checking for MODPLUG_LIBS (-lmodplug -lstdc++ -lm)... no
    checking for header <mpc/mpcdec.h>... no
    checking for header <mpcdec/mpcdec.h>... no
    checking for VORBIS_LIBS (pkg-config)... no
    checking for VORBIS_LIBS (-lvorbisfile -lvorbis -lm -logg)... yes
    checking for OPUS_LIBS (pkg-config)... no
    *** pkg-config required for OPUS
    checking for LIBSYSTEMD_LIBS (pkg-config)... no
    *** pkg-config required for LIBSYSTEMD
    checking for WAVPACK_LIBS (pkg-config)... no
    checking for WAVPACK_LIBS (-lwavpack)... no
    checking for header <mp4v2/mp4v2.h>... yes
    checking for header <neaacdec.h>... yes
    checking for MP4_LIBS (-lmp4v2 -lfaad -lm)... yes
    checking for header <neaacdec.h>... yes
    checking for AAC_LIBS (-lfaad -lm)... yes
    checking for FFMPEG_LIBS (pkg-config)... no
    *** pkg-config required for FFMPEG
    checking for CUE_LIBS (pkg-config)... no
    *** pkg-config required for CUE
    checking for CUE_LIBS (pkg-config)... no
    *** pkg-config required for CUE
    checking for header <ayemu.h>... no
    checking for PULSE_LIBS (pkg-config)... no
    *** pkg-config required for PULSE
    checking for ALSA_LIBS (pkg-config)... no
    *** pkg-config required for ALSA
    checking for JACK_LIBS (pkg-config)... no
    *** pkg-config required for JACK
    checking for SAMPLERATE_LIBS (pkg-config)... no
    *** pkg-config required for SAMPLERATE
    checking for AO_LIBS (pkg-config)... no
    checking for AO_LIBS (-lao)... yes
    checking for COREAUDIO_LIBS (-framework CoreAudio -framework AudioUnit)... yes
    checking for program artsc-config... no
    checking for header <sys/soundcard.h>... no
    checking for header <sys/audioio.h>... no
    checking for ROAR_LIBS (pkg-config)... no
    *** pkg-config required for ROAR
    rm: .tmp-0-prog.dSYM: is a directory
    rm: .tmp-1-prog.dSYM: is a directory
    rm: .tmp-10-prog.dSYM: is a directory
    rm: .tmp-11-prog.dSYM: is a directory
    rm: .tmp-12-prog.dSYM: is a directory
    rm: .tmp-13-prog.dSYM: is a directory
    rm: .tmp-14-prog.dSYM: is a directory
    rm: .tmp-15-prog.dSYM: is a directory
    rm: .tmp-16-prog.dSYM: is a directory
    rm: .tmp-17-prog.dSYM: is a directory
    rm: .tmp-18-prog.dSYM: is a directory
    rm: .tmp-2-prog.dSYM: is a directory
    rm: .tmp-3-prog.dSYM: is a directory
    rm: .tmp-4-prog.dSYM: is a directory
    rm: .tmp-5-prog.dSYM: is a directory
    rm: .tmp-6-prog.dSYM: is a directory
    rm: .tmp-7-prog.dSYM: is a directory
    rm: .tmp-8-prog.dSYM: is a directory
    rm: .tmp-9-prog.dSYM: is a directory
    INSTALL /Users/nathanl/tmp/cmus/usr/local/bin/cmus
    INSTALL /Users/nathanl/tmp/cmus/usr/local/bin/cmus-remote
    INSTALL /Users/nathanl/tmp/cmus/usr/local/lib/cmus/ip/flac.so
    INSTALL /Users/nathanl/tmp/cmus/usr/local/lib/cmus/ip/mad.so
    INSTALL /Users/nathanl/tmp/cmus/usr/local/lib/cmus/ip/vorbis.so
    INSTALL /Users/nathanl/tmp/cmus/usr/local/lib/cmus/ip/wav.so
    INSTALL /Users/nathanl/tmp/cmus/usr/local/lib/cmus/ip/mp4.so
    INSTALL /Users/nathanl/tmp/cmus/usr/local/lib/cmus/ip/aac.so
    INSTALL /Users/nathanl/tmp/cmus/usr/local/lib/cmus/op/coreaudio.so
    INSTALL /Users/nathanl/tmp/cmus/usr/local/lib/cmus/op/ao.so
    INSTALL /Users/nathanl/tmp/cmus/usr/local/share/cmus/cyan.theme
    INSTALL /Users/nathanl/tmp/cmus/usr/local/share/cmus/default.theme
    INSTALL /Users/nathanl/tmp/cmus/usr/local/share/cmus/gray-88.theme
    INSTALL /Users/nathanl/tmp/cmus/usr/local/share/cmus/green-mono-88.theme
    INSTALL /Users/nathanl/tmp/cmus/usr/local/share/cmus/green.theme
    INSTALL /Users/nathanl/tmp/cmus/usr/local/share/cmus/gruvbox-alt.theme
    INSTALL /Users/nathanl/tmp/cmus/usr/local/share/cmus/gruvbox.theme
    INSTALL /Users/nathanl/tmp/cmus/usr/local/share/cmus/jellybeans.theme
    INSTALL /Users/nathanl/tmp/cmus/usr/local/share/cmus/night.theme
    INSTALL /Users/nathanl/tmp/cmus/usr/local/share/cmus/rc
    INSTALL /Users/nathanl/tmp/cmus/usr/local/share/cmus/solarized-dark.theme
    INSTALL /Users/nathanl/tmp/cmus/usr/local/share/cmus/solarized-light.theme
    INSTALL /Users/nathanl/tmp/cmus/usr/local/share/cmus/xterm-white.theme
    INSTALL /Users/nathanl/tmp/cmus/usr/local/share/cmus/zenburn.theme
    INSTALL /Users/nathanl/tmp/cmus/usr/local/share/man/man1/cmus.1
    INSTALL /Users/nathanl/tmp/cmus/usr/local/share/man/man1/cmus-remote.1
    INSTALL /Users/nathanl/tmp/cmus/usr/local/share/man/man7/cmus-tutorial.7
    INSTALL /Users/nathanl/tmp/cmus/usr/local/share/doc/cmus/examples/cmus-status-display
    
  3. mahkoh commented on Jul 13, 2016

    @mahkoh
    Member

    ./configure CONFIG_COREAUDIO=y && make install DESTDIR=/Users/nathanl/tmp/cmus

    Remove the DESTDIR argument.

  4. nathanl commented on Jul 13, 2016

    @nathanl
    Author

    Tried that. It overwrote /usr/local/bin/cmus and does open and play, but the bug remains. Also, oddly, cmus --version now shows cmus v2.7.0 - previously it was v2.7.1.

  5. flyingmutant commented on Jul 13, 2016

    @flyingmutant
    Member

    cmus --version should mention the commit hash – does it? And what is the output of cmus --plugins?

  6. nathanl commented on Jul 15, 2016

    @nathanl
    Author

    It doesn't mention the commit hash.

    $: cmus --version                                                                                                                           
    cmus v2.7.0
    Copyright 2004-2006 Timo Hirvonen
    Copyright 2008-2013 Various Authors
    

    plugins looks like this:

    $: cmus --plugins                                                                                                                           
    Input Plugins: /usr/local/lib/cmus/ip
      mad:
        Priority: 55
        File Types: mp3 mp2
        MIME Types: audio/mpeg audio/x-mp3 audio/x-mpeg
      aac:
        Priority: 50
        File Types: aac
        MIME Types: audio/aac audio/aacp
      cue:
        Priority: 50
        File Types:
        MIME Types: application/x-cue
      flac:
        Priority: 50
        File Types: flac fla
        MIME Types:
      mp4:
        Priority: 50
        File Types: mp4 m4a m4b
        MIME Types:
      vorbis:
        Priority: 50
        File Types: ogg oga ogx
        MIME Types: application/ogg audio/x-ogg
      wav:
        Priority: 50
        File Types: wav
        MIME Types:
    
    Output Plugins: /usr/local/lib/cmus/op
      coreaudio
      ao
    
  7. flyingmutant commented on Jul 15, 2016

    @flyingmutant
    Member

    @Wang-Yue any ideas, what might cause this behavior?

  8. Wang-Yue commented on Jul 16, 2016

    @Wang-Yue
    Contributor

    I cannot reproduce the problem.

    When system default audio device is used, which means:
    dsp.coreaudio.device is set to empty string
    dsp.coreaudio.enable_hog_mode is false
    dsp.coreaudio.sync_sample_rate is false,
    in this case cmus has no idea what the device is. It just output to kAudioObjectSystemObject. The operating system will decide which device to use. It will always output to your system default output (be it headphone jack, usb audio, internal speaker, thunderbolt display, s/pdif).

    I cleared my settings, started cmus with dac unplugged. audio came out from internal speaker. Then I connectted USB DAC to my computer, audio switched to use the DAC, which showed the correct behavior.


    I'd like to share something else.

    The problem does occur, however, when you have selected a specific device in the setting, but having the device unplugged when starting cmus. Our code currently assumes user having the device ready when initializing the output plugin.

    There are two potential solutions to this issue:

    1. It would be better if user could switch device during runtime. Many media players support that. Device initialization work is currently done only when the plugin is initialized (coreaudio_init()). It's possible to call the following functions in order when coreaudio_set_device() is called: coreaudio_close() -> coreaudio_exit -> coreaudio_init -> coreaudio_open. This essentially closes previous device, and initialize the current device, when user changes the setting. This is easy to implement.
    2. Be more user friendly --- It's possible to automatically monitor plug-and-play device status in CoreAudio. One needs to do very low level programming using AudioUnitEvents and AUEventListeners. When a device that matches coreaudio_device_name is connected, we perform steps in the previous solution.

    Generally console applications are not written this way --- users are responsible to make sure the config file reflect right environment when the application is started. Though in the plug and play era, we could do a lot better. Patches are welcomed!

  9. Wang-Yue commented on Jul 24, 2016

    @Wang-Yue
    Contributor

    This bug can be closed. Not reproducible. Probably the person who reports the bug has wrong configuration settings.

  10. nathanl commented on Jul 29, 2016

    @nathanl
    Author

    dsp.coreaudio.device is set to empty string
    dsp.coreaudio.enable_hog_mode is false
    dsp.coreaudio.sync_sample_rate is false,

    I just checked and I see exactly these settings. (I think the only setting I've changed since installation is setting softvol to true.) If I understand correctly, that means I'm using whatever device the operating system decides to for output, so if it doesn't switch correctly, that's the OS's fault?

    I could have a setting wrong somehow with OS X, but as I said, it does switch if I unplug or plug in while playing video in the browser (for example).

  11. flyingmutant commented on Aug 25, 2016

    @flyingmutant
    Member

    FWIW, I can not reproduce the issue. Plugging and unplugging the headphones just works — no matter if I started cmus with them plugged or not.

  12. nathanl commented on Aug 26, 2016

    @nathanl
    Author

    Weird. The music playback does not switch over, even though other sounds do. Eg, I just unplugged and plugged back in. Cmus is still playing through my laptop speakers, but the "alarm bell" sound comes through the headphones.

    Maybe there is some weird interaction between my specific model of headphones and cmus. 😕 Oh, well. Thanks for discussing.

  13. philc commented on Oct 5, 2017

    @philc

    I can reproduce a flavor of this issue in 100% of cases. I have a USB sound card plugged into external thunderbolt monitors. Playback through this soundcard works fine in cmus. If I unplug the macbook from the monitors and replug, system sounds and apps like Spotify resume playing through the USB soundcard, but cmus does not. I must restart cmus, and then playback works. I restart cmus multiple times per day because of this, which led me to file this feature request to reduce frustration.

  14. sijad commented on May 4, 2018

    @sijad

    I can reproduce in cmus v2.8.0-rc0 macOS 10.12

  15. sijad commented on May 4, 2018

    @sijad

    I can't reproduce using coreaudio, :set output_plugin=coreaudio.
    it seems to be related to ao.

  16. Wang-Yue commented on May 5, 2018

    @Wang-Yue
    Contributor

    @sijad just use coreaudio. don't use the legacy ao plugin.

  17. sijad commented on May 5, 2018

    @sijad

    with coreaudio some high-res audio have playing problem. I'm not sure if is that a known problem?

    it seems this only happens with 96khz audios, by changing DAC output format to 96000 in midi application problem solved.

  18. Wang-Yue commented on May 7, 2018

    @Wang-Yue
    Contributor

    @sijad apart from that, coreaudio.sync_sample_rate will also sync the sample rate automatically for you based on the audio you are playing.

  19. nathanl commented on May 8, 2018

    @nathanl
    Author

    OP here. I just downloaded a zip of b595b8c (which reports v2.8.0-rc0 from /usr/local/bin/cmuss --version) and compiled with ./configure CONFIG_COREAUDIO=y && make install. After starting up /usr/local/bin/cmus, I :set output_plugin=coreaudio.

    With this, I can plug and unplug a USB headset and playback moves back and forth between the headset and the laptop speakers as expected. 👍

  20. Wang-Yue commented on May 8, 2018

    @Wang-Yue
    Contributor

    this issue can be closed

  21. philc commented on May 22, 2018

    @philc

    Since this affects Mac users, and most Mac users install via homebrew, and the homebrew formula author will probably not track an RC release, can we cut a 2.8.0 final release? We've been on 2.8.0-rc0 for 1.5 years now (released Nov 2016). Related: #583.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions