As @cobbal noted, on Mac OS X you would need to use PortAudio in some way to get the audio as it plays. The only other way to do it would be to use an audio player that has a plugin API, then write your code as a plugin for that one player. But a CoreAudio solution should make it possible for you to monitor all sounds played on the Mac.
Your CoreAudio code will not be portable at all to Windows and Linux. There is no portable solution at this time. On Windows you would probably want to use the WaveIn/WaveOut API, unless you have pro gear, in which case you would probably want to use ASIO. On Linux, I'm not sure; I think you could probably hook in to ALSA/PulseAudio to grab audio. Unless you have pro gear, in which case you would probably want to use JACK.
If you wanted a portable solution, you might want to look seriously at the plugin option. Find a portable free software media player that works on all your platforms, and make a scope plugin for that.
For an oscilloscope, you are going to want to get a book on Digital Signal Processing ("DSP"). You will probably want to use a Discrete Fourier Transform ("DFT") to get frequency information out of your discrete audio samples; a DFT library will likely be called an "FFT" library ("FFT" being short for "Fast Fourier Transform").
My favorite single book on DSP is: Understanding Digital Signal Processing by Richard G. Lyons.
EDIT: And by the way, most media players have "visualization" plugins, and some of them are displays based on frequencies. (Some even have names like "scope".) Is it possible that there is a media player that already does exactly the display you want?