0

For benchmarking purposes I repeat loading data from an asset and processing it with the Superpowered SDK. For opening the asset with the Superpowered SDK I create an AssetFileDescripter afd on java side and make a JNI call with the path to the apk, afd.getStartOffset() and afd.getLength() as parameters. In this JNI function I load the asset with a SuperpoweredDecoder and create a new file (/storage/emulated/0/result.wav) for saving the result.

The Problem is that when I create a new AssetFileDescripter in each benchmark iteration on java side creating the file /storage/emulated/0/result.wav with the Superpowered SDK fails after 971 iterations, or most of the time 995 iterations.

If I use only one and the same AssetFileDescripter for all iterations, all works fine and I can make 1000 or more benchmark iterations. Does anybody have ideas? (The android version of my testing device is 4.4.2)

I would be thankful for all hints.

Sebastian
  • 183
  • 1
  • 12
  • 1
    http://stackoverflow.com/questions/13262339/can-anyone-confirm-this-issue-limited-number-of-file-descriptors-on-some-androi seems relevant. – Alan Stokes Feb 19 '17 at 19:13
  • Thanks, you inspired me to close the AssetFileDescriptor in each iteration. I have somehow forgot to do this. – Sebastian Feb 19 '17 at 20:34
  • Can We convert our internal storage file to AssetFileDescripter ? Please tell me how your code is worked for playing storage music @Sebastian – nidhi Jul 06 '18 at 06:52
  • no, becasue the AssetFileDescriptor is used for assets (= raw files bundled with the application) and not for other storage like the internal. – Sebastian Aug 02 '18 at 10:40

1 Answers1

1

Closing the asset file descriptor after each iteration solved my problem. There really seems to be a device-dependent limit concerning open file descriptors. (Follow link to question in comments)

Sebastian
  • 183
  • 1
  • 12