OSDN Git Service

Bug 5244675 PCM sample rate metadata units
authorGlenn Kasten <gkasten@google.com>
Wed, 31 Aug 2011 23:32:33 +0000 (16:32 -0700)
committerGlenn Kasten <gkasten@google.com>
Tue, 6 Sep 2011 21:41:36 +0000 (14:41 -0700)
The current metadata key macro name ANDROID_KEY_INDEX_PCMFORMAT_SAMPLESPERSEC
is confusing.  This change renames it to ANDROID_KEY_INDEX_PCMFORMAT_SAMPLERATE,
and documents that it is in Hz rather than milliHz.  The key string is
renamed from AndroidPcmFormatSamplesPerSec to AndroidPcmFormatSampleRate.

Details:

OpenSL ES 1.0.1 PCM struct SLDataFormat_PCM field samplesPerSec
[sic] is in milliHz.  OpenSL ES 1.1 preserves that struct, but adds
struct SLDataFormat_PCM with field sampleRate also in milliHz.  If the
ANDROID_KEY_INDEX_PCMFORMAT_* metadata keys were intended to exactly
model the OpenSL ES PCM data format struct, the metadata sample rate
would also be in milliHz units.  However, the rest of Android operates
in Hz so we use Hz here also.

Backwards compatibility for the name should not be an issue,
as the initial beta developer has not yet started using this metadata.

Related change: delete a duplicate header file.

Change-Id: Ib8f620dfe7a328f621ddbb19f55e5691eb22d7b5

wilhelm/include/SLES/OpenSLES_AndroidMetadata.h
wilhelm/src/android/AacBqToPcmCbRenderer.cpp
wilhelm/src/android/OpenSLES_AndroidMetadata.h [deleted file]
wilhelm/src/android/android_AudioSfDecoder.cpp
wilhelm/src/android/android_AudioSfDecoder.h
wilhelm/tests/examples/slesTestDecodeAac.cpp
wilhelm/tests/examples/slesTestDecodeToBuffQueue.cpp

index f59b3f0..01e33b8 100644 (file)
@@ -28,11 +28,12 @@ extern "C" {
 /**
  * Additional metadata keys to be used in SLMetadataExtractionItf:
  *   the ANDROID_KEY_PCMFORMAT_* keys follow the fields of the SLDataFormat_PCM struct, and as such
- *     all values corresponding to these keys are of SLuint32 type, and are defined as the fields
- *     of the same name in SLDataFormat_PCM.
+ *   all values corresponding to these keys are of SLuint32 type, and are defined as the fields
+ *   of the same name in SLDataFormat_PCM.  The exception is that sample rate is expressed here
+ *   in Hz units, rather than in milliHz units.
  */
 #define ANDROID_KEY_PCMFORMAT_NUMCHANNELS   "AndroidPcmFormatNumChannels"
-#define ANDROID_KEY_PCMFORMAT_SAMPLESPERSEC "AndroidPcmFormatSamplesPerSec"
+#define ANDROID_KEY_PCMFORMAT_SAMPLERATE    "AndroidPcmFormatSampleRate"
 #define ANDROID_KEY_PCMFORMAT_BITSPERSAMPLE "AndroidPcmFormatBitsPerSample"
 #define ANDROID_KEY_PCMFORMAT_CONTAINERSIZE "AndroidPcmFormatContainerSize"
 #define ANDROID_KEY_PCMFORMAT_CHANNELMASK   "AndroidPcmFormatChannelMask"
index 4ab1592..521e636 100644 (file)
@@ -144,7 +144,7 @@ void AacBqToPcmCbRenderer::onPrepare() {
         //    initialization with the default values: they will be replaced by the actual values
         //      once the decoder has figured them out
         mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_NUMCHANNELS] = mChannelCount;
-        mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_SAMPLESPERSEC] = mSampleRateHz;
+        mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_SAMPLERATE] = mSampleRateHz;
         mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_CHANNELMASK] = mChannelMask;
     }
 
