-rw-r--r-- | noncore/multimedia/opierec/opierec.pro | 5 | ||||
-rw-r--r-- | noncore/multimedia/opierec/qtrec.cpp | 143 | ||||
-rw-r--r-- | noncore/multimedia/opierec/qtrec.h | 2 |
3 files changed, 62 insertions, 88 deletions
diff --git a/noncore/multimedia/opierec/opierec.pro b/noncore/multimedia/opierec/opierec.pro index 39fe493..5651151 100644 --- a/noncore/multimedia/opierec/opierec.pro +++ b/noncore/multimedia/opierec/opierec.pro | |||
@@ -1,5 +1,5 @@ | |||
1 | #CONFIG = qt qtopia warn_on release pdaudio | 1 | CONFIG = qt qtopia warn_on release pdaudio |
2 | CONFIG = qt warn_on release opie | 2 | #CONFIG = qt warn_on release opie |
3 | #CONFIG = qt warn_on release quick-app | 3 | #CONFIG = qt warn_on release quick-app |
4 | HEADERS = adpcm.h \ | 4 | HEADERS = adpcm.h \ |
5 | pixmaps.h \ | 5 | pixmaps.h \ |
@@ -23,6 +23,7 @@ contains(CONFIG, pdaudio) { | |||
23 | INCLUDEPATH += $(QPEDIR)/include | 23 | INCLUDEPATH += $(QPEDIR)/include |
24 | DEPENDPATH += $(QPEDIR)/include | 24 | DEPENDPATH += $(QPEDIR)/include |
25 | DEFINES += PDAUDIO | 25 | DEFINES += PDAUDIO |
26 | DEFINES += THREADED | ||
26 | TARGET = qperec | 27 | TARGET = qperec |
27 | 28 | ||
28 | # DESTDIR=$(QPEDIR)/bin | 29 | # DESTDIR=$(QPEDIR)/bin |
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp index bc6abcc..0a6e5ae 100644 --- a/noncore/multimedia/opierec/qtrec.cpp +++ b/noncore/multimedia/opierec/qtrec.cpp | |||
@@ -3,7 +3,6 @@ | |||
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 | |||
7 | #define DEV_VERSION | 6 | #define DEV_VERSION |
8 | 7 | ||
9 | #include "pixmaps.h" | 8 | #include "pixmaps.h" |
@@ -116,11 +115,13 @@ int sd; | |||
116 | Waveform* waveform; | 115 | Waveform* waveform; |
117 | Device *soundDevice; | 116 | Device *soundDevice; |
118 | 117 | ||
119 | // threaded recording | 118 | |
120 | //fuckin fulgy here | 119 | #ifdef THREADED |
121 | //void quickRec() | 120 | void quickRec() |
122 | //{ | 121 | #else |
123 | void QtRec::quickRec() { | 122 | void QtRec::quickRec() |
123 | #endif | ||
124 | { | ||
124 | 125 | ||
125 | qDebug("%d", | 126 | qDebug("%d", |
126 | filePara.numberSamples/filePara.sampleRate * filePara.channels); | 127 | filePara.numberSamples/filePara.sampleRate * filePara.channels); |
@@ -157,7 +158,7 @@ void QtRec::quickRec() { | |||
157 | 158 | ||
158 | for(;;) { | 159 | for(;;) { |
159 | if ( stopped) { | 160 | if ( stopped) { |
160 | qDebug("quickRec:: stopped"); | 161 | // qDebug("quickRec:: stopped"); |
161 | break; | 162 | break; |
162 | } | 163 | } |
163 | 164 | ||
@@ -233,7 +234,6 @@ void QtRec::quickRec() { | |||
233 | // fflush(stdout); | 234 | // fflush(stdout); |
234 | 235 | ||
235 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2/filePara.channels; | 236 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2/filePara.channels; |
236 | |||
237 | qApp->processEvents(); | 237 | qApp->processEvents(); |
238 | 238 | ||
239 | if( total >= filePara.samplesToRecord) { | 239 | if( total >= filePara.samplesToRecord) { |
@@ -243,7 +243,8 @@ void QtRec::quickRec() { | |||
243 | } | 243 | } |
244 | } //end main loop | 244 | } //end main loop |
245 | 245 | ||
246 | } else { // <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8; | 246 | } else { |
247 | // <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8; | ||
247 | unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ]; | 248 | unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ]; |
248 | memset( unsigned_inbuffer, 0, BUFSIZE); | 249 | memset( unsigned_inbuffer, 0, BUFSIZE); |
249 | memset( unsigned_outbuffer, 0, BUFSIZE); | 250 | memset( unsigned_outbuffer, 0, BUFSIZE); |
@@ -282,11 +283,15 @@ void QtRec::quickRec() { | |||
282 | } | 283 | } |
283 | } /// END quickRec() | 284 | } /// END quickRec() |
284 | 285 | ||
285 | void QtRec::playIt() | ||
286 | 286 | ||
287 | //void playIt() | 287 | #ifdef THREADED |
288 | void playIt() | ||
289 | #else | ||
290 | void QtRec::playIt() | ||
291 | #endif | ||
288 | { | 292 | { |
289 | int bytesWritten, number; | 293 | int bytesWritten = 0; |
294 | int number = 0; | ||
290 | int total = 0; // Total number of bytes read in so far. | 295 | int total = 0; // Total number of bytes read in so far. |
291 | if( filePara.resolution == 16 ) { //AFMT_S16_LE) { | 296 | if( filePara.resolution == 16 ) { //AFMT_S16_LE) { |
292 | if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { | 297 | if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { |
@@ -322,8 +327,8 @@ void QtRec::playIt() | |||
322 | // timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); | 327 | // timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); |
323 | // if(filePara.numberOfRecordedSeconds>1) | 328 | // if(filePara.numberOfRecordedSeconds>1) |
324 | // timeLabel->setText( timeString+ tr(" seconds")); | 329 | // timeLabel->setText( timeString+ tr(" seconds")); |
325 | printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4); | 330 | // printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4); |
326 | fflush(stdout); | 331 | // fflush(stdout); |
327 | 332 | ||
328 | qApp->processEvents(); | 333 | qApp->processEvents(); |
329 | 334 | ||
@@ -408,13 +413,12 @@ void QtRec::playIt() | |||
408 | stopped = true; | 413 | stopped = true; |
409 | break; | 414 | break; |
410 | } | 415 | } |
411 | printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples); | 416 | // printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples); |
412 | fflush(stdout); | 417 | // fflush(stdout); |
413 | } | 418 | } |
414 | } | 419 | } |
415 | } | 420 | } |
416 | 421 | ||
417 | /////////////////<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>> | ||
418 | 422 | ||
419 | QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) | 423 | QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) |
420 | : QWidget( parent, name, fl ) | 424 | : QWidget( parent, name, fl ) |
@@ -427,7 +431,14 @@ QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) | |||
427 | renameBox = 0; | 431 | renameBox = 0; |
428 | 432 | ||
429 | // open sound device to get volumes | 433 | // open sound device to get volumes |
430 | soundDevice = new Device( this, DSPSTROUT, DSPSTRMIXEROUT, false); | 434 | Config hwcfg("OpieRec"); |
435 | hwcfg.setGroup("Hardware"); | ||
436 | |||
437 | |||
438 | soundDevice = new Device( this, | ||
439 | hwcfg.readEntry( "Audio",DSPSTROUT), | ||
440 | hwcfg.readEntry( "Mixer",DSPSTRMIXEROUT), false); | ||
441 | // soundDevice = new Device( this, hwcfg.readEntry( "Audio","hw:0"), hwcfg.readEntry( "Mixer","hw:0"), false); | ||
431 | 442 | ||
432 | // soundDevice->setDeviceFormat(AFMT_S16_LE); | 443 | // soundDevice->setDeviceFormat(AFMT_S16_LE); |
433 | // soundDevice->setDeviceChannels(1); | 444 | // soundDevice->setDeviceChannels(1); |
@@ -640,12 +651,6 @@ void QtRec::init() { | |||
640 | glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0); | 651 | glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0); |
641 | glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1); | 652 | glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1); |
642 | 653 | ||
643 | QWidget *d = QApplication::desktop(); | ||
644 | int width = d->width(); | ||
645 | int height = d->height(); | ||
646 | |||
647 | if( width < height) { | ||
648 | |||
649 | tab_5 = new QWidget( TabWidget, "tab_5" ); | 654 | tab_5 = new QWidget( TabWidget, "tab_5" ); |
650 | 655 | ||
651 | QHBoxLayout *Layout19a; | 656 | QHBoxLayout *Layout19a; |
@@ -696,52 +701,6 @@ void QtRec::init() { | |||
696 | 701 | ||
697 | TabWidget->insertTab( tab_5, tr( "Volume" ) ); | 702 | TabWidget->insertTab( tab_5, tr( "Volume" ) ); |
698 | 703 | ||
699 | } else {// landscape | ||
700 | |||
701 | // Layout16->addWidget( dirGroup ); | ||
702 | // Layout18->addLayout( Layout16 ); | ||
703 | Layout15 = new QVBoxLayout(this); | ||
704 | Layout15->setSpacing( 2 ); | ||
705 | Layout15->setMargin( 0 ); | ||
706 | |||
707 | Layout15b = new QVBoxLayout(this); | ||
708 | Layout15b->setSpacing( 2 ); | ||
709 | Layout15b->setMargin( 0 ); | ||
710 | |||
711 | TextLabel2 = new QLabel( tab_3, "InputLabel" ); | ||
712 | TextLabel2->setText( tr( "In")); | ||
713 | TextLabel2->setFixedWidth(35); | ||
714 | Layout15->addWidget( TextLabel2 ); | ||
715 | |||
716 | TextLabel3 = new QLabel( tab_3, "OutputLabel" ); | ||
717 | TextLabel3->setText( tr( "Out" ) ); | ||
718 | Layout15b->addWidget( TextLabel3 ); | ||
719 | |||
720 | InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_3, (const char *) "InputSlider" ); | ||
721 | InputSlider->setTickmarks(QSlider::Both); | ||
722 | Layout15->addWidget( InputSlider); | ||
723 | |||
724 | OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_3,(const char *) "OutputSlider" ); | ||
725 | OutputSlider->setTickmarks(QSlider::Both); | ||
726 | |||
727 | Layout15b->addWidget( OutputSlider ); | ||
728 | |||
729 | outMuteCheckBox = new QCheckBox ( tr("mute"), tab_3 ); | ||
730 | Layout15->addWidget( outMuteCheckBox ); | ||
731 | |||
732 | inMuteCheckBox = new QCheckBox ( tr("mute"), tab_3 ); | ||
733 | inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus ); | ||
734 | Layout15b->addWidget( inMuteCheckBox ); | ||
735 | |||
736 | |||
737 | Layout19->addLayout( Layout15 ); | ||
738 | Layout19->addLayout( Layout15b ); | ||
739 | |||
740 | fillDirectoryCombo(); | ||
741 | |||
742 | TabWidget->insertTab( tab_3, tr( "Options" ) ); | ||
743 | |||
744 | } | ||
745 | 704 | ||
746 | waveform = new Waveform( this, "waveform" ); | 705 | waveform = new Waveform( this, "waveform" ); |
747 | // waveform->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)3, waveform->sizePolicy().hasHeightForWidth() ) ); | 706 | // waveform->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)3, waveform->sizePolicy().hasHeightForWidth() ) ); |
@@ -760,7 +719,7 @@ void QtRec::initIconView() { | |||
760 | QPixmap image0( ( const char** ) image0_data ); | 719 | QPixmap image0( ( const char** ) image0_data ); |
761 | 720 | ||
762 | int nFiles = cfg.readNumEntry("NumberofFiles",0); | 721 | int nFiles = cfg.readNumEntry("NumberofFiles",0); |
763 | qDebug("init number of files %d", nFiles); | 722 | // qDebug("init number of files %d", nFiles); |
764 | 723 | ||
765 | for(int i=1;i<= nFiles;i++) { | 724 | for(int i=1;i<= nFiles;i++) { |
766 | 725 | ||
@@ -1008,16 +967,20 @@ bool QtRec::rec() { //record | |||
1008 | setCaption( msg); | 967 | setCaption( msg); |
1009 | #endif | 968 | #endif |
1010 | filePara.fileName=currentFile.latin1(); | 969 | filePara.fileName=currentFile.latin1(); |
1011 | // qDebug("Start recording thread"); | 970 | qDebug("Start recording thread"); |
1012 | stopped = false; | 971 | stopped = false; |
1013 | 972 | ||
1014 | // pthread_t thread1; | 973 | #ifdef THREADED |
1015 | // pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); | 974 | pthread_t thread1; |
975 | pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); | ||
976 | #endif | ||
1016 | toBeginningButton->setEnabled( false); | 977 | toBeginningButton->setEnabled( false); |
1017 | toEndButton->setEnabled( false); | 978 | toEndButton->setEnabled( false); |
1018 | 979 | ||
1019 | startTimer(1000); | 980 | startTimer(1000); |
981 | #ifndef THREADED | ||
1020 | quickRec(); | 982 | quickRec(); |
983 | #endif | ||
1021 | } | 984 | } |
1022 | } //end setUpFile | 985 | } //end setUpFile |
1023 | } //end setupAudio | 986 | } //end setupAudio |
@@ -1070,12 +1033,13 @@ void QtRec::changedInVolume( ) { | |||
1070 | bool QtRec::setupAudio( bool b) { | 1033 | bool QtRec::setupAudio( bool b) { |
1071 | bool ok; | 1034 | bool ok; |
1072 | int sampleformat, stereo, flags; | 1035 | int sampleformat, stereo, flags; |
1073 | char * dspString, *mixerString; | 1036 | QString dspString, mixerString; |
1074 | 1037 | ||
1075 | filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16 | 1038 | filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16 |
1076 | 1039 | ||
1040 | if( !b) { | ||
1041 | // we want to play | ||
1077 | #ifdef PDAUDIO //ALSA | 1042 | #ifdef PDAUDIO //ALSA |
1078 | if( !b) { // we want to play | ||
1079 | if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { | 1043 | if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { |
1080 | sampleformat = SND_PCM_FORMAT_S16; | 1044 | sampleformat = SND_PCM_FORMAT_S16; |
1081 | filePara.resolution = 16; | 1045 | filePara.resolution = 16; |
@@ -1090,7 +1054,6 @@ bool QtRec::setupAudio( bool b) { | |||
1090 | filePara.resolution = 8; | 1054 | filePara.resolution = 8; |
1091 | } | 1055 | } |
1092 | #else | 1056 | #else |
1093 | if( !b) { | ||
1094 | // we want to play | 1057 | // we want to play |
1095 | if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { | 1058 | if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { |
1096 | sampleformat = AFMT_S16_LE; | 1059 | sampleformat = AFMT_S16_LE; |
@@ -1103,8 +1066,10 @@ bool QtRec::setupAudio( bool b) { | |||
1103 | 1066 | ||
1104 | stereo = filePara.channels; | 1067 | stereo = filePara.channels; |
1105 | flags = O_WRONLY; | 1068 | flags = O_WRONLY; |
1106 | dspString = DSPSTROUT; | 1069 | Config hwcfg("OpieRec"); |
1107 | mixerString = DSPSTRMIXEROUT; | 1070 | hwcfg.setGroup("Hardware"); |
1071 | dspString = hwcfg.readEntry( "Audio", DSPSTROUT); | ||
1072 | mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXEROUT); | ||
1108 | recording = false; | 1073 | recording = false; |
1109 | } else { // we want to record | 1074 | } else { // we want to record |
1110 | 1075 | ||
@@ -1138,8 +1103,10 @@ bool QtRec::setupAudio( bool b) { | |||
1138 | // filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; | 1103 | // filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; |
1139 | flags= O_RDWR; | 1104 | flags= O_RDWR; |
1140 | // flags= O_RDONLY; | 1105 | // flags= O_RDONLY; |
1141 | dspString = DSPSTRIN; | 1106 | Config hwcfg("OpieRec"); |
1142 | mixerString = DSPSTRMIXEROUT; | 1107 | hwcfg.setGroup("Hardware"); |
1108 | dspString = hwcfg.readEntry( "Audio", DSPSTRIN); | ||
1109 | mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXERIN); | ||
1143 | recording = true; | 1110 | recording = true; |
1144 | } | 1111 | } |
1145 | 1112 | ||
@@ -1220,7 +1187,7 @@ bool QtRec::doPlay() { | |||
1220 | 1187 | ||
1221 | // timeSlider->setRange( 0, filePara.numberSamples); | 1188 | // timeSlider->setRange( 0, filePara.numberSamples); |
1222 | 1189 | ||
1223 | timeString.sprintf("%d", filePara.numberOfRecordedSeconds); | 1190 | timeString.sprintf("%f", filePara.numberOfRecordedSeconds); |
1224 | timeLabel->setText( timeString+ tr(" seconds")); | 1191 | timeLabel->setText( timeString+ tr(" seconds")); |
1225 | 1192 | ||
1226 | QString msg; | 1193 | QString msg; |
@@ -1233,13 +1200,16 @@ bool QtRec::doPlay() { | |||
1233 | #endif | 1200 | #endif |
1234 | 1201 | ||
1235 | startTimer( 1000); | 1202 | startTimer( 1000); |
1236 | // pthread_t thread2; | 1203 | #ifdef THREADED |
1237 | // pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/); | 1204 | pthread_t thread2; |
1205 | pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/); | ||
1206 | #endif | ||
1238 | 1207 | ||
1239 | toBeginningButton->setEnabled( false); | 1208 | toBeginningButton->setEnabled( false); |
1240 | toEndButton->setEnabled( false); | 1209 | toEndButton->setEnabled( false); |
1210 | #ifndef THREADED | ||
1241 | playIt(); | 1211 | playIt(); |
1242 | 1212 | #endif | |
1243 | return true; | 1213 | return true; |
1244 | } | 1214 | } |
1245 | 1215 | ||
@@ -1866,7 +1836,7 @@ void QtRec::receive( const QCString &msg, const QByteArray & ) { | |||
1866 | 1836 | ||
1867 | 1837 | ||
1868 | ///////////////////////////// timerEvent | 1838 | ///////////////////////////// timerEvent |
1869 | void QtRec::timerEvent( QTimerEvent *e ) { | 1839 | void QtRec::timerEvent( QTimerEvent * ) { |
1870 | 1840 | ||
1871 | // if(!recording) | 1841 | // if(!recording) |
1872 | // timeSlider->setValue( secCount); | 1842 | // timeSlider->setValue( secCount); |
@@ -2160,3 +2130,4 @@ void QtRec::changeStereoCheck(bool b) { | |||
2160 | cfg.write(); | 2130 | cfg.write(); |
2161 | } | 2131 | } |
2162 | 2132 | ||
2133 | |||
diff --git a/noncore/multimedia/opierec/qtrec.h b/noncore/multimedia/opierec/qtrec.h index 31cff9e..5878d37 100644 --- a/noncore/multimedia/opierec/qtrec.h +++ b/noncore/multimedia/opierec/qtrec.h | |||
@@ -177,8 +177,10 @@ protected: | |||
177 | void keyReleaseEvent( QKeyEvent *e); | 177 | void keyReleaseEvent( QKeyEvent *e); |
178 | void receive( const QCString &, const QByteArray & ); | 178 | void receive( const QCString &, const QByteArray & ); |
179 | void showListMenu(QListViewItem * ); | 179 | void showListMenu(QListViewItem * ); |
180 | #ifndef THREADED | ||
180 | void quickRec(); | 181 | void quickRec(); |
181 | void playIt(); | 182 | void playIt(); |
183 | #endif | ||
182 | 184 | ||
183 | }; | 185 | }; |
184 | 186 | ||