Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MemoryDataSourceImpl#map changes the position of the data ByteBuffer #42

Closed
michschn opened this issue Jan 27, 2015 · 0 comments
Closed

Comments

@michschn
Copy link

When parsing a IsoFile from an MemoryDataSourceImpl, I always get errors like:

java.lang.RuntimeException: java.lang.IllegalArgumentException: Bad position (limit 41958): 1769172853
at java.nio.Buffer.positionImpl(Buffer.java:364)
at java.nio.Buffer.position(Buffer.java:358)
at com.googlecode.mp4parser.MemoryDataSourceImpl.positio...

This seems to be caused by map(...) implementation changing the data's position.

Restoring the position fixes the issue:
public ByteBuffer map(long startPosition, long size) throws IOException {
int oldPosition = data.position();
data.position(l2i(startPosition));
ByteBuffer result = data.slice();
result.limit(l2i(size));
data.position(oldPosition);
return result;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant