Plex Media Center for OS X Leopard

+ Top FAQs with Plex - for more help please check the WIKI.

Plex/Seven: New CoreAudio output module

Back when I was first getting audio output to work with the media center on OS X, I decided to use the PortAudio library. It’s portable, powerful, and I was already familiar with it, having used it on a previous job.

The downside to PortAudio turned out to be its lack of support for doing passthrough of encoded digital audio streams like AC3 and DTS. I always figured that a digital audio stream was just bits, and if the stream was set to the right bit-width and sample rate, encoded audio would work fine. It turns out I was only partially right; most receivers will accept this stream and lock onto the encoded audio. However, they’re only doing that because they’re being liberal about what they accept. The bitstream is actually lacking lower-level S/PDIF bits (meaning that they can’t be set at the application level) making it an official encoded audio stream. This meant that some receivers, acting by the letter of the law (like the one owned by poor fatez) refused to interpret the stream as encoded digital audio.

We first knew this was a problem around 8 months ago, which makes it the longest running Plex bug in history. The first person to tackle the problem was Brandon Golm. He worked extremely hard over several months on enhancing Portaudio with support for passthrough. However, the CoreAudio code in PortAudio isn’t the easiest to modify, and this approach (which I suggested and accept full blame for) didn’t end up coming to fruition.

Enter our resident Plex audio expert Ryan (who, incidentally, was one of the very first people to contribute code to the OSXBMC project!). Ryan took an interest in the problem and decided to approach it by porting VLC’s CoreAudio output module to Plex. After a enormous amount of hard work, the day finally arrived when he could claim victory:

untitled.jpg
Besides supporting all receivers, the new code has the following advantages:
  • Auto-detection of whether devices support encoded digital output. This is extremely useful for not getting your ears blasted with static, since when you switch from your Built-in Digital Output to your Logitech Headset, it will switch automatically to analog mode.

untitled.jpg

  • Increased flexibility: Interestingly enough, there are some audio devices (e.g. some external USB or Firewire devices) which don’t show up under CoreAudio as supporting encoded digital audio (S/PDIF). In this case, you can switch the digital output support to “Force Digital” and it will send audio to the device encoded “unofficially”. This means it likely won’t work with fatez’s receiver, but it is useful in some scenarios.

untitled.jpg

  • Improved lip-sync: the new code monitors the hardware latency reported by CoreAudio, so Plex is able to provide better synchronization between video and audio.

The new output module, coupled with the AC3 transcoding ability Ryan added back in Plex/Five (which allows converting 5.1 AAC and DTS stream to AC3), means that Plex now has — hands down — the absolute finest audio output features of any media center on the Mac, if not across all platforms.

23 Comments so far

  1. tv November 11th, 2008 11:59 pm

    Great work! Does this also mean it now supports multichannel _analog_ streams?

  2. Jalanr November 12th, 2008 12:07 am

    Wowww guys… when can we put our hands in the new version?
    :-)
    Great improvements and great job as usual.

  3. sej7278 November 12th, 2008 1:36 am

    does this fix the incredibly low analogue volume of Plex on mac mini’s, which is not a problem with VLC?

  4. Weavus November 12th, 2008 1:48 am

    The first two features were a bit ‘meh’ for me but this one is stonking! Can’t wait to test it out…

  5. max November 12th, 2008 4:44 am

    awesome :D! you guys rock!

  6. JG November 12th, 2008 5:00 am

    I love what you guys are doing. From the first time I installed OSXBMC to the Plex it is now has been a great improvement! I already like the new interface much more than the old. I love that you are working on making all the settings less confusing, this is one of my greatest irritations indeed. I would however like to see this minimalisation treatment applied to the skin as well. I find all the background pictures very distracting and would love a more appletv-like, clean interface. Not sure how everyone else feels about it, of course.
    Keep up the good work!

  7. Nat November 12th, 2008 5:03 am

    You guys are so rad.

  8. Magnus November 12th, 2008 5:41 am

    Great work! I’ve been waiting for this! Really looking forward to seven.

  9. rfritz November 12th, 2008 5:57 am

    Oh YEAH! ..can not wait HUGE THANKS

  10. Anville November 12th, 2008 6:23 am

    These daily revelations are like a Plex Advent calendar :-)

  11. BitPerfect November 12th, 2008 6:26 am

    Excellent! Now almost all that is missing audio wise is bit-perfect pass-through output of all files that are not 48kHz for those of us who have receiver that are capable. I think this project best explain the properties of bit perfect playback http://code.google.com/p/cmediadrivers/wiki/Bitperfect

    XBMC is also lacking this bitperfect playback capability as a legacy from the Xbox days http://xbmc.org/trac/ticket/4731

    Another thing is optional pass-through output of MP3, AAC, and WMA 9 Pro as many newer receivers are capable of decoding those type of streams nativly as well

  12. Bob Funn November 12th, 2008 8:43 am

    Its this attention to detail that makes this project a cut above so many others. thanks for the great work!

  13. jmarshall November 12th, 2008 9:52 am

    Now that you have something working, can these changes be taken upstream into portaudio? I’m sure other users of portaudio would be most grateful to not have to reinvent the wheel (again) in this regard. If it’s done in the common library, it’s available to all.

  14. elan November 12th, 2008 10:10 am

    @jmarshall: As I mentioned, we abandoned efforts to make the changes in Portaudio and instead ported VLC’s CoreAudio module.

  15. elan November 12th, 2008 10:19 am

    @tv: I believe Ryan said something like “If someone wanted to ship me one of those interfaces, I’d be happy to get it working!”

    @Jalanr: Release date is 11/16.

    @sej7278: That’s a problem with down-mixing and a lack of amplification. Not fixed with this code.

    @BitPerfect: Hadn’t considered passthrough of those other codecs, interesting thought.

  16. Neckaros November 12th, 2008 12:35 pm

    Thank you!!! i hope it will work with my receiver.

  17. symm November 12th, 2008 2:12 pm

    @elan: quote “Release date is 10/16.”

    Please tell me you meant 11/16 (not 10/16/09)…

    ;)

  18. elan November 12th, 2008 2:18 pm

    @symm: Well, these are all hypothetical features, so we’re hoping for 10/2009, but it could be 10/2010 as well.

    You’re absolutely right, I meant a few days from now :)

  19. Arjen November 13th, 2008 5:06 am

    That’s great news, I’ve been looking for a solution to fix lipsync issues. Will it be possible to adjust audio delay, or is the hardware detection enough?

    Lots of kudo’s,

    Arjen

  20. rwk November 14th, 2008 4:00 am

    Will it support Dolby TrueHD in .m2ts bluray titles?

  21. elan November 14th, 2008 4:59 am

    @Arjen: Yes, still possible to adjust delay yourself.

    @rwk: No difference with this feature.

  22. BitPerfect November 17th, 2008 1:56 am

    Great! I am personally really looking forward to bit perfect pass-thru, especially for Blu-ray and HD DVD backups with 24Bit at 192KHz audio streams, both Dolby TrueHD and DTS-HD Master Audio formats.

    Also bitperfect playback of basic MP3 and AAC music files at 44,1KHz without any resampling would be superb.

    Today there is no software on Mac which offers all this, however on Windows there is both MediaPortal and Foobar2000, but no XBMC based software.

  23. homesnake November 18th, 2008 5:54 pm

    Wow - I just loaded this version, and my audio delay problems disappeared! I’m using a Griffin firewave. Going to try some hi def content tonight. Good work on the core audio stuff guys…

    Plex is the best!

Leave a reply