Java Code Examples for android.media.AudioFormat#CHANNEL_OUT_7POINT1_SURROUND

The following examples show how to use android.media.AudioFormat#CHANNEL_OUT_7POINT1_SURROUND . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MediaCodecBridge.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
private int getAudioFormat(int channelCount) {
    switch (channelCount) {
        case 1:
            return AudioFormat.CHANNEL_OUT_MONO;
        case 2:
            return AudioFormat.CHANNEL_OUT_STEREO;
        case 4:
            return AudioFormat.CHANNEL_OUT_QUAD;
        case 6:
            return AudioFormat.CHANNEL_OUT_5POINT1;
        case 8:
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                return AudioFormat.CHANNEL_OUT_7POINT1_SURROUND;
            } else {
                return AudioFormat.CHANNEL_OUT_7POINT1;
            }
        default:
            return AudioFormat.CHANNEL_OUT_DEFAULT;
    }
}
 
Example 2
Source File: SonicAudioPlayer.java    From AntennaPod-AudioPlayer with Apache License 2.0 6 votes vote down vote up
private static int findFormatFromChannels(int numChannels) {
    switch (numChannels) {
        case 1:
            return AudioFormat.CHANNEL_OUT_MONO;
        case 2:
            return AudioFormat.CHANNEL_OUT_STEREO;
        case 3:
            return AudioFormat.CHANNEL_OUT_STEREO | AudioFormat.CHANNEL_OUT_FRONT_CENTER;
        case 4:
            return AudioFormat.CHANNEL_OUT_QUAD;
        case 5:
            return AudioFormat.CHANNEL_OUT_QUAD | AudioFormat.CHANNEL_OUT_FRONT_CENTER;
        case 6:
            return AudioFormat.CHANNEL_OUT_5POINT1;
        case 7:
            return AudioFormat.CHANNEL_OUT_5POINT1 | AudioFormat.CHANNEL_OUT_BACK_CENTER;
        case 8:
            if (Build.VERSION.SDK_INT >= 23) {
                return AudioFormat.CHANNEL_OUT_7POINT1_SURROUND;
            } else {
                return -1;
            }
        default:
            return -1; // Error
    }
}
 
