summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-06-23 17:17:08 (UTC)
committer llornkcor <llornkcor>2002-06-23 17:17:08 (UTC)
commit7c22b9cbf92650c432a84537f4b9c3d810e7dc75 (patch) (unidiff)
tree61525d12126e87cbce8135d2717c98340a7571e3
parent3165f1b279a7a3a863decf06013c6275466092e5 (diff)
downloadopie-7c22b9cbf92650c432a84537f4b9c3d810e7dc75.zip
opie-7c22b9cbf92650c432a84537f4b9c3d810e7dc75.tar.gz
opie-7c22b9cbf92650c432a84537f4b9c3d810e7dc75.tar.bz2
quick fix for ongoing recording
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
@@ -1,93 +1,94 @@
1/************************************************************************************ 1/************************************************************************************
2 ** 2 **
3 ** This file may be distributed and/or modified under the terms of the 3 ** This file may be distributed and/or modified under the terms of the
4 ** GNU General Public License version 2 as published by the Free Software 4 ** GNU General Public License version 2 as published by the Free Software
5 ** Foundation and appearing in the file LICENSE.GPL included in the 5 ** Foundation and appearing in the file LICENSE.GPL included in the
6 ** packaging of this file. 6 ** packaging of this file.
7 ** 7 **
8 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 8 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
9 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 9 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
10 ** 10 **
11 ************************************************************************************/ 11 ************************************************************************************/
12// copyright 2002 Jeremy Cowgar <jc@cowgar.com> 12// copyright 2002 Jeremy Cowgar <jc@cowgar.com>
13/* 13/*
14 * $Id$ 14 * $Id$
15 */ 15 */
16// Sun 03-17-2002 L.J.Potter <ljp@llornkcor.com> 16// Sun 03-17-2002 L.J.Potter <ljp@llornkcor.com>
17#include <sys/utsname.h> 17#include <sys/utsname.h>
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
31typedef struct _waveheader { 32typedef 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) */
42 u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */ 43 u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */
43 u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */ 44 u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */
44 u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */ 45 u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */
45 46
46 u_long data_chunk; /* 'data' */ 47 u_long data_chunk; /* 'data' */
47 48
48 u_long data_length;/* samplecount */ 49 u_long data_length;/* samplecount */
49} WaveHeader; 50} WaveHeader;
50 51
51#define RIFF 0x46464952 52#define RIFF 0x46464952
52#define WAVE 0x45564157 53#define WAVE 0x45564157
53#define FMT 0x20746D66 54#define FMT 0x20746D66
54#define DATA 0x61746164 55#define DATA 0x61746164
55#define PCM_CODE 1 56#define PCM_CODE 1
56#define WAVE_MONO 1 57#define WAVE_MONO 1
57#define WAVE_STEREO 2 58#define WAVE_STEREO 2
58 59
59#include "vmemo.h" 60#include "vmemo.h"
60 61
61#include <qpe/qpeapplication.h> 62#include <qpe/qpeapplication.h>
62#include <qpe/resource.h> 63#include <qpe/resource.h>
63#include <qpe/config.h> 64#include <qpe/config.h>
64 65
65#include <qpainter.h> 66#include <qpainter.h>
66#include <qdatetime.h> 67#include <qdatetime.h>
67#include <qregexp.h> 68#include <qregexp.h>
68#include <qsound.h> 69#include <qsound.h>
69#include <qfile.h> 70#include <qfile.h>
70#include <qmessagebox.h> 71#include <qmessagebox.h>
71 72
72int seq = 0; 73int seq = 0;
73 74
74/* XPM */ 75/* XPM */
75static char * vmemo_xpm[] = { 76static char * vmemo_xpm[] = {
76 "16 16 102 2", 77 "16 16 102 2",
77 " c None", 78 " c None",
78 ". c #60636A", 79 ". c #60636A",
79 "+ c #6E6E72", 80 "+ c #6E6E72",
80 "@ c #68696E", 81 "@ c #68696E",
81 "# c #4D525C", 82 "# c #4D525C",
82 "$ c #6B6C70", 83 "$ c #6B6C70",
83 "% c #E3E3E8", 84 "% c #E3E3E8",
84 "& c #EEEEF2", 85 "& c #EEEEF2",
85 "* c #EAEAEF", 86 "* c #EAEAEF",
86 "= c #CACAD0", 87 "= c #CACAD0",
87 "- c #474A51", 88 "- c #474A51",
88 "; c #171819", 89 "; c #171819",
89 "> c #9B9B9F", 90 "> c #9B9B9F",
90 ", c #EBEBF0", 91 ", c #EBEBF0",
91 "' c #F4F4F7", 92 "' c #F4F4F7",
92 ") c #F1F1F5", 93 ") c #F1F1F5",
93 "! c #DEDEE4", 94 "! c #DEDEE4",
@@ -140,128 +141,131 @@ static char * vmemo_xpm[] = {
140 "y c #76767C", 141 "y c #76767C",
141 "z c #373738", 142 "z c #373738",
142 "A c #717174", 143 "A c #717174",
143 "B c #727278", 144 "B c #727278",
144 "C c #1C1C1E", 145 "C c #1C1C1E",
145 "D c #3C3C3F", 146 "D c #3C3C3F",
146 "E c #ADADB6", 147 "E c #ADADB6",
147 "F c #54555A", 148 "F c #54555A",
148 "G c #8B8C94", 149 "G c #8B8C94",
149 "H c #5A5A5F", 150 "H c #5A5A5F",
150 "I c #BBBBC3", 151 "I c #BBBBC3",
151 "J c #C4C4CB", 152 "J c #C4C4CB",
152 "K c #909098", 153 "K c #909098",
153 "L c #737379", 154 "L c #737379",
154 "M c #343437", 155 "M c #343437",
155 "N c #8F8F98", 156 "N c #8F8F98",
156 "O c #000407", 157 "O c #000407",
157 "P c #2D3137", 158 "P c #2D3137",
158 "Q c #B0B1BC", 159 "Q c #B0B1BC",
159 "R c #3B3C40", 160 "R c #3B3C40",
160 "S c #6E6E74", 161 "S c #6E6E74",
161 "T c #95959C", 162 "T c #95959C",
162 "U c #74747A", 163 "U c #74747A",
163 "V c #1D1D1E", 164 "V c #1D1D1E",
164 "W c #91929A", 165 "W c #91929A",
165 "X c #42444A", 166 "X c #42444A",
166 "Y c #22282E", 167 "Y c #22282E",
167 "Z c #B0B2BC", 168 "Z c #B0B2BC",
168 "` c #898A90", 169 "` c #898A90",
169 " . c #65656A", 170 " . c #65656A",
170 ".. c #999AA2", 171 ".. c #999AA2",
171 "+. c #52535A", 172 "+. c #52535A",
172 "@. c #151B21", 173 "@. c #151B21",
173 "#. c #515257", 174 "#. c #515257",
174 "$. c #B5B5BE", 175 "$. c #B5B5BE",
175 "%. c #616167", 176 "%. c #616167",
176 "&. c #1A1D22", 177 "&. c #1A1D22",
177 "*. c #000713", 178 "*. c #000713",
178 "=. c #1F1F21", 179 "=. c #1F1F21",
179 " ", 180 " ",
180 " . + @ # ", 181 " . + @ # ",
181 " $ % & * = - ", 182 " $ % & * = - ",
182 " ; > , ' ) ! ~ ", 183 " ; > , ' ) ! ~ ",
183 " { ] ^ / ( _ : ", 184 " { ] ^ / ( _ : ",
184 " < [ } | 1 2 3 ", 185 " < [ } | 1 2 3 ",
185 " 4 5 6 7 8 9 0 a b c ", 186 " 4 5 6 7 8 9 0 a b c ",
186 " d e f g h i j 3 k l m n ", 187 " d e f g h i j 3 k l m n ",
187 " o p q r s t u v w n ", 188 " o p q r s t u v w n ",
188 " o x y z A B C D E n ", 189 " o x y z A B C D E n ",
189 " F G H I J K L M N O ", 190 " F G H I J K L M N O ",
190 " P Q R S T U V W X ", 191 " P Q R S T U V W X ",
191 " Y Z ` b ...+. ", 192 " Y Z ` b ...+. ",
192 " @.#.$.%.&. ", 193 " @.#.$.%.&. ",
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
197VMemo::VMemo( QWidget *parent, const char *_name ) 198VMemo::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;
205
206 t_timer = new QTimer( this );
207 connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) );
204 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
217 systemZaurus=FALSE; 221 systemZaurus=FALSE;
218 222
219 myChannel = new QCopChannel( "QPE/VMemo", this ); 223 myChannel = new QCopChannel( "QPE/VMemo", this );
220 connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), 224 connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)),
221 this, SLOT(receive(const QCString&, const QByteArray&)) ); 225 this, SLOT(receive(const QCString&, const QByteArray&)) );
222 226
223 if( toggleKey != -1 ) { 227 if( toggleKey != -1 ) {
224 // QPEApplication::grabKeyboard(); 228 // QPEApplication::grabKeyboard();
225 QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); 229 QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)");
226 // e << 4096; // Key_Escape 230 // e << 4096; // Key_Escape
227 // e << Key_F5; //4148 231 // e << Key_F5; //4148
228 e << toggleKey; 232 e << toggleKey;
229 e << QString("QPE/VMemo"); 233 e << QString("QPE/VMemo");
230 e << QString("toggleRecord()"); 234 e << QString("toggleRecord()");
231 } 235 }
232 // if( vmCfg.readNumEntry("hideIcon",0) == 1 || toggleKey > 0) 236 // if( vmCfg.readNumEntry("hideIcon",0) == 1 || toggleKey > 0)
233 // hide(); 237 // hide();
234 } 238 }
235} 239}
236 240
237VMemo::~VMemo() 241VMemo::~VMemo()
238{ 242{
239} 243}
240 244
241void VMemo::receive( const QCString &msg, const QByteArray &data ) 245void VMemo::receive( const QCString &msg, const QByteArray &data )
242{ 246{
243 QDataStream stream( data, IO_ReadOnly ); 247 QDataStream stream( data, IO_ReadOnly );
244 if (msg == "toggleRecord()") { 248 if (msg == "toggleRecord()") {
245 if (recording) { 249 if (recording) {
246 fromToggle = TRUE; 250 fromToggle = TRUE;
247 stopRecording(); 251 stopRecording();
248 } else { 252 } else {
249 fromToggle = TRUE; 253 fromToggle = TRUE;
250 startRecording(); 254 startRecording();
251 } 255 }
252 } 256 }
253} 257}
254 258
255void VMemo::paintEvent( QPaintEvent* ) 259void VMemo::paintEvent( QPaintEvent* )
256{ 260{
257 QPainter p(this); 261 QPainter p(this);
258 p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); 262 p.drawPixmap( 0, 1,( const char** ) vmemo_xpm );
259} 263}
260 264
261void VMemo::mousePressEvent( QMouseEvent * ) 265void VMemo::mousePressEvent( QMouseEvent * )
262{ 266{
263 startRecording(); 267 startRecording();
264} 268}
265 269
266void VMemo::mouseReleaseEvent( QMouseEvent * ) 270void VMemo::mouseReleaseEvent( QMouseEvent * )
267{ 271{
@@ -392,144 +396,145 @@ int VMemo::openDSP()
392 return -1; 396 return -1;
393 } 397 }
394 398
395 if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { 399 if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) {
396 perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); 400 perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
397 return -1; 401 return -1;
398 } 402 }
399 if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { 403 if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) {
400 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); 404 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")");
401 return -1; 405 return -1;
402 } 406 }
403 if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { 407 if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) {
404 perror("ioctl(\"SNDCTL_DSP_SPEED\")"); 408 perror("ioctl(\"SNDCTL_DSP_SPEED\")");
405 return -1; 409 return -1;
406 } 410 }
407 if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { 411 if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) {
408 perror("ioctl(\"SOUND_PCM_READ_RATE\")"); 412 perror("ioctl(\"SOUND_PCM_READ_RATE\")");
409 return -1; 413 return -1;
410 } 414 }
411 415
412 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute 416 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute
413 417
414 return 1; 418 return 1;
415} 419}
416 420
417int VMemo::openWAV(const char *filename) 421int VMemo::openWAV(const char *filename)
418{ 422{
419 track.setName(filename); 423 track.setName(filename);
420 if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { 424 if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) {
421 errorMsg=filename; 425 errorMsg=filename;
422 return -1; 426 return -1;
423 } 427 }
424 428
425 wav=track.handle(); 429 wav=track.handle();
426 430
427 WaveHeader wh; 431 WaveHeader wh;
428 432
429 wh.main_chunk = RIFF; 433 wh.main_chunk = RIFF;
430 wh.length=0; 434 wh.length=0;
431 wh.chunk_type = WAVE; 435 wh.chunk_type = WAVE;
432 wh.sub_chunk = FMT; 436 wh.sub_chunk = FMT;
433 wh.sc_len = 16; 437 wh.sc_len = 16;
434 wh.format = PCM_CODE; 438 wh.format = PCM_CODE;
435 wh.modus = channels; 439 wh.modus = channels;
436 wh.sample_fq = speed; 440 wh.sample_fq = speed;
437 wh.byte_p_sec = speed * channels * resolution/8; 441 wh.byte_p_sec = speed * channels * resolution/8;
438 wh.byte_p_spl = channels * (resolution / 8); 442 wh.byte_p_spl = channels * (resolution / 8);
439 wh.bit_p_spl = resolution; 443 wh.bit_p_spl = resolution;
440 wh.data_chunk = DATA; 444 wh.data_chunk = DATA;
441 wh.data_length= 0; 445 wh.data_length= 0;
442 // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d" 446 // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d"
443 // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl ); 447 // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl );
444 write (wav, &wh, sizeof(WaveHeader)); 448 write (wav, &wh, sizeof(WaveHeader));
445 449
446 return 1; 450 return 1;
447} 451}
448 452
449void VMemo::record(void) 453void 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
484 // j++; 489 // j++;
485 // } 490 // }
486 qApp->processEvents(); 491 qApp->processEvents();
487 // printf("%d\r",length); 492 // printf("%d\r",length);
488 // fflush(stdout); 493 // fflush(stdout);
489 } 494 }
490 495
491 } else { //AFMT_U8 496 } else { //AFMT_U8
492 // 8bit unsigned 497 // 8bit unsigned
493 unsigned short sound[512], monoBuffer[512]; 498 unsigned short sound[512], monoBuffer[512];
494 while(recording) { 499 while(recording) {
495 result = read(dsp, sound, 512); // 8192 500 result = read(dsp, sound, 512); // 8192
496 int j=0; 501 int j=0;
497 502
498 // if(systemZaurus) { 503 // if(systemZaurus) {
499 504
500 for (int i = 0; i < result; i++) { //since Z is mono do normally 505 for (int i = 0; i < result; i++) { //since Z is mono do normally
501 monoBuffer[i] = sound[i]; 506 monoBuffer[i] = sound[i];
502 } 507 }
503 508
504 length+=write(wav, monoBuffer, result); 509 length+=write(wav, monoBuffer, result);
505 510
506 // for (int i = 0; i < result; i+=2) { 511 // for (int i = 0; i < result; i+=2) {
507 // monoBuffer[j] = (sound[i]+sound[i+1])/2; 512 // monoBuffer[j] = (sound[i]+sound[i+1])/2;
508 // j++; 513 // j++;
509 // } 514 // }
510 // length+=write(wav, monoBuffer, result/2); 515 // length+=write(wav, monoBuffer, result/2);
511 length += result; 516 length += result;
512 // printf("%d\r",length); 517 // printf("%d\r",length);
513 // fflush(stdout); 518 // fflush(stdout);
514 } 519 }
515 520
516 qApp->processEvents(); 521 qApp->processEvents();
517 } 522 }
518 523
519 } else { // 16 bit only capabilities 524 } else { // 16 bit only capabilities
520 525
521 526
522 msg.sprintf("Recording format other"); 527 msg.sprintf("Recording format other");
523 qDebug(msg); 528 qDebug(msg);
524 529
525 signed short sound[512], monoBuffer[512]; 530 signed short sound[512], monoBuffer[512];
526 531
527 while(recording) { 532 while(recording) {
528 533
529 result = read(dsp, sound, 512); // 8192 534 result = read(dsp, sound, 512); // 8192
530 535
531 write(wav, sound, result); 536 write(wav, sound, result);
532 length += result; 537 length += result;
533 if(length<0) { 538 if(length<0) {
534 539
535 recording=false; 540 recording=false;
@@ -550,64 +555,71 @@ void VMemo::record(void)
550 value = length+36; 555 value = length+36;
551 556
552 lseek(wav, 4, SEEK_SET); 557 lseek(wav, 4, SEEK_SET);
553 write(wav, &value, 4); 558 write(wav, &value, 4);
554 lseek(wav, 40, SEEK_SET); 559 lseek(wav, 40, SEEK_SET);
555 560
556 write(wav, &length, 4); 561 write(wav, &length, 4);
557 562
558 track.close(); 563 track.close();
559 qDebug("Tracvk closed"); 564 qDebug("Tracvk closed");
560 565
561 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) 566 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1)
562 perror("ioctl(\"SNDCTL_DSP_RESET\")"); 567 perror("ioctl(\"SNDCTL_DSP_RESET\")");
563 568
564 ::close(dsp); 569 ::close(dsp);
565 fileName = fileName.left(fileName.length()-4); 570 fileName = fileName.left(fileName.length()-4);
566 // if(useAlerts) 571 // if(useAlerts)
567 // QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); 572 // QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName);
568 qDebug("done recording "+fileName); 573 qDebug("done recording "+fileName);
569 QSound::play(Resource::findSound("vmemoe")); 574 QSound::play(Resource::findSound("vmemoe"));
570 575
571 Config cfg("qpe"); 576 Config cfg("qpe");
572 cfg.setGroup("Volume"); 577 cfg.setGroup("Volume");
573 QString foo = cfg.readEntry("Mute","TRUE"); 578 QString foo = cfg.readEntry("Mute","TRUE");
574 if(foo.find("TRUE",0,TRUE) != -1) 579 if(foo.find("TRUE",0,TRUE) != -1)
575 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute 580 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute
576 581
577} 582}
578 583
579int VMemo::setToggleButton(int tog) { 584int VMemo::setToggleButton(int tog) {
580 585
581 for( int i=0; i < 10;i++) { 586 for( int i=0; i < 10;i++) {
582 switch (tog) { 587 switch (tog) {
583 case 0: 588 case 0:
584 return -1; 589 return -1;
585 break; 590 break;
586 case 1: 591 case 1:
587 return 0; 592 return 0;
588 break; 593 break;
589 case 2: 594 case 2:
590 return Key_Escape; 595 return Key_Escape;
591 break; 596 break;
592 case 3: 597 case 3:
593 return Key_Space; 598 return Key_Space;
594 break; 599 break;
595 case 4: 600 case 4:
596 return Key_F12; 601 return Key_F12;
597 break; 602 break;
598 case 5: 603 case 5:
599 return Key_F9; 604 return Key_F9;
600 break; 605 break;
601 case 6: 606 case 6:
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
620void 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
@@ -1,59 +1,63 @@
1/**************************************************************************************94x78** 1/**************************************************************************************94x78**
2** 2**
3** This file may be distributed and/or modified under the terms of the 3** This file may be distributed and/or modified under the terms of the
4** GNU General Public License version 2 as published by the Free Software 4** GNU General Public License version 2 as published by the Free Software
5** Foundation and appearing in the file LICENSE.GPL included in the 5** Foundation and appearing in the file LICENSE.GPL included in the
6** packaging of this file. 6** packaging of this file.
7** 7**
8** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 8** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
9** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 9** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
10** 10**
11*********************************************************************************************/ 11*********************************************************************************************/
12 12
13/* 13/*
14 * $Id$ 14 * $Id$
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
28class VMemo : public QWidget 29class VMemo : public QWidget
29{ 30{
30 Q_OBJECT 31 Q_OBJECT
31public: 32public:
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
37public slots: 40public 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();
44private: 48private:
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;
56}; 60};
57 61
58#endif // __VMEMO_H__ 62#endif // __VMEMO_H__
59 63