Пример #1
0
void FillBuffer(int channel)
{
	SceUChar8* dst;
	int num;
	int pos;
	sceMp3GetInfoToAddStreamData(streamsSceMp3[channel].handle,&dst,&num,&pos);
	if (streamsSceMp3[channel].lastPosition>pos)
	{
		if (!streamsSceMp3[channel].autoloop)
		{
			streamsSceMp3[channel].paused=TRUE;
			streamsSceMp3[channel].stopReason=PSPAALIB_STOP_END_OF_STREAM;
		}
	}
	streamsSceMp3[channel].lastPosition=pos;
	sceIoLseek32(streamsSceMp3[channel].file,pos,PSP_SEEK_SET);
	int read=sceIoRead(streamsSceMp3[channel].file,(char*)dst,num);
	sceMp3NotifyAddStreamData(streamsSceMp3[channel].handle,read);
}
Пример #2
0
bool JMP3::fillBuffers() {
   //JLOG("Start JMP3::fillBuffers");
   if (!init_done) {
      JLOG("JMP3::fillBuffers called but init_done is false!");
      return false;
   }
#ifdef MP3_SUPPORT   
   SceUChar8* dest;
   SceInt32 length;
   SceInt32 pos;

   int ret = sceMp3GetInfoToAddStreamData(m_mp3Handle, &dest, &length, &pos);
   if (ret < 0)
      return false;

    if (sceIoLseek32(m_fileHandle, pos, SEEK_SET) < 0) {
      // Re-open the file because file handel can be invalidated by suspend/resume.
      sceIoClose(m_fileHandle);
      m_fileHandle = sceIoOpen(m_fileName, PSP_O_RDONLY, 0777);
      if (m_fileHandle < 0)
         return false;
      if (sceIoLseek32(m_fileHandle, 0, SEEK_END) != m_fileSize
            || sceIoLseek32(m_fileHandle, pos, SEEK_SET) < 0) {
         sceIoClose(m_fileHandle);
         m_fileHandle = -1;
         return false;
      }
    }

    int readLength = sceIoRead(m_fileHandle, dest, length);

   if (readLength < 0)
      return false;

   ret = sceMp3NotifyAddStreamData(m_mp3Handle, readLength);
   if (ret < 0)
      return false;
#endif
     //JLOG("End JMP3::fillBuffers");
   return true;
}
Пример #3
0
int fillStreamBuffer( int fd, int handle )
{
    char* dst;
    int write;
    int pos;
    // Get Info on the stream (where to fill to, how much to fill, where to fill from)
    int status = sceMp3GetInfoToAddStreamData( handle, &dst, &write, &pos);
    if (status<0)
    {
        ERRORMSG("ERROR: sceMp3GetInfoToAddStreamData returned 0x%08X\n", status);
    }

    // Seek file to position requested
    status = sceIoLseek32( fd, pos, SEEK_SET );
    if (status<0)
    {
        ERRORMSG("ERROR: sceIoLseek32 returned 0x%08X\n", status);
    }

    // Read the amount of data
    int read = sceIoRead( fd, dst, write );
    if (read < 0)
    {
        ERRORMSG("ERROR: Could not read from file - 0x%08X\n", read);
    }

    if (read==0)
    {
        // End of file?
        return 0;
    }

    // Notify mp3 library about how much we really wrote to the stream buffer
    status = sceMp3NotifyAddStreamData( handle, read );
    if (status<0)
    {
        ERRORMSG("ERROR: sceMp3NotifyAddStreamData returned 0x%08X\n", status);
    }

    return (pos>0);
}