static void *stream_audio(ALLEGRO_THREAD *thread, void *data) { ALLEGRO_EVENT_QUEUE *queue; VideoState *is = data; ALLEGRO_AUDIO_STREAM *audio_stream = is->video->audio; queue = al_create_event_queue(); if (is->video->mixer) al_attach_audio_stream_to_mixer(audio_stream, is->video->mixer); else if (is->video->voice) al_attach_audio_stream_to_voice(audio_stream, is->video->voice); else al_attach_audio_stream_to_mixer(audio_stream, al_get_default_mixer()); al_register_event_source(queue, al_get_audio_stream_event_source(audio_stream)); while (1) { ALLEGRO_EVENT event; al_wait_for_event(queue, &event); if (event.type == ALLEGRO_EVENT_AUDIO_STREAM_FRAGMENT) { void *buf = al_get_audio_stream_fragment(audio_stream); if (!buf) continue; audio_callback(is, buf, AUDIO_BUFFER_SIZE); al_set_audio_stream_fragment(audio_stream, buf); } } return thread; }
static void sdl_audio_player(void *udata, unsigned char *stream, int len) { if(16 == sound_bps) len /= 2; if(audio_callback) audio_callback(stream,len); }
void retro_run(void) { update_input(); render_checkered(); if (!use_audio_cb) audio_callback(); bool updated = false; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) check_variables(); }
static void AQBufferCallback(void *userdata, AudioQueueRef outQ, AudioQueueBufferRef outQB) { unsigned char *coreAudioBuffer; coreAudioBuffer = (unsigned char*) outQB->mAudioData; outQB->mAudioDataByteSize = IPHONE_AUDIO_BUFFER_SIZE; AudioQueueSetParameter(outQ, kAudioQueueParam_Volume, __audioVolume); audio_callback(coreAudioBuffer, IPHONE_AUDIO_BUFFER_SIZE); AudioQueueEnqueueBuffer(outQ, outQB, 0, NULL); }
static void sdl_audio_callback(void *userdata, Uint8 *stream, int len) { audio_callback((Sint16 *)stream, len); }