From c3dcc87aa494934943769b70fd752af1271d196a Mon Sep 17 00:00:00 2001 From: Karl Kurbjun Date: Wed, 18 Apr 2007 07:41:31 +0000 Subject: Allow rockboy to run while music is playing with smaller roms. Works on players that do not use the IRAM macros. Only tested on the Gigabeat as I think that is the only player that will run rockboy well with music. Also simplified the sound and reduced the code size a bit. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13199 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/rockboy/rbsound.c | 103 ++++++++++++++--------------------------- 1 file changed, 35 insertions(+), 68 deletions(-) (limited to 'apps/plugins/rockboy/rbsound.c') diff --git a/apps/plugins/rockboy/rbsound.c b/apps/plugins/rockboy/rbsound.c index 41d00c1b73..4e61d5590c 100644 --- a/apps/plugins/rockboy/rbsound.c +++ b/apps/plugins/rockboy/rbsound.c @@ -2,30 +2,14 @@ #include "defs.h" #include "pcm.h" -/*#define ONEBUF*/ - /* Note: I think the single buffer implementation is more - * responsive with sound(less lag) but it creates more - * choppyness overall to the sound. 2 buffer's don't seem to - * make a difference, but 4 buffers is definately noticable - */ - struct pcm pcm IBSS_ATTR; -bool sound = 1; -#ifdef ONEBUF -#define N_BUFS 1 -#else -#define N_BUFS 4 -#endif +#define N_BUFS 2 #define BUF_SIZE 1024 #if CONFIG_CODEC == SWCODEC && !defined(SIMULATOR) -#ifndef ONEBUF -static short curbuf,gmcurbuf; -#else -bool doneplay=0; -#endif +bool doneplay=1; static unsigned char *buf=0; static unsigned short *gmbuf; @@ -34,33 +18,30 @@ static bool newly_started; void get_more(unsigned char** start, size_t* size) { -#ifdef ONEBUF - doneplay=1; - *start = (unsigned char*)(gmbuf); -#else - *start = (unsigned char*)(&gmbuf[pcm.len*curbuf]); -#endif - *size = BUF_SIZE*sizeof(short); + *start = (unsigned char*)(&gmbuf[pcm.len*doneplay]); + *size = BUF_SIZE*sizeof(short); } void pcm_init(void) { + if(plugbuf) + return; + newly_started = true; pcm.hz = 11025; pcm.stereo = 1; pcm.len = BUF_SIZE; - if(!buf){ - buf = my_malloc(pcm.len * N_BUFS); - gmbuf = my_malloc(pcm.len * N_BUFS*sizeof (short)); - pcm.buf = buf; - pcm.pos = 0; -#ifndef ONEBUF - curbuf = gmcurbuf= 0; -#endif - memset(gmbuf, 0, pcm.len * N_BUFS *sizeof(short)); - memset(buf, 0, pcm.len * N_BUFS); + if(!buf) + { + buf = my_malloc(pcm.len * N_BUFS); + gmbuf = my_malloc(pcm.len * N_BUFS*sizeof (short)); + + pcm.buf = buf; + pcm.pos = 0; + memset(gmbuf, 0, pcm.len * N_BUFS *sizeof(short)); + memset(buf, 0, pcm.len * N_BUFS); } rb->pcm_play_stop(); @@ -75,46 +56,32 @@ void pcm_close(void) rb->pcm_play_stop(); rb->pcm_set_frequency(44100); } - + int pcm_submit(void) { - if (!options.sound) return 1; register int i; - if (!sound) { - pcm.pos = 0; - return 0; - } + if (pcm.pos < pcm.len) return 1; - if (pcm.pos < pcm.len) return 1; + doneplay=!doneplay; -#ifndef ONEBUF - curbuf = (curbuf + 1) % N_BUFS; - pcm.buf = buf + pcm.len * curbuf; -#endif - pcm.pos = 0; + if(doneplay) + pcm.buf = buf + pcm.len; + else + pcm.buf = buf; + + pcm.pos = 0; + + /* gotta convert the 8 bit buffer to 16 */ + for(i=0; ipcm_play_data(&get_more,NULL,0); + newly_started = false; + } - /* gotta convert the 8 bit buffer to 16 */ - for(i=0; ipcm_play_data(&get_more,NULL,0); - newly_started = false; - } - - /* this while loop and done play are in place to make sure the sound timing - * is correct(although it's not) - */ -#ifdef ONEBUF - while(doneplay==0) rb->yield(); - doneplay=0; -#endif return 1; } #else -- cgit v1.2.3