summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opierec/qtrec.cpp
Unidiff
Diffstat (limited to 'noncore/multimedia/opierec/qtrec.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opierec/qtrec.cpp129
1 files changed, 64 insertions, 65 deletions
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp
index 1c64ab1..2187d5a 100644
--- a/noncore/multimedia/opierec/qtrec.cpp
+++ b/noncore/multimedia/opierec/qtrec.cpp
@@ -1,80 +1,79 @@
1/**************************************************************************** 1/****************************************************************************
2 // qtrec.cpp 2 // qtrec.cpp
3 Created: Thu Jan 17 11:19:58 2002 3 Created: Thu Jan 17 11:19:58 2002
4 copyright 2002 by L.J. Potter <ljp@llornkcor.com> 4 copyright 2002 by L.J. Potter <ljp@llornkcor.com>
5****************************************************************************/ 5****************************************************************************/
6#define DEV_VERSION 6#define DEV_VERSION
7 7
8#include "pixmaps.h" 8#include "pixmaps.h"
9#include "qtrec.h" 9#include "qtrec.h"
10#include "waveform.h" 10#include "waveform.h"
11
12#include <pthread.h>
13
14extern "C" { 11extern "C" {
15#include "adpcm.h" 12#include "adpcm.h"
16} 13}
17 14
18#include <sys/soundcard.h> 15/* OPIE */
19 16#include <opie2/odebug.h>
20#include <qpe/config.h> 17#include <qpe/config.h>
21#include <qpe/qcopenvelope_qws.h> 18#include <qpe/qcopenvelope_qws.h>
22#include <qpe/qpeapplication.h> 19#include <qpe/qpeapplication.h>
23#include <qpe/resource.h> 20#include <qpe/resource.h>
24#include <qpe/storage.h> 21#include <qpe/storage.h>
22using namespace Opie::Core;
25 23
24/* QT */
26#include <qcheckbox.h> 25#include <qcheckbox.h>
27#include <qcombobox.h> 26#include <qcombobox.h>
28//#include <qdatetime.h>
29#include <qdir.h> 27#include <qdir.h>
30#include <qgroupbox.h> 28#include <qgroupbox.h>
31#include <qlabel.h> 29#include <qlabel.h>
32#include <qlayout.h> 30#include <qlayout.h>
33#include <qlistview.h> 31#include <qlistview.h>
34#include <qmessagebox.h> 32#include <qmessagebox.h>
35#include <qpopupmenu.h> 33#include <qpopupmenu.h>
36#include <qpushbutton.h> 34#include <qpushbutton.h>
37#include <qslider.h> 35#include <qslider.h>
38#include <qtabwidget.h> 36#include <qtabwidget.h>
39#include <qtimer.h> 37#include <qtimer.h>
40 38
39/* STD */
41#include <errno.h> 40#include <errno.h>
42#include <fcntl.h> 41#include <fcntl.h>
43#include <math.h> 42#include <math.h>
44#include <mntent.h> 43#include <mntent.h>
45#include <stdio.h> 44#include <stdio.h>
46#include <stdlib.h> 45#include <stdlib.h>
47#include <sys/ioctl.h> 46#include <sys/ioctl.h>
48#include <sys/soundcard.h> 47#include <sys/soundcard.h>
49#include <sys/stat.h> 48#include <sys/stat.h>
50#include <sys/time.h> 49#include <sys/time.h>
51#include <sys/types.h> 50#include <sys/types.h>
52#include <sys/vfs.h> 51#include <sys/vfs.h>
53#include <unistd.h> 52#include <unistd.h>
54#include <sys/wait.h> 53#include <sys/wait.h>
55#include <sys/signal.h> 54#include <sys/signal.h>
56 55#include <pthread.h>
57 56
58#ifdef PDAUDIO //ALSA 57#ifdef PDAUDIO //ALSA
59#include <alsa/asoundlib.h> 58#include <alsa/asoundlib.h>
60static int deviceSampleRates[8] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, -1 }; 59static int deviceSampleRates[8] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, -1 };
61static int deviceBitRates[] = { 8, 16, 24, 32, -1 }; 60static int deviceBitRates[] = { 8, 16, 24, 32, -1 };
62#else //OSS 61#else //OSS
63static int deviceSampleRates[6] = { 11025, 16000, 22050, 32000, 44100, -1 }; 62static int deviceSampleRates[6] = { 11025, 16000, 22050, 32000, 44100, -1 };
64static int deviceBitRates[] = { 8, 16, -1 }; 63static int deviceBitRates[] = { 8, 16, -1 };
65#endif 64#endif
66 65
67#if defined(QT_QWS_SL5XXX) 66#if defined(QT_QWS_SL5XXX)
68///#if defined(QT_QWS_EBX) 67///#if defined(QT_QWS_EBX)
69 68
70#define DSPSTROUT "/dev/dsp" 69#define DSPSTROUT "/dev/dsp"
71#define DSPSTRIN "/dev/dsp1" 70#define DSPSTRIN "/dev/dsp1"
72#define DSPSTRMIXEROUT "/dev/mixer" 71#define DSPSTRMIXEROUT "/dev/mixer"
73#define DSPSTRMIXERIN "/dev/mixer1" 72#define DSPSTRMIXERIN "/dev/mixer1"
74 73
75#else 74#else
76 75
77#define DSPSTROUT "/dev/dsp" 76#define DSPSTROUT "/dev/dsp"
78#define DSPSTRIN "/dev/dsp" 77#define DSPSTRIN "/dev/dsp"
79#define DSPSTRMIXERIN "/dev/mixer" 78#define DSPSTRMIXERIN "/dev/mixer"
80#define DSPSTRMIXEROUT "/dev/mixer" 79#define DSPSTRMIXEROUT "/dev/mixer"
@@ -115,163 +114,163 @@ Waveform* waveform;
115Device *soundDevice; 114Device *soundDevice;
116 115
117 116
118#ifdef THREADED 117#ifdef THREADED
119void quickRec() 118void quickRec()
120#else 119#else
121 void QtRec::quickRec() 120 void QtRec::quickRec()
122#endif 121#endif
123{ 122{
124 123
125 qDebug("%d", 124 qDebug("%d",
126 filePara.numberSamples/filePara.sampleRate * filePara.channels); 125 filePara.numberSamples/filePara.sampleRate * filePara.channels);
127 qDebug("samples %d, rate %d, channels %d", 126 qDebug("samples %d, rate %d, channels %d",
128 filePara.numberSamples, filePara.sampleRate, filePara.channels); 127 filePara.numberSamples, filePara.sampleRate, filePara.channels);
129 128
130 int total = 0; // Total number of bytes read in so far. 129 int total = 0; // Total number of bytes read in so far.
131 int bytesWritten, number; 130 int bytesWritten, number;
132 131
133 bytesWritten = 0; 132 bytesWritten = 0;
134 number = 0; 133 number = 0;
135 QString num; 134 QString num;
136 int level = 0; 135 int level = 0;
137 int threshold = 0; 136 int threshold = 0;
138// int bits = filePara.resolution; 137// int bits = filePara.resolution;
139// qDebug("bits %d", bits); 138// odebug << "bits " << bits << "" << oendl;
140 139
141 if( filePara.resolution == 16 ) { //AFMT_S16_LE) 140 if( filePara.resolution == 16 ) { //AFMT_S16_LE)
142// qDebug("AFMT_S16_LE size %d", filePara.SecondsToRecord); 141// odebug << "AFMT_S16_LE size " << filePara.SecondsToRecord << "" << oendl;
143// qDebug("samples to record %d", filePara.samplesToRecord); 142// odebug << "samples to record " << filePara.samplesToRecord << "" << oendl;
144// qDebug("%d", filePara.sd); 143// odebug << "" << filePara.sd << "" << oendl;
145 level = 7; 144 level = 7;
146 threshold = 0; 145 threshold = 0;
147 146
148 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { 147 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) {
149// qDebug("start recording WAVE_FORMAT_DVI_ADPCM"); 148// odebug << "start recording WAVE_FORMAT_DVI_ADPCM" << oendl;
150 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> 149 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
151 char abuf[ BUFSIZE/2 ]; 150 char abuf[ BUFSIZE/2 ];
152 short sbuf[ BUFSIZE ]; 151 short sbuf[ BUFSIZE ];
153 short sbuf2[ BUFSIZE ]; 152 short sbuf2[ BUFSIZE ];
154 memset( abuf, 0, BUFSIZE/2); 153 memset( abuf, 0, BUFSIZE/2);
155 memset( sbuf, 0, BUFSIZE); 154 memset( sbuf, 0, BUFSIZE);
156 memset( sbuf2, 0, BUFSIZE); 155 memset( sbuf2, 0, BUFSIZE);
157 156
158 for(;;) { 157 for(;;) {
159 if ( stopped) { 158 if ( stopped) {
160 // qDebug("quickRec:: stopped"); 159 // odebug << "quickRec:: stopped" << oendl;
161 break; 160 break;
162 } 161 }
163 162
164// number=::read( filePara.sd, sbuf, BUFSIZE); 163// number=::read( filePara.sd, sbuf, BUFSIZE);
165 number = soundDevice ->devRead( filePara.sd, sbuf, BUFSIZE); 164 number = soundDevice ->devRead( filePara.sd, sbuf, BUFSIZE);
166 165
167 if(number <= 0) { 166 if(number <= 0) {
168 perror("recording error "); 167 perror("recording error ");
169 qDebug( "%s %d", filePara.fileName, number); 168 odebug << "" << filePara.fileName << " " << number << "" << oendl;
170 stopped = true; 169 stopped = true;
171 return; 170 return;
172 } 171 }
173 //if(stereo == 2) { 172 //if(stereo == 2) {
174// adpcm_coder( sbuf2, abuf, number/2, &encoder_state); 173// adpcm_coder( sbuf2, abuf, number/2, &encoder_state);
175 adpcm_coder( sbuf, abuf, number/2, &encoder_state); 174 adpcm_coder( sbuf, abuf, number/2, &encoder_state);
176 175
177 bytesWritten = ::write( filePara.fd , (short *)abuf, number/4); 176 bytesWritten = ::write( filePara.fd , (short *)abuf, number/4);
178 177
179 waveform->newSamples( (const short *)abuf, bytesWritten ); 178 waveform->newSamples( (const short *)abuf, bytesWritten );
180 179
181 total += bytesWritten; 180 total += bytesWritten;
182 filePara.numberSamples = total; 181 filePara.numberSamples = total;
183 timeSlider->setValue( total); 182 timeSlider->setValue( total);
184 183
185 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2 / filePara.channels; 184 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2 / filePara.channels;
186 185
187 qApp->processEvents(); 186 qApp->processEvents();
188 if( total >= filePara.samplesToRecord) { 187 if( total >= filePara.samplesToRecord) {
189 stopped = true; 188 stopped = true;
190 break; 189 break;
191 } 190 }
192 } 191 }
193 } else { 192 } else {
194 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> 193 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>>
195 qDebug("start recording WAVE_FORMAT_PCM"); 194 odebug << "start recording WAVE_FORMAT_PCM" << oendl;
196 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ]; 195 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ];
197 memset( inbuffer, 0, BUFSIZE); 196 memset( inbuffer, 0, BUFSIZE);
198 memset( outbuffer, 0, BUFSIZE); 197 memset( outbuffer, 0, BUFSIZE);
199 198
200 for(;;) { 199 for(;;) {
201 if ( stopped) { 200 if ( stopped) {
202 qDebug("quickRec:: stopped"); 201 odebug << "quickRec:: stopped" << oendl;
203 stopped = true; 202 stopped = true;
204 break; // stop if playing was set to false 203 break; // stop if playing was set to false
205 return; 204 return;
206 } 205 }
207 206
208 number = soundDevice->devRead( filePara.sd, (short *)inbuffer, BUFSIZE); 207 number = soundDevice->devRead( filePara.sd, (short *)inbuffer, BUFSIZE);
209 waveform->newSamples( inbuffer, number ); 208 waveform->newSamples( inbuffer, number );
210 209
211 if( number <= 0) { 210 if( number <= 0) {
212 perror( "recording error "); 211 perror( "recording error ");
213 qDebug( filePara.fileName); 212 odebug << filePara.fileName << oendl;
214 stopped = true; 213 stopped = true;
215 return; 214 return;
216 } 215 }
217 216
218 bytesWritten = ::write( filePara.fd , inbuffer, number); 217 bytesWritten = ::write( filePara.fd , inbuffer, number);
219 218
220 if( bytesWritten < 0) { 219 if( bytesWritten < 0) {
221 perror("File writing error "); 220 perror("File writing error ");
222 stopped = true; 221 stopped = true;
223 return; 222 return;
224 } 223 }
225 224
226 total += bytesWritten; 225 total += bytesWritten;
227 226
228 filePara.numberSamples = total; 227 filePara.numberSamples = total;
229 228
230 if( filePara.SecondsToRecord != 0) 229 if( filePara.SecondsToRecord != 0)
231 timeSlider->setValue( total); 230 timeSlider->setValue( total);
232// printf("Writing number %d, bytes %d,total %d\r",number, bytesWritten , total); 231// printf("Writing number %d, bytes %d,total %d\r",number, bytesWritten , total);
233// fflush(stdout); 232// fflush(stdout);
234 233
235 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2/filePara.channels; 234 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2/filePara.channels;
236 qApp->processEvents(); 235 qApp->processEvents();
237 236
238 if( total >= filePara.samplesToRecord) { 237 if( total >= filePara.samplesToRecord) {
239 stopped = true; 238 stopped = true;
240 break; 239 break;
241 } 240 }
242 } 241 }
243 } //end main loop 242 } //end main loop
244 243
245 } else { 244 } else {
246// <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8; 245// <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8;
247 unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ]; 246 unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ];
248 memset( unsigned_inbuffer, 0, BUFSIZE); 247 memset( unsigned_inbuffer, 0, BUFSIZE);
249 memset( unsigned_outbuffer, 0, BUFSIZE); 248 memset( unsigned_outbuffer, 0, BUFSIZE);
250 249
251 for(;;) { 250 for(;;) {
252 if ( stopped) { 251 if ( stopped) {
253 qDebug("quickRec:: stopped"); 252 odebug << "quickRec:: stopped" << oendl;
254 break; // stop if playing was set to false 253 break; // stop if playing was set to false
255 } 254 }
256 255
257 number = ::read( filePara.sd, unsigned_inbuffer, BUFSIZE); 256 number = ::read( filePara.sd, unsigned_inbuffer, BUFSIZE);
258 bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number); 257 bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number);
259 258
260 if(bytesWritten < 0) { 259 if(bytesWritten < 0) {
261 stopped = true; 260 stopped = true;
262 QMessageBox::message("Note","There was a problem\nwriting to the file"); 261 QMessageBox::message("Note","There was a problem\nwriting to the file");
263 perror("File writing error "); 262 perror("File writing error ");
264 return; 263 return;
265 } 264 }
266 265
267 total += bytesWritten; 266 total += bytesWritten;
268 filePara.numberSamples = total; 267 filePara.numberSamples = total;
269 // printf("\nWriting number %d, bytes %d,total %d \r",number, bytesWritten , total); 268 // printf("\nWriting number %d, bytes %d,total %d \r",number, bytesWritten , total);
270 // fflush(stdout); 269 // fflush(stdout);
271 if( filePara.SecondsToRecord !=0) 270 if( filePara.SecondsToRecord !=0)
272 timeSlider->setValue( total); 271 timeSlider->setValue( total);
273 272
274 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; 273 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate;
275 274
276 qApp->processEvents(); 275 qApp->processEvents();
277 if( total >= filePara.samplesToRecord) { 276 if( total >= filePara.samplesToRecord) {
@@ -352,49 +351,49 @@ void playIt()
352 number = ::read( filePara.fd, inbuffer, BUFSIZE); 351 number = ::read( filePara.fd, inbuffer, BUFSIZE);
353// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel 352// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel
354// // for (int i=0;i< number ; i++) { //2*i is left channel 353// // for (int i=0;i< number ; i++) { //2*i is left channel
355// outbuffer[i+1]= outbuffer[i]=inbuffer[i]; 354// outbuffer[i+1]= outbuffer[i]=inbuffer[i];
356// } 355// }
357 bytesWritten = ::write( filePara.sd, inbuffer, number); 356 bytesWritten = ::write( filePara.sd, inbuffer, number);
358 waveform->newSamples( inbuffer, bytesWritten ); 357 waveform->newSamples( inbuffer, bytesWritten );
359 //-------------->>>> out to device 358 //-------------->>>> out to device
360 // total+=bytesWritten; 359 // total+=bytesWritten;
361 // if(filePara.channels==1) 360 // if(filePara.channels==1)
362 // total += bytesWritten/2; //mono 361 // total += bytesWritten/2; //mono
363 // else 362 // else
364 total += bytesWritten; 363 total += bytesWritten;
365 timeSlider->setValue( total); 364 timeSlider->setValue( total);
366 365
367 filePara.numberSamples = total; 366 filePara.numberSamples = total;
368 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2; 367 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2;
369 368
370// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); 369// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
371// timeLabel->setText( timeString + tr(" seconds")); 370// timeLabel->setText( timeString + tr(" seconds"));
372 371
373 qApp->processEvents(); 372 qApp->processEvents();
374 373
375 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { 374 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
376 qWarning("Jane! Stop this crazy thing!"); 375 owarn << "Jane! Stop this crazy thing!" << oendl;
377 stopped = true; 376 stopped = true;
378// playing = false; 377// playing = false;
379 break; 378 break;
380 } 379 }
381 } 380 }
382 printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total); 381 printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total);
383 fflush(stdout); 382 fflush(stdout);
384 } //end loop 383 } //end loop
385 } else { 384 } else {
386/////////////////////////////// format = AFMT_U8; 385/////////////////////////////// format = AFMT_U8;
387 unsigned char unsigned_inbuffer[ BUFSIZE ]; //, unsigned_outbuffer[BUFSIZE]; 386 unsigned char unsigned_inbuffer[ BUFSIZE ]; //, unsigned_outbuffer[BUFSIZE];
388 memset( unsigned_inbuffer, 0, BUFSIZE); 387 memset( unsigned_inbuffer, 0, BUFSIZE);
389 for(;;) { 388 for(;;) {
390// main loop 389// main loop
391 if (stopped) { 390 if (stopped) {
392 break; // stop if playing was set to false 391 break; // stop if playing was set to false
393 return; 392 return;
394 } 393 }
395 number = ::read( filePara.fd, unsigned_inbuffer, BUFSIZE); 394 number = ::read( filePara.fd, unsigned_inbuffer, BUFSIZE);
396//data = (val >> 8) ^ 0x80; 395//data = (val >> 8) ^ 0x80;
397 // unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80; 396 // unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80;
398 bytesWritten = write ( filePara.sd, unsigned_inbuffer, number); 397 bytesWritten = write ( filePara.sd, unsigned_inbuffer, number);
399 waveform->newSamples( (const short *)unsigned_inbuffer, bytesWritten ); 398 waveform->newSamples( (const short *)unsigned_inbuffer, bytesWritten );
400 total += bytesWritten; 399 total += bytesWritten;
@@ -697,49 +696,49 @@ void QtRec::init() {
697 fillDirectoryCombo(); 696 fillDirectoryCombo();
698 697
699 TabWidget->insertTab( tab_3, tr( "Options" ) ); 698 TabWidget->insertTab( tab_3, tr( "Options" ) );
700 699
701 TabWidget->insertTab( tab_5, tr( "Volume" ) ); 700 TabWidget->insertTab( tab_5, tr( "Volume" ) );
702 701
703 702
704 waveform = new Waveform( this, "waveform" ); 703 waveform = new Waveform( this, "waveform" );
705// waveform->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)3, waveform->sizePolicy().hasHeightForWidth() ) ); 704// waveform->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)3, waveform->sizePolicy().hasHeightForWidth() ) );
706 waveform->setMinimumSize( QSize( 0, 50 ) ); 705 waveform->setMinimumSize( QSize( 0, 50 ) );
707 706
708 layout->addMultiCellWidget( waveform, 8, 8, 0, 7 ); 707 layout->addMultiCellWidget( waveform, 8, 8, 0, 7 );
709 waveform->setBackgroundColor ( black ); 708 waveform->setBackgroundColor ( black );
710} 709}
711 710
712void QtRec::initIconView() { 711void QtRec::initIconView() {
713 712
714 ListView1->clear(); 713 ListView1->clear();
715 Config cfg("OpieRec"); 714 Config cfg("OpieRec");
716 cfg.setGroup("Sounds"); 715 cfg.setGroup("Sounds");
717 QString temp; 716 QString temp;
718 QPixmap image0( ( const char** ) image0_data ); 717 QPixmap image0( ( const char** ) image0_data );
719 718
720 int nFiles = cfg.readNumEntry("NumberofFiles",0); 719 int nFiles = cfg.readNumEntry("NumberofFiles",0);
721 // qDebug("init number of files %d", nFiles); 720 // odebug << "init number of files " << nFiles << "" << oendl;
722 721
723 for(int i=1;i<= nFiles;i++) { 722 for(int i=1;i<= nFiles;i++) {
724 723
725 QListViewItem * item; 724 QListViewItem * item;
726 QString fileS, mediaLocation, fileDate, filePath; 725 QString fileS, mediaLocation, fileDate, filePath;
727 726
728 temp.sprintf( "%d",i); 727 temp.sprintf( "%d",i);
729 temp = cfg.readEntry( temp,""); //reads currentFile 728 temp = cfg.readEntry( temp,""); //reads currentFile
730 filePath = cfg.readEntry( temp,""); //currentFileName 729 filePath = cfg.readEntry( temp,""); //currentFileName
731 730
732 QFileInfo info(filePath); 731 QFileInfo info(filePath);
733 fileDate = info.lastModified().toString(); 732 fileDate = info.lastModified().toString();
734 733
735 fileS = cfg.readEntry( filePath, "0" );// file length in seconds 734 fileS = cfg.readEntry( filePath, "0" );// file length in seconds
736 mediaLocation = getStorage( filePath); 735 mediaLocation = getStorage( filePath);
737 if( info.exists()) { 736 if( info.exists()) {
738 item = new QListViewItem( ListView1, temp, fileS, mediaLocation, fileDate); 737 item = new QListViewItem( ListView1, temp, fileS, mediaLocation, fileDate);
739 item->setPixmap( 0, image0); 738 item->setPixmap( 0, image0);
740 if( currentFileName == filePath) 739 if( currentFileName == filePath)
741 ListView1->setSelected( item, true); 740 ListView1->setSelected( item, true);
742 } 741 }
743 } 742 }
744} 743}
745 744
@@ -839,49 +838,49 @@ void QtRec::initConfig() {
839 } else { 838 } else {
840 filePara.channels = 1; 839 filePara.channels = 1;
841 } 840 }
842 841
843 compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); 842 compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1));
844 if( compressionCheckBox->isChecked()) { 843 if( compressionCheckBox->isChecked()) {
845 bitRateComboBox->setEnabled(false); 844 bitRateComboBox->setEnabled(false);
846 bitRateComboBox->setCurrentItem(0); 845 bitRateComboBox->setCurrentItem(0);
847 filePara.resolution=16; 846 filePara.resolution=16;
848 } 847 }
849 848
850 autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0)); 849 autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0));
851 if( autoMuteCheckBox->isChecked()) 850 if( autoMuteCheckBox->isChecked())
852 slotAutoMute(true); 851 slotAutoMute(true);
853 else 852 else
854 slotAutoMute(false); 853 slotAutoMute(false);
855 854
856 Config cofg( "qpe"); 855 Config cofg( "qpe");
857 cofg.setGroup( "Volume"); 856 cofg.setGroup( "Volume");
858 outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0)); 857 outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0));
859 inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0)); 858 inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0));
860} 859}
861 860
862void QtRec::stop() { 861void QtRec::stop() {
863 qWarning("STOP"); 862 owarn << "STOP" << oendl;
864 setRecordButton(false); 863 setRecordButton(false);
865 864
866 if( !recording) 865 if( !recording)
867 endPlaying(); 866 endPlaying();
868 else 867 else
869 endRecording(); 868 endRecording();
870 timeSlider->setValue(0); 869 timeSlider->setValue(0);
871} 870}
872 871
873void QtRec::doPlayBtn() { 872void QtRec::doPlayBtn() {
874 873
875 if(!stopped) { 874 if(!stopped) {
876 playLabel2->setText(tr("Play")); 875 playLabel2->setText(tr("Play"));
877 stop(); 876 stop();
878 } else { 877 } else {
879 if(ListView1->currentItem() == 0) return; 878 if(ListView1->currentItem() == 0) return;
880 playLabel2->setText(tr("Stop")); 879 playLabel2->setText(tr("Stop"));
881 currentFile = ListView1->currentItem()->text(0); 880 currentFile = ListView1->currentItem()->text(0);
882 start(); 881 start();
883 } 882 }
884} 883}
885 884
886void QtRec::start() { //play 885void QtRec::start() { //play
887 if( stopped) { 886 if( stopped) {
@@ -901,143 +900,143 @@ void QtRec::start() { //play
901bool QtRec::rec() { //record 900bool QtRec::rec() { //record
902 QString timeString; 901 QString timeString;
903 timeString.sprintf("%.0f", 0.0); 902 timeString.sprintf("%.0f", 0.0);
904 timeLabel->setText( timeString+ " seconds"); 903 timeLabel->setText( timeString+ " seconds");
905 if(!stopped) { 904 if(!stopped) {
906 monitoring = true; 905 monitoring = true;
907 return false; 906 return false;
908 } else { 907 } else {
909 secCount = 1; 908 secCount = 1;
910 playLabel2->setText(tr("Stop")); 909 playLabel2->setText(tr("Stop"));
911 monitoring = false; 910 monitoring = false;
912 setRecordButton( true); 911 setRecordButton( true);
913 912
914 if( setupAudio( true)) 913 if( setupAudio( true))
915 if(setUpFile()) { 914 if(setUpFile()) {
916 int fileSize = 0; 915 int fileSize = 0;
917 Config cfg("OpieRec"); 916 Config cfg("OpieRec");
918 cfg.setGroup("Settings"); 917 cfg.setGroup("Settings");
919// qDebug( "<<<<<<<Device bits %d, device rate %d, device channels %d", 918// qDebug( "<<<<<<<Device bits %d, device rate %d, device channels %d",
920// soundDevice->getDeviceBits(), 919// soundDevice->getDeviceBits(),
921// soundDevice->getDeviceRate(), 920// soundDevice->getDeviceRate(),
922// soundDevice->getDeviceChannels()); 921// soundDevice->getDeviceChannels());
923 922
924 //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050); 923 //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050);
925// qDebug("sample rate is %d", filePara.sampleRate); 924// odebug << "sample rate is " << filePara.sampleRate << "" << oendl;
926 filePara.SecondsToRecord = getCurrentSizeLimit(); 925 filePara.SecondsToRecord = getCurrentSizeLimit();
927 926
928// qDebug("size limit %d sec", filePara.SecondsToRecord); 927// odebug << "size limit " << filePara.SecondsToRecord << " sec" << oendl;
929 int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); 928 int diskSize = checkDiskSpace( (const QString &) wavFile->trackName());
930 929
931 if( filePara.SecondsToRecord == 0) { 930 if( filePara.SecondsToRecord == 0) {
932 fileSize = diskSize; 931 fileSize = diskSize;
933 } else if( filePara.format == WAVE_FORMAT_PCM) { 932 } else if( filePara.format == WAVE_FORMAT_PCM) {
934// qDebug("WAVE_FORMAT_PCM"); 933// odebug << "WAVE_FORMAT_PCM" << oendl;
935 fileSize = (filePara.SecondsToRecord ) * filePara.channels 934 fileSize = (filePara.SecondsToRecord ) * filePara.channels
936 * filePara.sampleRate * ( filePara.resolution / 8) + 1000; 935 * filePara.sampleRate * ( filePara.resolution / 8) + 1000;
937 } else { 936 } else {
938// qDebug("WAVE_FORMAT_DVI_ADPCM"); 937// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl;
939 fileSize = ((filePara.SecondsToRecord) * filePara.channels 938 fileSize = ((filePara.SecondsToRecord) * filePara.channels
940 * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250; 939 * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250;
941 } 940 }
942 941
943 filePara.samplesToRecord = fileSize; 942 filePara.samplesToRecord = fileSize;
944 qDebug("filesize should be %d, bits %d, rate %d", 943 qDebug("filesize should be %d, bits %d, rate %d",
945 filePara.samplesToRecord, filePara.resolution, filePara.sampleRate); 944 filePara.samplesToRecord, filePara.resolution, filePara.sampleRate);
946 if( paused) { 945 if( paused) {
947 paused = false; 946 paused = false;
948 } 947 }
949 // else { 948 // else {
950 qDebug("Setting timeslider %d", filePara.samplesToRecord); 949 odebug << "Setting timeslider " << filePara.samplesToRecord << "" << oendl;
951 // if(fileSize != 0) 950 // if(fileSize != 0)
952 timeSlider->setRange(0, filePara.samplesToRecord); 951 timeSlider->setRange(0, filePara.samplesToRecord);
953 // } 952 // }
954 953
955 if( diskSize < fileSize/1024) { 954 if( diskSize < fileSize/1024) {
956 QMessageBox::warning(this, 955 QMessageBox::warning(this,
957 tr("Low Disk Space"), 956 tr("Low Disk Space"),
958 tr("You are running low of\nrecording space\n" 957 tr("You are running low of\nrecording space\n"
959 "or a card isn't being recognized")); 958 "or a card isn't being recognized"));
960 stopped = true; //we need to be stopped 959 stopped = true; //we need to be stopped
961 stop(); 960 stop();
962 } else { 961 } else {
963 QString msg; 962 QString msg;
964 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); 963 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution);
965#ifdef DEV_VERSION 964#ifdef DEV_VERSION
966 setCaption( msg); 965 setCaption( msg);
967#endif 966#endif
968 filePara.fileName=currentFile.latin1(); 967 filePara.fileName=currentFile.latin1();
969 qDebug("Start recording thread"); 968 odebug << "Start recording thread" << oendl;
970 stopped = false; 969 stopped = false;
971 970
972#ifdef THREADED 971#ifdef THREADED
973 pthread_t thread1; 972 pthread_t thread1;
974 pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); 973 pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/);
975#endif 974#endif
976 toBeginningButton->setEnabled( false); 975 toBeginningButton->setEnabled( false);
977 toEndButton->setEnabled( false); 976 toEndButton->setEnabled( false);
978 977
979 startTimer(1000); 978 startTimer(1000);
980#ifndef THREADED 979#ifndef THREADED
981 quickRec(); 980 quickRec();
982#endif 981#endif
983 } 982 }
984 } //end setUpFile 983 } //end setUpFile
985 } //end setupAudio 984 } //end setupAudio
986 return true; 985 return true;
987} 986}
988/* 987/*
989 This happens when a tab is selected*/ 988 This happens when a tab is selected*/
990void QtRec::thisTab(QWidget* widg) { 989void QtRec::thisTab(QWidget* widg) {
991 if(widg != NULL) { 990 if(widg != NULL) {
992 int index = TabWidget->currentPageIndex(); 991 int index = TabWidget->currentPageIndex();
993 992
994 if(index == 0) { //file page 993 if(index == 0) { //file page
995 } 994 }
996 995
997 if(index == 1) { //control page 996 if(index == 1) { //control page
998 fillDirectoryCombo(); 997 fillDirectoryCombo();
999// soundDevice->getOutVol(); 998// soundDevice->getOutVol();
1000// soundDevice->getInVol(); 999// soundDevice->getInVol();
1001 } 1000 }
1002 1001
1003 if( index==2) { //help page 1002 if( index==2) { //help page
1004 } 1003 }
1005 1004
1006 qApp->processEvents(); 1005 qApp->processEvents();
1007 update(); 1006 update();
1008 } 1007 }
1009} 1008}
1010 1009
1011void QtRec::getOutVol( ) { 1010void QtRec::getOutVol( ) {
1012 filePara.outVol = soundDevice->getOutVolume(); 1011 filePara.outVol = soundDevice->getOutVolume();
1013// qDebug("out vol %d", filePara.outVol); 1012// odebug << "out vol " << filePara.outVol << "" << oendl;
1014 OutputSlider->setValue( -filePara.outVol); 1013 OutputSlider->setValue( -filePara.outVol);
1015} 1014}
1016 1015
1017void QtRec::getInVol() { 1016void QtRec::getInVol() {
1018 filePara.inVol = soundDevice->getInVolume(); 1017 filePara.inVol = soundDevice->getInVolume();
1019// qDebug("in vol %d", filePara.inVol); 1018// odebug << "in vol " << filePara.inVol << "" << oendl;
1020 InputSlider->setValue( -filePara.inVol); 1019 InputSlider->setValue( -filePara.inVol);
1021} 1020}
1022 1021
1023void QtRec::changedOutVolume() { 1022void QtRec::changedOutVolume() {
1024 soundDevice->changedOutVolume( -OutputSlider->value()); 1023 soundDevice->changedOutVolume( -OutputSlider->value());
1025} 1024}
1026 1025
1027void QtRec::changedInVolume( ) { 1026void QtRec::changedInVolume( ) {
1028 soundDevice->changedInVolume( -InputSlider->value()); 1027 soundDevice->changedInVolume( -InputSlider->value());
1029} 1028}
1030 1029
1031 1030
1032bool QtRec::setupAudio( bool b) { 1031bool QtRec::setupAudio( bool b) {
1033 bool ok; 1032 bool ok;
1034 int sampleformat, stereo, flags; 1033 int sampleformat, stereo, flags;
1035 QString dspString, mixerString; 1034 QString dspString, mixerString;
1036 1035
1037 filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16 1036 filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16
1038 1037
1039 if( !b) { 1038 if( !b) {
1040// we want to play 1039// we want to play
1041#ifdef PDAUDIO //ALSA 1040#ifdef PDAUDIO //ALSA
1042 if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { 1041 if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) {
1043 sampleformat = SND_PCM_FORMAT_S16; 1042 sampleformat = SND_PCM_FORMAT_S16;
@@ -1069,141 +1068,141 @@ bool QtRec::setupAudio( bool b) {
1069 hwcfg.setGroup("Hardware"); 1068 hwcfg.setGroup("Hardware");
1070 dspString = hwcfg.readEntry( "Audio", DSPSTROUT); 1069 dspString = hwcfg.readEntry( "Audio", DSPSTROUT);
1071 mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXEROUT); 1070 mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXEROUT);
1072 recording = false; 1071 recording = false;
1073 } else { // we want to record 1072 } else { // we want to record
1074 1073
1075#ifdef PDAUDIO //ALSA 1074#ifdef PDAUDIO //ALSA
1076 if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") 1075 if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16")
1077 sampleformat = SND_PCM_FORMAT_S16; 1076 sampleformat = SND_PCM_FORMAT_S16;
1078 else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "24") 1077 else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "24")
1079 sampleformat = SND_PCM_FORMAT_S24; 1078 sampleformat = SND_PCM_FORMAT_S24;
1080 else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "32") 1079 else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "32")
1081 sampleformat = SND_PCM_FORMAT_S32; 1080 sampleformat = SND_PCM_FORMAT_S32;
1082 else 1081 else
1083 sampleformat = SND_PCM_FORMAT_U8; 1082 sampleformat = SND_PCM_FORMAT_U8;
1084 1083
1085#else 1084#else
1086 if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") 1085 if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16")
1087 sampleformat = AFMT_S16_LE; 1086 sampleformat = AFMT_S16_LE;
1088 else 1087 else
1089 sampleformat = AFMT_U8; 1088 sampleformat = AFMT_U8;
1090 1089
1091 if( !compressionCheckBox->isChecked()) { 1090 if( !compressionCheckBox->isChecked()) {
1092 filePara.format = WAVE_FORMAT_PCM; 1091 filePara.format = WAVE_FORMAT_PCM;
1093// qDebug("WAVE_FORMAT_PCM"); 1092// odebug << "WAVE_FORMAT_PCM" << oendl;
1094 } else { 1093 } else {
1095 filePara.format = WAVE_FORMAT_DVI_ADPCM; 1094 filePara.format = WAVE_FORMAT_DVI_ADPCM;
1096 sampleformat = AFMT_S16_LE; 1095 sampleformat = AFMT_S16_LE;
1097// qDebug("WAVE_FORMAT_DVI_ADPCM"); 1096// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl;
1098 } 1097 }
1099#endif 1098#endif
1100 1099
1101 stereo = filePara.channels; 1100 stereo = filePara.channels;
1102// filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; 1101// filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100;
1103 flags= O_RDWR; 1102 flags= O_RDWR;
1104// flags= O_RDONLY; 1103// flags= O_RDONLY;
1105 Config hwcfg("OpieRec"); 1104 Config hwcfg("OpieRec");
1106 hwcfg.setGroup("Hardware"); 1105 hwcfg.setGroup("Hardware");
1107 dspString = hwcfg.readEntry( "Audio", DSPSTRIN); 1106 dspString = hwcfg.readEntry( "Audio", DSPSTRIN);
1108 mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXERIN); 1107 mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXERIN);
1109 recording = true; 1108 recording = true;
1110 } 1109 }
1111 1110
1112 // if(soundDevice) delete soundDevice; 1111 // if(soundDevice) delete soundDevice;
1113 qDebug("<<<<<<<<<<<<<<<<<<<open dsp %d %d %d", filePara.sampleRate, filePara.channels, sampleformat); 1112 odebug << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl;
1114 qWarning("change waveform settings"); 1113 owarn << "change waveform settings" << oendl;
1115 waveform->changeSettings( filePara.sampleRate, filePara.channels ); 1114 waveform->changeSettings( filePara.sampleRate, filePara.channels );
1116 1115
1117 soundDevice = new Device( this, dspString, mixerString, b); 1116 soundDevice = new Device( this, dspString, mixerString, b);
1118// soundDevice->openDsp(); 1117// soundDevice->openDsp();
1119 soundDevice->reset(); 1118 soundDevice->reset();
1120 1119
1121 qDebug("device has been made %d", soundDevice->sd); 1120 odebug << "device has been made " << soundDevice->sd << "" << oendl;
1122 1121
1123 ////////////////// <<<<<<<<<<<<>>>>>>>>>>>> 1122 ////////////////// <<<<<<<<<<<<>>>>>>>>>>>>
1124 soundDevice->setDeviceFormat( sampleformat); 1123 soundDevice->setDeviceFormat( sampleformat);
1125 soundDevice->setDeviceChannels( filePara.channels); 1124 soundDevice->setDeviceChannels( filePara.channels);
1126 soundDevice->setDeviceRate( filePara.sampleRate); 1125 soundDevice->setDeviceRate( filePara.sampleRate);
1127 soundDevice->getDeviceFragSize(); 1126 soundDevice->getDeviceFragSize();
1128#ifdef QT_QWS_EBX 1127#ifdef QT_QWS_EBX
1129 int frag = FRAGSIZE; 1128 int frag = FRAGSIZE;
1130 soundDevice->setFragSize( frag); 1129 soundDevice->setFragSize( frag);
1131 soundDevice->getDeviceFragSize(); 1130 soundDevice->getDeviceFragSize();
1132#endif 1131#endif
1133 ///////////////// 1132 /////////////////
1134 filePara.sd = soundDevice->sd; 1133 filePara.sd = soundDevice->sd;
1135 1134
1136 if ( filePara.sd == -1) { 1135 if ( filePara.sd == -1) {
1137 1136
1138 monitoring = false; 1137 monitoring = false;
1139 stopped = true; 1138 stopped = true;
1140 update(); 1139 update();
1141 setCaption( tr( "OpieRecord " )+ QString::number(VERSION) ); 1140 setCaption( tr( "OpieRecord " )+ QString::number(VERSION) );
1142 return false; 1141 return false;
1143 } 1142 }
1144 if(autoMute) 1143 if(autoMute)
1145 doMute(false); 1144 doMute(false);
1146 1145
1147 return true; 1146 return true;
1148} 1147}
1149 1148
1150 1149
1151bool QtRec::setUpFile() { //setup file for recording 1150bool QtRec::setUpFile() { //setup file for recording
1152// qDebug("Setting up wavfile"); 1151// odebug << "Setting up wavfile" << oendl;
1153// if(wavFile) delete wavFile; 1152// if(wavFile) delete wavFile;
1154 wavFile = new WavFile( this, (const QString &)"", 1153 wavFile = new WavFile( this, (const QString &)"",
1155 true, 1154 true,
1156 filePara.sampleRate, 1155 filePara.sampleRate,
1157 filePara.channels, 1156 filePara.channels,
1158 filePara.resolution, 1157 filePara.resolution,
1159 filePara.format); 1158 filePara.format);
1160 1159
1161 filePara.fd = wavFile->wavHandle(); 1160 filePara.fd = wavFile->wavHandle();
1162 if(filePara.fd == -1) { 1161 if(filePara.fd == -1) {
1163 return false; 1162 return false;
1164 } else { 1163 } else {
1165// filePara.channels=1; 1164// filePara.channels=1;
1166 } 1165 }
1167 return true; 1166 return true;
1168} 1167}
1169 1168
1170/// <<<<<<<<<<<<<<<< PLAY >>>>>>>>>>>>>>>>>>> 1169/// <<<<<<<<<<<<<<<< PLAY >>>>>>>>>>>>>>>>>>>
1171bool QtRec::doPlay() { 1170bool QtRec::doPlay() {
1172 1171
1173 if( !paused) { 1172 if( !paused) {
1174 total = 0; 1173 total = 0;
1175 filePara.numberOfRecordedSeconds = 0; 1174 filePara.numberOfRecordedSeconds = 0;
1176 } else { 1175 } else {
1177 paused = false; 1176 paused = false;
1178 secCount = (int)filePara.numberOfRecordedSeconds; 1177 secCount = (int)filePara.numberOfRecordedSeconds;
1179 } 1178 }
1180 playing = true; 1179 playing = true;
1181 stopped = false; 1180 stopped = false;
1182 recording = false; 1181 recording = false;
1183 1182
1184 QString num; 1183 QString num;
1185 qDebug( "Play number of samples %d", filePara.numberSamples); 1184 odebug << "Play number of samples " << filePara.numberSamples << "" << oendl;
1186 1185
1187// timeSlider->setRange( 0, filePara.numberSamples); 1186// timeSlider->setRange( 0, filePara.numberSamples);
1188 1187
1189 timeString.sprintf("%f", filePara.numberOfRecordedSeconds); 1188 timeString.sprintf("%f", filePara.numberOfRecordedSeconds);
1190 timeLabel->setText( timeString+ tr(" seconds")); 1189 timeLabel->setText( timeString+ tr(" seconds"));
1191 1190
1192 QString msg; 1191 QString msg;
1193 msg.sprintf("%d, %d, %d", 1192 msg.sprintf("%d, %d, %d",
1194 filePara.sampleRate, 1193 filePara.sampleRate,
1195 filePara.channels, 1194 filePara.channels,
1196 filePara.resolution); 1195 filePara.resolution);
1197#ifdef DEV_VERSION 1196#ifdef DEV_VERSION
1198 setCaption( msg); 1197 setCaption( msg);
1199#endif 1198#endif
1200 1199
1201 startTimer( 1000); 1200 startTimer( 1000);
1202#ifdef THREADED 1201#ifdef THREADED
1203 pthread_t thread2; 1202 pthread_t thread2;
1204 pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/); 1203 pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/);
1205#endif 1204#endif
1206 1205
1207 toBeginningButton->setEnabled( false); 1206 toBeginningButton->setEnabled( false);
1208 toEndButton->setEnabled( false); 1207 toEndButton->setEnabled( false);
1209#ifndef THREADED 1208#ifndef THREADED
@@ -1213,69 +1212,69 @@ bool QtRec::doPlay() {
1213} 1212}
1214 1213
1215 1214
1216void QtRec::changebitrateCombo(int i) { 1215void QtRec::changebitrateCombo(int i) {
1217 Config cfg("OpieRec"); 1216 Config cfg("OpieRec");
1218 cfg.setGroup("Settings"); 1217 cfg.setGroup("Settings");
1219 int bits = 0; 1218 int bits = 0;
1220 if( i == 1) { bits = 16; } 1219 if( i == 1) { bits = 16; }
1221 else if( i == 2) { bits = 24; } 1220 else if( i == 2) { bits = 24; }
1222 else if( i == 3) { bits = 32; } 1221 else if( i == 3) { bits = 32; }
1223 else { bits=8; } 1222 else { bits=8; }
1224 cfg.writeEntry("bitrate", bits); 1223 cfg.writeEntry("bitrate", bits);
1225 filePara.resolution = bits; 1224 filePara.resolution = bits;
1226 cfg.write(); 1225 cfg.write();
1227} 1226}
1228 1227
1229void QtRec::changesamplerateCombo(int i) { 1228void QtRec::changesamplerateCombo(int i) {
1230 Config cfg("OpieRec"); 1229 Config cfg("OpieRec");
1231 cfg.setGroup("Settings"); 1230 cfg.setGroup("Settings");
1232 int rate=0; 1231 int rate=0;
1233 bool ok; 1232 bool ok;
1234 rate = sampleRateComboBox->text(i).toInt(&ok, 10); 1233 rate = sampleRateComboBox->text(i).toInt(&ok, 10);
1235 cfg.writeEntry( "samplerate",rate); 1234 cfg.writeEntry( "samplerate",rate);
1236 filePara.sampleRate=rate; 1235 filePara.sampleRate=rate;
1237 qDebug( "Change sample rate %d", rate); 1236 odebug << "Change sample rate " << rate << "" << oendl;
1238 cfg.write(); 1237 cfg.write();
1239} 1238}
1240 1239
1241 1240
1242void QtRec::changeDirCombo(int index) { 1241void QtRec::changeDirCombo(int index) {
1243 Config cfg("OpieRec"); 1242 Config cfg("OpieRec");
1244 cfg.setGroup("Settings"); 1243 cfg.setGroup("Settings");
1245 QString sName = directoryComboBox->text(index); 1244 QString sName = directoryComboBox->text(index);
1246 1245
1247 StorageInfo storageInfo; 1246 StorageInfo storageInfo;
1248 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1247 const QList<FileSystem> &fs = storageInfo.fileSystems();
1249 QListIterator<FileSystem> it ( fs ); 1248 QListIterator<FileSystem> it ( fs );
1250 QString storage; 1249 QString storage;
1251 for( ; it.current(); ++it ){ 1250 for( ; it.current(); ++it ){
1252 if( sName == (*it)->name()+" "+ (*it)->path() || 1251 if( sName == (*it)->name()+" "+ (*it)->path() ||
1253 (*it)->name() == sName ) { 1252 (*it)->name() == sName ) {
1254 const QString path = (*it)->path(); 1253 const QString path = (*it)->path();
1255 recDir = path; 1254 recDir = path;
1256 cfg.writeEntry("directory", recDir); 1255 cfg.writeEntry("directory", recDir);
1257 qDebug("new rec dir "+recDir); 1256 odebug << "new rec dir "+recDir << oendl;
1258 } 1257 }
1259 } 1258 }
1260 cfg.write(); 1259 cfg.write();
1261} 1260}
1262 1261
1263 1262
1264void QtRec::changeSizeLimitCombo(int) { 1263void QtRec::changeSizeLimitCombo(int) {
1265 Config cfg("OpieRec"); 1264 Config cfg("OpieRec");
1266 cfg.setGroup("Settings"); 1265 cfg.setGroup("Settings");
1267 cfg.writeEntry("sizeLimit", getCurrentSizeLimit() ); 1266 cfg.writeEntry("sizeLimit", getCurrentSizeLimit() );
1268 cfg.write(); 1267 cfg.write();
1269} 1268}
1270 1269
1271void QtRec::newSound() { 1270void QtRec::newSound() {
1272 if( !rec()) { 1271 if( !rec()) {
1273 endRecording(); 1272 endRecording();
1274 deleteSound(); 1273 deleteSound();
1275 } 1274 }
1276} 1275}
1277 1276
1278void QtRec::itClick(QListViewItem *item) { 1277void QtRec::itClick(QListViewItem *item) {
1279 currentFile = item->text(0); 1278 currentFile = item->text(0);
1280 setCaption("OpieRecord "+currentFile); 1279 setCaption("OpieRecord "+currentFile);
1281} 1280}
@@ -1353,49 +1352,49 @@ void QtRec::keyPressEvent( QKeyEvent *e) {
1353 // break; 1352 // break;
1354 1353
1355 ////////////////////////////// Zaurus keys 1354 ////////////////////////////// Zaurus keys
1356 case Key_F9: //activity 1355 case Key_F9: //activity
1357 break; 1356 break;
1358 case Key_F10: //contacts 1357 case Key_F10: //contacts
1359 break; 1358 break;
1360 case Key_F11: //menu 1359 case Key_F11: //menu
1361 break; 1360 break;
1362 case Key_F12: //home 1361 case Key_F12: //home
1363 break; 1362 break;
1364 case Key_F13: //mail 1363 case Key_F13: //mail
1365 break; 1364 break;
1366 case Key_Space: 1365 case Key_Space:
1367 break; 1366 break;
1368 case Key_Delete: 1367 case Key_Delete:
1369 break; 1368 break;
1370 case Key_Up: 1369 case Key_Up:
1371 // stop(); 1370 // stop();
1372 break; 1371 break;
1373 case Key_Down: 1372 case Key_Down:
1374 // newSound(); 1373 // newSound();
1375 break; 1374 break;
1376 case Key_Left: { 1375 case Key_Left: {
1377 qDebug("rewinding"); 1376 odebug << "rewinding" << oendl;
1378 if( !e->isAutoRepeat()) 1377 if( !e->isAutoRepeat())
1379 rewindPressed(); 1378 rewindPressed();
1380 } 1379 }
1381 break; 1380 break;
1382 case Key_Right: { 1381 case Key_Right: {
1383 if( !e->isAutoRepeat()) 1382 if( !e->isAutoRepeat())
1384 FastforwardPressed(); 1383 FastforwardPressed();
1385 } 1384 }
1386 break; 1385 break;
1387 } 1386 }
1388} 1387}
1389 1388
1390void QtRec::keyReleaseEvent( QKeyEvent *e) { 1389void QtRec::keyReleaseEvent( QKeyEvent *e) {
1391 switch ( e->key() ) { 1390 switch ( e->key() ) {
1392 // case Key_F1: 1391 // case Key_F1:
1393 // if(stopped && !recording) 1392 // if(stopped && !recording)
1394 // newSound(); 1393 // newSound();
1395 // else 1394 // else
1396 // stop(); 1395 // stop();
1397 // break; 1396 // break;
1398 // case Key_F2: 1397 // case Key_F2:
1399 // rewindReleased(); 1398 // rewindReleased();
1400 // break; 1399 // break;
1401 // case Key_F3: 1400 // case Key_F3:
@@ -1407,210 +1406,210 @@ void QtRec::keyReleaseEvent( QKeyEvent *e) {
1407 break; 1406 break;
1408 case Key_F10: //contacts 1407 case Key_F10: //contacts
1409 break; 1408 break;
1410 case Key_F11: //menu 1409 case Key_F11: //menu
1411 break; 1410 break;
1412 case Key_F12: //home 1411 case Key_F12: //home
1413 if(stopped) 1412 if(stopped)
1414 doPlayBtn(); 1413 doPlayBtn();
1415 else 1414 else
1416 stop(); 1415 stop();
1417 break; 1416 break;
1418 case Key_F13: //mail 1417 case Key_F13: //mail
1419 break; 1418 break;
1420 case Key_Space: 1419 case Key_Space:
1421 if(stopped && !recording) 1420 if(stopped && !recording)
1422 newSound(); 1421 newSound();
1423 else 1422 else
1424 stop(); 1423 stop();
1425 break; 1424 break;
1426 case Key_Delete: 1425 case Key_Delete:
1427 deleteSound(); 1426 deleteSound();
1428 break; 1427 break;
1429 case Key_Up: 1428 case Key_Up:
1430 // stop(); 1429 // stop();
1431 qDebug("Up"); 1430 odebug << "Up" << oendl;
1432 break; 1431 break;
1433 case Key_Down: 1432 case Key_Down:
1434 // start(); 1433 // start();
1435 // qDebug("Down"); 1434 // odebug << "Down" << oendl;
1436 // newSound(); 1435 // newSound();
1437 break; 1436 break;
1438 case Key_Left: 1437 case Key_Left:
1439 qDebug("Left"); 1438 odebug << "Left" << oendl;
1440 rewindReleased(); 1439 rewindReleased();
1441 break; 1440 break;
1442 case Key_Right: 1441 case Key_Right:
1443 qDebug("Right"); 1442 odebug << "Right" << oendl;
1444 FastforwardReleased(); 1443 FastforwardReleased();
1445 break; 1444 break;
1446 } 1445 }
1447} 1446}
1448 1447
1449void QtRec::endRecording() { 1448void QtRec::endRecording() {
1450 monitoring = false; 1449 monitoring = false;
1451 recording = false; 1450 recording = false;
1452 stopped = true; 1451 stopped = true;
1453 waveform->reset(); 1452 waveform->reset();
1454 setRecordButton( false); 1453 setRecordButton( false);
1455 1454
1456 toBeginningButton->setEnabled( true); 1455 toBeginningButton->setEnabled( true);
1457 toEndButton->setEnabled( true); 1456 toEndButton->setEnabled( true);
1458 1457
1459 killTimers(); 1458 killTimers();
1460 1459
1461 if(autoMute) 1460 if(autoMute)
1462 doMute( true); 1461 doMute( true);
1463 1462
1464 soundDevice->closeDevice( true); 1463 soundDevice->closeDevice( true);
1465 1464
1466 if( wavFile->track.isOpen()) { 1465 if( wavFile->track.isOpen()) {
1467 wavFile->adjustHeaders( filePara.fd, filePara.numberSamples); 1466 wavFile->adjustHeaders( filePara.fd, filePara.numberSamples);
1468 // soundDevice->sd=-1; 1467 // soundDevice->sd=-1;
1469 filePara.numberSamples = 0; 1468 filePara.numberSamples = 0;
1470 // filePara.sd=-1; 1469 // filePara.sd=-1;
1471 wavFile->closeFile(); 1470 wavFile->closeFile();
1472 filePara.fd=0; 1471 filePara.fd=0;
1473 1472
1474 if( wavFile->isTempFile()) { 1473 if( wavFile->isTempFile()) {
1475// move tmp file to regular file 1474// move tmp file to regular file
1476 QString cmd; 1475 QString cmd;
1477 cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName); 1476 cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName);
1478// qDebug("moving tmp file to "+currentFileName); 1477// odebug << "moving tmp file to "+currentFileName << oendl;
1479 system( cmd.latin1()); 1478 system( cmd.latin1());
1480 } 1479 }
1481 1480
1482 qDebug("Just moved " + wavFile->currentFileName); 1481 odebug << "Just moved " + wavFile->currentFileName << oendl;
1483 Config cfg("OpieRec"); 1482 Config cfg("OpieRec");
1484 cfg.setGroup("Sounds"); 1483 cfg.setGroup("Sounds");
1485 1484
1486 int nFiles = cfg.readNumEntry( "NumberofFiles",0); 1485 int nFiles = cfg.readNumEntry( "NumberofFiles",0);
1487 1486
1488 currentFile = QFileInfo( wavFile->currentFileName).fileName(); 1487 currentFile = QFileInfo( wavFile->currentFileName).fileName();
1489 currentFile = currentFile.left( currentFile.length() - 4); 1488 currentFile = currentFile.left( currentFile.length() - 4);
1490 1489
1491 cfg.writeEntry( "NumberofFiles", nFiles + 1); 1490 cfg.writeEntry( "NumberofFiles", nFiles + 1);
1492 cfg.writeEntry( QString::number( nFiles + 1), currentFile); 1491 cfg.writeEntry( QString::number( nFiles + 1), currentFile);
1493 cfg.writeEntry( currentFile, wavFile->currentFileName); 1492 cfg.writeEntry( currentFile, wavFile->currentFileName);
1494 1493
1495 QString time; 1494 QString time;
1496 time.sprintf("%.2f", filePara.numberOfRecordedSeconds); 1495 time.sprintf("%.2f", filePara.numberOfRecordedSeconds);
1497 cfg.writeEntry( wavFile->currentFileName, time ); 1496 cfg.writeEntry( wavFile->currentFileName, time );
1498// qDebug("writing config numberOfRecordedSeconds "+time); 1497// odebug << "writing config numberOfRecordedSeconds "+time << oendl;
1499 1498
1500 cfg.write(); 1499 cfg.write();
1501 qDebug("finished recording"); 1500 odebug << "finished recording" << oendl;
1502 timeLabel->setText(""); 1501 timeLabel->setText("");
1503 } 1502 }
1504 1503
1505 if(soundDevice) delete soundDevice; 1504 if(soundDevice) delete soundDevice;
1506 1505
1507 timeSlider->setValue(0); 1506 timeSlider->setValue(0);
1508 initIconView(); 1507 initIconView();
1509 selectItemByName( currentFile); 1508 selectItemByName( currentFile);
1510} 1509}
1511 1510
1512void QtRec::endPlaying() { 1511void QtRec::endPlaying() {
1513 monitoring = false; 1512 monitoring = false;
1514 recording = false; 1513 recording = false;
1515 playing = false; 1514 playing = false;
1516 stopped = true; 1515 stopped = true;
1517 waveform->reset(); 1516 waveform->reset();
1518// errorStop(); 1517// errorStop();
1519// qDebug("end playing"); 1518// odebug << "end playing" << oendl;
1520 setRecordButton( false); 1519 setRecordButton( false);
1521 1520
1522 toBeginningButton->setEnabled( true); 1521 toBeginningButton->setEnabled( true);
1523 toEndButton->setEnabled( true); 1522 toEndButton->setEnabled( true);
1524 1523
1525 if(autoMute) 1524 if(autoMute)
1526 doMute( true); 1525 doMute( true);
1527 1526
1528 soundDevice->closeDevice( false); 1527 soundDevice->closeDevice( false);
1529 soundDevice->sd = -1; 1528 soundDevice->sd = -1;
1530 // if(soundDevice) delete soundDevice; 1529 // if(soundDevice) delete soundDevice;
1531// qDebug("file and sound device closed"); 1530// odebug << "file and sound device closed" << oendl;
1532 timeLabel->setText(""); 1531 timeLabel->setText("");
1533 total = 0; 1532 total = 0;
1534 filePara.numberSamples = 0; 1533 filePara.numberSamples = 0;
1535 filePara.sd = -1; 1534 filePara.sd = -1;
1536// wavFile->closeFile(); 1535// wavFile->closeFile();
1537 filePara.fd = 0; 1536 filePara.fd = 0;
1538// if(wavFile) delete wavFile; //this crashes 1537// if(wavFile) delete wavFile; //this crashes
1539 1538
1540// qDebug("track closed"); 1539// odebug << "track closed" << oendl;
1541 killTimers(); 1540 killTimers();
1542 qWarning("reset slider"); 1541 owarn << "reset slider" << oendl;
1543 timeSlider->setValue(0); 1542 timeSlider->setValue(0);
1544 1543
1545 if(soundDevice) delete soundDevice; 1544 if(soundDevice) delete soundDevice;
1546 1545
1547} 1546}
1548 1547
1549bool QtRec::openPlayFile() { 1548bool QtRec::openPlayFile() {
1550 1549
1551 qApp->processEvents(); 1550 qApp->processEvents();
1552 if( currentFile.isEmpty()) { 1551 if( currentFile.isEmpty()) {
1553 QMessageBox::message(tr("Opierec"),tr("Please select file to play")); 1552 QMessageBox::message(tr("Opierec"),tr("Please select file to play"));
1554 endPlaying(); 1553 endPlaying();
1555 return false; 1554 return false;
1556 } 1555 }
1557 QString currentFileName; 1556 QString currentFileName;
1558 Config cfg("OpieRec"); 1557 Config cfg("OpieRec");
1559 cfg.setGroup("Sounds"); 1558 cfg.setGroup("Sounds");
1560 int nFiles = cfg.readNumEntry( "NumberofFiles", 0); 1559 int nFiles = cfg.readNumEntry( "NumberofFiles", 0);
1561 for(int i=0;i<nFiles+1;i++) { //look for file 1560 for(int i=0;i<nFiles+1;i++) { //look for file
1562 if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) { 1561 if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) {
1563 currentFileName = cfg.readEntry( currentFile, "" ); 1562 currentFileName = cfg.readEntry( currentFile, "" );
1564 qDebug("opening for play: " + currentFileName); 1563 odebug << "opening for play: " + currentFileName << oendl;
1565 } 1564 }
1566 } 1565 }
1567 wavFile = new WavFile(this, 1566 wavFile = new WavFile(this,
1568 currentFileName, 1567 currentFileName,
1569 false); 1568 false);
1570 filePara.fd = wavFile->wavHandle(); 1569 filePara.fd = wavFile->wavHandle();
1571 if(filePara.fd == -1) { 1570 if(filePara.fd == -1) {
1572 // if(!track.open(IO_ReadOnly)) { 1571 // if(!track.open(IO_ReadOnly)) {
1573 QString errorMsg = (QString)strerror(errno); 1572 QString errorMsg = (QString)strerror(errno);
1574 monitoring = false; 1573 monitoring = false;
1575 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); 1574 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) );
1576 QMessageBox::message(tr("Note"), tr("Could not open audio file.\n") 1575 QMessageBox::message(tr("Note"), tr("Could not open audio file.\n")
1577 + errorMsg + "\n" + currentFile); 1576 + errorMsg + "\n" + currentFile);
1578 return false; 1577 return false;
1579 } else { 1578 } else {
1580 1579
1581 filePara.numberSamples = wavFile->getNumberSamples(); 1580 filePara.numberSamples = wavFile->getNumberSamples();
1582 filePara.format = wavFile->getFormat(); 1581 filePara.format = wavFile->getFormat();
1583 filePara.sampleRate = wavFile->getSampleRate(); 1582 filePara.sampleRate = wavFile->getSampleRate();
1584 filePara.resolution = wavFile->getResolution(); 1583 filePara.resolution = wavFile->getResolution();
1585 filePara.channels = wavFile->getChannels(); 1584 filePara.channels = wavFile->getChannels();
1586 timeSlider->setPageStep(1); 1585 timeSlider->setPageStep(1);
1587 monitoring = true; 1586 monitoring = true;
1588 1587
1589 qDebug("file %d, samples %d %d", filePara.fd, filePara.numberSamples, filePara.sampleRate); 1588 odebug << "file " << filePara.fd << ", samples " << filePara.numberSamples << " " << filePara.sampleRate << "" << oendl;
1590 int sec = (int) (( filePara.numberSamples / filePara.sampleRate) / filePara.channels) / ( filePara.channels*( filePara.resolution/8)); 1589 int sec = (int) (( filePara.numberSamples / filePara.sampleRate) / filePara.channels) / ( filePara.channels*( filePara.resolution/8));
1591 1590
1592 qWarning("seconds %d", sec); 1591 owarn << "seconds " << sec << "" << oendl;
1593 1592
1594 timeSlider->setRange(0, filePara.numberSamples ); 1593 timeSlider->setRange(0, filePara.numberSamples );
1595 } 1594 }
1596 1595
1597 return true; 1596 return true;
1598} 1597}
1599 1598
1600void QtRec::listPressed( int mouse, QListViewItem *item, const QPoint &, int ) { 1599void QtRec::listPressed( int mouse, QListViewItem *item, const QPoint &, int ) {
1601 if(item == NULL ) 1600 if(item == NULL )
1602 return; 1601 return;
1603 switch (mouse) { 1602 switch (mouse) {
1604 case 1: { 1603 case 1: {
1605 if( renameBox != 0 ) //tricky 1604 if( renameBox != 0 ) //tricky
1606 cancelRename(); 1605 cancelRename();
1607 1606
1608 currentFile = item->text(0); 1607 currentFile = item->text(0);
1609 setCaption( "OpieRecord " + currentFile); 1608 setCaption( "OpieRecord " + currentFile);
1610 } 1609 }
1611 break; 1610 break;
1612 case 2: 1611 case 2:
1613 showListMenu(item); 1612 showListMenu(item);
1614 ListView1->clearSelection(); 1613 ListView1->clearSelection();
1615 break; 1614 break;
1616 }; 1615 };
@@ -1669,61 +1668,61 @@ void QtRec::doMenuPlay() {
1669 1668
1670void QtRec::doRename() { 1669void QtRec::doRename() {
1671 QRect r = ListView1->itemRect( ListView1->currentItem( )); 1670 QRect r = ListView1->itemRect( ListView1->currentItem( ));
1672 r = QRect( ListView1->viewportToContents( r.topLeft() ), r.size() ); 1671 r = QRect( ListView1->viewportToContents( r.topLeft() ), r.size() );
1673 r.setX( ListView1->contentsX() ); 1672 r.setX( ListView1->contentsX() );
1674 if ( r.width() > ListView1->visibleWidth() ) 1673 if ( r.width() > ListView1->visibleWidth() )
1675 r.setWidth( ListView1->visibleWidth() ); 1674 r.setWidth( ListView1->visibleWidth() );
1676 1675
1677 renameBox = new QLineEdit( ListView1->viewport(), "qt_renamebox" ); 1676 renameBox = new QLineEdit( ListView1->viewport(), "qt_renamebox" );
1678 renameBox->setFrame(true); 1677 renameBox->setFrame(true);
1679 1678
1680 renameBox->setText( ListView1->currentItem()->text(0) ); 1679 renameBox->setText( ListView1->currentItem()->text(0) );
1681 1680
1682 renameBox->selectAll(); 1681 renameBox->selectAll();
1683 renameBox->installEventFilter( this ); 1682 renameBox->installEventFilter( this );
1684 ListView1->addChild( renameBox, r.x(), r.y() ); 1683 ListView1->addChild( renameBox, r.x(), r.y() );
1685 renameBox->resize( r.size() ); 1684 renameBox->resize( r.size() );
1686 ListView1->viewport()->setFocusProxy( renameBox ); 1685 ListView1->viewport()->setFocusProxy( renameBox );
1687 renameBox->setFocus(); 1686 renameBox->setFocus();
1688 renameBox->show(); 1687 renameBox->show();
1689 1688
1690} 1689}
1691 1690
1692void QtRec::okRename() { 1691void QtRec::okRename() {
1693 qDebug(renameBox->text()); 1692 odebug << renameBox->text() << oendl;
1694 QString filename = renameBox->text(); 1693 QString filename = renameBox->text();
1695 cancelRename(); 1694 cancelRename();
1696 1695
1697 if( ListView1->currentItem() == NULL) 1696 if( ListView1->currentItem() == NULL)
1698 return; 1697 return;
1699 1698
1700 Config cfg("OpieRec"); 1699 Config cfg("OpieRec");
1701 cfg.setGroup("Sounds"); 1700 cfg.setGroup("Sounds");
1702 1701
1703 QString file = ListView1->currentItem()->text(0); 1702 QString file = ListView1->currentItem()->text(0);
1704 1703
1705 qDebug("filename is " + filename); 1704 odebug << "filename is " + filename << oendl;
1706 1705
1707 int nFiles = cfg.readNumEntry("NumberofFiles",0); 1706 int nFiles = cfg.readNumEntry("NumberofFiles",0);
1708 1707
1709 for(int i=0;i<nFiles+1;i++) { //look for file 1708 for(int i=0;i<nFiles+1;i++) { //look for file
1710 if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) { 1709 if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) {
1711 1710
1712 QString filePath = cfg.readEntry(file,""); 1711 QString filePath = cfg.readEntry(file,"");
1713 1712
1714 cfg.writeEntry( QString::number(i), filename ); 1713 cfg.writeEntry( QString::number(i), filename );
1715 cfg.writeEntry( filename, filePath ); 1714 cfg.writeEntry( filename, filePath );
1716 cfg.removeEntry( file); 1715 cfg.removeEntry( file);
1717 cfg.write(); 1716 cfg.write();
1718 } 1717 }
1719 } 1718 }
1720 1719
1721 ListView1->takeItem( ListView1->currentItem() ); 1720 ListView1->takeItem( ListView1->currentItem() );
1722 delete ListView1->currentItem(); 1721 delete ListView1->currentItem();
1723 ListView1->clear(); 1722 ListView1->clear();
1724 initIconView(); 1723 initIconView();
1725 update(); 1724 update();
1726} 1725}
1727 1726
1728void QtRec::cancelRename() { 1727void QtRec::cancelRename() {
1729 bool resetFocus = ListView1->viewport()->focusProxy() == renameBox; 1728 bool resetFocus = ListView1->viewport()->focusProxy() == renameBox;
@@ -1752,49 +1751,49 @@ bool QtRec::eventFilter( QObject * o, QEvent * e ) {
1752 return true; 1751 return true;
1753 } 1752 }
1754 } 1753 }
1755 return QWidget::eventFilter( o, e ); 1754 return QWidget::eventFilter( o, e );
1756} 1755}
1757 1756
1758 1757
1759int QtRec::getCurrentSizeLimit() { 1758int QtRec::getCurrentSizeLimit() {
1760 return sizeLimitCombo->currentItem() * 5; 1759 return sizeLimitCombo->currentItem() * 5;
1761} 1760}
1762 1761
1763void QtRec::timerBreak() { 1762void QtRec::timerBreak() {
1764 endPlaying(); 1763 endPlaying();
1765} 1764}
1766 1765
1767void QtRec::doVolMuting(bool b) { 1766void QtRec::doVolMuting(bool b) {
1768 Config cfg( "qpe" ); 1767 Config cfg( "qpe" );
1769 cfg. setGroup( "Volume" ); 1768 cfg. setGroup( "Volume" );
1770 cfg.writeEntry( "Mute",b); 1769 cfg.writeEntry( "Mute",b);
1771 cfg.write(); 1770 cfg.write();
1772 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b; 1771 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b;
1773} 1772}
1774 1773
1775void QtRec::doMicMuting(bool b) { 1774void QtRec::doMicMuting(bool b) {
1776 // qDebug("mic mute"); 1775 // odebug << "mic mute" << oendl;
1777 Config cfg( "qpe" ); 1776 Config cfg( "qpe" );
1778 cfg. setGroup( "Volume" ); 1777 cfg. setGroup( "Volume" );
1779 cfg.writeEntry( "MicMute",b); 1778 cfg.writeEntry( "MicMute",b);
1780 cfg.write(); 1779 cfg.write();
1781 QCopEnvelope( "QPE/System", "micChange(bool)" ) << b; 1780 QCopEnvelope( "QPE/System", "micChange(bool)" ) << b;
1782} 1781}
1783 1782
1784void QtRec::compressionSelected(bool b) { 1783void QtRec::compressionSelected(bool b) {
1785 Config cfg("OpieRec"); 1784 Config cfg("OpieRec");
1786 cfg.setGroup("Settings"); 1785 cfg.setGroup("Settings");
1787 cfg.writeEntry("wavCompression", b); 1786 cfg.writeEntry("wavCompression", b);
1788 cfg.writeEntry("bitrate", 16); 1787 cfg.writeEntry("bitrate", 16);
1789 filePara.resolution = 16; 1788 filePara.resolution = 16;
1790 cfg.write(); 1789 cfg.write();
1791 1790
1792 if(b) { 1791 if(b) {
1793 bitRateComboBox->setEnabled( false); 1792 bitRateComboBox->setEnabled( false);
1794 bitRateComboBox->setCurrentItem( 0); 1793 bitRateComboBox->setCurrentItem( 0);
1795 filePara.resolution = 16; 1794 filePara.resolution = 16;
1796 } else{ 1795 } else{
1797 bitRateComboBox->setEnabled( true); 1796 bitRateComboBox->setEnabled( true);
1798 } 1797 }
1799} 1798}
1800 1799
@@ -1808,158 +1807,158 @@ long QtRec::checkDiskSpace(const QString &path) {
1808 int availBlks = fs.f_bavail; 1807 int availBlks = fs.f_bavail;
1809 1808
1810 long mult = blkSize / 1024; 1809 long mult = blkSize / 1024;
1811 long div = 1024 / blkSize; 1810 long div = 1024 / blkSize;
1812 1811
1813 if ( !mult ) mult = 1; 1812 if ( !mult ) mult = 1;
1814 if ( !div ) div = 1; 1813 if ( !div ) div = 1;
1815 1814
1816 return availBlks * mult / div; 1815 return availBlks * mult / div;
1817 } 1816 }
1818 return -1; 1817 return -1;
1819} 1818}
1820 1819
1821// short f_fstyp; /* File system type */ 1820// short f_fstyp; /* File system type */
1822// long f_bsize; /* Block size */ 1821// long f_bsize; /* Block size */
1823// long f_frsize; /* Fragment size */ 1822// long f_frsize; /* Fragment size */
1824// long f_blocks; /* Total number of blocks*/ 1823// long f_blocks; /* Total number of blocks*/
1825// long f_bfree; /* Count of free blocks */ 1824// long f_bfree; /* Count of free blocks */
1826// long f_files; /* Total number of file nodes */ 1825// long f_files; /* Total number of file nodes */
1827// long f_ffree; /* Count of free file nodes */ 1826// long f_ffree; /* Count of free file nodes */
1828// char f_fname[6]; /* Volumename */ 1827// char f_fname[6]; /* Volumename */
1829// char f_fpack[6]; /* Pack name */ 1828// char f_fpack[6]; /* Pack name */
1830 1829
1831void QtRec::receive( const QCString &msg, const QByteArray & ) { 1830void QtRec::receive( const QCString &msg, const QByteArray & ) {
1832 qDebug("Voicerecord received message "+msg); 1831 odebug << "Voicerecord received message "+msg << oendl;
1833 1832
1834} 1833}
1835 1834
1836 1835
1837///////////////////////////// timerEvent 1836///////////////////////////// timerEvent
1838void QtRec::timerEvent( QTimerEvent * ) { 1837void QtRec::timerEvent( QTimerEvent * ) {
1839 1838
1840// if(!recording) 1839// if(!recording)
1841// timeSlider->setValue( secCount); 1840// timeSlider->setValue( secCount);
1842// else 1841// else
1843// timeSlider->setValue( filePara.numberOfRecordedSeconds); 1842// timeSlider->setValue( filePara.numberOfRecordedSeconds);
1844 1843
1845 if( stopped && playing) { 1844 if( stopped && playing) {
1846 stop(); 1845 stop();
1847 } 1846 }
1848 1847
1849 if( stopped && recording ){ 1848 if( stopped && recording ){
1850 stop(); 1849 stop();
1851 } 1850 }
1852 1851
1853 if( recording && filePara.SecondsToRecord < secCount && filePara.SecondsToRecord != 0) { 1852 if( recording && filePara.SecondsToRecord < secCount && filePara.SecondsToRecord != 0) {
1854 stop(); 1853 stop();
1855 } 1854 }
1856 1855
1857 qDebug( "%d", secCount ); 1856 odebug << "" << secCount << "" << oendl;
1858 QString timeString; 1857 QString timeString;
1859#ifdef DEV_VERSION 1858#ifdef DEV_VERSION
1860 QString msg; 1859 QString msg;
1861 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); 1860 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution);
1862 setCaption( msg +" :: "+QString::number(secCount)); 1861 setCaption( msg +" :: "+QString::number(secCount));
1863#endif 1862#endif
1864 1863
1865 timeString.sprintf("%d", secCount); 1864 timeString.sprintf("%d", secCount);
1866 timeLabel->setText( timeString + " seconds"); 1865 timeLabel->setText( timeString + " seconds");
1867 1866
1868 secCount++; 1867 secCount++;
1869} 1868}
1870 1869
1871void QtRec::changeTimeSlider(int index) { 1870void QtRec::changeTimeSlider(int index) {
1872 if( ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return; 1871 if( ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return;
1873 // qDebug("Slider moved to %d",index); 1872 // odebug << "Slider moved to " << index << "" << oendl;
1874 paused = true; 1873 paused = true;
1875 stopped = true; 1874 stopped = true;
1876 1875
1877 sliderPos=index; 1876 sliderPos=index;
1878 1877
1879 QString timeString; 1878 QString timeString;
1880 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; 1879 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2;
1881 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); 1880 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds);
1882 secCount = (int)filePara.numberOfRecordedSeconds; 1881 secCount = (int)filePara.numberOfRecordedSeconds;
1883 timeLabel->setText( timeString + tr(" seconds")); 1882 timeLabel->setText( timeString + tr(" seconds"));
1884} 1883}
1885 1884
1886void QtRec::timeSliderPressed() { 1885void QtRec::timeSliderPressed() {
1887 if( ListView1->currentItem() == 0) return; 1886 if( ListView1->currentItem() == 0) return;
1888 // qDebug("slider pressed"); 1887 // odebug << "slider pressed" << oendl;
1889 paused = true; 1888 paused = true;
1890 stopped = true; 1889 stopped = true;
1891} 1890}
1892 1891
1893void QtRec::timeSliderReleased() { 1892void QtRec::timeSliderReleased() {
1894 if( ListView1->currentItem() == 0) return; 1893 if( ListView1->currentItem() == 0) return;
1895 sliderPos = timeSlider->value(); 1894 sliderPos = timeSlider->value();
1896 1895
1897 // qDebug("slider released %d", sliderPos); 1896 // odebug << "slider released " << sliderPos << "" << oendl;
1898 stopped = false; 1897 stopped = false;
1899 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); 1898 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
1900 total = newPos*4; 1899 total = newPos*4;
1901 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; 1900 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2;
1902 1901
1903 doPlay(); 1902 doPlay();
1904} 1903}
1905 1904
1906void QtRec::rewindPressed() { 1905void QtRec::rewindPressed() {
1907 if( ListView1->currentItem() == 0) return; 1906 if( ListView1->currentItem() == 0) return;
1908 if( !wavFile->track.isOpen()) { 1907 if( !wavFile->track.isOpen()) {
1909 if( !openPlayFile() ) 1908 if( !openPlayFile() )
1910 return; 1909 return;
1911 else 1910 else
1912 if( !setupAudio( false)) 1911 if( !setupAudio( false))
1913 return; 1912 return;
1914 } else { 1913 } else {
1915 killTimers(); 1914 killTimers();
1916 paused = true; 1915 paused = true;
1917 stopped = true; 1916 stopped = true;
1918 rewindTimer->start( 50, false); 1917 rewindTimer->start( 50, false);
1919 } 1918 }
1920} 1919}
1921 1920
1922void QtRec::rewindTimerTimeout() { 1921void QtRec::rewindTimerTimeout() {
1923 int sliderValue = timeSlider->value(); 1922 int sliderValue = timeSlider->value();
1924 sliderValue = sliderValue - ( filePara.numberSamples / 100); 1923 sliderValue = sliderValue - ( filePara.numberSamples / 100);
1925 // if(toBeginningButton->isDown()) 1924 // if(toBeginningButton->isDown())
1926 timeSlider->setValue( sliderValue ) ; 1925 timeSlider->setValue( sliderValue ) ;
1927 // qDebug("%d", sliderValue); 1926 // odebug << "" << sliderValue << "" << oendl;
1928 QString timeString; 1927 QString timeString;
1929 filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2; 1928 filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2;
1930 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); 1929 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds);
1931 timeLabel->setText( timeString+ tr(" seconds")); 1930 timeLabel->setText( timeString+ tr(" seconds"));
1932} 1931}
1933 1932
1934void QtRec::rewindReleased() { 1933void QtRec::rewindReleased() {
1935 rewindTimer->stop(); 1934 rewindTimer->stop();
1936 if( wavFile->track.isOpen()) { 1935 if( wavFile->track.isOpen()) {
1937 sliderPos=timeSlider->value(); 1936 sliderPos=timeSlider->value();
1938 stopped = false; 1937 stopped = false;
1939 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); 1938 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
1940 total = newPos * 4; 1939 total = newPos * 4;
1941 // qDebug("rewind released %d", total); 1940 // odebug << "rewind released " << total << "" << oendl;
1942 startTimer( 1000); 1941 startTimer( 1000);
1943 doPlay(); 1942 doPlay();
1944 } 1943 }
1945} 1944}
1946 1945
1947void QtRec::FastforwardPressed() { 1946void QtRec::FastforwardPressed() {
1948 if( ListView1->currentItem() == 0) return; 1947 if( ListView1->currentItem() == 0) return;
1949 if( !wavFile->track.isOpen()) 1948 if( !wavFile->track.isOpen())
1950 if( !openPlayFile() ) 1949 if( !openPlayFile() )
1951 return; 1950 return;
1952 else 1951 else
1953 if( !setupAudio( false)) 1952 if( !setupAudio( false))
1954 return; 1953 return;
1955 killTimers(); 1954 killTimers();
1956 1955
1957 paused = true; 1956 paused = true;
1958 stopped = true; 1957 stopped = true;
1959 forwardTimer->start(50, false); 1958 forwardTimer->start(50, false);
1960} 1959}
1961 1960
1962 1961
1963void QtRec::forwardTimerTimeout() { 1962void QtRec::forwardTimerTimeout() {
1964 int sliderValue = timeSlider->value(); 1963 int sliderValue = timeSlider->value();
1965 sliderValue = sliderValue + ( filePara.numberSamples / 100); 1964 sliderValue = sliderValue + ( filePara.numberSamples / 100);
@@ -1981,49 +1980,49 @@ void QtRec::FastforwardReleased() {
1981 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); 1980 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
1982 total = newPos * 4; 1981 total = newPos * 4;
1983 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; 1982 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2;
1984 startTimer( 1000); 1983 startTimer( 1000);
1985 doPlay(); 1984 doPlay();
1986 } 1985 }
1987} 1986}
1988 1987
1989 1988
1990QString QtRec::getStorage(const QString &fileName) { 1989QString QtRec::getStorage(const QString &fileName) {
1991 1990
1992 StorageInfo storageInfo; 1991 StorageInfo storageInfo;
1993 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1992 const QList<FileSystem> &fs = storageInfo.fileSystems();
1994 QListIterator<FileSystem> it ( fs ); 1993 QListIterator<FileSystem> it ( fs );
1995 QString storage; 1994 QString storage;
1996 for( ; it.current(); ++it ){ 1995 for( ; it.current(); ++it ){
1997 const QString name = ( *it)->name(); 1996 const QString name = ( *it)->name();
1998 const QString path = ( *it)->path(); 1997 const QString path = ( *it)->path();
1999 const QString disk = ( *it)->disk(); 1998 const QString disk = ( *it)->disk();
2000 if( fileName.find( path,0,true) != -1) 1999 if( fileName.find( path,0,true) != -1)
2001 storage = name; 2000 storage = name;
2002 // const QString options = (*it)->options(); 2001 // const QString options = (*it)->options();
2003 // if( name.find( tr("Internal"),0,true) == -1) { 2002 // if( name.find( tr("Internal"),0,true) == -1) {
2004 // storageComboBox->insertItem( name +" -> "+disk); 2003 // storageComboBox->insertItem( name +" -> "+disk);
2005 // qDebug(name); 2004 // odebug << name << oendl;
2006 } 2005 }
2007 return storage; 2006 return storage;
2008 // struct mntent *me; 2007 // struct mntent *me;
2009 // // if(fileName == "/etc/mtab") { 2008 // // if(fileName == "/etc/mtab") {
2010 // FILE *mntfp = setmntent( fileName.latin1(), "r" ); 2009 // FILE *mntfp = setmntent( fileName.latin1(), "r" );
2011 // if ( mntfp ) { 2010 // if ( mntfp ) {
2012 // while ( (me = getmntent( mntfp )) != 0 ) { 2011 // while ( (me = getmntent( mntfp )) != 0 ) {
2013 // QString filesystemType = me->mnt_type; 2012 // QString filesystemType = me->mnt_type;
2014 2013
2015 // } 2014 // }
2016 // } 2015 // }
2017 // endmntent( mntfp ); 2016 // endmntent( mntfp );
2018} 2017}
2019 2018
2020void QtRec::setRecordButton(bool b) { 2019void QtRec::setRecordButton(bool b) {
2021 2020
2022 if(b) { //about to record or play 2021 if(b) { //about to record or play
2023 2022
2024 Rec_PushButton->setDown( true); 2023 Rec_PushButton->setDown( true);
2025 QPixmap image3( ( const char** ) image3_data ); 2024 QPixmap image3( ( const char** ) image3_data );
2026 Stop_PushButton->setPixmap( image3 ); 2025 Stop_PushButton->setPixmap( image3 );
2027 if(Stop_PushButton->isDown()) 2026 if(Stop_PushButton->isDown())
2028 Stop_PushButton->setDown( true); 2027 Stop_PushButton->setDown( true);
2029 playLabel2->setText( tr("Stop") ); 2028 playLabel2->setText( tr("Stop") );