Bug 27541 - XA fails to load the audio file from SDcard to play on MediaPlayer with "Java.IO.IOException: setDataSourceFD failed"
Summary: XA fails to load the audio file from SDcard to play on MediaPlayer with "Java...
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Android
Classification: Xamarin
Component: General (show other bugs)
Version: 4.20.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2015-03-02 02:06 UTC by Prashant Cholachagudda
Modified: 2017-10-04 15:05 UTC (History)
5 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Test case (40.83 KB, application/zip)
2015-03-02 02:06 UTC, Prashant Cholachagudda
Details

Description Prashant Cholachagudda 2015-03-02 02:06:25 UTC
Created attachment 10106 [details]
Test case

Xamarin.Android fails to load the audio files on MediaPlayer in Samsung Galaxy S3/S4 Phones and throws the below exception.

Java.IO.IOException: setDataSourceFD failed.: status=0x80000000
  at at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <IL 0x00011, 0x00068>
  at Android.Runtime.JNIEnv.CallVoidMethod (intptr,intptr,Android.Runtime.JValue[]) [0x00063] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:508
  at Android.Media.MediaPlayer.SetDataSource (string) [0x0004a] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Media.MediaPlayer.cs:2262
  at AudioRecoderer.MainActivity.<OnCreate>m__1 (object,System.EventArgs) [0x0003c] in /Users/dominicnahous/Downloads/AudioRecoderer/AudioRecoderer/MainActivity.cs:54
  at Android.Views.View/IOnClickListenerImplementor.OnClick (Android.Views.View) [0x0000d] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Views.View.cs:1873
  at Android.Views.View/IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Views.View.cs:1840
  at at (wrapper dynamic-method) object.45a9f2e6-9d8a-4cec-bf1c-62bf5da62bbe (intptr,intptr,intptr) <IL 0x00017, 0x00043>
  at --- End of managed exception stack trace ---
  at java.io.IOException: setDataSourceFD failed.: status=0x80000000
  at at android.media.MediaPlayer._setDataSource(Native Method)
  at at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1378)
  at at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1362)
  at at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1300)
  at at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1238)
  at at mono.android.view.View_OnClickListenerImplementor.n_onClick(Native Method)
  at at mono.android.view.View_OnClickListenerImplementor.onClick(View_OnClickListenerImplementor.java:29)
  at at android.view.View.performClick(View.java:4630)
  at at android.view.View$PerformClick.run(View.java:19331)
  at at android.os.Handler.handleCallback(Handler.java:733)
  at at android.os.Handler.dispatchMessage(Handler.java:95)
  at at android.os.Looper.loop(Looper.java:157)
  at at android.app.ActivityThread.main(ActivityThread.java:5356)
  at at java.lang.reflect.Method.invokeNative(Native Method)
  at at java.lang.reflect.Method.invoke(Method.java:515)
  at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
  at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
  at at dalvik.system.NativeStart.main(Native Method)

Please use the attached test case to produce the crash on Samsung S3/S4 devices
Comment 1 Naqeeb 2015-03-02 12:56:05 UTC
I have checked this issue with the help of attached Test Case and able to reproduce successfully. To reproduce I have followed below steps:

1. Open attached Test Case on XS.
2. Deploy on 'Samsung S3' and 'Samsung S4' device.
3. Click on 'Start Recording' button.
4. Wait for some time.
5. Click on 'Stop Recording' button.

I observe that when click on 'Stop Recording' button, It is throw same exception given in bug description. Same shown as Screencast: http://www.screencast.com/t/p2EkqqLj

Ide log: https://gist.github.com/sunil360/0acaab269ea36740c6be
Exception log: https://gist.github.com/sunil360/0fdec797281acae0c032
adb log: https://gist.github.com/sunil360/50897e25b9aa13e7426d

Environment info:
=== Xamarin Studio ===