@@ -211,7 +211,7 @@ void AacBqToPcmCbRenderer::onPrepare() {
 
     {
             android::Mutex::Autolock autoLock(mPcmFormatLock);
-            mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_SAMPLESPERSEC] = mSampleRateHz;
+            mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_SAMPLERATE] = mSampleRateHz;
             mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_NUMCHANNELS] = mChannelCount;
             mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_CHANNELMASK] = mChannelMask;
     }
diff --git a/wilhelm/src/android/OpenSLES_AndroidMetadata.h b/wilhelm/src/android/OpenSLES_AndroidMetadata.h
deleted file mode 100644 (file)
index cf717c2..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/**
- * Additional metadata keys
- *   the ANDROID_KEY_PCMFORMAT_* keys follow the fields of the SLDataFormat_PCM struct, and as such
- *     all corresponding values match SLuint32 size, and field definitions.
- * FIXME these values are candidates to be included in OpenSLES_Android.h as official metadata
- *     keys supported on the platform.
- */
-#define ANDROID_KEY_PCMFORMAT_NUMCHANNELS   "AndroidPcmFormatNumChannels"
-#define ANDROID_KEY_PCMFORMAT_SAMPLESPERSEC "AndroidPcmFormatSamplesPerSec"
-#define ANDROID_KEY_PCMFORMAT_BITSPERSAMPLE "AndroidPcmFormatBitsPerSample"
-#define ANDROID_KEY_PCMFORMAT_CONTAINERSIZE "AndroidPcmFormatContainerSize"
-#define ANDROID_KEY_PCMFORMAT_CHANNELMASK   "AndroidPcmFormatChannelMask"
-#define ANDROID_KEY_PCMFORMAT_ENDIANNESS    "AndroidPcmFormatEndianness"
index d881e18..65f7e3a 100644 (file)
@@ -185,7 +185,7 @@ void AudioSfDecoder::onPrepare() {
     //    initialization with the default values: they will be replaced by the actual values
     //      once the decoder has figured them out
     mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_NUMCHANNELS] = mChannelCount;
-    mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_SAMPLESPERSEC] = mSampleRateHz;
+    mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_SAMPLERATE] = mSampleRateHz;
     mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_CHANNELMASK] = mChannelMask;
     }
 
@@ -351,7 +351,7 @@ void AudioSfDecoder::onPrepare() {
 
     {
         android::Mutex::Autolock autoLock(mPcmFormatLock);
-        mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_SAMPLESPERSEC] = mSampleRateHz;
+        mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_SAMPLERATE] = mSampleRateHz;
         mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_NUMCHANNELS] = mChannelCount;
         mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_CHANNELMASK] = mChannelMask;
     }
@@ -803,7 +803,7 @@ void AudioSfDecoder::hasNewDecodeParams() {
         {
             android::Mutex::Autolock autoLock(mPcmFormatLock);
             mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_NUMCHANNELS] = mChannelCount;
-            mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_SAMPLESPERSEC] = mSampleRateHz;
+            mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_SAMPLERATE] = mSampleRateHz;
             mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_CHANNELMASK] = mChannelMask;
         }
     }
index b806d8c..2d0ec69 100644 (file)
 #include "ThrottledSource.h"
 
 #include "android_GenericPlayer.h"
