如何以编程方式列出当前在 Mac OS 10.6 上使用默认声音输出的进程

发布于 2024-11-09 17:02:58 字数 491 浏览 0 评论 0原文

我想知道是否有一种编程方式(公共 API、终端命令、AppleScript 等)来列出当前通过 Mac OS 10.6 中的默认声音输出播放声音的所有进程?

我已经尝试使用“lsof | grep -i coreaudio”终端命令来列出具有 Core Audio 句柄的进程,但这并不能告诉我这些进程当前是否正在输出声音;他们可能以前已经输出过声音,或者他们打算将来这样做。

例如,如果我打开 Google Chrome,当我使用 lsof 命令时,首先它不会列出。然后,如果我在 Youtube 上加载视频,它会连接到 Core Audio,因此它会被列出。但是,当我完成视频后,即使我完全关闭浏览器窗口,它仍然被列为连接到驱动程序,即使它显然不再播放声音。当我退出该过程时,它才会停止列出。

请注意,虽然我在 Windows 平台上拥有丰富的 C++ 编程经验并且非常了解 Windows API,但我对 Mac OS 编程相当陌生,因此如果我遗漏了一些明显的内容,请理解。

谢谢, 弗朗索瓦·夏龙

I would like to know if there is a programmatic way (public API, terminal command, AppleScript, etc.) to list all processes currently playing sound through the default sound output in Mac OS 10.6 ?

I already tried using the "lsof | grep -i coreaudio" terminal command to list processes having a handle on Core Audio, but this does not tell me if those processes are outputting sound currently; they might have outputted sound before or they intend to do it in the future.

For instance, if I open Google Chrome, at first it is not listed when I use the lsof command. Then, if I load a video on Youtube, it connects to Core Audio, so it gets listed. But, when I'm done with the video, even if I close the browser window completely, it still is listed as being connected to the driver even though it is obviously not playing sound anymore. It only stops being listed when I quit the process.

Note that while having a lengthy programming experience in C++ on Windows platforms and knowing the Windows API pretty well, I'm rather new to Mac OS programming, so please be understanding if I miss something obvious.

Thanks,
François Charron

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如若梦似彩虹 2024-11-16 17:02:58

我知道这篇文章已经很老了,但它确实有一些投票,所以人们可能会通过搜索查询遇到它。

我非常确定这是不可能的,除非您编写一个嵌入到使用 CoreAudio 的每个进程中的 CoreAudio 插件。这项工作与创建 Windows 音量混合器的 Mac 版本非常相似。

有一个开源实现(https://github.com/zonque/PulseAudioOSX)没有维护,我也没有很幸运地建造它。还有一些专有的解决方案,例如 Prosoft Engineering 的 Hear,应该能够做到这一点,但我认为它们没有提供用于查询的 API。

注意:我已经构建了 MuteTab,它尝试在浏览器中执行相同的操作(在 Flash 更改和引入音频指示器之前),并构建了 mute.fm (Windows),它需要它以及控制音量的能力如果我把它移植到 OSX 上工作。

I know this post is pretty old, but it does have some votes so people might run into it via search queries.

I am pretty sure that this is not possible unless you write a CoreAudio plug-in that gets embedded in each process that uses CoreAudio. The work is very similar to creating a Mac version of the Windows Volume Mixer.

There is an open source implementation of this (https://github.com/zonque/PulseAudioOSX) although it is unmaintained and I haven't had great luck in getting it to build. There are also proprietary solutions such as Prosoft Engineering's Hear that should be able to do this but I don't think they provide an API to query.

Note: I have built MuteTab which tries to do the same within a browser (prior to changes in Flash and the introduction of audio indicators) and have built mute.fm (Windows) which would need this as well as an ability to control the volumes if I ported it to work on OSX.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文