summaryrefslogtreecommitdiff
path: root/noncore/multimedia
Side-by-side diff
Diffstat (limited to 'noncore/multimedia') (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,40 +1,41 @@
-#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 \
helpwindow.h \
qtrec.h \
device.h \
wavFile.h \
waveform.h
SOURCES = adpcm.c \
helpwindow.cpp \
main.cpp \
qtrec.cpp \
device.cpp \
wavFile.cpp \
waveform.cpp
INTERFACES =
contains(CONFIG, pdaudio) {
# LIBS += -L/opt/buildroot-opie/output/staging/target/lib -lqpe -lpthread -ljpeg -lpng -lz
LIBS += -L$(QPEDIR)/lib -lqpe -lpthread -ljpeg -lpng -lz
INCLUDEPATH += $(QPEDIR)/include
DEPENDPATH += $(QPEDIR)/include
DEFINES += PDAUDIO
+ DEFINES += THREADED
TARGET = qperec
# DESTDIR=$(QPEDIR)/bin
}
contains(CONFIG, opie) {
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
DESTDIR=$(OPIEDIR)/bin
LIBS += -lqpe -lpthread
TARGET = opierec
include ( $(OPIEDIR)/include.pro )
}
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
@@ -1,30 +1,29 @@
/****************************************************************************
// qtrec.cpp
Created: Thu Jan 17 11:19:58 2002
copyright 2002 by L.J. Potter <ljp@llornkcor.com>
****************************************************************************/
-
#define DEV_VERSION
#include "pixmaps.h"
#include "qtrec.h"
#include "waveform.h"
#include "device.h"
#include <pthread.h>
extern "C" {
#include "adpcm.h"
}
#include <sys/soundcard.h>
#include <qpe/config.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
#include <qpe/storage.h>
#include <qcheckbox.h>
#include <qcombobox.h>
//#include <qdatetime.h>
@@ -95,90 +94,92 @@ typedef struct {
int channels; //number of channels
int fd; //file descriptor
int sd; //sound device descriptor
int numberSamples; //total number of samples
int SecondsToRecord; // number of seconds that should be recorded
float numberOfRecordedSeconds; //total number of samples recorded
int samplesToRecord; //number of samples to be recorded
int inVol; //input volume
int outVol; //output volume
int format; //wavfile format PCM.. ADPCM
const char *fileName; //name of fiel to be played/recorded
} fileParameters;
fileParameters filePara;
bool monitoring, recording, playing;
bool stopped;
QLabel *timeLabel;
QSlider *timeSlider;
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);
qDebug("samples %d, rate %d, channels %d",
filePara.numberSamples, filePara.sampleRate, filePara.channels);
int total = 0; // Total number of bytes read in so far.
int bytesWritten, number;
bytesWritten = 0;
number = 0;
QString num;
int level = 0;
int threshold = 0;
// int bits = filePara.resolution;
// qDebug("bits %d", bits);
if( filePara.resolution == 16 ) { //AFMT_S16_LE)
// qDebug("AFMT_S16_LE size %d", filePara.SecondsToRecord);
// qDebug("samples to record %d", filePara.samplesToRecord);
// qDebug("%d", filePara.sd);
level = 7;
threshold = 0;
if( filePara.format == WAVE_FORMAT_DVI_ADPCM) {
// qDebug("start recording WAVE_FORMAT_DVI_ADPCM");
// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
char abuf[ BUFSIZE/2 ];
short sbuf[ BUFSIZE ];
short sbuf2[ BUFSIZE ];
memset( abuf, 0, BUFSIZE/2);
memset( sbuf, 0, BUFSIZE);
memset( sbuf2, 0, BUFSIZE);
for(;;) {
if ( stopped) {
- qDebug("quickRec:: stopped");
+// qDebug("quickRec:: stopped");
break;
}
// number=::read( filePara.sd, sbuf, BUFSIZE);
number = soundDevice ->devRead( filePara.sd, sbuf, BUFSIZE);
if(number <= 0) {
perror("recording error ");
qDebug( "%s %d", filePara.fileName, number);
stopped = true;
return;
}
//if(stereo == 2) {
// adpcm_coder( sbuf2, abuf, number/2, &encoder_state);
adpcm_coder( sbuf, abuf, number/2, &encoder_state);
bytesWritten = ::write( filePara.fd , (short *)abuf, number/4);
waveform->newSamples( (const short *)abuf, bytesWritten );
total += bytesWritten;
filePara.numberSamples = total;
timeSlider->setValue( total);
@@ -212,139 +213,143 @@ void QtRec::quickRec() {
perror( "recording error ");
qDebug( filePara.fileName);
stopped = true;
return;
}
bytesWritten = ::write( filePara.fd , inbuffer, number);
if( bytesWritten < 0) {
perror("File writing error ");
stopped = true;
return;
}
total += bytesWritten;
filePara.numberSamples = total;
if( filePara.SecondsToRecord != 0)
timeSlider->setValue( total);
// printf("Writing number %d, bytes %d,total %d\r",number, bytesWritten , total);
// fflush(stdout);
filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2/filePara.channels;
-
qApp->processEvents();
if( total >= filePara.samplesToRecord) {
stopped = true;
break;
}
}
} //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);
for(;;) {
if ( stopped) {
qDebug("quickRec:: stopped");
break; // stop if playing was set to false
}
number = ::read( filePara.sd, unsigned_inbuffer, BUFSIZE);
bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number);
if(bytesWritten < 0) {
stopped = true;
QMessageBox::message("Note","There was a problem\nwriting to the file");
perror("File writing error ");
return;
}
total += bytesWritten;
filePara.numberSamples = total;
// printf("\nWriting number %d, bytes %d,total %d \r",number, bytesWritten , total);
// fflush(stdout);
if( filePara.SecondsToRecord !=0)
timeSlider->setValue( total);
filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate;
qApp->processEvents();
if( total >= filePara.samplesToRecord) {
stopped = true;
break;
}
} //end main loop
}
} /// 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) {
char abuf[ BUFSIZE / 2 ];
short sbuf[ BUFSIZE ];
short sbuf2[ BUFSIZE * 2 ];
memset( abuf, 0, BUFSIZE / 2);
memset( sbuf, 0, BUFSIZE);
memset( sbuf2, 0, BUFSIZE * 2);
// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
for(;;) { // play loop
if ( stopped) {
break;
return;
}// stop if playing was set to false
number = ::read( filePara.fd, abuf, BUFSIZE / 2);
adpcm_decoder( abuf, sbuf, number * 2, &decoder_state);
// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel
// sbuf2[i+1]=sbuf2[i]=sbuf[i];
// }
bytesWritten = write ( filePara.sd, sbuf, number * 4);
waveform->newSamples( (const short *)sbuf, number );
// if(filePara.channels==1)
// total += bytesWritten/2; //mono
// else
total += bytesWritten;
filePara.numberSamples = total/4;
filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2;
timeSlider->setValue( total/4);
// 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();
if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
// if( total >= filePara.numberSamples ){//|| secCount > filePara.numberOfRecordedSeconds ) {
stopped = true;
break;
}
}
} else {
// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>>
short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ];
memset( inbuffer, 0, BUFSIZE);
memset( outbuffer, 0, BUFSIZE);
for(;;) { // play loop
if ( stopped) {
break;
return;
}
// stop if playing was set to false
number = ::read( filePara.fd, inbuffer, BUFSIZE);
// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel
// // for (int i=0;i< number ; i++) { //2*i is left channel
@@ -387,68 +392,74 @@ void QtRec::playIt()
if (stopped) {
break; // stop if playing was set to false
return;
}
number = ::read( filePara.fd, unsigned_inbuffer, BUFSIZE);
//data = (val >> 8) ^ 0x80;
// unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80;
bytesWritten = write ( filePara.sd, unsigned_inbuffer, number);
waveform->newSamples( (const short *)unsigned_inbuffer, bytesWritten );
total += bytesWritten;
timeSlider->setValue( total);
filePara.numberSamples = total;
filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate;
// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
// timeLabel->setText( timeString + tr(" seconds"));
qApp->processEvents();
if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
// if( total >= filePara.numberSamples ) {
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 )
{
if ( !name )
setName( "OpieRec" );
init();
initConfig();
initConnections();
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);
// soundDevice->setDeviceRate( 22050);
getInVol();
getOutVol();
soundDevice->closeDevice( true);
soundDevice->sd = -1;
soundDevice = 0;
wavFile = 0;
if( soundDevice) delete soundDevice;
initIconView();
if( autoMute)
doMute( true);
ListView1->setFocus();
playing = false;
}
QtRec::~QtRec() {
@@ -619,54 +630,48 @@ void QtRec::init() {
bitGroup->setTitle( tr( "Bit Depth" ) );
bitGroup->setFixedSize( 65, 50);
bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" );
z = 0;
while( deviceBitRates[z] != -1) {
bitRateComboBox->insertItem( s.setNum( deviceBitRates[z], 10) );
z++;
}
bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) );
glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1);
compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 );
autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 );
stereoCheckBox = new QCheckBox ( tr("Stereo Channels"), tab_3 );
glayout3->addMultiCellWidget( compressionCheckBox, 2, 2, 0, 3);
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;
Layout19a = new QHBoxLayout( tab_5);
Layout19a->setSpacing( 2 );
Layout19a->setMargin( 0 );
Layout15 = new QVBoxLayout( this);
Layout15->setSpacing( 2 );
Layout15->setMargin( 0 );
Layout15b = new QVBoxLayout( this);
Layout15b->setSpacing( 2 );
Layout15b->setMargin( 0 );
TextLabel2 = new QLabel( tab_5, "InputLabel" );
TextLabel2->setText( tr( "In"));
TextLabel2->setFixedWidth( 35);
Layout15->addWidget( TextLabel2 );
TextLabel3 = new QLabel( tab_5, "OutputLabel" );
TextLabel3->setText( tr( "Out" ) );
Layout15b->addWidget( TextLabel3 );
@@ -675,113 +680,67 @@ void QtRec::init() {
Layout15->addWidget( InputSlider);
OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" );
OutputSlider->setTickmarks( QSlider::Both);
Layout15b->addWidget( OutputSlider );
outMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 );
Layout15->addWidget( outMuteCheckBox );
inMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 );
inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus );
Layout15b->addWidget( inMuteCheckBox );
Layout19a->addLayout( Layout15 );
Layout19a->addLayout( Layout15b );
fillDirectoryCombo();
TabWidget->insertTab( tab_3, tr( "Options" ) );
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() ) );
waveform->setMinimumSize( QSize( 0, 50 ) );
layout->addMultiCellWidget( waveform, 8, 8, 0, 7 );
waveform->setBackgroundColor ( black );
}
void QtRec::initIconView() {
ListView1->clear();
Config cfg("OpieRec");
cfg.setGroup("Sounds");
QString temp;
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++) {
QListViewItem * item;
QString fileS, mediaLocation, fileDate, filePath;
temp.sprintf( "%d",i);
temp = cfg.readEntry( temp,""); //reads currentFile
filePath = cfg.readEntry( temp,""); //currentFileName
QFileInfo info(filePath);
fileDate = info.lastModified().toString();
fileS = cfg.readEntry( filePath, "0" );// file length in seconds
mediaLocation = getStorage( filePath);
if( info.exists()) {
item = new QListViewItem( ListView1, temp, fileS, mediaLocation, fileDate);
item->setPixmap( 0, image0);
if( currentFileName == filePath)
ListView1->setSelected( item, true);
}
}
}
@@ -987,58 +946,62 @@ bool QtRec::rec() { //record
filePara.samplesToRecord, filePara.resolution, filePara.sampleRate);
if( paused) {
paused = false;
}
// else {
qDebug("Setting timeslider %d", filePara.samplesToRecord);
// if(fileSize != 0)
timeSlider->setRange(0, filePara.samplesToRecord);
// }
if( diskSize < fileSize/1024) {
QMessageBox::warning(this,
tr("Low Disk Space"),
tr("You are running low of\nrecording space\n"
"or a card isn't being recognized"));
stopped = true; //we need to be stopped
stop();
} else {
QString msg;
msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution);
#ifdef DEV_VERSION
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
return true;
}
/*
This happens when a tab is selected*/
void QtRec::thisTab(QWidget* widg) {
if(widg != NULL) {
int index = TabWidget->currentPageIndex();
if(index == 0) { //file page
}
if(index == 1) { //control page
fillDirectoryCombo();
// soundDevice->getOutVol();
// soundDevice->getInVol();
}
if( index==2) { //help page
}
qApp->processEvents();
@@ -1049,118 +1012,122 @@ void QtRec::thisTab(QWidget* widg) {
void QtRec::getOutVol( ) {
filePara.outVol = soundDevice->getOutVolume();
// qDebug("out vol %d", filePara.outVol);
OutputSlider->setValue( -filePara.outVol);
}
void QtRec::getInVol() {
filePara.inVol = soundDevice->getInVolume();
// qDebug("in vol %d", filePara.inVol);
InputSlider->setValue( -filePara.inVol);
}
void QtRec::changedOutVolume() {
soundDevice->changedOutVolume( -OutputSlider->value());
}
void QtRec::changedInVolume( ) {
soundDevice->changedInVolume( -InputSlider->value());
}
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;
} else if( filePara.resolution == 24 || compressionCheckBox->isChecked() ) {
sampleformat = SND_PCM_FORMAT_S24;
filePara.resolution = 24;
} else if( filePara.resolution == 32 || compressionCheckBox->isChecked() ) {
sampleformat = SND_PCM_FORMAT_S32;
filePara.resolution = 32;
} else {
sampleformat = SND_PCM_FORMAT_U8;
filePara.resolution = 8;
}
#else
- if( !b) {
// we want to play
if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) {
sampleformat = AFMT_S16_LE;
filePara.resolution = 16;
} else {
sampleformat = AFMT_U8;
filePara.resolution = 8;
}
#endif
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
#ifdef PDAUDIO //ALSA
if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16")
sampleformat = SND_PCM_FORMAT_S16;
else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "24")
sampleformat = SND_PCM_FORMAT_S24;
else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "32")
sampleformat = SND_PCM_FORMAT_S32;
else
sampleformat = SND_PCM_FORMAT_U8;
#else
if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16")
sampleformat = AFMT_S16_LE;
else
sampleformat = AFMT_U8;
if( !compressionCheckBox->isChecked()) {
filePara.format = WAVE_FORMAT_PCM;
// qDebug("WAVE_FORMAT_PCM");
} else {
filePara.format = WAVE_FORMAT_DVI_ADPCM;
sampleformat = AFMT_S16_LE;
// qDebug("WAVE_FORMAT_DVI_ADPCM");
}
#endif
stereo = filePara.channels;
// 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;
}
// if(soundDevice) delete soundDevice;
qDebug("<<<<<<<<<<<<<<<<<<<open dsp %d %d %d", filePara.sampleRate, filePara.channels, sampleformat);
qWarning("change waveform settings");
waveform->changeSettings( filePara.sampleRate, filePara.channels );
soundDevice = new Device( this, dspString, mixerString, b);
// soundDevice->openDsp();
soundDevice->reset();
qDebug("device has been made %d", soundDevice->sd);
////////////////// <<<<<<<<<<<<>>>>>>>>>>>>
soundDevice->setDeviceFormat( sampleformat);
soundDevice->setDeviceChannels( filePara.channels);
soundDevice->setDeviceRate( filePara.sampleRate);
soundDevice->getDeviceFragSize();
#ifdef QT_QWS_EBX
int frag = FRAGSIZE;
soundDevice->setFragSize( frag);
soundDevice->getDeviceFragSize();
#endif
@@ -1199,68 +1166,71 @@ bool QtRec::setUpFile() { //setup file for recording
// filePara.channels=1;
}
return true;
}
/// <<<<<<<<<<<<<<<< PLAY >>>>>>>>>>>>>>>>>>>
bool QtRec::doPlay() {
if( !paused) {
total = 0;
filePara.numberOfRecordedSeconds = 0;
} else {
paused = false;
secCount = (int)filePara.numberOfRecordedSeconds;
}
playing = true;
stopped = false;
recording = false;
QString num;
qDebug( "Play number of samples %d", filePara.numberSamples);
// timeSlider->setRange( 0, filePara.numberSamples);
- timeString.sprintf("%d", filePara.numberOfRecordedSeconds);
+ timeString.sprintf("%f", filePara.numberOfRecordedSeconds);
timeLabel->setText( timeString+ tr(" seconds"));
QString msg;
msg.sprintf("%d, %d, %d",
filePara.sampleRate,
filePara.channels,
filePara.resolution);
#ifdef DEV_VERSION
setCaption( msg);
#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;
}
void QtRec::changebitrateCombo(int i) {
Config cfg("OpieRec");
cfg.setGroup("Settings");
int bits = 0;
if( i == 1) { bits = 16; }
else if( i == 2) { bits = 24; }
else if( i == 3) { bits = 32; }
else { bits=8; }
cfg.writeEntry("bitrate", bits);
filePara.resolution = bits;
cfg.write();
}
void QtRec::changesamplerateCombo(int i) {
Config cfg("OpieRec");
cfg.setGroup("Settings");
int rate=0;
bool ok;
rate = sampleRateComboBox->text(i).toInt(&ok, 10);
cfg.writeEntry( "samplerate",rate);
@@ -1845,49 +1815,49 @@ long QtRec::checkDiskSpace(const QString &path) {
if ( !div ) div = 1;
return availBlks * mult / div;
}
return -1;
}
// short f_fstyp; /* File system type */
// long f_bsize; /* Block size */
// long f_frsize; /* Fragment size */
// long f_blocks; /* Total number of blocks*/
// long f_bfree; /* Count of free blocks */
// long f_files; /* Total number of file nodes */
// long f_ffree; /* Count of free file nodes */
// char f_fname[6]; /* Volumename */
// char f_fpack[6]; /* Pack name */
void QtRec::receive( const QCString &msg, const QByteArray & ) {
qDebug("Voicerecord received message "+msg);
}
///////////////////////////// timerEvent
-void QtRec::timerEvent( QTimerEvent *e ) {
+void QtRec::timerEvent( QTimerEvent * ) {
// if(!recording)
// timeSlider->setValue( secCount);
// else
// timeSlider->setValue( filePara.numberOfRecordedSeconds);
if( stopped && playing) {
stop();
}
if( stopped && recording ){
stop();
}
if( recording && filePara.SecondsToRecord < secCount && filePara.SecondsToRecord != 0) {
stop();
}
qDebug( "%d", secCount );
QString timeString;
#ifdef DEV_VERSION
QString msg;
msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution);
setCaption( msg +" :: "+QString::number(secCount));
@@ -2139,24 +2109,25 @@ void QtRec::selectItemByName(const QString & name) {
// output = output * scalar;
// //
// // When current gets close to 0.0, set current to 0.0 to prevent FP underflow
// // which can cause a severe performance degradation due to a flood
// // of interrupts.
// //
// if( output < vsf ) output = 0.0;
// }
// return (long) output;
// }
void QtRec::changeStereoCheck(bool b) {
Config cfg("OpieRec");
cfg.setGroup("Settings");
int ch = 0;
if ( !b) { ch = 1;}
else { ch = 2;}
cfg.writeEntry("stereo", b);
filePara.channels = ch;
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
@@ -156,30 +156,32 @@ protected:
QVBoxLayout* Layout15;
QVBoxLayout* Layout15b;
QVBoxLayout* Layout18;
QWidget *tab, *tab_2, *tab_3, *tab_4, *tab_5;
int sliderPos, total;
// short inbuffer[BUFSIZE], outbuffer[BUFSIZE];
// unsigned short unsigned_inbuffer[BUFSIZE], unsigned_outbuffer[BUFSIZE];
QGroupBox *sampleGroup, *bitGroup, *dirGroup, *sizeGroup;
/* short inbuffer[65536], outbuffer[65536]; */
/* unsigned short unsigned_inbuffer[65536], unsigned_outbuffer[65536]; */
bool doPlay();
bool openPlayFile();
bool setUpFile();
bool setupAudio( bool b);
void endPlaying();
void endRecording();
void fileBeamFinished( Ir *ir);
void initIconView();
void keyPressEvent( QKeyEvent *e);
void keyReleaseEvent( QKeyEvent *e);
void receive( const QCString &, const QByteArray & );
void showListMenu(QListViewItem * );
+#ifndef THREADED
void quickRec();
void playIt();
+#endif
};
#endif // QTREC_H