/* Sound Thread*/ static void *gp2x_sound_thread_play(void *none) { #ifndef NOSOUND app_DemuteSound(); #endif return NULL; }
void gp2x_start_sound() { lastlen = 0; sndOutPtr = sndOutBuffer; app_DemuteSound(); #if 0 int frag = 0, bsize, buffers; // if no settings change, we don't need to do anything if (rate == s_oldrate && s_oldbits == bits && s_oldstereo == stereo) return; if (sounddev > 0) close(sounddev); sounddev = open("/dev/dsp", O_WRONLY|O_ASYNC); if (sounddev == -1) printf("open(\"/dev/dsp\") failed with %i\n", errno); ioctl(sounddev, SNDCTL_DSP_SETFMT, &bits); ioctl(sounddev, SNDCTL_DSP_SPEED, &rate); ioctl(sounddev, SNDCTL_DSP_STEREO, &stereo); // calculate buffer size buffers = 16; bsize = rate / 32; if (rate > 22050) { bsize*=4; buffers*=2; } // 44k mode seems to be very demanding while ((bsize>>=1)) frag++; frag |= buffers<<16; // 16 buffers ioctl(sounddev, SNDCTL_DSP_SETFRAGMENT, &frag); usleep(192*1024); printf("gp2x_set_sound: %i/%ibit/%s, %i buffers of %i bytes\n", rate, bits, stereo?"stereo":"mono", frag>>16, 1<<(frag&0xffff)); s_oldrate = rate; s_oldbits = bits; s_oldstereo = stereo; #endif }
void initialize_audio() { audio_exit_thread = 0; audio.output_frequency = 44100; audio.playback_buffer_size = IPHONE_AUDIO_BUFFER_SIZE; app_DemuteSound(); }
int msdos_init_sound(void) { /* Ask the user if no soundcard was chosen */ if (soundcard == -1) { soundcard=1; } if (soundcard == 0) /* silence */ { /* update the Machine structure to show that sound is disabled */ Machine->sample_rate = 0; return 0; } /* use stereo output if supported */ gp2x_sound_stereo=0; if (usestereo) { if (Machine->drv->sound_attributes & SOUND_SUPPORTS_STEREO) gp2x_sound_stereo=1; } stream_cache_data = 0; stream_cache_len = 0; stream_cache_stereo = 0; gp2x_sound_rate=44100;//options.samplerate;//44100; //options.samplerate; /* update the Machine structure to reflect the actual sample rate */ Machine->sample_rate = gp2x_sound_rate; logerror("set stereo: %d\n",gp2x_sound_stereo); logerror("set sample rate: %d\n",Machine->sample_rate); osd_set_mastervolume(attenuation); /* set the startup volume */ app_MuteSound(); app_DemuteSound(); return 0; }