comparison render_sdl.c @ 445:80a9527c812c

Add config values for audio sample rate and buffer size
author Mike Pavone <pavone@retrodev.com>
date Thu, 18 Jul 2013 09:59:39 -0700
parents cc754a309ead
children 140af5509ce7
comparison
equal deleted inserted replaced
444:cc754a309ead 445:80a9527c812c
133 psg_cond = SDL_CreateCond(); 133 psg_cond = SDL_CreateCond();
134 ym_cond = SDL_CreateCond(); 134 ym_cond = SDL_CreateCond();
135 audio_ready = SDL_CreateCond(); 135 audio_ready = SDL_CreateCond();
136 136
137 SDL_AudioSpec desired, actual; 137 SDL_AudioSpec desired, actual;
138 desired.freq = 48000; 138 char * rate_str = tern_find_ptr(config, "audiorate");
139 int rate = rate_str ? atoi(rate_str) : 0;
140 if (!rate) {
141 rate = 48000;
142 }
143 desired.freq = rate;
139 desired.format = AUDIO_S16SYS; 144 desired.format = AUDIO_S16SYS;
140 desired.channels = 2; 145 desired.channels = 2;
141 desired.samples = 2048;//1024; 146 char * samples_str = tern_find_ptr(config, "audiobuffer");
147 int samples = samples_str ? atoi(samples_str) : 0;
148 if (!samples) {
149 samples = 512;
150 }
151 printf("config says: %d\n", samples);
152 desired.samples = samples*2;
142 desired.callback = audio_callback; 153 desired.callback = audio_callback;
143 desired.userdata = NULL; 154 desired.userdata = NULL;
144 155
145 if (SDL_OpenAudio(&desired, &actual) < 0) { 156 if (SDL_OpenAudio(&desired, &actual) < 0) {
146 fprintf(stderr, "Unable to open SDL audio: %s\n", SDL_GetError()); 157 fprintf(stderr, "Unable to open SDL audio: %s\n", SDL_GetError());