-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 16 | ||||
-rw-r--r-- | core/applets/vmemo/vmemo.h | 4 |
2 files changed, 18 insertions, 2 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 @@ -14,32 +14,33 @@ * $Id$ */ // Sun 03-17-2002 L.J.Potter <ljp@llornkcor.com> #include <sys/utsname.h> #include <sys/time.h> #include <sys/types.h> #include <unistd.h> #include <stdio.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/ioctl.h> #include <linux/soundcard.h> #include <string.h> #include <stdlib.h> #include <errno.h> +#include <qtimer.h> typedef struct _waveheader { u_long main_chunk; /* 'RIFF' */ u_long length; /* filelen */ u_long chunk_type; /* 'WAVE' */ u_long sub_chunk; /* 'fmt ' */ u_long sc_len; /* length of sub_chunk, =16 (chunckSize) format len */ u_short format; /* should be 1 for PCM-code (formatTag) */ u_short modus; /* 1 Mono, 2 Stereo (channels) */ u_long sample_fq; /* samples per second (samplesPerSecond) */ u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */ u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */ u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */ @@ -188,32 +189,35 @@ static char * vmemo_xpm[] = { " o x y z A B C D E n ", " F G H I J K L M N O ", " P Q R S T U V W X ", " Y Z ` b ...+. ", " @.#.$.%.&. ", " *.B =. ", " n n n n n n n n n "}; VMemo::VMemo( QWidget *parent, const char *_name ) : QWidget( parent, _name ) { setFixedHeight( 18 ); setFixedWidth( 14 ); recording = FALSE; + + t_timer = new QTimer( this ); + connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); struct utsname name; /* check for embedix kernel running on the zaurus*/ if (uname(&name) != -1) { QString release=name.release; Config vmCfg("Vmemo"); vmCfg.setGroup("Defaults"); int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); qDebug("toggleKey %d", toggleKey); if(release.find("embedix",0,TRUE) !=-1) systemZaurus=TRUE; else systemZaurus=FALSE; myChannel = new QCopChannel( "QPE/VMemo", this ); @@ -440,48 +444,49 @@ int VMemo::openWAV(const char *filename) wh.data_chunk = DATA; wh.data_length= 0; // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d" // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl ); write (wav, &wh, sizeof(WaveHeader)); return 1; } void VMemo::record(void) { int length=0, result, value; QString msg; msg.sprintf("Recording format %d", format); qDebug(msg); + t_timer->start( 30 * 1000+1000, TRUE); + if(systemZaurus) { msg.sprintf("Recording format zaurus"); qDebug(msg); signed short sound[512], monoBuffer[512]; - + if(format==AFMT_S16_LE) { while(recording) { result = read(dsp, sound, 512); // 8192 int j=0; - // if(systemZaurus) { for (int i = 0; i < result; i++) { //since Z is mono do normally monoBuffer[i] = sound[i]; } length+=write(wav, monoBuffer, result); if(length<0) recording=false; // for (int i = 0; i < result; i+=2) { // monoBuffer[j] = sound[i]; // // monoBuffer[j] = (sound[i]+sound[i+1])/2; // j++; // } qApp->processEvents(); // printf("%d\r",length); @@ -598,16 +603,23 @@ int VMemo::setToggleButton(int tog) { case 5: return Key_F9; break; case 6: return Key_F10; break; case 7: return Key_F11; break; case 8: return Key_F13; break; }; } return -1; } + +void VMemo::timerBreak() { + //stop + recording=false; + + QMessageBox::message("Vmemo","Vmemo recording has \ntimed out"); +} 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 @@ -11,49 +11,53 @@ *********************************************************************************************/ /* * $Id$ */ #ifndef __VMEMO_H__ #define __VMEMO_H__ #include <qwidget.h> #include <qpixmap.h> #include <qpe/applnk.h> #include <qfile.h> #include <qpe/qcopenvelope_qws.h> #include <qlabel.h> +#include <qtimer.h> class VMemo : public QWidget { Q_OBJECT public: VMemo( QWidget *parent, const char *name = NULL); ~VMemo(); QFile track; QString fileName, errorMsg; QLabel* msgLabel; + QTimer *t_timer; + public slots: void record(); void mousePressEvent( QMouseEvent * ); void mouseReleaseEvent( QMouseEvent * ); void receive( const QCString &msg, const QByteArray &data ); bool startRecording(); void stopRecording(); + void timerBreak(); private: bool useAlerts; void paintEvent( QPaintEvent* ); int setToggleButton(int); int openDSP(); int openWAV(const char *filename); bool fromToggle; QPixmap vmemoPixmap; QCopChannel *myChannel; bool systemZaurus; int dsp, wav, rate, speed, channels, format, resolution; bool recording; }; #endif // __VMEMO_H__ |