am aa9e3e01: Camera: Play shutter sound iff enableShutterSound(true) && ShutterCallback !null
* commit 'aa9e3e01b86bd9bfb5ac36c0f360d5fe478cbb2d':
Camera: Play shutter sound iff enableShutterSound(true) && ShutterCallback !null
diff --git a/include/media/stagefright/MediaCodec.h b/include/media/stagefright/MediaCodec.h
index cacfa54..b1e57cf 100644
--- a/include/media/stagefright/MediaCodec.h
+++ b/include/media/stagefright/MediaCodec.h
@@ -113,6 +113,8 @@
// pending, an error is pending.
void requestActivityNotification(const sp<AMessage> ¬ify);
+ status_t getName(AString *componentName) const;
+
protected:
virtual ~MediaCodec();
virtual void onMessageReceived(const sp<AMessage> &msg);
@@ -154,6 +156,7 @@
kWhatCodecNotify = 'codc',
kWhatRequestIDRFrame = 'ridr',
kWhatRequestActivityNotification = 'racN',
+ kWhatGetName = 'getN',
};
enum {
@@ -178,6 +181,7 @@
sp<ALooper> mLooper;
sp<ALooper> mCodecLooper;
sp<ACodec> mCodec;
+ AString mComponentName;
uint32_t mReplyID;
uint32_t mFlags;
sp<SurfaceTextureClient> mNativeWindow;
diff --git a/include/media/stagefright/MediaExtractor.h b/include/media/stagefright/MediaExtractor.h
index 94090ee..3076a96 100644
--- a/include/media/stagefright/MediaExtractor.h
+++ b/include/media/stagefright/MediaExtractor.h
@@ -67,7 +67,7 @@
}
protected:
- MediaExtractor() {}
+ MediaExtractor() : mIsDrm(false) {}
virtual ~MediaExtractor() {}
private:
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index 362d022..aec8c4a 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -1441,7 +1441,7 @@
result.append(" AudioTrack::dump\n");
snprintf(buffer, 255, " stream type(%d), left - right volume(%f, %f)\n", mStreamType, mVolume[0], mVolume[1]);
result.append(buffer);
- snprintf(buffer, 255, " format(%d), channel count(%d), frame count(%d)\n", mFormat, mChannelCount, mCblk->frameCount);
+ snprintf(buffer, 255, " format(%d), channel count(%d), frame count(%d)\n", mFormat, mChannelCount, (mCblk == 0) ? 0 : mCblk->frameCount);
result.append(buffer);
snprintf(buffer, 255, " sample rate(%d), status(%d), muted(%d)\n", (mCblk == 0) ? 0 : mCblk->sampleRate, mStatus, mMuted);
result.append(buffer);
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp
index dc8e4a3..b2afec7 100644
--- a/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/MPEG4Extractor.cpp
@@ -30,6 +30,7 @@
#include <string.h>
#include <media/stagefright/foundation/ABitReader.h>
+#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/DataSource.h>
@@ -1221,18 +1222,15 @@
case FOURCC('a', 'v', 'c', 'C'):
{
- char buffer[256];
- if (chunk_data_size > (off64_t)sizeof(buffer)) {
- return ERROR_BUFFER_TOO_SMALL;
- }
+ sp<ABuffer> buffer = new ABuffer(chunk_data_size);
if (mDataSource->readAt(
- data_offset, buffer, chunk_data_size) < chunk_data_size) {
+ data_offset, buffer->data(), chunk_data_size) < chunk_data_size) {
return ERROR_IO;
}
mLastTrack->meta->setData(
- kKeyAVCC, kTypeAVCC, buffer, chunk_data_size);
+ kKeyAVCC, kTypeAVCC, buffer->data(), chunk_data_size);
*offset += chunk_size;
break;
@@ -1633,8 +1631,9 @@
{
if (size == 16 && flags == 0) {
char tmp[16];
- sprintf(tmp, "%d/%d",
- (int)buffer[size - 5], (int)buffer[size - 3]);
+ uint16_t* pTrack = (uint16_t*)&buffer[10];
+ uint16_t* pTotalTracks = (uint16_t*)&buffer[12];
+ sprintf(tmp, "%d/%d", ntohs(*pTrack), ntohs(*pTotalTracks));
mFileMetaData->setCString(kKeyCDTrackNumber, tmp);
}
@@ -1642,10 +1641,11 @@
}
case FOURCC('d', 'i', 's', 'k'):
{
- if (size == 14 && flags == 0) {
+ if ((size == 14 || size == 16) && flags == 0) {
char tmp[16];
- sprintf(tmp, "%d/%d",
- (int)buffer[size - 3], (int)buffer[size - 1]);
+ uint16_t* pDisc = (uint16_t*)&buffer[10];
+ uint16_t* pTotalDiscs = (uint16_t*)&buffer[12];
+ sprintf(tmp, "%d/%d", ntohs(*pDisc), ntohs(*pTotalDiscs));
mFileMetaData->setCString(kKeyDiscNumber, tmp);
}
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp
index 56e6df0..cb8a651 100644
--- a/media/libstagefright/MediaCodec.cpp
+++ b/media/libstagefright/MediaCodec.cpp
@@ -302,6 +302,20 @@
return OK;
}
+status_t MediaCodec::getName(AString *name) const {
+ sp<AMessage> msg = new AMessage(kWhatGetName, id());
+
+ sp<AMessage> response;
+ status_t err;
+ if ((err = PostAndAwaitResponse(msg, &response)) != OK) {
+ return err;
+ }
+
+ CHECK(response->findString("name", name));
+
+ return OK;
+}
+
status_t MediaCodec::getInputBuffers(Vector<sp<ABuffer> > *buffers) const {
sp<AMessage> msg = new AMessage(kWhatGetBuffers, id());
msg->setInt32("portIndex", kPortIndexInput);
@@ -534,16 +548,15 @@
CHECK_EQ(mState, INITIALIZING);
setState(INITIALIZED);
- AString componentName;
- CHECK(msg->findString("componentName", &componentName));
+ CHECK(msg->findString("componentName", &mComponentName));
- if (componentName.startsWith("OMX.google.")) {
+ if (mComponentName.startsWith("OMX.google.")) {
mFlags |= kFlagIsSoftwareCodec;
} else {
mFlags &= ~kFlagIsSoftwareCodec;
}
- if (componentName.endsWith(".secure")) {
+ if (mComponentName.endsWith(".secure")) {
mFlags |= kFlagIsSecure;
} else {
mFlags &= ~kFlagIsSecure;
@@ -1171,6 +1184,25 @@
break;
}
+ case kWhatGetName:
+ {
+ uint32_t replyID;
+ CHECK(msg->senderAwaitsResponse(&replyID));
+
+ if (mComponentName.empty()) {
+ sp<AMessage> response = new AMessage;
+ response->setInt32("err", INVALID_OPERATION);
+
+ response->postReply(replyID);
+ break;
+ }
+
+ sp<AMessage> response = new AMessage;
+ response->setString("name", mComponentName.c_str());
+ response->postReply(replyID);
+ break;
+ }
+
default:
TRESPASS();
}
@@ -1240,6 +1272,10 @@
mActivityNotify.clear();
}
+ if (newState == UNINITIALIZED) {
+ mComponentName.clear();
+ }
+
mState = newState;
cancelPendingDequeueOperations();
diff --git a/media/libstagefright/StagefrightMediaScanner.cpp b/media/libstagefright/StagefrightMediaScanner.cpp
index b7cf96e..bccffd8 100644
--- a/media/libstagefright/StagefrightMediaScanner.cpp
+++ b/media/libstagefright/StagefrightMediaScanner.cpp
@@ -42,7 +42,7 @@
".mpeg", ".ogg", ".mid", ".smf", ".imy", ".wma", ".aac",
".wav", ".amr", ".midi", ".xmf", ".rtttl", ".rtx", ".ota",
".mkv", ".mka", ".webm", ".ts", ".fl", ".flac", ".mxmf",
- ".avi", ".mpeg", ".mpg"
+ ".avi", ".mpeg", ".mpg", ".mpga"
};
static const size_t kNumValidExtensions =
sizeof(kValidExtensions) / sizeof(kValidExtensions[0]);
diff --git a/media/libstagefright/StagefrightMetadataRetriever.cpp b/media/libstagefright/StagefrightMetadataRetriever.cpp
index a2f3f13..19af4fb 100644
--- a/media/libstagefright/StagefrightMetadataRetriever.cpp
+++ b/media/libstagefright/StagefrightMetadataRetriever.cpp
@@ -433,7 +433,7 @@
return NULL;
}
- return strdup(mMetaData.valueAt(index).string());
+ return mMetaData.valueAt(index).string();
}
void StagefrightMetadataRetriever::parseMetaData() {
diff --git a/media/libstagefright/WVMExtractor.cpp b/media/libstagefright/WVMExtractor.cpp
index 31b2bcf..5ae80cc 100644
--- a/media/libstagefright/WVMExtractor.cpp
+++ b/media/libstagefright/WVMExtractor.cpp
@@ -72,15 +72,18 @@
}
}
-bool WVMExtractor::getVendorLibHandle()
+static void init_routine()
{
- if (gVendorLibHandle == NULL) {
- gVendorLibHandle = dlopen("libwvm.so", RTLD_NOW);
- }
-
+ gVendorLibHandle = dlopen("libwvm.so", RTLD_NOW);
if (gVendorLibHandle == NULL) {
ALOGE("Failed to open libwvm.so");
}
+}
+
+bool WVMExtractor::getVendorLibHandle()
+{
+ static pthread_once_t sOnceControl = PTHREAD_ONCE_INIT;
+ pthread_once(&sOnceControl, init_routine);
return gVendorLibHandle != NULL;
}
diff --git a/media/libstagefright/codecs/amrwbenc/src/asm/ARMV5E/pred_lt4_1_opt.s b/media/libstagefright/codecs/amrwbenc/src/asm/ARMV5E/pred_lt4_1_opt.s
index e0b338d..ac2dd13 100644
--- a/media/libstagefright/codecs/amrwbenc/src/asm/ARMV5E/pred_lt4_1_opt.s
+++ b/media/libstagefright/codecs/amrwbenc/src/asm/ARMV5E/pred_lt4_1_opt.s
@@ -44,7 +44,9 @@
SUBLT r5, r5, #2 @x--
SUB r5, r5, #30 @x -= 15
RSB r4, r2, #3 @k = 3 - frac
- LDR r6, Table
+ ADRL r8, Table
+ LDR r6, [r8]
+ ADD r6, r8
MOV r8, r4, LSL #6
@MOV r7, #0 @j = 0
ADD r8, r6, r8 @ptr2 = &(inter4_2[k][0])
@@ -451,7 +453,7 @@
LDMFD r13!, {r4 - r12, r15}
Table:
- .word inter4_2
+ .word inter4_2-Table
@ENDFUNC
.END
diff --git a/media/libstagefright/rtsp/MyHandler.h b/media/libstagefright/rtsp/MyHandler.h
index deee30f..96c7683 100644
--- a/media/libstagefright/rtsp/MyHandler.h
+++ b/media/libstagefright/rtsp/MyHandler.h
@@ -1091,6 +1091,10 @@
void parsePlayResponse(const sp<ARTSPResponse> &response) {
mSeekable = false;
+ if (mTracks.size() == 0) {
+ ALOGV("parsePlayResponse: late packets ignored.");
+ return;
+ }
ssize_t i = response->mHeaders.indexOfKey("range");
if (i < 0) {
diff --git a/tools/resampler_tools/Android.mk b/tools/resampler_tools/Android.mk
new file mode 100644
index 0000000..e8cbe39
--- /dev/null
+++ b/tools/resampler_tools/Android.mk
@@ -0,0 +1,17 @@
+# Copyright 2005 The Android Open Source Project
+#
+# Android.mk for resampler_tools
+#
+
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ fir.cpp
+
+LOCAL_MODULE := fir
+
+include $(BUILD_HOST_EXECUTABLE)
+
+
diff --git a/tools/resampler_tools/fir.cpp b/tools/resampler_tools/fir.cpp
new file mode 100644
index 0000000..377814f
--- /dev/null
+++ b/tools/resampler_tools/fir.cpp
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2007 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.
+ */
+
+#include <math.h>
+#include <stdio.h>
+
+static double sinc(double x) {
+ if (fabs(x) == 0.0f) return 1.0f;
+ return sin(x) / x;
+}
+
+static double sqr(double x) {
+ return x*x;
+}
+
+static double I0(double x) {
+ // from the Numerical Recipes in C p. 237
+ double ax,ans,y;
+ ax=fabs(x);
+ if (ax < 3.75) {
+ y=x/3.75;
+ y*=y;
+ ans=1.0+y*(3.5156229+y*(3.0899424+y*(1.2067492
+ +y*(0.2659732+y*(0.360768e-1+y*0.45813e-2)))));
+ } else {
+ y=3.75/ax;
+ ans=(exp(ax)/sqrt(ax))*(0.39894228+y*(0.1328592e-1
+ +y*(0.225319e-2+y*(-0.157565e-2+y*(0.916281e-2
+ +y*(-0.2057706e-1+y*(0.2635537e-1+y*(-0.1647633e-1
+ +y*0.392377e-2))))))));
+ }
+ return ans;
+}
+
+static double kaiser(int k, int N, double alpha) {
+ if (k < 0 || k > N)
+ return 0;
+ return I0(M_PI*alpha * sqrt(1.0 - sqr((2.0*k)/N - 1.0))) / I0(M_PI*alpha);
+}
+
+int main(int argc, char** argv)
+{
+ // nc is the number of bits to store the coefficients
+ int nc = 32;
+
+ // ni is the minimum number of bits needed for interpolation
+ // (not used for generating the coefficients)
+ const int ni = nc / 2;
+
+ // cut off frequency ratio Fc/Fs
+ // The bigger the stop-band, the less coefficients we'll need.
+ double Fcr = 20000.0 / 48000.0;
+
+ // nzc is the number of zero-crossing on one half of the filter
+ int nzc = 8;
+
+ // alpha parameter of the kaiser window
+ // Larger numbers reduce ripples in the rejection band but increase
+ // the width of the transition band.
+ // the table below gives some value of alpha for a given
+ // stop-band attenuation.
+ // 30 dB 2.210
+ // 40 dB 3.384
+ // 50 dB 4.538
+ // 60 dB 5.658
+ // 70 dB 6.764
+ // 80 dB 7.865
+ // 90 dB 8.960
+ // 100 dB 10.056
+ double alpha = 7.865; // -80dB stop-band attenuation
+
+ // 2^nz is the number coefficients per zero-crossing
+ // (int theory this should be 1<<(nc/2))
+ const int nz = 4;
+
+ // total number of coefficients
+ const int N = (1 << nz) * nzc;
+
+ // generate the right half of the filter
+ printf("const int32_t RESAMPLE_FIR_SIZE = %d;\n", N);
+ printf("const int32_t RESAMPLE_FIR_NUM_COEF = %d;\n", nzc);
+ printf("const int32_t RESAMPLE_FIR_COEF_BITS = %d;\n", nc);
+ printf("const int32_t RESAMPLE_FIR_LERP_FRAC_BITS = %d;\n", ni);
+ printf("const int32_t RESAMPLE_FIR_LERP_INT_BITS = %d;\n", nz);
+ printf("\n");
+ printf("static int16_t resampleFIR[%d] = {", N);
+ for (int i=0 ; i<N ; i++)
+ {
+ double x = (2.0 * M_PI * i * Fcr) / (1 << nz);
+ double y = kaiser(i+N, 2*N, alpha) * sinc(x);
+
+ long yi = floor(y * ((1ULL<<(nc-1))) + 0.5);
+ if (yi >= (1LL<<(nc-1))) yi = (1LL<<(nc-1))-1;
+
+ if ((i % (1 << 4)) == 0) printf("\n ");
+ if (nc > 16)
+ printf("0x%08x, ", int(yi));
+ else
+ printf("0x%04x, ", int(yi)&0xFFFF);
+ }
+ printf("\n};\n");
+ return 0;
+ }
+
+// http://www.dsptutor.freeuk.com/KaiserFilterDesign/KaiserFilterDesign.html
+// http://www.csee.umbc.edu/help/sound/AFsp-V2R1/html/audio/ResampAudio.html
+
+