-#include "OpenSLES_AndroidMetadata.h"
 
 //--------------------------------------------------------------------------------------------------
 namespace android {
 
 // keep in sync with the entries of kPcmDecodeMetadataKeys[]
 #define ANDROID_KEY_INDEX_PCMFORMAT_NUMCHANNELS   0
-#define ANDROID_KEY_INDEX_PCMFORMAT_SAMPLESPERSEC 1
+#define ANDROID_KEY_INDEX_PCMFORMAT_SAMPLERATE    1
 #define ANDROID_KEY_INDEX_PCMFORMAT_BITSPERSAMPLE 2
 #define ANDROID_KEY_INDEX_PCMFORMAT_CONTAINERSIZE 3
 #define ANDROID_KEY_INDEX_PCMFORMAT_CHANNELMASK   4
@@ -44,7 +43,7 @@ namespace android {
 
 // to keep in sync with the ANDROID_KEY_INDEX_PCMFORMAT_* constants in android_AudioSfDecoder.cpp
 static const char* const kPcmDecodeMetadataKeys[] = {
-        ANDROID_KEY_PCMFORMAT_NUMCHANNELS, ANDROID_KEY_PCMFORMAT_SAMPLESPERSEC,
+        ANDROID_KEY_PCMFORMAT_NUMCHANNELS, ANDROID_KEY_PCMFORMAT_SAMPLERATE,
         ANDROID_KEY_PCMFORMAT_BITSPERSAMPLE, ANDROID_KEY_PCMFORMAT_CONTAINERSIZE,
         ANDROID_KEY_PCMFORMAT_CHANNELMASK, ANDROID_KEY_PCMFORMAT_ENDIANNESS };
 #define NB_PCMMETADATA_KEYS (sizeof(kPcmDecodeMetadataKeys)/sizeof(kPcmDecodeMetadataKeys[0]))
index 9fe091d..ee1b07d 100644 (file)
@@ -537,7 +537,7 @@ void TestDecToBuffQueue( SLObjectItf sl, const char *path, int fd)
             /* find out the key index of the metadata we're interested in */
             if (!strcmp((char*)keyInfo->data, ANDROID_KEY_PCMFORMAT_NUMCHANNELS)) {
                 channelCountKeyIndex = i;
-            } else if (!strcmp((char*)keyInfo->data, ANDROID_KEY_PCMFORMAT_SAMPLESPERSEC)) {
+            } else if (!strcmp((char*)keyInfo->data, ANDROID_KEY_PCMFORMAT_SAMPLERATE)) {
                 sampleRateKeyIndex = i;
             } else if (!strcmp((char*)keyInfo->data, ANDROID_KEY_PCMFORMAT_BITSPERSAMPLE)) {
                 bitsPerSampleKeyIndex = i;
@@ -561,9 +561,9 @@ void TestDecToBuffQueue( SLObjectItf sl, const char *path, int fd)
     }
     if (sampleRateKeyIndex != -1) {
         printf("Key %s is at index %d\n",
-                ANDROID_KEY_PCMFORMAT_SAMPLESPERSEC, sampleRateKeyIndex);
+                ANDROID_KEY_PCMFORMAT_SAMPLERATE, sampleRateKeyIndex);
     } else {
-        fprintf(stderr, "Unable to find key %s\n", ANDROID_KEY_PCMFORMAT_SAMPLESPERSEC);
+        fprintf(stderr, "Unable to find key %s\n", ANDROID_KEY_PCMFORMAT_SAMPLERATE);
     }
     if (bitsPerSampleKeyIndex != -1) {
         printf("Key %s is at index %d\n",
index af460b2..8e0a529 100644 (file)
@@ -474,7 +474,7 @@ void TestDecToBuffQueue( SLObjectItf sl, const char* path)
             /* find out the key index of the metadata we're interested in */
             if (!strcmp((char*)keyInfo->data, ANDROID_KEY_PCMFORMAT_NUMCHANNELS)) {
                 channelCountKeyIndex = i;
-            } else if (!strcmp((char*)keyInfo->data, ANDROID_KEY_PCMFORMAT_SAMPLESPERSEC)) {
+            } else if (!strcmp((char*)keyInfo->data, ANDROID_KEY_PCMFORMAT_SAMPLERATE)) {
                 sampleRateKeyIndex = i;
             }
             free(keyInfo);
@@ -488,9 +488,9 @@ void TestDecToBuffQueue( SLObjectItf sl, const char* path)
     }
     if (sampleRateKeyIndex != -1) {
         fprintf(stdout, "Key %s is at index %d\n",
-                ANDROID_KEY_PCMFORMAT_SAMPLESPERSEC, sampleRateKeyIndex);
+                ANDROID_KEY_PCMFORMAT_SAMPLERATE, sampleRateKeyIndex);
     } else {
-        fprintf(stderr, "Unable to find key %s\n", ANDROID_KEY_PCMFORMAT_SAMPLESPERSEC);
+        fprintf(stderr, "Unable to find key %s\n", ANDROID_KEY_PCMFORMAT_SAMPLERATE);
     }
 
     /* ------------------------------------------------------ */