summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index 4c07b3a..226f058 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -288,51 +288,48 @@ void VMemo::mousePressEvent( QMouseEvent * me) {
288 else 288 else
289 stopRecording(); 289 stopRecording();
290} 290}
291 291
292void VMemo::mouseReleaseEvent( QMouseEvent * ) { 292void VMemo::mouseReleaseEvent( QMouseEvent * ) {
293} 293}
294 294
295bool VMemo::startRecording() { 295bool VMemo::startRecording() {
296 Config config( "Vmemo" ); 296 Config config( "Vmemo" );
297 config.setGroup( "System" ); 297 config.setGroup( "System" );
298 298
299 useAlerts = config.readBoolEntry("Alert",1); 299 useAlerts = config.readBoolEntry("Alert",1);
300 if(useAlerts) { 300 if(useAlerts) {
301 301
302 msgLabel = new QLabel( 0, "alertLabel" ); 302 msgLabel = new QLabel( 0, "alertLabel" );
303 msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); 303 msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>");
304 msgLabel->show(); 304 msgLabel->show();
305 } 305 }
306 306
307 qDebug("Start recording engines"); 307 qDebug("Start recording engines");
308 recording = TRUE; 308 recording = TRUE;
309 309
310 if (openDSP() == -1) { 310 if (openDSP() == -1) {
311 recording = FALSE; 311 recording = FALSE;
312 msgLabel=0;
313 delete msgLabel;
314
315 return FALSE; 312 return FALSE;
316 } 313 }
317 314
318 config.setGroup("Defaults"); 315 config.setGroup("Defaults");
319 316
320 QDateTime dt = QDateTime::currentDateTime(); 317 QDateTime dt = QDateTime::currentDateTime();
321 318
322 QString fName; 319 QString fName;
323 config.setGroup( "System" ); 320 config.setGroup( "System" );
324 fName = QPEApplication::documentDir() ; 321 fName = QPEApplication::documentDir() ;
325 fileName = config.readEntry("RecLocation", fName); 322 fileName = config.readEntry("RecLocation", fName);
326 323
327 int s; 324 int s;
328 s=fileName.find(':'); 325 s=fileName.find(':');
329 if(s) 326 if(s)
330 fileName=fileName.right(fileName.length()-s-2); 327 fileName=fileName.right(fileName.length()-s-2);
331 qDebug("pathname will be "+fileName); 328 qDebug("pathname will be "+fileName);
332 329
333 if( fileName.left(1).find('/') == -1) 330 if( fileName.left(1).find('/') == -1)
334 fileName="/"+fileName; 331 fileName="/"+fileName;
335 if( fileName.right(1).find('/') == -1) 332 if( fileName.right(1).find('/') == -1)
336 fileName+="/"; 333 fileName+="/";
337 fName = "vm_"+ dt.toString()+ ".wav"; 334 fName = "vm_"+ dt.toString()+ ".wav";
338 335
@@ -406,50 +403,54 @@ void VMemo::stopRecording() {
406int VMemo::openDSP() { 403int VMemo::openDSP() {
407 Config cfg("Vmemo"); 404 Config cfg("Vmemo");
408 cfg.setGroup("Record"); 405 cfg.setGroup("Record");
409 406
410 speed = cfg.readNumEntry("SampleRate", 22050); 407 speed = cfg.readNumEntry("SampleRate", 22050);
411 channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) 408 channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1)
412 if (cfg.readNumEntry("SixteenBit", 1)==1) { 409 if (cfg.readNumEntry("SixteenBit", 1)==1) {
413 format = AFMT_S16_LE; 410 format = AFMT_S16_LE;
414 resolution = 16; 411 resolution = 16;
415 } else { 412 } else {
416 format = AFMT_U8; 413 format = AFMT_U8;
417 resolution = 8; 414 resolution = 8;
418 } 415 }
419 416
420 qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); 417 qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution);
421 418
422 if(systemZaurus) { 419 if(systemZaurus) {
423 dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 420 dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1
424 channels=1; //zaurus has one input channel 421 channels=1; //zaurus has one input channel
425 } else { 422 } else {
426 dsp = open("/dev/dsp", O_RDONLY); 423 dsp = open("/dev/dsp", O_RDONLY);
427 } 424 }
428 425
429 if(dsp == -1) { 426 if(dsp == -1) {
430 perror("open(\"/dev/dsp\")"); 427 msgLabel->close();
431 errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); 428 msgLabel=0;
429 delete msgLabel;
430
431 perror("open(\"/dev/dsp\")");
432 errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno);
432 QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); 433 QMessageBox::critical(0, "vmemo", errorMsg, "Abort");
433 return -1; 434 return -1;
434 } 435 }
435 436
436 if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { 437 if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) {
437 perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); 438 perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
438 return -1; 439 return -1;
439 } 440 }
440 if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { 441 if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) {
441 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); 442 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")");
442 return -1; 443 return -1;
443 } 444 }
444 if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { 445 if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) {
445 perror("ioctl(\"SNDCTL_DSP_SPEED\")"); 446 perror("ioctl(\"SNDCTL_DSP_SPEED\")");
446 return -1; 447 return -1;
447 } 448 }
448 if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { 449 if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) {
449 perror("ioctl(\"SOUND_PCM_READ_RATE\")"); 450 perror("ioctl(\"SOUND_PCM_READ_RATE\")");
450 return -1; 451 return -1;
451 } 452 }
452 453
453 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute 454 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute
454 455
455 return 1; 456 return 1;