"reload" mac audio drivers without rebooting

83

54

I have an external audio interface (M-audio fast track c400). In order to get my macbook to recognize it (display in audio/midi setup), I have to reboot, which is a hassle. I have had other m-audio interfaces that were automatically detected when connected, and I'm pretty sure this one should be the same. Most posts around the internet suggest updating the OS or the software/firmware for the device. I have done all of those with no luck. I am currently running OS X 10.8.5.

Is there a way to force OS X to reload the device? Preferably some command line voodoo that I could fire off quickly when needed or wrap up in a nice little shell script.

Edit: Progress..

The problem appears to be fixed now... I'm not sure how the following solved the problem. If you know, please comment!

Inspired by @sbugert's answer, I started looking into other system daemon's that might do the trick if restarted. As a shot in the dark I killed coreservicesd. This caused the OS to become visibly unstable and I was eventually logged out automatically. To my surprise, when I logged back in, my audio interface was recognized..

Based on that, I hypothesized that killing coreservicesd and logging out/in may be a possible (ugly) workaround. So I unplugged the interface and plugged it back in, and as expected, it was not recognized. So I killed coreservicesd and attempted to log out, however I could not get the system to log out due to the instability caused by killing coreservicesd. I eventually was forced to do a "hard" shutdown (i.e. holding the power button until it turns off). After booting up the macbook again, the interface is now recognized automatically every time I plug it in. I suspect that this "hard" reset may have solved the issue without all the shenanigans with the coreservices daemon, but I have no way to test that.

If anyone can shed light on this, please do!

Edit: It stopped working again so I don't know what's up.

RyanM

Posted 2013-09-19T06:59:16.187

Reputation: 933

Answers

101

EDIT: most likely only works for osx before 10.13

This is what you need,

sudo kextunload /System/Library/Extensions/AppleHDA.kext
sudo kextload /System/Library/Extensions/AppleHDA.kext

But if you want to kill your coreaudio as well,

 ps aux | grep 'coreaudio[d]' | awk '{print $2}' | xargs sudo kill

use with caution.
The grep target is written this way specifically to exclude grepping the grep process itself in the ps out.

Ali

Posted 2013-09-19T06:59:16.187

Reputation: 1 288

The kext changes caused my laptop to reset - I don't recommend it. The fix for me was to go to Settings > Sound and check the Output is set correctly. – vaughan – 2014-12-04T17:58:22.993

@vaughan what is your OSX version? any special hardware? like fancy microphone or speakers or audio devices with specially drivers? – Ali – 2014-12-04T21:35:13.900

This temporarily brings back my sound. In my case, I have had audio issues ever since using a Plantronics USB headset that was provided to test Cisco Jabber. Reloading the AppleHDA kext provides temporary sound but video still lags and stutters. – Aaron – 2015-01-22T23:54:51.797

@Aron you much have some software (driver) installed that (on boot?) replaces or changes things back. Ideally they also provided you with an uninstaller that removes that faulty software/driver. – Ali – 2015-01-23T14:32:56.937

1Works. I had to kill coreaudio first, probably because a track was playing - should've stopped it first. MacBook Pro 13, late 2013, 10.10.1 – VladFr – 2015-02-05T14:22:05.283

@Ali why 'coreaudio[d]' and not just 'coreaudiod'? – dev – 2015-10-24T16:51:34.963

@dev I remember (at least at the time, I guess it was snow leopard?) there were also other processes running, that will get stuck and their name started with coreaudio but at least on El Capitan it looks they may not be present. – Ali – 2015-10-25T11:41:51.140

@Ali but I mean from a regexp point of view, isn't coreaudio[d] exactly the same as coreaudiod? (ie a bracket expression with only one character is equivalent to that single character) – dev – 2015-10-25T11:49:20.027

@dev you are correct. It must have had a * at the end or something. Don't really remember. Maybe got deleted in editing or something. Good catch. – Ali – 2015-10-25T11:54:13.433

Using builtin speaker and this fixed when VLC caused all output to become silent. But also it caused volume control not to work. – William Entriken – 2016-07-20T20:00:30.590

Just restarting core audio solved my problem... whatever my problem was. My system just hung for 10s or so and then recovered except for sound. OS X: 10.11.5 -- but volume control doesn't work. Reloading kext's fixed it all the way. – xaxxon – 2016-08-18T10:58:49.523

10(kernel) Can't unload kext com.apple.driver.AppleHDA; classes have instances: (kernel) Kext com.apple.driver.AppleHDA class AppleHDATDMBusManager has 1 instance. (kernel) Kext com.apple.driver.AppleHDA class AppleHDATDMBusManagerCS4208 has 2 instances. Failed to unload com.apple.driver.AppleHDA - (libkern/kext) kext is in use or retained (cannot unload). – Sergei – 2016-10-01T12:09:34.510

That is great, thanks. It happens most times I do not disconnect my bluetooth headphone properly, so I have bound those commands to an alias of restartAudio in my .zsh_profile ! – swifty – 2017-02-01T19:08:21.570

Thanks @ali it finally saved me a daily restart I had for the past 3 months of my life! – Aidin – 2018-04-23T19:05:36.297

3I get the same error messages as @Sergei. After doing so, my sound is completely disabled. The icon is grayed out, the function keys don't work. I have to reboot to bring everything back. – Patrick M – 2018-08-06T23:49:14.417

7The driver loading/unloading is the only thing that worked to make the Mac detect my headphones. THANK YOU! – wizonesolutions – 2014-05-17T00:26:55.897

77

Try typing this into Terminal:

sudo killall coreaudiod

This will kill the coreaudio process and restart it.

sbugert

Posted 2013-09-19T06:59:16.187

Reputation: 871

1This fixed my no sound effects problem. – wisbucky – 2016-03-02T08:31:48.897

2wow my issue was the internal speakers would stop working intermittently until i rebooted. thanks! this did the trick! – Elon Zito – 2016-04-29T03:36:58.360

2Did not restart for me. Sound is just off/disabled now. – Stop Slandering Monica Cellio – 2016-08-31T17:27:56.873

2Did not restart for me as well. Any specific command to start it ? – ayrad – 2016-11-15T14:32:47.113

2

@sequoiamcdowell This should work: http://apple.stackexchange.com/questions/187983/sudo-killall-coreaudiod-made-it-so-i-dont-have-any-volume-at-all

– Hannes Karppila – 2016-12-14T04:02:16.217

1Some applications do not handle the audio daemon going away very well. For example, iTunes may just show a grayed out volume control until you restart it. – Scott Ahten – 2017-02-10T21:38:42.937

this is the correct answer for 10.13, my issue seems to be caused by Spotify. – nzajt – 2018-09-07T17:03:51.683

why is this answer so low - it works for me? Spotify may also be the culprit for me. – Cornelius Roemer – 2019-12-10T12:23:17.427

This is exactly what I was hoping for! ...but it doesn't seem to work. Upon executing the command I see all the internal audio devices disappear and reappear in Audio/MIDI setup, but the external interface does not appear with them. I also tried killall -KILL and killall -ABRT which have the same result. Perhaps something similar but lower-level needs to be done, like restarting/reloading all usb devices? – RyanM – 2013-09-19T19:34:55.890

0

Same solution but with different variation

sudo kill -9 `ps ax|grep 'coreaudio[a-z]' | awk '{print $1}'`

user1573604

Posted 2013-09-19T06:59:16.187

Reputation: 121

4Don't use kill -9 just for the sake of it. A bare kill is perfectly sufficient to halt the daemon in normal circumstances. Indiscriminate use of -9 can lead to situations where a daemon shuts down so brutally that you can no longer restart it. – dland – 2014-12-19T09:15:40.793

-1

Here I have discovered that if I select another device before disconnecting the interface (Fast Track C400 too), I can connect it again later with no problem. But if I am using the fast track and then disconnect it, it can't connect again until restart it.

Davi Raubach

Posted 2013-09-19T06:59:16.187

Reputation: 1