summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-04-27 04:33:57 (UTC)
committer llornkcor <llornkcor>2002-04-27 04:33:57 (UTC)
commite2f3288d468508f2cf7c0a327044963ca4b1b54a (patch) (unidiff)
treed149829fdc65a58b6feb200868bd0f28c5f37cd0
parent8ca9c8dad17ccaee9b0b8132324176c2a8e40526 (diff)
downloadopie-e2f3288d468508f2cf7c0a327044963ca4b1b54a.zip
opie-e2f3288d468508f2cf7c0a327044963ca4b1b54a.tar.gz
opie-e2f3288d468508f2cf7c0a327044963ca4b1b54a.tar.bz2
bug fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index 4b668de..ec46340 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -1,76 +1,76 @@
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/* 12/*
13 * $Id$ 13 * $Id$
14 */ 14 */
15// Sun 03-17-2002 L.J.Potter <ljp@llornkcor.com> 15// Sun 03-17-2002 L.J.Potter <ljp@llornkcor.com>
16#include <sys/utsname.h> 16#include <sys/utsname.h>
17#include <sys/time.h> 17#include <sys/time.h>
18#include <sys/types.h> 18#include <sys/types.h>
19#include <unistd.h> 19#include <unistd.h>
20#include <stdio.h> 20#include <stdio.h>
21#include <sys/stat.h> 21#include <sys/stat.h>
22#include <fcntl.h> 22#include <fcntl.h>
23#include <sys/ioctl.h> 23#include <sys/ioctl.h>
24#include <linux/soundcard.h> 24#include <linux/soundcard.h>
25
25#include <string.h> 26#include <string.h>
26#include <stdlib.h> 27#include <stdlib.h>
27#include <errno.h> 28#include <errno.h>
28#include <string.h>
29 29
30typedef struct _waveheader { 30typedef struct _waveheader {
31 u_long main_chunk; /* 'RIFF' */ 31 u_long main_chunk; /* 'RIFF' */
32 u_long length; /* filelen */ 32 u_long length; /* filelen */
33 u_long chunk_type; /* 'WAVE' */ 33 u_long chunk_type; /* 'WAVE' */
34 u_long sub_chunk; /* 'fmt ' */ 34 u_long sub_chunk; /* 'fmt ' */
35 u_long sc_len; /* length of sub_chunk, =16 35 u_long sc_len; /* length of sub_chunk, =16
36 (chunckSize) format len */ 36 (chunckSize) format len */
37 u_short format; /* should be 1 for PCM-code (formatTag) */ 37 u_short format; /* should be 1 for PCM-code (formatTag) */
38 38
39 u_short modus; /* 1 Mono, 2 Stereo (channels) */ 39 u_short modus; /* 1 Mono, 2 Stereo (channels) */
40 u_long sample_fq; /* samples per second (samplesPerSecond) */ 40 u_long sample_fq; /* samples per second (samplesPerSecond) */
41 u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */ 41 u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */
42 u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */ 42 u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */
43 u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */ 43 u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */
44 44
45 u_long data_chunk; /* 'data' */ 45 u_long data_chunk; /* 'data' */
46 46
47 u_long data_length;/* samplecount */ 47 u_long data_length;/* samplecount */
48} WaveHeader; 48} WaveHeader;
49 49
50#define RIFF 0x46464952 50#define RIFF 0x46464952
51#define WAVE 0x45564157 51#define WAVE 0x45564157
52#define FMT 0x20746D66 52#define FMT 0x20746D66
53#define DATA 0x61746164 53#define DATA 0x61746164
54#define PCM_CODE 1 54#define PCM_CODE 1
55#define WAVE_MONO 1 55#define WAVE_MONO 1
56#define WAVE_STEREO 2 56#define WAVE_STEREO 2
57 57
58#include "vmemo.h" 58#include "vmemo.h"
59 59
60#include <qpe/qpeapplication.h> 60#include <qpe/qpeapplication.h>
61#include <qpe/resource.h> 61#include <qpe/resource.h>
62#include <qpe/config.h> 62#include <qpe/config.h>
63 63
64#include <qpainter.h> 64#include <qpainter.h>
65#include <qdatetime.h> 65#include <qdatetime.h>
66#include <qsound.h> 66#include <qsound.h>
67#include <qfile.h> 67#include <qfile.h>
68#include <qmessagebox.h> 68#include <qmessagebox.h>
69 69
70int seq = 0; 70int seq = 0;
71 71
72/* XPM */ 72/* XPM */
73static char * vmemo_xpm[] = { 73static char * vmemo_xpm[] = {
74"16 16 102 2", 74"16 16 102 2",
75" c None", 75" c None",
76". c #60636A", 76". c #60636A",
@@ -248,97 +248,97 @@ void VMemo::mousePressEvent( QMouseEvent *me )
248 recording = FALSE; 248 recording = FALSE;
249 return; 249 return;
250 } 250 }
251 251
252 /* 252 /*
253 No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions 253 No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions
254 mousePressEvent and mouseReleaseEvent with a NULL parameter. 254 mousePressEvent and mouseReleaseEvent with a NULL parameter.
255 */ 255 */
256#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 256#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
257 if (!systemZaurus ) 257 if (!systemZaurus )
258 return; 258 return;
259#endif 259#endif
260 260
261 Config config( "Sound" ); 261 Config config( "Sound" );
262 config.setGroup( "System" ); 262 config.setGroup( "System" );
263 useAlerts = config.readBoolEntry("Alert"); 263 useAlerts = config.readBoolEntry("Alert");
264 264
265// if(useAlerts) 265// if(useAlerts)
266// QMessageBox::message("VMemo","Really Record?");//) ==1) 266// QMessageBox::message("VMemo","Really Record?");//) ==1)
267// return; 267// return;
268// } else { 268// } else {
269 if (!systemZaurus ) 269 if (!systemZaurus )
270 QSound::play(Resource::findSound("vmemob")); 270 QSound::play(Resource::findSound("vmemob"));
271// } 271// }
272 qDebug("Start recording"); 272 qDebug("Start recording");
273 recording = TRUE; 273 recording = TRUE;
274 if (openDSP() == -1) { 274 if (openDSP() == -1) {
275 QMessageBox::critical(0, "VMemo", "Could not open dsp device.\n"+errorMsg, "Abort"); 275 QMessageBox::critical(0, "VMemo", "Could not open dsp device.\n"+errorMsg, "Abort");
276 recording = FALSE; 276 recording = FALSE;
277 return; 277 return;
278 } 278 }
279 279
280 Config vmCfg("VMemo"); 280 Config vmCfg("VMemo");
281 vmCfg.setGroup("Defaults"); 281 vmCfg.setGroup("Defaults");
282 282
283 QDateTime dt = QDateTime::currentDateTime(); 283 QDateTime dt = QDateTime::currentDateTime();
284 284
285 QString fName; 285 QString fName;
286 Config cfg( "Sound" ); 286 Config cfg( "Sound" );
287 cfg.setGroup( "System" ); 287 cfg.setGroup( "System" );
288 fName = QPEApplication::documentDir() ; 288 fName = QPEApplication::documentDir() ;
289 fileName = cfg.readEntry("RecLocation", fName); 289 fileName = cfg.readEntry("RecLocation", fName);
290 290
291 int s; 291 int s;
292 s=fileName.find(':'); 292 s=fileName.find(':');
293 if(s) 293 if(s)
294 fileName=fileName.right(fileName.length()-s-2); 294 fileName=fileName.right(fileName.length()-s-2);
295 qDebug("filename will be "+fileName); 295 qDebug("filename will be "+fileName);
296 if( !fileName.right(1).find('/') == -1) 296 if( fileName.right(1).find('/') == -1)
297 fileName+="/"; 297 fileName+="/";
298 298
299// if(systemZaurus) 299// if(systemZaurus)
300// fileName=vmCfg.readEntry("Dir", "/mnt/cf/"); // zaurus does not have /mnt/ramfs 300// fileName=vmCfg.readEntry("Dir", "/mnt/cf/"); // zaurus does not have /mnt/ramfs
301// else 301// else
302// fileName=vmCfg.readEntry("Dir", "/mnt/ramfs/"); 302// fileName=vmCfg.readEntry("Dir", "/mnt/ramfs/");
303 303
304 fName = "vm_"+ dt.toString()+ ".wav"; 304 fName = "vm_"+ dt.toString()+ ".wav";
305 305
306 fileName+=fName; 306 fileName+=fName;
307 qDebug("filename is "+fileName); 307 qDebug("filename is "+fileName);
308 // No spaces in the filename 308 // No spaces in the filename
309 fileName.replace(QRegExp("'"),""); 309 fileName.replace(QRegExp("'"),"");
310 fileName.replace(QRegExp(" "),"_"); 310 fileName.replace(QRegExp(" "),"_");
311 fileName.replace(QRegExp(":"),"."); 311 fileName.replace(QRegExp(":"),".");
312 fileName.replace(QRegExp(","),""); 312 fileName.replace(QRegExp(","),"");
313 313
314 if(openWAV(fileName.latin1()) == -1) { 314 if(openWAV(fileName.latin1()) == -1) {
315 QString err("Could not open the output file\n"); 315 QString err("Could not open the output file\n");
316 err += fileName; 316 err += fileName;
317 QMessageBox::critical(0, "VMemo", err, "Abort"); 317 QMessageBox::critical(0, "VMemo", err, "Abort");
318 close(dsp); 318 close(dsp);
319 return; 319 return;
320 } 320 }
321 321
322 QArray<int> cats(1); 322 QArray<int> cats(1);
323 cats[0] = vmCfg.readNumEntry("Category", 0); 323 cats[0] = vmCfg.readNumEntry("Category", 0);
324 324
325 QString dlName("vm_"); 325 QString dlName("vm_");
326 dlName += dt.toString(); 326 dlName += dt.toString();
327 DocLnk l; 327 DocLnk l;
328 l.setFile(fileName); 328 l.setFile(fileName);
329 l.setName(dlName); 329 l.setName(dlName);
330 l.setType("audio/x-wav"); 330 l.setType("audio/x-wav");
331 l.setCategories(cats); 331 l.setCategories(cats);
332 l.writeLink(); 332 l.writeLink();
333 333
334 record(); 334 record();
335} 335}
336 336
337void VMemo::mouseReleaseEvent( QMouseEvent * ) 337void VMemo::mouseReleaseEvent( QMouseEvent * )
338{ 338{
339 recording = FALSE; 339 recording = FALSE;
340} 340}
341 341
342int VMemo::openDSP() 342int VMemo::openDSP()
343{ 343{
344 Config cfg("Sound"); 344 Config cfg("Sound");