author | llornkcor <llornkcor> | 2002-06-23 03:12:26 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-06-23 03:12:26 (UTC) |
commit | f3aa76578638116c92652e37b57075850ee17dd3 (patch) (unidiff) | |
tree | af09f06e462b156ab9c8dc2e7ddfcaf673a74cf7 /core/applets/vmemo | |
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 | |||
@@ -222,4 +222,5 @@ VMemo::VMemo( QWidget *parent, const char *_name ) | |||
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 |
@@ -229,6 +230,6 @@ VMemo::VMemo( QWidget *parent, const char *_name ) | |||
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 | } |
@@ -288,11 +289,13 @@ bool VMemo::startRecording() { | |||
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; |
@@ -328,7 +331,7 @@ bool VMemo::startRecording() { | |||
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; |
@@ -349,4 +352,5 @@ bool VMemo::startRecording() { | |||
349 | 352 | ||
350 | record(); | 353 | record(); |
354 | // delete msgLabel; | ||
351 | return TRUE; | 355 | return TRUE; |
352 | } | 356 | } |
@@ -385,4 +389,5 @@ int VMemo::openDSP() | |||
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 | } |
@@ -448,5 +453,9 @@ void VMemo::record(void) | |||
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 | ||
@@ -462,13 +471,21 @@ void VMemo::record(void) | |||
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(); |
@@ -476,4 +493,5 @@ void VMemo::record(void) | |||
476 | // fflush(stdout); | 493 | // fflush(stdout); |
477 | } | 494 | } |
495 | |||
478 | } else { //AFMT_U8 | 496 | } else { //AFMT_U8 |
479 | // 8bit unsigned | 497 | // 8bit unsigned |
@@ -482,15 +500,25 @@ void VMemo::record(void) | |||
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; |
@@ -504,15 +532,25 @@ void VMemo::record(void) | |||
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 ); |
@@ -520,13 +558,20 @@ void VMemo::record(void) | |||
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); |
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 | |||
@@ -6,5 +6,5 @@ TARGET = vmemoapplet | |||
6 | DESTDIR =$(OPIEDIR)/plugins/applets | 6 | DESTDIR =$(OPIEDIR)/plugins/applets |
7 | INCLUDEPATH += $(OPIEDIR)/include | 7 | INCLUDEPATH += $(OPIEDIR)/include |
8 | DEPENDPATH += ../$(OPIEDIR)/include | 8 | DEPENDPATH += $(OPIEDIR)/include |
9 | LIBS += -lqpe | 9 | LIBS += -lqpe |
10 | VERSION = 1.0.0 | 10 | 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 | |||