frameworks/av
Revision | 37940eefcba982836b579fe1ffec6cada72b0974 (tree) |
---|---|
Time | 2009-09-02 08:02:43 |
Author | Andreas Huber <andih@goog...> |
Commiter | Andreas Huber |
Squashed commit of the following:
commit c45bfbb97ccd05982008df47181f9c73abaf0497
Author: Andreas Huber <andih@google.com>
Date: Tue Sep 1 15:58:12 2009 -0700
commit 21d72e80e795fcae53d9c3bcc8ba6312b081e420
Author: Andreas Huber <andih@google.com>
Date: Tue Sep 1 15:55:45 2009 -0700
commit 84d507def8999c146ce124cc8edfe106c9ca70c2
Author: Andreas Huber <andih@google.com>
Date: Tue Sep 1 15:16:23 2009 -0700
@@ -136,7 +136,7 @@ private: | ||
136 | 136 | void clearCodecSpecificData(); |
137 | 137 | |
138 | 138 | void setAMRFormat(); |
139 | - void setAACFormat(); | |
139 | + void setAACFormat(int32_t numChannels, int32_t sampleRate); | |
140 | 140 | |
141 | 141 | status_t setVideoPortFormatType( |
142 | 142 | OMX_U32 portIndex, |
@@ -302,7 +302,11 @@ sp<OMXCodec> OMXCodec::Create( | ||
302 | 302 | codec->setAMRFormat(); |
303 | 303 | } |
304 | 304 | if (!createEncoder && !strcasecmp("audio/mp4a-latm", mime)) { |
305 | - codec->setAACFormat(); | |
305 | + int32_t numChannels, sampleRate; | |
306 | + CHECK(meta->findInt32(kKeyChannelCount, &numChannels)); | |
307 | + CHECK(meta->findInt32(kKeySampleRate, &sampleRate)); | |
308 | + | |
309 | + codec->setAACFormat(numChannels, sampleRate); | |
306 | 310 | } |
307 | 311 | if (!strncasecmp(mime, "video/", 6)) { |
308 | 312 | int32_t width, height; |
@@ -1321,10 +1325,6 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) { | ||
1321 | 1325 | return; |
1322 | 1326 | } |
1323 | 1327 | |
1324 | - // We're going to temporarily give up the lock while reading data | |
1325 | - // from the source. A certain client unfortunately chose to have the | |
1326 | - // thread supplying input data and reading output data be the same... | |
1327 | - | |
1328 | 1328 | MediaBuffer *srcBuffer; |
1329 | 1329 | status_t err; |
1330 | 1330 | if (mSeekTimeUs >= 0) { |
@@ -1332,13 +1332,10 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) { | ||
1332 | 1332 | options.setSeekTo(mSeekTimeUs); |
1333 | 1333 | mSeekTimeUs = -1; |
1334 | 1334 | |
1335 | - mLock.unlock(); | |
1336 | 1335 | err = mSource->read(&srcBuffer, &options); |
1337 | 1336 | } else { |
1338 | - mLock.unlock(); | |
1339 | 1337 | err = mSource->read(&srcBuffer); |
1340 | 1338 | } |
1341 | - mLock.lock(); | |
1342 | 1339 | |
1343 | 1340 | OMX_U32 flags = OMX_BUFFERFLAG_ENDOFFRAME; |
1344 | 1341 | OMX_TICKS timestamp = 0; |
@@ -1496,20 +1493,22 @@ void OMXCodec::setAMRFormat() { | ||
1496 | 1493 | } |
1497 | 1494 | } |
1498 | 1495 | |
1499 | -void OMXCodec::setAACFormat() { | |
1500 | - OMX_AUDIO_PARAM_AACPROFILETYPE def; | |
1501 | - def.nSize = sizeof(def); | |
1502 | - def.nVersion.s.nVersionMajor = 1; | |
1503 | - def.nVersion.s.nVersionMinor = 1; | |
1504 | - def.nPortIndex = kPortIndexInput; | |
1496 | +void OMXCodec::setAACFormat(int32_t numChannels, int32_t sampleRate) { | |
1497 | + OMX_AUDIO_PARAM_AACPROFILETYPE profile; | |
1498 | + profile.nSize = sizeof(profile); | |
1499 | + profile.nVersion.s.nVersionMajor = 1; | |
1500 | + profile.nVersion.s.nVersionMinor = 1; | |
1501 | + profile.nPortIndex = kPortIndexInput; | |
1505 | 1502 | |
1506 | 1503 | status_t err = |
1507 | - mOMX->get_parameter(mNode, OMX_IndexParamAudioAac, &def, sizeof(def)); | |
1504 | + mOMX->get_parameter(mNode, OMX_IndexParamAudioAac, &profile, sizeof(profile)); | |
1508 | 1505 | CHECK_EQ(err, OK); |
1509 | 1506 | |
1510 | - def.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP4ADTS; | |
1507 | + profile.nChannels = numChannels; | |
1508 | + profile.nSampleRate = sampleRate; | |
1509 | + profile.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP4ADTS; | |
1511 | 1510 | |
1512 | - err = mOMX->set_parameter(mNode, OMX_IndexParamAudioAac, &def, sizeof(def)); | |
1511 | + err = mOMX->set_parameter(mNode, OMX_IndexParamAudioAac, &profile, sizeof(profile)); | |
1513 | 1512 | CHECK_EQ(err, OK); |
1514 | 1513 | } |
1515 | 1514 |
@@ -2123,8 +2122,19 @@ void OMXCodec::initOutputFormat(const sp<MetaData> &inputFormat) { | ||
2123 | 2122 | inputFormat->findInt32(kKeyChannelCount, &numChannels); |
2124 | 2123 | inputFormat->findInt32(kKeySampleRate, &sampleRate); |
2125 | 2124 | |
2125 | + if ((OMX_U32)numChannels != params.nChannels) { | |
2126 | + LOGW("Codec outputs a different number of channels than " | |
2127 | + "the input stream contains."); | |
2128 | + } | |
2129 | + | |
2126 | 2130 | mOutputFormat->setCString(kKeyMIMEType, "audio/raw"); |
2127 | - mOutputFormat->setInt32(kKeyChannelCount, numChannels); | |
2131 | + | |
2132 | + // Use the codec-advertised number of channels, as some | |
2133 | + // codecs appear to output stereo even if the input data is | |
2134 | + // mono. | |
2135 | + mOutputFormat->setInt32(kKeyChannelCount, params.nChannels); | |
2136 | + | |
2137 | + // The codec-reported sampleRate is not reliable... | |
2128 | 2138 | mOutputFormat->setInt32(kKeySampleRate, sampleRate); |
2129 | 2139 | break; |
2130 | 2140 | } |