summaryrefslogtreecommitdiff
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
parent8c65ca19eb339c08fc16752697276b7e80794f2d (diff)
downloadopie-f3aa76578638116c92652e37b57075850ee17dd3.zip
opie-f3aa76578638116c92652e37b57075850ee17dd3.tar.gz
opie-f3aa76578638116c92652e37b57075850ee17dd3.tar.bz2
error checking
Diffstat (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
@@ -220,17 +220,18 @@ VMemo::VMemo( QWidget *parent, const char *_name )
connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)),
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
e << toggleKey;
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();
}
}
VMemo::~VMemo()
@@ -286,15 +287,17 @@ bool VMemo::startRecording() {
// if(useAlerts)
// 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;
}
@@ -326,11 +329,11 @@ bool VMemo::startRecording() {
fileName.replace(QRegExp(":"),".");
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;
}
@@ -347,8 +350,9 @@ bool VMemo::startRecording() {
l.writeLink();
record();
+ // delete msgLabel;
return TRUE;
}
void VMemo::stopRecording() {
@@ -383,8 +387,9 @@ 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;
}
if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) {
@@ -446,9 +451,13 @@ void VMemo::record(void)
msg.sprintf("Recording format %d", format);
qDebug(msg);
if(systemZaurus) {
+
+ msg.sprintf("Recording format zaurus");
+ qDebug(msg);
signed short sound[512], monoBuffer[512];
+
if(format==AFMT_S16_LE) {
while(recording) {
@@ -460,39 +469,58 @@ void VMemo::record(void)
monoBuffer[i] = sound[i];
}
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);
// fflush(stdout);
@@ -502,33 +530,50 @@ 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)
// QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName);
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
@@ -4,9 +4,9 @@ HEADERS = vmemo.h vmemoimpl.h
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
TRANSLATIONS = ../../i18n/pt_BR/libvmemoapplet.ts
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