-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 | |||
@@ -218,21 +218,22 @@ VMemo::VMemo( QWidget *parent, const char *_name ) | |||
218 | 218 | ||
219 | myChannel = new QCopChannel( "QPE/VMemo", this ); | 219 | myChannel = new QCopChannel( "QPE/VMemo", this ); |
220 | connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), | 220 | connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), |
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 |
227 | e << toggleKey; | 228 | e << toggleKey; |
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 | ||
236 | VMemo::~VMemo() | 237 | VMemo::~VMemo() |
237 | { | 238 | { |
238 | } | 239 | } |
@@ -284,19 +285,21 @@ bool VMemo::startRecording() { | |||
284 | } | 285 | } |
285 | 286 | ||
286 | // if(useAlerts) | 287 | // if(useAlerts) |
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 | } |
300 | 303 | ||
301 | config.setGroup("Defaults"); | 304 | config.setGroup("Defaults"); |
302 | 305 | ||
@@ -324,15 +327,15 @@ bool VMemo::startRecording() { | |||
324 | fileName.replace(QRegExp("'"),""); | 327 | fileName.replace(QRegExp("'"),""); |
325 | fileName.replace(QRegExp(" "),"_"); | 328 | fileName.replace(QRegExp(" "),"_"); |
326 | fileName.replace(QRegExp(":"),"."); | 329 | fileName.replace(QRegExp(":"),"."); |
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 | } |
336 | 339 | ||
337 | QArray<int> cats(1); | 340 | QArray<int> cats(1); |
338 | cats[0] = config.readNumEntry("Category", 0); | 341 | cats[0] = config.readNumEntry("Category", 0); |
@@ -345,12 +348,13 @@ bool VMemo::startRecording() { | |||
345 | l.setType("audio/x-wav"); | 348 | l.setType("audio/x-wav"); |
346 | l.setCategories(cats); | 349 | l.setCategories(cats); |
347 | l.writeLink(); | 350 | l.writeLink(); |
348 | 351 | ||
349 | 352 | ||
350 | record(); | 353 | record(); |
354 | // delete msgLabel; | ||
351 | return TRUE; | 355 | return TRUE; |
352 | } | 356 | } |
353 | 357 | ||
354 | void VMemo::stopRecording() { | 358 | void VMemo::stopRecording() { |
355 | recording = FALSE; | 359 | recording = FALSE; |
356 | if(useAlerts) | 360 | if(useAlerts) |
@@ -381,12 +385,13 @@ int VMemo::openDSP() | |||
381 | dsp = open("/dev/dsp", O_RDWR); | 385 | dsp = open("/dev/dsp", O_RDWR); |
382 | } | 386 | } |
383 | 387 | ||
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 | ||
390 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { | 395 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { |
391 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 396 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
392 | return -1; | 397 | return -1; |
@@ -444,13 +449,17 @@ void VMemo::record(void) | |||
444 | int length=0, result, value; | 449 | int length=0, result, value; |
445 | QString msg; | 450 | QString msg; |
446 | msg.sprintf("Recording format %d", format); | 451 | msg.sprintf("Recording format %d", format); |
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) { |
454 | 463 | ||
455 | result = read(dsp, sound, 512); // 8192 | 464 | result = read(dsp, sound, 512); // 8192 |
456 | int j=0; | 465 | int j=0; |
@@ -458,79 +467,115 @@ void VMemo::record(void) | |||
458 | if(systemZaurus) { | 467 | if(systemZaurus) { |
459 | for (int i = 0; i < result; i++) { //since Z is mono do normally | 468 | for (int i = 0; i < result; i++) { //since Z is mono do normally |
460 | monoBuffer[i] = sound[i]; | 469 | monoBuffer[i] = sound[i]; |
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); |
498 | // fflush(stdout); | 526 | // fflush(stdout); |
499 | } | 527 | } |
500 | 528 | ||
501 | qApp->processEvents(); | 529 | qApp->processEvents(); |
502 | } | 530 | } |
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) |
534 | // QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); | 579 | // QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); |
535 | qDebug("done recording "+fileName); | 580 | qDebug("done recording "+fileName); |
536 | QSound::play(Resource::findSound("vmemoe")); | 581 | QSound::play(Resource::findSound("vmemoe")); |
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 | |||
@@ -2,13 +2,13 @@ TEMPLATE = lib | |||
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | HEADERS= vmemo.h vmemoimpl.h | 3 | HEADERS= vmemo.h vmemoimpl.h |
4 | SOURCES= vmemo.cpp vmemoimpl.cpp | 4 | SOURCES= vmemo.cpp vmemoimpl.cpp |
5 | TARGET = vmemoapplet | 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 |
11 | 11 | ||
12 | TRANSLATIONS = ../../i18n/pt_BR/libvmemoapplet.ts | 12 | TRANSLATIONS = ../../i18n/pt_BR/libvmemoapplet.ts |
13 | TRANSLATIONS += ../../i18n/es/libvmemoapplet.ts | 13 | TRANSLATIONS += ../../i18n/es/libvmemoapplet.ts |
14 | TRANSLATIONS += ../../i18n/pt/libvmemoapplet.ts | 14 | TRANSLATIONS += ../../i18n/pt/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 | |||