Version 5.7.2 (build 8)
Installation UUID: 561c7a69-0a91-4bae-ad7c-f0c79d594337
Runtime:
	Mono 3.12.0 ((detached/b8f5055)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000077

=== Apple Developer Tools ===

Xcode 5.1.1 (5085)
Build 5B1008

=== Xamarin.iOS ===

Version: 8.6.2.26 (Business Edition)
Hash: 9905782
Branch: 
Build date: 2015-02-26 11:05:07-0500

=== Xamarin.Android ===

Version: 4.20.0.28 (Trial Edition)
Android SDK: /Users/tajinder/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Xamarin.Mac ===

Version: 1.10.0.18 (Business Edition)

=== Build Information ===

Release ID: 507020008
Git revision: 64a4266f0a82f7558472383d8ae66a526b3b881d
Build date: 2015-02-25 11:22:12-05
Xamarin addins: 1cb443ca2dddd9933d748e035560f06cf9c246bd

=== Operating System ===

Mac OS X 10.8.4
Darwin Tajinders-iMac.local 12.4.2 Darwin Kernel Version 12.4.2
    Mon Jun 17 18:00:12 PDT 2013
    root:xnu-2050.45.8~1/RELEASE_X86_64 x86_64
Comment 2 Nestor 2016-01-13 01:26:18 UTC
Having the same issue, do you have
Comment 3 Jonathan Pryor 2016-01-14 20:21:41 UTC
The Java API is unhappy:

>   at java.io.IOException: setDataSourceFD failed.: status=0x80000000

So...Google: 

https://www.google.com/search?q=at+java.io.IOException%3A+setDataSourceFD+failed.%3A+status%3D0x80000000

Which shows multiple hits on stackoverflow.com, e.g.:

http://stackoverflow.com/questions/9657280/mediaplayer-setdatasource-causes-ioexception-for-valid-file

Do any of those links solve your problem?
Comment 4 Nestor 2016-01-14 23:26:25 UTC
I couldn't find any solution. As the original bug description says it affects only some Samsung devices (maybe others).

Similar to the screencast (comment 1), I'm trying to play an audio file recorded with the same device using:

Recorder.SetAudioChannels(1);
Recorder.SetAudioSamplingRate(16000);
Recorder.SetAudioEncodingBitRate(24000);
Recorder.SetAudioSource(AudioSource.Mic);
Recorder.SetOutputFormat(OutputFormat.AacAdts);
Recorder.SetAudioEncoder(AudioEncoder.Aac);

This works in other devices, even files recorded in the samsung devices work if I copy them to my PC.

I have tried:

if (!File.Exists(FilePath))  return false;
Player.SetDataSource(FilePath);
Player.Prepare();
...

var fis = new FileInputStream(FilePath);
Player.SetDataSource(fis.FD);
Player.Prepare();
....

var audioFile = new Java.IO.File(FilePath);
var uri = Android.Net.Uri.FromFile(aduioFile);                    Player.SetDataSource(Android.App.Application.Context,uri);
Player.Prepare();
...

And I have simmilar exceptions 


{Java.IO.IOException: Exception of type 'Java.IO.IOException' was thrown.
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/1978/f98871a9/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61 
  at Android.Runtime.JNIEnv.CallVoidMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue* parms) [0x00063] in /Users/builder/data/lanes/1978/f98871a9/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:571 
  at Android.Media.MediaPlayer.SetDataSource (System.String path) [0x00061] in /Users/builder/data/lanes/1978/f98871a9/source/monodroid/src/Mono.Android/platforms/android-22/src/generated/Android.Media.MediaPlayer.cs:2577  
  --- End of managed exception stack trace ---
java.io.IOException: setDataSourceFD failed.: status=0x80000000
	at android.media.MediaPlayer._setDataSource(Native Method)
	at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1231)
	at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1215)
	at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1173)
	at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1114)
	at md5530bd51e982e6e7b340b73e88efe666e.CellAdapter.n_onItemClick(Native Method)
	at md5530bd51e982e6e7b340b73e88efe666e.CellAdapter.onItemClick(CellAdapter.java:83)
	at android.widget.AdapterView.performItemClick(AdapterView.java:308)
	at android.widget.AbsListView.performItemClick(AbsListView.java:1510)
	at android.widget.AbsListView$PerformClick.run(AbsListView.java:3472)
	at android.widget.AbsListView$3.run(AbsListView.java:4835)
	at android.os.Handler.handleCallback(Handler.java:733)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:146)
	at android.app.ActivityThread.main(ActivityThread.java:5593)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:515)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
	at dalvik.system.NativeStart.main(Native Method)
}



