Under The Microscope

Restore Audio Streaming to Apple TV, With Airfoil Satellite TV

As described in Friday’s post, we’ve been working on two distinct solutions to enable you to stream audio from Airfoil to the newest Apple TVs. We’re now able to provide you with the first of those solutions.

Get Airfoil Satellite TV Now!

Airfoil Satellite TV IconWhen tvOS 10.2 broke Airfoil’s ability to send audio directly to the Apple TV, we began working on an alternative method of getting audio to the device. We’re now pleased to provide Airfoil Satellite TV, an app to turn your Apple TV into an audio receiver for Airfoil. With Airfoil Satellite TV running on your Apple TV, you’ll again be able to send audio from your Mac or Windows machine to tvOS-based Apple TVs.

To download the free Airfoil Satellite TV, just search for it in the App Store right on your Apple TV. If you have automatic downloading turned on for your Apple TV, you can also click this link to get the app. When you’ve got the app running, just use Airfoil to send audio to the “Airfoil Satellite on <Your Apple TV Name>” device. Once you do, you’ll again be able to rock out with audio from your Mac or PC playing through your Apple TV.

Airfoil Updates Still To Come

Airfoil IconAirfoil Satellite TV restores the ability to use your Apple TV as a receiver for Airfoil, but it must be running in the foreground. As discussed in our previous post, we’ve also been working in parallel to restore Airfoil’s ability to stream directly to the Apple TV without no app required.

We’ve recently completed the preliminary work to enable Airfoil to connect with tvOS-based Apple TVs, and we’re working on bringing the functionality into Airfoil. Once that’s ready, we’ll ship free updates for Airfoil for Mac and Airfoil for Windows. While we can’t yet give release dates for these updates, you can be sure we’re working hard to get them to you as soon as possible.

Updates on Airfoil and the Newest Apple TVs

Update (April 23rd, 2017): Airfoil Satellite TV is now available for Apple TV’s running tvOS 10.2. See this post for full details.


Late last month, we alerted users to an incompatibility between Airfoil and Apple TVs running tvOS 10.2. We’ve since been hard at work on restoring the ability to stream audio from Airfoil to the newest Apple TVs. We’ve attacked this problem in two ways, and while we’re not finished yet, we’re now close to a pair of solutions to get things working for our users.

Long-Term Solution: Airfoil Updates

Airfoil IconWe’re working diligently to restore Airfoil’s ability to stream directly to the Apple TV. We know our users want to stream audio from their Macs and PCs to Apple TVs, and we’re incredibly eager to get this functionality back for you. This work has required a great deal of research, along with no small amount of reverse engineering, and that unfortunately takes time.

Happily, we’ve recently completed the preliminary work to enable Airfoil to connect with tvOS-based Apple TVs. We now have a working prototype for this, and we’re working on bringing the functionality into Airfoil. Once that’s ready, we’ll ship free updates for Airfoil for Mac and Airfoil for Windows. While we can’t yet give release dates for these updates, you can be sure we’re working hard to get them to you.

Interim Solution: Airfoil Satellite TV

Airfoil Satellite TV IconIn parallel with our work on Airfoil itself, we’ve also been working on a second solution to enable you to stream audio from your computer to the Apple TV. Yesterday, we submitted the results of this work to the App Store, in the form of a new app called Airfoil Satellite TV.

You may know that the Airfoil Satellite name is used for applications which enable various devices to act as audio receivers for Airfoil. With Airfoil Satellite running on a device, Airfoil sees that device as an output to which it can stream audio. When your Apple TV is running Airfoil Satellite TV, you’ll again be able to send audio from your Mac or Windows machine to tvOS-based Apple TVs.

At this point, we’re just waiting on Apple and the App Store review process to get the first version of Airfoil Satellite TV to you. We’ll post just as soon as it’s available.

Almost There

We hope to have Airfoil Satellite TV approved and in the App Store very soon. Once that’s available, all Apple TV users will be again be able to receive audio from their Macs and PCs using Airfoil.

Soon after that, we’ll be providing free updates to Airfoil for Mac and Airfoil for Windows, enabling Airfoil to talk directly to the newest Apple TVs without requiring any other software. These Airfoil updates will take a bit longer, but we’ll have more news on them soon.

We’re certainly sorry for this temporary loss of functionality in Airfoil, and we’re working diligently to have the problem resolved very soon. Thank you for your patience, and please stay tuned for updates.

Airfoil & Apple TV Users Should Avoid tvOS 10.2

Update (April 23rd, 2017): We’ve now released Airfoil Satellite TV, a free app for the newest models of Apple TV. With Airfoil Satellite TV, Airfoil can again send audio to your tvOS-based Apple TV. Updates to Airfoil, which will restore streaming directly to the Apple TV without requiring a receiver app, are still in the works.

Get the free Airfoil Satellite TV by searching for it in the App Store right on your Apple TV. If you have automatic downloading turned on for your Apple TV, you can also click this link to get the app.


Summary: To prevent loss of connectivity with Airfoil, Apple TV users should not upgrade to tvOS 10.2 at this time.

On March 27th, Apple released tvOS 10.2 for the latest generation of Apple TV. Changes made by Apple in this update have broken Airfoil’s ability to transmit audio to the newest generation of Apple TV. This issue affects both Airfoil for Mac and Airfoil for Windows, and prevents Airfoil from successfully sending audio to the Apple TV. If your Apple TV is still running tvOS 10.1.1 (or lower), stick with that for now to maintain connectivity with Airfoil.

