Fixed audio being silent on older iOS devices
Tested on an iPod running iOS 6.1
parent
12efabcbf0
commit
407e1693ae
|
@ -674,11 +674,19 @@ prepare_audioqueue(_THIS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure we can feed the device at least 50 milliseconds at a time. */
|
/* Make sure we can feed the device a minimum amount of time */
|
||||||
|
double MINIMUM_AUDIO_BUFFER_TIME_MS;
|
||||||
|
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1) {
|
||||||
|
/* Older hardware, use 40 ms as a minimum time */
|
||||||
|
MINIMUM_AUDIO_BUFFER_TIME_MS = 40.0;
|
||||||
|
} else {
|
||||||
|
/* Newer hardware, use 15 ms as a minimum time */
|
||||||
|
MINIMUM_AUDIO_BUFFER_TIME_MS = 15.0;
|
||||||
|
}
|
||||||
const double msecs = (this->spec.samples / ((double) this->spec.freq)) * 1000.0;
|
const double msecs = (this->spec.samples / ((double) this->spec.freq)) * 1000.0;
|
||||||
int numAudioBuffers = 2;
|
int numAudioBuffers = 2;
|
||||||
if (msecs < 10.0) { /* use more buffers if we have a VERY small sample set. */
|
if (msecs < MINIMUM_AUDIO_BUFFER_TIME_MS) { /* use more buffers if we have a VERY small sample set. */
|
||||||
numAudioBuffers = (int) (SDL_ceil(10.0 / msecs) * 2);
|
numAudioBuffers = ((int)SDL_ceil(MINIMUM_AUDIO_BUFFER_TIME_MS / msecs) * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->hidden->audioBuffer = SDL_calloc(1, sizeof (AudioQueueBufferRef) * numAudioBuffers);
|
this->hidden->audioBuffer = SDL_calloc(1, sizeof (AudioQueueBufferRef) * numAudioBuffers);
|
||||||
|
|
Loading…
Reference in New Issue