forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Strange problem porting app.

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
theHobbit



Joined: 30 Sep 2006
Posts: 65

PostPosted: Fri Sep 05, 2008 1:31 pm    Post subject: Strange problem porting app. Reply with quote

Hi there, i'm trying to port vio2play to the psp. vio2play is a nintendo ds sound format (2sf) player for linux.

I've already compiled a library with the vio2sf code and a simple test player. But when i try to run the app in the psp i get an 0x80020148 error, wich means 'Unsupported prx'. This error was supposed to occur when you tryied to run a 1.5 kernel app in a 3xx kernel if i'm not wrong (?)

But i'm creating the app as a user mode prx, so i don't know why i'm getting that error code.

Here is the simple player and the makefile:

Code:


#include <pspkernel.h>
#include <psppower.h>

#include <SDL/SDL.h>
#include "ao.h"
#include "corlett.h"
#include "vio2sf/vio2sf.h"

PSP_MODULE_INFO("vio2play", 0x0, 0, 1);
PSP_MAIN_THREAD_PARAMS(/*Prio*/80, /*Stack KB*/512, PSP_THREAD_ATTR_USER);//PSP_THREAD_ATTR_USER);
PSP_MAIN_THREAD_NAME("Main");
PSP_HEAP_SIZE_KB(2 * 1024);

// Variables
static uint8 *buffer;       // buffer containing 2sf file
static uint32 size;         // size of buffer
static corlett_t *c = NULL;

// Audio info variables
int  channels = 2;
int  samplerate = 44100;
int    length = 0;

static void audiocallback ( void * userdata, Uint8 * stream, int len )
{
   xsf_gen(stream, len);
}

char *xsf_tagget(const char *tag, const char *pData, int dwSize);

/* ao_get_lib: called to load secondary files */
int xsf_get_lib(char *filename, void **buffer, unsigned int *length)
{
   uint8 *filebuf;
   uint32 size;
   FILE *auxfile;

   auxfile = fopen(filename, "rb");
   if (!auxfile)
   {
      printf("Unable to find auxiliary file %s\n", filename);
      return AO_FAIL;
   }

   fseek(auxfile, 0, SEEK_END);
   size = ftell(auxfile);
   fseek(auxfile, 0, SEEK_SET);

   filebuf = malloc(size);

   if (!filebuf)
   {
      fclose(auxfile);
      printf("ERROR: could not allocate %d bytes of memory\n", size);
      return AO_FAIL;
   }

   fread(filebuf, size, 1, auxfile);
   fclose(auxfile);

   *buffer = filebuf;
   *length = (uint64)size;

   return AO_SUCCESS;
}

static void do_frame(uint32 size, int16 *buffer)
{
   xsf_gen(buffer, size);
}

// load and set up a 2sf file
int load_file(char *name)
{
   FILE *file;
   uint32 filesig;
   uint8 *filedata;
   uint64 file_len;

   file = fopen(name, "rb");

   if (!file)
   {
      fprintf(stderr, "ERROR: could not open file %s\n", name);
      return -1;
   }

   // get the length of the file by seeking to the end then reading the current position
   fseek(file, 0, SEEK_END);
   size = ftell(file);
   // reset the pointer
   fseek(file, 0, SEEK_SET);

   buffer = malloc(size);

   if (!buffer)
   {
      fclose(file);
      fprintf(stderr, "ERROR: could not allocate %d bytes of memory\n", size);
      return -1;
   }

   // read the file
   fread(buffer, size, 1, file);
   fclose(file);

   // init our *SF engine so we can get tags
   if (corlett_decode(buffer, size, &filedata, &file_len, &c) != AO_SUCCESS)
   {
      fprintf(stderr, "Error: Unable to process tags\n");
      return -1;
   }
   free(filedata);   // we don't use this

    if (xsf_start(buffer, size) != XSF_TRUE)
   {
      fprintf(stderr, "ERROR: vio2sf rejected the file!\n");
      return -1;
   }

   return 0;
}

u64 tickFrequency, last, cur, med;
int main( int argc, char *argv[] )
{
   char tune[256];
   if( argv[1] ) strcpy(tune, argv[1]);
   else strcpy(tune, "test.2sf");
   
   if( load_file(tune) < 0 ) goto close;
   
   // Get audio info
   samplerate = 44100;
   channels = 2;
   if ((c != NULL) && (c->inf_length != NULL)) length = psfTimeToMS(c->inf_length);
   else length = 0;   

   if ((c != NULL) && (c->inf_title != NULL))
   {
      fprintf(stderr, "Playing \"%s\" by %s from %s.  Copyright %s %s.\n", c->inf_title, c->inf_artist, c->inf_game, c->inf_copy, c->inf_year);
   }
   else
   {
      fprintf(stderr, "Playing %s\n", tune);
   }
   
   fprintf(stderr, "Samplerate:    %d\n", samplerate);
   fprintf(stderr, "Channels:      %d\n", channels);
   fprintf(stderr, "BitsPerSample: %d\n", 0);
   fprintf(stderr, "Length:        %d\n", length);
   
   // Check if samplerate is compatible
   if( samplerate != 44100 ) {
      fprintf(stderr, "Error: Samplerate not supported: %d\n", samplerate);
      goto close;
   }
   
   SDL_AudioSpec audioSpec;
   audioSpec.freq       = samplerate;
    audioSpec.format    = AUDIO_S16LSB;
    audioSpec.channels    = channels;
    audioSpec.samples    = 8192;
    audioSpec.callback    = audiocallback;
   
   if (SDL_OpenAudio(&audioSpec, NULL)<0) {
        fprintf(stderr, "Error: Cannot open audio device\n");
        return 0;
    }
   
    SDL_PauseAudio(0);
   
   if( length > 0 ) SDL_Delay( length );
   else SDL_Delay( 5000 );

close:      
   fprintf(stderr, "Exiting OK\n");
   SDL_CloseAudio();
   SDL_Quit();
   
   // Terminate engine and free memory
   xsf_term();
   free(buffer);
   
   sceKernelDelayThread( 0 );
   sceKernelExitGame();
   return 0;
}


Code:
# Modplug Player PSP

TARGET = vio2play

PSPSDK=$(shell psp-config --pspsdk-path)
PSPBIN = D:/cygwin/usr/local/pspdev/psp/bin
PSPDIR=$(shell psp-config --psp-prefix)

PSP_FW_VERSION = 371
BUILD_PRX = 1

CFLAGS  = -O2 -G0 -Wall -DLSB_FIRST=1 -D_strnicmp=strnicmp
CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions
INCDIR = vio2sf

OBJS =    vio2play.o corlett.o
      
LIBS = -l2sf -lSDL -lm -lz \
      -lpsppower -lpsprtc -lpspaudio

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = vio2play v

include $(PSPSDK)/lib/build.mak


The only thing i have found is that something in the vio2sf code is causing it, because if i comment all vio2sf calls (xsf_something) the app loads and run fine. Does anyone have a clue of what is happening? I could share the code if anyone is interested.

Thanks in advance
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group