开发者

How to programmatically list processes currently using the default sound output on Mac OS 10.6

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 co开发者_开发问答nnected 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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