author | llornkcor <llornkcor> | 2002-06-23 03:12:26 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-06-23 03:12:26 (UTC) |
commit | f3aa76578638116c92652e37b57075850ee17dd3 (patch) (side-by-side diff) | |
tree | af09f06e462b156ab9c8dc2e7ddfcaf673a74cf7 | |
parent | 8c65ca19eb339c08fc16752697276b7e80794f2d (diff) | |
download | opie-f3aa76578638116c92652e37b57075850ee17dd3.zip opie-f3aa76578638116c92652e37b57075850ee17dd3.tar.gz opie-f3aa76578638116c92652e37b57075850ee17dd3.tar.bz2 |
error checking
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 69 | ||||
-rw-r--r-- | core/applets/vmemo/vmemo.pro | 2 | ||||
-rw-r--r-- | core/applets/vmemo/vmemoimpl.cpp | 0 |
3 files changed, 58 insertions, 13 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index 7021fae..e25a1ab 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp @@ -223,2 +223,3 @@ VMemo::VMemo( QWidget *parent, const char *_name ) if( toggleKey != -1 ) { + // QPEApplication::grabKeyboard(); QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); @@ -230,4 +231,4 @@ VMemo::VMemo( QWidget *parent, const char *_name ) } - if( vmCfg.readNumEntry("hideIcon",0) == 1 || toggleKey > 0) - hide(); + // if( vmCfg.readNumEntry("hideIcon",0) == 1 || toggleKey > 0) + // hide(); } @@ -289,9 +290,11 @@ bool VMemo::startRecording() { // } else { - if (!systemZaurus ) - QSound::play(Resource::findSound("vmemob")); + // if (!systemZaurus ) + // QSound::play(Resource::findSound("vmemob")); // } - qDebug("Start recording"); + qDebug("Start recording engines"); recording = TRUE; + if (openDSP() == -1) { - QMessageBox::critical(0, "vmemo", "Could not open dsp device.\n"+errorMsg, "Abort"); + // QMessageBox::critical(0, "vmemo", "Could not open dsp device.\n"+errorMsg, "Abort"); + // delete msgLabel; recording = FALSE; @@ -329,5 +332,5 @@ bool VMemo::startRecording() { if(openWAV(fileName.latin1()) == -1) { - QString err("Could not open the output file\n"); - err += fileName; - QMessageBox::critical(0, "vmemo", err, "Abort"); + // QString err("Could not open the output file\n"); + // err += fileName; + // QMessageBox::critical(0, "vmemo", err, "Abort"); close(dsp); @@ -350,2 +353,3 @@ bool VMemo::startRecording() { record(); + // delete msgLabel; return TRUE; @@ -386,2 +390,3 @@ int VMemo::openDSP() errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); + QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); return -1; @@ -449,3 +454,7 @@ void VMemo::record(void) if(systemZaurus) { + + msg.sprintf("Recording format zaurus"); + qDebug(msg); signed short sound[512], monoBuffer[512]; + if(format==AFMT_S16_LE) { @@ -463,2 +472,4 @@ void VMemo::record(void) length+=write(wav, monoBuffer, result); + if(length<0) + recording=false; @@ -466,4 +477,7 @@ void VMemo::record(void) + for (int i = 0; i < result; i+=2) { - monoBuffer[j] = (sound[i]+sound[i+1])/2; +/ monoBuffer[j] = sound[i]; + // monoBuffer[j] = (sound[i]+sound[i+1])/2; + j++; @@ -471,3 +485,6 @@ void VMemo::record(void) - length+=write(wav, monoBuffer, result/2); + length+=write(wav, monoBuffer, result); + if(length<0) + recording=false; + // length+=write(wav, monoBuffer, result/2); } @@ -477,2 +494,3 @@ void VMemo::record(void) } + } else { //AFMT_U8 @@ -483,3 +501,5 @@ void VMemo::record(void) int j=0; + if(systemZaurus) { + for (int i = 0; i < result; i++) { //since Z is mono do normally @@ -487,4 +507,7 @@ void VMemo::record(void) } + length+=write(wav, monoBuffer, result); + } else { //ipaq /stereo inputs + for (int i = 0; i < result; i+=2) { @@ -493,3 +516,8 @@ void VMemo::record(void) } + length+=write(wav, monoBuffer, result/2); + + if(length<0) + recording=false; + } @@ -505,2 +533,5 @@ void VMemo::record(void) + msg.sprintf("Recording format other"); + qDebug(msg); + signed short sound[512], monoBuffer[512]; @@ -508,7 +539,12 @@ void VMemo::record(void) while(recording) { + result = read(dsp, sound, 512); // 8192 + write(wav, sound, result); length += result; + if(length<0) { - qApp->processEvents(); + recording=false; + perror("dev/dsp's is a lookin' messy"); + QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); } @@ -516,2 +552,4 @@ void VMemo::record(void) // fflush(stdout); + qApp->processEvents(); + } // qDebug("file has length of %d lasting %d seconds", @@ -521,3 +559,6 @@ void VMemo::record(void) + //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<// + value = length+36; + lseek(wav, 4, SEEK_SET); @@ -525,4 +566,7 @@ void VMemo::record(void) lseek(wav, 40, SEEK_SET); + write(wav, &length, 4); + track.close(); + qDebug("Tracvk closed"); @@ -530,2 +574,3 @@ void VMemo::record(void) perror("ioctl(\"SNDCTL_DSP_RESET\")"); + ::close(dsp); diff --git a/core/applets/vmemo/vmemo.pro b/core/applets/vmemo/vmemo.pro index 298d989..734cf5c 100644 --- a/core/applets/vmemo/vmemo.pro +++ b/core/applets/vmemo/vmemo.pro @@ -7,3 +7,3 @@ DESTDIR =$(OPIEDIR)/plugins/applets INCLUDEPATH += $(OPIEDIR)/include -DEPENDPATH += ../$(OPIEDIR)/include +DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe diff --git a/core/applets/vmemo/vmemoimpl.cpp b/core/applets/vmemo/vmemoimpl.cpp index 9e6c7cd..ef4a3a6 100644 --- a/core/applets/vmemo/vmemoimpl.cpp +++ b/core/applets/vmemo/vmemoimpl.cpp |