- Timestamp:
- Mar 22, 2017 2:23:28 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Storage/CUE.cpp
r66144 r66197 27 27 #include <VBox/scsiinline.h> 28 28 #include <iprt/assert.h> 29 #include <iprt/asm.h> 29 30 #include <iprt/alloc.h> 30 31 #include <iprt/cdefs.h> … … 72 73 /** BINARY */ 73 74 CUEKEYWORD_BINARY, 75 /** MOTOROLA */ 76 CUEKEYWORD_MOTOROLA, 74 77 /** WAVE */ 75 78 CUEKEYWORD_WAVE, … … 210 213 /** Pointer to our internal region list. */ 211 214 PVDREGIONLIST pRegionList; 215 /** Flag whether the backing file is little (BINARY) or big (MOTOROLA) endian. */ 216 bool fLittleEndian; 212 217 } CUEIMAGE, *PCUEIMAGE; 213 218 … … 1029 1034 { 1030 1035 if (cueTokenizerSkipIfIsKeywordEqual(pTokenizer, CUEKEYWORD_BINARY)) 1036 { 1037 pThis->fLittleEndian = true; 1031 1038 rc = cueParseTrackList(pThis, pTokenizer); 1039 } 1040 else if (cueTokenizerSkipIfIsKeywordEqual(pTokenizer, CUEKEYWORD_MOTOROLA)) 1041 { 1042 pThis->fLittleEndian = false; 1043 rc = cueParseTrackList(pThis, pTokenizer); 1044 } 1032 1045 else 1033 1046 rc = vdIfError(pThis->pIfError, VERR_NOT_SUPPORTED, RT_SRC_POS, … … 1133 1146 { 1134 1147 cTracks++; 1135 pRegionPrev->cRegionBlocksOrBytes = pRegionPrev->cbBlock * pRegion->offRegion; 1148 uint64_t cBlocks = pRegion->offRegion - (pRegionPrev->offRegion / pRegionPrev->cbBlock); 1149 pRegionPrev->cRegionBlocksOrBytes = pRegionPrev->cbBlock * cBlocks; 1136 1150 offDisk += pRegionPrev->cRegionBlocksOrBytes; 1137 1151 … … 1491 1505 Assert(!(cbToRead % pRegion->cbBlock)); 1492 1506 1493 rc = vdIfIoIntFileReadUser(pThis->pIfIo, pThis->pStorageData, uOffset, 1494 pIoCtx, cbToRead); 1495 if (RT_SUCCESS(rc)) 1507 /* Need to convert audio data samples to big endian. */ 1508 if ( pRegion->enmDataForm == VDREGIONDATAFORM_CDDA 1509 && pThis->fLittleEndian) 1510 { 1496 1511 *pcbActuallyRead = cbToRead; 1512 1513 while (cbToRead) 1514 { 1515 RTSGSEG Segment; 1516 unsigned cSegments = 1; 1517 size_t cbSeg = 0; 1518 1519 cbSeg = vdIfIoIntIoCtxSegArrayCreate(pThis->pIfIo, pIoCtx, &Segment, 1520 &cSegments, cbToRead); 1521 1522 rc = vdIfIoIntFileReadSync(pThis->pIfIo, pThis->pStorageData, uOffset, Segment.pvSeg, cbSeg); 1523 if (RT_FAILURE(rc)) 1524 break; 1525 1526 uint16_t *pu16Buf = (uint16_t *)Segment.pvSeg; 1527 for (uint32_t i = 0; i < cbSeg / sizeof(uint16_t); i++) 1528 { 1529 *pu16Buf = RT_BSWAP_U16(*pu16Buf); 1530 pu16Buf++; 1531 } 1532 1533 cbToRead -= RT_MIN(cbToRead, cbSeg); 1534 uOffset += cbSeg; 1535 } 1536 } 1537 else 1538 { 1539 rc = vdIfIoIntFileReadUser(pThis->pIfIo, pThis->pStorageData, uOffset, 1540 pIoCtx, cbToRead); 1541 if (RT_SUCCESS(rc)) 1542 *pcbActuallyRead = cbToRead; 1543 } 1497 1544 } 1498 1545 else … … 1561 1608 LogFlowFunc(("pBackendData=%#p\n", pBackendData)); 1562 1609 PCUEIMAGE pThis = (PCUEIMAGE)pBackendData; 1563 uint64_t cb = 0;1564 1610 1565 1611 AssertPtrReturn(pThis, 0); 1612 1613 PCVDREGIONDESC pRegion = &pThis->pRegionList->aRegions[pThis->pRegionList->cRegions - 1]; 1614 uint64_t cb = pRegion->offRegion + pRegion->cRegionBlocksOrBytes; 1566 1615 1567 1616 LogFlowFunc(("returns %llu\n", cb)); … … 1580 1629 if (pThis->pStorage) 1581 1630 { 1582 int rc = vdIfIoIntFileGetSize(pThis->pIfIo, pThis->pStorage , &cbFile);1631 int rc = vdIfIoIntFileGetSize(pThis->pIfIo, pThis->pStorageData, &cbFile); 1583 1632 if (RT_FAILURE(rc)) 1584 1633 cbFile = 0; /* Make sure it is 0 */ … … 1941 1990 "CUE", 1942 1991 /* uBackendCaps */ 1943 VD_CAP_FILE | VD_CAP_ ASYNC | VD_CAP_VFS,1992 VD_CAP_FILE | VD_CAP_VFS, 1944 1993 /* paFileExtensions */ 1945 1994 s_aCueFileExtensions,
Note:
See TracChangeset
for help on using the changeset viewer.