-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 | 21 | ||||
-rw-r--r-- | noncore/multimedia/opierec/wavFile.cpp | 40 |
4 files changed, 43 insertions, 35 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 ) if( !record){ //playing - owarn << "setting up DSP for playing" << oendl; - flags = O_WRONLY; + owarn << "New Sound device DSP for playing" << oendl; + flags = O_RDWR; +// flags = O_WRONLY; } else { //recording - owarn << "setting up DSP for recording" << oendl; + owarn << "New Sound device DSP for recording" << oendl; flags = O_RDWR; // flags = O_RDONLY; @@ -70,4 +71,5 @@ Device::Device( QObject * parent, bool record ) bool Device::openDsp() { + qWarning("Device::openDsp()"); if( openDevice( flags) == -1) { perror("<<<<<<<<<<<<<<ioctl(\"Open device\")"); @@ -78,8 +80,8 @@ bool Device::openDsp() { int Device::openDevice( int flags) { - owarn << "Opening"<< dspstr; + owarn << "Opening sound device:"<< DSPSTROUT << oendl; - if (( sd = ::open( DSPSTROUT, flags)) == -1) { - perror("open(\"/dev/dsp\")"); + if (( sd = ::open( DSPSTROUT, O_RDWR)) == -1) { + perror("open(\"/dev/dsp\")\n"); QString errorMsg="Could not open audio device\n /dev/dsp\n" +(QString)strerror(errno); @@ -91,4 +93,5 @@ int Device::openDevice( int flags) { perror("ioctl RESET"); } + qWarning("opened!"); return sd; } @@ -151,4 +154,5 @@ bool Device::selectMicInput() { bool Device::closeDevice( bool) { + if(sd) ::close( sd); //close sound device 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) { DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopiecore2 -lpthread + DEFINES += THREADED TARGET = opierec 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 @@ -157,5 +157,5 @@ void quickRec() adpcm_coder( sbuf, abuf, number/2, &encoder_state); - bytesWritten = ::write( filePara.fd , (short *)abuf, number/4); + bytesWritten = ::write( filePara.fd , abuf, number/4); waveform->newSamples( sbuf, number ); @@ -168,5 +168,5 @@ void quickRec() fflush(stdout); - filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2 / filePara.channels; + filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2;// / filePara.channels; qApp->processEvents(); @@ -302,6 +302,8 @@ void playIt() // sbuf2[i+1]=sbuf2[i]=sbuf[i]; // } - bytesWritten = write ( filePara.sd, sbuf, number * 4); - waveform->newSamples( (const short *)sbuf, number *4); + bytesWritten = write ( soundDevice->sd , sbuf, number * 4); + + waveform->newSamples( sbuf, number ); + // if(filePara.channels==1) // total += bytesWritten/2; //mono @@ -343,5 +345,5 @@ void playIt() // outbuffer[i+1]= outbuffer[i]=inbuffer[i]; // } - bytesWritten = ::write( filePara.sd, inbuffer, number); + bytesWritten = ::write( soundDevice->sd, inbuffer, number); waveform->newSamples( inbuffer, number); //-------------->>>> out to device @@ -789,6 +791,6 @@ void QtRec::initConfig() { compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); if( compressionCheckBox->isChecked()) { + bitRateComboBox->setCurrentItem(1); bitRateComboBox->setEnabled(false); - bitRateComboBox->setCurrentItem(0); filePara.resolution=16; } @@ -1049,5 +1051,5 @@ bool QtRec::setupAudio( bool b) { // if(soundDevice) delete soundDevice; - odebug << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl; + owarn << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl; // owarn << "change waveform settings" << oendl; waveform->changeSettings( filePara.sampleRate, filePara.channels ); @@ -1484,5 +1486,5 @@ void QtRec::endPlaying() { bool QtRec::openPlayFile() { - + qWarning("opening file"); qApp->processEvents(); if( currentFile.isEmpty()) { @@ -1727,6 +1729,7 @@ void QtRec::compressionSelected(bool b) { if(b) { - bitRateComboBox->setEnabled( false); + qWarning("set adpcm"); bitRateComboBox->setCurrentItem( 1); + bitRateComboBox->setEnabled( false); filePara.resolution = 16; } else{ 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 : QObject( parent) { -//odebug << "new wave file" << oendl; + owarn << "new wave file: " << fileName << oendl; bool b = makeNwFile; wavSampleRate=sampleRate; @@ -110,5 +110,5 @@ void WavFile::closeFile() { int WavFile::openFile(const QString ¤tFileName) { -// odebug << "open play file "+currentFileName << oendl; + qWarning("open play file "+currentFileName);; closeFile(); @@ -153,5 +153,5 @@ bool WavFile::setWavHeader(int fd, wavhdr *hdr) { write( fd,hdr, sizeof(*hdr)); - odebug << "writing header: bitrate " << wavResolution << ", samplerate " << wavSampleRate << ", channels " << wavChannels << oendl; + owarn << "writing header: bitrate " << wavResolution << ", samplerate " << wavSampleRate << ", channels " << wavChannels << oendl; return true; } @@ -163,10 +163,10 @@ bool WavFile::adjustHeaders(int fd, int total) { lseek( fd, 40, SEEK_SET); write( fd, &total, sizeof(total)); - odebug << "adjusting header " << total << "" << oendl; + owarn << "adjusting header " << total << "" << oendl; return true; } int WavFile::parseWavHeader(int fd) { - odebug << "Parsing wav header" << oendl; + owarn << "Parsing wav header" << oendl; char string[4]; int found; @@ -176,18 +176,18 @@ int WavFile::parseWavHeader(int fd) { if (read(fd, string, 4) < 4) { - odebug << " Could not read from sound file." << oendl; + owarn << " Could not read from sound file." << oendl; return -1; } if (strncmp(string, "RIFF", 4)) { - odebug << " not a valid WAV file." << oendl; + owarn << " not a valid WAV file." << oendl; return -1; } lseek(fd, 4, SEEK_CUR); if (read(fd, string, 4) < 4) { - odebug << "Could not read from sound file." << oendl; + owarn << "Could not read from sound file." << oendl; return -1; } if (strncmp(string, "WAVE", 4)) { - odebug << "not a valid WAV file." << oendl; + owarn << "not a valid WAV file." << oendl; return -1; } @@ -196,10 +196,10 @@ int WavFile::parseWavHeader(int fd) { while (!found) { if (read(fd, string, 4) < 4) { - odebug << "Could not read from sound file." << oendl; + owarn << "Could not read from sound file." << oendl; return -1; } if (strncmp(string, "fmt ", 4)) { if (read(fd, &longdata, 4) < 4) { - odebug << "Could not read from sound file." << oendl; + owarn << "Could not read from sound file." << oendl; return -1; } @@ -208,37 +208,37 @@ int WavFile::parseWavHeader(int fd) { lseek(fd, 4, SEEK_CUR); if (read(fd, &fmt, 2) < 2) { - odebug << "Could not read format chunk." << oendl; + owarn << "Could not read format chunk." << oendl; return -1; } if (fmt != WAVE_FORMAT_PCM && fmt != WAVE_FORMAT_DVI_ADPCM) { - odebug << "Wave file contains unknown format. Unable to continue." << oendl; + owarn << "Wave file contains unknown format. Unable to continue." << oendl; return -1; } wavFormat = fmt; // compressionFormat=fmt; - odebug << "compressionFormat is " << fmt << "" << oendl; + owarn << "compressionFormat is " << fmt << "" << oendl; if (read(fd, &ch, 2) < 2) { - odebug << "Could not read format chunk." << oendl; + owarn << "Could not read format chunk." << oendl; return -1; } else { wavChannels = ch; - odebug << "File has " << ch << " channels" << oendl; + owarn << "File has " << ch << " channels" << oendl; } if (read(fd, &samplerrate, 4) < 4) { - odebug << "Could not read from format chunk." << oendl; + owarn << "Could not read from format chunk." << oendl; return -1; } else { wavSampleRate = samplerrate; // sampleRate = samplerrate; - odebug << "File has samplerate of " << (int) samplerrate << "" << oendl; + owarn << "File has samplerate of " << (int) samplerrate << "" << oendl; } lseek(fd, 6, SEEK_CUR); if (read(fd, &bitrate, 2) < 2) { - odebug << "Could not read format chunk." << oendl; + owarn << "Could not read format chunk." << oendl; return -1; } else { wavResolution=bitrate; // resolution = bitrate; - odebug << "File has bitrate of " << bitrate << "" << oendl; + owarn << "File has bitrate of " << bitrate << "" << oendl; } found++; |