View unanswered posts | View active topics It is currently Thu Nov 27, 2014 9:28 pm



Reply to topic  [ 7 posts ] 
 fopen() freezes the DS while concurrent access to the card 
Author Message

Joined: Tue Jul 14, 2009 10:44 pm
Posts: 4
Hi,

I successfully used libfat to read and display images on my DS.
My concern is that when I use ASLib to stream a MP3 at the same time (using AS_MP3StreamPlay() function), it sometimes freezes the DS.

I think it may be caused by a concurrent access going wrong.
I made a "stress test loop" which load 2 jpgs files every second to diagnose. Here is the status:
- Loading + MP3 streaming : Freeze somewhere between a few seconds and 11 minutes (best results)
- Loading only : Didn't freeze after 9 hours
- MP3 only : Didn't freeze after 1 hour

Using extensive highly elaborated trace system (a.k.a. "printf" :o) ), freeze always happens during the fopen.

Is it a way to check that the libfat is ready before trying to open a file? (I don't mind waiting a few ms to open the file)

Thanks for reading my question,
Eric


Sat Aug 01, 2009 10:45 am
Profile
User avatar

Joined: Fri Jul 11, 2008 8:49 pm
Posts: 222
Location: The Netherlands
it is known that ASlib takes a heavy tol on the ds, leaving little time left for your program. I also believe that opening a file while streaming a mp3 isn't possible, because ASlib needs constant acces to the mp3 file.


and ASlib probably isn't supported by devkitPro.

_________________
my blog:
http://vuurrobin.100webcustomers.com/


Sat Aug 01, 2009 12:28 pm
Profile WWW

Joined: Tue Jul 14, 2009 10:44 pm
Posts: 4
Thanks for your reply vuurobin!

I was thinking that ASLib was using the ARM7, leaving most of the ARM9 resources for your program... but I may be wrong here since I didn't actually check the code source.

I've read on this very forum that libfat was thread safe, and I still cannot understand how it would be possible than the lib can be placed in a situation where no file could be opened (except for exhausting the max number of handlers, which is probably not the case here (I checked the numerical value of the fd, and it stayed stable)).

ASLib is just using libfat here. This freeze is probably libfat related and could probably be reproduced without ASLib.

I could probably work-around the problem by preloading all my files before starting the music, but I am really curious about the source of the issue (you always learn a lot by understanding why things doesn't work how they're supposed to ;o) ).

Eric


Sat Aug 01, 2009 3:03 pm
Profile
Site Admin

Joined: Tue Aug 09, 2005 3:21 am
Posts: 1138
Location: UK
devkitARM does not support threading on the DS.

ASLib is an unsupported 3rd party library.

_________________
devkitPro IRC support
Personal Blog


Sun Aug 02, 2009 11:47 pm
Profile ICQ WWW
User avatar

Joined: Fri Jul 11, 2008 8:49 pm
Posts: 222
Location: The Netherlands
@WinterMute, maybe he meant threading more like this, where you said that libfat is thread safe.

@LeF, ASlib uses the ARM7 to play the file, but it uses ARM9 to stream the file from the flashcard. because it does this every vblank, it leaves little to no time to access any other file on the flashcard (flashcards aren't exactly fast when it comes to accessing files).

_________________
my blog:
http://vuurrobin.100webcustomers.com/


Mon Aug 03, 2009 1:26 pm
Profile WWW

Joined: Thu Jul 02, 2009 1:19 pm
Posts: 332
you could try removing the aslib vblank handler and calling it directly in you main loop. provided that you main loop does not run too slow then it should work.

also, make sure you are NOT calling irqInit() as this is being called for you in startup code in the newer libnds versions.


Mon Aug 03, 2009 2:10 pm
Profile
Site Admin

Joined: Tue Aug 09, 2005 3:21 am
Posts: 1138
Location: UK
vuurrobin wrote:
@WinterMute, maybe he meant threading more like this, where you said that libfat is thread safe.


Yeah but libfat is only thread safe in a threaded environment like cube/wii. Currently devkitARM does not support threading and there aren't really any current plans to change that.

Quote:
@LeF, ASlib uses the ARM7 to play the file, but it uses ARM9 to stream the file from the flashcard. because it does this every vblank, it leaves little to no time to access any other file on the flashcard (flashcards aren't exactly fast when it comes to accessing files).


This is one of the reasons why streaming audio on the DS isn't the best of ideas. Generally I'd use tracker formats for in game music unless you're doing something like a standalone mp3 player.

_________________
devkitPro IRC support
Personal Blog


Tue Aug 04, 2009 12:08 am
Profile ICQ WWW
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
  Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.
Get devkitPro at SourceForge.net. Fast, secure and Free Open Source software downloads