summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/media/stagefright/MetaData.h7
-rw-r--r--media/libmediaplayerservice/nuplayer/GenericSource.cpp59
-rw-r--r--media/libmediaplayerservice/nuplayer/GenericSource.h5
-rw-r--r--media/libstagefright/httplive/M3UParser.cpp10
-rw-r--r--services/audioflinger/AudioFlinger.cpp5
-rw-r--r--services/audioflinger/AudioFlinger.h2
-rwxr-xr-xservices/audioflinger/Threads.cpp4
-rw-r--r--services/audioflinger/Tracks.cpp6
-rw-r--r--services/audiopolicy/AudioPolicyManager.cpp21
9 files changed, 106 insertions, 13 deletions
diff --git a/include/media/stagefright/MetaData.h b/include/media/stagefright/MetaData.h
index d38d976..087d016 100644
--- a/include/media/stagefright/MetaData.h
+++ b/include/media/stagefright/MetaData.h
@@ -166,6 +166,13 @@ enum {
kKeyCryptoDefaultIVSize = 'cryS', // int32_t
kKeyPssh = 'pssh', // raw data
+
+ // Please see MediaFormat.KEY_IS_AUTOSELECT.
+ kKeyTrackIsAutoselect = 'auto', // bool (int32_t)
+ // Please see MediaFormat.KEY_IS_DEFAULT.
+ kKeyTrackIsDefault = 'dflt', // bool (int32_t)
+ // Similar to MediaFormat.KEY_IS_FORCED_SUBTITLE but pertains to av tracks as well.
+ kKeyTrackIsForced = 'frcd', // bool (int32_t)
};
enum {
diff --git a/media/libmediaplayerservice/nuplayer/GenericSource.cpp b/media/libmediaplayerservice/nuplayer/GenericSource.cpp
index 388f77a..cc0cb01 100644
--- a/media/libmediaplayerservice/nuplayer/GenericSource.cpp
+++ b/media/libmediaplayerservice/nuplayer/GenericSource.cpp
@@ -81,11 +81,12 @@ void NuPlayer::GenericSource::initFromDataSource(
const char *mime;
CHECK(meta->findCString(kKeyMIMEType, &mime));
- sp<MediaSource> track;
+ sp<MediaSource> track = extractor->getTrack(i);
if (!strncasecmp(mime, "audio/", 6)) {
if (mAudioTrack.mSource == NULL) {
- mAudioTrack.mSource = track = extractor->getTrack(i);
+ mAudioTrack.mIndex = i;
+ mAudioTrack.mSource = track;
if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_VORBIS)) {
mAudioIsVorbis = true;
@@ -95,11 +96,13 @@ void NuPlayer::GenericSource::initFromDataSource(
}
} else if (!strncasecmp(mime, "video/", 6)) {
if (mVideoTrack.mSource == NULL) {
- mVideoTrack.mSource = track = extractor->getTrack(i);
+ mVideoTrack.mIndex = i;
+ mVideoTrack.mSource = track;
}
}
if (track != NULL) {
+ mSources.push(track);
int64_t durationUs;
if (meta->findInt64(kKeyDuration, &durationUs)) {
if (durationUs > mDurationUs) {
@@ -194,6 +197,56 @@ status_t NuPlayer::GenericSource::getDuration(int64_t *durationUs) {
return OK;
}
+size_t NuPlayer::GenericSource::getTrackCount() const {
+ return mSources.size();
+}
+
+sp<AMessage> NuPlayer::GenericSource::getTrackInfo(size_t trackIndex) const {
+ size_t trackCount = mSources.size();
+ if (trackIndex >= trackCount) {
+ return NULL;
+ }
+
+ sp<AMessage> format = new AMessage();
+ sp<MetaData> meta = mSources.itemAt(trackIndex)->getFormat();
+
+ const char *mime;
+ CHECK(meta->findCString(kKeyMIMEType, &mime));
+
+ int32_t trackType;
+ if (!strncasecmp(mime, "video/", 6)) {
+ trackType = MEDIA_TRACK_TYPE_VIDEO;
+ } else if (!strncasecmp(mime, "audio/", 6)) {
+ trackType = MEDIA_TRACK_TYPE_AUDIO;
+ } else if (!strcasecmp(mime, MEDIA_MIMETYPE_TEXT_3GPP)) {
+ trackType = MEDIA_TRACK_TYPE_TIMEDTEXT;
+ } else {
+ trackType = MEDIA_TRACK_TYPE_UNKNOWN;
+ }
+ format->setInt32("type", trackType);
+
+ const char *lang;
+ if (!meta->findCString(kKeyMediaLanguage, &lang)) {
+ lang = "und";
+ }
+ format->setString("language", lang);
+
+ if (trackType == MEDIA_TRACK_TYPE_SUBTITLE) {
+ format->setString("mime", mime);
+
+ int32_t isAutoselect = 1, isDefault = 0, isForced = 0;
+ meta->findInt32(kKeyTrackIsAutoselect, &isAutoselect);
+ meta->findInt32(kKeyTrackIsDefault, &isDefault);
+ meta->findInt32(kKeyTrackIsForced, &isForced);
+
+ format->setInt32("auto", !!isAutoselect);
+ format->setInt32("default", !!isDefault);
+ format->setInt32("forced", !!isForced);
+ }
+
+ return format;
+}
+
status_t NuPlayer::GenericSource::seekTo(int64_t seekTimeUs) {
if (mVideoTrack.mSource != NULL) {
int64_t actualTimeUs;
diff --git a/media/libmediaplayerservice/nuplayer/GenericSource.h b/media/libmediaplayerservice/nuplayer/GenericSource.h
index 20d597e..e0cd20f 100644
--- a/media/libmediaplayerservice/nuplayer/GenericSource.h
+++ b/media/libmediaplayerservice/nuplayer/GenericSource.h
@@ -50,6 +50,8 @@ struct NuPlayer::GenericSource : public NuPlayer::Source {
virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit);
virtual status_t getDuration(int64_t *durationUs);
+ virtual size_t getTrackCount() const;
+ virtual sp<AMessage> getTrackInfo(size_t trackIndex) const;
virtual status_t seekTo(int64_t seekTimeUs);
protected:
@@ -58,7 +60,10 @@ protected:
virtual sp<MetaData> getFormatMeta(bool audio);
private:
+ Vector<sp<MediaSource> > mSources;
+
struct Track {
+ size_t mIndex;
sp<MediaSource> mSource;
sp<AnotherPacketSource> mPackets;
};
diff --git a/media/libstagefright/httplive/M3UParser.cpp b/media/libstagefright/httplive/M3UParser.cpp
index 281e0da..efd852c 100644
--- a/media/libstagefright/httplive/M3UParser.cpp
+++ b/media/libstagefright/httplive/M3UParser.cpp
@@ -413,6 +413,8 @@ static bool MakeURL(const char *baseURL, const char *url, AString *out) {
// Base URL must be absolute
return false;
}
+ const size_t schemeEnd = (strstr(baseURL, "//") - baseURL) + 2;
+ CHECK(schemeEnd == 7 || schemeEnd == 8);
if (!strncasecmp("http://", url, 7) || !strncasecmp("https://", url, 8)) {
// "url" is already an absolute URL, ignore base URL.
@@ -457,7 +459,7 @@ static bool MakeURL(const char *baseURL, const char *url, AString *out) {
// Check whether the found slash actually is part of the path
// and not part of the "http://".
- if (end > 6) {
+ if (end >= schemeEnd) {
out->setTo(baseURL, end);
} else {
out->setTo(baseURL);
@@ -728,6 +730,9 @@ status_t M3UParser::parseStreamInf(
key.tolower();
const AString &codecs = unquoteString(val);
+ if (meta->get() == NULL) {
+ *meta = new AMessage;
+ }
(*meta)->setString(key.c_str(), codecs.c_str());
} else if (!strcasecmp("audio", key.c_str())
|| !strcasecmp("video", key.c_str())
@@ -751,6 +756,9 @@ status_t M3UParser::parseStreamInf(
}
key.tolower();
+ if (meta->get() == NULL) {
+ *meta = new AMessage;
+ }
(*meta)->setString(key.c_str(), groupID.c_str());
}
}
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 5fed0c1..5fd7ce8 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -1847,8 +1847,9 @@ audio_io_handle_t AudioFlinger::openInput(audio_module_handle_t module,
audio_io_handle_t id = nextUniqueId();
audio_stream_in_t *inStream = NULL;
+ audio_input_flags_t flags = AUDIO_INPUT_FLAG_FAST; // FIXME until added to openInput()
status_t status = inHwHal->open_input_stream(inHwHal, id, *pDevices, &config,
- &inStream);
+ &inStream, flags);
ALOGV("openInput() openInputStream returned input %p, SamplingRate %d, Format %#x, Channels %x, "
"status %d",
inStream,
@@ -1868,7 +1869,7 @@ audio_io_handle_t AudioFlinger::openInput(audio_module_handle_t module,
// FIXME describe the change proposed by HAL (save old values so we can log them here)
ALOGV("openInput() reopening with proposed sampling rate and channel mask");
inStream = NULL;
- status = inHwHal->open_input_stream(inHwHal, id, *pDevices, &config, &inStream);
+ status = inHwHal->open_input_stream(inHwHal, id, *pDevices, &config, &inStream, flags);
// FIXME log this new status; HAL should not propose any further changes
}
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index be19554..4df0921 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -327,7 +327,7 @@ private:
void purgeStaleEffects_l();
// Set kEnableExtendedPrecision to true to use extended precision in MixerThread
- static const bool kEnableExtendedPrecision = true;
+ static const bool kEnableExtendedPrecision = false;
// Returns true if format is permitted for the PCM sink in the MixerThread
static inline bool isValidPcmSinkFormat(audio_format_t format) {
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 0f01b02..e17aa98 100755
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -4783,7 +4783,7 @@ AudioFlinger::RecordThread::RecordThread(const sp<AudioFlinger>& audioFlinger,
, mPipeFramesP2(0)
// mPipeMemory
// mFastCaptureNBLogWriter
- , mFastTrackAvail(true)
+ , mFastTrackAvail(false)
{
snprintf(mName, kNameLength, "AudioIn_%X", id);
mNBLogWriter = audioFlinger->newWriter_l(kLogSize, mName);
@@ -4895,6 +4895,7 @@ AudioFlinger::RecordThread::RecordThread(const sp<AudioFlinger>& audioFlinger,
// FIXME
#endif
+ mFastTrackAvail = true;
}
failed: ;
@@ -5745,6 +5746,7 @@ void AudioFlinger::RecordThread::dumpInternals(int fd, const Vector<String16>& a
} else {
dprintf(fd, " No active record clients\n");
}
+ dprintf(fd, " Fast capture thread: %s\n", hasFastCapture() ? "yes" : "no");
dprintf(fd, " Fast track available: %s\n", mFastTrackAvail ? "yes" : "no");
dumpBase(fd, args);
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index cacb066..eb3e6b4 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -1987,12 +1987,12 @@ void AudioFlinger::RecordThread::RecordTrack::invalidate()
/*static*/ void AudioFlinger::RecordThread::RecordTrack::appendDumpHeader(String8& result)
{
- result.append(" Active Client Fmt Chn mask Session S Server fCount Resampling\n");
+ result.append(" Active Client Fmt Chn mask Session S Server fCount SRate\n");
}
void AudioFlinger::RecordThread::RecordTrack::dump(char* buffer, size_t size, bool active)
{
- snprintf(buffer, size, " %6s %6u %3u %08X %7u %1d %08X %6zu %10d\n",
+ snprintf(buffer, size, " %6s %6u %3u %08X %7u %1d %08X %6zu %5u\n",
active ? "yes" : "no",
(mClient == 0) ? getpid_cached : mClient->pid(),
mFormat,
@@ -2001,7 +2001,7 @@ void AudioFlinger::RecordThread::RecordTrack::dump(char* buffer, size_t size, bo
mState,
mCblk->mServer,
mFrameCount,
- mResampler != NULL);
+ mSampleRate);
}
diff --git a/services/audiopolicy/AudioPolicyManager.cpp b/services/audiopolicy/AudioPolicyManager.cpp
index 1b4796b..f2320de 100644
--- a/services/audiopolicy/AudioPolicyManager.cpp
+++ b/services/audiopolicy/AudioPolicyManager.cpp
@@ -560,6 +560,13 @@ void AudioPolicyManager::setForceUse(audio_policy_force_use_t usage,
forceVolumeReeval = true;
mForceUse[usage] = config;
break;
+ case AUDIO_POLICY_FORCE_FOR_HDMI_SYSTEM_AUDIO:
+ if (config != AUDIO_POLICY_FORCE_NONE &&
+ config != AUDIO_POLICY_FORCE_HDMI_SYSTEM_AUDIO_ENFORCED) {
+ ALOGW("setForceUse() invalid config %d forHDMI_SYSTEM_AUDIO", config);
+ }
+ mForceUse[usage] = config;
+ break;
default:
ALOGW("setForceUse() invalid usage %d", usage);
break;
@@ -1529,6 +1536,9 @@ status_t AudioPolicyManager::dump(int fd)
result.append(buffer);
snprintf(buffer, SIZE, " Force use for system %d\n", mForceUse[AUDIO_POLICY_FORCE_FOR_SYSTEM]);
result.append(buffer);
+ snprintf(buffer, SIZE, " Force use for hdmi system audio %d\n",
+ mForceUse[AUDIO_POLICY_FORCE_FOR_HDMI_SYSTEM_AUDIO]);
+ result.append(buffer);
snprintf(buffer, SIZE, " Available output devices:\n");
result.append(buffer);
@@ -3554,10 +3564,10 @@ audio_devices_t AudioPolicyManager::getDeviceForStrategy(routing_strategy strate
}
int device3 = AUDIO_DEVICE_NONE;
if (strategy == STRATEGY_MEDIA) {
- // ARC, SPDIF and LINE can co-exist with others.
+ // ARC, SPDIF and AUX_LINE can co-exist with others.
device3 = availableOutputDeviceTypes & AUDIO_DEVICE_OUT_HDMI_ARC;
device3 |= (availableOutputDeviceTypes & AUDIO_DEVICE_OUT_SPDIF);
- device3 |= (availableOutputDeviceTypes & AUDIO_DEVICE_OUT_LINE);
+ device3 |= (availableOutputDeviceTypes & AUDIO_DEVICE_OUT_AUX_LINE);
}
device2 |= device3;
@@ -3565,6 +3575,13 @@ audio_devices_t AudioPolicyManager::getDeviceForStrategy(routing_strategy strate
// STRATEGY_ENFORCED_AUDIBLE, AUDIO_DEVICE_NONE otherwise
device |= device2;
+ // If hdmi system audio mode is on, remove speaker out of output list.
+ if ((strategy == STRATEGY_MEDIA) &&
+ (mForceUse[AUDIO_POLICY_FORCE_FOR_HDMI_SYSTEM_AUDIO] ==
+ AUDIO_POLICY_FORCE_HDMI_SYSTEM_AUDIO_ENFORCED)) {
+ device &= ~AUDIO_DEVICE_OUT_SPEAKER;
+ }
+
if (device) break;
device = mDefaultOutputDevice->mDeviceType;
if (device == AUDIO_DEVICE_NONE) {