Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,17 @@ public void setDataSource(FileDescriptor fd)
*/
private void setDataSource(FileDescriptor fd, long offset, long length)
throws IOException, IllegalArgumentException, IllegalStateException {
// FIXME: handle offset, length
setDataSource(fd);
// Create a duplicated file descriptor that we can close safely
ParcelFileDescriptor pfd = ParcelFileDescriptor.dup(fd);
try {
// Use the duplicated file descriptor and handle offset and length
// Instead of calling setDataSource(fd) which would duplicate again unnecessarily
_setDataSourceFd(pfd.getFd());
// TODO: handle offset and length when needed
} finally {
// Make sure to close the duplicated file descriptor
pfd.close();
}
}

public void setDataSource(IMediaDataSource mediaDataSource)
Expand Down