summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-07-26 01:14:13 (UTC)
committer llornkcor <llornkcor>2002-07-26 01:14:13 (UTC)
commit630a8f6e4ff5eddaee0089e383c42cc198c68ced (patch) (side-by-side diff)
tree7d743e08c5964eb96f0fb5090d977fdf702c3f44
parentf3678966b4f08e9cc99b5f625c028e6f2d29a8ae (diff)
downloadopie-630a8f6e4ff5eddaee0089e383c42cc198c68ced.zip
opie-630a8f6e4ff5eddaee0089e383c42cc198c68ced.tar.gz
opie-630a8f6e4ff5eddaee0089e383c42cc198c68ced.tar.bz2
made 2nd button release stop recording, and fixed umlimited time recording
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp24
-rw-r--r--core/applets/vmemo/vmemo.h2
2 files changed, 17 insertions, 9 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,17 +257,19 @@ VMemo::VMemo( QWidget *parent, const char *_name )
VMemo::~VMemo() {
}
void VMemo::receive( const QCString &msg, const QByteArray &data ) {
qDebug("receive");
QDataStream stream( data, IO_ReadOnly );
+
if (msg == "toggleRecord()") {
+
if (recording) {
fromToggle = TRUE;
mouseReleaseEvent(NULL);
-// stopRecording();
+ stopRecording();
} else {
fromToggle = TRUE;
// mousePressEvent(NULL);
startRecording();
}
}
@@ -356,19 +358,19 @@ bool VMemo::startRecording() {
fileName="/"+fileName;
if( fileName.right(1).find('/') == -1)
fileName+="/";
fName = "vm_"+ dt.toString()+ ".wav";
fileName+=fName;
- qDebug("filename is "+fileName);
// No spaces in the filename
fileName.replace(QRegExp("'"),"");
fileName.replace(QRegExp(" "),"_");
fileName.replace(QRegExp(":"),".");
fileName.replace(QRegExp(","),"");
+ qDebug("filename is "+fileName);
// open tmp file here
char *pointer;
pointer=tmpnam(NULL);
qDebug("Opening tmp file %s",pointer);
if(openWAV(pointer ) == -1) {
@@ -377,13 +379,13 @@ bool VMemo::startRecording() {
QString err("Could not open the temp file\n");
err += fileName;
QMessageBox::critical(0, "vmemo", err, "Abort");
::close(dsp);
return FALSE;
}
- record();
+ if( record() ) {
QString cmd;
cmd.sprintf("mv %s "+fileName, pointer);
// move tmp file to regular file here
system(cmd.latin1());
@@ -395,14 +397,16 @@ bool VMemo::startRecording() {
DocLnk l;
l.setFile(fileName);
l.setName(dlName);
l.setType("audio/x-wav");
l.setCategories(cats);
l.writeLink();
-
return TRUE;
+ } else
+ return FALSE;
+
}
void VMemo::stopRecording() {
show();
qDebug("Stopped recording");
recording = FALSE;
@@ -501,21 +505,22 @@ int VMemo::openWAV(const char *filename) {
// , 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) {
+bool VMemo::record() {
+
int length=0, result, value;
QString msg;
msg.sprintf("Recording format %d", format);
qDebug(msg);
Config config("Vmemo");
config.setGroup("Record");
int sRate=config.readNumEntry("SizeLimit", 30);
-
+ if(sRate > 0)
t_timer->start( sRate * 1000+1000, TRUE);
// if(systemZaurus) {
// } else { // 16 bit only capabilities
msg.sprintf("Recording format other");
@@ -534,14 +539,15 @@ void VMemo::record(void) {
else
result = read(dsp, sound, 1024); // 8192
if( result <= 0) {
perror("recording error ");
// qDebug(currentFileName);
QMessageBox::message(tr("Note"),tr("error recording"));
- recording=FALSE;;
+ recording=FALSE;
break;
+ return FALSE;
}
if(useADPCM) {
adpcm_coder( sbuf, abuf, result/2, &encoder_state);
bytesWritten = ::write(wav, abuf, result/4);
@@ -555,12 +561,14 @@ void VMemo::record(void) {
length +=bytesWritten;
if(length<0) {
recording=false;
perror("dev/dsp's is a lookin' messy");
QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName);
+ break;
+ return FALSE;
}
// printf("%d\r",length);
// fflush(stdout);
qApp->processEvents();
}
// qDebug("file has length of %d lasting %d seconds",
@@ -594,13 +602,13 @@ void VMemo::record(void) {
Config cfg("qpe");
cfg.setGroup("Volume");
QString foo = cfg.readEntry("Mute","TRUE");
if(foo.find("TRUE",0,TRUE) != -1)
QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute
-
+return TRUE;
}
int VMemo::setToggleButton(int tog) {
for( int i=0; i < 10;i++) {
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:
QFile track;
QString fileName, errorMsg;
QLabel* msgLabel;
QTimer *t_timer;
bool usingIcon, useADPCM;
public slots:
- void record();
+ bool record();
void mousePressEvent( QMouseEvent * );
void mouseReleaseEvent( QMouseEvent * );
void receive( const QCString &msg, const QByteArray &data );
bool startRecording();
void stopRecording();
void timerBreak();