author | llornkcor <llornkcor> | 2002-07-26 01:14:13 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-07-26 01:14:13 (UTC) |
commit | 630a8f6e4ff5eddaee0089e383c42cc198c68ced (patch) (unidiff) | |
tree | 7d743e08c5964eb96f0fb5090d977fdf702c3f44 /core/applets/vmemo | |
parent | f3678966b4f08e9cc99b5f625c028e6f2d29a8ae (diff) | |
download | opie-630a8f6e4ff5eddaee0089e383c42cc198c68ced.zip opie-630a8f6e4ff5eddaee0089e383c42cc198c68ced.tar.gz opie-630a8f6e4ff5eddaee0089e383c42cc198c68ced.tar.bz2 |
made 2nd button release stop recording, and fixed umlimited time recording
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 44 | ||||
-rw-r--r-- | core/applets/vmemo/vmemo.h | 2 |
2 files changed, 27 insertions, 19 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index b5239eb..035965e 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -257,22 +257,24 @@ VMemo::VMemo( QWidget *parent, const char *_name ) | |||
257 | VMemo::~VMemo() { | 257 | VMemo::~VMemo() { |
258 | } | 258 | } |
259 | 259 | ||
260 | void VMemo::receive( const QCString &msg, const QByteArray &data ) { | 260 | void VMemo::receive( const QCString &msg, const QByteArray &data ) { |
261 | qDebug("receive"); | 261 | qDebug("receive"); |
262 | QDataStream stream( data, IO_ReadOnly ); | 262 | QDataStream stream( data, IO_ReadOnly ); |
263 | |||
263 | if (msg == "toggleRecord()") { | 264 | if (msg == "toggleRecord()") { |
264 | if (recording) { | 265 | |
265 | fromToggle = TRUE; | 266 | if (recording) { |
266 | mouseReleaseEvent(NULL); | 267 | fromToggle = TRUE; |
267 | // stopRecording(); | 268 | mouseReleaseEvent(NULL); |
268 | } else { | 269 | stopRecording(); |
269 | fromToggle = TRUE; | 270 | } else { |
270 | // mousePressEvent(NULL); | 271 | fromToggle = TRUE; |
271 | startRecording(); | 272 | // mousePressEvent(NULL); |
272 | } | 273 | startRecording(); |
274 | } | ||
273 | } | 275 | } |
274 | } | 276 | } |
275 | 277 | ||
276 | void VMemo::paintEvent( QPaintEvent* ) { | 278 | void VMemo::paintEvent( QPaintEvent* ) { |
277 | QPainter p(this); | 279 | QPainter p(this); |
278 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); | 280 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); |
@@ -356,19 +358,19 @@ bool VMemo::startRecording() { | |||
356 | fileName="/"+fileName; | 358 | fileName="/"+fileName; |
357 | if( fileName.right(1).find('/') == -1) | 359 | if( fileName.right(1).find('/') == -1) |
358 | fileName+="/"; | 360 | fileName+="/"; |
359 | fName = "vm_"+ dt.toString()+ ".wav"; | 361 | fName = "vm_"+ dt.toString()+ ".wav"; |
360 | 362 | ||
361 | fileName+=fName; | 363 | fileName+=fName; |
362 | qDebug("filename is "+fileName); | ||
363 | // No spaces in the filename | 364 | // No spaces in the filename |
364 | fileName.replace(QRegExp("'"),""); | 365 | fileName.replace(QRegExp("'"),""); |
365 | fileName.replace(QRegExp(" "),"_"); | 366 | fileName.replace(QRegExp(" "),"_"); |
366 | fileName.replace(QRegExp(":"),"."); | 367 | fileName.replace(QRegExp(":"),"."); |
367 | fileName.replace(QRegExp(","),""); | 368 | fileName.replace(QRegExp(","),""); |
368 | 369 | ||
370 | qDebug("filename is "+fileName); | ||
369 | // open tmp file here | 371 | // open tmp file here |
370 | char *pointer; | 372 | char *pointer; |
371 | pointer=tmpnam(NULL); | 373 | pointer=tmpnam(NULL); |
372 | qDebug("Opening tmp file %s",pointer); | 374 | qDebug("Opening tmp file %s",pointer); |
373 | 375 | ||
374 | if(openWAV(pointer ) == -1) { | 376 | if(openWAV(pointer ) == -1) { |
@@ -377,13 +379,13 @@ bool VMemo::startRecording() { | |||
377 | QString err("Could not open the temp file\n"); | 379 | QString err("Could not open the temp file\n"); |
378 | err += fileName; | 380 | err += fileName; |
379 | QMessageBox::critical(0, "vmemo", err, "Abort"); | 381 | QMessageBox::critical(0, "vmemo", err, "Abort"); |
380 | ::close(dsp); | 382 | ::close(dsp); |
381 | return FALSE; | 383 | return FALSE; |
382 | } | 384 | } |
383 | record(); | 385 | if( record() ) { |
384 | 386 | ||
385 | QString cmd; | 387 | QString cmd; |
386 | cmd.sprintf("mv %s "+fileName, pointer); | 388 | cmd.sprintf("mv %s "+fileName, pointer); |
387 | // move tmp file to regular file here | 389 | // move tmp file to regular file here |
388 | system(cmd.latin1()); | 390 | system(cmd.latin1()); |
389 | 391 | ||
@@ -395,14 +397,16 @@ bool VMemo::startRecording() { | |||
395 | DocLnk l; | 397 | DocLnk l; |
396 | l.setFile(fileName); | 398 | l.setFile(fileName); |
397 | l.setName(dlName); | 399 | l.setName(dlName); |
398 | l.setType("audio/x-wav"); | 400 | l.setType("audio/x-wav"); |
399 | l.setCategories(cats); | 401 | l.setCategories(cats); |
400 | l.writeLink(); | 402 | l.writeLink(); |
401 | |||
402 | return TRUE; | 403 | return TRUE; |
404 | } else | ||
405 | return FALSE; | ||
406 | |||
403 | } | 407 | } |
404 | 408 | ||
405 | void VMemo::stopRecording() { | 409 | void VMemo::stopRecording() { |
406 | show(); | 410 | show(); |
407 | qDebug("Stopped recording"); | 411 | qDebug("Stopped recording"); |
408 | recording = FALSE; | 412 | recording = FALSE; |
@@ -501,22 +505,23 @@ int VMemo::openWAV(const char *filename) { | |||
501 | // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl ); | 505 | // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl ); |
502 | write (wav, &wh, sizeof(WaveHeader)); | 506 | write (wav, &wh, sizeof(WaveHeader)); |
503 | 507 | ||
504 | return 1; | 508 | return 1; |
505 | } | 509 | } |
506 | 510 | ||
507 | void VMemo::record(void) { | 511 | bool VMemo::record() { |
508 | int length=0, result, value; | 512 | |
513 | int length=0, result, value; | ||
509 | QString msg; | 514 | QString msg; |
510 | msg.sprintf("Recording format %d", format); | 515 | msg.sprintf("Recording format %d", format); |
511 | qDebug(msg); | 516 | qDebug(msg); |
512 | Config config("Vmemo"); | 517 | Config config("Vmemo"); |
513 | config.setGroup("Record"); | 518 | config.setGroup("Record"); |
514 | int sRate=config.readNumEntry("SizeLimit", 30); | 519 | int sRate=config.readNumEntry("SizeLimit", 30); |
515 | 520 | if(sRate > 0) | |
516 | t_timer->start( sRate * 1000+1000, TRUE); | 521 | t_timer->start( sRate * 1000+1000, TRUE); |
517 | 522 | ||
518 | // if(systemZaurus) { | 523 | // if(systemZaurus) { |
519 | // } else { // 16 bit only capabilities | 524 | // } else { // 16 bit only capabilities |
520 | 525 | ||
521 | msg.sprintf("Recording format other"); | 526 | msg.sprintf("Recording format other"); |
522 | qDebug(msg); | 527 | qDebug(msg); |
@@ -534,14 +539,15 @@ void VMemo::record(void) { | |||
534 | else | 539 | else |
535 | result = read(dsp, sound, 1024); // 8192 | 540 | result = read(dsp, sound, 1024); // 8192 |
536 | if( result <= 0) { | 541 | if( result <= 0) { |
537 | perror("recording error "); | 542 | perror("recording error "); |
538 | // qDebug(currentFileName); | 543 | // qDebug(currentFileName); |
539 | QMessageBox::message(tr("Note"),tr("error recording")); | 544 | QMessageBox::message(tr("Note"),tr("error recording")); |
540 | recording=FALSE;; | 545 | recording=FALSE; |
541 | break; | 546 | break; |
547 | return FALSE; | ||
542 | } | 548 | } |
543 | 549 | ||
544 | if(useADPCM) { | 550 | if(useADPCM) { |
545 | adpcm_coder( sbuf, abuf, result/2, &encoder_state); | 551 | adpcm_coder( sbuf, abuf, result/2, &encoder_state); |
546 | bytesWritten = ::write(wav, abuf, result/4); | 552 | bytesWritten = ::write(wav, abuf, result/4); |
547 | 553 | ||
@@ -555,12 +561,14 @@ void VMemo::record(void) { | |||
555 | length +=bytesWritten; | 561 | length +=bytesWritten; |
556 | 562 | ||
557 | if(length<0) { | 563 | if(length<0) { |
558 | recording=false; | 564 | recording=false; |
559 | perror("dev/dsp's is a lookin' messy"); | 565 | perror("dev/dsp's is a lookin' messy"); |
560 | QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); | 566 | QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); |
567 | break; | ||
568 | return FALSE; | ||
561 | } | 569 | } |
562 | // printf("%d\r",length); | 570 | // printf("%d\r",length); |
563 | // fflush(stdout); | 571 | // fflush(stdout); |
564 | qApp->processEvents(); | 572 | qApp->processEvents(); |
565 | } | 573 | } |
566 | // qDebug("file has length of %d lasting %d seconds", | 574 | // qDebug("file has length of %d lasting %d seconds", |
@@ -594,13 +602,13 @@ void VMemo::record(void) { | |||
594 | 602 | ||
595 | Config cfg("qpe"); | 603 | Config cfg("qpe"); |
596 | cfg.setGroup("Volume"); | 604 | cfg.setGroup("Volume"); |
597 | QString foo = cfg.readEntry("Mute","TRUE"); | 605 | QString foo = cfg.readEntry("Mute","TRUE"); |
598 | if(foo.find("TRUE",0,TRUE) != -1) | 606 | if(foo.find("TRUE",0,TRUE) != -1) |
599 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute | 607 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute |
600 | 608 | return TRUE; | |
601 | } | 609 | } |
602 | 610 | ||
603 | int VMemo::setToggleButton(int tog) { | 611 | int VMemo::setToggleButton(int tog) { |
604 | 612 | ||
605 | for( int i=0; i < 10;i++) { | 613 | for( int i=0; i < 10;i++) { |
606 | switch (tog) { | 614 | switch (tog) { |
diff --git a/core/applets/vmemo/vmemo.h b/core/applets/vmemo/vmemo.h index 167af2a..9ee08ff 100644 --- a/core/applets/vmemo/vmemo.h +++ b/core/applets/vmemo/vmemo.h | |||
@@ -35,13 +35,13 @@ public: | |||
35 | QFile track; | 35 | QFile track; |
36 | QString fileName, errorMsg; | 36 | QString fileName, errorMsg; |
37 | QLabel* msgLabel; | 37 | QLabel* msgLabel; |
38 | QTimer *t_timer; | 38 | QTimer *t_timer; |
39 | bool usingIcon, useADPCM; | 39 | bool usingIcon, useADPCM; |
40 | public slots: | 40 | public slots: |
41 | void record(); | 41 | bool record(); |
42 | void mousePressEvent( QMouseEvent * ); | 42 | void mousePressEvent( QMouseEvent * ); |
43 | void mouseReleaseEvent( QMouseEvent * ); | 43 | void mouseReleaseEvent( QMouseEvent * ); |
44 | void receive( const QCString &msg, const QByteArray &data ); | 44 | void receive( const QCString &msg, const QByteArray &data ); |
45 | bool startRecording(); | 45 | bool startRecording(); |
46 | void stopRecording(); | 46 | void stopRecording(); |
47 | void timerBreak(); | 47 | void timerBreak(); |