| View previous topic :: View next topic |
| Author |
Message |
Shapyi
Joined: 25 Apr 2005 Posts: 95
|
Posted: Fri Apr 18, 2008 12:31 pm Post subject: Question about memory stick access and threads |
|
|
I searched the forums and couldn't find a direct answer. I am writing a program for PSP that uses a thread to stream MP3s as background music using cooleye's example. Now the thread is reading the memory stick every time it needs a new frame in the mp3. The main program is also reading the memory stick fairly often. Do I need to worry about that? Does the kernel handle it alright or do I need to lock anything?
Thanks. |
|
| Back to top |
|
 |
a_noob
Joined: 17 Sep 2006 Posts: 97 Location: _start: jr 0xDEADBEEF
|
Posted: Fri Apr 18, 2008 2:30 pm Post subject: |
|
|
You shouldnt need to worry about it, but I would optimise the mp3 player to take larger chunks than just the next frame, I would advise taking in multiple frames, and using slightly more memory, This will also have less reading from the ms. Just my two cents ;) _________________
| Code: | .øOº'ºOø.
'ºOo.oOº' |
|
|
| Back to top |
|
 |
moonlight
Joined: 26 Oct 2005 Posts: 567
|
Posted: Fri Apr 18, 2008 5:10 pm Post subject: |
|
|
Some tips: make the read buffer aligned to 64 bytes. There is actually a noticeable difference in reading speed when the buffer is aligned to 64 bytes.
Read always a quantity multiple of 512, the bigger the better (the file position should be also at a multiple of 512). |
|
| Back to top |
|
 |
Insert_witty_name
Joined: 10 May 2006 Posts: 376
|
Posted: Fri Apr 18, 2008 7:24 pm Post subject: |
|
|
I used a similar method to your initially, but it caused lagging when other file io was present (only from the save dialog).
To circumvent this I made larger reads (64 frames at a time), triple buffered and used async reading.
Moonlight's tips also give a decent boost. |
|
| Back to top |
|
 |
Viper8896
Joined: 26 Jan 2006 Posts: 110
|
Posted: Sun Apr 20, 2008 4:57 pm Post subject: |
|
|
some tips:
sceAudioOutput and sceAudioOutputBlocking are two functions that do the ouput. One starts the output and then executes the next bit of code. The other starts the output then waits before going to the next line of code. The trick is to have the sceAudioOutputBlocking in a different thread because when it executes this line of code it is really just waiting the thread so then you have you're decoding thread automatically get control and make sure the cpu has allways got something to do.
also if you're not sure of the sample size when you call:
sceAudioChReserve(int channel, int samplecount, int format);
the other way is to use:
sceAudioSetChannelDataLen(int channel, int samplecount);
before every output. |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Sun Apr 20, 2008 7:15 pm Post subject: |
|
|
| Also, the count must be a multiple of 64. Many people make the buffer 64 byte aligned as well, but that isn't required. |
|
| Back to top |
|
 |
SilverSpring
Joined: 27 Feb 2007 Posts: 115
|
Posted: Sun Apr 20, 2008 9:18 pm Post subject: |
|
|
If anyone's interested, found a little while ago:
| Code: | 0x38553111 sceAudioSRCChReserve
0x5c37c0ae sceAudioSRCChRelease
0xe0727056 sceAudioSRCOutputBlocking |
Prototypes are different to the the sceAudioChReserve/sceAudioChRelease/sceAudioOutputBlocking, something like this:
| Code: | int sceAudioSRCChReserve(int samplecount, int freq, int format);
int sceAudioSRCChRelease(void);
int sceAudioSRCOutputBlocking(int vol, void *buf);
|
That should complete the audio lib now. |
|
| Back to top |
|
 |
Shapyi
Joined: 25 Apr 2005 Posts: 95
|
Posted: Mon Apr 21, 2008 9:56 am Post subject: |
|
|
| Thanks for all the comments. Everything seems to be working fine. |
|
| Back to top |
|
 |
Viper8896
Joined: 26 Jan 2006 Posts: 110
|
Posted: Mon Apr 21, 2008 12:31 pm Post subject: |
|
|
| SilverSpring wrote: | | If anyone's interested, found a little while ago:..... |
have you tried that, found out what it does and do you know what SRC means? |
|
| Back to top |
|
 |
SilverSpring
Joined: 27 Feb 2007 Posts: 115
|
Posted: Mon Apr 21, 2008 7:47 pm Post subject: |
|
|
| Viper8896 wrote: | | SilverSpring wrote: | | If anyone's interested, found a little while ago:..... |
have you tried that, found out what it does and do you know what SRC means? |
Well those nids I was finding for cswindle so I'm guessing he might have a sample on the proper usage. |
|
| Back to top |
|
 |
crazyc
Joined: 17 Jun 2005 Posts: 410
|
Posted: Thu Apr 24, 2008 6:49 am Post subject: |
|
|
| SilverSpring wrote: | | Viper8896 wrote: | | SilverSpring wrote: | | If anyone's interested, found a little while ago:..... |
have you tried that, found out what it does and do you know what SRC means? |
Well those nids I was finding for cswindle so I'm guessing he might have a sample on the proper usage. | http://forums.ps2dev.org/viewtopic.php?t=8742 |
|
| Back to top |
|
 |
SilverSpring
Joined: 27 Feb 2007 Posts: 115
|
Posted: Thu Apr 24, 2008 8:20 am Post subject: |
|
|
Oh ok, wow over 8 months ago too.
Well at least we have the proper names now so the post wasnt completely redundant :) |
|
| Back to top |
|
 |
|