{Java.IO.IOException: Exception of type 'Java.IO.IOException' was thrown.
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/1978/f98871a9/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61 
  at Android.Runtime.JNIEnv.CallVoidMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue* parms) [0x00063] in /Users/builder/data/lanes/1978/f98871a9/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:571 
  at Android.Media.MediaPlayer.SetDataSource (Java.IO.FileDescriptor fd) [0x0005a] in /Users/builder/data/lanes/1978/f98871a9/source/monodroid/src/Mono.Android/platforms/android-22/src/generated/Android.Media.MediaPlayer.cs:2492   
  --- End of managed exception stack trace ---
java.io.IOException: setDataSourceFD failed.: status=0x80000000
	at android.media.MediaPlayer._setDataSource(Native Method)
	at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1231)
	at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1215)
	at md5530bd51e982e6e7b340b73e88efe666e.GenericAnimatorListener.n_onAnimationEnd(Native Method)
	at md5530bd51e982e6e7b340b73e88efe666e.GenericAnimatorListener.onAnimationEnd(GenericAnimatorListener.java:46)
	at android.view.ViewPropertyAnimator$AnimatorEventListener.onAnimationEnd(ViewPropertyAnimator.java:1030)
	at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1056)
	at android.animation.ValueAnimator.access$400(ValueAnimator.java:50)
	at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:644)
	at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:660)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:812)
	at android.view.Choreographer.doCallbacks(Choreographer.java:612)
	at android.view.Choreographer.doFrame(Choreographer.java:581)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:798)
	at android.os.Handler.handleCallback(Handler.java:733)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:146)
	at android.app.ActivityThread.main(ActivityThread.java:5593)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:515)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
	at dalvik.system.NativeStart.main(Native Method)
}



at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
  at Android.Runtime.JNIEnv.CallVoidMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue* parms) [0x00000] in <filename unknown>:0 
  at Android.Media.MediaPlayer.SetDataSource (Android.Content.Context context, Android.Net.Uri uri) [0x00000] in <filename unknown>:0   
  --- End of managed exception stack trace ---
java.io.IOException: setDataSourceFD failed.: status=0x80000000
	at android.media.MediaPlayer._setDataSource(Native Method)
	at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1231)
	at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1215)
	at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1173)
	at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1114)
	at android.media.MediaPlayer.setDataSource(MediaPlayer.java:945)
	at android.media.MediaPlayer.setDataSource(MediaPlayer.java:928)
	at md5530bd51e982e6e7b340b73e88efe666e.GenericAnimatorListener.n_onAnimationEnd(Native Method)
	at md5530bd51e982e6e7b340b73e88efe666e.GenericAnimatorListener.onAnimationEnd(GenericAnimatorListener.java:46)
	at android.view.ViewPropertyAnimator$AnimatorEventListener.onAnimationEnd(ViewPropertyAnimator.java:1030)
	at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1056)
	at android.animation.ValueAnimator.access$400(ValueAnimator.java:50)
	at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:644)
	at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:660)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:812)
	at android.view.Choreographer.doCallbacks(Choreographer.java:612)
	at android.view.Choreographer.doFrame(Choreographer.java:581)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:798)
	at android.os.Handler.handleCallback(Handler.java:733)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:146)
	at android.app.ActivityThread.main(ActivityThread.java:5593)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:515)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
	at dalvik.system.NativeStart.main(Native Method)
Comment 5 Jon Douglas [MSFT] 2017-10-04 15:05:17 UTC
Unfortunately, we’re unable to reproduce this report. If this issue is still occurring for you, please reopen this issue and attach a reproduction to the bug by starting with a clean Xamarin.Android project adding just the code necessary to demonstrate the issue.

This also seems answered based on the following comment: https://bugzilla.xamarin.com/show_bug.cgi?id=27541#c3

Note You need to log in before you can comment on or make changes to this bug.