Rockbox.org home
Downloads
Release release
Dev builds dev builds
Extras extras
themes themes
Documentation
Manual manual
Wiki wiki
Device Status device status
Support
Forums forums
Mailing lists mailing lists
IRC IRC
Development
Bugs bugs
Patches patches
Dev Guide dev guide
Search



Donate

Rockbox Technical Forums


Login with username, password and session length
Home Help Search Staff List Login Register
News:

Welcome to the Rockbox Technical Forums!

+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  Help with calling rb-> mp3_play_data
« previous next »
  • Print
Pages: [1]

Author Topic: Help with calling rb-> mp3_play_data  (Read 1436 times)

Offline snoozydude

  • Member
  • *
  • Posts: 6
Help with calling rb-> mp3_play_data
« on: November 30, 2007, 04:40:10 AM »
Hello
I have created a function to play an bit of an mp3 file that gets read into a buffer (txt) when I hit a particular value of x and y in the main program.

The actual mp3 file is about 3mb and I just read in a small amount at the moment.

I can get the mp3 excert to play but I do not return from my "play_track" function. The function mp3_is_playing does not return false.

If I remove the calls to mp3_play_data and just put in a counter loop the function works as expected and returns to the main program.

I find I also have to put in a short sleep for rb->mp3_is_playing() to return True.
 
Should mp3_play_data return when it get to the end of the buffer?

Here is an excert of the program - any tips would me much appreciated.

#define BUFFER_SIZE 163840
static unsigned char beep[25];
unsigned char** start;
size_t* size;
static bool is_playing;

/* This is a dummy function to keep mp3_play_data happy  
* copied from chip8.c
*/
void callback(unsigned char** start,size_t* size)
{
*start = beep;
*size = sizeof(beep);
}

short play_track(short x, short y)
{
int fd = -1;
static char txt[BUFFER_SIZE+1];
char *track;

   track="/.rockbox/rocks/games/bob.mp3";
   fd = rb->open(track, O_RDONLY);
 
   if (fd < 0) {
      fd=99;
   }
 
  if (fd == 1) {
      rb->read(fd,txt,BUFFER_SIZE);
      rb->mp3_play_data( txt, sizeof(txt), callback);
  }

  rb->close(fd);
  rb->sleep(HZ);
  rb->yield();

  while( rb->mp3_is_playing() ){
     rb->sleep(HZ);  
  }
 
  x+=1;
  return x;
}
Logged

  • Print
Pages: [1]
« previous next »
+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  Help with calling rb-> mp3_play_data
 

  • SMF 2.0.17 | SMF © 2019, Simple Machines
  • Rockbox Privacy Policy
  • XHTML
  • RSS
  • WAP2

Page created in 0.047 seconds with 15 queries.