When the GUI is first launched, it begins by looking for a USB FM Radio device. Once a device is found, it is opened up as a USB Audio Device for audio streaming and as a HID device for FM Tuner control. In addition, the default WAV output device is opened to playback the audio stream.
Audio Stream—The host application uses a circular buffer of 20 32 kB blocks to accept audio from the USB FM Radio device. Initially, 19 of the buffers are filled with audio data. Next, this data is sent to the WAV output device, and as streaming continues, pointers to the first free block and first playable block are incremented around the circular buffer to provide a constant and seamless flow of audio.
Audio will stream until a user action occurs such as tune, seek, or an alteration of radio settings. When this occurs, the audio stream will stop, and the commands for the requested action are sent down through the HID interface. Once the acknowledgement of the command comes back, the GUI is updated and stream playback will continue.
Device Status—In addition to the audio streaming, the device is also polled for its current attributes such as the current station, the received signal strength, and a stereo/mono indicator. As this information changes, it will also change on the display of the GUI.
Device Removal—Audio streaming and polling will stop if the device is disconnected from the USB. In this case, all of the device handles are closed, and the host application will begin to poll for connected devices.
USB Device Driver—Because Windows has built-in drivers for USB audio and HID class devices, the USB FM Radio does not require an OEM supplied driver disk for operation. The player executable is the only required user software. A similar approach is possible for other operating systems, if they have built-in support for these two USB device classes.