Exemplo n.º 1
0
void
psp_audio_init()
{
  psp_audio_chid = sceAudioChReserve(-1, 1024, 0);
  psp_audio_thid = sceKernelCreateThread( "audio_thread",(void*)&psp_audio_thread,0x12,0x10000,0,NULL);
	sceKernelStartThread( psp_audio_thid, 0, 0);

  MP3_Init();

  psp_cdaudio_chid = sceAudioChReserve(-1, 1024, 0);
  psp_cdaudio_thid = sceKernelCreateThread( "cdaudio_thread",(void*)&psp_cdaudio_thread,0x12,0x10000,0,NULL);
	sceKernelStartThread( psp_cdaudio_thid, 0, 0);
}
Exemplo n.º 2
0
int playerStart(char *path,pMalloc extern_malloc,pFree extern_free,	int(*callback)(int)){
	int ret,ch;MODFILE mod;
	if(!extern_malloc || !extern_free)return -1;
	if((ch=sceAudioChReserve(PSP_AUDIO_NEXT_CHANNEL,PSP_AUDIO_SAMPLE_ALIGN(768),PSP_AUDIO_FORMAT_STEREO))<0)return ch;
	myMalloc=extern_malloc;
	myFree	=extern_free;
	MODFILE_Init(&mod);
	if((ret=MODFILE_Load(path, &mod))<0)return ret;
	mod.musicvolume = 255;
	mod.sfxvolume = 255;
	mod.callback = NULL;//callback;
	MODFILE_Start(&mod);
	MODFILE_SetFormat(&mod, 44100, 2,16,1/*unsigned*/);
	SceCtrlData pad;
	sceCtrlSetSamplingCycle(0);
	sceCtrlSetSamplingMode(1);
	for(int i=0;;i++){
		sceCtrlReadBufferPositive(&pad,1);
		if(pad.Buttons&PSP_CTRL_START)break;
		mod.mixingbuf =(void*)out[i%2];
		mod.mixingbuflen = 768*2*2;
		MODFILE_Player(&mod);
		sceAudioOutputBlocking(ch, PSP_AUDIO_VOLUME_MAX,out[i%2]);
	}
	MODFILE_Stop(&mod);
	MODFILE_Free(&mod);
	sceAudioChRelease(ch);
	return 0;
}
Exemplo n.º 3
0
int pspAudioInit()
{
	int i,ret;
	int failed=0;
	char str[32];

	audio_terminate=0;
	audio_ready=0;

	for (i=0; i<PSP_NUM_AUDIO_CHANNELS; i++) {
    AudioStatus[i].handle = -1;
    AudioStatus[i].threadhandle = -1;
    AudioStatus[i].volumeright = PSP_VOLUME_MAX;
    AudioStatus[i].volumeleft  = PSP_VOLUME_MAX;
    AudioStatus[i].callback = 0;
    AudioStatus[i].pdata = 0;
	}
	for (i=0; i<PSP_NUM_AUDIO_CHANNELS; i++) {
		if ((AudioStatus[i].handle = sceAudioChReserve(-1,PSP_NUM_AUDIO_SAMPLES,0))<0) 
      failed=1;
	}
	if (failed) {
		for (i=0; i<PSP_NUM_AUDIO_CHANNELS; i++) {
			if (AudioStatus[i].handle != -1) 
        sceAudioChRelease(AudioStatus[i].handle);
			AudioStatus[i].handle = -1;
		}
		return -1;
	}
	audio_ready = 1;
	strcpy(str,"audiot0");
	for (i=0; i<PSP_NUM_AUDIO_CHANNELS; i++) {
		str[6]='0'+i;
		AudioStatus[i].threadhandle = sceKernelCreateThread(str,(void*)&AudioChannelThread,0x12,0x10000,0,NULL);
		if (AudioStatus[i].threadhandle < 0) {
			AudioStatus[i].threadhandle = -1;
			failed=1;
			break;
		}
		ret=sceKernelStartThread(AudioStatus[i].threadhandle,sizeof(i),&i);
		if (ret!=0) {
			failed=1;
			break;
		}
	}
	if (failed) {
		audio_terminate=1;
		for (i=0; i<PSP_NUM_AUDIO_CHANNELS; i++) {
			if (AudioStatus[i].threadhandle != -1) {
				//sceKernelWaitThreadEnd(AudioStatus[i].threadhandle,NULL);
				sceKernelDeleteThread(AudioStatus[i].threadhandle);
			}
			AudioStatus[i].threadhandle = -1;
		}
		audio_ready=0;
		return -1;
	}
	return 0;
}
Exemplo n.º 4
0
static int
PSPAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
{
    int format, mixlen, i;
    this->hidden = (struct SDL_PrivateAudioData *)
        SDL_malloc(sizeof(*this->hidden));
    if (this->hidden == NULL) {
        return SDL_OutOfMemory();
    }
    SDL_zerop(this->hidden);
    switch (this->spec.format & 0xff) {
        case 8:
        case 16:
            this->spec.format = AUDIO_S16LSB;
            break;
        default:
            return SDL_SetError("Unsupported audio format");
    }

    /* The sample count must be a multiple of 64. */
    this->spec.samples = PSP_AUDIO_SAMPLE_ALIGN(this->spec.samples);
    this->spec.freq = 44100;

    /* Update the fragment size as size in bytes. */
    SDL_CalculateAudioSpec(&this->spec);

    /* Allocate the mixing buffer.  Its size and starting address must
       be a multiple of 64 bytes.  Our sample count is already a multiple of
       64, so spec->size should be a multiple of 64 as well. */
    mixlen = this->spec.size * NUM_BUFFERS;
    this->hidden->rawbuf = (Uint8 *) memalign(64, mixlen);
    if (this->hidden->rawbuf == NULL) {
        return SDL_SetError("Couldn't allocate mixing buffer");
    }

    /* Setup the hardware channel. */
    if (this->spec.channels == 1) {
        format = PSP_AUDIO_FORMAT_MONO;
    } else {
        format = PSP_AUDIO_FORMAT_STEREO;
    }
    this->hidden->channel = sceAudioChReserve(PSP_AUDIO_NEXT_CHANNEL, this->spec.samples, format);
    if (this->hidden->channel < 0) {
        free(this->hidden->rawbuf);
        this->hidden->rawbuf = NULL;
        return SDL_SetError("Couldn't reserve hardware channel");
    }

    memset(this->hidden->rawbuf, 0, mixlen);
    for (i = 0; i < NUM_BUFFERS; i++) {
        this->hidden->mixbufs[i] = &this->hidden->rawbuf[i * this->spec.size];
    }

    this->hidden->next_buffer = 0;
    return 0;
}
Exemplo n.º 5
0
bool PspAudio::open(uint32 freq, uint32 numOfChannels, uint32 numOfSamples, callbackFunc callback, void *userData) {
	DEBUG_ENTER_FUNC();
	if (_init) {
		PSP_ERROR("audio device already initialized\n");
		return true;
	}

	PSP_DEBUG_PRINT("freq[%d], numOfChannels[%d], numOfSamples[%d], callback[%p], userData[%x]\n",
			freq, numOfChannels, numOfSamples, callback, (uint32)userData);

	numOfSamples = PSP_AUDIO_SAMPLE_ALIGN(numOfSamples);
	uint32 bufLen = numOfSamples * numOfChannels * NUM_BUFFERS * sizeof(uint16);

	PSP_DEBUG_PRINT("total buffer size[%d]\n", bufLen);

	_buffers[0] = (byte *)memalign(64, bufLen);
	if (!_buffers[0]) {
		PSP_ERROR("failed to allocate memory for audio buffers\n");
		return false;
	}
	memset(_buffers[0], 0, bufLen);	// clean the buffer

	// Fill in the rest of the buffer pointers
	byte *pBuffer = _buffers[0];
	for (int i = 1; i < NUM_BUFFERS; i++) {
		pBuffer += numOfSamples * numOfChannels * sizeof(uint16);
		_buffers[i] = pBuffer;
	}

	// Reserve a HW channel for our audio
	_pspChannel = sceAudioChReserve(PSP_AUDIO_NEXT_CHANNEL, numOfSamples, numOfChannels == 2 ? PSP_AUDIO_FORMAT_STEREO : PSP_AUDIO_FORMAT_MONO);
	if (_pspChannel < 0) {
		PSP_ERROR("failed to reserve audio channel\n");
		return false;
	}

	PSP_DEBUG_PRINT("reserved channel[%d] for audio\n", _pspChannel);

	// Save our data
	_numOfChannels = numOfChannels;
	_numOfSamples = numOfSamples;
	_bufferSize = numOfSamples * numOfChannels * sizeof(uint16);	// should be the right size to send the app
	_callback = callback;
	_userData = userData;
	_bufferToFill = 0;
	_bufferToPlay = 0;

	_init = true;
	_paused = true;	// start in paused mode

	threadCreateAndStart("audioThread", PRIORITY_AUDIO_THREAD, STACK_AUDIO_THREAD);	// start the consumer thread

	return true;
}
Exemplo n.º 6
0
/**
 * start_channel:  Allocate a new channel and starts playback.
 *
 * [Parameters]
 *     buffer_desc: Playback buffer descriptor
 * [Return value]
 *     Nonzero on success, zero on error
 */
