summaryrefslogtreecommitdiff
authorjeremy <jeremy>2002-02-14 04:01:40 (UTC)
committer jeremy <jeremy>2002-02-14 04:01:40 (UTC)
commitc47e1afcc185c05f4e1d9178566032df74981489 (patch) (unidiff)
tree7e3a6d3660920de9d3f6b888fac87a4f8c8e92f1
parent3d4486b3a89e45785f92d8d963b334ddd4ac095a (diff)
downloadopie-c47e1afcc185c05f4e1d9178566032df74981489.zip
opie-c47e1afcc185c05f4e1d9178566032df74981489.tar.gz
opie-c47e1afcc185c05f4e1d9178566032df74981489.tar.bz2
Just eradicating bugs. Still not ready for public/general use.
----------------------------------------------------------------------
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/moc_vmemo.cpp2
-rw-r--r--core/applets/vmemo/vmemo.cpp222
2 files changed, 108 insertions, 116 deletions
diff --git a/core/applets/vmemo/moc_vmemo.cpp b/core/applets/vmemo/moc_vmemo.cpp
index 7e68ac1..fbe1f6b 100644
--- a/core/applets/vmemo/moc_vmemo.cpp
+++ b/core/applets/vmemo/moc_vmemo.cpp
@@ -1,52 +1,52 @@
1/**************************************************************************** 1/****************************************************************************
2** VMemo meta object code from reading C++ file 'vmemo.h' 2** VMemo meta object code from reading C++ file 'vmemo.h'
3** 3**
4** Created: Wed Feb 13 17:52:12 2002 4** Created: Wed Feb 13 21:49:42 2002
5** by: The Qt MOC ($Id$) 5** by: The Qt MOC ($Id$)
6** 6**
7** WARNING! All changes made in this file will be lost! 7** WARNING! All changes made in this file will be lost!
8*****************************************************************************/ 8*****************************************************************************/
9 9
10#if !defined(Q_MOC_OUTPUT_REVISION) 10#if !defined(Q_MOC_OUTPUT_REVISION)
11#define Q_MOC_OUTPUT_REVISION 9 11#define Q_MOC_OUTPUT_REVISION 9
12#elif Q_MOC_OUTPUT_REVISION != 9 12#elif Q_MOC_OUTPUT_REVISION != 9
13#error "Moc format conflict - please regenerate all moc files" 13#error "Moc format conflict - please regenerate all moc files"
14#endif 14#endif
15 15
16#include "vmemo.h" 16#include "vmemo.h"
17#include <qmetaobject.h> 17#include <qmetaobject.h>
18#include <qapplication.h> 18#include <qapplication.h>
19 19
20 20
21 21
22const char *VMemo::className() const 22const char *VMemo::className() const
23{ 23{
24 return "VMemo"; 24 return "VMemo";
25} 25}
26 26
27QMetaObject *VMemo::metaObj = 0; 27QMetaObject *VMemo::metaObj = 0;
28 28
29void VMemo::initMetaObject() 29void VMemo::initMetaObject()
30{ 30{
31 if ( metaObj ) 31 if ( metaObj )
32 return; 32 return;
33 if ( qstrcmp(QWidget::className(), "QWidget") != 0 ) 33 if ( qstrcmp(QWidget::className(), "QWidget") != 0 )
34 badSuperclassWarning("VMemo","QWidget"); 34 badSuperclassWarning("VMemo","QWidget");
35 (void) staticMetaObject(); 35 (void) staticMetaObject();
36} 36}
37 37
38#ifndef QT_NO_TRANSLATION 38#ifndef QT_NO_TRANSLATION
39 39
40QString VMemo::tr(const char* s) 40QString VMemo::tr(const char* s)
41{ 41{
42 return qApp->translate( "VMemo", s, 0 ); 42 return qApp->translate( "VMemo", s, 0 );
43} 43}
44 44
45QString VMemo::tr(const char* s, const char * c) 45QString VMemo::tr(const char* s, const char * c)
46{ 46{
47 return qApp->translate( "VMemo", s, c ); 47 return qApp->translate( "VMemo", s, c );
48} 48}
49 49
50#endif // QT_NO_TRANSLATION 50#endif // QT_NO_TRANSLATION
51 51
52QMetaObject* VMemo::staticMetaObject() 52QMetaObject* VMemo::staticMetaObject()
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index 6bd1622..73bd996 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -1,368 +1,360 @@
1/**************************************************************************************94x78** 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 12
13/* 13/*
14 * $Id$ 14 * $Id$
15 */ 15 */
16 16
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#include <string.h> 26#include <string.h>
27#include <stdlib.h> 27#include <stdlib.h>
28 28
29typedef struct _waveheader { 29typedef struct _waveheader {
30 u_long main_chunk; /* 'RIFF' */ 30 u_long main_chunk; /* 'RIFF' */
31 u_long length; /* filelen */ 31 u_long length; /* filelen */
32 u_long chunk_type; /* 'WAVE' */ 32 u_long chunk_type; /* 'WAVE' */
33 33
34 u_long sub_chunk; /* 'fmt ' */ 34 u_long sub_chunk; /* 'fmt ' */
35 u_long sc_len; /* length of sub_chunk, =16 (chunckSize) */ 35 u_long sc_len; /* length of sub_chunk, =16 (chunckSize) */
36 u_short format; /* should be 1 for PCM-code (formatTag) */ 36 u_short format; /* should be 1 for PCM-code (formatTag) */
37 u_short modus; /* 1 Mono, 2 Stereo (channels) */ 37 u_short modus; /* 1 Mono, 2 Stereo (channels) */
38 u_long sample_fq; /* samples per second (samplesPerSecond) */ 38 u_long sample_fq; /* samples per second (samplesPerSecond) */
39 u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */ 39 u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */
40 u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */ 40 u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */
41 u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */ 41 u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */
42 42
43 u_long data_chunk; /* 'data' */ 43 u_long data_chunk; /* 'data' */
44 u_long data_length; /* samplecount */ 44 u_long data_length;/* samplecount */
45} WaveHeader; 45} WaveHeader;
46 46
47#define RIFF 0x46464952 47#define RIFF 0x46464952
48#define WAVE 0x45564157 48#define WAVE 0x45564157
49#define FMT 0x20746D66 49#define FMT 0x20746D66
50#define DATA 0x61746164 50#define DATA 0x61746164
51#define PCM_CODE 1 51#define PCM_CODE 1
52#define WAVE_MONO 1 52#define WAVE_MONO 1
53#define WAVE_STEREO 2 53#define WAVE_STEREO 2
54 54
55#include "vmemo.h" 55#include "vmemo.h"
56 56
57#include <qpe/qpeapplication.h> 57#include <qpe/qpeapplication.h>
58#include <qpe/resource.h> 58#include <qpe/resource.h>
59#include <qpe/config.h> 59#include <qpe/config.h>
60 60
61#include <qpainter.h> 61#include <qpainter.h>
62#include <qdatetime.h> 62#include <qdatetime.h>
63#include <qsound.h> 63#include <qsound.h>
64#include <qfile.h> 64#include <qfile.h>
65#include <qmessagebox.h>
65 66
66int seq = 0; 67int seq = 0;
67 68
68/* XPM */ 69/* XPM */
69static char * vmemo_xpm[] = { 70static char * vmemo_xpm[] = {
70"14 14 47 1", 71"14 14 47 1",
71" c None", 72" c None",
72". c #101010", 73". c #101010",
73"+ c #0D0D0D", 74"+ c #0D0D0D",
74"@ c #0B0B0B", 75"@ c #0B0B0B",
75"# c #393939", 76"# c #393939",
76"$ c #6C6C6C", 77"$ c #6C6C6C",
77"% c #5D5D5D", 78"% c #5D5D5D",
78"& c #4E4E4E", 79"& c #4E4E4E",
79"* c #1C1C1C", 80"* c #1C1C1C",
80"= c #131313", 81"= c #131313",
81"- c #7B7B7B", 82"- c #7B7B7B",
82"; c #303030", 83"; c #303030",
83"> c #383838", 84"> c #383838",
84", c #3F3F3F", 85", c #3F3F3F",
85"' c #343434", 86"' c #343434",
86") c #060606", 87") c #060606",
87"! c #444444", 88"! c #444444",
88"~ c #646464", 89"~ c #646464",
89"{ c #505050", 90"{ c #505050",
90"] c #717171", 91"] c #717171",
91"^ c #1B1B1B", 92"^ c #1B1B1B",
92"/ c #585858", 93"/ c #585858",
93"( c #4C4C4C", 94"( c #4C4C4C",
94"_ c #353535", 95"_ c #353535",
95": c #0E0E0E", 96": c #0E0E0E",
96"< c #080808", 97"< c #080808",
97"[ c #262626", 98"[ c #262626",
98"} c #121212", 99"} c #121212",
99"| c #7F7F7F", 100"| c #7F7F7F",
100"1 c #464646", 101"1 c #464646",
101"2 c #0C0C0C", 102"2 c #0C0C0C",
102"3 c #727272", 103"3 c #727272",
103"4 c #292929", 104"4 c #292929",
104"5 c #656565", 105"5 c #656565",
105"6 c #565656", 106"6 c #565656",
106"7 c #434343", 107"7 c #434343",
107"8 c #272727", 108"8 c #272727",
108"9 c #0F0F0F", 109"9 c #0F0F0F",
109"0 c #3A3A3A", 110"0 c #3A3A3A",
110"a c #090909", 111"a c #090909",
111"b c #535353", 112"b c #535353",
112"c c #545454", 113"c c #545454",
113"d c #494949", 114"d c #494949",
114"e c #7A7A7A", 115"e c #7A7A7A",
115"f c #202020", 116"f c #202020",
116"g c #3D3D3D", 117"g c #3D3D3D",
117"h c #1F1F1F", 118"h c #1F1F1F",
118" .+@ ", 119" .+@ ",
119" #$%&* ", 120" #$%&* ",
120" =-;>,')", 121" =-;>,')",
121" .$;!~,)", 122" .$;!~,)",
122" ;#{]!)", 123" ;#{]!)",
123" ^~/(_)", 124" ^~/(_)",
124" ./:@<[)", 125" ./:@<[)",
125" }. .|]1;;2 ", 126" }. .|]1;;2 ",
126" #-$;^/3&;;4@ ", 127" #-$;^/3&;;4@ ",
127".$;;#5:67;89 ", 128".$;;#5:67;89 ",
128":%;0%&ab;8. ", 129":%;0%&ab;8. ",
129"@cd%e!fg49 ", 130"@cd%e!fg49 ",
130" h0,!_;2@ ", 131" h0,!_;2@ ",
131" ))))) "}; 132" ))))) "};
132 133
133VMemo::VMemo( QWidget *parent, const char *name ) 134VMemo::VMemo( QWidget *parent, const char *name )
134 : QWidget( parent, name ) 135 : QWidget( parent, name )
135{ 136{
136 setFixedHeight( 18 ); 137 setFixedHeight( 18 );
137 setFixedWidth( 14 ); 138 setFixedWidth( 14 );
138 139
139 recording = FALSE; 140 recording = FALSE;
140 141
141 struct utsname name; //check for embedix kernel running on the zaurus, if lineo change string, this break 142 struct utsname name; /* check for embedix kernel running on the zaurus, if
142 if (uname(&name) != -1) { 143 lineo change string, this break
143 QString release=name.release; 144 */
144 if(release.find("embedix",0,TRUE) !=-1) { 145 if (uname(&name) != -1)
145 systemZaurus=TRUE; 146 {
146 printf("System release: %s\n", name.release); 147 QString release=name.release;
147 } else 148 qWarning("System release: %s\n", name.release);
148 systemZaurus=FALSE; 149 if(release.find("embedix",0,TRUE) !=-1)
149 } 150 systemZaurus=TRUE;
150 151 else
152 systemZaurus=FALSE;
153 }
154
151} 155}
152 156
153VMemo::~VMemo() 157VMemo::~VMemo()
154{ 158{
155} 159}
156 160
157void VMemo::paintEvent( QPaintEvent* ) 161void VMemo::paintEvent( QPaintEvent* )
158{ 162{
159 QPainter p(this); 163 QPainter p(this);
160 p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); 164 p.drawPixmap( 0, 1,( const char** ) vmemo_xpm );
161} 165}
162 166
163void VMemo::mousePressEvent( QMouseEvent * ) 167void VMemo::mousePressEvent( QMouseEvent * )
164{ 168{
169 // just to be safe
170 if (recording)
171 {
172 recording = FALSE;
173 return;
174 }
175
165 qWarning("VMemo::mousePress()"); 176 qWarning("VMemo::mousePress()");
166 QSound::play(Resource::findSound("vmemob")); 177 QSound::play(Resource::findSound("vmemob"));
167 178
168 recording = TRUE; 179 recording = TRUE;
169 qWarning("VMemo::mousePress() -> Starting to record"); 180 qWarning("VMemo::mousePress() -> Starting to record");
170 if (openDSP() == -1) 181 if (openDSP() == -1)
171 { 182 {
172 // ### Display an error box 183 // ### Display an error box
173 qWarning("VMemo::mousePress() -> DSP error"); 184 QMessageBox::critical(0, "VMemo", "Could not open dsp device.", "Abort");
174 recording = FALSE; 185 recording = FALSE;
175 return; 186 return;
176 } 187 }
177 188
178 Config vmCfg("VMemo"); 189 Config vmCfg("VMemo");
179 vmCfg.setGroup("Defaults"); 190 vmCfg.setGroup("Defaults");
180 191
181 QDateTime dt = QDateTime::currentDateTime(); 192 QDateTime dt = QDateTime::currentDateTime();
182 QString fileName; 193 QString fileName;
183 if(systemZaurus) 194 if(systemZaurus)
184 fileName=vmCfg.readEntry("Dir", "/mnt/cf/"); // zaurus does not have /mnt/ramfs 195 fileName=vmCfg.readEntry("Dir", "/mnt/cf/"); // zaurus does not have /mnt/ramfs
185 else 196 else
186 fileName=vmCfg.readEntry("Dir", "/mnt/ramfs/"); 197 fileName=vmCfg.readEntry("Dir", "/mnt/ramfs/");
187 198
188 fileName += "vm_"; 199 fileName += "vm_";
189 fileName += dt.toString(); 200 fileName += dt.toString();
190 fileName += ".wav"; 201 fileName += ".wav";
191 202
192 // No spaces in the filename 203 // No spaces in the filename
193 fileName.replace(QRegExp("'"),""); 204 fileName.replace(QRegExp("'"),"");
194 fileName.replace(QRegExp(" "),"_"); 205 fileName.replace(QRegExp(" "),"_");
195 fileName.replace(QRegExp(":"),"."); 206 fileName.replace(QRegExp(":"),".");
196 fileName.replace(QRegExp(","),""); 207 fileName.replace(QRegExp(","),"");
197 208
198 if(openWAV(fileName.latin1()) == -1) 209 if(openWAV(fileName.latin1()) == -1)
199 { 210 {
200 // ### Display an error box 211 // ### Display an error box
201 qWarning("VMemo::mousePress() -> WAV error"); 212 qWarning("VMemo::mousePress() -> WAV error");
202 close(dsp); 213 close(dsp);
203 return; 214 return;
204 } 215 }
205 216
206 QArray<int> cats(1); 217 QArray<int> cats(1);
207 cats[0] = vmCfg.readNumEntry("Category", 0); 218 cats[0] = vmCfg.readNumEntry("Category", 0);
208 219
209 QString dlName("vm_"); 220 QString dlName("vm_");
210 dlName += dt.toString(); 221 dlName += dt.toString();
211 DocLnk l; 222 DocLnk l;
212 l.setFile(fileName); 223 l.setFile(fileName);
213 l.setName(dlName); 224 l.setName(dlName);
214 l.setType("audio/x-wav"); 225 l.setType("audio/x-wav");
215 l.setCategories(cats); 226 l.setCategories(cats);
216 l.writeLink(); 227 l.writeLink();
217 228
218 record(); 229 record();
219} 230}
220 231
221void VMemo::mouseReleaseEvent( QMouseEvent * ) 232void VMemo::mouseReleaseEvent( QMouseEvent * )
222{ 233{
223 qWarning("VMemo::mouseRelese() -> Done recording"); 234 qWarning("VMemo::mouseRelese() -> Done recording");
224 recording = FALSE; 235 recording = FALSE;
225 QSound::play(Resource::findSound("vmemoe"));
226} 236}
227 237
228int VMemo::openDSP() 238int VMemo::openDSP()
229{ 239{
230 Config cfg("Sound"); 240 Config cfg("Sound");
231 cfg.setGroup("Record"); 241 cfg.setGroup("Record");
232 242
233 speed = cfg.readNumEntry("SampleRate", 11025); 243 speed = cfg.readNumEntry("SampleRate", 11025);
234 channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) 244 channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1)
235 if (cfg.readNumEntry("SixteenBit", 1)) 245 if (cfg.readNumEntry("SixteenBit", 1))
236 { 246 {
237 format = AFMT_S16_LE; 247 format = AFMT_S16_LE;
238 resolution = 16; 248 resolution = 16;
239 } 249 }
240 else 250 else
241 { 251 {
242 format = AFMT_U8; 252 format = AFMT_U8;
243 resolution = 8; 253 resolution = 8;
244 } 254 }
245 255
246 if(systemZaurus) 256 if(systemZaurus)
247 dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 257 dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1
248 else 258 else
249 dsp = open("/dev/dsp", O_RDWR); 259 dsp = open("/dev/dsp", O_RDWR);
250 260
251 qWarning("speed = %i", speed);
252
253 if(dsp == -1) 261 if(dsp == -1)
254 { 262 {
255 perror("open(\"/dev/dsp\")"); 263 perror("open(\"/dev/dsp\")");
256 return -1; 264 return -1;
257 } 265 }
258 266
259 if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { 267 if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1)
260 perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); 268 {
261 return -1; 269 perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
262 } 270 return -1;
263 if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { 271 }
264 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); 272 if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1)
265 return -1; 273 {
266 } 274 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")");
267 if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { 275 return -1;
268 perror("ioctl(\"SNDCTL_DSP_SPEED\")"); 276 }
269 return -1; 277 if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1)
270 } 278 {
271 if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { 279 perror("ioctl(\"SNDCTL_DSP_SPEED\")");
272 perror("ioctl(\"SOUND_PCM_READ_RATE\")"); 280 return -1;
273 return -1; 281 }
274 } 282 if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1)
275 qWarning("speed = %i", speed); 283 {
276 284 perror("ioctl(\"SOUND_PCM_READ_RATE\")");
285 return -1;
286 }
287
277 return 1; 288 return 1;
278} 289}
279 290
280int VMemo::openWAV(const char *filename) 291int VMemo::openWAV(const char *filename)
281{ 292{
282 char buffer[256];
283
284 qDebug("Creating %s ",filename); 293 qDebug("Creating %s ",filename);
285 track.setName(filename); 294 track.setName(filename);
286 if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) 295 if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw))
287 { 296 {
288 qDebug("Could not open file"); 297 qDebug("Could not open file");
289 return -1; 298 return -1;
290 } 299 }
291 wav=track.handle(); 300 wav=track.handle();
292 301
293 WaveHeader wh; 302 WaveHeader wh;
294 303
295 /*
296 wh.main_chunk = RIFF;
297 wh.length = 0;
298 wh.chunk_type = WAVE;
299 wh.sub_chunk = FMT;
300 wh.sc_len = 16;
301 wh.format = PCM_CODE;
302 wh.modus = channels;
303 wh.sample_fq = speed;
304 wh.byte_p_spl = ((resolution == 8) ? 1 : 2) * (channels ? 2 : 1);
305 wh.byte_p_sec = resolution; //speed * wh.modus * wh.byte_p_spl;
306 wh.bit_p_spl = resolution;
307 wh.data_chunk = DATA;
308 wh.data_length= 0;
309 */
310
311 wh.main_chunk = RIFF; 304 wh.main_chunk = RIFF;
312 wh.length = 0; 305 wh.length = 0;
313 wh.chunk_type = WAVE; 306 wh.chunk_type = WAVE;
314 307
315 wh.sub_chunk = FMT; 308 wh.sub_chunk = FMT;
316 wh.sc_len = 16; 309 wh.sc_len = 16;
317 wh.format = PCM_CODE; 310 wh.format = PCM_CODE;
318 wh.modus = channels; 311 wh.modus = channels;
319 wh.sample_fq = speed; 312 wh.sample_fq = speed;
320 wh.bit_p_spl = resolution; 313 wh.bit_p_spl = resolution;
321 wh.byte_p_sec = wh.sample_fq * wh.bit_p_spl; 314 wh.byte_p_sec = wh.sample_fq * wh.bit_p_spl;
322 wh.byte_p_spl = channels * (wh.bit_p_spl % 8); 315 wh.byte_p_spl = channels * (wh.bit_p_spl % 8);
323 316
324 qWarning("channels = %i\n"
325 "samplesPerSecond = %i\n"
326 "avgBytesPerSecond = %i\n"
327 "blockAlign = %i\n"
328 "bitsPerSecond = %i\n", wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl);
329
330 wh.data_chunk = DATA; 317 wh.data_chunk = DATA;
331 wh.data_length= 0; 318 wh.data_length= 0;
332 319
333 write (wav, &wh, sizeof(WaveHeader)); 320 write (wav, &wh, sizeof(WaveHeader));
334 321
335 return 1; 322 return 1;
336} 323}
337 324
338void VMemo::record(void) 325void VMemo::record(void)
339{ 326{
340 int length=0, result, value; 327 int length=0, result, value;
341 char sound[8192]; 328 char sound[8192];
342 329
343 qWarning("VMemo::record()"); 330 qWarning("VMemo::record()");
344 331
345 while(recording) 332 while(recording)
346 { 333 {
347 result = read(dsp, sound, 8192); 334 result = read(dsp, sound, 512); // 8192
348 write(wav, sound, result); 335 qApp->processEvents();
349 length += result; 336 write(wav, sound, result);
350 qApp->processEvents(); 337 qApp->processEvents();
351 } 338 length += result;
352 339 qApp->processEvents();
340 }
341
353 qWarning("VMemo::record() -> Done recording"); 342 qWarning("VMemo::record() -> Done recording");
354 qWarning("VMemo::record() -> Closing dsp"); 343 qWarning("VMemo::record() -> Closing dsp");
355 344
356 value = length+36; 345 value = length+36;
357 lseek(wav, 4, SEEK_SET); 346 lseek(wav, 4, SEEK_SET);
358 write(wav, &value, 4); 347 write(wav, &value, 4);
359 lseek(wav, 40, SEEK_SET); 348 lseek(wav, 40, SEEK_SET);
360 write(wav, &length, 4); 349 write(wav, &length, 4);
361 track.close(); 350 track.close();
362 351
363 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1)// ); //tell driver to stop for a while 352 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1)// ); //tell driver to stop for a while
364 perror("ioctl(\"SNDCTL_DSP_RESET\")"); 353 perror("ioctl(\"SNDCTL_DSP_RESET\")");
365 ::close(dsp); 354 ::close(dsp);
366 355
356 qWarning("VMemo::record() -> playing done recording sound");
357 QSound::play(Resource::findSound("vmemoe"));
367 qWarning("VMemo::record() -> terminating"); 358 qWarning("VMemo::record() -> terminating");
359 QMessageBox::information(0, "VMemo", "Recording Done", 1);
368} 360}