Next Steps

We’re currently researching this problem, and hope to work around Apple’s changes with a future update. In the meantime, Airfoil users should avoid tvOS 10.2, sticking with their current version of tvOS instead. Be sure to disable automatic updates on the Apple TV as well. You can do this by going to Settings -> System -> Software Updates, and toggling “Automatically Update” to Off.

More to Come

We’ll post more news as soon as we have it, so watch this blog, as well as our Twitter account. When a new version is available, Airfoil itself can alert you, so be sure Software Update is on in the Preferences.

The Flexibility of Audio Hijack 3

Audio Hijack IconOver at Six Colors, Jason Snell recently wrote about two different ways he uses Audio Hijack 3 to record audio for his podcasts. Jason covers both recording (and live-streaming) his audio when all his guests are remote, as well as using Audio Hijack to record multiple parties in the same room. If you’re curious to learn more about how podcasters do their work with Audio Hijack (as well as Loopback and Nicecast, or you’re interested to start your own podcast, this is a great post.

These sorts of set-ups are exactly how we hoped Audio Hijack 3 would be used when we were designing it. We knew the new design would enable all manner of great new uses. For instance, making it possible record to multiple files in one Audio Hijack Session was certain to be powerful, but it’s not always easy to see if and how that power is being used. It’s very gratifying to see our work put to such good use by others!

JavaScript: Correctly Converting a Byte Array to a UTF-8 String

As you may know, the release of Airfoil for Mac 5.5 added support for streaming audio from your Mac to Google Chromecast devices. Despite the fact that Chromecast and AirPlay receivers perform very similar functions, their internal workings are very different, and making it all work together was no small feat. Streaming audio to the Chromecast actually required us to write our own custom receiver application to run on that device itself.

Chromecast applications are written in JavaScript, and while we’ve covered a lot of ground over the years, creating a network audio player in JavaScript was definitely a new challenge. While working on this, we encountered one particularly interesting problem which didn’t seem to have a ready-made solution. After much fruitless web searching, we ultimately solved this problem ourselves, and feel that solution is worth sharing with the world at large. Non-programmer users may wish to stop reading here (go check out Airfoil for Mac if you haven’t seen it yet!), but JavaScript coders, this is for you.

A JavaScript Problem

This issue we ran into was accurately rendering metadata strings — the information on what artist and song is currently playing. Airfoil converts these strings to a stream of bytes and sends them across the network to the Chromecast receiver, which converts them back to a string for display. This sounds simple enough, but there’s a catch: Many metadata strings require special handling.

An easy example of this is accented characters, as seen in band names ranging from Queensrÿche to Sigur Rós. When converting this text to a stream of bytes, the special characters need to be encoded with something like UTF-8. When converting from a stream of bytes back to a string, the UTF-8 must be decoded back the right special characters. This is a very old, very solved problem, but it is still surprisingly easy to screw it up.

Searching for “JavaScript convert bytes to string” will bring you to numerous code samples and Stack Overflow questions. Nearly all of these answers are wrong, or at least incomplete when it comes to correctly handling UTF-8 strings. The code samples generally look like this:

  function stringFromArray(data)
  {
    var count = data.length;
    var str = "";
    
    for(var index = 0; index < count; index += 1)
      str += String.fromCharCode(data[index]);
    
    return str;
  }

While this works fine for simple ASCII strings, it fails to correctly decode strings that contain special characters such as accented characters. The problem is that special characters get encoded into multi-byte sequences, but the simple loop calling fromCharCode() will treat every byte as if it were a single character. Special characters go in, and mangled sequences of ASCII come out.


Top: Mangled; Bottom: Correct

Our JavaScript Solution

Modern string handling means dealing with UTF-8 and correctly handling special characters, so this is a common problem that should have lots of proper solutions. Unfortunately, further searching for something like “JavaScript convert UTF-8 encoded bytes to string” currently provides no additional help, instead resulting in the same wrong results as the previous query.

Hopefully, we can change that. Here’s the solution for converting bytes to a string that we worked out, which correctly handles UTF-8 encoded special characters:

  function stringFromUTF8Array(data)
  {
    const extraByteMap = [ 1, 1, 1, 1, 2, 2, 3, 0 ];
    var count = data.length;
    var str = "";
    
    for (var index = 0;index < count;)
    {
      var ch = data[index++];
      if (ch & 0x80)
      {
        var extra = extraByteMap[(ch >> 3) & 0x07];
        if (!(ch & 0x40) || !extra || ((index + extra) > count))
          return null;
        
        ch = ch & (0x3F >> extra);
        for (;extra > 0;extra -= 1)
        {
          var chx = data[index++];
          if ((chx & 0xC0) != 0x80)
            return null;
          
          ch = (ch << 6) | (chx & 0x3F);
        }
      }
      
      str += String.fromCharCode(ch);
    }
    
    return str;
  }

As you can see, our version is longer than the commonly found, and incorrect examples. That additional code provides two big improvements. First, it will translate multi-byte UTF-8 sequences correctly, thereby preserving any special characters. As well, it will pick up on invalid UTF-8 sequences, so data corruption can be detected.

Hopefully, this solution will prove useful to future JavaScript coders! Remember, converting bytes to a string requires attention to special characters, and our more robust solution above should help.

Our Software