summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opierec/qtrec.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp
index 2187d5a..6eb6524 100644
--- a/noncore/multimedia/opierec/qtrec.cpp
+++ b/noncore/multimedia/opierec/qtrec.cpp
@@ -154,132 +154,135 @@ void quickRec()
154 memset( sbuf, 0, BUFSIZE); 154 memset( sbuf, 0, BUFSIZE);
155 memset( sbuf2, 0, BUFSIZE); 155 memset( sbuf2, 0, BUFSIZE);
156 156
157 for(;;) { 157 for(;;) {
158 if ( stopped) { 158 if ( stopped) {
159 // odebug << "quickRec:: stopped" << oendl; 159 // odebug << "quickRec:: stopped" << oendl;
160 break; 160 break;
161 } 161 }
162 162
163// number=::read( filePara.sd, sbuf, BUFSIZE); 163// number=::read( filePara.sd, sbuf, BUFSIZE);
164 number = soundDevice ->devRead( filePara.sd, sbuf, BUFSIZE); 164 number = soundDevice ->devRead( filePara.sd, sbuf, BUFSIZE);
165 165
166 if(number <= 0) { 166 if(number <= 0) {
167 perror("recording error "); 167 perror("recording error ");
168 odebug << "" << filePara.fileName << " " << number << "" << oendl; 168 odebug << "" << filePara.fileName << " " << number << "" << oendl;
169 stopped = true; 169 stopped = true;
170 return; 170 return;
171 } 171 }
172 //if(stereo == 2) { 172 //if(stereo == 2) {
173// adpcm_coder( sbuf2, abuf, number/2, &encoder_state); 173// adpcm_coder( sbuf2, abuf, number/2, &encoder_state);
174 adpcm_coder( sbuf, abuf, number/2, &encoder_state); 174 adpcm_coder( sbuf, abuf, number/2, &encoder_state);
175 175
176 bytesWritten = ::write( filePara.fd , (short *)abuf, number/4); 176 bytesWritten = ::write( filePara.fd , (short *)abuf, number/4);
177 177
178 waveform->newSamples( (const short *)abuf, bytesWritten ); 178 waveform->newSamples( sbuf, number );
179 179
180 total += bytesWritten; 180 total += bytesWritten;
181 filePara.numberSamples = total; 181 filePara.numberSamples = total;
182 timeSlider->setValue( total); 182 timeSlider->setValue( total);
183 183
184 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2 / filePara.channels; 184 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2
185 / filePara.channels;
185 186
186 qApp->processEvents(); 187 qApp->processEvents();
187 if( total >= filePara.samplesToRecord) { 188 if( total >= filePara.samplesToRecord) {
188 stopped = true; 189 stopped = true;
189 break; 190 break;
190 } 191 }
191 } 192 }
192 } else { 193 } else {
193 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> 194 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>>
194 odebug << "start recording WAVE_FORMAT_PCM" << oendl; 195 odebug << "start recording WAVE_FORMAT_PCM" << oendl;
195 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ]; 196 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ];
196 memset( inbuffer, 0, BUFSIZE); 197 memset( inbuffer, 0, BUFSIZE);
197 memset( outbuffer, 0, BUFSIZE); 198 memset( outbuffer, 0, BUFSIZE);
198 199
199 for(;;) { 200 for(;;) {
200 if ( stopped) { 201 if ( stopped) {
201 odebug << "quickRec:: stopped" << oendl; 202 odebug << "quickRec:: stopped" << oendl;
202 stopped = true; 203 stopped = true;
203 break; // stop if playing was set to false 204 break; // stop if playing was set to false
204 return; 205 return;
205 } 206 }
206 207
207 number = soundDevice->devRead( filePara.sd, (short *)inbuffer, BUFSIZE); 208 number = soundDevice->devRead( filePara.sd, (short *)inbuffer, BUFSIZE);
208 waveform->newSamples( inbuffer, number );
209 209
210 if( number <= 0) { 210 if( number <= 0) {
211 perror( "recording error "); 211 perror( "recording error ");
212 odebug << filePara.fileName << oendl; 212 odebug << filePara.fileName << oendl;
213 stopped = true; 213 stopped = true;
214 return; 214 return;
215 } 215 }
216 216
217 bytesWritten = ::write( filePara.fd , inbuffer, number); 217 bytesWritten = ::write( filePara.fd , inbuffer, number);
218 waveform->newSamples( inbuffer, number );
218 219
219 if( bytesWritten < 0) { 220 if( bytesWritten < 0) {
220 perror("File writing error "); 221 perror("File writing error ");
221 stopped = true; 222 stopped = true;
222 return; 223 return;
223 } 224 }
224 225
225 total += bytesWritten; 226 total += bytesWritten;
226 227
227 filePara.numberSamples = total; 228 filePara.numberSamples = total;
228 229
229 if( filePara.SecondsToRecord != 0) 230 if( filePara.SecondsToRecord != 0)
230 timeSlider->setValue( total); 231 timeSlider->setValue( total);
231// printf("Writing number %d, bytes %d,total %d\r",number, bytesWritten , total); 232// printf("Writing number %d, bytes %d,total %d\r",number, bytesWritten , total);
232// fflush(stdout); 233// fflush(stdout);
233 234
234 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2/filePara.channels; 235 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate
236 / (float)2/filePara.channels;
235 qApp->processEvents(); 237 qApp->processEvents();
236 238
237 if( total >= filePara.samplesToRecord) { 239 if( total >= filePara.samplesToRecord) {
238 stopped = true; 240 stopped = true;
239 break; 241 break;
240 } 242 }
241 } 243 }
242 } //end main loop 244 } //end main loop
243 245
244 } else { 246 } else {
245// <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8; 247// <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8;
246 unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ]; 248 unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ];
247 memset( unsigned_inbuffer, 0, BUFSIZE); 249 memset( unsigned_inbuffer, 0, BUFSIZE);
248 memset( unsigned_outbuffer, 0, BUFSIZE); 250 memset( unsigned_outbuffer, 0, BUFSIZE);
249 251
250 for(;;) { 252 for(;;) {
251 if ( stopped) { 253 if ( stopped) {
252 odebug << "quickRec:: stopped" << oendl; 254 odebug << "quickRec:: stopped" << oendl;
253 break; // stop if playing was set to false 255 break; // stop if playing was set to false
254 } 256 }
255 257
256 number = ::read( filePara.sd, unsigned_inbuffer, BUFSIZE); 258 number = ::read( filePara.sd, unsigned_inbuffer, BUFSIZE);
257 bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number); 259 bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number);
260 waveform->newSamples( (const short *) unsigned_inbuffer, number );
258 261
259 if(bytesWritten < 0) { 262 if(bytesWritten < 0) {
260 stopped = true; 263 stopped = true;
261 QMessageBox::message("Note","There was a problem\nwriting to the file"); 264 QMessageBox::message("Note","<p>There was a problem writing to the file</p>");
262 perror("File writing error "); 265 perror("File writing error ");
263 return; 266 return;
264 } 267 }
265 268
266 total += bytesWritten; 269 total += bytesWritten;
267 filePara.numberSamples = total; 270 filePara.numberSamples = total;
268 // printf("\nWriting number %d, bytes %d,total %d \r",number, bytesWritten , total); 271 // printf("\nWriting number %d, bytes %d,total %d \r",number, bytesWritten , total);
269 // fflush(stdout); 272 // fflush(stdout);
270 if( filePara.SecondsToRecord !=0) 273 if( filePara.SecondsToRecord !=0)
271 timeSlider->setValue( total); 274 timeSlider->setValue( total);
272 275
273 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; 276 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate;
274 277
275 qApp->processEvents(); 278 qApp->processEvents();
276 if( total >= filePara.samplesToRecord) { 279 if( total >= filePara.samplesToRecord) {
277 stopped = true; 280 stopped = true;
278 break; 281 break;
279 } 282 }
280 } //end main loop 283 } //end main loop
281 } 284 }
282} /// END quickRec() 285} /// END quickRec()
283 286
284 287
285#ifdef THREADED 288#ifdef THREADED
@@ -292,115 +295,115 @@ void playIt()
292 int number = 0; 295 int number = 0;
293 int total = 0; // Total number of bytes read in so far. 296 int total = 0; // Total number of bytes read in so far.
294 if( filePara.resolution == 16 ) { //AFMT_S16_LE) { 297 if( filePara.resolution == 16 ) { //AFMT_S16_LE) {
295 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { 298 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) {
296 char abuf[ BUFSIZE / 2 ]; 299 char abuf[ BUFSIZE / 2 ];
297 short sbuf[ BUFSIZE ]; 300 short sbuf[ BUFSIZE ];
298 short sbuf2[ BUFSIZE * 2 ]; 301 short sbuf2[ BUFSIZE * 2 ];
299 memset( abuf, 0, BUFSIZE / 2); 302 memset( abuf, 0, BUFSIZE / 2);
300 memset( sbuf, 0, BUFSIZE); 303 memset( sbuf, 0, BUFSIZE);
301 memset( sbuf2, 0, BUFSIZE * 2); 304 memset( sbuf2, 0, BUFSIZE * 2);
302// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> 305// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
303 for(;;) { // play loop 306 for(;;) { // play loop
304 if ( stopped) { 307 if ( stopped) {
305 break; 308 break;
306 return; 309 return;
307 }// stop if playing was set to false 310 }// stop if playing was set to false
308 311
309 number = ::read( filePara.fd, abuf, BUFSIZE / 2); 312 number = ::read( filePara.fd, abuf, BUFSIZE / 2);
310 adpcm_decoder( abuf, sbuf, number * 2, &decoder_state); 313 adpcm_decoder( abuf, sbuf, number * 2, &decoder_state);
311 314
312// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel 315// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel
313// sbuf2[i+1]=sbuf2[i]=sbuf[i]; 316// sbuf2[i+1]=sbuf2[i]=sbuf[i];
314// } 317// }
315 bytesWritten = write ( filePara.sd, sbuf, number * 4); 318 bytesWritten = write ( filePara.sd, sbuf, number * 4);
316 waveform->newSamples( (const short *)sbuf, number ); 319 waveform->newSamples( (const short *)sbuf, number *4);
317 // if(filePara.channels==1) 320 // if(filePara.channels==1)
318 // total += bytesWritten/2; //mono 321 // total += bytesWritten/2; //mono
319 // else 322 // else
320 total += bytesWritten; 323 total += bytesWritten;
321 filePara.numberSamples = total/4; 324 filePara.numberSamples = total/4;
322 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2; 325 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2;
323 326
324 timeSlider->setValue( total/4); 327 timeSlider->setValue( total/4);
325// timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); 328// timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds);
326// if(filePara.numberOfRecordedSeconds>1) 329// if(filePara.numberOfRecordedSeconds>1)
327// timeLabel->setText( timeString+ tr(" seconds")); 330// timeLabel->setText( timeString+ tr(" seconds"));
328 // printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4); 331 // printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4);
329 // fflush(stdout); 332 // fflush(stdout);
330 333
331 qApp->processEvents(); 334 qApp->processEvents();
332 335
333 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { 336 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
334// if( total >= filePara.numberSamples ){//|| secCount > filePara.numberOfRecordedSeconds ) { 337// if( total >= filePara.numberSamples ){//|| secCount > filePara.numberOfRecordedSeconds ) {
335 stopped = true; 338 stopped = true;
336 break; 339 break;
337 } 340 }
338 } 341 }
339 } else { 342 } else {
340 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> 343 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>>
341 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ]; 344 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ];
342 memset( inbuffer, 0, BUFSIZE); 345 memset( inbuffer, 0, BUFSIZE);
343 memset( outbuffer, 0, BUFSIZE); 346 memset( outbuffer, 0, BUFSIZE);
344 347
345 for(;;) { // play loop 348 for(;;) { // play loop
346 if ( stopped) { 349 if ( stopped) {
347 break; 350 break;
348 return; 351 return;
349 } 352 }
350// stop if playing was set to false 353// stop if playing was set to false
351 number = ::read( filePara.fd, inbuffer, BUFSIZE); 354 number = ::read( filePara.fd, inbuffer, BUFSIZE);
352// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel 355// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel
353// // for (int i=0;i< number ; i++) { //2*i is left channel 356// // for (int i=0;i< number ; i++) { //2*i is left channel
354// outbuffer[i+1]= outbuffer[i]=inbuffer[i]; 357// outbuffer[i+1]= outbuffer[i]=inbuffer[i];
355// } 358// }
356 bytesWritten = ::write( filePara.sd, inbuffer, number); 359 bytesWritten = ::write( filePara.sd, inbuffer, number);
357 waveform->newSamples( inbuffer, bytesWritten ); 360 waveform->newSamples( inbuffer, number);
358 //-------------->>>> out to device 361 //-------------->>>> out to device
359 // total+=bytesWritten; 362 // total+=bytesWritten;
360 // if(filePara.channels==1) 363 // if(filePara.channels==1)
361 // total += bytesWritten/2; //mono 364 // total += bytesWritten/2; //mono
362 // else 365 // else
363 total += bytesWritten; 366 total += bytesWritten;
364 timeSlider->setValue( total); 367 timeSlider->setValue( total);
365 368
366 filePara.numberSamples = total; 369 filePara.numberSamples = total;
367 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2; 370 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2;
368 371
369// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); 372// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
370// timeLabel->setText( timeString + tr(" seconds")); 373// timeLabel->setText( timeString + tr(" seconds"));
371 374
372 qApp->processEvents(); 375 qApp->processEvents();
373 376
374 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { 377 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
375 owarn << "Jane! Stop this crazy thing!" << oendl; 378 owarn << "Jane! Stop this crazy thing!" << oendl;
376 stopped = true; 379 stopped = true;
377// playing = false; 380// playing = false;
378 break; 381 break;
379 } 382 }
380 } 383 }
381 printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total); 384// printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total);
382 fflush(stdout); 385// fflush(stdout);
383 } //end loop 386 } //end loop
384 } else { 387 } else {
385/////////////////////////////// format = AFMT_U8; 388/////////////////////////////// format = AFMT_U8;
386 unsigned char unsigned_inbuffer[ BUFSIZE ]; //, unsigned_outbuffer[BUFSIZE]; 389 unsigned char unsigned_inbuffer[ BUFSIZE ]; //, unsigned_outbuffer[BUFSIZE];
387 memset( unsigned_inbuffer, 0, BUFSIZE); 390 memset( unsigned_inbuffer, 0, BUFSIZE);
388 for(;;) { 391 for(;;) {
389// main loop 392// main loop
390 if (stopped) { 393 if (stopped) {
391 break; // stop if playing was set to false 394 break; // stop if playing was set to false
392 return; 395 return;
393 } 396 }
394 number = ::read( filePara.fd, unsigned_inbuffer, BUFSIZE); 397 number = ::read( filePara.fd, unsigned_inbuffer, BUFSIZE);
395//data = (val >> 8) ^ 0x80; 398//data = (val >> 8) ^ 0x80;
396 // unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80; 399 // unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80;
397 bytesWritten = write ( filePara.sd, unsigned_inbuffer, number); 400 bytesWritten = write ( filePara.sd, unsigned_inbuffer, number);
398 waveform->newSamples( (const short *)unsigned_inbuffer, bytesWritten ); 401 waveform->newSamples( (const short *)unsigned_inbuffer, bytesWritten );
399 total += bytesWritten; 402 total += bytesWritten;
400 403
401 timeSlider->setValue( total); 404 timeSlider->setValue( total);
402 filePara.numberSamples = total; 405 filePara.numberSamples = total;
403 406
404 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; 407 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate;
405// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); 408// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
406// timeLabel->setText( timeString + tr(" seconds")); 409// timeLabel->setText( timeString + tr(" seconds"));
@@ -429,75 +432,76 @@ QtRec::QtRec( QWidget* parent, const char* name, WFlags fl )
429 renameBox = 0; 432 renameBox = 0;
430 433
431// open sound device to get volumes 434// open sound device to get volumes
432 Config hwcfg("OpieRec"); 435 Config hwcfg("OpieRec");
433 hwcfg.setGroup("Hardware"); 436 hwcfg.setGroup("Hardware");
434 437
435 438
436 soundDevice = new Device( this, 439 soundDevice = new Device( this,
437 hwcfg.readEntry( "Audio",DSPSTROUT), 440 hwcfg.readEntry( "Audio",DSPSTROUT),
438 hwcfg.readEntry( "Mixer",DSPSTRMIXEROUT), false); 441 hwcfg.readEntry( "Mixer",DSPSTRMIXEROUT), false);
439 // soundDevice = new Device( this, hwcfg.readEntry( "Audio","hw:0"), hwcfg.readEntry( "Mixer","hw:0"), false); 442 // soundDevice = new Device( this, hwcfg.readEntry( "Audio","hw:0"), hwcfg.readEntry( "Mixer","hw:0"), false);
440 443
441// soundDevice->setDeviceFormat(AFMT_S16_LE); 444// soundDevice->setDeviceFormat(AFMT_S16_LE);
442// soundDevice->setDeviceChannels(1); 445// soundDevice->setDeviceChannels(1);
443// soundDevice->setDeviceRate( 22050); 446// soundDevice->setDeviceRate( 22050);
444 447
445 getInVol(); 448 getInVol();
446 getOutVol(); 449 getOutVol();
447 450
448 soundDevice->closeDevice( true); 451 soundDevice->closeDevice( true);
449 soundDevice->sd = -1; 452 soundDevice->sd = -1;
450 soundDevice = 0; 453 soundDevice = 0;
451 wavFile = 0; 454 wavFile = 0;
452 455
453 if( soundDevice) delete soundDevice; 456 // if( soundDevice) delete soundDevice;
454 457
455 initIconView(); 458 initIconView();
456 459
457 if( autoMute) 460 if( autoMute)
458 doMute( true); 461 doMute( true);
459 ListView1->setFocus(); 462 ListView1->setFocus();
460 playing = false; 463 playing = false;
461} 464}
462 465
463QtRec::~QtRec() { 466QtRec::~QtRec() {
467// if( soundDevice) delete soundDevice;
464 468
465} 469}
466 470
467void QtRec::cleanUp() { 471void QtRec::cleanUp() {
468 472
469 if( !stopped) { 473 if( !stopped) {
470 stopped = true; 474 stopped = true;
471 endRecording(); 475 endRecording();
472 } 476 }
473 477
474 ListView1->clear(); 478 ListView1->clear();
475 479
476 if( autoMute) 480 if( autoMute)
477 doMute(false); 481 doMute(false);
478 482
479 if( wavFile) delete wavFile; 483 // if( wavFile) delete wavFile;
480// if(soundDevice) delete soundDevice; 484// if(soundDevice) delete soundDevice;
481} 485}
482 486
483void QtRec::init() { 487void QtRec::init() {
484 488
485 needsStereoOut = false; 489 needsStereoOut = false;
486 QPixmap image3( ( const char** ) image3_data ); 490 QPixmap image3( ( const char** ) image3_data );
487 QPixmap image4( ( const char** ) image4_data ); 491 QPixmap image4( ( const char** ) image4_data );
488 QPixmap image6( ( const char** ) image6_data ); 492 QPixmap image6( ( const char** ) image6_data );
489 493
490 stopped = true; 494 stopped = true;
491 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); 495 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) );
492 QGridLayout *layout = new QGridLayout( this ); 496 QGridLayout *layout = new QGridLayout( this );
493 layout->setSpacing( 2); 497 layout->setSpacing( 2);
494 layout->setMargin( 2); 498 layout->setMargin( 2);
495 499
496 TabWidget = new QTabWidget( this, "TabWidget" ); 500 TabWidget = new QTabWidget( this, "TabWidget" );
497 layout->addMultiCellWidget(TabWidget, 0, 7, 0, 7); 501 layout->addMultiCellWidget(TabWidget, 0, 7, 0, 7);
498// TabWidget->setTabShape(QTabWidget::Triangular); 502// TabWidget->setTabShape(QTabWidget::Triangular);
499 503
500 ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** 504 ///**********<<<<<<<<<<<<>>>>>>>>>>>>***************
501 tab = new QWidget( TabWidget, "tab" ); 505 tab = new QWidget( TabWidget, "tab" );
502 506
503 QGridLayout *layout1 = new QGridLayout( tab); 507 QGridLayout *layout1 = new QGridLayout( tab);
@@ -1480,89 +1484,89 @@ void QtRec::endRecording() {
1480 1484
1481 odebug << "Just moved " + wavFile->currentFileName << oendl; 1485 odebug << "Just moved " + wavFile->currentFileName << oendl;
1482 Config cfg("OpieRec"); 1486 Config cfg("OpieRec");
1483 cfg.setGroup("Sounds"); 1487 cfg.setGroup("Sounds");
1484 1488
1485 int nFiles = cfg.readNumEntry( "NumberofFiles",0); 1489 int nFiles = cfg.readNumEntry( "NumberofFiles",0);
1486 1490
1487 currentFile = QFileInfo( wavFile->currentFileName).fileName(); 1491 currentFile = QFileInfo( wavFile->currentFileName).fileName();
1488 currentFile = currentFile.left( currentFile.length() - 4); 1492 currentFile = currentFile.left( currentFile.length() - 4);
1489 1493
1490 cfg.writeEntry( "NumberofFiles", nFiles + 1); 1494 cfg.writeEntry( "NumberofFiles", nFiles + 1);
1491 cfg.writeEntry( QString::number( nFiles + 1), currentFile); 1495 cfg.writeEntry( QString::number( nFiles + 1), currentFile);
1492 cfg.writeEntry( currentFile, wavFile->currentFileName); 1496 cfg.writeEntry( currentFile, wavFile->currentFileName);
1493 1497
1494 QString time; 1498 QString time;
1495 time.sprintf("%.2f", filePara.numberOfRecordedSeconds); 1499 time.sprintf("%.2f", filePara.numberOfRecordedSeconds);
1496 cfg.writeEntry( wavFile->currentFileName, time ); 1500 cfg.writeEntry( wavFile->currentFileName, time );
1497// odebug << "writing config numberOfRecordedSeconds "+time << oendl; 1501// odebug << "writing config numberOfRecordedSeconds "+time << oendl;
1498 1502
1499 cfg.write(); 1503 cfg.write();
1500 odebug << "finished recording" << oendl; 1504 odebug << "finished recording" << oendl;
1501 timeLabel->setText(""); 1505 timeLabel->setText("");
1502 } 1506 }
1503 1507
1504 if(soundDevice) delete soundDevice; 1508 // if(soundDevice) delete soundDevice;
1505 1509
1506 timeSlider->setValue(0); 1510 timeSlider->setValue(0);
1507 initIconView(); 1511 initIconView();
1508 selectItemByName( currentFile); 1512 selectItemByName( currentFile);
1509} 1513}
1510 1514
1511void QtRec::endPlaying() { 1515void QtRec::endPlaying() {
1512 monitoring = false; 1516 monitoring = false;
1513 recording = false; 1517 recording = false;
1514 playing = false; 1518 playing = false;
1515 stopped = true; 1519 stopped = true;
1516 waveform->reset(); 1520 waveform->reset();
1517// errorStop(); 1521// errorStop();
1518// odebug << "end playing" << oendl; 1522// odebug << "end playing" << oendl;
1519 setRecordButton( false); 1523 setRecordButton( false);
1520 1524
1521 toBeginningButton->setEnabled( true); 1525 toBeginningButton->setEnabled( true);
1522 toEndButton->setEnabled( true); 1526 toEndButton->setEnabled( true);
1523 1527
1524 if(autoMute) 1528 if(autoMute)
1525 doMute( true); 1529 doMute( true);
1526 1530
1527 soundDevice->closeDevice( false); 1531 soundDevice->closeDevice( false);
1528 soundDevice->sd = -1; 1532 soundDevice->sd = -1;
1529 // if(soundDevice) delete soundDevice; 1533 // if(soundDevice) delete soundDevice;
1530// odebug << "file and sound device closed" << oendl; 1534// odebug << "file and sound device closed" << oendl;
1531 timeLabel->setText(""); 1535 timeLabel->setText("");
1532 total = 0; 1536 total = 0;
1533 filePara.numberSamples = 0; 1537 filePara.numberSamples = 0;
1534 filePara.sd = -1; 1538 filePara.sd = -1;
1535// wavFile->closeFile(); 1539// wavFile->closeFile();
1536 filePara.fd = 0; 1540 filePara.fd = 0;
1537// if(wavFile) delete wavFile; //this crashes 1541// if(wavFile) delete wavFile; //this crashes
1538 1542
1539// odebug << "track closed" << oendl; 1543// odebug << "track closed" << oendl;
1540 killTimers(); 1544 killTimers();
1541 owarn << "reset slider" << oendl; 1545 owarn << "reset slider" << oendl;
1542 timeSlider->setValue(0); 1546 timeSlider->setValue(0);
1543 1547
1544 if(soundDevice) delete soundDevice; 1548 // if(soundDevice) delete soundDevice;
1545 1549
1546} 1550}
1547 1551
1548bool QtRec::openPlayFile() { 1552bool QtRec::openPlayFile() {
1549 1553
1550 qApp->processEvents(); 1554 qApp->processEvents();
1551 if( currentFile.isEmpty()) { 1555 if( currentFile.isEmpty()) {
1552 QMessageBox::message(tr("Opierec"),tr("Please select file to play")); 1556 QMessageBox::message(tr("Opierec"),tr("Please select file to play"));
1553 endPlaying(); 1557 endPlaying();
1554 return false; 1558 return false;
1555 } 1559 }
1556 QString currentFileName; 1560 QString currentFileName;
1557 Config cfg("OpieRec"); 1561 Config cfg("OpieRec");
1558 cfg.setGroup("Sounds"); 1562 cfg.setGroup("Sounds");
1559 int nFiles = cfg.readNumEntry( "NumberofFiles", 0); 1563 int nFiles = cfg.readNumEntry( "NumberofFiles", 0);
1560 for(int i=0;i<nFiles+1;i++) { //look for file 1564 for(int i=0;i<nFiles+1;i++) { //look for file
1561 if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) { 1565 if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) {
1562 currentFileName = cfg.readEntry( currentFile, "" ); 1566 currentFileName = cfg.readEntry( currentFile, "" );
1563 odebug << "opening for play: " + currentFileName << oendl; 1567 odebug << "opening for play: " + currentFileName << oendl;
1564 } 1568 }
1565 } 1569 }
1566 wavFile = new WavFile(this, 1570 wavFile = new WavFile(this,
1567 currentFileName, 1571 currentFileName,
1568 false); 1572 false);
@@ -1769,49 +1773,49 @@ void QtRec::doVolMuting(bool b) {
1769 cfg.writeEntry( "Mute",b); 1773 cfg.writeEntry( "Mute",b);
1770 cfg.write(); 1774 cfg.write();
1771 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b; 1775 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b;
1772} 1776}
1773 1777
1774void QtRec::doMicMuting(bool b) { 1778void QtRec::doMicMuting(bool b) {
1775 // odebug << "mic mute" << oendl; 1779 // odebug << "mic mute" << oendl;
1776 Config cfg( "qpe" ); 1780 Config cfg( "qpe" );
1777 cfg. setGroup( "Volume" ); 1781 cfg. setGroup( "Volume" );
1778 cfg.writeEntry( "MicMute",b); 1782 cfg.writeEntry( "MicMute",b);
1779 cfg.write(); 1783 cfg.write();
1780 QCopEnvelope( "QPE/System", "micChange(bool)" ) << b; 1784 QCopEnvelope( "QPE/System", "micChange(bool)" ) << b;
1781} 1785}
1782 1786
1783void QtRec::compressionSelected(bool b) { 1787void QtRec::compressionSelected(bool b) {
1784 Config cfg("OpieRec"); 1788 Config cfg("OpieRec");
1785 cfg.setGroup("Settings"); 1789 cfg.setGroup("Settings");
1786 cfg.writeEntry("wavCompression", b); 1790 cfg.writeEntry("wavCompression", b);
1787 cfg.writeEntry("bitrate", 16); 1791 cfg.writeEntry("bitrate", 16);
1788 filePara.resolution = 16; 1792 filePara.resolution = 16;
1789 cfg.write(); 1793 cfg.write();
1790 1794
1791 if(b) { 1795 if(b) {
1792 bitRateComboBox->setEnabled( false); 1796 bitRateComboBox->setEnabled( false);
1793 bitRateComboBox->setCurrentItem( 0); 1797 bitRateComboBox->setCurrentItem( 1);
1794 filePara.resolution = 16; 1798 filePara.resolution = 16;
1795 } else{ 1799 } else{
1796 bitRateComboBox->setEnabled( true); 1800 bitRateComboBox->setEnabled( true);
1797 } 1801 }
1798} 1802}
1799 1803
1800long QtRec::checkDiskSpace(const QString &path) { 1804long QtRec::checkDiskSpace(const QString &path) {
1801 1805
1802 struct statfs fs; 1806 struct statfs fs;
1803 1807
1804 if ( !statfs( path.latin1(), &fs ) ) { 1808 if ( !statfs( path.latin1(), &fs ) ) {
1805 1809
1806 int blkSize = fs.f_bsize; 1810 int blkSize = fs.f_bsize;
1807 int availBlks = fs.f_bavail; 1811 int availBlks = fs.f_bavail;
1808 1812
1809 long mult = blkSize / 1024; 1813 long mult = blkSize / 1024;
1810 long div = 1024 / blkSize; 1814 long div = 1024 / blkSize;
1811 1815
1812 if ( !mult ) mult = 1; 1816 if ( !mult ) mult = 1;
1813 if ( !div ) div = 1; 1817 if ( !div ) div = 1;
1814 1818
1815 return availBlks * mult / div; 1819 return availBlks * mult / div;
1816 } 1820 }
1817 return -1; 1821 return -1;