Index: AppController.h =================================================================== RCS file: /sources/gap/gap/user-apps/AClock/AppController.h,v retrieving revision 1.1 diff -u -r1.1 AppController.h --- AppController.h 2 May 2010 05:16:14 -0000 1.1 +++ AppController.h 6 May 2011 13:23:54 -0000 @@ -45,4 +45,5 @@ - (void) setFrequency: (id)sender; - (void) setSecond: (id)sender; - (void) setNumberType: (id)sender; +- (void) playCuckoo:(int) round; @end Index: AppController.m =================================================================== RCS file: /sources/gap/gap/user-apps/AClock/AppController.m,v retrieving revision 1.1 diff -u -r1.1 AppController.m --- AppController.m 2 May 2010 05:16:14 -0000 1.1 +++ AppController.m 6 May 2011 13:23:55 -0000 @@ -46,8 +46,12 @@ - (void) setRing: (id) sender { useRing = [sender intValue]?YES:NO; - if (useRing) - system([[NSString stringWithFormat:@"playsound %@ &", [[NSBundle mainBundle] pathForResource:@"ring.wav" ofType:nil]] lossyCString]); + if (useRing) { + NSSound *ring = [[NSSound alloc] initWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"ring.wav" ofType:nil] byReference: NO]; + [ring retain]; + [ring play]; + [ring release]; + } [defaults setObject:useRing?@"YES":@"NO" forKey:@"Ring"]; [defaults synchronize]; } @@ -158,8 +162,11 @@ { if ([alarmWindow isVisible] && extracount) { - NSLog([NSString stringWithFormat:@"playsound --volume %0.1f %@ &",volume, [[NSBundle mainBundle] pathForResource:@"ring.wav" ofType:nil]]); - system([[NSString stringWithFormat:@"playsound --volume %0.1f %@ &",volume, [[NSBundle mainBundle] pathForResource:@"ring.wav" ofType:nil]] lossyCString]); + NSSound *ring = [[NSSound alloc] initWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"ring.wav" ofType:nil] byReference: NO]; + [ring setVolume: volume]; + [ring retain]; + [ring play]; + [ring release]; extracount--; volume += volume_append; if (volume > 1.0) volume = 1.0; @@ -291,7 +298,6 @@ { /* initialize the clock so it won't flick */ NSCalendarDate *d = [NSCalendarDate date]; - NSTimeInterval g = [d timeIntervalSinceReferenceDate]; double time; time = [d hourOfDay] * 3600 + [d minuteOfHour] * 60 + [d secondOfMinute]; [_clock setHandsTimeNoAlarm: time]; @@ -314,7 +320,6 @@ NSTimeInterval g = [d timeIntervalSinceReferenceDate]; double time; NSInteger hod = [d hourOfDay]; - NSInteger moh = [d minuteOfHour]; if (useCuckoo && lastHourOfDay != hod) { @@ -339,7 +344,6 @@ [clicon setHandsTime: time]; } -static int cround; static int cstate = -1; NSTimer *ctimer; - (void) cuckoo @@ -362,8 +366,15 @@ { if (cstate == -1) { + int loop = 0; cstate = 20 * round; - system([[NSString stringWithFormat:@"playsound --loop %d %@ &", round - 1, [[NSBundle mainBundle] pathForResource:@"cuckoo.wav" ofType:nil]] lossyCString]); + NSSound *cuckoo = [[NSSound alloc] initWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"cuckoo.wav" ofType:nil] byReference: NO]; + [cuckoo retain]; + while (loop < round) { + [cuckoo play]; + loop++; + } + [cuckoo release]; NSInvocation *inv; inv = [NSInvocation invocationWithMethodSignature: [self methodSignatureForSelector:@selector(cuckoo)]]; Index: Clock.h =================================================================== RCS file: /sources/gap/gap/user-apps/AClock/Clock.h,v retrieving revision 1.1 diff -u -r1.1 Clock.h --- Clock.h 2 May 2010 05:16:14 -0000 1.1 +++ Clock.h 6 May 2011 13:23:55 -0000 @@ -88,6 +88,7 @@ -(double) alarmInterval; -(void) setAlarmInterval: (double)time; -(void) setHandsTimeNoAlarm: (double)time; +- (void) setCuckooState:(int)st; @end Index: Clock.m =================================================================== RCS file: /sources/gap/gap/user-apps/AClock/Clock.m,v retrieving revision 1.1 diff -u -r1.1 Clock.m --- Clock.m 2 May 2010 05:16:14 -0000 1.1 +++ Clock.m 6 May 2011 13:23:55 -0000 @@ -57,14 +57,6 @@ /** Internally used functions/methods **/ -static double wrap_time(double time) -{ - int i; - i=floor(time/1440); - return time-i*1440; -} - - -(void) _frameChanged { NSRect r=[self bounds]; @@ -363,7 +355,6 @@ -(void) drawRect: (NSRect)r { NSGraphicsContext *ctxt=GSCurrentContext(); - id defaults = [NSUserDefaults standardUserDefaults]; /* BOOL smoothSeconds = [defaults boolForKey: @"SmoothSeconds"]; */ @@ -687,7 +678,7 @@ /* draw arc */ if (showsArc) { - double a1,a2,x,y; + double a1,a2; double r1; a1 = 90 - (handsTime - 43200 * floor(handsTime/43200))/43200 * 360; @@ -919,7 +910,7 @@ } } -- (void) setCuckooState:(int)st; +- (void) setCuckooState:(int)st { if (st != cstate) { @@ -1021,8 +1012,6 @@ -(void) setAlarmInterval: (double)time { - int n = handsTime / 43200; - alarmInterval = floor(handsTime / 43200) * 43200 + fmod(time, 43200.); if (alarmInterval < handsTime) alarmInterval += 43200; Index: main.m =================================================================== RCS file: /sources/gap/gap/user-apps/AClock/main.m,v retrieving revision 1.1 diff -u -r1.1 main.m --- main.m 2 May 2010 05:16:15 -0000 1.1 +++ main.m 6 May 2011 13:23:55 -0000 @@ -1,10 +1,6 @@ #include -int main(int argc, char **argv) +int main(int argc, const char **argv) { - CREATE_AUTORELEASE_POOL(pool); - [NSApplication sharedApplication]; - [NSApp run]; - DESTROY(pool); - return 0; + return NSApplicationMain (argc, argv); }