summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-04-20 14:19:26 (UTC)
committer llornkcor <llornkcor>2002-04-20 14:19:26 (UTC)
commit90c114cefd8d8675fa3992b5049d01a14eb7712c (patch) (unidiff)
tree779366706fbabc90e5efcd88e54c6e7c6f7e6bfd
parent0850b6d2e7908e66c8a14eb3e7fafcc63e0b800c (diff)
downloadopie-90c114cefd8d8675fa3992b5049d01a14eb7712c.zip
opie-90c114cefd8d8675fa3992b5049d01a14eb7712c.tar.gz
opie-90c114cefd8d8675fa3992b5049d01a14eb7712c.tar.bz2
more informative error messages
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp116
-rw-r--r--core/applets/vmemo/vmemo.h1
2 files changed, 70 insertions, 47 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index 4d4d598..4c55dc7 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -27,2 +27,4 @@
27#include <stdlib.h> 27#include <stdlib.h>
28#include <errno.h>
29#include <string.h>
28 30
@@ -208,11 +210,11 @@ VMemo::VMemo( QWidget *parent, const char *_name )
208 systemZaurus=FALSE; 210 systemZaurus=FALSE;
209 myChannel = new QCopChannel( "QPE/VMemo", this ); 211 myChannel = new QCopChannel( "QPE/VMemo", this );
210 connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), 212 connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)),
211 this, SLOT(receive(const QCString&, const QByteArray&)) ); 213 this, SLOT(receive(const QCString&, const QByteArray&)) );
212 214
213// // Register the REC key press, for ipaq only 215// // Register the REC key press, for ipaq only
214 QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); 216 QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)");
215 e << 4096; 217 e << 4096;
216 e << QString("QPE/VMemo"); 218 e << QString("QPE/VMemo");
217 e << QString("toggleRecord()"); 219 e << QString("toggleRecord()");
218 } 220 }
@@ -254,11 +256,11 @@ void VMemo::mousePressEvent( QMouseEvent *me )
254 */ 256 */
255 if (!systemZaurus && me != NULL) 257 if (!systemZaurus && me != NULL)
256 return; 258 return;
257 259
258// Config config( "Sound" ); 260 Config config( "Sound" );
259// config.setGroup( "System" ); 261 config.setGroup( "System" );
260// useAlerts = config.readBoolEntry("Alert"); 262 useAlerts = config.readBoolEntry("Alert");
261 263
262// if(useAlerts) { 264// if(useAlerts)
263// if( QMessageBox::warning(this,"VMemo","Really Record?","Yes","No",0,0,1) ==1) 265// QMessageBox::message("VMemo","Really Record?");//) ==1)
264// return; 266// return;
@@ -270,3 +272,3 @@ void VMemo::mousePressEvent( QMouseEvent *me )
270 if (openDSP() == -1) { 272 if (openDSP() == -1) {
271 QMessageBox::critical(0, "VMemo", "Could not open dsp device.", "Abort"); 273 QMessageBox::critical(0, "VMemo", "Could not open dsp device.\n"+errorMsg, "Abort");
272 recording = FALSE; 274 recording = FALSE;
@@ -279,13 +281,26 @@ void VMemo::mousePressEvent( QMouseEvent *me )
279 QDateTime dt = QDateTime::currentDateTime(); 281 QDateTime dt = QDateTime::currentDateTime();
280 QString fileName;
281 282
282 if(systemZaurus) 283 QString fName;
283 fileName=vmCfg.readEntry("Dir", "/mnt/cf/"); // zaurus does not have /mnt/ramfs 284 Config cfg( "Sound" );
284 else 285 cfg.setGroup( "System" );
285 fileName=vmCfg.readEntry("Dir", "/mnt/ramfs/"); 286 fileName = cfg.readEntry("RecLocation",QPEApplication::documentDir() );
286 287
287 fileName += "vm_"; 288 int s;
288 fileName += dt.toString(); 289 s=fileName.find(':');
289 fileName += ".wav"; 290 if(s)
291 fileName=fileName.right(fileName.length()-s-2)+"/";
292
293// if( !fileName.right(1).find('/') == -1)
294// fileName+="/audio/";
295// else
296// fileName+="audio/";
297
298// if(systemZaurus)
299// fileName=vmCfg.readEntry("Dir", "/mnt/cf/"); // zaurus does not have /mnt/ramfs
300// else
301// fileName=vmCfg.readEntry("Dir", "/mnt/ramfs/");
290 302
303 fName = "vm_"+ dt.toString()+ ".wav";
304 fileName+=fName;
305 qDebug("filename is "+fileName);
291 // No spaces in the filename 306 // No spaces in the filename
@@ -297,5 +312,4 @@ void VMemo::mousePressEvent( QMouseEvent *me )
297 if(openWAV(fileName.latin1()) == -1) { 312 if(openWAV(fileName.latin1()) == -1) {
298 QString err("Could not open the output file: "); 313 QString err("Could not open the output file\n");
299 err += fileName; 314 err += fileName;
300
301 QMessageBox::critical(0, "VMemo", err, "Abort"); 315 QMessageBox::critical(0, "VMemo", err, "Abort");
@@ -336,6 +350,7 @@ int VMemo::openDSP()
336 } else { 350 } else {
337 format = AFMT_S8; 351 format = AFMT_U8;
338 resolution = 8; 352 resolution = 8;
339 } 353 }
340 354
355 qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution);
341 356
@@ -350,2 +365,4 @@ int VMemo::openDSP()
350 perror("open(\"/dev/dsp\")"); 365 perror("open(\"/dev/dsp\")");
366
367 errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno);
351 return -1; 368 return -1;
@@ -355,2 +372,3 @@ int VMemo::openDSP()
355 perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); 372 perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
373 errorMsg="ioctl(\"SNDCTL_DSP_SETFMT\")\n%d\n"+(QString)strerror(errno),format;
356 return -1; 374 return -1;
@@ -359,2 +377,3 @@ int VMemo::openDSP()
359 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); 377 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")");
378 errorMsg="ioctl(\"SNDCTL_DSP_CHANNELS\")\n%d\n"+(QString)strerror(errno),channels;
360 return -1; 379 return -1;
@@ -363,2 +382,3 @@ int VMemo::openDSP()
363 perror("ioctl(\"SNDCTL_DSP_SPEED\")"); 382 perror("ioctl(\"SNDCTL_DSP_SPEED\")");
383 errorMsg="ioctl(\"SNDCTL_DSP_SPEED\")\n%d\n"+(QString)strerror(errno),speed;
364 return -1; 384 return -1;
@@ -367,2 +387,3 @@ int VMemo::openDSP()
367 perror("ioctl(\"SOUND_PCM_READ_RATE\")"); 387 perror("ioctl(\"SOUND_PCM_READ_RATE\")");
388 errorMsg="ioctl(\"SOUND_PCM_READ_RATE\")\n%d\n"+(QString)strerror(errno),rate;
368 return -1; 389 return -1;
@@ -376,4 +397,6 @@ int VMemo::openWAV(const char *filename)
376 track.setName(filename); 397 track.setName(filename);
377 if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) 398 if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) {
399 errorMsg=filename;
378 return -1; 400 return -1;
401 }
379 402
@@ -432,3 +455,3 @@ void VMemo::record(void)
432 } 455 }
433 } else { //AFMT_S8 456 } else { //AFMT_U8
434// 8bit unsigned 457// 8bit unsigned
@@ -440,15 +463,15 @@ void VMemo::record(void)
440 if(systemZaurus) { 463 if(systemZaurus) {
441 for (int i = 0; i < result; i++) { //since Z is mono do normally 464 for (int i = 0; i < result; i++) { //since Z is mono do normally
442 monoBuffer[i] = sound[i]; 465 monoBuffer[i] = sound[i];
443 } 466 }
444 qApp->processEvents(); 467 qApp->processEvents();
445 length+=write(wav, monoBuffer, result); 468 length+=write(wav, monoBuffer, result);
446 } else { //ipaq /stereo inputs 469 } else { //ipaq /stereo inputs
447 for (int i = 0; i < result; i+=2) { 470 for (int i = 0; i < result; i+=2) {
448 monoBuffer[j] = (sound[i]+sound[i+1])/2; 471 monoBuffer[j] = (sound[i]+sound[i+1])/2;
449 j++; 472 j++;
450 } 473 }
451 qApp->processEvents(); 474 qApp->processEvents();
452 length+=write(wav, monoBuffer, result/2); 475 length+=write(wav, monoBuffer, result/2);
453 } 476 }
454 length += result; 477 length += result;
@@ -493,6 +516,5 @@ void VMemo::record(void)
493 ::close(dsp); 516 ::close(dsp);
494// if(useAlerts) 517 if(useAlerts)
495// QMessageBox::message("Vmemo"," Done recording"); 518 QMessageBox::message("Vmemo"," Done recording\n"+ fileName);
496// else 519 QSound::play(Resource::findSound("vmemoe"));
497 QSound::play(Resource::findSound("vmemoe"));
498} 520}
diff --git a/core/applets/vmemo/vmemo.h b/core/applets/vmemo/vmemo.h
index f30476f..3972877 100644
--- a/core/applets/vmemo/vmemo.h
+++ b/core/applets/vmemo/vmemo.h
@@ -32,2 +32,3 @@ public:
32 QFile track; 32 QFile track;
33 QString fileName, errorMsg;
33 34