Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -327,15 +327,17 @@ - (void) stop
if ([scheme caseInsensitiveCompare:@"jar"] == NSOrderedSame ||
[scheme caseInsensitiveCompare:@"jrt"] == NSOrderedSame) {
CJavaInputStreamCallbacks *callbacks = new (nothrow) CJavaInputStreamCallbacks();
if (callbacks == NULL) {
jobject jConnectionHolder = CLocator::CreateConnectionHolder(env, jLocator);
if (callbacks == NULL || jConnectionHolder == NULL) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space after callbacks == NULL.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

if (callbacks) delete callbacks;
[mediaURL release];
LOGGER_WARNMSG("OSXMediaPlayer: Unable to create CJavaInputStreamCallbacks\n");
ThrowJavaException(env, "com/sun/media/jfxmedia/MediaException",
"OSXMediaPlayer: Unable to create CJavaInputStreamCallbacks");
return;
}

if (!callbacks->Init(env, jLocator)) {
if (!callbacks->Init(env, jConnectionHolder)) {
[mediaURL release];
delete callbacks;
LOGGER_WARNMSG("OSXMediaPlayer: callbacks->Init() failed\n");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -780,10 +780,6 @@ - (BOOL)resourceLoader:(AVAssetResourceLoader *)resourceLoader
}

if (dataRequest != nil) {
long position = locatorStream->GetCallbacks()->Seek(dataRequest.requestedOffset);
if (position != dataRequest.requestedOffset) {
return NO;
}

// If requestsAllDataToEndOfResource is YES, than requestedLength is
// invalid and we need to provide all data to the end of file.
Expand All @@ -803,8 +799,23 @@ - (BOOL)resourceLoader:(AVAssetResourceLoader *)resourceLoader
}

NSMutableData* readData = nil;
bool isRandomAccess = locatorStream->GetCallbacks()->IsRandomAccess();
int64_t position = -1;
if (isRandomAccess) {
position = dataRequest.requestedOffset;
} else {
position = locatorStream->GetCallbacks()->Seek(dataRequest.requestedOffset);
if (position != dataRequest.requestedOffset) {
return NO;
}
}
while (requestedLength > 0) {
unsigned int blockSize = locatorStream->GetCallbacks()->ReadNextBlock();
unsigned int blockSize = -1;
if (isRandomAccess) {
blockSize = locatorStream->GetCallbacks()->ReadBlock(position, requestedLength);
} else {
blockSize = locatorStream->GetCallbacks()->ReadNextBlock();
}
if (blockSize <= 0) {
break;
}
Expand All @@ -818,6 +829,7 @@ - (BOOL)resourceLoader:(AVAssetResourceLoader *)resourceLoader
[loadingRequest.dataRequest respondWithData:readData];

requestedLength -= readSize;
position += readSize;
}

[loadingRequest finishLoading];
Expand Down