-
Notifications
You must be signed in to change notification settings - Fork 577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
audio device event not captured #3057
Comments
BTW I successfully tested that I can capture event using objective C code. The following code does print the UUID of the microphone device when it is enabled or not in another app:
|
I'm also seeing the same issue with the I suspect related, I'm seeing some strangeness with the state of the watcher apparently not being preserved, e.g.:
So, all that seems to work well, but if we now re-obtain the audiodevice, the watcher isn't running (the following run immediately after the above):
|
To work around audiodevice callbacks not working. Hammerspoon/hammerspoon#3057
At some point between 0.9.97 and 0.9.100 (6815), I still see the same strangeness with the watcher state I describe in my comment above. |
It looks like what's happening is that every time you call I don't think this behavior is a bug per se, but it's not documented as far as I can tell, and it's definitely not very intuitive. The reason I thought to check for this is:
Footnotes
|
Agreed. At this point, I believe the original problem for this issue has been fixed and it could be closed. [EDITED: Was confused and thought I originally opened this issue.] I propose I open another issue around the documentation of this state behavior so it's not lost. I'm not set up to generate a PR for the documentation right now, or I'd do that. |
I was mistaken when I said this. I forgotten I had a work around that used polling instead of the callbacks which fooled me into thinking the callbacks were working, so this issue is not fixed I believe. |
I note that hs.camera does not seem to exhibit the same behavior has hs.audiodevice with regards to objects versus devices. The watchers seem to carry over from one object created to the next. For example:
|
@Rhys-T Thank you for the explanation. I have modified my code such that I am storing my hs.audiodevice instances now, which I believe should prevent them from being garbage collected, however I am still not seeing watchers being called. For clarity, it's not that I'm seeing the watchers called at first and then they stop being called, rather I'm never seeing them called. If anyone is having any success with hs.audiodevice watchers, I welcome hearing that. |
@von Hmm… it's working on my Hammerspoon (0.9.97 / 6267, Intel), at least with Unfortunately, I'm not familiar enough with macOS's audio APIs to know what to try next, if it's not the garbage collection thing… Re: |
Thank you @Rhys-T . Turns out it's my bad and everything is working as it should. Knowing it worked for you caused me to think hard enough about this to realize what I was assuming wrong. My mistake was a bad assumption about how Zoom works. Looks like it grabs the microphone at the start of a meeting and its muting/unmuting is all internal to the app and it doesn't fire any sort of watcher callback. I was clicking Mute/unmute/etc and not seeing any watcher callbacks and assuming they were not working. If one cares about Zoom mute state, one has to check the Zoom application menu state or a similar workaround. With the spawning of #3559 to cover the documentation of |
@von Glad to hear it's working for you. If it helps, someone has already written a Spoon for tracking whether or not Zoom is a) connected to a meeting, and b) unmuted: https://github.com/jpf/Zoom.spoon (more usage examples here: https://developer.okta.com/blog/2020/10/22/set-up-a-mute-indicator-light-for-zoom-with-hammerspoon) |
Thanks @Rhys-T , I am aware of that repo and took my approach from it (you'll see it credited towards the top of my code). It's a good piece of software, my use case (monitoring any microphone or camera access, not just Zoom) is different enough I only borrowed from it instead of re-using it in its entirety. |
Hi, I am building a macOS app and I was successful in capturing the audio input device (internal default macbook microphone) when it's being used. However, as soon as I connect my airpods as my audio device, it does not detect. I've used |
Hi @esphoenixc it doesn't seem like your issue has anything to do with Hammerspoon in that you're writing a native Mac app. If I'm correct, you're in the wrong place. |
Similar issue posted on https://groups.google.com/g/hammerspoon/c/heoYjCDatNk
I am currently unable to get the callback being fired for any audio event with hammerspoon 0.9.93.
I run the following code:
but it never print anything whatever I do (changing input volume, enabling mic, muting...)
I did the same on the output devices without more success.
I authorized hammerspoon to access the microphone using that command to have the permission request:
but it didn't change anything.
I successfully tested than the inUse() method properly returns the current state of the microphone to ensure the library still get the input device properties.
I also general watcher about device change event does work.
i.e., this code:
properly output events when I plug/unplug my headset for instance.
But I didn't find any clue about why the individual audiodevice event watcher doesn't work me.
BTW I am on a MacBook Air M1 using Mac OS Big Sur.
The text was updated successfully, but these errors were encountered: