h6ah4i / android-openslmediaplayer

Re-implementation of Android's MediaPlayer and audio effect classes based on OpenSL ES APIs.
https://openslmediaplayer.h6ah4i.com
Apache License 2.0
419 stars 97 forks source link

Rare issue in HybridMediaPlayer while using setDataSource() #32

Closed hunnydarapstar closed 7 years ago

hunnydarapstar commented 7 years ago

Hii @h6ah4i

I just encountered an issue while using HybridMediaPlayer at setDataSource(Context context,Uri uri) Method. Please note the parameters I am using for code inspection.

Here is the logcat:

Fatal Exception: java.lang.NullPointerException
com.h6ah4i.android.media.opensl.OpenSLMediaPlayer.setDataSource (SourceFile:134)

The line 134 points here:

public void setDataSource(FileDescriptor fd) throws IOException, IllegalArgumentException, IllegalStateException {
        int nativeFD = checkAndObtainNativeFileDescriptor(fd);
        this.checkNativeImplIsAvailable();
        int result = setDataSourceFdImplNative(this.mNativeHandle, nativeFD); //line 134 where null pointer exception is thrown
        parseResultAndThrowException(result);
    }

Please have a look on the issue. Looking forward to hear from you.

Best Regards

h6ah4i commented 7 years ago

@hunnydarapstar Hi. Please look at the following diagram. Maybe, you are using setDataSource(Context context, Uri uri), and the NullPointerException was thrown because the passed context parameter was null.

image

https://github.com/h6ah4i/android-openslmediaplayer/blob/0.7.2/library/src/main/java/com/h6ah4i/android/media/opensl/OpenSLMediaPlayer.java#L134