Diffstat (limited to 'noncore/multimedia/opierec/wavFile.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opierec/wavFile.cpp | 86 |
1 files changed, 44 insertions, 42 deletions
diff --git a/noncore/multimedia/opierec/wavFile.cpp b/noncore/multimedia/opierec/wavFile.cpp index 7e9b50f..fc0130c 100644 --- a/noncore/multimedia/opierec/wavFile.cpp +++ b/noncore/multimedia/opierec/wavFile.cpp @@ -28,5 +28,5 @@ WavFile::WavFile( QObject * parent,const QString &fileName, bool makeNwFile, int : QObject( parent) { -//odebug << "new wave file" << oendl; +//odebug << "new wave file" << oendl; bool b = makeNwFile; wavSampleRate=sampleRate; @@ -44,5 +44,5 @@ WavFile::WavFile( QObject * parent,const QString &fileName, bool makeNwFile, int bool WavFile::newFile() { -// odebug << "Set up new file" << oendl; +// odebug << "Set up new file" << oendl; Config cfg("OpieRec"); cfg.setGroup("Settings"); @@ -64,5 +64,5 @@ bool WavFile::newFile() { currentFileName+=".wav"; -// odebug << "set up file for recording: "+currentFileName << oendl; +// odebug << "set up file for recording: "+currentFileName << oendl; char pointer[] = "/tmp/opierec-XXXXXX"; int fd = 0; @@ -72,5 +72,5 @@ bool WavFile::newFile() { // if destination file is most likely in flash (assuming jffs2) // we have to write to a different filesystem first - + useTmpFile = true; if(( fd = mkstemp( pointer)) < 0 ) { @@ -78,10 +78,10 @@ bool WavFile::newFile() { return false; } - -// odebug << "Opening tmp file " << pointer << "" << oendl; + +// odebug << "Opening tmp file " << pointer << "" << oendl; track.setName( pointer); } else { //just use regular file.. no moving - + useTmpFile = false; track.setName( currentFileName); @@ -89,7 +89,7 @@ bool WavFile::newFile() { if(!track.open( IO_ReadWrite | IO_Truncate)) { QString errorMsg=(QString)strerror(errno); - odebug << errorMsg << oendl; + odebug << errorMsg << oendl; QMessageBox::message("Note", "Error opening file.\n" +errorMsg); - + return false; } else { @@ -105,17 +105,17 @@ WavFile::~WavFile() { void WavFile::closeFile() { - if(track.isOpen()) + if(track.isOpen()) track.close(); } int WavFile::openFile(const QString ¤tFileName) { -// odebug << "open play file "+currentFileName << oendl; +// odebug << "open play file "+currentFileName << oendl; closeFile(); - + track.setName(currentFileName); if(!track.open(IO_ReadOnly)) { QString errorMsg=(QString)strerror(errno); - odebug << "<<<<<<<<<<< "+errorMsg+currentFileName << oendl; + odebug << "<<<<<<<<<<< "+errorMsg+currentFileName << oendl; QMessageBox::message("Note", "Error opening file.\n" +errorMsg); return -1; @@ -125,5 +125,5 @@ int WavFile::openFile(const QString ¤tFileName) { return track.handle(); } - + bool WavFile::setWavHeader(int fd, wavhdr *hdr) { @@ -135,9 +135,9 @@ bool WavFile::setWavHeader(int fd, wavhdr *hdr) { if( wavFormat == WAVE_FORMAT_PCM) { (*hdr).fmtTag = 1; // PCM -// odebug << "set header WAVE_FORMAT_PCM" << oendl; +// odebug << "set header WAVE_FORMAT_PCM" << oendl; } else { (*hdr).fmtTag = WAVE_FORMAT_DVI_ADPCM; //intel ADPCM - // odebug << "set header WAVE_FORMAT_DVI_ADPCM" << oendl; + // odebug << "set header WAVE_FORMAT_DVI_ADPCM" << oendl; } @@ -153,6 +153,7 @@ bool WavFile::setWavHeader(int fd, wavhdr *hdr) { write( fd,hdr, sizeof(*hdr)); - qDebug("writing header: bitrate%d, samplerate %d, channels %d", - wavResolution, wavSampleRate, wavChannels); + odebug << "writing header: bitrate " << wavResolution + << ", samplerate " << wavSampleRate + << ", channels " << wavChannels << oendl; return true; } @@ -164,10 +165,10 @@ bool WavFile::adjustHeaders(int fd, int total) { lseek( fd, 40, SEEK_SET); write( fd, &total, sizeof(total)); - odebug << "adjusting header " << total << "" << oendl; + odebug << "adjusting header " << total << "" << oendl; return true; } int WavFile::parseWavHeader(int fd) { - odebug << "Parsing wav header" << oendl; + odebug << "Parsing wav header" << oendl; char string[4]; int found; @@ -177,18 +178,18 @@ int WavFile::parseWavHeader(int fd) { if (read(fd, string, 4) < 4) { - odebug << " Could not read from sound file.\n" << oendl; + odebug << " Could not read from sound file.\n" << oendl; return -1; } if (strncmp(string, "RIFF", 4)) { - odebug << " not a valid WAV file.\n" << oendl; + odebug << " not a valid WAV file.\n" << oendl; return -1; } lseek(fd, 4, SEEK_CUR); if (read(fd, string, 4) < 4) { - odebug << "Could not read from sound file.\n" << oendl; + odebug << "Could not read from sound file.\n" << oendl; return -1; } if (strncmp(string, "WAVE", 4)) { - odebug << "not a valid WAV file.\n" << oendl; + odebug << "not a valid WAV file.\n" << oendl; return -1; } @@ -197,10 +198,10 @@ int WavFile::parseWavHeader(int fd) { while (!found) { if (read(fd, string, 4) < 4) { - odebug << "Could not read from sound file.\n" << oendl; + odebug << "Could not read from sound file.\n" << oendl; return -1; } if (strncmp(string, "fmt ", 4)) { if (read(fd, &longdata, 4) < 4) { - odebug << "Could not read from sound file.\n" << oendl; + odebug << "Could not read from sound file.\n" << oendl; return -1; } @@ -209,38 +210,37 @@ int WavFile::parseWavHeader(int fd) { lseek(fd, 4, SEEK_CUR); if (read(fd, &fmt, 2) < 2) { - odebug << "Could not read format chunk.\n" << oendl; + odebug << "Could not read format chunk.\n" << oendl; return -1; } if (fmt != WAVE_FORMAT_PCM && fmt != WAVE_FORMAT_DVI_ADPCM) { - qDebug("Wave file contains unknown format." - " Unable to continue.\n"); + odebug << "Wave file contains unknown format. Unable to continue.\n" << oendl; return -1; } wavFormat = fmt; // compressionFormat=fmt; - odebug << "compressionFormat is " << fmt << "" << oendl; + odebug << "compressionFormat is " << fmt << "" << oendl; if (read(fd, &ch, 2) < 2) { - odebug << "Could not read format chunk.\n" << oendl; + odebug << "Could not read format chunk.\n" << oendl; return -1; } else { wavChannels = ch; - odebug << "File has " << ch << " channels" << oendl; + odebug << "File has " << ch << " channels" << oendl; } if (read(fd, &samplerrate, 4) < 4) { - odebug << "Could not read from format chunk.\n" << oendl; + odebug << "Could not read from format chunk.\n" << oendl; return -1; } else { wavSampleRate = samplerrate; // sampleRate = samplerrate; - odebug << "File has samplerate of " << (int) samplerrate << "" << oendl; + odebug << "File has samplerate of " << (int) samplerrate << "" << oendl; } lseek(fd, 6, SEEK_CUR); if (read(fd, &bitrate, 2) < 2) { - odebug << "Could not read format chunk.\n" << oendl; + odebug << "Could not read format chunk.\n" << oendl; return -1; } else { wavResolution=bitrate; // resolution = bitrate; - odebug << "File has bitrate of " << bitrate << "" << oendl; + odebug << "File has bitrate of " << bitrate << "" << oendl; } found++; @@ -250,5 +250,5 @@ int WavFile::parseWavHeader(int fd) { while (!found) { if (read(fd, string, 4) < 4) { - odebug << "Could not read from sound file.\n" << oendl; + odebug << "Could not read from sound file.\n" << oendl; return -1; } @@ -256,5 +256,5 @@ int WavFile::parseWavHeader(int fd) { if (strncmp(string, "data", 4)) { if (read(fd, &longdata, 4)<4) { - odebug << "Could not read from sound file.\n" << oendl; + odebug << "Could not read from sound file.\n" << oendl; return -1; } @@ -263,12 +263,14 @@ int WavFile::parseWavHeader(int fd) { } else { if (read(fd, &longdata, 4) < 4) { - odebug << "Could not read from sound file.\n" << oendl; + odebug << "Could not read from sound file.\n" << oendl; return -1; } else { wavNumberSamples = longdata; - qDebug("file has length of %d \nlasting %d seconds", (int)longdata, - (int)(( longdata / wavSampleRate) / wavChannels) / ( wavChannels*( wavResolution/8)) ); + odebug << "file hase length of " << (int)longdata << "\n" + << "lasting " + << (int)(( longdata / wavSampleRate) / wavChannels) / ( wavChannels*( wavResolution/8)) + << " seconds" << oendl; // wavSeconds = (( longdata / wavSampleRate) / wavChannels) / ( wavChannels*( wavResolution/8)); - + return longdata; } |