Exclusive Access

From JRiverWiki
Jump to: navigation, search

Both Microsoft's WASAPI system and Apple's Core Audio API provide software with the ability to open audio streams in exclusive mode. This provides a number of benefits, the primary of which is more direct and lower-latency access to the audio hardware. Media Center enables this option by default when you choose WASAPI or Core Audio as your Audio Output Mode. This setting can be toggled on and off via:

Tools > Options > Audio > Audio Device > Device settings > Open device for exclusive access

Open device for exclusive access is recommended, but it is good to understand how it works.

When Exclusive Access is enabled, then:

  • When you start playback, Media Center sends an exclusive-mode stream. If another audio device is currently using the audio hardware, the request for exclusive access is rejected, and playback fails.
  • While playback is active (including while paused) in Media Center, no other application on the system can use the specified audio device. Applications that attempt to play sound (such as system sounds or a web browser) will typically be automatically assigned to an alternate (perhaps disconnected) audio output on the computer, or playback will fail entirely.
  • As soon as playback is stopped in Media Center, the audio device again becomes available to the system for use by other applications.

This allows Media Center to completely control the audio output, set any supported bitdepth and sample rate, and prevent other applications from interfering with the audio output. It is the recommended setting for WASAPI and Core Audio, and it is enabled in Media Center by default.

Requirements

Windows-Sound Properties Advanced.png

Exclusive Access requires:

  • An audio device driver that supports this mode.
  • A selected Audio Output Mode that supports Exclusive Access (such as WASAPI on Windows, or Core Audio on OSX).
  • In Windows under WASAPI, that Allow applications to take exclusive control of this device is enabled in the Advanced tab of the device's Properties dialog.

Most standard Windows and OS X drivers for common audio hardware now properly support exclusive mode, though you may have difficulty with older hardware and with virtual sound devices included as part of virtual machines. Windows should default to allowing exclusive access (as described above), but you can verify this by:

  1. Open the Sound control panel in Windows
  2. Select your device and click Properties.
  3. Switch to the Advanced tab.
  4. Ensure that Allow applications to take exclusive control of this device and Give exclusive mode applications priority are both enabled.

Benefits and Considerations

Exclusive Access provides a number of sound quality and ease-of-use advantages, including:

  • It can play files of any sample rate natively, as long as your audio device supports the given sample rate. In Exclusive Mode it does not matter what Default Format is selected in the audio device's properties dialog on Windows, or in the Audio MIDI Setup utility on OSX. MC can "take control" and play any file supported natively by the audio device without resampling.
  • It can use your audio device's best supported bitdepth (which it does automatically).
  • It can directly control the number of output channels. This means that it can use a multichannel output even if the Speaker Configuration in the OS is set to Stereo-only. This is sometimes convenient when using Media Center with a Home Theater surround system and receiver, because you can set the OS default format to Stereo and allow the receiver to upconvert stereo sources to surround (for web browser audio and other applications). In Exclusive Mode, Media Center will still use the number of channels selected in the Output Format DSP, regardless of the OS's Speaker Configuration setting.
  • It allows you to effectively use the Maximize device volume during playback feature to bypass your device's volume control and enable convenient use of MC's Internal Volume control.
  • It provides a much lower latency and hardware direct method for accessing and controlling the audio device.

However, this means that while MC is playing or paused, your audio device will be locked out from use by other applications on the system. You can't, for example:

  • Play a game with sound effects while listening to music
  • Watch a web video with sound while MC is playing something else.
  • Capture MC's audio output through other software applications like Audio Hijack Pro or Camtasia Studio.
  • Hear system sound alerts like email notifications and calendar alerts.

Disabling Exclusive Access

You can disable Exclusive Access by either:

  • unchecking the Open device for exclusive access box in the Tools > Options > Audio > Audio Device > Device Settings dialog.
  • switching the audio output mode to one that does not support Exclusive Access, such as DirectSound.
The Exclusive Access setting

Issues with Disabling Exclusive Access in WASAPI

As described above, in WASAPI with Exclusive Mode enabled, Media Center can play any audio file natively without resampling. This means, for example, that audio files sourced from CD will play at their native 44.1kHz and audio from DVD and other video sources will play with their native 48kHz sample rate. It doesn't matter what the Default Format for the audio device is set to, as the OS does not need to resample and can play the file natively. Therefore, you can set MC's Output Format DSP to only resample those audio formats that your particular audio device does not support natively.

On the other hand, unlike in the older Direct Sound API, Shared-mode WASAPI on Windows provides no automatic resampling. Therefore, with Exclusive Access disabled, Media Center must resample all audio output to match the currently selected Default format in Windows. Otherwise, playback will fail, because the audio device can't accept multiple streams in different formats simultaneously without resampling. This often manifests when you try to play files with differing sample rates. So, if the Default Format is set to 44.1kHz, you may not notice until you try to play a 48kHz video file, or the reverse.

This is the error dialog you'll see if you play any format other than the system's Default with Exclusive Mode disabled.

If you disable Exclusive Mode in WASAPI on Windows, then you must set Media Center's Output Format DSP to resample all audio to match the format you have selected as the Default Format for the audio device. In WASAPI non-Exclusive mode, the Windows Default Format setting now becomes the only output setting that MC can use, and you must resample all other formats to match this format.

Without Exclusive Access, this will be the only format that will play successfully.
Please Note: Core Audio on OS X does not suffer from the sample rate limitation, as it automatically switches the format and resamples as is needed on the fly. However, if you want to be sure to preserve the original format of your audio file and play them natively, Exclusive Mode is still recommended as it prevents other applications from changing the output format.

Alternatives to Disabling Exclusive Access

As described above, using Exclusive Access in Media Center provides substantial flexibility for MC to provide the best possible sound quality for your hardware. That's why it is the default and recommended setting. However, there are some cases where you may want to occasionally disable this to accomplish a particular task (such as those described above in the Benefits and Considerations section).

Rather than disabling Exclusive Access entirely, or switching to a lesser quality mode that doesn't support it, you can make a second Zone in Media Center that uses the same output, and use this Zone instead when you need to accomplish those tasks, while keeping your "regular" Zone set with Exclusive Access enabled for general usage.

To do this:

  1. Go to Player > Zone > Add Zone.
  2. In the Add Zone dialog that appears, give the new Zone a clear name (such as "Non-Exclusive").
  3. Select your current regular Zone in the Copy combobox.
  4. Click OK to add the Zone.

Then, switch to your newly created Zone and modify the settings there to either:

  • Disable Exclusive Access and enable resampling in the Output Format DSP.
  • Switch your Audio Device to a mode that doesn't support Exclusive Access, such as DirectSound.

Since Audio settings and DSP settings are applied per-Zone, this will not modify the settings in your original "standard" Zone. But, any time you need to play music while you are playing the latest Battlefield, you can switch MC to this alternate zone and you will be able to use it alongside other applications.