I've got some trouble with the media backend (mostly Stagefrightplayer) in Android, and I'd like to understand why it throws the errors it does. The errors are usually device spesific, so debugging on an emulator wouldn't be sufficient.
Example:
I/AwesomePlayer( 147): mConnectingDataSource->connect() returned -1004
V/MediaPlayerService( 147): [332] notify (0x272830, 100, 1, -1004)
E/MediaPlayer(24881): error (1, -1004)
E/MediaPlayer(24881): Error (1,-1004)
W/PlayerListener(24881): Received error: what = 1, extra = -1004
Example 2:
E/MediaPlayer( 941): error (1, -2147483648)
I've also gotten the player to bork completely and spit out a traces.txt.
Is there a way to debug what's happening, just like I debug Java code? Thanks.
Android Studio 3.0 and higher allow you to profile and debug APKs without having to build them from an Android Studio project. However, you need to make sure you're using an APK with debugging enabled. To start debugging an APK, click Profile or debug APK from the Android Studio Welcome screen.
A device must enable Developer mode in order to deploy and test an Android app. Developer mode is enabled by following these steps: Go to the Settings screen. Select About phone.
Quite a few things you can do.
If you believe the error is in the framework itself, then get the source and dig http://source.android.com/
Otherwise, the best debugger for Android is DDMS, it can work with the emulator, but also with the real device. http://developer.android.com/guide/developing/tools/ddms.html
dumpstate through adb (http://developer.android.com/guide/developing/tools/adb.html) will also give you a full snapshot of what is happening on the device, but it will difficult for you to get the exact point when the error happens.
Although that will still not give you source level debugging as GDB would (or I am not sure what you mean by your usual way of debugging Java code).
If you really mean kernel as kernel, then you are not really in Android anymore but more in Linux world but I don't think you need to go that far.
If you have trouble with a specific Android application (that's out of the open source and is not your own), I am afraid you are out of luck.
For the MediaPlayer part, the file for Eclair is located in https://android.googlesource.com/platform/frameworks/base/+/eclair-release/media/java/android/media/MediaPlayer.java, but cannot find the specific error message you put there.
Not that this directly answers your question, but this information might be useful to you.
So based upon your -1004 error code, you had an I/O Error trying to stream. As far as the -2147483648 error code, can't help you much. You would have to look at all of the log output from the media player to see why you are getting that code since it isn't defined. I've seen it from having the decoder choke on the video encoding.
Borrowed from: /frameworks/base/include/media/stagefright/MediaErrors.h
MEDIA_ERROR_BASE = -1000,
ERROR_ALREADY_CONNECTED = MEDIA_ERROR_BASE,
ERROR_NOT_CONNECTED = MEDIA_ERROR_BASE - 1,
ERROR_UNKNOWN_HOST = MEDIA_ERROR_BASE - 2,
ERROR_CANNOT_CONNECT = MEDIA_ERROR_BASE - 3,
ERROR_IO = MEDIA_ERROR_BASE - 4,
ERROR_CONNECTION_LOST = MEDIA_ERROR_BASE - 5,
ERROR_MALFORMED = MEDIA_ERROR_BASE - 7,
ERROR_OUT_OF_RANGE = MEDIA_ERROR_BASE - 8,
ERROR_BUFFER_TOO_SMALL = MEDIA_ERROR_BASE - 9,
ERROR_UNSUPPORTED = MEDIA_ERROR_BASE - 10,
ERROR_END_OF_STREAM = MEDIA_ERROR_BASE - 11,
Remote debugging (gdbserver on target + gdb on host) can be used to step-through C/C++ userland code running on real hardware. It offers all 'usual' options like breakpoints, backtrace, view/set variables, tracepoints.
For details, look at 'gdbclient' shell function of Android build system, pre-build eabi gdb and maybe DDD or another frontend. Eclipse should be ok.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With