Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[submodule "BGHUDAppKit"]
path = BGHUDAppKit
url = git@github.com:niltsh/BGHUDAppKit.git
url=https://github.com/AnakinMac/BGHUDAppKit.git
[submodule "UniversalDetector"]
path = UniversalDetector
url = git@github.com:niltsh/UniversalDetector.git
[submodule "localization"]
path = localization
url = git@github.com:niltsh/MPlayerX-Localization.git
url=https://github.com/AnakinMac/UniversalDetector.git
2 changes: 1 addition & 1 deletion BGHUDAppKit
38 changes: 25 additions & 13 deletions MPlayerX/ControlUIView.m
Original file line number Diff line number Diff line change
Expand Up @@ -528,18 +528,8 @@ -(void) refreshAutoHideTimer
float ti = [ud doubleForKey:kUDKeyCtrlUIAutoHideTime];

if ((ti != autoHideTimeInterval) && (ti > 0)) {
// 这个Timer没有retain,所以也不需要release
if (autoHideTimer) {
[autoHideTimer invalidate];
autoHideTimer = nil;
}
autoHideTimeInterval = ti;
autoHideTimer = [NSTimer timerWithTimeInterval:(autoHideTimeInterval + 1)/2
target:self
selector:@selector(tryToHide)
userInfo:nil
repeats:YES];
[[NSRunLoop mainRunLoop] addTimer:autoHideTimer forMode:NSDefaultRunLoopMode];
autoHideTimeInterval = ti;

}
}

Expand Down Expand Up @@ -573,7 +563,11 @@ -(void) doHide
[title.animator setAlphaValue:0];
}
}
}
}
if (autoHideTimer) {
[autoHideTimer invalidate];
autoHideTimer = nil;
}
}

-(void) tryToHide
Expand All @@ -588,6 +582,24 @@ -(void) tryToHide
-(void) showUp
{
shouldHide = NO;

if (autoHideTimer) {
[autoHideTimer invalidate];
autoHideTimer = nil;
}

autoHideTimer = [NSTimer timerWithTimeInterval:(autoHideTimeInterval + 1)/2
target:self
selector:@selector(tryToHide)
userInfo:nil
repeats:YES];

if (MPXGetSysVersion() == kMPXSysVersionMavericks) {
[autoHideTimer setTolerance:1.0];
}

[[NSRunLoop mainRunLoop] addTimer:autoHideTimer forMode:NSDefaultRunLoopMode];


[self.animator setAlphaValue:CONTROLALPHA];

Expand Down
2 changes: 2 additions & 0 deletions MPlayerX/DisplayLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
BOOL flagPositionOffsetChanged;
BOOL flagScaleChanged;
BOOL refitBounds;

NSLock *_lock;
}

@property (readwrite, assign) BOOL fillScreen;
Expand Down
104 changes: 56 additions & 48 deletions MPlayerX/DisplayLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ - (id) init

mirror = NO;
flip = NO;
_lock = [[NSLock alloc] init];

}
return self;
}
Expand Down Expand Up @@ -268,33 +270,36 @@ -(void) reshape
*/
-(int) startWithFormat:(DisplayFormat)displayFormat buffer:(char**)data total:(NSUInteger)num
{
@synchronized(self) {
fmt = displayFormat;

if (data && (num > 0)) {
CVReturn error;

bufRefs = malloc(num * sizeof(CVOpenGLBufferRef));

for (bufTotal=0; bufTotal<num; bufTotal++) {
error = CVPixelBufferCreateWithBytes(NULL, fmt.width, fmt.height, fmt.pixelFormat,
data[bufTotal], fmt.width * fmt.bytes,
NULL, NULL, NULL, &bufRefs[bufTotal]);
if (error != kCVReturnSuccess) {
[self stop];
MPLog(@"video buffer failed");
break;
}

// FIXME: here frame size is used to guess the color space of the image
CVBufferSetAttachment(bufRefs[bufTotal],
kCVImageBufferYCbCrMatrixKey,
((fmt.width >= 1280) || (fmt.height > 576))?(kCVImageBufferYCbCrMatrix_ITU_R_709_2):(kCVImageBufferYCbCrMatrix_ITU_R_601_4),
kCVAttachmentMode_ShouldPropagate);

[_lock lock];

fmt = displayFormat;

if (data && (num > 0)) {
CVReturn error;

bufRefs = malloc(num * sizeof(CVOpenGLBufferRef));

for (bufTotal=0; bufTotal<num; bufTotal++) {
error = CVPixelBufferCreateWithBytes(NULL, fmt.width, fmt.height, fmt.pixelFormat,
data[bufTotal], fmt.width * fmt.bytes,
NULL, NULL, NULL, &bufRefs[bufTotal]);
if (error != kCVReturnSuccess) {
[self stop];
MPLog(@"video buffer failed");
break;
}
}
flagAspectRatioChanged = YES;
}

// FIXME: here frame size is used to guess the color space of the image
CVBufferSetAttachment(bufRefs[bufTotal],
kCVImageBufferYCbCrMatrixKey,
((fmt.width >= 1920) || (fmt.height > 864))?(kCVImageBufferYCbCrMatrix_SMPTE_240M_1995):(kCVImageBufferYCbCrMatrix_ITU_R_709_2),
kCVAttachmentMode_ShouldPropagate);
}
}
flagAspectRatioChanged = YES;
[_lock unlock];

[self setOpaque:YES];
return (bufRefs)?0:1;
}
Expand All @@ -307,28 +312,31 @@ -(void) draw:(NSUInteger)frameNum

-(void) stop
{
@synchronized(self) {
frameNow = -1;

if (bufRefs) {
for(;bufTotal>0;bufTotal--) {
SAFERELEASEOPENGLBUFFER(bufRefs[bufTotal-1]);
}
free(bufRefs);
bufRefs = NULL;
}

memset(&fmt, 0, sizeof(fmt));
fmt.aspect = kDisplayAscpectRatioInvalid;
flagAspectRatioChanged = YES;

// 这里不能清除externalAspectRatio
// 因为有可能在一次播放过程中出现多次start,stop
// 用户强制设定了externalAspectRaio的时候,即使多次start,stop也不应该重置externalAspectRatio
// 因此应该在外部重置

[self setNeedsDisplay];
}
[_lock lock];

frameNow = -1;

if (bufRefs) {
for(;bufTotal>0;bufTotal--) {
SAFERELEASEOPENGLBUFFER(bufRefs[bufTotal-1]);
}
free(bufRefs);
bufRefs = NULL;
}

memset(&fmt, 0, sizeof(fmt));
fmt.aspect = kDisplayAscpectRatioInvalid;
flagAspectRatioChanged = YES;

// 这里不能清除externalAspectRatio
// 因为有可能在一次播放过程中出现多次start,stop
// 用户强制设定了externalAspectRaio的时候,即使多次start,stop也不应该重置externalAspectRatio
// 因此应该在外部重置

[self setNeedsDisplay];

[_lock unlock];

[self setOpaque:NO];
}

Expand Down
4 changes: 2 additions & 2 deletions MPlayerX/MPlayerX-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.19</string>
<string>1.0.21</string>
<key>CFBundleSignature</key>
<string>NILT</string>
<key>CFBundleURLTypes</key>
Expand Down Expand Up @@ -531,7 +531,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1686</string>
<string>1800</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.entertainment</string>
<key>LSMinimumSystemVersion</key>
Expand Down
Loading