summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opierec
Unidiff
Diffstat (limited to 'noncore/multimedia/opierec') (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opierec/opierec.pro5
-rw-r--r--noncore/multimedia/opierec/qtrec.cpp143
-rw-r--r--noncore/multimedia/opierec/qtrec.h2
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,4 +1,4 @@
1#CONFIG = qt qtopia warn_on release pdaudio 1CONFIG = qt qtopia warn_on release pdaudio
2CONFIG = 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
4HEADERS = adpcm.h \ 4HEADERS = adpcm.h \
@@ -24,4 +24,5 @@ contains(CONFIG, pdaudio) {
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
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
@@ -4,5 +4,4 @@
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
@@ -117,9 +116,11 @@ Waveform* waveform;
117Device *soundDevice; 116Device *soundDevice;
118 117
119// threaded recording 118
120//fuckin fulgy here 119#ifdef THREADED
121//void quickRec() 120void quickRec()
122//{ 121#else
123void QtRec::quickRec() { 122 void QtRec::quickRec()
123#endif
124{
124 125
125 qDebug("%d", 126 qDebug("%d",
@@ -158,5 +159,5 @@ void QtRec::quickRec() {
158 for(;;) { 159 for(;;) {
159 if ( stopped) { 160 if ( stopped) {
160 qDebug("quickRec:: stopped"); 161 // qDebug("quickRec:: stopped");
161 break; 162 break;
162 } 163 }
@@ -234,5 +235,4 @@ void QtRec::quickRec() {
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
@@ -244,5 +244,6 @@ void QtRec::quickRec() {
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);
@@ -283,9 +284,13 @@ void QtRec::quickRec() {
283} /// END quickRec() 284} /// END quickRec()
284 285
285void QtRec::playIt()
286 286
287//void playIt() 287#ifdef THREADED
288void 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) {
@@ -323,6 +328,6 @@ void QtRec::playIt()
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();
@@ -409,11 +414,10 @@ void QtRec::playIt()
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
419QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) 423QtRec::QtRec( QWidget* parent, const char* name, WFlags fl )
@@ -428,5 +432,12 @@ QtRec::QtRec( QWidget* parent, const char* name, WFlags fl )
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);
@@ -641,10 +652,4 @@ void QtRec::init() {
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
@@ -697,50 +702,4 @@ void QtRec::init() {
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" );
@@ -761,5 +720,5 @@ void QtRec::initIconView() {
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++) {
@@ -1009,14 +968,18 @@ bool QtRec::rec() { //record
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
@@ -1071,10 +1034,11 @@ 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;
@@ -1091,5 +1055,4 @@ bool QtRec::setupAudio( bool b) {
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() ) {
@@ -1104,6 +1067,8 @@ bool QtRec::setupAudio( bool b) {
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
@@ -1139,6 +1104,8 @@ bool QtRec::setupAudio( bool b) {
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 }
@@ -1221,5 +1188,5 @@ bool QtRec::doPlay() {
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
@@ -1234,11 +1201,14 @@ bool QtRec::doPlay() {
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}
@@ -1867,5 +1837,5 @@ void QtRec::receive( const QCString &msg, const QByteArray & ) {
1867 1837
1868///////////////////////////// timerEvent 1838///////////////////////////// timerEvent
1869void QtRec::timerEvent( QTimerEvent *e ) { 1839void QtRec::timerEvent( QTimerEvent * ) {
1870 1840
1871// if(!recording) 1841// if(!recording)
@@ -2161,2 +2131,3 @@ void QtRec::changeStereoCheck(bool b) {
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
@@ -178,6 +178,8 @@ protected:
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};