diff options
Diffstat (limited to 'audio_utils/spdif')
-rw-r--r-- | audio_utils/spdif/AC3FrameScanner.cpp | 11 | ||||
-rw-r--r-- | audio_utils/spdif/AC3FrameScanner.h | 2 | ||||
-rw-r--r-- | audio_utils/spdif/SPDIFEncoder.cpp | 6 |
3 files changed, 15 insertions, 4 deletions
diff --git a/audio_utils/spdif/AC3FrameScanner.cpp b/audio_utils/spdif/AC3FrameScanner.cpp index 7f8068d0..ffbedb52 100644 --- a/audio_utils/spdif/AC3FrameScanner.cpp +++ b/audio_utils/spdif/AC3FrameScanner.cpp @@ -126,6 +126,12 @@ void AC3FrameScanner::resetBurst() } } +// Per IEC 61973-3:5.3.3, for E-AC3 burst-length shall be in bytes. +uint16_t AC3FrameScanner::convertBytesToLengthCode(uint16_t numBytes) const +{ + return (mDataType == SPDIF_DATA_TYPE_E_AC3) ? numBytes : numBytes * 8; +} + // per IEC 61973-3 Paragraph 5.3.3 // We have to send 6 audio blocks on all active substreams. // Substream zero must be the first. @@ -204,7 +210,10 @@ bool AC3FrameScanner::parseHeader() // Keep track of how many audio blocks we have for each substream. // This should be safe because mSubstreamID is ANDed with 0x07 above. // And the array is allocated as [8]. - mSubstreamBlockCounts[mSubstreamID] += mAudioBlocksPerSyncFrame; + if ((mStreamType == AC3_STREAM_TYPE_0) + || (mStreamType == AC3_STREAM_TYPE_2)) { + mSubstreamBlockCounts[mSubstreamID] += mAudioBlocksPerSyncFrame; + } // Print enough so we can see all the substreams. ALOGD_IF((mFormatDumpCount < 3*8 ), diff --git a/audio_utils/spdif/AC3FrameScanner.h b/audio_utils/spdif/AC3FrameScanner.h index f944dcc0..1ef56108 100644 --- a/audio_utils/spdif/AC3FrameScanner.h +++ b/audio_utils/spdif/AC3FrameScanner.h @@ -47,6 +47,8 @@ public: virtual bool isLastInBurst(); virtual void resetBurst(); + virtual uint16_t convertBytesToLengthCode(uint16_t numBytes) const; + protected: // Keep track of how many of each substream blocks have been accumulated. // We need all of each substream before sending block data burst. diff --git a/audio_utils/spdif/SPDIFEncoder.cpp b/audio_utils/spdif/SPDIFEncoder.cpp index 7a546276..2eeeba66 100644 --- a/audio_utils/spdif/SPDIFEncoder.cpp +++ b/audio_utils/spdif/SPDIFEncoder.cpp @@ -175,9 +175,9 @@ void SPDIFEncoder::flushBurstBuffer() { const int preambleSize = 4 * sizeof(uint16_t); if (mByteCursor > preambleSize) { - // Set number of bits for valid payload before zeroPad. - uint16_t lengthCode = (mByteCursor - preambleSize) * 8; - mBurstBuffer[3] = lengthCode; + // Set lengthCode for valid payload before zeroPad. + uint16_t numBytes = (mByteCursor - preambleSize); + mBurstBuffer[3] = mFramer->convertBytesToLengthCode(numBytes); sendZeroPad(); writeOutput(mBurstBuffer, mByteCursor); |