static SDL_AudioDevice *DCAUD_CreateDevice(int devindex) { SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); if ( this ) { memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { free(this); } return(0); } memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = DCAUD_OpenAudio; this->WaitAudio = DCAUD_WaitAudio; this->PlayAudio = DCAUD_PlayAudio; this->GetAudioBuf = DCAUD_GetAudioBuf; this->CloseAudio = DCAUD_CloseAudio; this->free = DCAUD_DeleteDevice; spu_init(); return this; }
sint32 EMU_CALL psx_init(void) { sint32 r; psx_endian_check(); psx_size_check(); // BIOS must be loaded first if ( !bios_get_image_native() || !bios_get_imagesize() ) return 0; // // BIOS must be a power of 2, or all hell breaks loose // { uint32 s = bios_get_imagesize(); if(s & (s - 1)) psx_hang("imagesize error"); } // // Environment inits // ps1preboot = getenvhex("ps1preboot"); ps2preboot = getenvhex("ps2preboot"); r = iop_init(); if(r) return r; r = ioptimer_init(); if(r) return r; r = r3000_init(); if(r) return r; r = spu_init(); if(r) return r; r = spucore_init(); if(r) return r; r = vfs_init(); if(r) return r; library_was_initialized = 1; return 0; }
int hardware_periph_init() { /* Init sound */ spu_init(); spu_dma_init(); /* Init CD-ROM.. NOTE: NO GD-ROM SUPPORT. ONLY CDs/CDRs. */ cdrom_init(); /* Setup maple bus */ maple_init(); /* Init video */ vid_init(DEFAULT_VID_MODE, DEFAULT_PIXEL_MODE); /* Setup network (this won't do anything unless we enable netcore) */ bba_init(); la_init(); initted = 2; return 0; }
static int init2 (void) { RSACPDS_Func func; func.reg_read = spu_read; func.reg_write = spu_write; func.set_event = spu_set_event; func.wait_for_event = spu_wait_event; func.enter_critical_section = spu_enter_critical_section; func.leave_critical_section = spu_leave_critical_section; if (spu_init (irq_callback, NULL) < 0) { ERR ("spu_init error"); return -1; } if (RSACPDS_Init ( 0/*use_dsp*/, &func, RSACPDS_ADDRESS_MODE_32BIT ) < RSACPDS_RTN_GOOD) { ERR ("RSACPDS_Init error"); spu_deinit (); return -1; } pthread_mutex_init (&transfer_lock, NULL); pthread_mutex_init (&transfer_done, NULL); transfer_flag = 0; uint32_t dsp0_addr, dsp0_size; void *dsp0_io; spu_get_workarea (&dsp0_addr, &dsp0_size, &dsp0_io); dsp0_size = (32 << 10); paac = NULL; aacbuf = (unsigned char *)dsp0_io; aacaddr = (unsigned char *)dsp0_addr; pcmbuf = (short *)dsp0_io; pcmbuf += dsp0_size / 4; pcmaddr = (short *)(dsp0_addr + dsp0_size / 2); buflist_init (aacbuf, (uint32_t)aacaddr, &inbuflist, &inbuf_free, &inbuf_used, AACSIZE, dsp0_size / 2); buflist_init (pcmbuf, (uint32_t)pcmaddr, &outbuflist, &outbuf_free, &outbuf_used, PCMSIZE, dsp0_size / 2); inbuf_current = NULL; outbuf_current = NULL; inbuf_copying = NULL; outbuf_copying = NULL; datalist_init (&indata); datalist_init (&outdata); datalist_init (&delaydata); datalist_init (&outlendata); datalist_init (&outfmtdata); format_type = SPU_AAC_DECODE_SETFMT_TYPE_ADTS; pthread_mutex_lock (&transfer_done); return 0; }
static int DCAUD_OpenDevice(_THIS, SDL_AudioSpec * spec) { SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format); int valid_datatype = 0; /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc((sizeof *this->hidden)); if (this->hidden == NULL) { SDL_OutOfMemory(); return 0; } SDL_memset(this->hidden, 0, (sizeof *this->hidden)); spu_init(); while ((!valid_datatype) && (test_format)) { spec->format = test_format; switch (test_format) { /* only formats Dreamcast accepts... */ case AUDIO_S8: case AUDIO_S16LSB: valid_datatype = 1; break; default: test_format = SDL_NextAudioFormat(); break; } } if (!valid_datatype) { /* shouldn't happen, but just in case... */ DCAUD_CloseDevice(this); SDL_SetError("Unsupported audio format"); return 0; } if (spec->channels > 2) spec->channels = 2; /* no more than stereo on the Dreamcast. */ /* Update the fragment size as size in bytes */ SDL_CalculateAudioSpec(spec); /* Allocate mixing buffer */ this->hidden->mixlen = spec->size; this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen); if (this->hidden->mixbuf == NULL) { DCAUD_CloseDevice(this); SDL_OutOfMemory(); return 0; } SDL_memset(this->hidden->mixbuf, spec->silence, spec->size); this->hidden->leftpos = 0x11000; this->hidden->rightpos = 0x11000 + spec->size; this->hidden->playing = 0; this->hidden->nextbuf = 0; /* We're ready to rock and roll. :-) */ return 1; }