author | llornkcor <llornkcor> | 2002-06-23 17:17:08 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-06-23 17:17:08 (UTC) |
commit | 7c22b9cbf92650c432a84537f4b9c3d810e7dc75 (patch) (unidiff) | |
tree | 61525d12126e87cbce8135d2717c98340a7571e3 /core/applets/vmemo | |
parent | 3165f1b279a7a3a863decf06013c6275466092e5 (diff) | |
download | opie-7c22b9cbf92650c432a84537f4b9c3d810e7dc75.zip opie-7c22b9cbf92650c432a84537f4b9c3d810e7dc75.tar.gz opie-7c22b9cbf92650c432a84537f4b9c3d810e7dc75.tar.bz2 |
quick fix for ongoing recording
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 14 | ||||
-rw-r--r-- | core/applets/vmemo/vmemo.h | 4 |
2 files changed, 17 insertions, 1 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index cfa07b4..63ee0b8 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -18,24 +18,25 @@ | |||
18 | #include <sys/time.h> | 18 | #include <sys/time.h> |
19 | #include <sys/types.h> | 19 | #include <sys/types.h> |
20 | #include <unistd.h> | 20 | #include <unistd.h> |
21 | #include <stdio.h> | 21 | #include <stdio.h> |
22 | #include <sys/stat.h> | 22 | #include <sys/stat.h> |
23 | #include <fcntl.h> | 23 | #include <fcntl.h> |
24 | #include <sys/ioctl.h> | 24 | #include <sys/ioctl.h> |
25 | #include <linux/soundcard.h> | 25 | #include <linux/soundcard.h> |
26 | 26 | ||
27 | #include <string.h> | 27 | #include <string.h> |
28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | #include <errno.h> | 29 | #include <errno.h> |
30 | #include <qtimer.h> | ||
30 | 31 | ||
31 | typedef struct _waveheader { | 32 | typedef struct _waveheader { |
32 | u_long main_chunk; /* 'RIFF' */ | 33 | u_long main_chunk; /* 'RIFF' */ |
33 | u_long length; /* filelen */ | 34 | u_long length; /* filelen */ |
34 | u_long chunk_type; /* 'WAVE' */ | 35 | u_long chunk_type; /* 'WAVE' */ |
35 | u_long sub_chunk; /* 'fmt ' */ | 36 | u_long sub_chunk; /* 'fmt ' */ |
36 | u_long sc_len; /* length of sub_chunk, =16 | 37 | u_long sc_len; /* length of sub_chunk, =16 |
37 | (chunckSize) format len */ | 38 | (chunckSize) format len */ |
38 | u_short format; /* should be 1 for PCM-code (formatTag) */ | 39 | u_short format; /* should be 1 for PCM-code (formatTag) */ |
39 | 40 | ||
40 | u_short modus; /* 1 Mono, 2 Stereo (channels) */ | 41 | u_short modus; /* 1 Mono, 2 Stereo (channels) */ |
41 | u_long sample_fq; /* samples per second (samplesPerSecond) */ | 42 | u_long sample_fq; /* samples per second (samplesPerSecond) */ |
@@ -193,24 +194,27 @@ static char * vmemo_xpm[] = { | |||
193 | " *.B =. ", | 194 | " *.B =. ", |
194 | " n n n n n n n n n "}; | 195 | " n n n n n n n n n "}; |
195 | 196 | ||
196 | 197 | ||
197 | VMemo::VMemo( QWidget *parent, const char *_name ) | 198 | VMemo::VMemo( QWidget *parent, const char *_name ) |
198 | : QWidget( parent, _name ) | 199 | : QWidget( parent, _name ) |
199 | { | 200 | { |
200 | setFixedHeight( 18 ); | 201 | setFixedHeight( 18 ); |
201 | setFixedWidth( 14 ); | 202 | setFixedWidth( 14 ); |
202 | 203 | ||
203 | recording = FALSE; | 204 | recording = FALSE; |
204 | 205 | ||
206 | t_timer = new QTimer( this ); | ||
207 | connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); | ||
208 | |||
205 | struct utsname name; /* check for embedix kernel running on the zaurus*/ | 209 | struct utsname name; /* check for embedix kernel running on the zaurus*/ |
206 | if (uname(&name) != -1) { | 210 | if (uname(&name) != -1) { |
207 | QString release=name.release; | 211 | QString release=name.release; |
208 | Config vmCfg("Vmemo"); | 212 | Config vmCfg("Vmemo"); |
209 | vmCfg.setGroup("Defaults"); | 213 | vmCfg.setGroup("Defaults"); |
210 | int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); | 214 | int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); |
211 | 215 | ||
212 | qDebug("toggleKey %d", toggleKey); | 216 | qDebug("toggleKey %d", toggleKey); |
213 | 217 | ||
214 | if(release.find("embedix",0,TRUE) !=-1) | 218 | if(release.find("embedix",0,TRUE) !=-1) |
215 | systemZaurus=TRUE; | 219 | systemZaurus=TRUE; |
216 | else | 220 | else |
@@ -444,40 +448,41 @@ int VMemo::openWAV(const char *filename) | |||
444 | write (wav, &wh, sizeof(WaveHeader)); | 448 | write (wav, &wh, sizeof(WaveHeader)); |
445 | 449 | ||
446 | return 1; | 450 | return 1; |
447 | } | 451 | } |
448 | 452 | ||
449 | void VMemo::record(void) | 453 | void VMemo::record(void) |
450 | { | 454 | { |
451 | int length=0, result, value; | 455 | int length=0, result, value; |
452 | QString msg; | 456 | QString msg; |
453 | msg.sprintf("Recording format %d", format); | 457 | msg.sprintf("Recording format %d", format); |
454 | qDebug(msg); | 458 | qDebug(msg); |
455 | 459 | ||
460 | t_timer->start( 30 * 1000+1000, TRUE); | ||
461 | |||
456 | if(systemZaurus) { | 462 | if(systemZaurus) { |
457 | 463 | ||
458 | msg.sprintf("Recording format zaurus"); | 464 | msg.sprintf("Recording format zaurus"); |
459 | qDebug(msg); | 465 | qDebug(msg); |
460 | signed short sound[512], monoBuffer[512]; | 466 | signed short sound[512], monoBuffer[512]; |
461 | 467 | ||
462 | if(format==AFMT_S16_LE) { | 468 | if(format==AFMT_S16_LE) { |
463 | 469 | ||
464 | 470 | ||
465 | 471 | ||
466 | while(recording) { | 472 | while(recording) { |
467 | 473 | ||
468 | result = read(dsp, sound, 512); // 8192 | 474 | result = read(dsp, sound, 512); // 8192 |
469 | int j=0; | 475 | int j=0; |
470 | 476 | ||
471 | // if(systemZaurus) { | ||
472 | for (int i = 0; i < result; i++) { //since Z is mono do normally | 477 | for (int i = 0; i < result; i++) { //since Z is mono do normally |
473 | monoBuffer[i] = sound[i]; | 478 | monoBuffer[i] = sound[i]; |
474 | } | 479 | } |
475 | 480 | ||
476 | length+=write(wav, monoBuffer, result); | 481 | length+=write(wav, monoBuffer, result); |
477 | if(length<0) | 482 | if(length<0) |
478 | recording=false; | 483 | recording=false; |
479 | 484 | ||
480 | // for (int i = 0; i < result; i+=2) { | 485 | // for (int i = 0; i < result; i+=2) { |
481 | // monoBuffer[j] = sound[i]; | 486 | // monoBuffer[j] = sound[i]; |
482 | // // monoBuffer[j] = (sound[i]+sound[i+1])/2; | 487 | // // monoBuffer[j] = (sound[i]+sound[i+1])/2; |
483 | 488 | ||
@@ -602,12 +607,19 @@ int VMemo::setToggleButton(int tog) { | |||
602 | return Key_F10; | 607 | return Key_F10; |
603 | break; | 608 | break; |
604 | case 7: | 609 | case 7: |
605 | return Key_F11; | 610 | return Key_F11; |
606 | break; | 611 | break; |
607 | case 8: | 612 | case 8: |
608 | return Key_F13; | 613 | return Key_F13; |
609 | break; | 614 | break; |
610 | }; | 615 | }; |
611 | } | 616 | } |
612 | return -1; | 617 | return -1; |
613 | } | 618 | } |
619 | |||
620 | void VMemo::timerBreak() { | ||
621 | //stop | ||
622 | recording=false; | ||
623 | |||
624 | QMessageBox::message("Vmemo","Vmemo recording has \ntimed out"); | ||
625 | } | ||
diff --git a/core/applets/vmemo/vmemo.h b/core/applets/vmemo/vmemo.h index b33ab55..51ace35 100644 --- a/core/applets/vmemo/vmemo.h +++ b/core/applets/vmemo/vmemo.h | |||
@@ -15,41 +15,45 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | #ifndef __VMEMO_H__ | 17 | #ifndef __VMEMO_H__ |
18 | #define __VMEMO_H__ | 18 | #define __VMEMO_H__ |
19 | 19 | ||
20 | 20 | ||
21 | #include <qwidget.h> | 21 | #include <qwidget.h> |
22 | #include <qpixmap.h> | 22 | #include <qpixmap.h> |
23 | #include <qpe/applnk.h> | 23 | #include <qpe/applnk.h> |
24 | #include <qfile.h> | 24 | #include <qfile.h> |
25 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qtimer.h> | ||
27 | 28 | ||
28 | class VMemo : public QWidget | 29 | class VMemo : public QWidget |
29 | { | 30 | { |
30 | Q_OBJECT | 31 | Q_OBJECT |
31 | public: | 32 | public: |
32 | VMemo( QWidget *parent, const char *name = NULL); | 33 | VMemo( QWidget *parent, const char *name = NULL); |
33 | ~VMemo(); | 34 | ~VMemo(); |
34 | QFile track; | 35 | QFile track; |
35 | QString fileName, errorMsg; | 36 | QString fileName, errorMsg; |
36 | QLabel* msgLabel; | 37 | QLabel* msgLabel; |
38 | QTimer *t_timer; | ||
39 | |||
37 | public slots: | 40 | public slots: |
38 | void record(); | 41 | void record(); |
39 | void mousePressEvent( QMouseEvent * ); | 42 | void mousePressEvent( QMouseEvent * ); |
40 | void mouseReleaseEvent( QMouseEvent * ); | 43 | void mouseReleaseEvent( QMouseEvent * ); |
41 | void receive( const QCString &msg, const QByteArray &data ); | 44 | void receive( const QCString &msg, const QByteArray &data ); |
42 | bool startRecording(); | 45 | bool startRecording(); |
43 | void stopRecording(); | 46 | void stopRecording(); |
47 | void timerBreak(); | ||
44 | private: | 48 | private: |
45 | bool useAlerts; | 49 | bool useAlerts; |
46 | void paintEvent( QPaintEvent* ); | 50 | void paintEvent( QPaintEvent* ); |
47 | int setToggleButton(int); | 51 | int setToggleButton(int); |
48 | int openDSP(); | 52 | int openDSP(); |
49 | int openWAV(const char *filename); | 53 | int openWAV(const char *filename); |
50 | bool fromToggle; | 54 | bool fromToggle; |
51 | QPixmap vmemoPixmap; | 55 | QPixmap vmemoPixmap; |
52 | QCopChannel *myChannel; | 56 | QCopChannel *myChannel; |
53 | bool systemZaurus; | 57 | bool systemZaurus; |
54 | int dsp, wav, rate, speed, channels, format, resolution; | 58 | int dsp, wav, rate, speed, channels, format, resolution; |
55 | bool recording; | 59 | bool recording; |