summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-06-23 03:12:26 (UTC)
committer llornkcor <llornkcor>2002-06-23 03:12:26 (UTC)
commitf3aa76578638116c92652e37b57075850ee17dd3 (patch) (unidiff)
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
@@ -221,6 +221,7 @@ VMemo::VMemo( QWidget *parent, const char *_name )
221 this, SLOT(receive(const QCString&, const QByteArray&)) ); 221 this, SLOT(receive(const QCString&, const QByteArray&)) );
222 222
223 if( toggleKey != -1 ) { 223 if( toggleKey != -1 ) {
224 // QPEApplication::grabKeyboard();
224 QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); 225 QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)");
225// e << 4096; // Key_Escape 226// e << 4096; // Key_Escape
226// e << Key_F5; //4148 227// e << Key_F5; //4148
@@ -228,8 +229,8 @@ VMemo::VMemo( QWidget *parent, const char *_name )
228 e << QString("QPE/VMemo"); 229 e << QString("QPE/VMemo");
229 e << QString("toggleRecord()"); 230 e << QString("toggleRecord()");
230 } 231 }
231 if( vmCfg.readNumEntry("hideIcon",0) == 1 || toggleKey > 0) 232 // if( vmCfg.readNumEntry("hideIcon",0) == 1 || toggleKey > 0)
232 hide(); 233 // hide();
233 } 234 }
234} 235}
235 236
@@ -287,13 +288,15 @@ bool VMemo::startRecording() {
287// QMessageBox::message("VMemo","Really Record?");//) ==1) 288// QMessageBox::message("VMemo","Really Record?");//) ==1)
288// return; 289// return;
289// } else { 290// } else {
290 if (!systemZaurus ) 291 // if (!systemZaurus )
291 QSound::play(Resource::findSound("vmemob")); 292 // QSound::play(Resource::findSound("vmemob"));
292// } 293// }
293 qDebug("Start recording"); 294 qDebug("Start recording engines");
294 recording = TRUE; 295 recording = TRUE;
296
295 if (openDSP() == -1) { 297 if (openDSP() == -1) {
296 QMessageBox::critical(0, "vmemo", "Could not open dsp device.\n"+errorMsg, "Abort"); 298 // QMessageBox::critical(0, "vmemo", "Could not open dsp device.\n"+errorMsg, "Abort");
299 // delete msgLabel;
297 recording = FALSE; 300 recording = FALSE;
298 return FALSE; 301 return FALSE;
299 } 302 }
@@ -327,9 +330,9 @@ bool VMemo::startRecording() {
327 fileName.replace(QRegExp(","),""); 330 fileName.replace(QRegExp(","),"");
328 331
329 if(openWAV(fileName.latin1()) == -1) { 332 if(openWAV(fileName.latin1()) == -1) {
330 QString err("Could not open the output file\n"); 333 // QString err("Could not open the output file\n");
331 err += fileName; 334 // err += fileName;
332 QMessageBox::critical(0, "vmemo", err, "Abort"); 335 // QMessageBox::critical(0, "vmemo", err, "Abort");
333 close(dsp); 336 close(dsp);
334 return FALSE; 337 return FALSE;
335 } 338 }
@@ -348,6 +351,7 @@ bool VMemo::startRecording() {
348 351
349 352
350 record(); 353 record();
354 // delete msgLabel;
351 return TRUE; 355 return TRUE;
352} 356}
353 357
@@ -384,6 +388,7 @@ int VMemo::openDSP()
384 if(dsp == -1) { 388 if(dsp == -1) {
385 perror("open(\"/dev/dsp\")"); 389 perror("open(\"/dev/dsp\")");
386 errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); 390 errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno);
391 QMessageBox::critical(0, "vmemo", errorMsg, "Abort");
387 return -1; 392 return -1;
388 } 393 }
389 394
@@ -447,7 +452,11 @@ void VMemo::record(void)
447 qDebug(msg); 452 qDebug(msg);
448 453
449 if(systemZaurus) { 454 if(systemZaurus) {
455
456 msg.sprintf("Recording format zaurus");
457 qDebug(msg);
450 signed short sound[512], monoBuffer[512]; 458 signed short sound[512], monoBuffer[512];
459
451 if(format==AFMT_S16_LE) { 460 if(format==AFMT_S16_LE) {
452 461
453 while(recording) { 462 while(recording) {
@@ -461,37 +470,56 @@ void VMemo::record(void)
461 } 470 }
462 471
463 length+=write(wav, monoBuffer, result); 472 length+=write(wav, monoBuffer, result);
473 if(length<0)
474 recording=false;
464 475
465 } else { //ipaq /stereo inputs 476 } else { //ipaq /stereo inputs
466 477
478
467 for (int i = 0; i < result; i+=2) { 479 for (int i = 0; i < result; i+=2) {
468 monoBuffer[j] = (sound[i]+sound[i+1])/2; 480/ monoBuffer[j] = sound[i];
481 // monoBuffer[j] = (sound[i]+sound[i+1])/2;
482
469 j++; 483 j++;
470 } 484 }
471 485
472 length+=write(wav, monoBuffer, result/2); 486 length+=write(wav, monoBuffer, result);
487 if(length<0)
488 recording=false;
489 // length+=write(wav, monoBuffer, result/2);
473 } 490 }
474 qApp->processEvents(); 491 qApp->processEvents();
475// printf("%d\r",length); 492// printf("%d\r",length);
476// fflush(stdout); 493// fflush(stdout);
477 } 494 }
495
478 } else { //AFMT_U8 496 } else { //AFMT_U8
479// 8bit unsigned 497// 8bit unsigned
480 unsigned short sound[512], monoBuffer[512]; 498 unsigned short sound[512], monoBuffer[512];
481 while(recording) { 499 while(recording) {
482 result = read(dsp, sound, 512); // 8192 500 result = read(dsp, sound, 512); // 8192
483 int j=0; 501 int j=0;
502
484 if(systemZaurus) { 503 if(systemZaurus) {
504
485 for (int i = 0; i < result; i++) { //since Z is mono do normally 505 for (int i = 0; i < result; i++) { //since Z is mono do normally
486 monoBuffer[i] = sound[i]; 506 monoBuffer[i] = sound[i];
487 } 507 }
508
488 length+=write(wav, monoBuffer, result); 509 length+=write(wav, monoBuffer, result);
510
489 } else { //ipaq /stereo inputs 511 } else { //ipaq /stereo inputs
512
490 for (int i = 0; i < result; i+=2) { 513 for (int i = 0; i < result; i+=2) {
491 monoBuffer[j] = (sound[i]+sound[i+1])/2; 514 monoBuffer[j] = (sound[i]+sound[i+1])/2;
492 j++; 515 j++;
493 } 516 }
517
494 length+=write(wav, monoBuffer, result/2); 518 length+=write(wav, monoBuffer, result/2);
519
520 if(length<0)
521 recording=false;
522
495 } 523 }
496 length += result; 524 length += result;
497// printf("%d\r",length); 525// printf("%d\r",length);
@@ -503,31 +531,48 @@ void VMemo::record(void)
503 531
504 } else { // this is specific for ipaqs that do not have 8 bit capabilities 532 } else { // this is specific for ipaqs that do not have 8 bit capabilities
505 533
534 msg.sprintf("Recording format other");
535 qDebug(msg);
536
506 signed short sound[512], monoBuffer[512]; 537 signed short sound[512], monoBuffer[512];
507 538
508 while(recording) { 539 while(recording) {
540
509 result = read(dsp, sound, 512); // 8192 541 result = read(dsp, sound, 512); // 8192
542
510 write(wav, sound, result); 543 write(wav, sound, result);
511 length += result; 544 length += result;
545 if(length<0) {
512 546
513 qApp->processEvents(); 547 recording=false;
548 perror("dev/dsp's is a lookin' messy");
549 QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName);
514 } 550 }
515// printf("%d\r",length); 551// printf("%d\r",length);
516// fflush(stdout); 552// fflush(stdout);
553 qApp->processEvents();
554 }
517 // qDebug("file has length of %d lasting %d seconds", 555 // qDebug("file has length of %d lasting %d seconds",
518 // length, (( length / speed) / channels) / 2 ); 556 // length, (( length / speed) / channels) / 2 );
519 // medialplayer states wrong length in secs 557 // medialplayer states wrong length in secs
520 } 558 }
521 559
560 //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<//
561
522 value = length+36; 562 value = length+36;
563
523 lseek(wav, 4, SEEK_SET); 564 lseek(wav, 4, SEEK_SET);
524 write(wav, &value, 4); 565 write(wav, &value, 4);
525 lseek(wav, 40, SEEK_SET); 566 lseek(wav, 40, SEEK_SET);
567
526 write(wav, &length, 4); 568 write(wav, &length, 4);
569
527 track.close(); 570 track.close();
571 qDebug("Tracvk closed");
528 572
529 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) 573 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1)
530 perror("ioctl(\"SNDCTL_DSP_RESET\")"); 574 perror("ioctl(\"SNDCTL_DSP_RESET\")");
575
531 ::close(dsp); 576 ::close(dsp);
532 fileName = fileName.left(fileName.length()-4); 577 fileName = fileName.left(fileName.length()-4);
533// if(useAlerts) 578// 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
5 TARGET = vmemoapplet 5 TARGET = vmemoapplet
6 DESTDIR =$(OPIEDIR)/plugins/applets 6 DESTDIR =$(OPIEDIR)/plugins/applets
7INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += ../$(OPIEDIR)/include 8DEPENDPATH += $(OPIEDIR)/include
9LIBS += -lqpe 9LIBS += -lqpe
10 VERSION = 1.0.0 10 VERSION = 1.0.0
11 11
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