Merge "AudioFormat: implement ENCODING_IEC61937" into nyc-dev

This commit is contained in:
Phil Burk
2016-02-12 22:24:53 +00:00
committed by Android (Google) Code Review
3 changed files with 9 additions and 4 deletions

View File

@@ -31,6 +31,7 @@
#define ENCODING_AAC_LC 10
#define ENCODING_AAC_HE_V1 11
#define ENCODING_AAC_HE_V2 12
#define ENCODING_IEC61937 13
#define ENCODING_INVALID 0
#define ENCODING_DEFAULT 1
@@ -64,6 +65,8 @@ static inline audio_format_t audioFormatToNative(int audioFormat)
return AUDIO_FORMAT_AAC_HE_V1;
case ENCODING_AAC_HE_V2:
return AUDIO_FORMAT_AAC_HE_V2;
case ENCODING_IEC61937:
return AUDIO_FORMAT_IEC61937;
case ENCODING_DEFAULT:
return AUDIO_FORMAT_DEFAULT;
default:
@@ -103,6 +106,8 @@ static inline int audioFormatFromNative(audio_format_t nativeFormat)
return ENCODING_AAC_HE_V1;
case AUDIO_FORMAT_AAC_HE_V2:
return ENCODING_AAC_HE_V2;
case AUDIO_FORMAT_IEC61937:
return ENCODING_IEC61937;
case AUDIO_FORMAT_DEFAULT:
return ENCODING_DEFAULT;
default:

View File

@@ -246,7 +246,7 @@ android_media_AudioTrack_setup(JNIEnv *env, jobject thiz, jobject weak_this,
// compute the frame count
size_t frameCount;
if (audio_is_linear_pcm(format)) {
if (audio_has_proportional_frames(format)) {
const size_t bytesPerSample = audio_bytes_per_sample(format);
frameCount = buffSizeInBytes / (channelCount * bytesPerSample);
} else {
@@ -1008,7 +1008,7 @@ static jint android_media_AudioTrack_get_min_buff_size(JNIEnv *env, jobject thi
return -1;
}
const audio_format_t format = audioFormatToNative(audioFormat);
if (audio_is_linear_pcm(format)) {
if (audio_has_proportional_frames(format)) {
const size_t bytesPerSample = audio_bytes_per_sample(format);
return frameCount * channelCount * bytesPerSample;
} else {

View File

@@ -885,10 +885,10 @@ public class AudioTrack implements AudioRouting
// postcondition:
// mNativeBufferSizeInBytes is valid (multiple of frame size, positive)
private void audioBuffSizeCheck(int audioBufferSize) {
// NB: this section is only valid with PCM data.
// NB: this section is only valid with PCM or IEC61937 data.
// To update when supporting compressed formats
int frameSizeInBytes;
if (AudioFormat.isEncodingLinearPcm(mAudioFormat)) {
if (AudioFormat.isEncodingLinearFrames(mAudioFormat)) {
frameSizeInBytes = mChannelCount * AudioFormat.getBytesPerSample(mAudioFormat);
} else {
frameSizeInBytes = 1;