Permalink
Browse files

Minor changes that seem to eliminate stuttering of preview sounds on …

…OS X Lion. Not a perfect fix, but quick and dirty and seems to get the job done.
  • Loading branch information...
1 parent 3898d05 commit b37f0ba7fdd78650c10713c66bac688b62635f0a Eric Johnson committed Aug 20, 2011
Showing with 11 additions and 1 deletion.
  1. +11 −1 Playback.m
View
@@ -54,7 +54,7 @@ -(id)init;
des.channels = 1;
des.callback = (void (*)(void *, Uint8 *, int))SDLAudioCallback;
des.userdata = self;
- des.samples = 2048;
+ des.samples = 2048*16;
if(SDL_OpenAudio(&des, NULL)) {
NSLog(@"Failed opening audio device");
[self release]; return nil;
@@ -343,9 +343,19 @@ -(void)audioCallback:(Uint8 *)stream :(int)len;
}
else memset(stream, 0, len);
}
+
+static NSAutoreleasePool * pool = nil;
+static int poolCount = 0;
+
static void SDLAudioCallback(Playback *playback, Uint8 *stream, int len)
{
+ if (poolCount == 0) {
+ [pool release];
+ poolCount = 100000;
+ pool = [[NSAutoreleasePool alloc] init];
+ }
[playback audioCallback:stream:len];
+ poolCount--;
}

0 comments on commit b37f0ba

Please sign in to comment.