Skip to content

Commit

Permalink
Minor changes that seem to eliminate stuttering of preview sounds on …
Browse files Browse the repository at this point in the history
…OS X Lion. Not a perfect fix, but quick and dirty and seems to get the job done.
  • Loading branch information
Eric Johnson committed Aug 20, 2011
1 parent 3898d05 commit b37f0ba
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Playback.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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--;
}


Expand Down

0 comments on commit b37f0ba

Please sign in to comment.