author | llornkcor <llornkcor> | 2005-03-12 01:54:52 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2005-03-12 01:54:52 (UTC) |
commit | 84af289057291a49a52a60b390bc5320c02b5a55 (patch) (unidiff) | |
tree | 523f2d36240efd4f500bfbc35996771bebd7360d | |
parent | 6b67c3b2685b2d3f1bc7a787216aa769d4ea257a (diff) | |
download | opie-84af289057291a49a52a60b390bc5320c02b5a55.zip opie-84af289057291a49a52a60b390bc5320c02b5a55.tar.gz opie-84af289057291a49a52a60b390bc5320c02b5a55.tar.bz2 |
fix irregularity with adpcm and bits
-rw-r--r-- | noncore/multimedia/opierec/device.cpp | 16 | ||||
-rw-r--r-- | noncore/multimedia/opierec/opierec.pro | 1 | ||||
-rw-r--r-- | noncore/multimedia/opierec/qtrec.cpp | 123 | ||||
-rw-r--r-- | noncore/multimedia/opierec/wavFile.cpp | 62 |
4 files changed, 105 insertions, 97 deletions
diff --git a/noncore/multimedia/opierec/device.cpp b/noncore/multimedia/opierec/device.cpp index e7e0f4b..a76665e 100644 --- a/noncore/multimedia/opierec/device.cpp +++ b/noncore/multimedia/opierec/device.cpp | |||
@@ -59,8 +59,9 @@ Device::Device( QObject * parent, bool record ) | |||
59 | 59 | ||
60 | if( !record){ //playing | 60 | if( !record){ //playing |
61 | owarn << "setting up DSP for playing" << oendl; | 61 | owarn << "New Sound device DSP for playing" << oendl; |
62 | flags = O_WRONLY; | 62 | flags = O_RDWR; |
63 | // flags = O_WRONLY; | ||
63 | } else { //recording | 64 | } else { //recording |
64 | owarn << "setting up DSP for recording" << oendl; | 65 | owarn << "New Sound device DSP for recording" << oendl; |
65 | flags = O_RDWR; | 66 | flags = O_RDWR; |
66 | // flags = O_RDONLY; | 67 | // flags = O_RDONLY; |
@@ -70,4 +71,5 @@ Device::Device( QObject * parent, bool record ) | |||
70 | 71 | ||
71 | bool Device::openDsp() { | 72 | bool Device::openDsp() { |
73 | qWarning("Device::openDsp()"); | ||
72 | if( openDevice( flags) == -1) { | 74 | if( openDevice( flags) == -1) { |
73 | perror("<<<<<<<<<<<<<<ioctl(\"Open device\")"); | 75 | perror("<<<<<<<<<<<<<<ioctl(\"Open device\")"); |
@@ -78,8 +80,8 @@ bool Device::openDsp() { | |||
78 | 80 | ||
79 | int Device::openDevice( int flags) { | 81 | int Device::openDevice( int flags) { |
80 | owarn << "Opening"<< dspstr; | 82 | owarn << "Opening sound device:"<< DSPSTROUT << oendl; |
81 | 83 | ||
82 | if (( sd = ::open( DSPSTROUT, flags)) == -1) { | 84 | if (( sd = ::open( DSPSTROUT, O_RDWR)) == -1) { |
83 | perror("open(\"/dev/dsp\")"); | 85 | perror("open(\"/dev/dsp\")\n"); |
84 | QString errorMsg="Could not open audio device\n /dev/dsp\n" | 86 | QString errorMsg="Could not open audio device\n /dev/dsp\n" |
85 | +(QString)strerror(errno); | 87 | +(QString)strerror(errno); |
@@ -91,4 +93,5 @@ int Device::openDevice( int flags) { | |||
91 | perror("ioctl RESET"); | 93 | perror("ioctl RESET"); |
92 | } | 94 | } |
95 | qWarning("opened!"); | ||
93 | return sd; | 96 | return sd; |
94 | } | 97 | } |
@@ -151,4 +154,5 @@ bool Device::selectMicInput() { | |||
151 | 154 | ||
152 | bool Device::closeDevice( bool) { | 155 | bool Device::closeDevice( bool) { |
156 | if(sd) | ||
153 | ::close( sd); //close sound device | 157 | ::close( sd); //close sound device |
154 | return true; | 158 | return true; |
diff --git a/noncore/multimedia/opierec/opierec.pro b/noncore/multimedia/opierec/opierec.pro index 6a5838a..6008bf7 100644 --- a/noncore/multimedia/opierec/opierec.pro +++ b/noncore/multimedia/opierec/opierec.pro | |||
@@ -32,4 +32,5 @@ contains(CONFIG, pdaudio) { | |||
32 | DEPENDPATH += $(OPIEDIR)/include | 32 | DEPENDPATH += $(OPIEDIR)/include |
33 | LIBS += -lqpe -lopiecore2 -lpthread | 33 | LIBS += -lqpe -lopiecore2 -lpthread |
34 | DEFINES += THREADED | ||
34 | TARGET = opierec | 35 | TARGET = opierec |
35 | include( $(OPIEDIR)/include.pro ) | 36 | include( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp index e827083..9b761aa 100644 --- a/noncore/multimedia/opierec/qtrec.cpp +++ b/noncore/multimedia/opierec/qtrec.cpp | |||
@@ -118,16 +118,16 @@ void quickRec() | |||
118 | int level = 0; | 118 | int level = 0; |
119 | int threshold = 0; | 119 | int threshold = 0; |
120 | int bits = filePara.resolution; | 120 | int bits = filePara.resolution; |
121 | odebug << "bits " << bits << "" << oendl; | 121 | odebug << "bits " << bits << "" << oendl; |
122 | 122 | ||
123 | if( filePara.resolution == 16 ) { //AFMT_S16_LE) | 123 | if( filePara.resolution == 16 ) { //AFMT_S16_LE) |
124 | odebug << "AFMT_S16_LE size " << filePara.SecondsToRecord << "" << oendl; | 124 | odebug << "AFMT_S16_LE size " << filePara.SecondsToRecord << "" << oendl; |
125 | odebug << "samples to record " << filePara.samplesToRecord << "" << oendl; | 125 | odebug << "samples to record " << filePara.samplesToRecord << "" << oendl; |
126 | odebug << "" << filePara.sd << "" << oendl; | 126 | odebug << "" << filePara.sd << "" << oendl; |
127 | level = 7; | 127 | level = 7; |
128 | threshold = 0; | 128 | threshold = 0; |
129 | 129 | ||
130 | if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { | 130 | if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { |
131 | odebug << "start recording WAVE_FORMAT_DVI_ADPCM" << oendl; | 131 | odebug << "start recording WAVE_FORMAT_DVI_ADPCM" << oendl; |
132 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> | 132 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> |
133 | char abuf[ BUFSIZE/2 ]; | 133 | char abuf[ BUFSIZE/2 ]; |
@@ -157,5 +157,5 @@ void quickRec() | |||
157 | adpcm_coder( sbuf, abuf, number/2, &encoder_state); | 157 | adpcm_coder( sbuf, abuf, number/2, &encoder_state); |
158 | 158 | ||
159 | bytesWritten = ::write( filePara.fd , (short *)abuf, number/4); | 159 | bytesWritten = ::write( filePara.fd , abuf, number/4); |
160 | 160 | ||
161 | waveform->newSamples( sbuf, number ); | 161 | waveform->newSamples( sbuf, number ); |
@@ -165,8 +165,8 @@ void quickRec() | |||
165 | timeSlider->setValue( total); | 165 | timeSlider->setValue( total); |
166 | 166 | ||
167 | printf("%d, bytes %d,total %d\r", number, bytesWritten, total); | 167 | printf("%d, bytes %d,total %d\r", number, bytesWritten, total); |
168 | fflush(stdout); | 168 | fflush(stdout); |
169 | 169 | ||
170 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2/ filePara.channels; | 170 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2;/// filePara.channels; |
171 | 171 | ||
172 | qApp->processEvents(); | 172 | qApp->processEvents(); |
@@ -215,6 +215,6 @@ void quickRec() | |||
215 | if( filePara.SecondsToRecord != 0) | 215 | if( filePara.SecondsToRecord != 0) |
216 | timeSlider->setValue( total); | 216 | timeSlider->setValue( total); |
217 | printf("%d, bytes %d,total %d\r",number, bytesWritten , total); | 217 | printf("%d, bytes %d,total %d\r",number, bytesWritten , total); |
218 | fflush(stdout); | 218 | fflush(stdout); |
219 | 219 | ||
220 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate | 220 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate |
@@ -302,6 +302,8 @@ void playIt() | |||
302 | // sbuf2[i+1]=sbuf2[i]=sbuf[i]; | 302 | // sbuf2[i+1]=sbuf2[i]=sbuf[i]; |
303 | // } | 303 | // } |
304 | bytesWritten = write ( filePara.sd, sbuf, number * 4); | 304 | bytesWritten = write ( soundDevice->sd , sbuf, number * 4); |
305 | waveform->newSamples( (const short *)sbuf, number *4); | 305 | |
306 | waveform->newSamples( sbuf, number ); | ||
307 | |||
306 | // if(filePara.channels==1) | 308 | // if(filePara.channels==1) |
307 | // total += bytesWritten/2; //mono | 309 | // total += bytesWritten/2; //mono |
@@ -343,5 +345,5 @@ void playIt() | |||
343 | // outbuffer[i+1]= outbuffer[i]=inbuffer[i]; | 345 | // outbuffer[i+1]= outbuffer[i]=inbuffer[i]; |
344 | // } | 346 | // } |
345 | bytesWritten = ::write( filePara.sd, inbuffer, number); | 347 | bytesWritten = ::write( soundDevice->sd, inbuffer, number); |
346 | waveform->newSamples( inbuffer, number); | 348 | waveform->newSamples( inbuffer, number); |
347 | //-------------->>>> out to device | 349 | //-------------->>>> out to device |
@@ -433,5 +435,5 @@ QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) | |||
433 | wavFile = 0; | 435 | wavFile = 0; |
434 | // if( soundDevice) delete soundDevice; | 436 | // if( soundDevice) delete soundDevice; |
435 | QTimer::singleShot(100,this, SLOT(initIconView())); | 437 | QTimer::singleShot(100,this, SLOT(initIconView())); |
436 | 438 | ||
437 | if( autoMute) | 439 | if( autoMute) |
@@ -789,6 +791,6 @@ void QtRec::initConfig() { | |||
789 | compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); | 791 | compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); |
790 | if( compressionCheckBox->isChecked()) { | 792 | if( compressionCheckBox->isChecked()) { |
793 | bitRateComboBox->setCurrentItem(1); | ||
791 | bitRateComboBox->setEnabled(false); | 794 | bitRateComboBox->setEnabled(false); |
792 | bitRateComboBox->setCurrentItem(0); | ||
793 | filePara.resolution=16; | 795 | filePara.resolution=16; |
794 | } | 796 | } |
@@ -1049,5 +1051,5 @@ bool QtRec::setupAudio( bool b) { | |||
1049 | 1051 | ||
1050 | // if(soundDevice) delete soundDevice; | 1052 | // if(soundDevice) delete soundDevice; |
1051 | odebug << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl; | 1053 | owarn << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl; |
1052 | // owarn << "change waveform settings" << oendl; | 1054 | // owarn << "change waveform settings" << oendl; |
1053 | waveform->changeSettings( filePara.sampleRate, filePara.channels ); | 1055 | waveform->changeSettings( filePara.sampleRate, filePara.channels ); |
@@ -1231,36 +1233,36 @@ void QtRec::deleteSound() { | |||
1231 | // #endif | 1233 | // #endif |
1232 | // { | 1234 | // { |
1233 | QString file = ListView1->currentItem()->text(0); | 1235 | QString file = ListView1->currentItem()->text(0); |
1234 | QString fileName; | 1236 | QString fileName; |
1235 | fileName = cfg.readEntry( file, ""); | 1237 | fileName = cfg.readEntry( file, ""); |
1236 | QFile f( fileName); | 1238 | QFile f( fileName); |
1237 | if( f.exists()) | 1239 | if( f.exists()) |
1238 | if( !f.remove()) | 1240 | if( !f.remove()) |
1239 | QMessageBox::message( tr("Error"), tr("Could not remove file.")); | 1241 | QMessageBox::message( tr("Error"), tr("Could not remove file.")); |
1240 | 1242 | ||
1241 | int nFiles = cfg.readNumEntry( "NumberofFiles",0); | 1243 | int nFiles = cfg.readNumEntry( "NumberofFiles",0); |
1242 | bool found = false; | 1244 | bool found = false; |
1243 | for(int i=0;i<nFiles+1;i++) { | 1245 | for(int i=0;i<nFiles+1;i++) { |
1244 | 1246 | ||
1245 | if( cfg.readEntry( QString::number(i),"").find( file,0,true) != -1) { | 1247 | if( cfg.readEntry( QString::number(i),"").find( file,0,true) != -1) { |
1246 | found = true; | 1248 | found = true; |
1247 | cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); | 1249 | cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); |
1248 | } | 1250 | } |
1249 | if(found) | 1251 | if(found) |
1250 | cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); | 1252 | cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); |
1251 | } | 1253 | } |
1252 | 1254 | ||
1253 | cfg.removeEntry( cfg.readEntry( file)); | 1255 | cfg.removeEntry( cfg.readEntry( file)); |
1254 | cfg.removeEntry( file); | 1256 | cfg.removeEntry( file); |
1255 | cfg.writeEntry( "NumberofFiles", nFiles-1); | 1257 | cfg.writeEntry( "NumberofFiles", nFiles-1); |
1256 | cfg.write(); | 1258 | cfg.write(); |
1257 | 1259 | ||
1258 | ListView1->takeItem( ListView1->currentItem() ); | 1260 | ListView1->takeItem( ListView1->currentItem() ); |
1259 | delete ListView1->currentItem(); | 1261 | delete ListView1->currentItem(); |
1260 | 1262 | ||
1261 | ListView1->clear(); | 1263 | ListView1->clear(); |
1262 | ListView1->setSelected( ListView1->firstChild(), true); | 1264 | ListView1->setSelected( ListView1->firstChild(), true); |
1263 | initIconView(); | 1265 | initIconView(); |
1264 | update(); | 1266 | update(); |
1265 | setCaption( tr( "OpieRecord " )); | 1267 | setCaption( tr( "OpieRecord " )); |
1266 | } | 1268 | } |
@@ -1410,5 +1412,5 @@ void QtRec::endRecording() { | |||
1410 | QString cmd; | 1412 | QString cmd; |
1411 | cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName); | 1413 | cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName); |
1412 | odebug << "moving tmp file to "+currentFileName << oendl; | 1414 | odebug << "moving tmp file to "+currentFileName << oendl; |
1413 | system( cmd.latin1()); | 1415 | system( cmd.latin1()); |
1414 | } | 1416 | } |
@@ -1430,5 +1432,5 @@ void QtRec::endRecording() { | |||
1430 | time.sprintf("%.2f", filePara.numberOfRecordedSeconds); | 1432 | time.sprintf("%.2f", filePara.numberOfRecordedSeconds); |
1431 | cfg.writeEntry( wavFile->currentFileName, time ); | 1433 | cfg.writeEntry( wavFile->currentFileName, time ); |
1432 | odebug << "writing config numberOfRecordedSeconds "+time << oendl; | 1434 | odebug << "writing config numberOfRecordedSeconds "+time << oendl; |
1433 | 1435 | ||
1434 | cfg.write(); | 1436 | cfg.write(); |
@@ -1484,8 +1486,8 @@ void QtRec::endPlaying() { | |||
1484 | 1486 | ||
1485 | bool QtRec::openPlayFile() { | 1487 | bool QtRec::openPlayFile() { |
1486 | 1488 | qWarning("opening file"); | |
1487 | qApp->processEvents(); | 1489 | qApp->processEvents(); |
1488 | if( currentFile.isEmpty()) { | 1490 | if( currentFile.isEmpty()) { |
1489 | QMessageBox::message(tr("Opierec"),tr("Please select file to play")); | 1491 | QMessageBox::message(tr("Opierec"),tr("Please select file to play")); |
1490 | endPlaying(); | 1492 | endPlaying(); |
1491 | return false; | 1493 | return false; |
@@ -1727,6 +1729,7 @@ void QtRec::compressionSelected(bool b) { | |||
1727 | 1729 | ||
1728 | if(b) { | 1730 | if(b) { |
1729 | bitRateComboBox->setEnabled( false); | 1731 | qWarning("set adpcm"); |
1730 | bitRateComboBox->setCurrentItem( 1); | 1732 | bitRateComboBox->setCurrentItem( 1); |
1733 | bitRateComboBox->setEnabled( false); | ||
1731 | filePara.resolution = 16; | 1734 | filePara.resolution = 16; |
1732 | } else{ | 1735 | } else{ |
@@ -1802,5 +1805,5 @@ void QtRec::timerEvent( QTimerEvent * ) { | |||
1802 | void QtRec::changeTimeSlider(int index) { | 1805 | void QtRec::changeTimeSlider(int index) { |
1803 | if( ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return; | 1806 | if( ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return; |
1804 | odebug << "Slider moved to " << index << "" << oendl; | 1807 | odebug << "Slider moved to " << index << "" << oendl; |
1805 | paused = true; | 1808 | paused = true; |
1806 | stopped = true; | 1809 | stopped = true; |
@@ -1817,5 +1820,5 @@ void QtRec::changeTimeSlider(int index) { | |||
1817 | void QtRec::timeSliderPressed() { | 1820 | void QtRec::timeSliderPressed() { |
1818 | if( ListView1->currentItem() == 0) return; | 1821 | if( ListView1->currentItem() == 0) return; |
1819 | odebug << "slider pressed" << oendl; | 1822 | odebug << "slider pressed" << oendl; |
1820 | paused = true; | 1823 | paused = true; |
1821 | stopped = true; | 1824 | stopped = true; |
@@ -1826,5 +1829,5 @@ void QtRec::timeSliderReleased() { | |||
1826 | sliderPos = timeSlider->value(); | 1829 | sliderPos = timeSlider->value(); |
1827 | 1830 | ||
1828 | odebug << "slider released " << sliderPos << "" << oendl; | 1831 | odebug << "slider released " << sliderPos << "" << oendl; |
1829 | stopped = false; | 1832 | stopped = false; |
1830 | int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); | 1833 | int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); |
@@ -1856,5 +1859,5 @@ void QtRec::rewindTimerTimeout() { | |||
1856 | // if(toBeginningButton->isDown()) | 1859 | // if(toBeginningButton->isDown()) |
1857 | timeSlider->setValue( sliderValue ) ; | 1860 | timeSlider->setValue( sliderValue ) ; |
1858 | odebug << "" << sliderValue << "" << oendl; | 1861 | odebug << "" << sliderValue << "" << oendl; |
1859 | QString timeString; | 1862 | QString timeString; |
1860 | filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2; | 1863 | filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2; |
@@ -1870,5 +1873,5 @@ void QtRec::rewindReleased() { | |||
1870 | int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); | 1873 | int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); |
1871 | total = newPos * 4; | 1874 | total = newPos * 4; |
1872 | odebug << "rewind released " << total << "" << oendl; | 1875 | odebug << "rewind released " << total << "" << oendl; |
1873 | startTimer( 1000); | 1876 | startTimer( 1000); |
1874 | doPlay(); | 1877 | doPlay(); |
diff --git a/noncore/multimedia/opierec/wavFile.cpp b/noncore/multimedia/opierec/wavFile.cpp index 80453e1..b53c416 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 | |||
28 | : QObject( parent) | 28 | : QObject( parent) |
29 | { | 29 | { |
30 | //odebug << "new wave file" << oendl; | 30 | owarn << "new wave file: " << fileName << oendl; |
31 | bool b = makeNwFile; | 31 | bool b = makeNwFile; |
32 | wavSampleRate=sampleRate; | 32 | wavSampleRate=sampleRate; |
@@ -110,18 +110,18 @@ void WavFile::closeFile() { | |||
110 | 110 | ||
111 | int WavFile::openFile(const QString ¤tFileName) { | 111 | int WavFile::openFile(const QString ¤tFileName) { |
112 | // odebug << "open play file "+currentFileName << oendl; | 112 | qWarning("open play file "+currentFileName);; |
113 | closeFile(); | 113 | closeFile(); |
114 | 114 | ||
115 | track.setName(currentFileName); | 115 | track.setName(currentFileName); |
116 | 116 | ||
117 | if(!track.open(IO_ReadOnly)) { | 117 | if(!track.open(IO_ReadOnly)) { |
118 | QString errorMsg=(QString)strerror(errno); | 118 | QString errorMsg=(QString)strerror(errno); |
119 | odebug << "<<<<<<<<<<< "+errorMsg+currentFileName << oendl; | 119 | odebug << "<<<<<<<<<<< "+errorMsg+currentFileName << oendl; |
120 | QMessageBox::message("Note", "Error opening file.\n" +errorMsg); | 120 | QMessageBox::message("Note", "Error opening file.\n" +errorMsg); |
121 | return -1; | 121 | return -1; |
122 | } else { | 122 | } else { |
123 | parseWavHeader( track.handle()); | 123 | parseWavHeader( track.handle()); |
124 | } | 124 | } |
125 | return track.handle(); | 125 | return track.handle(); |
126 | } | 126 | } |
127 | 127 | ||
@@ -153,5 +153,5 @@ bool WavFile::setWavHeader(int fd, wavhdr *hdr) { | |||
153 | 153 | ||
154 | write( fd,hdr, sizeof(*hdr)); | 154 | write( fd,hdr, sizeof(*hdr)); |
155 | odebug << "writing header: bitrate " << wavResolution << ", samplerate " << wavSampleRate << ", channels " << wavChannels << oendl; | 155 | owarn << "writing header: bitrate " << wavResolution << ", samplerate " << wavSampleRate << ", channels " << wavChannels << oendl; |
156 | return true; | 156 | return true; |
157 | } | 157 | } |
@@ -163,10 +163,10 @@ bool WavFile::adjustHeaders(int fd, int total) { | |||
163 | lseek( fd, 40, SEEK_SET); | 163 | lseek( fd, 40, SEEK_SET); |
164 | write( fd, &total, sizeof(total)); | 164 | write( fd, &total, sizeof(total)); |
165 | odebug << "adjusting header " << total << "" << oendl; | 165 | owarn << "adjusting header " << total << "" << oendl; |
166 | return true; | 166 | return true; |
167 | } | 167 | } |
168 | 168 | ||
169 | int WavFile::parseWavHeader(int fd) { | 169 | int WavFile::parseWavHeader(int fd) { |
170 | odebug << "Parsing wav header" << oendl; | 170 | owarn << "Parsing wav header" << oendl; |
171 | char string[4]; | 171 | char string[4]; |
172 | int found; | 172 | int found; |
@@ -176,18 +176,18 @@ int WavFile::parseWavHeader(int fd) { | |||
176 | 176 | ||
177 | if (read(fd, string, 4) < 4) { | 177 | if (read(fd, string, 4) < 4) { |
178 | odebug << " Could not read from sound file." << oendl; | 178 | owarn << " Could not read from sound file." << oendl; |
179 | return -1; | 179 | return -1; |
180 | } | 180 | } |
181 | if (strncmp(string, "RIFF", 4)) { | 181 | if (strncmp(string, "RIFF", 4)) { |
182 | odebug << " not a valid WAV file." << oendl; | 182 | owarn << " not a valid WAV file." << oendl; |
183 | return -1; | 183 | return -1; |
184 | } | 184 | } |
185 | lseek(fd, 4, SEEK_CUR); | 185 | lseek(fd, 4, SEEK_CUR); |
186 | if (read(fd, string, 4) < 4) { | 186 | if (read(fd, string, 4) < 4) { |
187 | odebug << "Could not read from sound file." << oendl; | 187 | owarn << "Could not read from sound file." << oendl; |
188 | return -1; | 188 | return -1; |
189 | } | 189 | } |
190 | if (strncmp(string, "WAVE", 4)) { | 190 | if (strncmp(string, "WAVE", 4)) { |
191 | odebug << "not a valid WAV file." << oendl; | 191 | owarn << "not a valid WAV file." << oendl; |
192 | return -1; | 192 | return -1; |
193 | } | 193 | } |
@@ -196,10 +196,10 @@ int WavFile::parseWavHeader(int fd) { | |||
196 | while (!found) { | 196 | while (!found) { |
197 | if (read(fd, string, 4) < 4) { | 197 | if (read(fd, string, 4) < 4) { |
198 | odebug << "Could not read from sound file." << oendl; | 198 | owarn << "Could not read from sound file." << oendl; |
199 | return -1; | 199 | return -1; |
200 | } | 200 | } |
201 | if (strncmp(string, "fmt ", 4)) { | 201 | if (strncmp(string, "fmt ", 4)) { |
202 | if (read(fd, &longdata, 4) < 4) { | 202 | if (read(fd, &longdata, 4) < 4) { |
203 | odebug << "Could not read from sound file." << oendl; | 203 | owarn << "Could not read from sound file." << oendl; |
204 | return -1; | 204 | return -1; |
205 | } | 205 | } |
@@ -208,37 +208,37 @@ int WavFile::parseWavHeader(int fd) { | |||
208 | lseek(fd, 4, SEEK_CUR); | 208 | lseek(fd, 4, SEEK_CUR); |
209 | if (read(fd, &fmt, 2) < 2) { | 209 | if (read(fd, &fmt, 2) < 2) { |
210 | odebug << "Could not read format chunk." << oendl; | 210 | owarn << "Could not read format chunk." << oendl; |
211 | return -1; | 211 | return -1; |
212 | } | 212 | } |
213 | if (fmt != WAVE_FORMAT_PCM && fmt != WAVE_FORMAT_DVI_ADPCM) { | 213 | if (fmt != WAVE_FORMAT_PCM && fmt != WAVE_FORMAT_DVI_ADPCM) { |
214 | odebug << "Wave file contains unknown format. Unable to continue." << oendl; | 214 | owarn << "Wave file contains unknown format. Unable to continue." << oendl; |
215 | return -1; | 215 | return -1; |
216 | } | 216 | } |
217 | wavFormat = fmt; | 217 | wavFormat = fmt; |
218 | // compressionFormat=fmt; | 218 | // compressionFormat=fmt; |
219 | odebug << "compressionFormat is " << fmt << "" << oendl; | 219 | owarn << "compressionFormat is " << fmt << "" << oendl; |
220 | if (read(fd, &ch, 2) < 2) { | 220 | if (read(fd, &ch, 2) < 2) { |
221 | odebug << "Could not read format chunk." << oendl; | 221 | owarn << "Could not read format chunk." << oendl; |
222 | return -1; | 222 | return -1; |
223 | } else { | 223 | } else { |
224 | wavChannels = ch; | 224 | wavChannels = ch; |
225 | odebug << "File has " << ch << " channels" << oendl; | 225 | owarn << "File has " << ch << " channels" << oendl; |
226 | } | 226 | } |
227 | if (read(fd, &samplerrate, 4) < 4) { | 227 | if (read(fd, &samplerrate, 4) < 4) { |
228 | odebug << "Could not read from format chunk." << oendl; | 228 | owarn << "Could not read from format chunk." << oendl; |
229 | return -1; | 229 | return -1; |
230 | } else { | 230 | } else { |
231 | wavSampleRate = samplerrate; | 231 | wavSampleRate = samplerrate; |
232 | // sampleRate = samplerrate; | 232 | // sampleRate = samplerrate; |
233 | odebug << "File has samplerate of " << (int) samplerrate << "" << oendl; | 233 | owarn << "File has samplerate of " << (int) samplerrate << "" << oendl; |
234 | } | 234 | } |
235 | lseek(fd, 6, SEEK_CUR); | 235 | lseek(fd, 6, SEEK_CUR); |
236 | if (read(fd, &bitrate, 2) < 2) { | 236 | if (read(fd, &bitrate, 2) < 2) { |
237 | odebug << "Could not read format chunk." << oendl; | 237 | owarn << "Could not read format chunk." << oendl; |
238 | return -1; | 238 | return -1; |
239 | } else { | 239 | } else { |
240 | wavResolution=bitrate; | 240 | wavResolution=bitrate; |
241 | // resolution = bitrate; | 241 | // resolution = bitrate; |
242 | odebug << "File has bitrate of " << bitrate << "" << oendl; | 242 | owarn << "File has bitrate of " << bitrate << "" << oendl; |
243 | } | 243 | } |
244 | found++; | 244 | found++; |