summaryrefslogtreecommitdiff
path: root/core
authorllornkcor <llornkcor>2002-06-23 03:12:26 (UTC)
committer llornkcor <llornkcor>2002-06-23 03:12:26 (UTC)
commitf3aa76578638116c92652e37b57075850ee17dd3 (patch) (side-by-side diff)
treeaf09f06e462b156ab9c8dc2e7ddfcaf673a74cf7 /core
parent8c65ca19eb339c08fc16752697276b7e80794f2d (diff)
downloadopie-f3aa76578638116c92652e37b57075850ee17dd3.zip
opie-f3aa76578638116c92652e37b57075850ee17dd3.tar.gz
opie-f3aa76578638116c92652e37b57075850ee17dd3.tar.bz2
error checking
Diffstat (limited to 'core') (more/less context) (show whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp69
-rw-r--r--core/applets/vmemo/vmemo.pro2
-rw-r--r--core/applets/vmemo/vmemoimpl.cpp0
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
@@ -221,6 +221,7 @@ VMemo::VMemo( QWidget *parent, const char *_name )
this, SLOT(receive(const QCString&, const QByteArray&)) );
if( toggleKey != -1 ) {
+ // QPEApplication::grabKeyboard();
QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)");
// e << 4096; // Key_Escape
// e << Key_F5; //4148
@@ -228,8 +229,8 @@ VMemo::VMemo( QWidget *parent, const char *_name )
e << QString("QPE/VMemo");
e << QString("toggleRecord()");
}
- if( vmCfg.readNumEntry("hideIcon",0) == 1 || toggleKey > 0)
- hide();
+ // if( vmCfg.readNumEntry("hideIcon",0) == 1 || toggleKey > 0)
+ // hide();
}
}
@@ -287,13 +288,15 @@ bool VMemo::startRecording() {
// QMessageBox::message("VMemo","Really Record?");//) ==1)
// return;
// } 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;
return FALSE;
}
@@ -327,9 +330,9 @@ bool VMemo::startRecording() {
fileName.replace(QRegExp(","),"");
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);
return FALSE;
}
@@ -348,6 +351,7 @@ bool VMemo::startRecording() {
record();
+ // delete msgLabel;
return TRUE;
}
@@ -384,6 +388,7 @@ int VMemo::openDSP()
if(dsp == -1) {
perror("open(\"/dev/dsp\")");
errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno);
+ QMessageBox::critical(0, "vmemo", errorMsg, "Abort");
return -1;
}
@@ -447,7 +452,11 @@ void VMemo::record(void)
qDebug(msg);
if(systemZaurus) {
+
+ msg.sprintf("Recording format zaurus");
+ qDebug(msg);
signed short sound[512], monoBuffer[512];
+
if(format==AFMT_S16_LE) {
while(recording) {
@@ -461,37 +470,56 @@ void VMemo::record(void)
}
length+=write(wav, monoBuffer, result);
+ if(length<0)
+ recording=false;
} else { //ipaq /stereo inputs
+
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++;
}
- length+=write(wav, monoBuffer, result/2);
+ length+=write(wav, monoBuffer, result);
+ if(length<0)
+ recording=false;
+ // length+=write(wav, monoBuffer, result/2);
}
qApp->processEvents();
// printf("%d\r",length);
// fflush(stdout);
}
+
} else { //AFMT_U8
// 8bit unsigned
unsigned short sound[512], monoBuffer[512];
while(recording) {
result = read(dsp, sound, 512); // 8192
int j=0;
+
if(systemZaurus) {
+
for (int i = 0; i < result; i++) { //since Z is mono do normally
monoBuffer[i] = sound[i];
}
+
length+=write(wav, monoBuffer, result);
+
} else { //ipaq /stereo inputs
+
for (int i = 0; i < result; i+=2) {
monoBuffer[j] = (sound[i]+sound[i+1])/2;
j++;
}
+
length+=write(wav, monoBuffer, result/2);
+
+ if(length<0)
+ recording=false;
+
}
length += result;
// printf("%d\r",length);
@@ -503,31 +531,48 @@ void VMemo::record(void)
} else { // this is specific for ipaqs that do not have 8 bit capabilities
+ msg.sprintf("Recording format other");
+ qDebug(msg);
+
signed short sound[512], monoBuffer[512];
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);
}
// printf("%d\r",length);
// fflush(stdout);
+ qApp->processEvents();
+ }
// qDebug("file has length of %d lasting %d seconds",
// length, (( length / speed) / channels) / 2 );
// medialplayer states wrong length in secs
}
+ //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<//
+
value = length+36;
+
lseek(wav, 4, SEEK_SET);
write(wav, &value, 4);
lseek(wav, 40, SEEK_SET);
+
write(wav, &length, 4);
+
track.close();
+ qDebug("Tracvk closed");
if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1)
perror("ioctl(\"SNDCTL_DSP_RESET\")");
+
::close(dsp);
fileName = fileName.left(fileName.length()-4);
// if(useAlerts)
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
@@ -5,7 +5,7 @@ SOURCES = vmemo.cpp vmemoimpl.cpp
TARGET = vmemoapplet
DESTDIR =$(OPIEDIR)/plugins/applets
INCLUDEPATH += $(OPIEDIR)/include
-DEPENDPATH += ../$(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe
VERSION = 1.0.0
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