author | llornkcor <llornkcor> | 2003-11-13 08:33:15 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-11-13 08:33:15 (UTC) |
commit | 3451f19533b2dd342a57bceda4aec20edd4048b7 (patch) (side-by-side diff) | |
tree | 9065ee04704e4f095a093696be94b1776b873c1e | |
parent | 452f0cc3d9fdd792d2050ceaffd33b3d1611fcc3 (diff) | |
download | opie-3451f19533b2dd342a57bceda4aec20edd4048b7.zip opie-3451f19533b2dd342a57bceda4aec20edd4048b7.tar.gz opie-3451f19533b2dd342a57bceda4aec20edd4048b7.tar.bz2 |
update wavfile
-rw-r--r-- | noncore/multimedia/opierec/wavFile.cpp | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/noncore/multimedia/opierec/wavFile.cpp b/noncore/multimedia/opierec/wavFile.cpp index 7bfffb6..b177c91 100644 --- a/noncore/multimedia/opierec/wavFile.cpp +++ b/noncore/multimedia/opierec/wavFile.cpp @@ -24,9 +24,9 @@ WavFile::WavFile( QObject * parent,const QString &fileName, bool makeNwFile, int sampleRate, int channels, int resolution, int format ) : QObject( parent) { -qDebug("new wave file"); +//qDebug("new wave file"); bool b = makeNwFile; wavSampleRate=sampleRate; wavFormat=format; wavChannels=channels; @@ -40,9 +40,9 @@ qDebug("new wave file"); } bool WavFile::newFile() { - qDebug("Set up new file"); +// qDebug("Set up new file"); Config cfg("OpieRec"); cfg.setGroup("Settings"); currentFileName=cfg.readEntry("directory",QDir::homeDirPath()); @@ -59,19 +59,24 @@ bool WavFile::newFile() { else currentFileName += date; currentFileName+=".wav"; - qDebug("set up file for recording: "+currentFileName); - char *pointer; +// qDebug("set up file for recording: "+currentFileName); + char pointer[] = "/tmp/opierec-XXXXXX"; + int fd = 0; if( currentFileName.find("/mnt",0,true) == -1 && currentFileName.find("/tmp",0,true) == -1 ) { // if destination file is most likely in flash (assuming jffs2) // we have to write to a different filesystem first useTmpFile = true; - pointer=tmpnam(NULL); - qDebug("Opening tmp file %s",pointer); + if(( fd = mkstemp( pointer)) < 0 ) { + perror("mkstemp failed"); + return false; + } + +// qDebug("Opening tmp file %s",pointer); track.setName( pointer); } else { //just use regular file.. no moving @@ -100,9 +105,9 @@ void WavFile::closeFile() { track.close(); } int WavFile::openFile(const QString ¤tFileName) { - qDebug("open play file "+currentFileName); +// qDebug("open play file "+currentFileName); closeFile(); track.setName(currentFileName); @@ -125,13 +130,13 @@ bool WavFile::setWavHeader(int fd, wavhdr *hdr) { (*hdr).fmtLen = 16; // format length = 16 if( wavFormat == WAVE_FORMAT_PCM) { (*hdr).fmtTag = 1; // PCM - qDebug("set header WAVE_FORMAT_PCM"); +// qDebug("set header WAVE_FORMAT_PCM"); } else { (*hdr).fmtTag = WAVE_FORMAT_DVI_ADPCM; //intel ADPCM - qDebug("set header WAVE_FORMAT_DVI_ADPCM"); + // qDebug("set header WAVE_FORMAT_DVI_ADPCM"); } // (*hdr).nChannels = 1;//filePara.channels;// ? 2 : 1*/; // channels (*hdr).nChannels = wavChannels;// ? 2 : 1*/; // channels @@ -143,10 +148,10 @@ bool WavFile::setWavHeader(int fd, wavhdr *hdr) { strncpy((*hdr).dataID, "data", 4); write( fd,hdr, sizeof(*hdr)); - qDebug("writing header: bitrate%d, samplerate %d, channels %d", - wavResolution, wavSampleRate, wavChannels); +// qDebug("writing header: bitrate%d, samplerate %d, channels %d", +// wavResolution, wavSampleRate, wavChannels); return true; } bool WavFile::adjustHeaders(int fd, int total) { @@ -154,14 +159,14 @@ bool WavFile::adjustHeaders(int fd, int total) { int i = total + 36; write( fd, &i, sizeof(i)); lseek( fd, 40, SEEK_SET); write( fd, &total, sizeof(total)); - qDebug("adjusting header %d", total); +// qDebug("adjusting header %d", total); return true; } int WavFile::parseWavHeader(int fd) { - qDebug("Parsing wav header"); +// qDebug("Parsing wav header"); char string[4]; int found; short fmt; unsigned short ch, bitrate; @@ -257,10 +262,10 @@ int WavFile::parseWavHeader(int fd) { qDebug("Could not read from sound file.\n"); return -1; } else { wavNumberSamples = longdata; - qDebug("file has length of %d \nlasting %d seconds", longdata, - (( longdata / wavSampleRate) / wavChannels) / ( wavChannels*( wavResolution/8)) ); + qDebug("file has length of %d \nlasting %d seconds", (int)longdata, + (int)(( longdata / wavSampleRate) / wavChannels) / ( wavChannels*( wavResolution/8)) ); // wavSeconds = (( longdata / wavSampleRate) / wavChannels) / ( wavChannels*( wavResolution/8)); return longdata; } |