There are several options for outputting sound on the Raspberry Pi 2. The first is the HDMI port. If you are using this connected to a HDTV, for example, you can stream both video and audio at the same time.
The second is the analogue audio jack. This is perfect for attaching headphones or speakers that use a headphone-style plug.
However, we are not limited to these two methods.
As explained in Chapter 1, Introduction to the Raspberry Pi's Architecture and Setup, the Raspberry Pi 2 implements an Inter-IC Sound (I2S) serial bus for both audio input and output.
From the Raspberry Pi's perspective, implementing I2S allows us to not only use HDMI and the analogue audio jack, but also implement audio via the GPIO pins or USB.
We can therefore connect an external device to, say, our GPIO pins that can act as a HiFi system. Later in this chapter we will look at some example hardware that does exactly this.