diff options
25 files changed, 410 insertions, 309 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index ee46c85..9e3008b 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -3121,6 +3121,13 @@ public final class Settings { "vending_promo_refresh_freq_ms"; /** + * Frequency in milliseconds when we should refresh the provisioning information from + * the carrier backend. + */ + public static final String VENDING_CARRIER_PROVISIONING_REFRESH_FREQUENCY_MS = + "vending_carrier_ref_freq_ms"; + + /** * URL that points to the legal terms of service to display in Settings. * <p> * This should be a https URL. For a pretty user-friendly URL, use diff --git a/docs/html/guide/developing/device.jd b/docs/html/guide/developing/device.jd index 2c42e78..9dea053 100644 --- a/docs/html/guide/developing/device.jd +++ b/docs/html/guide/developing/device.jd @@ -7,11 +7,12 @@ page.title=Developing on a Device <ol> <li><a href="#devices">Available Devices</a> <ol> - <li><a href="#g1">T-Mobile G1</a></li> + <li><a href="#consumer">Consumer devices</a></li> <li><a href="#dev-phone-1">Android Dev Phone 1</a></li> </ol> </li> <li><a href="#setting-up">Setting up a Device for Development</a></li> + <li><a href="#WinUsbDriver">Installing the WinUsb Driver</a></li> </ol> </div> </div> @@ -23,20 +24,24 @@ developing and debugging.</p> <h2 id="devices">Available Devices</h2> -<p>While developers can use regular -consumer devices purchased at retail to test and use their apps, some developers -may choose not to use a retail device, preferring an unlocked or no-contract -device. Here are some options for obtaining devices capable of testing your applications.</p> +<p>Here are some options for obtaining devices capable of testing your applications.</p> -<h3 id="g1">T-Mobile G1</h3> +<h3 id="consumer">Consumer devices</h3> -<p>The T-Mobile G1 device makes an excellent development device. You can write -applications in the SDK and install them on the G1, then run them as users -would, using the same hardware, system, and network.</p> +<p>It's likely that one of your local mobile carriers offers an Android-powered device. +Any Android-powered device (even one bought from your mobile carrier) is a perfectly good +device for running and testing your own Android applications. +You can write applications using the Android SDK and then install them +directly onto the device for testing.</p> + +<p>Check with the service providers in your area to determine which Android-powered +devices are available.</p> + +<p>Be aware that consumer devices are not designed to allow system image updates by the +user. If you're interested in manually updating the device with custom system images, then +you'll need a developer device such as the <a href="#dev-phone-1">Android Dev Phone 1</a>.</p> -<p>For more information about obtaining a G1, visit the <a -href="http://www.t-mobileg1.com">T-Mobile G1 site</a>. </p> <h3 id="dev-phone-1">Android Dev Phone 1</h3> @@ -60,6 +65,7 @@ href="http://www.t-mobileg1.com">T-Mobile G1 site</a>. </p> </ul> </div> </div> + <p>The Android Dev Phone 1 is a SIM-unlocked and hardware-unlocked device that is designed for advanced developers. The device ships with a system image that is fully compatible with Android 1.0, so you can rely on it when developing your @@ -67,7 +73,7 @@ applications. You can use any SIM in the device and can flash custom Android builds that will work with the unlocked bootloader. Unlike the bootloader on retail devices, the bootloader on the Android Dev Phone 1 does not enforce signed system images. The Android Dev Phone 1 should also appeal to developers -who live outside of T-Mobile geographies. </p> +who live in geographies where local mobile carriers do not currently offer Android-powered devices. </p> <p>To purchase an Android Dev Phone 1 device, you must first register as an Android developer on the Android Market site, if you haven't done so already. @@ -82,25 +88,30 @@ Singapore, Switzerland, Netherlands, Austria, Sweden, Finland, Poland, and Hungary. We will continue to expand this program into new geographies over time. Check this page for updated information.</p> -<p>Note that Android Dev Phone 1 devices are <em>not</em> intended for +<p>Android Dev Phone 1 devices are <em>not</em> intended for non-developer end-users. Because the device can be configured with system software not provided by or supported by Google or any other company, end-users operate these devices at their own risk.</p> +<p>Note that your Android Dev Phone 1 will not receive automated +over-the-air (OTA) updates for the system image. System updates must be flashed manually. +See the HTC site for a guide to <a href="http://www.htc.com/www/support/android/adp.html">Flashing +your Android Dev Phone with a Factory System Image</a>.</p> + <p>For full device specs and more information about obtaining an Android Dev Phone 1 device, see the <a href="http://market.android.com/publish">Android Market</a> site.</p> + <h2 id="setting-up">Setting up a Device for Development</h2> -<p>With a T-mobile G1 or Android Dev Phone 1, you can develop and debug your Android applications just as you +<p>With an Android-powered device, you can develop and debug your Android applications just as you would on the emulator. There are just a few things to do before you can start.</p> <ol> <li>Declare your application as "debuggable" in your Android Manifest. <p>In Eclipse, you can do this from the <b>Application</b> tab when viewing the Manifest (on the right side, set <b>Debuggable</b> to <em>true</em>). Otherwise, in the <code>AndroidManifest.xml</code> - file, add <code>android:debuggable="true"</code> to the <code><application></code> element.</p> </li> <li>Turn on "USB Debugging" on your device. @@ -110,30 +121,8 @@ would on the emulator. There are just a few things to do before you can start.</ </li> <li>Setup your system to detect your device. <ul> - <li>If you're developing on 32-bit Windows, you need to install the 32-bit USB driver for adb. - The USB driver is included in the SDK package. To install it, follow these steps:</p> - <ol> - <li>Connect your Android device via USB. When the <em>Found New Hardware Wizard</em> appears, - you'll be asked if you'd like Windows Update to search for software. Select <em>No, not this - time</em> and click <b>Next</b>.</li> - - <li>Select <em>Install from a list or specified location</em> and click <b>Next</b>.</li> - <li>Select <em>Search for the best driver in these locations</em>. Browse to the <code>usb_driver/x86</code> in the SDK package (<code><sdk>\usb_driver\x86</code>).</li> - <li>Click <b>Finish</b>. The system should install the driver files as necessary. Your machine may require a reboot.</li> - </ol> - </li> - <li>If you're developing on 64-bit Windows Vista, you need to install the 64-bit USB driver for adb. - The USB driver is included in the SDK package. To install it, follow these steps:</p> - <ol> - <li>Connect your Android device via USB. When the <em>Found New Hardware Wizard</em> appears, - you'll be asked if you'd like Windows Update to search for software. Select <em>No, not this - time</em> and click <b>Next</b>.</li> - - <li>Select <em>Install from a list or specified location</em> and click <b>Next</b>.</li> - <li>Select <em>Search for the best driver in these locations</em>. Browse to the <code>usb_driver/amd64</code> in the SDK package (<code><sdk>\usb_driver\amd64</code>).</li> - <li>Click <b>Finish</b>. The system should install the driver files as necessary. Your machine may require a reboot.</li> - </ol> - </li> + <li>If you're developing on Windows, you need to install a USB driver for adb. + Follow the steps below for <a href="#WinUsbDriver">Installing the WinUsb Driver</a>.</li> <li>If you're developing on Mac OS X, it just works. Skip this step.</li> <li>If you're developing on Ubuntu Linux, you need to add a rules file: <ol> @@ -145,7 +134,7 @@ would on the emulator. There are just a few things to do before you can start.</ <code>SUBSYSTEM=="usb_device", SYSFS{idVendor}=="0bb4", MODE="0666"</code></p> </li> <li>Now execute:<br/> - <code>chmod a+r /etc/udev/rules.d/50-android.rules</code> + <code>chmod a+r /etc/udev/rules.d/51-android.rules</code> </li> </ol> @@ -161,3 +150,156 @@ Select the device to install and run the application there.</p> <p>If using the <a href="{@docRoot}guide/developing/tools/adb.html">Android Debug Bridge</a> (adb), you can issue commands with the <code>-d</code> flag to target your connected device.</p> + + + + +<h2 id="WinUsbDriver">Installing the WinUsb Driver</h2> + +<p>A WinUsb-based driver is needed in order to use your Android-powered device for development on a Windows machine. +The USB installation package can be found in the <code><em><sdk></em>\usb_driver\</code> +folder of your SDK package.</p> + +<p class="note"><strong>Note:</strong> If you are connecting an Android-powered device to your computer +for the first time, folllow the procedure to "Perform a fresh installation." +Android SDKs older than version 1.6 included a non-WinUsb-based driver +for connecting your device. If you installed the older USB driver and it is working properly, +you do not need to upgrade to the new driver. However, if you are having problems with the driver or +would simply like to upgrade to the latest version, follow the procedure to "Upgrade an existing +driver." </p> + +<p>Before you begin installing or upgrading the USB driver, you must +copy the USB installation package to a secure location on your computer. +For example, you might want to create a directory at <code>C:\Android\Windows\USB\install\</code> and +move it there. Once you've moved the installation package, select the appropriate procedure below, +based on your operating system and whether you're installing for the first time or upgrading.</p> + +<ol class="nolist"> + <li>Windows Vista: + <ol class="nolist"> + <li><a href="#VistaFreshInstall">Perform a fresh installation</a></li> + <li><a href="#VistaUprade">Upgrade an existing driver</a></li> + </ol> + </li> + <li>Windows XP: + <ol class="nolist"> + <li><a href="#XPFreshInstall">Perform a fresh installation</a></li> + <li><a href="#XPUpgrade">Upgrade an existing driver</a></li> + </ol> + </li> +</ol> + + +<p class="caution"><strong>Caution:</strong> +You may make changes to <code>android_winusb.inf</code> file found inside <code>usb_driver\</code> +(e.g., to add support for new devices), +however, this will lead to security warnings when you install or upgrade the +driver. Making any other changes to the driver files may break the installation process.</p> + +<h3 id="VistaFreshInstall">Windows Vista: Perform a fresh installation</h3> + +<p>To install the Android USB driver on Windows Vista for the first time:</p> + +<ol> + <li>Connect your Android-powered device to your computer's USB port. Windows will detect the device + and launch the Found New Hardware wizard.</li> + <li>Select "Locate and install driver software."</li> + <li>Select "Don't search online."</li> + <li>Select "I don't have the disk. Show me other options."</li> + <li>Select "Browse my computer for driver software."</li> + <li>Click "Browse..." and locate the folder where you copied the + installation package. As long as you specified the exact location of the + installation package, you may leave "Include subfolders" checked or unchecked—it doesn't matter.</li> + <li>Click "Next." Vista may prompt you to confirm the privilege elevation required for driver + installation. Confirm it.</li> + <li>When Vista asks if you'd like to install the Google ADB Interface device, click "Install" + to install the driver.</li> +</ol> + +<p>Return to <a href="#setting-up">Setting up a Device for Development</a>.</p> + + + +<h3 id="VistaUpgrade">Windows Vista: Upgrade an existing driver</h3> + +<p>To upgrade an existing Android USB driver on Windows Vista with the new one:</p> + +<ol> + <li>Connect your Android-powered device to your computer's USB port.</li> + <li>Right-click on "Computer" from your desktop or Windows Explorer, + and select "Manage."</li> + <li>Select "Device Manager" in the left pane of the Computer Management window.</li> + <li>Locate and expand "ADB Interface" in the right pane.</li> + <li>Right-click on "HTC Dream Composite ADB Interface", and select "Update Driver Software..."</li> + <li>When Vista starts updating the driver, a prompt will ask how you want to search for the driver + software. Select "Browse my computer for driver software."</li> + <li>Click "Browse..." and locate the folder where you copied the + installation package. As long as you specified the exact location of the + installation package, you may leave "Include subfolders" checked or unchecked—it doesn't matter.</li> + <li>Click "Next." Vista may prompt you to confirm the privilege elevation required for driver + installation. Confirm it.</li> + <li>When Vista asks if you'd like to install the Google ADB Interface device, click "Install" + to install the driver.</li> +</ol> + +<p>Return to <a href="#setting-up">Setting up a Device for Development</a>.</p> + + + +<h3 id="XPFreshInstall">Windows XP: Perform a fresh installation</h3> + +<p>To install the Android USB driver on Windows XP for the first time:</p> + +<ol> + <li>Connect your Android-powered device to your computer's USB port. Windows + will detect the device and launch the Hardware Update Wizard.</li> + <li>Select "Install from a list or specific location" and click + "Next."</li> + <li>Select "Search for the best driver in these locations"; uncheck "Search + removable media"; and check "Include this location in the search."</li> + <li>Click "Browse..." and locate the folder where you copied the installation + package.</li> + <li>Click "Next" to install the driver.</li> +</ol> + +<p>Return to <a href="#setting-up">Setting up a Device for Development</a>.</p> + + + +<h3 id="XPUpgrade">Windows XP: Upgrade an existing driver</h3> + +<p>To upgrade an existing Android USB driver on Windows XP with the new one:</p> + +<ol> + <li>Connect your Android-powered device to your computer's USB port.</li> + <li>Right-click on "My Computer" from your desktop or Windows Explorer, + and select "Manage."</li> + <li>Select "Device Manager" in the left pane of the Computer Management window.</li> + <li>Locate and expand "Android Phone" in the right pane.</li> + <li>Right-click "Android Composite ADB Interface" and select "Update Driver..." + This will launch the Hardware Update Wizard.</li> + <li>Select "Install from a list or specific location" and click + "Next."</li> + <li>Select "Search for the best driver in these locations"; uncheck "Search + removable media"; and check "Include this location in the search."</li> + <li>Click "Browse..." and locate the folder where you copied the installation + package.</li> + <li>Click "Next" to install the driver.</li> +</ol> + +<p>Return to <a href="#setting-up">Setting up a Device for Development</a>.</p> + + + + + + + + + + + + + + + diff --git a/include/media/stagefright/MediaDebug.h b/include/media/stagefright/MediaDebug.h index 83acd77..c8a8f00 100644 --- a/include/media/stagefright/MediaDebug.h +++ b/include/media/stagefright/MediaDebug.h @@ -2,6 +2,8 @@ #define MEDIA_DEBUG_H_ +#include <cutils/log.h> + #define LITERAL_TO_STRING_INTERNAL(x) #x #define LITERAL_TO_STRING(x) LITERAL_TO_STRING_INTERNAL(x) 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 @@ AudioPlayer::~AudioPlayer() { } 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 @@ void AudioPlayer::start() { : 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::start() { } void AudioPlayer::pause() { - assert(mStarted); + CHECK(mStarted); if (mAudioSink.get() != NULL) { mAudioSink->pause(); @@ -113,7 +111,7 @@ void AudioPlayer::pause() { } void AudioPlayer::resume() { - assert(mStarted); + CHECK(mStarted); if (mAudioSink.get() != NULL) { mAudioSink->start(); @@ -123,7 +121,7 @@ void AudioPlayer::resume() { } void AudioPlayer::stop() { - assert(mStarted); + CHECK(mStarted); if (mAudioSink.get() != NULL) { mAudioSink->stop(); @@ -202,7 +200,7 @@ void AudioPlayer::fillBuffer(void *data, size_t size) { 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 @@ void AudioPlayer::fillBuffer(void *data, size_t size) { 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 @@ public: } 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 @@ CameraSource::~CameraSource() { } 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::start(MetaData *) { } status_t CameraSource::stop() { - assert(mStarted); + CHECK(mStarted); mCamera->stopPreview(); mCamera->unlock(); @@ -167,7 +165,7 @@ sp<MetaData> CameraSource::getFormat() { 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 @@ ssize_t FileSource::read_at(off_t offset, void *data, size_t size) { 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 @@ HTTPDataSource::HTTPDataSource(const char *uri) 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 @@ HTTPDataSource::HTTPDataSource(const char *uri) } 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 @@ HTTPDataSource::HTTPDataSource(const char *uri) 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 @@ HTTPDataSource::HTTPDataSource(const char *host, int port, const char *path) 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 @@ status_t HTTPStream::connect(const char *server, int port) { 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 @@ status_t HTTPStream::disconnect() { return ERROR_NOT_CONNECTED; } - assert(mSocket >= 0); + CHECK(mSocket >= 0); close(mSocket); mSocket = -1; @@ -165,7 +165,7 @@ status_t HTTPStream::receive_line(char *line, size_t size) { 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 @@ MP3Extractor::MP3Extractor(const sp<DataSource> &source) 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 @@ MP3Source::~MP3Source() { } status_t MP3Source::start(MetaData *) { - assert(!mStarted); + CHECK(!mStarted); mGroup = new MediaBufferGroup; @@ -409,7 +407,7 @@ status_t MP3Source::start(MetaData *) { } status_t MP3Source::stop() { - assert(mStarted); + CHECK(mStarted); delete mGroup; mGroup = NULL; @@ -481,7 +479,7 @@ status_t MP3Source::read( // 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 @@ MPEG4Writer::MPEG4Writer(const char *filename) : mFile(fopen(filename, "wb")), mOffset(0), mMdatOffset(0) { - assert(mFile != NULL); + CHECK(mFile != NULL); } MPEG4Writer::~MPEG4Writer() { @@ -173,7 +171,7 @@ void MPEG4Writer::stop() { } endBox(); // moov - assert(mBoxes.empty()); + CHECK(mBoxes.empty()); fclose(mFile); mFile = NULL; @@ -193,7 +191,7 @@ off_t MPEG4Writer::addSample(MediaBuffer *buffer) { } 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::beginBox(const char *fourcc) { } void MPEG4Writer::endBox() { - assert(!mBoxes.empty()); + CHECK(!mBoxes.empty()); off_t offset = *--mBoxes.end(); mBoxes.erase(--mBoxes.end()); @@ -244,7 +242,7 @@ void MPEG4Writer::writeCString(const char *s) { } 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 @@ void MPEG4Writer::Track::start() { 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 @@ void MPEG4Writer::Track::threadEntry() { ++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 @@ void MPEG4Writer::Track::threadEntry() { 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 @@ int64_t MPEG4Writer::Track::getDuration() const { 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 @@ void MPEG4Writer::Track::writeTrackHeader(int32_t trackID) { 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 @@ void MPEG4Writer::Track::writeTrackHeader(int32_t trackID) { int32_t samplerate; bool success = mMeta->findInt32(kKeySampleRate, &samplerate); - assert(success); + CHECK(success); mOwner->writeInt32(samplerate << 16); mOwner->endBox(); @@ -515,7 +513,7 @@ void MPEG4Writer::Track::writeTrackHeader(int32_t trackID) { } 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 @@ void MPEG4Writer::Track::writeTrackHeader(int32_t trackID) { 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 @@ void MPEG4Writer::Track::writeTrackHeader(int32_t trackID) { 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 @@ MediaBuffer::MediaBuffer(size_t size) void MediaBuffer::release() { if (mObserver == NULL) { - assert(mRefCount == 0); + CHECK_EQ(mRefCount, 0); delete this; return; } @@ -79,12 +77,12 @@ void MediaBuffer::release() { 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 @@ void MediaBuffer::set_range(size_t offset, size_t length) { 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 @@ void MediaBuffer::reset() { } MediaBuffer::~MediaBuffer() { - assert(mObserver == NULL); + CHECK_EQ(mObserver, NULL); if (mOwnsData && mData != NULL) { free(mData); @@ -143,7 +141,7 @@ MediaBuffer::~MediaBuffer() { } 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 @@ MediaBufferGroup::~MediaBufferGroup() { 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 2d7b628..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 @@ void MediaPlayerImpl::videoEntry() { bool eof = false; status_t err = mVideoDecoder->start(); - assert(err == OK); + CHECK_EQ(err, OK); while (mPlaying) { MediaBuffer *buffer; @@ -253,7 +251,7 @@ void MediaPlayerImpl::videoEntry() { } 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 @@ void MediaPlayerImpl::videoEntry() { 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 @@ void MediaPlayerImpl::init() { 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 @@ void MediaPlayerImpl::setVideoSource(const sp<MediaSource> &source) { 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 @@ MediaSource *MediaPlayerImpl::makeShoutcastSource(const char *uri) { } 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 @@ MediaSource *MediaPlayerImpl::makeShoutcastSource(const char *uri) { 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 @@ MediaSource *MediaPlayerImpl::makeShoutcastSource(const char *uri) { 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 @@ MediaSource *MediaPlayerImpl::makeShoutcastSource(const char *uri) { 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 @@ void MediaPlayerImpl::populateISurface() { 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 @@ bool MetaData::findInt32(uint32_t key, int32_t *value) { return false; } - assert(size == sizeof(*value)); + CHECK_EQ(size, sizeof(*value)); *value = *(int32_t *)data; @@ -102,7 +102,7 @@ bool MetaData::findFloat(uint32_t key, float *value) { return false; } - assert(size == sizeof(*value)); + CHECK_EQ(size, sizeof(*value)); *value = *(float *)data; @@ -117,7 +117,7 @@ bool MetaData::findPointer(uint32_t key, void **value) { 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 @@ MmapSource::MmapSource(const char *filename) 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 @@ MmapSource::MmapSource(int fd, int64_t offset, int64_t length) 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 @@ status_t MmapSource::InitCheck() const { 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 @@ status_t OMXClient::connect() { 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 @@ void OMXClient::disconnect() { return; } - assert(mObservers.isEmpty()); + CHECK(mObservers.isEmpty()); mReflector->reset(); mReflector.clear(); @@ -88,7 +86,7 @@ void OMXClient::unregisterObserver(IOMX::node_id node) { Mutex::Autolock autoLock(mLock); ssize_t index = mObservers.indexOfKey(node); - assert(index >= 0); + CHECK(index >= 0); if (index < 0) { return; @@ -155,7 +153,7 @@ void OMXObserver::start() { 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 @@ void OMXCodec::setVideoOutputFormat( // 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 @@ void OMXCodec::setVideoOutputFormat( &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 CodecInfo kEncoderInfo[] = { 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 @@ sp<OMXDecoder> OMXDecoder::Create( 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 @@ sp<OMXDecoder> OMXDecoder::Create( 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 @@ sp<OMXDecoder> OMXDecoder::Create( // printf("length = %d, size = %d\n", length, size); - assert(size >= length); + CHECK(size >= length); decoder->addCodecSpecificData(ptr, length); @@ -258,7 +257,7 @@ OMXDecoder::~OMXDecoder() { 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 @@ OMXDecoder::~OMXDecoder() { } status_t OMXDecoder::start(MetaData *) { - assert(!mStarted); + CHECK(!mStarted); // mDealer->dump("Decoder Dealer"); @@ -292,7 +291,7 @@ status_t OMXDecoder::start(MetaData *) { } status_t OMXDecoder::stop() { - assert(mStarted); + CHECK(mStarted); LOGI("Initiating OMX Node shutdown, busy polling."); initiateShutdown(); @@ -340,7 +339,7 @@ sp<MetaData> OMXDecoder::getFormat() { status_t OMXDecoder::read( MediaBuffer **out, const ReadOptions *options) { - assert(mStarted); + CHECK(mStarted); *out = NULL; @@ -384,7 +383,7 @@ status_t OMXDecoder::read( // 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 @@ status_t OMXDecoder::read( return OK; } else { - assert(mErrorCondition != OK); + CHECK(mErrorCondition != OK); return mErrorCondition; } } @@ -463,13 +462,13 @@ void OMXDecoder::setAMRFormat() { 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 @@ void OMXDecoder::setAACFormat() { 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 @@ status_t OMXDecoder::setVideoPortFormatType( 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 @@ void OMXDecoder::setVideoInputFormat( 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 @@ void OMXDecoder::setVideoInputFormat( 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 @@ void OMXDecoder::setVideoInputFormat( err = mOMX->set_parameter( mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); - assert(err == NO_ERROR); + CHECK_EQ(err, NO_ERROR); //////////////////////////////////////////////////////////////////////////// @@ -621,12 +620,12 @@ void OMXDecoder::setVideoInputFormat( 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 @@ void OMXDecoder::setVideoInputFormat( 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 @@ void OMXDecoder::setVideoOutputFormat( status_t err = mOMX->set_parameter( mNode, OMX_IndexParamStandardComponentRole, &role, sizeof(role)); - assert(err == OK); + CHECK_EQ(err, OK); } #endif @@ -672,7 +671,7 @@ void OMXDecoder::setVideoOutputFormat( 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 @@ void OMXDecoder::setVideoOutputFormat( 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 @@ void OMXDecoder::setVideoOutputFormat( err = mOMX->set_parameter( mNode, OMX_IndexParamVideoPortFormat, &format, sizeof(format)); - assert(err == OK); + CHECK_EQ(err, OK); } #endif @@ -719,7 +718,7 @@ void OMXDecoder::setVideoOutputFormat( 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 @@ void OMXDecoder::setVideoOutputFormat( } #endif - assert(def.eDomain == OMX_PortDomainVideo); + CHECK_EQ(def.eDomain, OMX_PortDomainVideo); video_def->nFrameWidth = width; video_def->nFrameHeight = height; @@ -738,7 +737,7 @@ void OMXDecoder::setVideoOutputFormat( err = mOMX->set_parameter( mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); - assert(err == NO_ERROR); + CHECK_EQ(err, NO_ERROR); //////////////////////////////////////////////////////////////////////////// @@ -749,9 +748,9 @@ void OMXDecoder::setVideoOutputFormat( 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 @@ void OMXDecoder::setVideoOutputFormat( 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 @@ void OMXDecoder::setup() { const char *mime; bool success = meta->findCString(kKeyMIMEType, &mime); - assert(success); + CHECK(success); if (!strcasecmp(mime, "audio/3gpp")) { setAMRFormat(); @@ -781,7 +780,7 @@ void OMXDecoder::setup() { 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 @@ void OMXDecoder::setup() { 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 @@ void OMXDecoder::setup() { 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 @@ void OMXDecoder::setup() { } 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 @@ void OMXDecoder::setup() { default: { - assert(!"should not be here, neither audio nor video."); + CHECK(!"should not be here, neither audio nor video."); break; } } @@ -880,7 +879,7 @@ void OMXDecoder::onStart() { 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 @@ void OMXDecoder::onStart() { // 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 @@ void OMXDecoder::allocateBuffers(OMX_U32 port_index) { 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 @@ void OMXDecoder::allocateBuffers(OMX_U32 port_index) { 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 @@ void OMXDecoder::allocateBuffers(OMX_U32 port_index) { mComponentName, err); } } - assert(err == OK); + CHECK_EQ(err, OK); LOGV("allocated %s buffer %p.", port_index == kPortIndexInput ? "INPUT" : "OUTPUT", @@ -1019,7 +1018,7 @@ void OMXDecoder::onEventCmdComplete(OMX_COMMANDTYPE type, OMX_U32 data) { 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 @@ void OMXDecoder::onEventCmdComplete(OMX_COMMANDTYPE type, OMX_U32 data) { 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 @@ void OMXDecoder::onEventCmdComplete(OMX_COMMANDTYPE type, OMX_U32 data) { PortStatus status = getPortStatus(port_index); - assert(status == kPortStatusFlushing + CHECK(status == kPortStatusFlushing || status == kPortStatusFlushingToDisabled || status == kPortStatusFlushingToShutdown); @@ -1085,7 +1084,7 @@ void OMXDecoder::onEventCmdComplete(OMX_COMMANDTYPE type, OMX_U32 data) { 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 @@ void OMXDecoder::onEventCmdComplete(OMX_COMMANDTYPE type, OMX_U32 data) { 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::onEventCmdComplete(OMX_COMMANDTYPE type, OMX_U32 data) { } 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 @@ void OMXDecoder::onEventPortSettingsChanged(OMX_U32 port_index) { 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 @@ void OMXDecoder::onStateChanged(OMX_STATETYPE to) { postInitialFillBuffer(buffer); } } else { - assert(to == OMX_StateLoaded); + CHECK_EQ(to, OMX_StateLoaded); mState = to; @@ -1171,14 +1170,14 @@ void OMXDecoder::onStateChanged(OMX_STATETYPE to) { 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 @@ void OMXDecoder::initiateShutdown() { return; } - assert(mState == OMX_StateExecuting); + CHECK_EQ(mState, OMX_StateExecuting); mShutdownInitiated = true; @@ -1204,7 +1203,7 @@ void OMXDecoder::initiateShutdown() { 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 @@ void OMXDecoder::initiateShutdown() { 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 @@ void OMXDecoder::onEmptyBufferDone(IOMX::buffer_id buffer) { err = NO_ERROR; break; } - assert(err == NO_ERROR); + CHECK_EQ(err, NO_ERROR); } void OMXDecoder::onFillBufferDone(const omx_message &msg) { @@ -1310,7 +1309,7 @@ void OMXDecoder::onFillBufferDone(const omx_message &msg) { break; } } - assert(err == NO_ERROR); + CHECK_EQ(err, NO_ERROR); } void OMXDecoder::onRealEmptyBufferDone(IOMX::buffer_id buffer) { @@ -1322,7 +1321,7 @@ void OMXDecoder::onRealEmptyBufferDone(IOMX::buffer_id buffer) { } 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 @@ void OMXDecoder::onRealEmptyBufferDone(IOMX::buffer_id buffer) { 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 @@ void OMXDecoder::onRealEmptyBufferDone(IOMX::buffer_id buffer) { } 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 @@ void OMXDecoder::onRealEmptyBufferDone(IOMX::buffer_id buffer) { 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 @@ void OMXDecoder::freeInputBuffer(IOMX::buffer_id buffer) { 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 @@ void OMXDecoder::freeOutputBuffer(IOMX::buffer_id buffer) { 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 @@ void OMXDecoder::dumpPortDefinition(OMX_U32 port_index) { 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 @@ void OMXDecoder::dumpPortDefinition(OMX_U32 port_index) { 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 @@ void OMXDecoder::dumpPortDefinition(OMX_U32 port_index) { 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 @@ status_t SampleTable::setChunkOffsetParams( return ERROR_MALFORMED; } - assert(type == kChunkOffsetType32 || type == kChunkOffsetType64); + CHECK(type == kChunkOffsetType32 || type == kChunkOffsetType64); mChunkOffsetOffset = data_offset; mChunkOffsetType = type; @@ -132,7 +132,7 @@ status_t SampleTable::setSampleSizeParams( return ERROR_MALFORMED; } - assert(type == kSampleSizeType32 || type == kSampleSizeTypeCompact); + CHECK(type == kSampleSizeType32 || type == kSampleSizeTypeCompact); mSampleSizeOffset = data_offset; @@ -272,7 +272,7 @@ status_t SampleTable::getChunkOffset(uint32_t chunk_index, off_t *offset) { *offset = ntohl(offset32); } else { - assert(mChunkOffsetOffset == kChunkOffsetType64); + CHECK_EQ(mChunkOffsetOffset, kChunkOffsetType64); uint64_t offset64; if (mDataSource->read_at( @@ -399,7 +399,7 @@ status_t SampleTable::getSampleSize( default: { - assert(mSampleSizeFieldSize == 4); + CHECK_EQ(mSampleSizeFieldSize, 4); uint8_t x; if (mDataSource->read_at( @@ -569,26 +569,6 @@ status_t SampleTable::findClosestSyncSample( } } -#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 @@ ShoutcastSource::ShoutcastSource(HTTPStream *http) 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 @@ ShoutcastSource::~ShoutcastSource() { } 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::start(MetaData *) { } status_t ShoutcastSource::stop() { - assert(mStarted); + CHECK(mStarted); delete mGroup; mGroup = NULL; @@ -85,7 +86,7 @@ sp<MetaData> ShoutcastSource::getFormat() { status_t ShoutcastSource::read( MediaBuffer **out, const ReadOptions *options) { - assert(mStarted); + CHECK(mStarted); *out = NULL; @@ -120,7 +121,7 @@ status_t ShoutcastSource::read( 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::postEventToBack(const sp<Event> &event) { 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 @@ public: } void setHandle(OMX_HANDLETYPE handle) { - assert(mHandle == NULL); + CHECK_EQ(mHandle, NULL); mHandle = handle; } @@ -541,7 +539,7 @@ void OMX::fill_buffer(node_id node, buffer_id buffer) { 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 @@ void OMX::empty_buffer( 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 @@ QComHardwareRenderer::QComHardwareRenderer( 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 @@ void QComHardwareRenderer::publishBuffers(uint32_t pmem_fd) { 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 @@ SoftwareRenderer::SoftwareRenderer( 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 @@ SoftwareRenderer::SoftwareRenderer( mMemoryHeap); status_t err = mISurface->registerBuffers(bufferHeap); - assert(err == OK); + CHECK_EQ(err, OK); } SoftwareRenderer::~SoftwareRenderer() { @@ -65,7 +63,7 @@ void SoftwareRenderer::render( 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; |
