summaryrefslogtreecommitdiffstats
path: root/media/libmedia
diff options
context:
space:
mode:
Diffstat (limited to 'media/libmedia')
-rw-r--r--media/libmedia/AudioRecord.cpp93
-rw-r--r--media/libmedia/AudioTrack.cpp49
-rwxr-xr-x[-rw-r--r--]media/libmedia/MediaProfiles.cpp28
3 files changed, 141 insertions, 29 deletions
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index 2725b5b..087a567 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -1,7 +1,7 @@
/*
**
** Copyright 2008, The Android Open Source Project
-** Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
+** Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
@@ -136,6 +136,7 @@ status_t AudioRecord::set(
ALOGV("set(): sampleRate %d, channelMask %#x, frameCount %d",sampleRate, channelMask, frameCount);
AutoMutex lock(mLock);
+ status_t status;
if (mAudioRecord != 0) {
return INVALID_OPERATION;
@@ -185,12 +186,61 @@ status_t AudioRecord::set(
return BAD_VALUE;
}
+#ifdef QCOM_HARDWARE
+ size_t inputBuffSizeInBytes = -1;
+ if (AudioSystem::getInputBufferSize(sampleRate, format, channelCount, &inputBuffSizeInBytes)
+ != NO_ERROR) {
+ ALOGE("AudioSystem could not query the input buffer size.");
+ return NO_INIT;
+ }
+ ALOGV("AudioRecord::set() inputBuffSizeInBytes = %d", inputBuffSizeInBytes );
+
+ if (inputBuffSizeInBytes == 0) {
+ ALOGE("Recording parameters are not supported: sampleRate %d, channelCount %d, format %d",
+ sampleRate, channelCount, format);
+ return BAD_VALUE;
+ }
+
+ // Change for Codec type
+ int frameSizeInBytes = 0;
+ if(inputSource == AUDIO_SOURCE_VOICE_COMMUNICATION) {
+ if (audio_is_linear_pcm(format)) {
+ frameSizeInBytes = channelCount * (format == AUDIO_FORMAT_PCM_16_BIT ? sizeof(int16_t)
+: sizeof(int8_t));
+ } else {
+ frameSizeInBytes = channelCount *sizeof(int16_t);
+ }
+ } else {
+ if (format ==AUDIO_FORMAT_AMR_NB) {
+ frameSizeInBytes = channelCount * 32; // Full rate framesize
+ } else if (format ==AUDIO_FORMAT_EVRC) {
+ frameSizeInBytes = channelCount * 23; // Full rate framesize
+ } else if (format ==AUDIO_FORMAT_QCELP) {
+ frameSizeInBytes = channelCount * 35; // Full rate framesize
+ } else if (format ==AUDIO_FORMAT_AAC) {
+ frameSizeInBytes = 2048;
+ } else if ((format ==AUDIO_FORMAT_PCM_16_BIT) || (format ==AUDIO_FORMAT_PCM_8_BIT)) {
+ if (audio_is_linear_pcm(format)) {
+ frameSizeInBytes = channelCount * (format == AUDIO_FORMAT_PCM_16_BIT ? sizeof(int16_t) : sizeof(int8_t));
+ } else {
+ frameSizeInBytes = sizeof(int8_t);
+ }
+ } else if(format == AUDIO_FORMAT_AMR_WB) {
+ frameSizeInBytes = channelCount * 61;
+
+ }
+ }
+ // We use 2* size of input buffer for ping pong use of record buffer.
+ int minFrameCount = 2 * inputBuffSizeInBytes / frameSizeInBytes;
+#else
// validate framecount
int minFrameCount = 0;
- status_t status = getMinFrameCount(&minFrameCount, sampleRate, format, channelMask);
+ status = getMinFrameCount(&minFrameCount, sampleRate, format, channelMask);
if (status != NO_ERROR) {
return status;
}
+#endif
+
ALOGV("AudioRecord::set() minFrameCount = %d", minFrameCount);
if (frameCount == 0) {
@@ -203,6 +253,10 @@ status_t AudioRecord::set(
notificationFrames = frameCount/2;
}
+#ifdef QCOM_HARDWARE
+ //update mInputSource before openRecord_l
+ mInputSource = inputSource;
+#endif
// create the IAudioRecord
status = openRecord_l(sampleRate, format, channelMask,
frameCount, input);
@@ -233,7 +287,9 @@ status_t AudioRecord::set(
mMarkerReached = false;
mNewPosition = 0;
mUpdatePeriod = 0;
+#ifndef QCOM_HARDWARE
mInputSource = inputSource;
+#endif
mInput = input;
AudioSystem::acquireAudioSessionId(mSessionId);
@@ -269,11 +325,36 @@ uint32_t AudioRecord::frameCount() const
size_t AudioRecord::frameSize() const
{
- if (audio_is_linear_pcm(mFormat)) {
- return channelCount()*audio_bytes_per_sample(mFormat);
+#ifdef QCOM_HARDWARE
+ if(inputSource() == AUDIO_SOURCE_VOICE_COMMUNICATION) {
+ if (audio_is_linear_pcm(mFormat)) {
+ return channelCount()*audio_bytes_per_sample(mFormat);
+ } else {
+ return channelCount()*sizeof(int16_t);
+ }
} else {
- return sizeof(uint8_t);
+ if (format() ==AUDIO_FORMAT_AMR_NB) {
+ return channelCount() * 32; // Full rate framesize
+ } else if (format() == AUDIO_FORMAT_EVRC) {
+ return channelCount() * 23; // Full rate framesize
+ } else if (format() == AUDIO_FORMAT_QCELP) {
+ return channelCount() * 35; // Full rate framesize
+ } else if (format() == AUDIO_FORMAT_AAC) {
+ // Not actual framsize but for variable frame rate AAC encoding,
+ // buffer size is treated as a frame size
+ return 2048;
+ } else if(format() == AUDIO_FORMAT_AMR_WB) {
+ return channelCount() * 61;
+ }
+#endif
+ if (audio_is_linear_pcm(mFormat)) {
+ return channelCount()*audio_bytes_per_sample(mFormat);
+ } else {
+ return sizeof(uint8_t);
+ }
+#ifdef QCOM_HARDWARE
}
+#endif
}
audio_source_t AudioRecord::inputSource() const
@@ -453,7 +534,7 @@ status_t AudioRecord::openRecord_l(
sampleRate, format,
channelMask,
frameCount,
- IAudioFlinger::TRACK_DEFAULT,
+ (int16_t)inputSource(),
tid,
&mSessionId,
&status);
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index a2f4348..1025799 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -69,25 +69,31 @@ status_t AudioTrack::getMinFrameCount(
// audio_format_t format
// audio_channel_mask_t channelMask
// audio_output_flags_t flags
- int afSampleRate;
+ int afSampleRate = 0;
if (AudioSystem::getOutputSamplingRate(&afSampleRate, streamType) != NO_ERROR) {
return NO_INIT;
}
- int afFrameCount;
+ int afFrameCount = 0;
if (AudioSystem::getOutputFrameCount(&afFrameCount, streamType) != NO_ERROR) {
return NO_INIT;
}
- uint32_t afLatency;
+ uint32_t afLatency = 0;
if (AudioSystem::getOutputLatency(&afLatency, streamType) != NO_ERROR) {
return NO_INIT;
}
+ if(!afSampleRate || !afFrameCount) {
+ ALOGW("samplerate or framecount 0");
+ return NO_INIT;
+ }
+
// Ensure that buffer depth covers at least audio hardware latency
uint32_t minBufCount = afLatency / ((1000 * afFrameCount) / afSampleRate);
if (minBufCount < 2) minBufCount = 2;
*frameCount = (sampleRate == 0) ? afFrameCount * minBufCount :
- afFrameCount * minBufCount * sampleRate / afSampleRate;
+ afFrameCount * minBufCount * sampleRate / afSampleRate;
+
ALOGV("getMinFrameCount=%d: afFrameCount=%d, minBufCount=%d, afSampleRate=%d, afLatency=%d",
*frameCount, afFrameCount, minBufCount, afSampleRate, afLatency);
return NO_ERROR;
@@ -455,11 +461,23 @@ uint32_t AudioTrack::frameCount() const
size_t AudioTrack::frameSize() const
{
- if (audio_is_linear_pcm(mFormat)) {
- return channelCount()*audio_bytes_per_sample(mFormat);
+#ifdef QCOM_HARDWARE
+ if ((audio_stream_type_t)mStreamType == AUDIO_STREAM_VOICE_CALL) {
+ if (audio_is_linear_pcm(mFormat)) {
+ return channelCount()*audio_bytes_per_sample(mFormat);
+ } else {
+ return channelCount()*sizeof(int16_t);
+ }
} else {
- return sizeof(uint8_t);
+#endif
+ if (audio_is_linear_pcm(mFormat)) {
+ return channelCount()*audio_bytes_per_sample(mFormat);
+ } else {
+ return sizeof(uint8_t);
+ }
+#ifdef QCOM_HARDWARE
}
+#endif
}
sp<IMemory>& AudioTrack::sharedBuffer()
@@ -980,20 +998,26 @@ status_t AudioTrack::createTrack_l(
} else if (!(flags & AUDIO_OUTPUT_FLAG_FAST)) {
// FIXME move these calculations and associated checks to server
- int afSampleRate;
+ int afSampleRate = 0;
if (AudioSystem::getSamplingRate(output, streamType, &afSampleRate) != NO_ERROR) {
return NO_INIT;
}
- int afFrameCount;
+ int afFrameCount = 0;
if (AudioSystem::getFrameCount(output, streamType, &afFrameCount) != NO_ERROR) {
return NO_INIT;
}
+ if(!afSampleRate && !afFrameCount) {
+ ALOGW("samplerate or framecount zero");
+ return NO_INIT;
+ }
+
// Ensure that buffer depth covers at least audio hardware latency
uint32_t minBufCount = afLatency / ((1000 * afFrameCount)/afSampleRate);
if (minBufCount < 2) minBufCount = 2;
- int minFrameCount = (afFrameCount*sampleRate*minBufCount)/afSampleRate;
+ uint32_t minFrameCount = (afFrameCount*sampleRate*minBufCount)/afSampleRate;
+
ALOGV("minFrameCount: %d, afFrameCount=%d, minBufCount=%d, sampleRate=%d, afSampleRate=%d"
", afLatency=%d",
minFrameCount, afFrameCount, minBufCount, sampleRate, afSampleRate, afLatency);
@@ -1088,7 +1112,10 @@ status_t AudioTrack::createTrack_l(
mCblk->waitTimeMs = 0;
mRemainingFrames = mNotificationFramesAct;
// FIXME don't believe this lie
- mLatency = afLatency + (1000*mCblk->frameCount) / sampleRate;
+ if(sampleRate)
+ mLatency = afLatency + (1000*mCblk->frameCount) / sampleRate;
+ else
+ mLatency = afLatency;
// If IAudioTrack is re-created, don't let the requested frameCount
// decrease. This can confuse clients that cache frameCount().
if (mCblk->frameCount > mFrameCount) {
diff --git a/media/libmedia/MediaProfiles.cpp b/media/libmedia/MediaProfiles.cpp
index fa536a6..e1299c2 100644..100755
--- a/media/libmedia/MediaProfiles.cpp
+++ b/media/libmedia/MediaProfiles.cpp
@@ -87,31 +87,35 @@ const MediaProfiles::NameToTagMap MediaProfiles::sCamcorderQualityNameMap[] = {
{"timelapse720p", CAMCORDER_QUALITY_TIME_LAPSE_720P},
{"timelapse1080p", CAMCORDER_QUALITY_TIME_LAPSE_1080P},
{"timelapseqvga", CAMCORDER_QUALITY_TIME_LAPSE_QVGA},
+ {"timelapsevga", CAMCORDER_QUALITY_TIME_LAPSE_VGA},
+ {"timelapsewvga", CAMCORDER_QUALITY_TIME_LAPSE_WVGA},
+ {"timelapsefwvga", CAMCORDER_QUALITY_TIME_LAPSE_FWVGA},
+ {"timelapsewqvga", CAMCORDER_QUALITY_TIME_LAPSE_WQVGA},
};
/*static*/ void
MediaProfiles::logVideoCodec(const MediaProfiles::VideoCodec& codec)
{
- ALOGV("video codec:");
- ALOGV("codec = %d", codec.mCodec);
- ALOGV("bit rate: %d", codec.mBitRate);
- ALOGV("frame width: %d", codec.mFrameWidth);
- ALOGV("frame height: %d", codec.mFrameHeight);
- ALOGV("frame rate: %d", codec.mFrameRate);
+ALOGV("video codec:");
+ALOGV("codec = %d", codec.mCodec);
+ALOGV("bit rate: %d", codec.mBitRate);
+ALOGV("frame width: %d", codec.mFrameWidth);
+ALOGV("frame height: %d", codec.mFrameHeight);
+ALOGV("frame rate: %d", codec.mFrameRate);
}
/*static*/ void
MediaProfiles::logAudioCodec(const MediaProfiles::AudioCodec& codec)
{
- ALOGV("audio codec:");
- ALOGV("codec = %d", codec.mCodec);
- ALOGV("bit rate: %d", codec.mBitRate);
- ALOGV("sample rate: %d", codec.mSampleRate);
- ALOGV("number of channels: %d", codec.mChannels);
+ALOGV("audio codec:");
+ALOGV("codec = %d", codec.mCodec);
+ALOGV("bit rate: %d", codec.mBitRate);
+ALOGV("sample rate: %d", codec.mSampleRate);
+ALOGV("number of channels: %d", codec.mChannels);
}
/*static*/ void
-MediaProfiles::logVideoEncoderCap(const MediaProfiles::VideoEncoderCap& cap)
+ MediaProfiles::logVideoEncoderCap(const MediaProfiles::VideoEncoderCap& cap)
{
ALOGV("video encoder cap:");
ALOGV("codec = %d", cap.mCodec);