Merge "Map >= 24bit encodings to ENCODING_PCM_FLOAT" into mnc-dev
This commit is contained in:
@@ -80,6 +80,13 @@ static inline int audioFormatFromNative(audio_format_t nativeFormat)
|
|||||||
return ENCODING_PCM_8BIT;
|
return ENCODING_PCM_8BIT;
|
||||||
case AUDIO_FORMAT_PCM_FLOAT:
|
case AUDIO_FORMAT_PCM_FLOAT:
|
||||||
return ENCODING_PCM_FLOAT;
|
return ENCODING_PCM_FLOAT;
|
||||||
|
|
||||||
|
// map these to ENCODING_PCM_FLOAT
|
||||||
|
case AUDIO_FORMAT_PCM_8_24_BIT:
|
||||||
|
case AUDIO_FORMAT_PCM_24_BIT_PACKED:
|
||||||
|
case AUDIO_FORMAT_PCM_32_BIT:
|
||||||
|
return ENCODING_PCM_FLOAT;
|
||||||
|
|
||||||
case AUDIO_FORMAT_AC3:
|
case AUDIO_FORMAT_AC3:
|
||||||
return ENCODING_AC3;
|
return ENCODING_AC3;
|
||||||
case AUDIO_FORMAT_E_AC3:
|
case AUDIO_FORMAT_E_AC3:
|
||||||
|
|||||||
@@ -832,6 +832,15 @@ exit:
|
|||||||
return jStatus;
|
return jStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool hasFormat(int* formats, size_t size, int format) {
|
||||||
|
for (size_t index = 0; index < size; index++) {
|
||||||
|
if (formats[index] == format) {
|
||||||
|
return true; // found
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false; // not found
|
||||||
|
}
|
||||||
|
|
||||||
static jint convertAudioPortFromNative(JNIEnv *env,
|
static jint convertAudioPortFromNative(JNIEnv *env,
|
||||||
jobject *jAudioPort, const struct audio_port *nAudioPort)
|
jobject *jAudioPort, const struct audio_port *nAudioPort)
|
||||||
{
|
{
|
||||||
@@ -839,6 +848,7 @@ static jint convertAudioPortFromNative(JNIEnv *env,
|
|||||||
jintArray jSamplingRates = NULL;
|
jintArray jSamplingRates = NULL;
|
||||||
jintArray jChannelMasks = NULL;
|
jintArray jChannelMasks = NULL;
|
||||||
jintArray jChannelIndexMasks = NULL;
|
jintArray jChannelIndexMasks = NULL;
|
||||||
|
int* cFormats = NULL;
|
||||||
jintArray jFormats = NULL;
|
jintArray jFormats = NULL;
|
||||||
jobjectArray jGains = NULL;
|
jobjectArray jGains = NULL;
|
||||||
jobject jHandle = NULL;
|
jobject jHandle = NULL;
|
||||||
@@ -846,7 +856,7 @@ static jint convertAudioPortFromNative(JNIEnv *env,
|
|||||||
bool useInMask;
|
bool useInMask;
|
||||||
size_t numPositionMasks = 0;
|
size_t numPositionMasks = 0;
|
||||||
size_t numIndexMasks = 0;
|
size_t numIndexMasks = 0;
|
||||||
|
size_t numUniqueFormats;
|
||||||
ALOGV("convertAudioPortFromNative id %d role %d type %d name %s",
|
ALOGV("convertAudioPortFromNative id %d role %d type %d name %s",
|
||||||
nAudioPort->id, nAudioPort->role, nAudioPort->type, nAudioPort->name);
|
nAudioPort->id, nAudioPort->role, nAudioPort->type, nAudioPort->name);
|
||||||
|
|
||||||
@@ -897,15 +907,20 @@ static jint convertAudioPortFromNative(JNIEnv *env,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// formats
|
// formats
|
||||||
jFormats = env->NewIntArray(nAudioPort->num_formats);
|
cFormats = new int[nAudioPort->num_formats];
|
||||||
|
numUniqueFormats = 0;
|
||||||
|
for (size_t index = 0; index < nAudioPort->num_formats; index++) {
|
||||||
|
int format = audioFormatFromNative(nAudioPort->formats[index]);
|
||||||
|
if (!hasFormat(cFormats, numUniqueFormats, format)) {
|
||||||
|
cFormats[numUniqueFormats++] = format;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jFormats = env->NewIntArray(numUniqueFormats);
|
||||||
if (jFormats == NULL) {
|
if (jFormats == NULL) {
|
||||||
jStatus = (jint)AUDIO_JAVA_ERROR;
|
jStatus = (jint)AUDIO_JAVA_ERROR;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
for (size_t j = 0; j < nAudioPort->num_formats; j++) {
|
env->SetIntArrayRegion(jFormats, 0, numUniqueFormats, cFormats);
|
||||||
jint jFormat = audioFormatFromNative(nAudioPort->formats[j]);
|
|
||||||
env->SetIntArrayRegion(jFormats, j, 1, &jFormat);
|
|
||||||
}
|
|
||||||
|
|
||||||
// gains
|
// gains
|
||||||
jGains = env->NewObjectArray(nAudioPort->num_gains,
|
jGains = env->NewObjectArray(nAudioPort->num_gains,
|
||||||
@@ -1000,6 +1015,12 @@ exit:
|
|||||||
if (jChannelMasks != NULL) {
|
if (jChannelMasks != NULL) {
|
||||||
env->DeleteLocalRef(jChannelMasks);
|
env->DeleteLocalRef(jChannelMasks);
|
||||||
}
|
}
|
||||||
|
if (jChannelIndexMasks != NULL) {
|
||||||
|
env->DeleteLocalRef(jChannelIndexMasks);
|
||||||
|
}
|
||||||
|
if (cFormats != NULL) {
|
||||||
|
delete[] cFormats;
|
||||||
|
}
|
||||||
if (jFormats != NULL) {
|
if (jFormats != NULL) {
|
||||||
env->DeleteLocalRef(jFormats);
|
env->DeleteLocalRef(jFormats);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user