TEST_F(SoundSourceProxyTest, open) { // This test piggy-backs off of the cover-test files. for (const auto& filePath: getFilePaths()) { ASSERT_TRUE(SoundSourceProxy::isFileNameSupported(filePath)); Mixxx::AudioSourcePointer pAudioSource(openAudioSource(filePath)); ASSERT_TRUE(!pAudioSource.isNull()); EXPECT_LT(0, pAudioSource->getChannelCount()); EXPECT_LT(0, pAudioSource->getSamplingRate()); EXPECT_LT(0, pAudioSource->getFrameCount()); } }
void ResultProcessor::getFilePaths(const std::string & directory , std::vector<std::string> & paths , int fileIndex) { fs::directory_iterator end; fs::directory_iterator dirIter(directory); if(dirIter == end) throw std::runtime_error("given argument is not a path to existing directory: " + directory); for(; dirIter != end ; dirIter++) { if(dirIter.is_directory() && dirIter.name().compare(".") != 0 && dirIter.name().compare("..") != 0) { getFilePaths(dirIter.path() , paths , fileIndex); } if(dirIter.is_file() && Utils::getFileIndex(dirIter.name()) == fileIndex) { paths.push_back(dirIter.path()); } } }
TEST_F(SoundSourceProxyTest, open) { // This test piggy-backs off of the cover-test files. for (const auto& filePath: getFilePaths()) { ASSERT_TRUE(SoundSourceProxy::isFileNameSupported(filePath)); Mixxx::AudioSourcePointer pAudioSource(openAudioSource(filePath)); // Obtaining an AudioSource may fail for unsupported file formats, // even if the corresponding file extension is supported, e.g. // AAC vs. ALAC in .m4a files if (pAudioSource.isNull()) { // skip test file continue; } EXPECT_LT(0, pAudioSource->getChannelCount()); EXPECT_LT(0, pAudioSource->getSamplingRate()); EXPECT_LT(0, pAudioSource->getFrameCount()); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- QStringList BookmarksModel::getFilePaths(BookmarksItem* item) { QStringList list; if (item != rootItem && item->childCount() <= 0) { QString filePath = item->data(BookmarksItem::Path).toString(); if (filePath.isEmpty() == false) { list.append(filePath); } return list; } for (int i = 0; i < item->childCount(); i++) { list.append(getFilePaths(item->child(i))); } return list; }
void createFiles(void) { int i =0; char filePathList[fileCount][160]; getFilePaths(filePathList); int fid = -1; int dataToWrite[500]; createData(dataToWrite,500); //char arr[500*4]; for(i=0;i<fileCount;++i) { kprintf("Creating file %s\r\n",filePathList[i]); if((fid = open(LFILESYS,filePathList[i],"n"))== SYSERR) { kprintf("Failure\r\n"); return ; } kprintf("Writting to the file\r\n"); if(write(fid,(char*)dataToWrite,4*500)== SYSERR) { kprintf("Write failed\r\n"); } kprintf("File size %u\r\n",lfltab[fid-5].fileSize); kprintf("closing the file\r\n"); if(close(fid)== SYSERR) { kprintf("close failed\r\n"); } } kprintf("Done Writting\r\n"); kprintf("Deleting Directory /dir1/dir2/dir3\r\n"); char *path ="/dir1/dir2/dir3"; if(control(LFILESYS,LF_CTL_RMDIR,(int)path,0) == SYSERR) { kprintf("Deleting directory /dir1/dir2/dir3 failed\r\n"); } kprintf("Deleting Directory /dir1/dir2\r\n"); path ="/dir1/dir2"; if(control(LFILESYS,LF_CTL_RMDIR,(int)path,0) == SYSERR) { kprintf("Deleting directory /dir1/dir2 failed\r\n"); } kprintf("Deleting Directory /dir1\r\n"); path ="/dir1"; if(control(LFILESYS,LF_CTL_RMDIR,(int)path,0) == SYSERR) { kprintf("Deleting directory /dir1 failed\r\n"); } lfsckfmt(RDISK); /*kprintf("Removing file /dir1/file_000/ \r\n"); char *path ="/dir1/file_000"; if(control(LFILESYS,LF_CTL_DEL,(int)path,0) == SYSERR) { kprintf("Removing file /dir1/file_000/ failed\r\n"); } kprintf("Removing file /dir1/dir2/dir3/file_003/ \r\n"); path ="/dir1/dir2/dir3/file_003/"; if(control(LFILESYS,LF_CTL_DEL,(int)path,0) == SYSERR) { kprintf("Removing file /dir1/dir2/dir3/file_003 failed\r\n"); } for(i=0;i<fileCount;++i) { kprintf("Opening file %s\r\n",filePathList[i]); if((fid = open(LFILESYS,filePathList[i],"o"))== SYSERR) { kprintf("Failure\r\n"); //return ; continue; } kprintf("File depth %u\r\n",lfltab[fid-5].depth); kprintf("File size %u\r\n",lfltab[fid-5].fileSize); kprintf("firstIbId %u\r\n",lfltab[fid-5].firstIbId); int k =0; kprintf("filePath "); for(k=0;k<lfltab[fid-5].depth;++k) { kprintf("/%s",lfltab[fid-5].path[k]); } kprintf("\r\n"); kprintf("Reading from the file\r\n"); int bytesRead = 0; if((bytesRead =read(fid,arr,500*4)) == SYSERR) { kprintf("Read falied\n"); } kprintf("Bytes Read %d\r\n",bytesRead); if(matchData((int*)arr,500)) { kprintf("MATCH \r\n"); } else { kprintf("MISMATCH\r\n"); } // int j=0; // for(j=0;j<bytesRead;++j) // { // kprintf("%c\r\n",arr[j]); // } kprintf("closing the file\r\n"); if(close(fid)== SYSERR) { kprintf("close failed\r\n"); } } kprintf("Done Opening\r\n"); kprintf("Creating file /dir1/file_000/ \r\n"); if((fid = open(LFILESYS,"/dir1/file_000","n")) == SYSERR) { kprintf("Creating file /dir1/file_000/ failed\r\n"); } if(write(fid,(char*)dataToWrite,4*500)== SYSERR) { kprintf("Write failed\r\n"); } kprintf("closing the file\r\n"); if(close(fid)== SYSERR) { kprintf("close failed\r\n"); } kprintf("opening file /dir1/file_000/ \r\n"); if((fid = open(LFILESYS,"/dir1/file_000","o")) == SYSERR) { kprintf("opening file /dir1/file_000/ failed\r\n"); } kprintf("Reading from the file\r\n"); int bytesRead = 0; if((bytesRead =read(fid,arr,500*4)) == SYSERR) { kprintf("Read falied\n"); } kprintf("Bytes Read %d\r\n",bytesRead); kprintf("Creating file /dir1/dir2/dir3/file_003/ \r\n"); if((fid = open(LFILESYS,"/dir1/dir2/dir3/file_003/","n")) == SYSERR) { kprintf("Creating file /dir1/dir2/dir3/file_003/ failed\r\n"); } if(write(fid,(char*)dataToWrite,4*500)== SYSERR) { kprintf("Write failed\r\n"); } kprintf("closing the file\r\n"); if(close(fid)== SYSERR) { kprintf("close failed\r\n"); } kprintf("opening file /dir1/dir2/dir3/file_003/ \r\n"); if((fid = open(LFILESYS,"/dir1/dir2/dir3/file_003","o")) == SYSERR) { kprintf("opening file /dir1/dir2/dir3/file_003 failed\r\n"); } kprintf("Reading from the file\r\n"); if((bytesRead =read(fid,arr,500*4)) == SYSERR) { kprintf("Read falied\n"); } kprintf("Bytes Read %d\r\n",bytesRead);*/ }
TEST_F(SoundSourceProxyTest, seekForward) { const SINT kReadFrameCount = 10000; // According to API documentation of op_pcm_seek(): // "...decoding after seeking may not return exactly the same // values as would be obtained by decoding the stream straight // through. However, such differences are expected to be smaller // than the loss introduced by Opus's lossy compression." // NOTE(uklotzde): The current version 0.6 of opusfile doesn't // seem to support sample accurate seeking. The differences // between the samples decoded with continuous reading and // those samples decoded after seeking are quite noticeable! const CSAMPLE kOpusSeekDecodingError = 0.2f; for (const auto& filePath: getFilePaths()) { ASSERT_TRUE(SoundSourceProxy::isFileNameSupported(filePath)); qDebug() << "Seek forward test:" << filePath; Mixxx::AudioSourcePointer pContReadSource(openAudioSource(filePath)); ASSERT_FALSE(pContReadSource.isNull()); const SINT readSampleCount = pContReadSource->frames2samples(kReadFrameCount); SampleBuffer contReadData(readSampleCount); SampleBuffer seekReadData(readSampleCount); #ifdef __FFMPEGFILE__ if (dynamic_cast<Mixxx::SoundSourceFFmpeg*>(pContReadSource.data())) { if (filePath.endsWith(".mp3")) { qDebug() << "Skip test since it will fail using SoundSourceFFmpeg"; continue; } } #endif for (SINT contFrameIndex = 0; pContReadSource->isValidFrameIndex(contFrameIndex); contFrameIndex += kReadFrameCount) { // Read next chunk of frames for Cont source without seek const SINT contReadFrameCount = pContReadSource->readSampleFrames(kReadFrameCount, &contReadData[0]); Mixxx::AudioSourcePointer pSeekReadSource(openAudioSource(filePath)); ASSERT_FALSE(pSeekReadSource.isNull()); ASSERT_EQ(pContReadSource->getChannelCount(), pSeekReadSource->getChannelCount()); ASSERT_EQ(pContReadSource->getFrameCount(), pSeekReadSource->getFrameCount()); // Seek source to next chunk and read it const SINT seekFrameIndex = pSeekReadSource->seekSampleFrame(contFrameIndex); ASSERT_EQ(contFrameIndex, seekFrameIndex); const SINT seekReadFrameCount = pSeekReadSource->readSampleFrames(kReadFrameCount, &seekReadData[0]); // content of both buffers should be equal ASSERT_EQ(contReadFrameCount, seekReadFrameCount); const SINT readSampleCount = pContReadSource->frames2samples(contReadFrameCount); for (SINT readSampleOffset = 0; readSampleOffset < readSampleCount; ++readSampleOffset) { if (filePath.endsWith(".opus")) { EXPECT_NEAR(contReadData[readSampleOffset], seekReadData[readSampleOffset], kOpusSeekDecodingError) << "Mismatch in " << filePath.toStdString() << " at seek frame index " << seekFrameIndex << "/" << pContReadSource->getMaxFrameIndex() << " for read sample offset " << readSampleOffset; } else { // NOTE(uklotzde): The comparison EXPECT_EQ might be // replaced with EXPECT_FLOAT_EQ to guarantee almost // accurate seeking. Currently EXPECT_EQ works for all // tested file formats except Opus. EXPECT_EQ(contReadData[readSampleOffset], seekReadData[readSampleOffset]) << "Mismatch in " << filePath.toStdString() << " at seek frame index " << seekFrameIndex << "/" << pContReadSource->getMaxFrameIndex() << " for read sample offset " << readSampleOffset; } } } } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- QStringList BookmarksModel::getFilePaths() { return getFilePaths(rootItem); }