summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (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,5 +1,5 @@
-#CONFIG = qt qtopia warn_on release pdaudio
-CONFIG = qt warn_on release opie
+CONFIG = qt qtopia warn_on release pdaudio
+#CONFIG = qt warn_on release opie
#CONFIG = qt warn_on release quick-app
HEADERS = adpcm.h \
pixmaps.h \
@@ -23,6 +23,7 @@ contains(CONFIG, pdaudio) {
INCLUDEPATH += $(QPEDIR)/include
DEPENDPATH += $(QPEDIR)/include
DEFINES += PDAUDIO
+ DEFINES += THREADED
TARGET = qperec
# 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 @@
Created: Thu Jan 17 11:19:58 2002
copyright 2002 by L.J. Potter <ljp@llornkcor.com>
****************************************************************************/
-
#define DEV_VERSION
#include "pixmaps.h"
@@ -116,11 +115,13 @@ int sd;
Waveform* waveform;
Device *soundDevice;
-// threaded recording
-//fuckin fulgy here
-//void quickRec()
-//{
-void QtRec::quickRec() {
+
+#ifdef THREADED
+void quickRec()
+#else
+ void QtRec::quickRec()
+#endif
+{
qDebug("%d",
filePara.numberSamples/filePara.sampleRate * filePara.channels);
@@ -157,7 +158,7 @@ void QtRec::quickRec() {
for(;;) {
if ( stopped) {
- qDebug("quickRec:: stopped");
+// qDebug("quickRec:: stopped");
break;
}
@@ -233,7 +234,6 @@ void QtRec::quickRec() {
// fflush(stdout);
filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2/filePara.channels;
-
qApp->processEvents();
if( total >= filePara.samplesToRecord) {
@@ -243,7 +243,8 @@ void QtRec::quickRec() {
}
} //end main loop
- } else { // <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8;
+ } else {
+// <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8;
unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ];
memset( unsigned_inbuffer, 0, BUFSIZE);
memset( unsigned_outbuffer, 0, BUFSIZE);
@@ -282,11 +283,15 @@ void QtRec::quickRec() {
}
} /// END quickRec()
-void QtRec::playIt()
-//void playIt()
+#ifdef THREADED
+void playIt()
+#else
+ void QtRec::playIt()
+#endif
{
- int bytesWritten, number;
+ int bytesWritten = 0;
+ int number = 0;
int total = 0; // Total number of bytes read in so far.
if( filePara.resolution == 16 ) { //AFMT_S16_LE) {
if( filePara.format == WAVE_FORMAT_DVI_ADPCM) {
@@ -322,8 +327,8 @@ void QtRec::playIt()
// timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds);
// if(filePara.numberOfRecordedSeconds>1)
// timeLabel->setText( timeString+ tr(" seconds"));
- printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4);
- fflush(stdout);
+// printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4);
+// fflush(stdout);
qApp->processEvents();
@@ -408,13 +413,12 @@ void QtRec::playIt()
stopped = true;
break;
}
- printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples);
- fflush(stdout);
+// printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples);
+// fflush(stdout);
}
}
}
-/////////////////<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>
QtRec::QtRec( QWidget* parent, const char* name, WFlags fl )
: QWidget( parent, name, fl )
@@ -427,7 +431,14 @@ QtRec::QtRec( QWidget* parent, const char* name, WFlags fl )
renameBox = 0;
// open sound device to get volumes
- soundDevice = new Device( this, DSPSTROUT, DSPSTRMIXEROUT, false);
+ Config hwcfg("OpieRec");
+ hwcfg.setGroup("Hardware");
+
+
+ soundDevice = new Device( this,
+ hwcfg.readEntry( "Audio",DSPSTROUT),
+ hwcfg.readEntry( "Mixer",DSPSTRMIXEROUT), false);
+// soundDevice = new Device( this, hwcfg.readEntry( "Audio","hw:0"), hwcfg.readEntry( "Mixer","hw:0"), false);
// soundDevice->setDeviceFormat(AFMT_S16_LE);
// soundDevice->setDeviceChannels(1);
@@ -640,12 +651,6 @@ void QtRec::init() {
glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0);
glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1);
- QWidget *d = QApplication::desktop();
- int width = d->width();
- int height = d->height();
-
- if( width < height) {
-
tab_5 = new QWidget( TabWidget, "tab_5" );
QHBoxLayout *Layout19a;
@@ -696,52 +701,6 @@ void QtRec::init() {
TabWidget->insertTab( tab_5, tr( "Volume" ) );
- } else {// landscape
-
- // Layout16->addWidget( dirGroup );
- // Layout18->addLayout( Layout16 );
- Layout15 = new QVBoxLayout(this);
- Layout15->setSpacing( 2 );
- Layout15->setMargin( 0 );
-
- Layout15b = new QVBoxLayout(this);
- Layout15b->setSpacing( 2 );
- Layout15b->setMargin( 0 );
-
- TextLabel2 = new QLabel( tab_3, "InputLabel" );
- TextLabel2->setText( tr( "In"));
- TextLabel2->setFixedWidth(35);
- Layout15->addWidget( TextLabel2 );
-
- TextLabel3 = new QLabel( tab_3, "OutputLabel" );
- TextLabel3->setText( tr( "Out" ) );
- Layout15b->addWidget( TextLabel3 );
-
- InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_3, (const char *) "InputSlider" );
- InputSlider->setTickmarks(QSlider::Both);
- Layout15->addWidget( InputSlider);
-
- OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_3,(const char *) "OutputSlider" );
- OutputSlider->setTickmarks(QSlider::Both);
-
- Layout15b->addWidget( OutputSlider );
-
- outMuteCheckBox = new QCheckBox ( tr("mute"), tab_3 );
- Layout15->addWidget( outMuteCheckBox );
-
- inMuteCheckBox = new QCheckBox ( tr("mute"), tab_3 );
- inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus );
- Layout15b->addWidget( inMuteCheckBox );
-
-
- Layout19->addLayout( Layout15 );
- Layout19->addLayout( Layout15b );
-
- fillDirectoryCombo();
-
- TabWidget->insertTab( tab_3, tr( "Options" ) );
-
- }
waveform = new Waveform( this, "waveform" );
// waveform->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)3, waveform->sizePolicy().hasHeightForWidth() ) );
@@ -760,7 +719,7 @@ void QtRec::initIconView() {
QPixmap image0( ( const char** ) image0_data );
int nFiles = cfg.readNumEntry("NumberofFiles",0);
- qDebug("init number of files %d", nFiles);
+// qDebug("init number of files %d", nFiles);
for(int i=1;i<= nFiles;i++) {
@@ -1008,16 +967,20 @@ bool QtRec::rec() { //record
setCaption( msg);
#endif
filePara.fileName=currentFile.latin1();
-// qDebug("Start recording thread");
+ qDebug("Start recording thread");
stopped = false;
-// pthread_t thread1;
-// pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/);
+#ifdef THREADED
+ pthread_t thread1;
+ pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/);
+#endif
toBeginningButton->setEnabled( false);
toEndButton->setEnabled( false);
startTimer(1000);
+#ifndef THREADED
quickRec();
+#endif
}
} //end setUpFile
} //end setupAudio
@@ -1070,12 +1033,13 @@ void QtRec::changedInVolume( ) {
bool QtRec::setupAudio( bool b) {
bool ok;
int sampleformat, stereo, flags;
- char * dspString, *mixerString;
+ QString dspString, mixerString;
filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16
+ if( !b) {
+// we want to play
#ifdef PDAUDIO //ALSA
- if( !b) { // we want to play
if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) {
sampleformat = SND_PCM_FORMAT_S16;
filePara.resolution = 16;
@@ -1090,7 +1054,6 @@ bool QtRec::setupAudio( bool b) {
filePara.resolution = 8;
}
#else
- if( !b) {
// we want to play
if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) {
sampleformat = AFMT_S16_LE;
@@ -1103,8 +1066,10 @@ bool QtRec::setupAudio( bool b) {
stereo = filePara.channels;
flags = O_WRONLY;
- dspString = DSPSTROUT;
- mixerString = DSPSTRMIXEROUT;
+ Config hwcfg("OpieRec");
+ hwcfg.setGroup("Hardware");
+ dspString = hwcfg.readEntry( "Audio", DSPSTROUT);
+ mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXEROUT);
recording = false;
} else { // we want to record
@@ -1138,8 +1103,10 @@ bool QtRec::setupAudio( bool b) {
// filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100;
flags= O_RDWR;
// flags= O_RDONLY;
- dspString = DSPSTRIN;
- mixerString = DSPSTRMIXEROUT;
+ Config hwcfg("OpieRec");
+ hwcfg.setGroup("Hardware");
+ dspString = hwcfg.readEntry( "Audio", DSPSTRIN);
+ mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXERIN);
recording = true;
}
@@ -1220,7 +1187,7 @@ bool QtRec::doPlay() {
// timeSlider->setRange( 0, filePara.numberSamples);
- timeString.sprintf("%d", filePara.numberOfRecordedSeconds);
+ timeString.sprintf("%f", filePara.numberOfRecordedSeconds);
timeLabel->setText( timeString+ tr(" seconds"));
QString msg;
@@ -1233,13 +1200,16 @@ bool QtRec::doPlay() {
#endif
startTimer( 1000);
-// pthread_t thread2;
-// pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/);
+#ifdef THREADED
+ pthread_t thread2;
+ pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/);
+#endif
toBeginningButton->setEnabled( false);
toEndButton->setEnabled( false);
+#ifndef THREADED
playIt();
-
+#endif
return true;
}
@@ -1866,7 +1836,7 @@ void QtRec::receive( const QCString &msg, const QByteArray & ) {
///////////////////////////// timerEvent
-void QtRec::timerEvent( QTimerEvent *e ) {
+void QtRec::timerEvent( QTimerEvent * ) {
// if(!recording)
// timeSlider->setValue( secCount);
@@ -2160,3 +2130,4 @@ void QtRec::changeStereoCheck(bool b) {
cfg.write();
}
+
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:
void keyReleaseEvent( QKeyEvent *e);
void receive( const QCString &, const QByteArray & );
void showListMenu(QListViewItem * );
+#ifndef THREADED
void quickRec();
void playIt();
+#endif
};