static int start_channel(PSPSoundBufferDesc *buffer_desc)
{
    if (!buffer_desc) {
        DMSG("buffer_desc == NULL");
        return 0;
    }
    if (buffer_desc->started) {
        DMSG("Buffer is already started!");
        return 0;
    }

    /* Allocate a hardware channel */
    buffer_desc->channel = sceAudioChReserve(
        PSP_AUDIO_NEXT_CHANNEL, BUFFER_SIZE, PSP_AUDIO_FORMAT_STEREO
    );
    if (buffer_desc->channel < 0) {
        DMSG("Failed to allocate channel: %s",
             psp_strerror(buffer_desc->channel));
        return 0;
    }

    /* Initialize the ring buffer */
    buffer_desc->cur_play = NUM_BUFFERS - 1;
    buffer_desc->next_play = 0;
    buffer_desc->next_write = 0;
    int i;
    for (i = 0; i < NUM_BUFFERS; i++) {
        buffer_desc->write_ready[i] = 1;
    }
    buffer_desc->stop = 0;
    /* Also write everything out of the cache so it's ready for the ME */
    sceKernelDcacheWritebackAll();

    /* Start the playback thread */
    char thname[100];
    snprintf(thname, sizeof(thname), "YabauseSoundCh%d", buffer_desc->channel);
    SceUID handle = sys_start_thread(thname, playback_thread,
                                     THREADPRI_SOUND, 0x1000,
                                     sizeof(buffer_desc), &buffer_desc);
    if (handle < 0) {
        DMSG("Failed to create thread: %s", psp_strerror(handle));
        sceAudioChRelease(buffer_desc->channel);
        return 0;
    }
    buffer_desc->thread = handle;

    /* Success */
    buffer_desc->started = 1;
    return 1;
}
Exemplo n.º 7
0
void OSPC_PlayBuffer(char *buff,int len,int release,int vol)
{
    int i,j,pollcpt;
    char str[256];
    SPC_ID666 *id;
    char *emulator[3]={"Unknown","Zsnes","Snes9x"};
    uint8 *scr;
   
    OSPC_Init();

    if (i=OSPC_LoadBuffer(buff,len))
    {
    	sprintf(str,"Error at SPC loading, code : %d",i);
    	msgBoxLines(str,60);
    	//gp32_pause();
    	//GpAppExit();
    	return;
    }
     

	OSPC_id=OSPC_GetID666(spc_data);
		
  OSPC_sound_fd = sceAudioChReserve( -1, 1024, 0 );
  OSPC_exit=0;
  OSPC_volume=vol;
  OSPC_thread = sceKernelCreateThread( "OSPC Thread", (SceKernelThreadEntry)OSPC_PlayThread, 0x8, 256*1024, 0, 0 );
  if (OSPC_thread<0) {
  	msgBoxLines("Cannot create OSPC playback thread",60);
  } else {
  	//init start time		
		sceKernelLibcGettimeofday( &OSPC_start_time, 0 );
  	
  	sceKernelStartThread( OSPC_thread, 0, 0 );
  	
  	if (release) return;
  	
  	for (;;) {
  		pgWaitV();
  		if (get_pad()) break;
  	}
  	OSPC_exit=1;  	
  	sceKernelWaitThreadEnd( OSPC_thread, NULL );
		sceKernelDeleteThread( OSPC_thread );
		OSPC_thread=-1;
  }    
  sceAudioChRelease( OSPC_sound_fd );
  OSPC_Stop();            
  OSPC_Close();    
  if (OSPC_id) free(OSPC_id);
}
Exemplo n.º 8
0
int PlayThread(SceSize argsize, void* args)
{
	if (argsize!=sizeof(int))
	{
		sceKernelExitThread(0);
	}
	int hardwareChannel=*((int*)args);
	int channel=hardwareChannels[hardwareChannel];
	int stopReason;
	void *mainBuf,*backBuf,*tempBuf;
	mainBuf=malloc(4096);
	backBuf=malloc(4096);
	sceAudioChReserve(hardwareChannel,1024,PSP_AUDIO_FORMAT_STEREO);
	while(TRUE)
	{
		stopReason=AalibGetStopReason(channel);
		if (!stopReason)
		{
			goto Play;
		}
		else if (stopReason<0)
		{
			sceKernelDelayThread(10);
			continue;
		}
		else
		{
			goto Release;
		}
	}
Play:
	GetProcessedBuffer(mainBuf,1024,channel);
	while (!AalibGetStopReason(channel))
	{
		sceAudioOutputPanned(hardwareChannel,(unsigned int)(channels[channel].volume.left*channels[channel].audioStrength*PSP_AUDIO_VOLUME_MAX),(unsigned int)(channels[channel].volume.right*channels[channel].audioStrength*PSP_AUDIO_VOLUME_MAX),mainBuf);
		GetProcessedBuffer(backBuf,1024,channel);
		while (sceAudioGetChannelRestLen(hardwareChannel))
			sceKernelDelayThread(100);
		
		tempBuf=mainBuf;
		mainBuf=backBuf;
		backBuf=tempBuf;
	}
Release:
	FreeHardwareChannel(channel);
	AalibStop(channel);
	sceKernelExitThread(0);
	return 0;
}
Exemplo n.º 9
0
static int SoundThread()
{
	int err=0;
	int sample_count;
	int chan;
	int realSampleCount;
	int buf = 0;

	//For SMS, we need tighter timings
	if (menuConfig.sound.perfectSynchro && gblMachineType == EM_SMS)
		sample_count = 128;
	else
		sample_count = snd.sample_rate/snd.fps;
	sample_count = PSP_AUDIO_SAMPLE_ALIGN(sample_count);
	realSampleCount = sample_count / (44100 / snd.sample_rate);
	chan = sceAudioChReserve(PSP_AUDIO_NEXT_CHANNEL, sample_count, PSP_AUDIO_FORMAT_STEREO);

	if(chan > 0 && sample_count > 0 && sample_count <= 2048)
	{
		for(; soundRunning; )
		{
			if (soundPause)
				memset(audioOut[buf], 0, sample_count * sizeof(sample_t));
			else
				StandardSoundProcess();

			//Game Boy: réglage du son ne fonctionne pas!
			AudioGet(audioOut[buf], sample_count, realSampleCount);
			sceAudioOutputBlocking(chan, PSP_AUDIO_VOLUME_MAX, (void*)audioOut[buf]);

			if (menuConfig.sound.perfectSynchro)
				buf = 1 - buf;
		}

		sceAudioChRelease(chan);
	}

	soundRunning = -1;
	sceKernelExitDeleteThread(0);
}
Exemplo n.º 10
0
Arquivo: mp3.c Projeto: 173210/mvspsp
int mp3_thread_start(void)
{
	mp3_handle  = -1;
	mp3_thread  = -1;
	mp3_active  = 0;
	mp3_status  = MP3_STOP;
	mp3_running = 0;
	mp3_sleep   = 0;

	mp3_newfile = 0;
	mp3_volume  = 0;

	memset(mp3_out[0], 0, MP3_BUFFER_SIZE);
	memset(mp3_out[1], 0, MP3_BUFFER_SIZE);

	mp3_handle = sceAudioChReserve(PSP_AUDIO_NEXT_CHANNEL, MP3_SAMPLES, PSP_AUDIO_FORMAT_STEREO);
	if (mp3_handle < 0)
	{
		fatalerror(TEXT(COULD_NOT_RESERVE_AUDIO_CHANNEL_FOR_MP3));
		return 0;
	}

	mp3_active = 1;

	mp3_thread = sceKernelCreateThread("MP3 thread", MP3Thread, 0x8, 0x40000, 0, NULL);
	if (mp3_thread < 0)
	{
		fatalerror(TEXT(COULD_NOT_START_MP3_THREAD));
		sceAudioChRelease(mp3_handle);
		return 0;
	}

	sceKernelStartThread(mp3_thread, 0, 0);

	return 1;
}
Exemplo n.º 11
0
// -------------------------------------------------------
// Initialize the AT3 replay
static triSInt AT3_FileInit(triVoid *File_Mem, triSInt File_Length, triVoid (*Mixing_CallBack)(triS16 *AT3_Audio_Buffer, triSInt AT3_Buffer_Size))
{
	triUInt *dwFile_Mem;
	triUChar *tmpFile_Mem;
	typedef struct
	{
		unsigned short		wFormatTag;         // Format category
		unsigned short		wChannels;          // Number of channels
		unsigned long		dwSamplesPerSec;    // Sampling rate
		unsigned long		dwAvgBytesPerSec;   // For buffer estimation
		unsigned short		wBlockAlign;        // Data block size
		unsigned short		wBitsPerSample;		// Sample size
	} WAVFMTCHUNK;
	WAVFMTCHUNK fmt;
	memset( &fmt, 0, sizeof(WAVFMTCHUNK) );
					
	AT3_Playing = 0;
	AT3_CallBack = Mixing_CallBack;
	
	dwFile_Mem = (triUInt *) File_Mem;
	
	if(*dwFile_Mem++ == 'FFIR')
	{
		dwFile_Mem++;

		if(*dwFile_Mem++ == 'EVAW')
		{
			tmpFile_Mem = (triUChar *) (dwFile_Mem + 2);
			AT3_align = 384;
			while(*dwFile_Mem != 'atad')
			{
				if (*dwFile_Mem++ == ' tmf')
				{
					memcpy( &fmt, (dwFile_Mem+1), sizeof(WAVFMTCHUNK) );
					AT3_align = fmt.wBlockAlign;
					//printf("Fmt:\nFormat: %x\nChannels: %i\nRate: %i\nBPS: %i\nAlign: %i\nBits: %i\n", fmt.wFormatTag, fmt.wChannels, fmt.dwSamplesPerSec, fmt.dwAvgBytesPerSec, fmt.wBlockAlign, fmt.wBitsPerSample );
				}
				
				dwFile_Mem = (triUInt *) (tmpFile_Mem + *dwFile_Mem);
				tmpFile_Mem = (triUChar *) (dwFile_Mem + 2);
			}
			dwFile_Mem++;
			
			AT3_Datas_Start = (triSInt) tmpFile_Mem - (triSInt) File_Mem;
			memset(AT3_Codec_Buffer, 0, sizeof(AT3_Codec_Buffer));
			memset(AT3_Mix_Buffer, 0, AT3_SAMPLES * 2 * 2);
			
			AT3_Codec_Buffer[26] = 0x20;
			AT3_Codec_Buffer[43] = 0x1001;
			memcpy( (void*)AT3_Buffer, (void*)(File_Mem + AT3_Datas_Start), AT3_align );
			if (AT3_align==192)
			{
				memcpy( (void*)(AT3_Buffer+192), (void*)AT3_Buffer, 192 );
			}
			AT3_pos = (triUInt)(File_Mem + AT3_Datas_Start);
			AT3_Codec_Buffer[AT3_CURRENT_BUFFER] = (triSInt)AT3_Buffer; //(File_Mem + AT3_Datas_Start);
			AT3_Codec_Buffer[AT3_TEMPORARY_BUFFER] = (triSInt) AT3_Mix_Buffer;
			
			if (AT3_align==304)
				AT3_Codec_Buffer[10] = 6;
			else
				AT3_Codec_Buffer[10] = 4;
			AT3_Codec_Buffer[44] = 2;
			AT3_length = File_Length;
			AT3_Codec_Buffer[AT3_INITIAL_BUFFER] = (triSInt) File_Mem;
			AT3_Codec_Buffer[AT3_LENGTH_BUFFER] = 384;

			if(sceAudiocodecCheckNeedMem(AT3_Codec_Buffer, AT3_TYPE_ATRAC3) < 0) return(0);
			if(sceAudiocodecGetEDRAM(AT3_Codec_Buffer, AT3_TYPE_ATRAC3) < 0) return(0);
			if(sceAudiocodecInit(AT3_Codec_Buffer, AT3_TYPE_ATRAC3) < 0) return(0);

			AT3_Channel = sceAudioChReserve(0, AT3_SAMPLES, PSP_AUDIO_FORMAT_STEREO);
		
			if(AT3_Channel < 0) return(0);
		
			AT3_ThreadID = sceKernelCreateThread("TriAtrac3", (triVoid *) AT3_Thread, AT3_THREAD_PRIORITY, (1024 * 4), PSP_THREAD_ATTR_USER, NULL);
		
			if(AT3_ThreadID < 0) return(0);
		
			sceKernelStartThread(AT3_ThreadID, 0, NULL);
		
			return(1);
		}
	}
	return(0);
}
Exemplo n.º 12
0
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Functions for ME
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Open audio for player:
int openAudio(int channel, int samplecount){
	int audio_channel = sceAudioChReserve(channel, samplecount, PSP_AUDIO_FORMAT_STEREO );
    if(audio_channel < 0)
        audio_channel = sceAudioChReserve(PSP_AUDIO_NEXT_CHANNEL, samplecount, PSP_AUDIO_FORMAT_STEREO );
	return audio_channel;
}
Exemplo n.º 13
0
int main(int argc, char *argv[])
{
    SceCtrlData pad;
    int oldButtons = 0;
    int i;
#define SECOND       1000000
#define REPEAT_START (1 * SECOND)
#define REPEAT_DELAY (SECOND / 5)
    struct timeval repeatStart;
    struct timeval repeatDelay;

    repeatStart.tv_sec = 0;
    repeatStart.tv_usec = 0;
    repeatDelay.tv_sec = 0;
    repeatDelay.tv_usec = 0;

    for (i = 0; i < SAMPLE_SIZE; i += 2)
    {
	buffer1[i+0] = 0x00;
	buffer1[i+1] = 0x70;
	buffer2[i+0] = 0x00;
	buffer2[i+1] = 0x10;
    }

    pspDebugScreenInit();

    printf("Triangle - Exit\n");
    printf("Cross - Test Blocking Audio\n");
    printf("Square - Test non-Blocking Audio\n");
    printf("Circle - Test Audio2\n");

    channel = sceAudioChReserve(PSP_AUDIO_NEXT_CHANNEL, SAMPLE_SIZE, PSP_AUDIO_FORMAT_STEREO);
    if (channel < 0)
    {
        sceKernelExitGame();
    }

    while(!done)
    {
        sceCtrlReadBufferPositive(&pad, 1);
        int buttonDown = (oldButtons ^ pad.Buttons) & pad.Buttons;

	if (pad.Buttons == oldButtons)
	{
		struct timeval now;
		gettimeofday(&now, NULL);
		if (repeatStart.tv_sec == 0)
		{
			repeatStart.tv_sec = now.tv_sec;
			repeatStart.tv_usec = now.tv_usec;
			repeatDelay.tv_sec = 0;
			repeatDelay.tv_usec = 0;
		}
		else
		{
			long usec = (now.tv_sec - repeatStart.tv_sec) * SECOND;
			usec += (now.tv_usec - repeatStart.tv_usec);
			if (usec >= REPEAT_START)
			{
				if (repeatDelay.tv_sec != 0)
				{
					usec = (now.tv_sec - repeatDelay.tv_sec) * SECOND;
					usec += (now.tv_usec - repeatDelay.tv_usec);
					if (usec >= REPEAT_DELAY)
					{
						repeatDelay.tv_sec = 0;
					}
				}

				if (repeatDelay.tv_sec == 0)
				{
					buttonDown = pad.Buttons;
					repeatDelay.tv_sec = now.tv_sec;
					repeatDelay.tv_usec = now.tv_usec;
				}
			}
		}
	}
	else
	{
		repeatStart.tv_sec = 0;
	}

        if (buttonDown & PSP_CTRL_CROSS)
        {
		strcpy(text, "Start Test:\n");
		gettimeofday(&previousAudioOutput, NULL);
		for (i = 0; i < 10; i++)
		{
			audioOutput(buffer1, 1);
			audioOutput(buffer2, 1);
		}
		strcat(text, "\n");

		printf(text);
        }

        if (buttonDown & PSP_CTRL_SQUARE)
        {
		strcpy(text, "Start Test:\n");
		gettimeofday(&previousAudioOutput, NULL);
		for (i = 0; i < 10; i++)
		{
			audioOutput(buffer1, 0);
			audioOutput(buffer2, 0);
		}
		strcat(text, "\n");

		printf(text);
        }

        if (buttonDown & PSP_CTRL_CIRCLE)
        {
		sceAudioOutput2Reserve(SAMPLE_SIZE / 2);

		audioOutput2(buffer1, 0xFFFFF);
		sceKernelDelayThread(1 * 1000000);
		audioOutput2(buffer1, 0x20000);
		sceKernelDelayThread(1 * 1000000);
		audioOutput2(buffer1, 0x10000);
		sceKernelDelayThread(1 * 1000000);
		audioOutput2(buffer1, 0x08000);
		sceKernelDelayThread(1 * 1000000);
		audioOutput2(buffer1, 0x04000);
		sceKernelDelayThread(1 * 1000000);
		audioOutput2(buffer1, 0x02000);
		sceKernelDelayThread(1 * 1000000);
		audioOutput2(buffer1, 0x01000);
		sceKernelDelayThread(1 * 1000000);
		audioOutput2(buffer1, 0x00800);
        }

        if (buttonDown & PSP_CTRL_RIGHT)
        {
        }

        if (buttonDown & PSP_CTRL_UP)
        {
        }

        if (buttonDown & PSP_CTRL_DOWN)
        {
        }


        if (buttonDown & PSP_CTRL_TRIANGLE)
	{
        	done = 1;
	}

        oldButtons = pad.Buttons;
	sceDisplayWaitVblank();
    }

    sceKernelExitGame();
    return 0;
}
Exemplo n.º 14
0
SceInt32 CPMFPlayer::InitAudio()
{
	int i = 0, fail = 0;

	Audio.m_AudioChannel = sceAudioChReserve(-1, 512, PSP_AUDIO_FORMAT_STEREO);
	if(Audio.m_AudioChannel < 0)
	{
		sprintf(m_LastError, "sceAudioChReserve() failed: 0x%08X", (int)Audio.m_AudioChannel);
		return -1;
	}

	sceAudioSetChannelDataLen(Audio.m_AudioChannel, m_MpegAtracOutSize / 4);

	Audio.m_ThreadID = sceKernelCreateThread("audio_thread", T_Audio, 0x3D, 0x10000, PSP_THREAD_ATTR_USER, NULL);
	if(Audio.m_ThreadID < 0)
	{
		sprintf(m_LastError, "sceKernelCreateThread() failed: 0x%08X", (int)Audio.m_ThreadID);
		goto exit0;
	}

	Audio.m_SemaphoreStart = sceKernelCreateSema("audio_start_sema",  0, 0, 1, NULL);
	if(Audio.m_SemaphoreStart < 0)
	{
		sprintf(m_LastError, "sceKernelCreateSema() failed: 0x%08X", (int)Audio.m_SemaphoreStart);
		goto exit1;
	}

	Audio.m_SemaphoreLock = sceKernelCreateSema("audio_lock_sema",  0, 1, 1, NULL);
	if(Audio.m_SemaphoreLock	< 0 )
	{
		sprintf(m_LastError, "sceKernelCreateSema() failed: 0x%08X", (int)Audio.m_SemaphoreLock);
		goto exit2;
	}

	Audio.m_iNumBuffers			= 4;
	Audio.m_iFullBuffers		= 0;
	Audio.m_iPlayBuffer			= 1;
	Audio.m_iDecodeBuffer		= 0;
	Audio.m_iAbort				= 0;
	Audio.m_LastError			= m_LastError;

	for(i = 0; i < Audio.m_iNumBuffers; i++)
	{
		Audio.m_pAudioBuffer[i] = NULL;
		Audio.m_iBufferTimeStamp[i] = 0;
	}

	for(i = 0; i < Audio.m_iNumBuffers; i++)
	{
		Audio.m_pAudioBuffer[i] = memalign(64, m_MpegAtracOutSize);
		if(Audio.m_pAudioBuffer[i] < 0) fail++;
	}

	if(fail > 0)
	{
		for(i = 0; i < Audio.m_iNumBuffers; i++)
		{
			if(Audio.m_pAudioBuffer[i] != NULL)
				free(Audio.m_pAudioBuffer[i]);
		}

		sprintf(m_LastError, "malloc() failed!");
		goto exit3;
	}

	return 0;

exit3:
	sceKernelDeleteSema(Audio.m_SemaphoreLock);
exit2:
	sceKernelDeleteSema(Audio.m_SemaphoreStart);
exit1:
	sceKernelDeleteThread(Audio.m_ThreadID);
exit0:
	sceAudioChRelease(Audio.m_AudioChannel);

	return -1;
}
Exemplo n.º 15
0
int  MP3_Load (const char *name){
	if ( !mp3_codec_flag )
		return -1;
	mp3_file_handle = sceIoOpen(name, PSP_O_RDONLY, 0777);
	if ( !mp3_file_handle ) 
		return -1;
	if ( sceIoRead( mp3_file_handle, mp3_header_buffer, 4 ) != 4 ) {
		sceIoClose(mp3_file_handle);
		return -2;
	}
	while(1) {
		if ( mp3_header_buffer[0] == 'I' && mp3_header_buffer[1] == 'D' && mp3_header_buffer[2] == '3' ) {
			unsigned char id3v2_buffer[6];
			if ( sceIoRead( mp3_file_handle, id3v2_buffer, 6 ) != 6 ) {
				sceIoClose(mp3_file_handle);
				return -2;
			}
			int id3v2_size = (int)(id3v2_buffer[2] & 0x7F) << 21 
				| (int)(id3v2_buffer[3] & 0x7F) << 14
				| (int)(id3v2_buffer[4] & 0x7F) << 7
				| (int)(id3v2_buffer[5] & 0x7F);
			sceIoLseek32(mp3_file_handle, id3v2_size, PSP_SEEK_CUR);
			if ( sceIoRead( mp3_file_handle, mp3_header_buffer, 4 ) != 4 ) {
				sceIoClose(mp3_file_handle);
				return -2;
			}
			continue;
		}
		unsigned int mp3_header = mp3_header_buffer[0];
		mp3_header = (mp3_header<<8) | mp3_header_buffer[1];
		mp3_header = (mp3_header<<8) | mp3_header_buffer[2];
		mp3_header = (mp3_header<<8) | mp3_header_buffer[3];
	
		if ( (mp3_header & 0xFFFE0000) != 0xFFFA0000) {
			sceIoLseek32(mp3_file_handle, -3, PSP_SEEK_CUR);
			if ( sceIoRead( mp3_file_handle, mp3_header_buffer, 4 ) != 4 ) {
				sceIoClose(mp3_file_handle);
				return -2;
			}
			continue;
		}
		mp3_samplerate = (mp3_header & 0x0C00) >> 10;
		if ( mp3_samplerate != 0 && mp3_samplerate != 1 ) {
			sceIoClose(mp3_file_handle);
			return -3;
		}
		mp3_samplerate = (mp3_samplerate == 0)?44100:48000;
	
		mp3_channels = (mp3_header & 0x00C0) >> 6;
		mp3_channels = (mp3_channels == 3)?1:2;
	
		mp3_data_start = sceIoLseek32(mp3_file_handle, -4, PSP_SEEK_CUR);
		
		break;
	}
	
	mp3_audio_channel = sceAudioChReserve(PSP_AUDIO_NEXT_CHANNEL, MP3_SAMPLE_COUNT, PSP_AUDIO_FORMAT_STEREO);
	if ( mp3_audio_channel < 0 ) {
		sceIoClose(mp3_file_handle);
		return -4;
	}
	
	mp3_audio_thread = sceKernelCreateThread("mp3_audio_thread",MP3OutputThread,0x12,0x10000,0,NULL);
	
	if ( mp3_audio_thread < 0 ) {
		sceAudioChRelease(mp3_audio_channel);
		sceIoClose(mp3_file_handle);
		return -5;
	}
	
	return 1;
}
Exemplo n.º 16
0
char *pmp_play_open(struct pmp_play_struct *p, struct movie_file_struct *movie, int usePos, int pspType, int tvAspectRatio, int tvWidth, int tvHeight, int videoMode)
	{
	pmp_play_safe_constructor(p);
	p->subtitle = 0;
	p->subtitle_count = 0;

	
	char *result = pmp_decode_open(&p->decoder, movie->movie_file, pspType, tvAspectRatio, tvWidth, tvHeight, videoMode);
	if (result != 0)
		{
		pmp_play_close(p, 0, pspType);
		return(result);
		}

	if (subtitle_parse_search( movie, p->decoder.reader.file.header.video.rate, p->decoder.reader.file.header.video.scale, &p->subtitle_count)==0) p->subtitle = 1;
	
	if ( cooleyesAudioSetFrequency(sceKernelDevkitVersion(), p->decoder.reader.file.header.audio.rate) != 0)
		{
		pmp_play_close(p, 0, pspType);
		return("pmp_play_open: sceAudioSetFrequency failed");
		}
	p->audio_reserved = sceAudioChReserve(0, p->decoder.reader.file.header.audio.scale, PSP_AUDIO_FORMAT_STEREO);
	if (p->audio_reserved < 0)
		{
		pmp_play_close(p, 0, pspType);
		return("pmp_play_open: sceAudioChReserve failed");
		}


	p->semaphore_can_get = sceKernelCreateSema("can_get", 0, 0, p->decoder.number_of_frame_buffers, 0);
	if (p->semaphore_can_get < 0)
		{
		pmp_play_close(p, 0, pspType);
		return("pmp_play_open: sceKernelCreateSema failed on semaphore_can_get");
		}


	p->semaphore_can_put = sceKernelCreateSema("can_put", 0, p->decoder.number_of_frame_buffers, p->decoder.number_of_frame_buffers, 0);
	if (p->semaphore_can_put < 0)
		{
		pmp_play_close(p, 0, pspType);
		return("pmp_play_open: sceKernelCreateSema failed on semaphore_can_put");
		}


	p->semaphore_can_show = sceKernelCreateSema("can_show", 0, 0, 1, 0);
	if (p->semaphore_can_show < 0)
		{
		pmp_play_close(p, 0, pspType);
		return("pmp_play_open: sceKernelCreateSema failed on semaphore_can_show");
		}


	p->semaphore_show_done = sceKernelCreateSema("show_done", 0, 0, 1, 0);
	if (p->semaphore_show_done < 0)
		{
		pmp_play_close(p, 0, pspType);
		return("pmp_play_open: sceKernelCreateSema failed on semaphore_show_done");
		}




	p->output_thread = sceKernelCreateThread("output", pmp_output_thread, 0x8, 0x10000, 0, 0);
	if (p->output_thread < 0)
		{
		pmp_play_close(p, 0, pspType);
		return("pmp_play_open: sceKernelCreateThread failed on output_thread");
		}


	p->show_thread = sceKernelCreateThread("show", pmp_show_thread, 0x8, 0x10000, 0, 0);
	if (p->show_thread < 0)
		{
		pmp_play_close(p, 0, pspType);
		return("pmp_play_open: sceKernelCreateThread failed on show_thread");
		}




	p->return_request = 0;
	p->return_result  = 0;


	p->paused = 0;
	p->seek   = 0;


	p->audio_stream     = 0;
	//add by cooleyes 2007/02/01
	p->audio_channel    = 0;
	//add end
	p->volume_boost     = 3;
	p->aspect_ratio     = 0;
	p->zoom             = 100;
	p->luminosity_boost = 0;
	p->show_interface   = 0;
	p->loop             = 0;
	p->resume_pos		= 0;
	p->last_keyframe_pos= 0;
	p->subtitle_format  = (((gufont_haveflags&GU_FONT_HAS_UNICODE_CHARMAP))?1:0);
	p->subtitle_fontcolor = 0;
	p->subtitle_bordercolor = 0;
	
	memcpy(p->hash, movie->movie_hash, 16);
	
	if (usePos) pmp_stat_load( p );

	return(0);
	}
