summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Kondik <steve@cyngn.com>2015-12-14 20:57:31 -0600
committerSteve Kondik <steve@cyngn.com>2015-12-15 05:45:43 -0500
commit455a7456a95cc6bab8630def18537b9b275ed211 (patch)
treefbc4a1748720df6cf50a7f1bf2a6f5fef795b6e4
parent093c8ed16d58b3095789a3d8a0f0923eb31b4af4 (diff)
downloadframeworks_av-455a7456a95cc6bab8630def18537b9b275ed211.zip
frameworks_av-455a7456a95cc6bab8630def18537b9b275ed211.tar.gz
frameworks_av-455a7456a95cc6bab8630def18537b9b275ed211.tar.bz2
nuplayer: Improve offload format conversions
* Annotate source buffers with the audio format * Add support for 32-bit signed PCM offload (zero copy) Change-Id: Id758830784740c0a038452d383c8ec8e3e4593bb
-rw-r--r--media/libavextensions/mediaplayerservice/AVNuUtils.cpp53
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h9
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.h4
3 files changed, 34 insertions, 32 deletions
diff --git a/media/libavextensions/mediaplayerservice/AVNuUtils.cpp b/media/libavextensions/mediaplayerservice/AVNuUtils.cpp
index c475fd3..3354d23 100644
--- a/media/libavextensions/mediaplayerservice/AVNuUtils.cpp
+++ b/media/libavextensions/mediaplayerservice/AVNuUtils.cpp
@@ -138,7 +138,11 @@ bool AVNuUtils::pcmOffloadException(const sp<MetaData> &meta) {
ALOGV("%s: no audio mime present, ignoring pcm offload", __func__);
return true;
}
-//#if defined (PCM_OFFLOAD_ENABLED) || defined (PCM_OFFLOAD_ENABLED_24)
+
+ if (!is24bitPCMOffloadEnabled() && !is16bitPCMOffloadEnabled()) {
+ return true;
+ }
+
const char * const ExceptionTable[] = {
MEDIA_MIMETYPE_AUDIO_AMR_NB,
MEDIA_MIMETYPE_AUDIO_AMR_WB,
@@ -257,7 +261,10 @@ status_t AVNuUtils::convertToSinkFormatIfNeeded(
audio_format_t sinkFormat, bool isOffload) {
audio_format_t srcFormat = AUDIO_FORMAT_INVALID;
- if (!buffer->meta()->findInt32("pcm-format", (int32_t *)&srcFormat)) {
+ if (!isOffload
+ || !audio_is_offload_pcm(sinkFormat)
+ || !buffer->meta()->findInt32("pcm-format", (int32_t *)&srcFormat)
+ || ((int32_t)srcFormat < 0)) {
newBuffer = buffer;
return OK;
}
@@ -280,37 +287,25 @@ status_t AVNuUtils::convertToSinkFormatIfNeeded(
buffer->size(), frames, srcFormat);
audio_format_t dstFormat;
- if (isOffload) {
- switch (sinkFormat) {
- case AUDIO_FORMAT_PCM_16_BIT_OFFLOAD:
- dstFormat = AUDIO_FORMAT_PCM_16_BIT;
- break;
- case AUDIO_FORMAT_PCM_24_BIT_OFFLOAD:
- if (srcFormat != AUDIO_FORMAT_PCM_24_BIT_PACKED &&
- srcFormat != AUDIO_FORMAT_PCM_8_24_BIT) {
- ALOGE("Invalid src format for 24 bit conversion");
- return INVALID_OPERATION;
- }
+ switch (sinkFormat) {
+ case AUDIO_FORMAT_PCM_16_BIT_OFFLOAD:
+ dstFormat = AUDIO_FORMAT_PCM_16_BIT;
+ break;
+ case AUDIO_FORMAT_PCM_24_BIT_OFFLOAD:
+ if (srcFormat == AUDIO_FORMAT_PCM_32_BIT)
+ dstFormat = AUDIO_FORMAT_PCM_32_BIT;
+ else
dstFormat = AUDIO_FORMAT_PCM_24_BIT_OFFLOAD;
- break;
- case AUDIO_FORMAT_DEFAULT:
- ALOGI("OffloadInfo not yet initialized, retry");
- return NO_INIT;
- default:
- ALOGE("Invalid offload format %x given for conversion",
- sinkFormat);
- return INVALID_OPERATION;
- }
- } else {
- if (sinkFormat == AUDIO_FORMAT_INVALID) {
- ALOGD("PCM Info not yet initialized, drop buffer");
+ break;
+ case AUDIO_FORMAT_DEFAULT:
+ ALOGI("OffloadInfo not yet initialized, retry");
+ return NO_INIT;
+ default:
+ ALOGE("Invalid offload format %x given for conversion",
+ sinkFormat);
return INVALID_OPERATION;
- }
-
- dstFormat = sinkFormat;
}
if (srcFormat == dstFormat) {
- ALOGV("same format");
newBuffer = buffer;
return OK;
}
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h
index 5f84a06..23c87ae 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h
@@ -17,9 +17,13 @@
#ifndef NUPLAYER_DECODER_H_
#define NUPLAYER_DECODER_H_
-#include "NuPlayer.h"
+#include <media/stagefright/foundation/AMessage.h>
+#include "NuPlayer.h"
#include "NuPlayerDecoderBase.h"
+#include "NuPlayerSource.h"
+
+#include "mediaplayerservice/AVNuExtensions.h"
namespace android {
@@ -49,7 +53,8 @@ protected:
virtual void onFlush();
virtual void onShutdown(bool notifyComplete);
virtual bool doRequestBuffers();
- virtual void setPcmFormat(const sp<AMessage> & /*format*/) {}
+ virtual void setPcmFormat(const sp<AMessage> &format) { format->setInt32("pcm-format",
+ AVNuUtils::get()->getKeyPCMFormat(mSource->getFormatMeta(true))); }
enum {
kWhatCodecNotify = 'cdcN',
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.h b/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.h
index fbc4087..cfd61da 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.h
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.h
@@ -18,6 +18,8 @@
#define NUPLAYER_DECODER_PASS_THROUGH_H_
+#include <media/stagefright/foundation/AMessage.h>
+
#include "NuPlayer.h"
#include "NuPlayerDecoderBase.h"
@@ -43,7 +45,7 @@ protected:
virtual void onFlush();
virtual void onShutdown(bool notifyComplete);
virtual bool doRequestBuffers();
- virtual void setPcmFormat(const sp<AMessage> & /*format*/) {}
+ virtual void setPcmFormat(const sp<AMessage> &format) { format->setInt32("pcm-format", mPCMFormat); }
virtual sp<ABuffer> aggregateBuffer(const sp<ABuffer> &accessUnit);
enum {