-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathComponentVersionsController.mm
110 lines (89 loc) · 3.12 KB
/
ComponentVersionsController.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
* Copyright (C) 2005 - 2020 Stephen F. Booth <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#import "ComponentVersionsController.h"
#include <lame/lame.h>
#include <FLAC/format.h>
#include <speex/speex.h>
#include <sndfile/sndfile.h>
#include <mac/All.h>
#include <wavpack/wavpack.h>
#include <wchar.h>
@implementation NSString (WideCharSupport)
+ (NSString *) stringWithWideString:(const wchar_t *)ws
{
size_t buflen = 8 * wcslen(ws) + 1;
char *temp = (char *)malloc(buflen);
wcstombs(temp, ws, buflen);
NSString* retVal = [self stringWithUTF8String:temp];
free(temp);
return retVal;
}
@end
static ComponentVersionsController *sharedController = nil;
@implementation ComponentVersionsController
+ (ComponentVersionsController *) sharedController
{
@synchronized(self) {
if(nil == sharedController)
[[self alloc] init];
}
return sharedController;
}
+ (id) allocWithZone:(NSZone *)zone
{
@synchronized(self) {
if(nil == sharedController) {
sharedController = [super allocWithZone:zone];
return sharedController;
}
}
return nil;
}
- (id)init
{
if((self = [super initWithWindowNibName:@"ComponentVersions"])) {
const char *speexVersion;
char buffer [128];
speex_lib_ctl(SPEEX_LIB_GET_VERSION_STRING, &speexVersion);
sf_command(NULL, SFC_GET_LIB_VERSION, buffer, sizeof(buffer));
_flacVersion = [NSString stringWithFormat:@"FLAC %s", FLAC__VERSION_STRING];
_lameVersion = [NSString stringWithFormat:@"LAME %s", get_lame_version()];
_macVersion = [NSString stringWithFormat:@"Monkey's Audio %@", [NSString stringWithWideString:MAC_VERSION_STRING]];
if(NULL != speexVersion) {
_speexVersion = [NSString stringWithCString:speexVersion encoding:NSASCIIStringEncoding];
}
else {
_speexVersion = NSLocalizedStringFromTable(@"Unknown", @"General", @"");
}
_libsndfileVersion = [NSString stringWithCString:buffer encoding:NSASCIIStringEncoding];
_wavPackVersion = [NSString stringWithFormat:@"WavPack %s", WavpackGetLibraryVersionString()];
return self;
}
return nil;
}
- (void) windowDidLoad
{
[self setShouldCascadeWindows:NO];
[[self window] center];
}
- (id) copyWithZone:(NSZone *)zone { return self; }
- (id) retain { return self; }
- (NSUInteger) retainCount { return UINT_MAX; /* denotes an object that cannot be released */ }
- (oneway void) release { /* do nothing */ }
- (id) autorelease { return self; }
@end