Exemplo n.º 17
0
int main(int argc, char *argv[]) {
	char *at3_data;
	int at3_size;

	char *decode_data;
	int decode_size;
	int n;

	FILE *file;

	int atracID;
	int maxSamples = 0;
	int result;
	int channel;
	
	u32 puiPosition;
	u32 puiDataByte;
	
	if ((file = fopen("sample.at3", "rb")) != NULL) {
		fseek(file, 0, SEEK_END);
		at3_size = ftell(file);
		
		fseek(file, 0, SEEK_SET);
		
		at3_data = malloc(at3_size);
		decode_data = malloc(decode_size = 512 * 1024);
		memset(at3_data, 0, at3_size);
		memset(decode_data, 0, decode_size);
		
		fread(at3_data, at3_size, 1, file);

		fclose(file);
	}

	pspSdkLoadStartModule("flash0:/kd/audiocodec.prx", PSP_MEMORY_PARTITION_KERNEL);
	pspSdkLoadStartModule("flash0:/kd/libatrac3plus.prx", PSP_MEMORY_PARTITION_KERNEL);
	
	printf("at3: %08X, %08X\n", (unsigned int)at3_data, at3_size);
	printf("Header: %s\n", (char *)at3_data);
		
	atracID = sceAtracSetDataAndGetID(at3_data, at3_size);
	
	result = sceAtracSetLoopNum(atracID, 2);
	printf("sceAtracSetLoopNum: %08X\n", result);

	printf("sceAtracSetDataAndGetID: %08X\n", atracID);
	
	result = sceAtracGetMaxSample(atracID, &maxSamples);
	printf("sceAtracGetMaxSample: %08X, %d\n", result, maxSamples);
	
	channel = sceAudioChReserve(0, maxSamples, PSP_AUDIO_FORMAT_STEREO);
	
	result = sceAtracGetSecondBufferInfo(atracID, &puiPosition, &puiDataByte);
	printf("sceAtracGetSecondBufferInfo: %08X, %u, %u\n", result, (unsigned int)puiPosition, (unsigned int)puiDataByte);
	
	int end = 0;
	int steps = 0;
	while (!end) {
		//int remainFrame = -1;
		int remainFrame = 0;
		//int decodeBufferPosition = 0;
		int samples = 0;
		int nextSample = 0;
		u32 nextPosition = 0;
		
		if (steps < 4) {
			result = sceAtracGetNextSample(atracID, &nextSample);
			printf("sceAtracGetNextSample(%d): %d\n", result, nextSample);
			result = sceAtracGetNextDecodePosition(atracID, &nextPosition);
			printf("sceAtracGetNextDecodePosition(%d): %u\n", result, (unsigned int)nextPosition);
		}

		result = sceAtracDecodeData(atracID, (u16 *)decode_data, &samples, &end, &remainFrame);
		
		if (steps < 4) {
			
		}
		
		sceAudioSetChannelDataLen(channel, samples);
		sceAudioOutputBlocking(channel, 0x8000, decode_data);
		
		result = sceAtracGetRemainFrame(atracID, &remainFrame);

		if (steps < 4) {
			printf("sceAtracDecodeData: %08X, at3_size: %d, decode_size: %d, samples: %d, end: %d, remainFrame: %d\n\n", result, at3_size, decode_size, samples, end, remainFrame);
			if (steps == 1) {
				for (n = 0; n < 32; n++) printf("%04X ", (u16)decode_data[n]);
			}
			printf("sceAtracGetRemainFrame: %08X\n", result);
		}

		steps++;
	}
	
	sceAudioChRelease(channel);
	result = sceAtracReleaseAtracID(atracID);
	printf("sceAtracGetRemainFrame: %08X\n", result);

	return 0;
}
Exemplo n.º 18
0
int audio_Init(void)
{
	int i, ret;
	int failed = 0;
	char str[32];
	audio_terminate=0;
	audio_ready=0;
	for(i=0; i<CHANNELS; i++)
	{
		audio_handles[i] = -1;
		audio_thread_handle[i] = -1;
		audio_ChannelCallback[i] = 0;
		audio_volumes[i][0] = MAXVOLUME;
		audio_volumes[i][1] = MAXVOLUME;
	}
	for(i=0; i<CHANNELS; i++) if((audio_handles[i] = sceAudioChReserve(-1, SAMPLES, 0)) < 0) failed = 1;
	if(failed)
	{
		for(i=0; i<CHANNELS; i++)
		{
			if(audio_handles[i] != -1) sceAudioChRelease(audio_handles[i]);
			audio_handles[i] = -1;
		}
		return -1;
	}
	audio_ready = 1;
	strcpy(str,"Sound Thread");
	for(i=0; i<CHANNELS; i++)
	{
		str[6] = '0' + i;
		audio_thread_handle[i] = sceKernelCreateThread(str, audio_ChannelThread, 0x8, 0x10000, PSP_THREAD_ATTR_USER, NULL);
		if(audio_thread_handle[i] < 0)
		{
			audio_thread_handle[i] = -1;
			failed = 1;
			break;
		}
		ret = sceKernelStartThread(audio_thread_handle[i], sizeof(i), &i);
		if(ret != 0)
		{
			failed = 1;
			break;
		}
	}
	if(failed)
	{
		audio_terminate = 1;
		for(i=0; i<CHANNELS; i++)
		{
			if(audio_thread_handle[i] != -1)
			{
				sceKernelWaitThreadEnd(audio_thread_handle[i],NULL);
				sceKernelDeleteThread(audio_thread_handle[i]);
			}
			audio_thread_handle[i] = -1;
		}
		audio_ready = 0;
		return -1;
	}
	audio_SetChannelCallback(0, audio_UpdateCallback);
	return 0;
}
Exemplo n.º 19
0
/* digi_psp_init:
 *  Initializes the PSP digital sound driver.
 */
