I am porting my Linux Qt jukebox project to Windows. Everything is working correctly except for the CD Ripper portion. I am having a problem with the portion of the code that extracts the tracks from the CDs. Here is the code in question:
Code:
void CD_Extractor::Extract(int tracknum) { int size; char *buf; int16_t *readresult; long result; long x; long firstsector,lastsector; int i; QMessageBox box; QString fname; QByteArray arr; Paranoia = cdio_paranoia_init(Drive); firstsector = cdio_cddap_track_firstsector(Drive, tracknum); lastsector = cdio_cddap_track_lastsector(Drive, tracknum); size = (lastsector - firstsector) + 1; SectorsTotal = size; SectorsRead = 0; cdio_cddap_speed_set(Drive,32); paranoia_modeset(Paranoia, PARANOIA_MODE_FULL); //^PARANOIA_MODE_NEVERSKIP); paranoia_seek(Paranoia, firstsector, SEEK_SET); WriteWav(file.handle(),size * CD_Framesize_Raw); for (i = firstsector; i <= lastsector; i++) { try { //readresult = cdio_paranoia_read(Paranoia,NULL); readresult = cdio_paranoia_read_limited(Paranoia,NULL,3); SectorsRead++; buf = (char*)readresult; file.write(buf,CD_Framesize_Raw); UpdateProgress(Progress()); } catch(...) { break; } } fname = file.fileName(); file.close(); cdio_paranoia_free(Paranoia); ExtractFinished(fname); } void CD_Extractor::WriteWav(int f,long bytes) { /* quick and dirty */ write(f,"RIFF",4); /* 0-3 */ PutNum(bytes+44-8,f,0,4); /* 4-7 */ write(f,"WAVEfmt ",8); /* 8-15 */ PutNum(16,f,0,4); /* 16-19 */ PutNum(1,f,0,2); /* 20-21 */ PutNum(2,f,0,2); /* 22-23 */ PutNum(44100,f,0,4); /* 24-27 */ PutNum(44100*2*2,f,0,4); /* 28-31 */ PutNum(4,f,0,2); /* 32-33 */ PutNum(16,f,0,2); /* 34-35 */ write(f,"data",4); /* 36-39 */ PutNum(bytes,f,0,4); /* 40-43 */ } void CD_Extractor::PutNum(long num,int f,int endianness,int bytes){ int i; unsigned char c; if(!endianness) i=0; else i=bytes-1; while(bytes--){ c=(num>>(i<<3))&0xff; if(write(f,&c,1)==-1){ perror("Could not write to output."); exit(1); } if(endianness) i--; else i++; } }
When I try to compile, this is what I get:
'write' was not declared in this scope
After digging around, I found that the version of "write" I was using in WriteWav needed the unistd.h header. So I added "#include <unistd.h>" to my source file. That's when things got really interesting. Now when I try to compile, I get this:
debug/cd_extractor.o: In function `ZorN10QEventLoop17ProcessEventsFlagES0_':
C:\SKG_Jukebox\CDRipperTest-build-desktop/../../Qt/2010.04/qt/include/QtCore/../../src/corelib/global/qglobal.h:1368: multiple definition of `operator|(QEventLoop::ProcessEventsFlag, QEventLoop::ProcessEventsFlag)'
debug/mainwindow.o:C:\SKG_Jukebox\CDRipperTest-build-desktop/../../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qeventloop.h:95: first defined here
debug/cd_extractor.o: In function `ZorN10QEventLoop17ProcessEventsFlagE6QFlagsIS0_E' :
C:\SKG_Jukebox\CDRipperTest-build-desktop/../../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qeventloop.h:95: multiple definition of `operator|(QEventLoop::ProcessEventsFlag, QFlags<QEventLoop::ProcessEventsFlag>)'
debug/mainwindow.o:C:\SKG_Jukebox\CDRipperTest-build-desktop/../../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qeventloop.h:95: first defined here
debug/cd_extractor.o: In function `ZorN10QEventLoop17ProcessEventsFlagEi':
C:\SKG_Jukebox\CDRipperTest-build-desktop/../../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qeventloop.h:95: multiple definition of `operator|(QEventLoop::ProcessEventsFlag, int)'
debug/mainwindow.o:C:\SKG_Jukebox\CDRipperTest-build-desktop/../../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qeventloop.h:95: first defined here
debug/cd_extractor.o:C:\SKG_Jukebox\CDRipperTest-build-desktop/../../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qcoreapplication.h:215: multiple definition of `QCoreApplication::sendEvent(QObject*, QEvent*)'
debug/mainwindow.o:C:\SKG_Jukebox\CDRipperTest-build-desktop/../../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qcoreapplication.h:215: first defined here
debug/cd_extractor.o:C:\SKG_Jukebox\CDRipperTest-build-desktop/../../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qcoreapplication.h:218: multiple definition of `QCoreApplication::sendSpontaneousEvent(QObject*, QEvent*)'
debug/mainwindow.o:C:\SKG_Jukebox\CDRipperTest-build-desktop/../../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qcoreapplication.h:218: first defined here
debug/cd_extractor.o:C:\SKG_Jukebox\CDRipperTest-build-desktop/../../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qcoreapplication.h:220: multiple definition of `QCoreApplication::sendPostedEvents()'
debug/mainwindow.o:C:\SKG_Jukebox\CDRipperTest-build-desktop/../../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qcoreapplication.h:220: first defined here
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\CDRipperTest.exe] Error 1
mingw32-make: *** [debug] Error 2
Keep in mind that this exact code compiles and runs just fine under Linux. I'm linked to the correct DLLs. I tried cleaning the project and running QMake. Any insights anyone? This is kind of hlding up my Windows port.