summaryrefslogtreecommitdiff
Unidiff
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
@@ -3,3 +3,3 @@
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$)
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,2 +1,2 @@
1/**************************************************************************************94x78** 1/************************************************************************************
2** 2**
@@ -10,3 +10,3 @@
10** 10**
11*********************************************************************************************/ 11************************************************************************************/
12 12
@@ -29,10 +29,10 @@
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) */
@@ -42,12 +42,12 @@ typedef struct _waveheader {
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
@@ -64,2 +64,3 @@ typedef struct _waveheader {
64#include <qfile.h> 64#include <qfile.h>
65#include <qmessagebox.h>
65 66
@@ -140,12 +141,15 @@ VMemo::VMemo( QWidget *parent, const char *name )
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}
@@ -164,2 +168,9 @@ void 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()");
@@ -170,9 +181,9 @@ void VMemo::mousePressEvent( QMouseEvent * )
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");
@@ -183,5 +194,5 @@ void VMemo::mousePressEvent( QMouseEvent * )
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
@@ -198,9 +209,9 @@ void VMemo::mousePressEvent( QMouseEvent * )
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);
@@ -224,3 +235,2 @@ void VMemo::mouseReleaseEvent( QMouseEvent * )
224 recording = FALSE; 235 recording = FALSE;
225 QSound::play(Resource::findSound("vmemoe"));
226} 236}
@@ -235,43 +245,44 @@ int VMemo::openDSP()
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;
@@ -281,4 +292,2 @@ int VMemo::openWAV(const char *filename)
281{ 292{
282 char buffer[256];
283
284 qDebug("Creating %s ",filename); 293 qDebug("Creating %s ",filename);
@@ -286,6 +295,6 @@ int VMemo::openWAV(const char *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();
@@ -294,18 +303,2 @@ int VMemo::openWAV(const char *filename)
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;
@@ -323,8 +316,2 @@ int VMemo::openWAV(const char *filename)
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;
@@ -345,9 +332,11 @@ void VMemo::record(void)
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");
@@ -363,6 +352,9 @@ void VMemo::record(void)
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}