static int digi_psp_init(int input, int voices)
{
   char digi_psp_desc[512] = EMPTY_STRING;
   char tmp1[256];

   if (input) {
      ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE,
         get_config_text("Input is not supported"));
      return -1;
   }

   hw_channel = sceAudioChReserve(PSP_AUDIO_NEXT_CHANNEL, SAMPLES_PER_BUFFER,
      PSP_AUDIO_FORMAT_STEREO);
   if (hw_channel < 0) {
      ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE,
         get_config_text("Failed reserving hardware sound channel"));
      return -1;
   }

   psp_audio_on = TRUE;

   audio_thread_UID = sceKernelCreateThread("psp_audio_thread",
      (void *)&psp_audio_channel_thread, 0x19, 0x10000, 0, NULL);

   if (audio_thread_UID < 0) {
      ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE,
         get_config_text("Cannot create audio thread"));
      digi_psp_exit(FALSE);
      return -1;
   }

   if (sceKernelStartThread(audio_thread_UID, 0, NULL) != 0) {
      ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE,
         get_config_text("Cannot start audio thread"));
      digi_psp_exit(FALSE);
      return -1;
   }

   /* Allegro sound state variables */
   _sound_bits = 16;
   _sound_stereo = TRUE;
   _sound_freq = 44100;

   digi_psp.voices = voices;
   if (_mixer_init(SAMPLES_PER_BUFFER * 2, _sound_freq, _sound_stereo,
         (_sound_bits == 16), &digi_psp.voices))
   {
      ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE,
         get_config_text("Error initializing mixer"));
      digi_psp_exit(FALSE);
      return -1;
   }

   uszprintf(digi_psp_desc, sizeof(digi_psp_desc),
      get_config_text("%d bits, %d bps, %s"), _sound_bits,
      _sound_freq, uconvert_ascii(_sound_stereo ? "stereo" : "mono", tmp1));

   digi_psp.desc = digi_psp_desc;

   return 0;
}
Exemplo n.º 20
0
void OSPC_Play(char *fname,int release,int vol) {
	  u16 *menu_bg;	  
		u16 *dst,*src;
    int i,j,pollcpt;    
    char str[256];    
    char *emulator[3]={"Unknown","Zsnes","Snes9x"};
    uint8 *scr;
   
    OSPC_Init();

    if (i=OSPC_Load(fname))
    {
    	sprintf(str,"Error at SPC loading, code : %d",i);
    	msgBoxLines(str,60);
    	//gp32_pause();
    	//GpAppExit();
    	return;
    }
     

	OSPC_id=OSPC_GetID666(spc_data);
	
  OSPC_sound_fd = sceAudioChReserve( -1, 1024, 0 );
  OSPC_exit=0;
  OSPC_volume=vol;
  OSPC_thread = sceKernelCreateThread( "OSPC Thread", (SceKernelThreadEntry)OSPC_PlayThread, 0x8, 256*1024, 0, 0 );    
  if (OSPC_thread<0) {
  	msgBoxLines("Cannot create OSPC playback thread",60);
  } else {
  	//init start time
		scePowerSetClockFrequency(266,266,133);
		sceKernelLibcGettimeofday( &OSPC_start_time, 0 );
  	
  	sceKernelStartThread( OSPC_thread, 0, 0 );
  	
  	if (release) return;  		  		  			
  	//init bg
  	menu_bg=(u16*)malloc_64(480*272*2);
		dst=menu_bg;
		show_background(bg_img_mul,(os9x_lowbat?0x600000:0));	
		for (i=0;i<272;i++) {
			src = (u16*)pgGetVramAddr(0,i);						
			memcpy(dst,src,480*2);
			dst+=480;
		}
		//init fx
		fx_init();  		  			
  	for (;;) {
  		//show bg
  		OSPC_show_bg(menu_bg);
  		//show bg fx
  		fx_main(pgGetVramAddr(0,0));
  		
   		//batt infos
  		show_batteryinfo();
  		//music info
  		//draw frame
  		pgDrawFrame(14,14,20+230+5+1,75+1,12|(12<<5)|(12<<10));
  		pgDrawFrame(13,13,20+230+5+2,75+2,30|(30<<5)|(30<<10));
  		pgDrawFrame(12,12,20+230+5+3,75+3,12|(12<<5)|(12<<10));
  		pgFillBoxHalfer(15,15,20+230+5,75);
  		//
  		if (strlen(OSPC_id->gametitle)) sprintf(str,"Game : %s",OSPC_id->gametitle);
  		else sprintf(str,"Game : unknown");
  		mh_print(20,20,(char*)str,30|(30<<5)|(30<<10));
  		
  		if (strlen(OSPC_id->songname)) sprintf(str,"Song : %s",OSPC_id->songname);
  		else sprintf(str,"Song : unknown");  			
  		mh_print(20,30,(char*)str,30|(30<<5)|(30<<10));
  		
  		if (strlen(OSPC_id->dumper)) sprintf(str,"Dumper : %s",OSPC_id->dumper);
  		else sprintf(str,"Dumper : unknown");
  		mh_print(20,40,(char*)str,30|(30<<5)|(30<<10));
  		
  		if (strlen(OSPC_id->comments)) sprintf(str,"Comments : %s",OSPC_id->comments);
  		else sprintf(str,"Comments : unknown");
  		mh_print(20,50,(char*)str,30|(30<<5)|(30<<10));
  		
  		if (strlen(OSPC_id->author)) sprintf(str,"Author : %s",OSPC_id->author);
  		else sprintf(str,"Author : unknown");
  		mh_print(20,60,(char*)str,30|(30<<5)|(30<<10));
			//time infos
			//draw frame
			//draw frame
  		pgDrawFrame(14,94,20+65+5+1,116,8|(8<<5)|(16<<10));
  		pgDrawFrame(13,93,20+65+5+2,117,28|(28<<5)|(31<<10));
  		pgDrawFrame(12,92,20+65+5+3,118,8|(8<<5)|(16<<10));
			pgFillBoxHalfer(15,95,20+65+5,115);
			sceKernelLibcGettimeofday( &OSPC_cur_time, 0 );
			i=(OSPC_cur_time.tv_sec-OSPC_start_time.tv_sec)+(OSPC_cur_time.tv_usec-OSPC_start_time.tv_usec)/1000000;
  		sprintf(str,"%2d%c%.2d / %2d:%.2d",i/60,((i&1)?':':' '),i%60,OSPC_id->playtime/60,OSPC_id->playtime%60);
  		mh_print(20,100,(char*)str,(20)|(31<<5)|(18<<10));
  		  		
  		if (get_pad()) break;
  			
  		pgScreenFlip();
  	}
  	OSPC_exit=1;  	
  	sceKernelWaitThreadEnd( OSPC_thread, NULL );
		sceKernelDeleteThread( OSPC_thread );
		OSPC_thread=-1;
		
		free(menu_bg);
		fx_close();
  }    
  sceAudioChRelease( OSPC_sound_fd );
  OSPC_Stop();            
  OSPC_Close();    
  if (OSPC_id) free(OSPC_id);
}