assert => CHECK in stagefright.
diff --git a/media/libstagefright/AudioPlayer.cpp b/media/libstagefright/AudioPlayer.cpp
index e8571b5..140bc68 100644
--- a/media/libstagefright/AudioPlayer.cpp
+++ b/media/libstagefright/AudioPlayer.cpp
@@ -14,14 +14,12 @@
* limitations under the License.
*/
-#undef NDEBUG
-#include <assert.h>
-
#define LOG_TAG "AudioPlayer"
#include <utils/Log.h>
#include <media/AudioTrack.h>
#include <media/stagefright/AudioPlayer.h>
+#include <media/stagefright/MediaDebug.h>
#include <media/stagefright/MediaSource.h>
#include <media/stagefright/MetaData.h>
@@ -48,36 +46,36 @@
}
void AudioPlayer::setSource(const sp<MediaSource> &source) {
- assert(mSource == NULL);
+ CHECK_EQ(mSource, NULL);
mSource = source;
}
void AudioPlayer::start() {
- assert(!mStarted);
- assert(mSource != NULL);
+ CHECK(!mStarted);
+ CHECK(mSource != NULL);
status_t err = mSource->start();
- assert(err == OK);
+ CHECK_EQ(err, OK);
sp<MetaData> format = mSource->getFormat();
const char *mime;
bool success = format->findCString(kKeyMIMEType, &mime);
- assert(success);
- assert(!strcasecmp(mime, "audio/raw"));
+ CHECK(success);
+ CHECK(!strcasecmp(mime, "audio/raw"));
success = format->findInt32(kKeySampleRate, &mSampleRate);
- assert(success);
+ CHECK(success);
int32_t numChannels;
success = format->findInt32(kKeyChannelCount, &numChannels);
- assert(success);
+ CHECK(success);
if (mAudioSink.get() != NULL) {
status_t err = mAudioSink->open(
mSampleRate, numChannels, AudioSystem::PCM_16_BIT,
DEFAULT_AUDIOSINK_BUFFERCOUNT,
&AudioPlayer::AudioSinkCallback, this);
- assert(err == OK);
+ CHECK_EQ(err, OK);
mLatencyUs = (int64_t)mAudioSink->latency() * 1000;
mFrameSize = mAudioSink->frameSize();
@@ -91,7 +89,7 @@
: AudioSystem::CHANNEL_OUT_MONO,
8192, 0, &AudioCallback, this, 0);
- assert(mAudioTrack->initCheck() == OK);
+ CHECK_EQ(mAudioTrack->initCheck(), OK);
mLatencyUs = (int64_t)mAudioTrack->latency() * 1000;
mFrameSize = mAudioTrack->frameSize();
@@ -103,7 +101,7 @@
}
void AudioPlayer::pause() {
- assert(mStarted);
+ CHECK(mStarted);
if (mAudioSink.get() != NULL) {
mAudioSink->pause();
@@ -113,7 +111,7 @@
}
void AudioPlayer::resume() {
- assert(mStarted);
+ CHECK(mStarted);
if (mAudioSink.get() != NULL) {
mAudioSink->start();
@@ -123,7 +121,7 @@
}
void AudioPlayer::stop() {
- assert(mStarted);
+ CHECK(mStarted);
if (mAudioSink.get() != NULL) {
mAudioSink->stop();
@@ -202,7 +200,7 @@
if (mInputBuffer == NULL) {
status_t err = mSource->read(&mInputBuffer, &options);
- assert((err == OK && mInputBuffer != NULL)
+ CHECK((err == OK && mInputBuffer != NULL)
|| (err != OK && mInputBuffer == NULL));
if (err != OK) {
@@ -215,7 +213,7 @@
mInputBuffer->meta_data()->findInt32(kKeyTimeUnits, &units);
success = success &&
mInputBuffer->meta_data()->findInt32(kKeyTimeScale, &scale);
- assert(success);
+ CHECK(success);
Mutex::Autolock autoLock(mLock);
mPositionTimeMediaUs = (int64_t)units * 1000000 / scale;
diff --git a/media/libstagefright/CachingDataSource.cpp b/media/libstagefright/CachingDataSource.cpp
index d599cd5..fd00576 100644
--- a/media/libstagefright/CachingDataSource.cpp
+++ b/media/libstagefright/CachingDataSource.cpp
@@ -14,14 +14,12 @@
* limitations under the License.
*/
-#include <media/stagefright/CachingDataSource.h>
-
-#undef NDEBUG
-#include <assert.h>
-
#include <stdlib.h>
#include <string.h>
+#include <media/stagefright/CachingDataSource.h>
+#include <media/stagefright/MediaDebug.h>
+
namespace android {
CachingDataSource::CachingDataSource(
diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp
index ee12873..f75b173 100644
--- a/media/libstagefright/CameraSource.cpp
+++ b/media/libstagefright/CameraSource.cpp
@@ -16,13 +16,11 @@
#include <sys/time.h>
-#undef NDEBUG
-#include <assert.h>
-
#include <OMX_Component.h>
#include <binder/IServiceManager.h>
#include <media/stagefright/CameraSource.h>
+#include <media/stagefright/MediaDebug.h>
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/MetaData.h>
#include <ui/ICameraClient.h>
@@ -56,12 +54,12 @@
}
virtual void notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2) {
- assert(mSource != NULL);
+ CHECK(mSource != NULL);
mSource->notifyCallback(msgType, ext1, ext2);
}
virtual void dataCallback(int32_t msgType, const sp<IMemory> &data) {
- assert(mSource != NULL);
+ CHECK(mSource != NULL);
mSource->dataCallback(msgType, data);
}
@@ -128,16 +126,16 @@
}
status_t CameraSource::start(MetaData *) {
- assert(!mStarted);
+ CHECK(!mStarted);
status_t err = mCamera->lock();
- assert(err == OK);
+ CHECK_EQ(err, OK);
err = mCamera->setPreviewDisplay(new DummySurface);
- assert(err == OK);
+ CHECK_EQ(err, OK);
mCamera->setPreviewCallbackFlag(1);
mCamera->startPreview();
- assert(err == OK);
+ CHECK_EQ(err, OK);
mStarted = true;
@@ -145,7 +143,7 @@
}
status_t CameraSource::stop() {
- assert(mStarted);
+ CHECK(mStarted);
mCamera->stopPreview();
mCamera->unlock();
@@ -167,7 +165,7 @@
status_t CameraSource::read(
MediaBuffer **buffer, const ReadOptions *options) {
- assert(mStarted);
+ CHECK(mStarted);
*buffer = NULL;
diff --git a/media/libstagefright/FileSource.cpp b/media/libstagefright/FileSource.cpp
index c26d0a0..f6b90b2 100644
--- a/media/libstagefright/FileSource.cpp
+++ b/media/libstagefright/FileSource.cpp
@@ -15,9 +15,7 @@
*/
#include <media/stagefright/FileSource.h>
-
-#undef NDEBUG
-#include <assert.h>
+#include <media/stagefright/MediaDebug.h>
namespace android {
@@ -40,7 +38,7 @@
Mutex::Autolock autoLock(mLock);
int err = fseeko(mFile, offset, SEEK_SET);
- assert(err != -1);
+ CHECK(err != -1);
ssize_t result = fread(data, 1, size, mFile);
diff --git a/media/libstagefright/HTTPDataSource.cpp b/media/libstagefright/HTTPDataSource.cpp
index d1f8cd4..698223b 100644
--- a/media/libstagefright/HTTPDataSource.cpp
+++ b/media/libstagefright/HTTPDataSource.cpp
@@ -14,13 +14,11 @@
* limitations under the License.
*/
-#undef NDEBUG
-#include <assert.h>
-
#include <stdlib.h>
#include <media/stagefright/HTTPDataSource.h>
#include <media/stagefright/HTTPStream.h>
+#include <media/stagefright/MediaDebug.h>
#include <media/stagefright/string.h>
namespace android {
@@ -32,7 +30,7 @@
mBuffer(malloc(kBufferSize)),
mBufferLength(0),
mBufferOffset(0) {
- assert(!strncasecmp("http://", uri, 7));
+ CHECK(!strncasecmp("http://", uri, 7));
string host;
string path;
@@ -53,8 +51,8 @@
} else {
char *end;
long tmp = strtol(colon + 1, &end, 10);
- assert(end > colon + 1);
- assert(tmp > 0 && tmp < 65536);
+ CHECK(end > colon + 1);
+ CHECK(tmp > 0 && tmp < 65536);
port = tmp;
host = string(host, 0, colon - host.c_str());
@@ -68,7 +66,7 @@
mPath = strdup(path.c_str());
status_t err = mHttp.connect(mHost, mPort);
- assert(err == OK);
+ CHECK_EQ(err, OK);
}
HTTPDataSource::HTTPDataSource(const char *host, int port, const char *path)
@@ -79,7 +77,7 @@
mBufferLength(0),
mBufferOffset(0) {
status_t err = mHttp.connect(mHost, mPort);
- assert(err == OK);
+ CHECK_EQ(err, OK);
}
HTTPDataSource::~HTTPDataSource() {
diff --git a/media/libstagefright/HTTPStream.cpp b/media/libstagefright/HTTPStream.cpp
index 29e6f72..098ddbd 100644
--- a/media/libstagefright/HTTPStream.cpp
+++ b/media/libstagefright/HTTPStream.cpp
@@ -17,7 +17,6 @@
#include <sys/socket.h>
#include <arpa/inet.h>
-#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <netdb.h>
@@ -27,6 +26,7 @@
#include <unistd.h>
#include <media/stagefright/HTTPStream.h>
+#include <media/stagefright/MediaDebug.h>
namespace android {
@@ -49,7 +49,7 @@
return ERROR_ALREADY_CONNECTED;
}
- assert(mSocket == -1);
+ CHECK_EQ(mSocket, -1);
mSocket = socket(AF_INET, SOCK_STREAM, 0);
if (mSocket < 0) {
@@ -89,7 +89,7 @@
return ERROR_NOT_CONNECTED;
}
- assert(mSocket >= 0);
+ CHECK(mSocket >= 0);
close(mSocket);
mSocket = -1;
@@ -165,7 +165,7 @@
saw_CR = (c == '\r');
- assert(length + 1 < size);
+ CHECK(length + 1 < size);
line[length++] = c;
}
}
diff --git a/media/libstagefright/MP3Extractor.cpp b/media/libstagefright/MP3Extractor.cpp
index 44258ba..14f3e0c 100644
--- a/media/libstagefright/MP3Extractor.cpp
+++ b/media/libstagefright/MP3Extractor.cpp
@@ -18,13 +18,11 @@
#define LOG_TAG "MP3Extractor"
#include <utils/Log.h>
-#undef NDEBUG
-#include <assert.h>
-
#include <media/stagefright/DataSource.h>
#include <media/stagefright/MP3Extractor.h>
#include <media/stagefright/MediaBuffer.h>
#include <media/stagefright/MediaBufferGroup.h>
+#include <media/stagefright/MediaDebug.h>
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/MediaSource.h>
#include <media/stagefright/MetaData.h>
@@ -317,7 +315,7 @@
off_t pos = 0;
uint32_t header;
bool success = Resync(mDataSource, 0, &pos, &header);
- assert(success);
+ CHECK(success);
if (success) {
mFirstFramePos = pos;
@@ -393,7 +391,7 @@
}
status_t MP3Source::start(MetaData *) {
- assert(!mStarted);
+ CHECK(!mStarted);
mGroup = new MediaBufferGroup;
@@ -409,7 +407,7 @@
}
status_t MP3Source::stop() {
- assert(mStarted);
+ CHECK(mStarted);
delete mGroup;
mGroup = NULL;
@@ -481,7 +479,7 @@
// Try again with the new position.
}
- assert(frame_size <= buffer->size());
+ CHECK(frame_size <= buffer->size());
ssize_t n = mDataSource->read_at(mCurrentPos, buffer->data(), frame_size);
if (n < (ssize_t)frame_size) {
diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp
index 10c4629..90b1b9a 100644
--- a/media/libstagefright/MPEG4Writer.cpp
+++ b/media/libstagefright/MPEG4Writer.cpp
@@ -16,15 +16,13 @@
#include <arpa/inet.h>
-#undef NDEBUG
-#include <assert.h>
-
#include <ctype.h>
#include <pthread.h>
#include <media/stagefright/MPEG4Writer.h>
#include <media/stagefright/MediaBuffer.h>
#include <media/stagefright/MetaData.h>
+#include <media/stagefright/MediaDebug.h>
#include <media/stagefright/MediaSource.h>
#include <media/stagefright/Utils.h>
@@ -71,7 +69,7 @@
: mFile(fopen(filename, "wb")),
mOffset(0),
mMdatOffset(0) {
- assert(mFile != NULL);
+ CHECK(mFile != NULL);
}
MPEG4Writer::~MPEG4Writer() {
@@ -173,7 +171,7 @@
}
endBox(); // moov
- assert(mBoxes.empty());
+ CHECK(mBoxes.empty());
fclose(mFile);
mFile = NULL;
@@ -193,7 +191,7 @@
}
void MPEG4Writer::beginBox(const char *fourcc) {
- assert(strlen(fourcc) == 4);
+ CHECK_EQ(strlen(fourcc), 4);
mBoxes.push_back(mOffset);
@@ -202,7 +200,7 @@
}
void MPEG4Writer::endBox() {
- assert(!mBoxes.empty());
+ CHECK(!mBoxes.empty());
off_t offset = *--mBoxes.end();
mBoxes.erase(--mBoxes.end());
@@ -244,7 +242,7 @@
}
void MPEG4Writer::writeFourcc(const char *s) {
- assert(strlen(s) == 4);
+ CHECK_EQ(strlen(s), 4);
fwrite(s, 1, 4, mFile);
mOffset += 4;
}
@@ -286,7 +284,7 @@
mDone = false;
int err = pthread_create(&mThread, &attr, ThreadWrapper, this);
- assert(err == 0);
+ CHECK_EQ(err, 0);
pthread_attr_destroy(&attr);
}
@@ -345,7 +343,7 @@
++offset;
}
- // assert(offset + 3 < size);
+ // CHECK(offset + 3 < size);
if (offset + 3 >= size) {
// XXX assume the entire first chunk of data is the codec specific
// data.
@@ -368,10 +366,10 @@
int32_t units, scale;
bool success =
buffer->meta_data()->findInt32(kKeyTimeUnits, &units);
- assert(success);
+ CHECK(success);
success =
buffer->meta_data()->findInt32(kKeyTimeScale, &scale);
- assert(success);
+ CHECK(success);
info.timestamp = (int64_t)units * 1000 / scale;
@@ -389,7 +387,7 @@
void MPEG4Writer::Track::writeTrackHeader(int32_t trackID) {
const char *mime;
bool success = mMeta->findCString(kKeyMIMEType, &mime);
- assert(success);
+ CHECK(success);
bool is_audio = !strncasecmp(mime, "audio/", 6);
@@ -428,7 +426,7 @@
int32_t width, height;
bool success = mMeta->findInt32(kKeyWidth, &width);
success = success && mMeta->findInt32(kKeyHeight, &height);
- assert(success);
+ CHECK(success);
mOwner->writeInt32(width);
mOwner->writeInt32(height);
@@ -505,7 +503,7 @@
int32_t samplerate;
bool success = mMeta->findInt32(kKeySampleRate, &samplerate);
- assert(success);
+ CHECK(success);
mOwner->writeInt32(samplerate << 16);
mOwner->endBox();
@@ -515,7 +513,7 @@
} else if (!strcasecmp("video/3gpp", mime)) {
mOwner->beginBox("s263");
} else {
- assert(!"should not be here, unknown mime type.");
+ CHECK(!"should not be here, unknown mime type.");
}
mOwner->writeInt32(0); // reserved
@@ -530,7 +528,7 @@
int32_t width, height;
bool success = mMeta->findInt32(kKeyWidth, &width);
success = success && mMeta->findInt32(kKeyHeight, &height);
- assert(success);
+ CHECK(success);
mOwner->writeInt16(width);
mOwner->writeInt16(height);
@@ -542,7 +540,7 @@
mOwner->writeInt16(0x18); // depth
mOwner->writeInt16(-1); // predefined
- assert(23 + mCodecSpecificDataSize < 128);
+ CHECK(23 + mCodecSpecificDataSize < 128);
if (!strcasecmp("video/mp4v-es", mime)) {
mOwner->beginBox("esds");
diff --git a/media/libstagefright/MediaBuffer.cpp b/media/libstagefright/MediaBuffer.cpp
index cd78dbd..f3c0e73 100644
--- a/media/libstagefright/MediaBuffer.cpp
+++ b/media/libstagefright/MediaBuffer.cpp
@@ -17,14 +17,12 @@
#define LOG_TAG "MediaBuffer"
#include <utils/Log.h>
-#undef NDEBUG
-#include <assert.h>
-
#include <errno.h>
#include <pthread.h>
#include <stdlib.h>
#include <media/stagefright/MediaBuffer.h>
+#include <media/stagefright/MediaDebug.h>
#include <media/stagefright/MetaData.h>
namespace android {
@@ -65,7 +63,7 @@
void MediaBuffer::release() {
if (mObserver == NULL) {
- assert(mRefCount == 0);
+ CHECK_EQ(mRefCount, 0);
delete this;
return;
}
@@ -79,12 +77,12 @@
mObserver->signalBufferReturned(this);
}
- assert(prevCount > 0);
+ CHECK(prevCount > 0);
}
void MediaBuffer::claim() {
- assert(mObserver != NULL);
- assert(mRefCount == 1);
+ CHECK(mObserver != NULL);
+ CHECK_EQ(mRefCount, 1);
mRefCount = 0;
}
@@ -113,7 +111,7 @@
if (offset < 0 || offset + length > mSize) {
LOGE("offset = %d, length = %d, mSize = %d", offset, length, mSize);
}
- assert(offset >= 0 && offset + length <= mSize);
+ CHECK(offset >= 0 && offset + length <= mSize);
mRangeOffset = offset;
mRangeLength = length;
@@ -129,7 +127,7 @@
}
MediaBuffer::~MediaBuffer() {
- assert(mObserver == NULL);
+ CHECK_EQ(mObserver, NULL);
if (mOwnsData && mData != NULL) {
free(mData);
@@ -143,7 +141,7 @@
}
void MediaBuffer::setObserver(MediaBufferObserver *observer) {
- assert(observer == NULL || mObserver == NULL);
+ CHECK(observer == NULL || mObserver == NULL);
mObserver = observer;
}
diff --git a/media/libstagefright/MediaBufferGroup.cpp b/media/libstagefright/MediaBufferGroup.cpp
index aec7722..c8d05f4 100644
--- a/media/libstagefright/MediaBufferGroup.cpp
+++ b/media/libstagefright/MediaBufferGroup.cpp
@@ -17,11 +17,9 @@
#define LOG_TAG "MediaBufferGroup"
#include <utils/Log.h>
-#undef NDEBUG
-#include <assert.h>
-
#include <media/stagefright/MediaBuffer.h>
#include <media/stagefright/MediaBufferGroup.h>
+#include <media/stagefright/MediaDebug.h>
namespace android {
@@ -36,7 +34,7 @@
buffer = next) {
next = buffer->nextBuffer();
- assert(buffer->refcount() == 0);
+ CHECK_EQ(buffer->refcount(), 0);
buffer->setObserver(NULL);
buffer->release();
diff --git a/media/libstagefright/MediaPlayerImpl.cpp b/media/libstagefright/MediaPlayerImpl.cpp
index 2d7b62837b..e5301bb 100644
--- a/media/libstagefright/MediaPlayerImpl.cpp
+++ b/media/libstagefright/MediaPlayerImpl.cpp
@@ -18,9 +18,6 @@
#define LOG_TAG "MediaPlayerImpl"
#include "utils/Log.h"
-#undef NDEBUG
-#include <assert.h>
-
#include <OMX_Component.h>
#include <unistd.h>
@@ -30,6 +27,7 @@
// #include <media/stagefright/CameraSource.h>
#include <media/stagefright/HTTPDataSource.h>
#include <media/stagefright/HTTPStream.h>
+#include <media/stagefright/MediaDebug.h>
#include <media/stagefright/MediaExtractor.h>
#include <media/stagefright/MediaPlayerImpl.h>
#include <media/stagefright/MetaData.h>
@@ -227,7 +225,7 @@
bool eof = false;
status_t err = mVideoDecoder->start();
- assert(err == OK);
+ CHECK_EQ(err, OK);
while (mPlaying) {
MediaBuffer *buffer;
@@ -253,7 +251,7 @@
}
status_t err = mVideoDecoder->read(&buffer, &options);
- assert((err == OK && buffer != NULL) || (err != OK && buffer == NULL));
+ CHECK((err == OK && buffer != NULL) || (err != OK && buffer == NULL));
if (err == ERROR_END_OF_STREAM || err != OK) {
eof = true;
@@ -269,10 +267,10 @@
int32_t units, scale;
bool success =
buffer->meta_data()->findInt32(kKeyTimeUnits, &units);
- assert(success);
+ CHECK(success);
success =
buffer->meta_data()->findInt32(kKeyTimeScale, &scale);
- assert(success);
+ CHECK(success);
int64_t pts_us = (int64_t)units * 1000000 / scale;
{
@@ -362,7 +360,7 @@
for (size_t i = 0; i < num_tracks; ++i) {
const sp<MetaData> meta = mExtractor->getTrackMetaData(i);
- assert(meta != NULL);
+ CHECK(meta != NULL);
const char *mime;
if (!meta->findCString(kKeyMIMEType, &mime)) {
@@ -424,10 +422,10 @@
sp<MetaData> meta = source->getFormat();
bool success = meta->findInt32(kKeyWidth, &mVideoWidth);
- assert(success);
+ CHECK(success);
success = meta->findInt32(kKeyHeight, &mVideoHeight);
- assert(success);
+ CHECK(success);
#if !USE_OMX_CODEC
mVideoDecoder = OMXDecoder::Create(
@@ -495,8 +493,8 @@
} else {
char *end;
long tmp = strtol(colon + 1, &end, 10);
- assert(end > colon + 1);
- assert(tmp > 0 && tmp < 65536);
+ CHECK(end > colon + 1);
+ CHECK(tmp > 0 && tmp < 65536);
port = tmp;
host = string(host, 0, colon - host.c_str());
@@ -510,7 +508,7 @@
for (;;) {
status_t err = http->connect(host.c_str(), port);
- assert(err == OK);
+ CHECK_EQ(err, OK);
err = http->send("GET ");
err = http->send(path.c_str());
@@ -520,13 +518,13 @@
err = http->send("\r\n");
err = http->send("Icy-MetaData: 1\r\n\r\n");
- assert(OK == http->receive_header(&http_status));
+ CHECK_EQ(OK, http->receive_header(&http_status));
if (http_status == 301 || http_status == 302) {
string location;
- assert(http->find_header_value("Location", &location));
+ CHECK(http->find_header_value("Location", &location));
- assert(string(location, 0, 7) == "http://");
+ CHECK(string(location, 0, 7) == "http://");
location.erase(0, 7);
string::size_type slashPos = location.find('/');
if (slashPos == string::npos) {
@@ -545,7 +543,7 @@
const char *start = host.c_str() + colonPos + 1;
char *end;
long tmp = strtol(start, &end, 10);
- assert(end > start && *end == '\0');
+ CHECK(end > start && (*end == '\0'));
port = (tmp >= 0 && tmp < 65536) ? (int)tmp : 80;
} else {
@@ -622,7 +620,7 @@
success = success && meta->findCString(kKeyDecoderComponent, &component);
success = success && meta->findInt32(kKeyWidth, &decodedWidth);
success = success && meta->findInt32(kKeyHeight, &decodedHeight);
- assert(success);
+ CHECK(success);
if (mSurface.get() != NULL) {
mVideoRenderer =
diff --git a/media/libstagefright/MetaData.cpp b/media/libstagefright/MetaData.cpp
index 5d23732b..6b067cb 100644
--- a/media/libstagefright/MetaData.cpp
+++ b/media/libstagefright/MetaData.cpp
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-#include <assert.h>
#include <stdlib.h>
#include <string.h>
+#include <media/stagefright/MediaDebug.h>
#include <media/stagefright/MetaData.h>
namespace android {
@@ -87,7 +87,7 @@
return false;
}
- assert(size == sizeof(*value));
+ CHECK_EQ(size, sizeof(*value));
*value = *(int32_t *)data;
@@ -102,7 +102,7 @@
return false;
}
- assert(size == sizeof(*value));
+ CHECK_EQ(size, sizeof(*value));
*value = *(float *)data;
@@ -117,7 +117,7 @@
return false;
}
- assert(size == sizeof(*value));
+ CHECK_EQ(size, sizeof(*value));
*value = *(void **)data;
diff --git a/media/libstagefright/MmapSource.cpp b/media/libstagefright/MmapSource.cpp
index 7cb861c..47d95f9 100644
--- a/media/libstagefright/MmapSource.cpp
+++ b/media/libstagefright/MmapSource.cpp
@@ -20,13 +20,11 @@
#include <sys/mman.h>
-#undef NDEBUG
-#include <assert.h>
-
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
+#include <media/stagefright/MediaDebug.h>
#include <media/stagefright/MmapSource.h>
namespace android {
@@ -36,7 +34,7 @@
mBase(NULL),
mSize(0) {
LOGV("MmapSource '%s'", filename);
- assert(mFd >= 0);
+ CHECK(mFd >= 0);
off_t size = lseek(mFd, 0, SEEK_END);
mSize = (size_t)size;
@@ -56,7 +54,7 @@
mBase(NULL),
mSize(length) {
LOGV("MmapSource fd:%d offset:%lld length:%lld", fd, offset, length);
- assert(fd >= 0);
+ CHECK(fd >= 0);
mBase = mmap(0, mSize, PROT_READ, MAP_FILE | MAP_SHARED, mFd, offset);
@@ -86,7 +84,7 @@
ssize_t MmapSource::read_at(off_t offset, void *data, size_t size) {
LOGV("read_at offset:%ld data:%p size:%d", offset, data, size);
- assert(offset >= 0);
+ CHECK(offset >= 0);
size_t avail = 0;
if (offset >= 0 && offset < (off_t)mSize) {
diff --git a/media/libstagefright/OMXClient.cpp b/media/libstagefright/OMXClient.cpp
index 5423ffa..2a32b4c 100644
--- a/media/libstagefright/OMXClient.cpp
+++ b/media/libstagefright/OMXClient.cpp
@@ -20,12 +20,10 @@
#include <sys/socket.h>
-#undef NDEBUG
-#include <assert.h>
-
#include <binder/IServiceManager.h>
#include <media/IMediaPlayerService.h>
#include <media/IOMX.h>
+#include <media/stagefright/MediaDebug.h>
#include <media/stagefright/OMXClient.h>
namespace android {
@@ -44,10 +42,10 @@
sp<IBinder> binder = sm->getService(String16("media.player"));
sp<IMediaPlayerService> service = interface_cast<IMediaPlayerService>(binder);
- assert(service.get() != NULL);
+ CHECK(service.get() != NULL);
mOMX = service->createOMX();
- assert(mOMX.get() != NULL);
+ CHECK(mOMX.get() != NULL);
mReflector = new OMXClientReflector(this);
@@ -61,7 +59,7 @@
return;
}
- assert(mObservers.isEmpty());
+ CHECK(mObservers.isEmpty());
mReflector->reset();
mReflector.clear();
@@ -88,7 +86,7 @@
Mutex::Autolock autoLock(mLock);
ssize_t index = mObservers.indexOfKey(node);
- assert(index >= 0);
+ CHECK(index >= 0);
if (index < 0) {
return;
@@ -155,7 +153,7 @@
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
int err = pthread_create(&mThread, &attr, ThreadWrapper, this);
- assert(err == 0);
+ CHECK_EQ(err, 0);
pthread_attr_destroy(&attr);
}
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 9cdc7f7..cdaba7c 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -494,6 +494,7 @@
// Enabling this code appears to be the right thing(tm), but,...
// the TI decoder then loses the ability to output YUV420 and only outputs
// YCbYCr (16bit)
+#if 1
if (!strcmp("OMX.TI.Video.Decoder", mComponentName)
&& !strcasecmp("video/avc", mime)) {
OMX_PARAM_COMPONENTROLETYPE role;
@@ -509,6 +510,7 @@
&role, sizeof(role));
CHECK_EQ(err, OK);
}
+#endif
OMX_VIDEO_CODINGTYPE compressionFormat = OMX_VIDEO_CodingUnused;
if (!strcasecmp("video/avc", mime)) {
diff --git a/media/libstagefright/OMXDecoder.cpp b/media/libstagefright/OMXDecoder.cpp
index cf08fa5..a3172ed 100644
--- a/media/libstagefright/OMXDecoder.cpp
+++ b/media/libstagefright/OMXDecoder.cpp
@@ -18,13 +18,12 @@
#define LOG_TAG "OMXDecoder"
#include <utils/Log.h>
-#undef NDEBUG
-#include <assert.h>
#include <ctype.h>
#include <OMX_Component.h>
#include <media/stagefright/ESDS.h>
+#include <media/stagefright/MediaDebug.h>
#include <media/stagefright/MetaData.h>
#include <media/stagefright/OMXDecoder.h>
@@ -87,7 +86,7 @@
static const char *GetCodec(const CodecInfo *info, size_t numInfos,
const char *mime, int index) {
- assert(index >= 0);
+ CHECK(index >= 0);
for(size_t i = 0; i < numInfos; ++i) {
if (!strcasecmp(mime, info[i].mime)) {
if (index == 0) {
@@ -108,7 +107,7 @@
const sp<MediaSource> &source) {
const char *mime;
bool success = meta->findCString(kKeyMIMEType, &mime);
- assert(success);
+ CHECK(success);
sp<IOMX> omx = client->interface();
@@ -168,7 +167,7 @@
size_t size;
if (meta->findData(kKeyESDS, &type, &data, &size)) {
ESDS esds((const char *)data, size);
- assert(esds.InitCheck() == OK);
+ CHECK_EQ(esds.InitCheck(), OK);
const void *codec_specific_data;
size_t codec_specific_data_size;
@@ -193,7 +192,7 @@
// printf("length = %d, size = %d\n", length, size);
- assert(size >= length);
+ CHECK(size >= length);
decoder->addCodecSpecificData(ptr, length);
@@ -258,7 +257,7 @@
mClient->unregisterObserver(mNode);
status_t err = mOMX->free_node(mNode);
- assert(err == OK);
+ CHECK_EQ(err, OK);
mNode = 0;
free(mMIME);
@@ -269,7 +268,7 @@
}
status_t OMXDecoder::start(MetaData *) {
- assert(!mStarted);
+ CHECK(!mStarted);
// mDealer->dump("Decoder Dealer");
@@ -292,7 +291,7 @@
}
status_t OMXDecoder::stop() {
- assert(mStarted);
+ CHECK(mStarted);
LOGI("Initiating OMX Node shutdown, busy polling.");
initiateShutdown();
@@ -340,7 +339,7 @@
status_t OMXDecoder::read(
MediaBuffer **out, const ReadOptions *options) {
- assert(mStarted);
+ CHECK(mStarted);
*out = NULL;
@@ -384,7 +383,7 @@
// never sends the completion event... FIXME
status_t err = mOMX->send_command(mNode, OMX_CommandFlush, OMX_ALL);
- assert(err == OK);
+ CHECK_EQ(err, OK);
// Once flushing is completed buffers will again be scheduled to be
// filled/emptied.
@@ -402,7 +401,7 @@
return OK;
} else {
- assert(mErrorCondition != OK);
+ CHECK(mErrorCondition != OK);
return mErrorCondition;
}
}
@@ -463,13 +462,13 @@
status_t err =
mOMX->get_parameter(mNode, OMX_IndexParamAudioAmr, &def, sizeof(def));
- assert(err == NO_ERROR);
+ CHECK_EQ(err, NO_ERROR);
def.eAMRFrameFormat = OMX_AUDIO_AMRFrameFormatFSF;
def.eAMRBandMode = OMX_AUDIO_AMRBandModeNB0;
err = mOMX->set_parameter(mNode, OMX_IndexParamAudioAmr, &def, sizeof(def));
- assert(err == NO_ERROR);
+ CHECK_EQ(err, NO_ERROR);
}
void OMXDecoder::setAACFormat() {
@@ -481,12 +480,12 @@
status_t err =
mOMX->get_parameter(mNode, OMX_IndexParamAudioAac, &def, sizeof(def));
- assert(err == NO_ERROR);
+ CHECK_EQ(err, NO_ERROR);
def.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP4ADTS;
err = mOMX->set_parameter(mNode, OMX_IndexParamAudioAac, &def, sizeof(def));
- assert(err == NO_ERROR);
+ CHECK_EQ(err, NO_ERROR);
}
status_t OMXDecoder::setVideoPortFormatType(
@@ -512,8 +511,8 @@
return err;
}
- // The following assertion is violated by TI's video decoder.
- // assert(format.nIndex == index);
+ // The following CHECKion is violated by TI's video decoder.
+ // CHECK_EQ(format.nIndex, index);
#if 1
LOGI("portIndex: %ld, index: %ld, eCompressionFormat=%d eColorFormat=%d",
@@ -570,7 +569,7 @@
compressionFormat = OMX_VIDEO_CodingH263;
} else {
LOGE("Not a supported video mime type: %s", mime);
- assert(!"Should not be here. Not a supported video mime type.");
+ CHECK(!"Should not be here. Not a supported video mime type.");
}
OMX_COLOR_FORMATTYPE colorFormat =
@@ -598,9 +597,9 @@
status_t err = mOMX->get_parameter(
mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
- assert(err == NO_ERROR);
+ CHECK_EQ(err, NO_ERROR);
- assert(def.eDomain == OMX_PortDomainVideo);
+ CHECK_EQ(def.eDomain, OMX_PortDomainVideo);
video_def->nFrameWidth = width;
video_def->nFrameHeight = height;
@@ -610,7 +609,7 @@
err = mOMX->set_parameter(
mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
- assert(err == NO_ERROR);
+ CHECK_EQ(err, NO_ERROR);
////////////////////////////////////////////////////////////////////////////
@@ -621,12 +620,12 @@
err = mOMX->get_parameter(
mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
- assert(err == NO_ERROR);
+ CHECK_EQ(err, NO_ERROR);
def.nBufferSize = (width * height * 2); // (width * height * 3) / 2;
LOGI("setting nBufferSize = %ld", def.nBufferSize);
- assert(def.eDomain == OMX_PortDomainVideo);
+ CHECK_EQ(def.eDomain, OMX_PortDomainVideo);
video_def->nFrameWidth = width;
video_def->nFrameHeight = height;
@@ -635,7 +634,7 @@
err = mOMX->set_parameter(
mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
- assert(err == NO_ERROR);
+ CHECK_EQ(err, NO_ERROR);
}
void OMXDecoder::setVideoOutputFormat(
@@ -659,7 +658,7 @@
status_t err = mOMX->set_parameter(
mNode, OMX_IndexParamStandardComponentRole,
&role, sizeof(role));
- assert(err == OK);
+ CHECK_EQ(err, OK);
}
#endif
@@ -672,7 +671,7 @@
compressionFormat = OMX_VIDEO_CodingH263;
} else {
LOGE("Not a supported video mime type: %s", mime);
- assert(!"Should not be here. Not a supported video mime type.");
+ CHECK(!"Should not be here. Not a supported video mime type.");
}
setVideoPortFormatType(
@@ -690,13 +689,13 @@
status_t err = mOMX->get_parameter(
mNode, OMX_IndexParamVideoPortFormat,
&format, sizeof(format));
- assert(err == OK);
+ CHECK_EQ(err, OK);
- assert(format.eCompressionFormat == OMX_VIDEO_CodingUnused);
+ CHECK_EQ(format.eCompressionFormat, OMX_VIDEO_CodingUnused);
static const int OMX_QCOM_COLOR_FormatYVU420SemiPlanar = 0x7FA30C00;
- assert(format.eColorFormat == OMX_COLOR_FormatYUV420Planar
+ CHECK(format.eColorFormat == OMX_COLOR_FormatYUV420Planar
|| format.eColorFormat == OMX_COLOR_FormatYUV420SemiPlanar
|| format.eColorFormat == OMX_COLOR_FormatCbYCrY
|| format.eColorFormat == OMX_QCOM_COLOR_FormatYVU420SemiPlanar);
@@ -704,7 +703,7 @@
err = mOMX->set_parameter(
mNode, OMX_IndexParamVideoPortFormat,
&format, sizeof(format));
- assert(err == OK);
+ CHECK_EQ(err, OK);
}
#endif
@@ -719,7 +718,7 @@
status_t err = mOMX->get_parameter(
mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
- assert(err == NO_ERROR);
+ CHECK_EQ(err, NO_ERROR);
#if 1
// XXX Need a (much) better heuristic to compute input buffer sizes.
@@ -729,7 +728,7 @@
}
#endif
- assert(def.eDomain == OMX_PortDomainVideo);
+ CHECK_EQ(def.eDomain, OMX_PortDomainVideo);
video_def->nFrameWidth = width;
video_def->nFrameHeight = height;
@@ -738,7 +737,7 @@
err = mOMX->set_parameter(
mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
- assert(err == NO_ERROR);
+ CHECK_EQ(err, NO_ERROR);
////////////////////////////////////////////////////////////////////////////
@@ -749,9 +748,9 @@
err = mOMX->get_parameter(
mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
- assert(err == NO_ERROR);
+ CHECK_EQ(err, NO_ERROR);
- assert(def.eDomain == OMX_PortDomainVideo);
+ CHECK_EQ(def.eDomain, OMX_PortDomainVideo);
#if 0
def.nBufferSize =
@@ -763,7 +762,7 @@
err = mOMX->set_parameter(
mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
- assert(err == NO_ERROR);
+ CHECK_EQ(err, NO_ERROR);
}
void OMXDecoder::setup() {
@@ -771,7 +770,7 @@
const char *mime;
bool success = meta->findCString(kKeyMIMEType, &mime);
- assert(success);
+ CHECK(success);
if (!strcasecmp(mime, "audio/3gpp")) {
setAMRFormat();
@@ -781,7 +780,7 @@
int32_t width, height;
bool success = meta->findInt32(kKeyWidth, &width);
success = success && meta->findInt32(kKeyHeight, &height);
- assert(success);
+ CHECK(success);
if (mIsEncoder) {
setVideoInputFormat(mime, width, height);
@@ -804,14 +803,14 @@
status_t err = mOMX->get_parameter(
mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
- assert(err == NO_ERROR);
+ CHECK_EQ(err, NO_ERROR);
switch (def.eDomain) {
case OMX_PortDomainAudio:
{
OMX_AUDIO_PORTDEFINITIONTYPE *audio_def = &def.format.audio;
- assert(audio_def->eEncoding == OMX_AUDIO_CodingPCM);
+ CHECK_EQ(audio_def->eEncoding, OMX_AUDIO_CodingPCM);
OMX_AUDIO_PARAM_PCMMODETYPE params;
params.nSize = sizeof(params);
@@ -821,11 +820,11 @@
err = mOMX->get_parameter(
mNode, OMX_IndexParamAudioPcm, ¶ms, sizeof(params));
- assert(err == OK);
+ CHECK_EQ(err, OK);
- assert(params.eNumData == OMX_NumericalDataSigned);
- assert(params.nBitPerSample == 16);
- assert(params.ePCMMode == OMX_AUDIO_PCMModeLinear);
+ CHECK_EQ(params.eNumData, OMX_NumericalDataSigned);
+ CHECK_EQ(params.nBitPerSample, 16);
+ CHECK_EQ(params.ePCMMode, OMX_AUDIO_PCMModeLinear);
int32_t numChannels, sampleRate;
meta->findInt32(kKeyChannelCount, &numChannels);
@@ -850,7 +849,7 @@
} else if (video_def->eCompressionFormat == OMX_VIDEO_CodingAVC) {
mOutputFormat->setCString(kKeyMIMEType, "video/avc");
} else {
- assert(!"Unknown compression format.");
+ CHECK(!"Unknown compression format.");
}
if (!strcmp(mComponentName, "OMX.PV.avcdec")) {
@@ -870,7 +869,7 @@
default:
{
- assert(!"should not be here, neither audio nor video.");
+ CHECK(!"should not be here, neither audio nor video.");
break;
}
}
@@ -880,7 +879,7 @@
if (!(mQuirks & kRequiresLoadedToIdleAfterAllocation)) {
status_t err =
mOMX->send_command(mNode, OMX_CommandStateSet, OMX_StateIdle);
- assert(err == NO_ERROR);
+ CHECK_EQ(err, NO_ERROR);
}
allocateBuffers(kPortIndexInput);
@@ -891,12 +890,12 @@
// h264 vdec disagrees.
status_t err =
mOMX->send_command(mNode, OMX_CommandStateSet, OMX_StateIdle);
- assert(err == NO_ERROR);
+ CHECK_EQ(err, NO_ERROR);
}
}
void OMXDecoder::allocateBuffers(OMX_U32 port_index) {
- assert(mBuffers[port_index].empty());
+ CHECK(mBuffers[port_index].empty());
OMX_U32 num_buffers;
OMX_U32 buffer_size;
@@ -911,7 +910,7 @@
status_t err = mOMX->get_parameter(
mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
- assert(err == NO_ERROR);
+ CHECK_EQ(err, NO_ERROR);
num_buffers = def.nBufferCountActual;
buffer_size = def.nBufferSize;
@@ -925,7 +924,7 @@
LOGE("[%s] allocating IMemory of size %ld FAILED.",
mComponentName, buffer_size);
}
- assert(mem.get() != NULL);
+ CHECK(mem.get() != NULL);
IOMX::buffer_id buffer;
status_t err;
@@ -960,7 +959,7 @@
mComponentName, err);
}
}
- assert(err == OK);
+ CHECK_EQ(err, OK);
LOGV("allocated %s buffer %p.",
port_index == kPortIndexInput ? "INPUT" : "OUTPUT",
@@ -1019,7 +1018,7 @@
case OMX_CommandPortDisable: {
OMX_U32 port_index = data;
- assert(getPortStatus(port_index) == kPortStatusDisabled);
+ CHECK_EQ(getPortStatus(port_index), kPortStatusDisabled);
status_t err =
mOMX->send_command(mNode, OMX_CommandPortEnable, port_index);
@@ -1031,10 +1030,10 @@
case OMX_CommandPortEnable: {
OMX_U32 port_index = data;
- assert(getPortStatus(port_index) ==kPortStatusDisabled);
+ CHECK(getPortStatus(port_index) ==kPortStatusDisabled);
setPortStatus(port_index, kPortStatusActive);
- assert(port_index == kPortIndexOutput);
+ CHECK_EQ(port_index, kPortIndexOutput);
BufferList *obuffers = &mBuffers.editItemAt(kPortIndexOutput);
while (!obuffers->empty()) {
@@ -1053,7 +1052,7 @@
PortStatus status = getPortStatus(port_index);
- assert(status == kPortStatusFlushing
+ CHECK(status == kPortStatusFlushing
|| status == kPortStatusFlushingToDisabled
|| status == kPortStatusFlushingToShutdown);
@@ -1085,7 +1084,7 @@
setPortStatus(port_index, kPortStatusDisabled);
status_t err = mOMX->send_command(
mNode, OMX_CommandPortDisable, port_index);
- assert(err == OK);
+ CHECK_EQ(err, OK);
freePortBuffers(port_index);
break;
@@ -1093,14 +1092,14 @@
default:
{
- assert(status == kPortStatusFlushingToShutdown);
+ CHECK_EQ(status, kPortStatusFlushingToShutdown);
setPortStatus(port_index, kPortStatusShutdown);
if (getPortStatus(kPortIndexInput) == kPortStatusShutdown
&& getPortStatus(kPortIndexOutput) == kPortStatusShutdown) {
status_t err = mOMX->send_command(
mNode, OMX_CommandStateSet, OMX_StateIdle);
- assert(err == OK);
+ CHECK_EQ(err, OK);
}
break;
}
@@ -1114,7 +1113,7 @@
}
void OMXDecoder::onEventPortSettingsChanged(OMX_U32 port_index) {
- assert(getPortStatus(port_index) == kPortStatusActive);
+ CHECK_EQ(getPortStatus(port_index), kPortStatusActive);
status_t err;
@@ -1131,18 +1130,18 @@
err = mOMX->send_command(mNode, OMX_CommandPortDisable, port_index);
}
- assert(err == NO_ERROR);
+ CHECK_EQ(err, NO_ERROR);
}
void OMXDecoder::onStateChanged(OMX_STATETYPE to) {
if (mState == OMX_StateLoaded) {
- assert(to == OMX_StateIdle);
+ CHECK_EQ(to, OMX_StateIdle);
mState = to;
status_t err =
mOMX->send_command(mNode, OMX_CommandStateSet, OMX_StateExecuting);
- assert(err == NO_ERROR);
+ CHECK_EQ(err, NO_ERROR);
} else if (mState == OMX_StateIdle) {
if (to == OMX_StateExecuting) {
mState = to;
@@ -1163,7 +1162,7 @@
postInitialFillBuffer(buffer);
}
} else {
- assert(to == OMX_StateLoaded);
+ CHECK_EQ(to, OMX_StateLoaded);
mState = to;
@@ -1171,14 +1170,14 @@
setPortStatus(kPortIndexOutput, kPortStatusActive);
}
} else if (mState == OMX_StateExecuting) {
- assert(to == OMX_StateIdle);
+ CHECK_EQ(to, OMX_StateIdle);
mState = to;
LOGV("Executing->Idle complete, initiating Idle->Loaded");
status_t err =
mOMX->send_command(mNode, OMX_CommandStateSet, OMX_StateLoaded);
- assert(err == NO_ERROR);
+ CHECK_EQ(err, NO_ERROR);
freePortBuffers(kPortIndexInput);
freePortBuffers(kPortIndexOutput);
@@ -1196,7 +1195,7 @@
return;
}
- assert(mState == OMX_StateExecuting);
+ CHECK_EQ(mState, OMX_StateExecuting);
mShutdownInitiated = true;
@@ -1204,7 +1203,7 @@
if (mQuirks & kDoesntFlushOnExecutingToIdle) {
if (mQuirks & kDoesntProperlyFlushAllPortsAtOnce) {
err = mOMX->send_command(mNode, OMX_CommandFlush, kPortIndexInput);
- assert(err == OK);
+ CHECK_EQ(err, OK);
err = mOMX->send_command(mNode, OMX_CommandFlush, kPortIndexOutput);
} else {
@@ -1220,7 +1219,7 @@
setPortStatus(kPortIndexInput, kPortStatusShutdown);
setPortStatus(kPortIndexOutput, kPortStatusShutdown);
}
- assert(err == OK);
+ CHECK_EQ(err, OK);
}
void OMXDecoder::setPortStatus(OMX_U32 port_index, PortStatus status) {
@@ -1266,7 +1265,7 @@
err = NO_ERROR;
break;
}
- assert(err == NO_ERROR);
+ CHECK_EQ(err, NO_ERROR);
}
void OMXDecoder::onFillBufferDone(const omx_message &msg) {
@@ -1310,7 +1309,7 @@
break;
}
}
- assert(err == NO_ERROR);
+ CHECK_EQ(err, NO_ERROR);
}
void OMXDecoder::onRealEmptyBufferDone(IOMX::buffer_id buffer) {
@@ -1322,7 +1321,7 @@
}
const sp<IMemory> mem = mBufferMap.valueFor(buffer);
- assert(mem.get() != NULL);
+ CHECK(mem.get() != NULL);
static const uint8_t kNALStartCode[4] = { 0x00, 0x00, 0x00, 0x01 };
@@ -1332,14 +1331,14 @@
size_t range_length = 0;
if (mIsAVC && !(mQuirks & kWantsNALFragments)) {
- assert((*mCodecSpecificDataIterator).size + 4 <= mem->size());
+ CHECK((*mCodecSpecificDataIterator).size + 4 <= mem->size());
memcpy(mem->pointer(), kNALStartCode, 4);
memcpy((uint8_t *)mem->pointer() + 4, (*it).data, (*it).size);
range_length = (*it).size + 4;
} else {
- assert((*mCodecSpecificDataIterator).size <= mem->size());
+ CHECK((*mCodecSpecificDataIterator).size <= mem->size());
memcpy((uint8_t *)mem->pointer(), (*it).data, (*it).size);
range_length = (*it).size;
@@ -1371,7 +1370,7 @@
} else {
err = mSource->read(&input_buffer);
}
- assert((err == OK && input_buffer != NULL)
+ CHECK((err == OK && input_buffer != NULL)
|| (err != OK && input_buffer == NULL));
if (err == ERROR_END_OF_STREAM) {
@@ -1415,7 +1414,7 @@
src_length, mem->size());
}
- assert(src_length <= mem->size());
+ CHECK(src_length <= mem->size());
memcpy(mem->pointer(), src_data, src_length);
OMX_U32 flags = 0;
@@ -1520,7 +1519,7 @@
LOGV("freeInputBuffer %p", buffer);
status_t err = mOMX->free_buffer(mNode, kPortIndexInput, buffer);
- assert(err == NO_ERROR);
+ CHECK_EQ(err, NO_ERROR);
mBufferMap.removeItem(buffer);
LOGV("freeInputBuffer %p done", buffer);
@@ -1530,11 +1529,11 @@
LOGV("freeOutputBuffer %p", buffer);
status_t err = mOMX->free_buffer(mNode, kPortIndexOutput, buffer);
- assert(err == NO_ERROR);
+ CHECK_EQ(err, NO_ERROR);
mBufferMap.removeItem(buffer);
ssize_t index = mMediaBufferMap.indexOfKey(buffer);
- assert(index >= 0);
+ CHECK(index >= 0);
MediaBuffer *mbuffer = mMediaBufferMap.editValueAt(index);
mMediaBufferMap.removeItemsAt(index);
mbuffer->setObserver(NULL);
@@ -1553,7 +1552,7 @@
status_t err = mOMX->get_parameter(
mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
- assert(err == NO_ERROR);
+ CHECK_EQ(err, NO_ERROR);
LOGI("DumpPortDefinition on port %ld", port_index);
LOGI("nBufferCountActual = %ld, nBufferCountMin = %ld, nBufferSize = %ld",
@@ -1565,7 +1564,7 @@
if (port_index == kPortIndexOutput) {
OMX_AUDIO_PORTDEFINITIONTYPE *audio_def = &def.format.audio;
- assert(audio_def->eEncoding == OMX_AUDIO_CodingPCM);
+ CHECK_EQ(audio_def->eEncoding, OMX_AUDIO_CodingPCM);
OMX_AUDIO_PARAM_PCMMODETYPE params;
params.nSize = sizeof(params);
@@ -1575,12 +1574,12 @@
err = mOMX->get_parameter(
mNode, OMX_IndexParamAudioPcm, ¶ms, sizeof(params));
- assert(err == OK);
+ CHECK_EQ(err, OK);
- assert(params.nChannels == 1 || params.bInterleaved);
- assert(params.eNumData == OMX_NumericalDataSigned);
- assert(params.nBitPerSample == 16);
- assert(params.ePCMMode == OMX_AUDIO_PCMModeLinear);
+ CHECK(params.nChannels == 1 || params.bInterleaved);
+ CHECK_EQ(params.eNumData, OMX_NumericalDataSigned);
+ CHECK_EQ(params.nBitPerSample, 16);
+ CHECK_EQ(params.ePCMMode, OMX_AUDIO_PCMModeLinear);
LOGI("nChannels = %ld, nSamplingRate = %ld",
params.nChannels, params.nSamplingRate);
diff --git a/media/libstagefright/SampleTable.cpp b/media/libstagefright/SampleTable.cpp
index 75bfde3..5e32559 100644
--- a/media/libstagefright/SampleTable.cpp
+++ b/media/libstagefright/SampleTable.cpp
@@ -18,9 +18,9 @@
#include <utils/Log.h>
#include <arpa/inet.h>
-#include <assert.h>
#include <media/stagefright/DataSource.h>
+#include <media/stagefright/MediaDebug.h>
#include <media/stagefright/SampleTable.h>
#include <media/stagefright/Utils.h>
@@ -59,7 +59,7 @@
return ERROR_MALFORMED;
}
- assert(type == kChunkOffsetType32 || type == kChunkOffsetType64);
+ CHECK(type == kChunkOffsetType32 || type == kChunkOffsetType64);
mChunkOffsetOffset = data_offset;
mChunkOffsetType = type;
@@ -132,7 +132,7 @@
return ERROR_MALFORMED;
}
- assert(type == kSampleSizeType32 || type == kSampleSizeTypeCompact);
+ CHECK(type == kSampleSizeType32 || type == kSampleSizeTypeCompact);
mSampleSizeOffset = data_offset;
@@ -272,7 +272,7 @@
*offset = ntohl(offset32);
} else {
- assert(mChunkOffsetOffset == kChunkOffsetType64);
+ CHECK_EQ(mChunkOffsetOffset, kChunkOffsetType64);
uint64_t offset64;
if (mDataSource->read_at(
@@ -399,7 +399,7 @@
default:
{
- assert(mSampleSizeFieldSize == 4);
+ CHECK_EQ(mSampleSizeFieldSize, 4);
uint8_t x;
if (mDataSource->read_at(
@@ -569,26 +569,6 @@
}
}
-#if 1
- // Make sure we return a sample at or _after_ the requested one.
- // Seeking to a particular time in a media source containing audio and
- // video will most likely be able to sync fairly close to the requested
- // time in the audio track but may only be able to seek a fair distance
- // from the requested time in the video track.
- // If we seek the video track to a time earlier than the audio track,
- // we'll cause the video track to be late for quite a while, the decoder
- // trying to catch up.
- // If we seek the video track to a time later than the audio track,
- // audio will start playing fine while no video will be output for a
- // while, the video decoder will not stress the system.
- if (mDataSource->read_at(
- mSyncSampleOffset + 8 + (left - 1) * 4, &x, 4) != 4) {
- return ERROR_IO;
- }
- x = ntohl(x);
- assert((x - 1) >= start_sample_index);
-#endif
-
*sample_index = x - 1;
return OK;
diff --git a/media/libstagefright/ShoutcastSource.cpp b/media/libstagefright/ShoutcastSource.cpp
index 17b626e..4375f38 100644
--- a/media/libstagefright/ShoutcastSource.cpp
+++ b/media/libstagefright/ShoutcastSource.cpp
@@ -19,6 +19,7 @@
#include <media/stagefright/HTTPStream.h>
#include <media/stagefright/MediaBuffer.h>
#include <media/stagefright/MediaBufferGroup.h>
+#include <media/stagefright/MediaDebug.h>
#include <media/stagefright/MetaData.h>
#include <media/stagefright/ShoutcastSource.h>
#include <media/stagefright/string.h>
@@ -36,8 +37,8 @@
char *end;
const char *start = metaint.c_str();
mMetaDataOffset = strtol(start, &end, 10);
- assert(end > start && *end == '\0');
- assert(mMetaDataOffset > 0);
+ CHECK(end > start && *end == '\0');
+ CHECK(mMetaDataOffset > 0);
mBytesUntilMetaData = mMetaDataOffset;
}
@@ -53,7 +54,7 @@
}
status_t ShoutcastSource::start(MetaData *) {
- assert(!mStarted);
+ CHECK(!mStarted);
mGroup = new MediaBufferGroup;
mGroup->add_buffer(new MediaBuffer(4096)); // XXX
@@ -64,7 +65,7 @@
}
status_t ShoutcastSource::stop() {
- assert(mStarted);
+ CHECK(mStarted);
delete mGroup;
mGroup = NULL;
@@ -85,7 +86,7 @@
status_t ShoutcastSource::read(
MediaBuffer **out, const ReadOptions *options) {
- assert(mStarted);
+ CHECK(mStarted);
*out = NULL;
@@ -120,7 +121,7 @@
if (mBytesUntilMetaData == 0) {
unsigned char num_16_byte_blocks = 0;
n = mHttp->receive((char *)&num_16_byte_blocks, 1);
- assert(n == 1);
+ CHECK_EQ(n, 1);
char meta[255 * 16];
size_t meta_size = num_16_byte_blocks * 16;
diff --git a/media/libstagefright/TimedEventQueue.cpp b/media/libstagefright/TimedEventQueue.cpp
index 2f8a19f..3d85f75 100644
--- a/media/libstagefright/TimedEventQueue.cpp
+++ b/media/libstagefright/TimedEventQueue.cpp
@@ -24,9 +24,7 @@
#include <sys/time.h>
-#undef NDEBUG
-#include <assert.h>
-
+#include <media/stagefright/MediaDebug.h>
#include <media/stagefright/TimedEventQueue.h>
namespace android {
@@ -89,7 +87,7 @@
void TimedEventQueue::postEventWithDelay(
const sp<Event> &event, int64_t delay_us) {
- assert(delay_us >= 0);
+ CHECK(delay_us >= 0);
postTimedEvent(event, getRealTimeUs() + delay_us);
}
diff --git a/media/libstagefright/omx/OMX.cpp b/media/libstagefright/omx/OMX.cpp
index 39fa27e..1e59b52 100644
--- a/media/libstagefright/omx/OMX.cpp
+++ b/media/libstagefright/omx/OMX.cpp
@@ -20,15 +20,13 @@
#include <sys/socket.h>
-#undef NDEBUG
-#include <assert.h>
-
#include "OMX.h"
#include "OMXRenderer.h"
#include "pv_omxcore.h"
#include <binder/IMemory.h>
+#include <media/stagefright/MediaDebug.h>
#include <media/stagefright/QComHardwareRenderer.h>
#include <media/stagefright/SoftwareRenderer.h>
#include <media/stagefright/TIHardwareRenderer.h>
@@ -50,7 +48,7 @@
}
void setHandle(OMX_HANDLETYPE handle) {
- assert(mHandle == NULL);
+ CHECK_EQ(mHandle, NULL);
mHandle = handle;
}
@@ -541,7 +539,7 @@
OMX_ERRORTYPE err =
OMX_FillThisBuffer(node_meta->handle(), header);
- assert(err == OMX_ErrorNone);
+ CHECK_EQ(err, OMX_ErrorNone);
}
void OMX::empty_buffer(
@@ -563,7 +561,7 @@
OMX_ERRORTYPE err =
OMX_EmptyThisBuffer(node_meta->handle(), header);
- assert(err == OMX_ErrorNone);
+ CHECK_EQ(err, OMX_ErrorNone);
}
status_t OMX::get_extension_index(
diff --git a/media/libstagefright/omx/QComHardwareRenderer.cpp b/media/libstagefright/omx/QComHardwareRenderer.cpp
index 5a23792..e9930be 100644
--- a/media/libstagefright/omx/QComHardwareRenderer.cpp
+++ b/media/libstagefright/omx/QComHardwareRenderer.cpp
@@ -14,11 +14,9 @@
* limitations under the License.
*/
-#undef NDEBUG
-#include <assert.h>
-
#include <binder/MemoryHeapBase.h>
#include <binder/MemoryHeapPmem.h>
+#include <media/stagefright/MediaDebug.h>
#include <media/stagefright/QComHardwareRenderer.h>
#include <ui/ISurface.h>
@@ -68,9 +66,9 @@
mDecodedWidth(decodedWidth),
mDecodedHeight(decodedHeight),
mFrameSize((mDecodedWidth * mDecodedHeight * 3) / 2) {
- assert(mISurface.get() != NULL);
- assert(mDecodedWidth > 0);
- assert(mDecodedHeight > 0);
+ CHECK(mISurface.get() != NULL);
+ CHECK(mDecodedWidth > 0);
+ CHECK(mDecodedHeight > 0);
}
QComHardwareRenderer::~QComHardwareRenderer() {
@@ -133,7 +131,7 @@
mMemoryHeap);
status_t err = mISurface->registerBuffers(bufferHeap);
- assert(err == OK);
+ CHECK_EQ(err, OK);
}
} // namespace android
diff --git a/media/libstagefright/omx/SoftwareRenderer.cpp b/media/libstagefright/omx/SoftwareRenderer.cpp
index 5483238..da97d55 100644
--- a/media/libstagefright/omx/SoftwareRenderer.cpp
+++ b/media/libstagefright/omx/SoftwareRenderer.cpp
@@ -17,10 +17,8 @@
#define LOG_TAG "SoftwareRenderer"
#include <utils/Log.h>
-#undef NDEBUG
-#include <assert.h>
-
#include <binder/MemoryHeapBase.h>
+#include <media/stagefright/MediaDebug.h>
#include <media/stagefright/SoftwareRenderer.h>
#include <ui/ISurface.h>
@@ -40,10 +38,10 @@
mFrameSize(mDecodedWidth * mDecodedHeight * 2), // RGB565
mMemoryHeap(new MemoryHeapBase(2 * mFrameSize)),
mIndex(0) {
- assert(mISurface.get() != NULL);
- assert(mDecodedWidth > 0);
- assert(mDecodedHeight > 0);
- assert(mMemoryHeap->heapID() >= 0);
+ CHECK(mISurface.get() != NULL);
+ CHECK(mDecodedWidth > 0);
+ CHECK(mDecodedHeight > 0);
+ CHECK(mMemoryHeap->heapID() >= 0);
ISurface::BufferHeap bufferHeap(
mDisplayWidth, mDisplayHeight,
@@ -52,7 +50,7 @@
mMemoryHeap);
status_t err = mISurface->registerBuffers(bufferHeap);
- assert(err == OK);
+ CHECK_EQ(err, OK);
}
SoftwareRenderer::~SoftwareRenderer() {
@@ -65,7 +63,7 @@
LOGE("size is %d, expected %d",
size, (mDecodedHeight * mDecodedWidth * 3) / 2);
}
- assert(size >= (mDecodedWidth * mDecodedHeight * 3) / 2);
+ CHECK(size >= (mDecodedWidth * mDecodedHeight * 3) / 2);
static const signed kClipMin = -278;
static const signed kClipMax = 535;