author | llornkcor <llornkcor> | 2002-04-24 23:47:05 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-24 23:47:05 (UTC) |
commit | b6958ff0363b194e129584a0a0a597bd643718a3 (patch) (unidiff) | |
tree | e5b68b3bd300e029685a58152f23d690895b9070 | |
parent | 26d2eaa54161d16521cfc7b2866dd8f14fe54b42 (diff) | |
download | opie-b6958ff0363b194e129584a0a0a597bd643718a3.zip opie-b6958ff0363b194e129584a0a0a597bd643718a3.tar.gz opie-b6958ff0363b194e129584a0a0a597bd643718a3.tar.bz2 |
bug fix
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index 4c55dc7..22cb276 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -245,71 +245,74 @@ void VMemo::paintEvent( QPaintEvent* ) | |||
245 | void VMemo::mousePressEvent( QMouseEvent *me ) | 245 | void VMemo::mousePressEvent( QMouseEvent *me ) |
246 | { | 246 | { |
247 | // just to be safe | 247 | // just to be safe |
248 | if (recording) { | 248 | if (recording) { |
249 | recording = FALSE; | 249 | recording = FALSE; |
250 | return; | 250 | return; |
251 | } | 251 | } |
252 | 252 | ||
253 | /* | 253 | /* |
254 | No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions | 254 | No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions |
255 | mousePressEvent and mouseReleaseEvent with a NULL parameter. | 255 | mousePressEvent and mouseReleaseEvent with a NULL parameter. |
256 | */ | 256 | */ |
257 | if (!systemZaurus && me != NULL) | 257 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
258 | return; | 258 | if (!systemZaurus ) |
259 | 259 | return; | |
260 | #endif | ||
261 | |||
260 | Config config( "Sound" ); | 262 | Config config( "Sound" ); |
261 | config.setGroup( "System" ); | 263 | config.setGroup( "System" ); |
262 | useAlerts = config.readBoolEntry("Alert"); | 264 | useAlerts = config.readBoolEntry("Alert"); |
263 | 265 | ||
264 | // if(useAlerts) | 266 | // if(useAlerts) |
265 | // QMessageBox::message("VMemo","Really Record?");//) ==1) | 267 | // QMessageBox::message("VMemo","Really Record?");//) ==1) |
266 | // return; | 268 | // return; |
267 | // } else { | 269 | // } else { |
270 | if (!systemZaurus ) | ||
268 | QSound::play(Resource::findSound("vmemob")); | 271 | QSound::play(Resource::findSound("vmemob")); |
269 | // } | 272 | // } |
270 | qDebug("Start recording"); | 273 | qDebug("Start recording"); |
271 | recording = TRUE; | 274 | recording = TRUE; |
272 | if (openDSP() == -1) { | 275 | if (openDSP() == -1) { |
273 | QMessageBox::critical(0, "VMemo", "Could not open dsp device.\n"+errorMsg, "Abort"); | 276 | QMessageBox::critical(0, "VMemo", "Could not open dsp device.\n"+errorMsg, "Abort"); |
274 | recording = FALSE; | 277 | recording = FALSE; |
275 | return; | 278 | return; |
276 | } | 279 | } |
277 | 280 | ||
278 | Config vmCfg("VMemo"); | 281 | Config vmCfg("VMemo"); |
279 | vmCfg.setGroup("Defaults"); | 282 | vmCfg.setGroup("Defaults"); |
280 | 283 | ||
281 | QDateTime dt = QDateTime::currentDateTime(); | 284 | QDateTime dt = QDateTime::currentDateTime(); |
282 | 285 | ||
283 | QString fName; | 286 | QString fName; |
284 | Config cfg( "Sound" ); | 287 | Config cfg( "Sound" ); |
285 | cfg.setGroup( "System" ); | 288 | cfg.setGroup( "System" ); |
286 | fileName = cfg.readEntry("RecLocation",QPEApplication::documentDir() ); | 289 | fName = QPEApplication::documentDir() ; |
290 | fileName = cfg.readEntry("RecLocation", fName); | ||
287 | 291 | ||
288 | int s; | 292 | int s; |
289 | s=fileName.find(':'); | 293 | s=fileName.find(':'); |
290 | if(s) | 294 | if(s) |
291 | fileName=fileName.right(fileName.length()-s-2)+"/"; | 295 | fileName=fileName.right(fileName.length()-s-2); |
292 | 296 | qDebug("filename will be "+fileName); | |
293 | // if( !fileName.right(1).find('/') == -1) | 297 | if( !fileName.right(1).find('/') == -1) |
294 | // fileName+="/audio/"; | 298 | fileName+="/"; |
295 | // else | ||
296 | // fileName+="audio/"; | ||
297 | 299 | ||
298 | // if(systemZaurus) | 300 | // if(systemZaurus) |
299 | // fileName=vmCfg.readEntry("Dir", "/mnt/cf/"); // zaurus does not have /mnt/ramfs | 301 | // fileName=vmCfg.readEntry("Dir", "/mnt/cf/"); // zaurus does not have /mnt/ramfs |
300 | // else | 302 | // else |
301 | // fileName=vmCfg.readEntry("Dir", "/mnt/ramfs/"); | 303 | // fileName=vmCfg.readEntry("Dir", "/mnt/ramfs/"); |
302 | 304 | ||
303 | fName = "vm_"+ dt.toString()+ ".wav"; | 305 | fName = "vm_"+ dt.toString()+ ".wav"; |
306 | |||
304 | fileName+=fName; | 307 | fileName+=fName; |
305 | qDebug("filename is "+fileName); | 308 | qDebug("filename is "+fileName); |
306 | // No spaces in the filename | 309 | // No spaces in the filename |
307 | fileName.replace(QRegExp("'"),""); | 310 | fileName.replace(QRegExp("'"),""); |
308 | fileName.replace(QRegExp(" "),"_"); | 311 | fileName.replace(QRegExp(" "),"_"); |
309 | fileName.replace(QRegExp(":"),"."); | 312 | fileName.replace(QRegExp(":"),"."); |
310 | fileName.replace(QRegExp(","),""); | 313 | fileName.replace(QRegExp(","),""); |
311 | 314 | ||
312 | if(openWAV(fileName.latin1()) == -1) { | 315 | if(openWAV(fileName.latin1()) == -1) { |
313 | QString err("Could not open the output file\n"); | 316 | QString err("Could not open the output file\n"); |
314 | err += fileName; | 317 | err += fileName; |
315 | QMessageBox::critical(0, "VMemo", err, "Abort"); | 318 | QMessageBox::critical(0, "VMemo", err, "Abort"); |
@@ -354,25 +357,24 @@ int VMemo::openDSP() | |||
354 | 357 | ||
355 | qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); | 358 | qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); |
356 | 359 | ||
357 | if(systemZaurus) { | 360 | if(systemZaurus) { |
358 | dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 | 361 | dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 |
359 | channels=1; //zaurus has one input channel | 362 | channels=1; //zaurus has one input channel |
360 | } else { | 363 | } else { |
361 | dsp = open("/dev/dsp", O_RDWR); | 364 | dsp = open("/dev/dsp", O_RDWR); |
362 | } | 365 | } |
363 | 366 | ||
364 | if(dsp == -1) { | 367 | if(dsp == -1) { |
365 | perror("open(\"/dev/dsp\")"); | 368 | perror("open(\"/dev/dsp\")"); |
366 | |||
367 | errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); | 369 | errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); |
368 | return -1; | 370 | return -1; |
369 | } | 371 | } |
370 | 372 | ||
371 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { | 373 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { |
372 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 374 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
373 | errorMsg="ioctl(\"SNDCTL_DSP_SETFMT\")\n%d\n"+(QString)strerror(errno),format; | 375 | errorMsg="ioctl(\"SNDCTL_DSP_SETFMT\")\n%d\n"+(QString)strerror(errno),format; |
374 | return -1; | 376 | return -1; |
375 | } | 377 | } |
376 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { | 378 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { |
377 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | 379 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); |
378 | errorMsg="ioctl(\"SNDCTL_DSP_CHANNELS\")\n%d\n"+(QString)strerror(errno),channels; | 380 | errorMsg="ioctl(\"SNDCTL_DSP_CHANNELS\")\n%d\n"+(QString)strerror(errno),channels; |
@@ -505,16 +507,18 @@ void VMemo::record(void) | |||
505 | } | 507 | } |
506 | 508 | ||
507 | value = length+36; | 509 | value = length+36; |
508 | lseek(wav, 4, SEEK_SET); | 510 | lseek(wav, 4, SEEK_SET); |
509 | write(wav, &value, 4); | 511 | write(wav, &value, 4); |
510 | lseek(wav, 40, SEEK_SET); | 512 | lseek(wav, 40, SEEK_SET); |
511 | write(wav, &length, 4); | 513 | write(wav, &length, 4); |
512 | track.close(); | 514 | track.close(); |
513 | 515 | ||
514 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) | 516 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) |
515 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); | 517 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); |
516 | ::close(dsp); | 518 | ::close(dsp); |
519 | fileName = fileName.left(fileName.length()-4); | ||
517 | if(useAlerts) | 520 | if(useAlerts) |
518 | QMessageBox::message("Vmemo"," Done recording\n"+ fileName); | 521 | QMessageBox::message("Vmemo"," Done recording\n"+ fileName); |
522 | qDebug("done recording "+fileName); | ||
519 | QSound::play(Resource::findSound("vmemoe")); | 523 | QSound::play(Resource::findSound("vmemoe")); |
520 | } | 524 | } |