summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp16
-rw-r--r--core/applets/vmemo/vmemo.h4
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
@@ -6,48 +6,49 @@
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
************************************************************************************/
// copyright 2002 Jeremy Cowgar <jc@cowgar.com>
/*
* $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) */
u_long data_chunk; /* 'data' */
u_long data_length;/* samplecount */
} WaveHeader;
#define RIFF 0x46464952
#define WAVE 0x45564157
#define FMT 0x20746D66
@@ -180,48 +181,51 @@ static char * vmemo_xpm[] = {
" . + @ # ",
" $ % & * = - ",
" ; > , ' ) ! ~ ",
" { ] ^ / ( _ : ",
" < [ } | 1 2 3 ",
" 4 5 6 7 8 9 0 a b c ",
" d e f g h i j 3 k l m n ",
" o p q r s t u v w n ",
" 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 );
connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)),
this, SLOT(receive(const QCString&, const QByteArray&)) );
if( toggleKey != -1 ) {
// QPEApplication::grabKeyboard();
QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)");
// e << 4096; // Key_Escape
// e << Key_F5; //4148
@@ -432,64 +436,65 @@ int VMemo::openWAV(const char *filename)
wh.sub_chunk = FMT;
wh.sc_len = 16;
wh.format = PCM_CODE;
wh.modus = channels;
wh.sample_fq = speed;
wh.byte_p_sec = speed * channels * resolution/8;
wh.byte_p_spl = channels * (resolution / 8);
wh.bit_p_spl = resolution;
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);
// fflush(stdout);
}
} else { //AFMT_U8
// 8bit unsigned
unsigned short sound[512], monoBuffer[512];
while(recording) {
result = read(dsp, sound, 512); // 8192
@@ -590,24 +595,31 @@ int VMemo::setToggleButton(int tog) {
return Key_Escape;
break;
case 3:
return Key_Space;
break;
case 4:
return Key_F12;
break;
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
@@ -3,57 +3,61 @@
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
*********************************************************************************************/
/*
* $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__