/* * Write or read access to file using the HDF5 interface. */ static IOR_offset_t HDF5_Xfer(int access, void *fd, IOR_size_t * buffer, IOR_offset_t length, IOR_param_t * param) { static int firstReadCheck = FALSE, startNewDataSet; IOR_offset_t segmentPosition, segmentSize; /* * this toggle is for the read check operation, which passes through * this function twice; note that this function will open a data set * only on the first read check and close only on the second */ if (access == READCHECK) { if (firstReadCheck == TRUE) { firstReadCheck = FALSE; } else { firstReadCheck = TRUE; } } /* determine by offset if need to start new data set */ if (param->filePerProc == TRUE) { segmentPosition = (IOR_offset_t) 0; segmentSize = param->blockSize; } else { segmentPosition = (IOR_offset_t) ((rank + rankOffset) % param->numTasks) * param->blockSize; segmentSize = (IOR_offset_t) (param->numTasks) * param->blockSize; } if ((IOR_offset_t) ((param->offset - segmentPosition) % segmentSize) == 0) { /* * ordinarily start a new data set, unless this is the * second pass through during a read check */ startNewDataSet = TRUE; if (access == READCHECK && firstReadCheck != TRUE) { startNewDataSet = FALSE; } } /* create new data set */ if (startNewDataSet == TRUE) { /* if just opened this file, no data set to close yet */ if (newlyOpenedFile != TRUE) { HDF5_CHECK(H5Dclose(dataSet), "cannot close data set"); HDF5_CHECK(H5Sclose(fileDataSpace), "cannot close file data space"); } SetupDataSet(fd, param); } SeekOffset(fd, param->offset, param); /* this is necessary to reset variables for reaccessing file */ startNewDataSet = FALSE; newlyOpenedFile = FALSE; /* access the file */ if (access == WRITE) { /* WRITE */ HDF5_CHECK(H5Dwrite(dataSet, H5T_NATIVE_LLONG, memDataSpace, fileDataSpace, xferPropList, buffer), "cannot write to data set"); } else { /* READ or CHECK */ HDF5_CHECK(H5Dread(dataSet, H5T_NATIVE_LLONG, memDataSpace, fileDataSpace, xferPropList, buffer), "cannot read from data set"); } return (length); }
void AudioPlayer::SeekSecond(float second) { SeekOffset(second / GetBufferLengthInSeconds()); }