Example 3
Source File: Util.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the audio track channel configuration for the given channel count, or {@link
 * AudioFormat#CHANNEL_INVALID} if output is not poossible.
 *
 * @param channelCount The number of channels in the input audio.
 * @return The channel configuration or {@link AudioFormat#CHANNEL_INVALID} if output is not
 *     possible.
 */
public static int getAudioTrackChannelConfig(int channelCount) {
  switch (channelCount) {
    case 1:
      return AudioFormat.CHANNEL_OUT_MONO;
    case 2:
      return AudioFormat.CHANNEL_OUT_STEREO;
    case 3:
      return AudioFormat.CHANNEL_OUT_STEREO | AudioFormat.CHANNEL_OUT_FRONT_CENTER;
    case 4:
      return AudioFormat.CHANNEL_OUT_QUAD;
    case 5:
      return AudioFormat.CHANNEL_OUT_QUAD | AudioFormat.CHANNEL_OUT_FRONT_CENTER;
    case 6:
      return AudioFormat.CHANNEL_OUT_5POINT1;
    case 7:
      return AudioFormat.CHANNEL_OUT_5POINT1 | AudioFormat.CHANNEL_OUT_BACK_CENTER;
    case 8:
      if (Util.SDK_INT >= 23) {
        return AudioFormat.CHANNEL_OUT_7POINT1_SURROUND;
      } else if (Util.SDK_INT >= 21) {
        // Equal to AudioFormat.CHANNEL_OUT_7POINT1_SURROUND, which is hidden before Android M.
        return AudioFormat.CHANNEL_OUT_5POINT1
            | AudioFormat.CHANNEL_OUT_SIDE_LEFT
            | AudioFormat.CHANNEL_OUT_SIDE_RIGHT;
      } else {
        // 8 ch output is not supported before Android L.
        return AudioFormat.CHANNEL_INVALID;
      }
    default:
      return AudioFormat.CHANNEL_INVALID;
  }
}
 
Example 4
Source File: Util.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the audio track channel configuration for the given channel count, or {@link
 * AudioFormat#CHANNEL_INVALID} if output is not poossible.
 *
 * @param channelCount The number of channels in the input audio.
 * @return The channel configuration or {@link AudioFormat#CHANNEL_INVALID} if output is not
 *     possible.
 */
public static int getAudioTrackChannelConfig(int channelCount) {
  switch (channelCount) {
    case 1:
      return AudioFormat.CHANNEL_OUT_MONO;
    case 2:
      return AudioFormat.CHANNEL_OUT_STEREO;
    case 3:
      return AudioFormat.CHANNEL_OUT_STEREO | AudioFormat.CHANNEL_OUT_FRONT_CENTER;
    case 4:
      return AudioFormat.CHANNEL_OUT_QUAD;
    case 5:
      return AudioFormat.CHANNEL_OUT_QUAD | AudioFormat.CHANNEL_OUT_FRONT_CENTER;
    case 6:
      return AudioFormat.CHANNEL_OUT_5POINT1;
    case 7:
      return AudioFormat.CHANNEL_OUT_5POINT1 | AudioFormat.CHANNEL_OUT_BACK_CENTER;
    case 8:
      if (Util.SDK_INT >= 23) {
        return AudioFormat.CHANNEL_OUT_7POINT1_SURROUND;
      } else if (Util.SDK_INT >= 21) {
        // Equal to AudioFormat.CHANNEL_OUT_7POINT1_SURROUND, which is hidden before Android M.
        return AudioFormat.CHANNEL_OUT_5POINT1
            | AudioFormat.CHANNEL_OUT_SIDE_LEFT
            | AudioFormat.CHANNEL_OUT_SIDE_RIGHT;
      } else {
        // 8 ch output is not supported before Android L.
        return AudioFormat.CHANNEL_INVALID;
      }
    default:
      return AudioFormat.CHANNEL_INVALID;
  }
}
 
Example 5
Source File: Util.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the audio track channel configuration for the given channel count, or {@link
 * AudioFormat#CHANNEL_INVALID} if output is not poossible.
 *
 * @param channelCount The number of channels in the input audio.
 * @return The channel configuration or {@link AudioFormat#CHANNEL_INVALID} if output is not
 *     possible.
 */
public static int getAudioTrackChannelConfig(int channelCount) {
  switch (channelCount) {
    case 1:
      return AudioFormat.CHANNEL_OUT_MONO;
    case 2:
      return AudioFormat.CHANNEL_OUT_STEREO;
    case 3:
      return AudioFormat.CHANNEL_OUT_STEREO | AudioFormat.CHANNEL_OUT_FRONT_CENTER;
    case 4:
      return AudioFormat.CHANNEL_OUT_QUAD;
    case 5:
      return AudioFormat.CHANNEL_OUT_QUAD | AudioFormat.CHANNEL_OUT_FRONT_CENTER;
    case 6:
      return AudioFormat.CHANNEL_OUT_5POINT1;
    case 7:
      return AudioFormat.CHANNEL_OUT_5POINT1 | AudioFormat.CHANNEL_OUT_BACK_CENTER;
    case 8:
      if (Util.SDK_INT >= 23) {
        return AudioFormat.CHANNEL_OUT_7POINT1_SURROUND;
      } else if (Util.SDK_INT >= 21) {
        // Equal to AudioFormat.CHANNEL_OUT_7POINT1_SURROUND, which is hidden before Android M.
        return AudioFormat.CHANNEL_OUT_5POINT1
            | AudioFormat.CHANNEL_OUT_SIDE_LEFT
            | AudioFormat.CHANNEL_OUT_SIDE_RIGHT;
      } else {
        // 8 ch output is not supported before Android L.
        return AudioFormat.CHANNEL_INVALID;
      }
    default:
      return AudioFormat.CHANNEL_INVALID;
  }
}