mirror of https://github.com/encounter/SDL.git
coreaudio: we don't need to track number of allocated audio buffers anymore.
CoreAudio takes care of iterating through the buffers and freeing them now, so we don't have to manage this ourselves.
This commit is contained in:
parent
fc4402e5ff
commit
6844d92c23
|
@ -47,7 +47,6 @@ struct SDL_PrivateAudioData
|
||||||
{
|
{
|
||||||
SDL_Thread *thread;
|
SDL_Thread *thread;
|
||||||
AudioQueueRef audioQueue;
|
AudioQueueRef audioQueue;
|
||||||
int numAudioBuffers;
|
|
||||||
AudioQueueBufferRef *audioBuffer;
|
AudioQueueBufferRef *audioBuffer;
|
||||||
void *buffer;
|
void *buffer;
|
||||||
UInt32 bufferOffset;
|
UInt32 bufferOffset;
|
||||||
|
|
|
@ -667,23 +667,22 @@ prepare_audioqueue(_THIS)
|
||||||
|
|
||||||
/* Make sure we can feed the device at least 50 milliseconds at a time. */
|
/* Make sure we can feed the device at least 50 milliseconds at a time. */
|
||||||
const double msecs = (this->spec.samples / ((double) this->spec.freq)) * 1000.0;
|
const double msecs = (this->spec.samples / ((double) this->spec.freq)) * 1000.0;
|
||||||
if (msecs >= 10.0) {
|
int numAudioBuffers = 2;
|
||||||
this->hidden->numAudioBuffers = 2;
|
if (msecs < 10.0) { /* use more buffers if we have a VERY small sample set. */
|
||||||
} else {
|
numAudioBuffers = (int) (SDL_ceil(10.0 / msecs) * 2);
|
||||||
this->hidden->numAudioBuffers = (int) (SDL_ceil(10.0 / msecs) * 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->hidden->audioBuffer = SDL_calloc(1, sizeof (AudioQueueBufferRef) * this->hidden->numAudioBuffers);
|
this->hidden->audioBuffer = SDL_calloc(1, sizeof (AudioQueueBufferRef) * numAudioBuffers);
|
||||||
if (this->hidden->audioBuffer == NULL) {
|
if (this->hidden->audioBuffer == NULL) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG_COREAUDIO
|
#if DEBUG_COREAUDIO
|
||||||
printf("COREAUDIO: numAudioBuffers == %d\n", this->hidden->numAudioBuffers);
|
printf("COREAUDIO: numAudioBuffers == %d\n", numAudioBuffers);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (i = 0; i < this->hidden->numAudioBuffers; i++) {
|
for (i = 0; i < numAudioBuffers; i++) {
|
||||||
result = AudioQueueAllocateBuffer(this->hidden->audioQueue, this->spec.size, &this->hidden->audioBuffer[i]);
|
result = AudioQueueAllocateBuffer(this->hidden->audioQueue, this->spec.size, &this->hidden->audioBuffer[i]);
|
||||||
CHECK_RESULT("AudioQueueAllocateBuffer");
|
CHECK_RESULT("AudioQueueAllocateBuffer");
|
||||||
SDL_memset(this->hidden->audioBuffer[i]->mAudioData, this->spec.silence, this->hidden->audioBuffer[i]->mAudioDataBytesCapacity);
|
SDL_memset(this->hidden->audioBuffer[i]->mAudioData, this->spec.silence, this->hidden->audioBuffer[i]->mAudioDataBytesCapacity);
|
||||||
|
|
Loading…
Reference in New Issue