summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opierec/qtrec.cpp
Side-by-side diff
Diffstat (limited to 'noncore/multimedia/opierec/qtrec.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opierec/qtrec.cpp103
1 files changed, 78 insertions, 25 deletions
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp
index aeab26d..bc6abcc 100644
--- a/noncore/multimedia/opierec/qtrec.cpp
+++ b/noncore/multimedia/opierec/qtrec.cpp
@@ -57,4 +57,14 @@ extern "C" {
#include <sys/signal.h>
+
+#ifdef PDAUDIO //ALSA
+#include <alsa/asoundlib.h>
+static int deviceSampleRates[8] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, -1 };
+static int deviceBitRates[] = { 8, 16, 24, 32, -1 };
+#else //OSS
+static int deviceSampleRates[6] = { 11025, 16000, 22050, 32000, 44100, -1 };
+static int deviceBitRates[] = { 8, 16, -1 };
+#endif
+
#if defined(QT_QWS_SL5XXX)
///#if defined(QT_QWS_EBX)
@@ -109,7 +119,7 @@ Device *soundDevice;
// threaded recording
//fuckin fulgy here
-void quickRec()
-{
-//void QtRec::quickRec() {
+//void quickRec()
+//{
+void QtRec::quickRec() {
qDebug("%d",
@@ -164,5 +174,7 @@ void quickRec()
// adpcm_coder( sbuf2, abuf, number/2, &encoder_state);
adpcm_coder( sbuf, abuf, number/2, &encoder_state);
- bytesWritten = soundDevice->devWrite( filePara.fd , (short *)abuf, number/4);
+
+ bytesWritten = ::write( filePara.fd , (short *)abuf, number/4);
+
waveform->newSamples( (const short *)abuf, bytesWritten );
@@ -204,5 +216,5 @@ void quickRec()
}
- bytesWritten = soundDevice->devWrite( filePara.fd , inbuffer, number);
+ bytesWritten = ::write( filePara.fd , inbuffer, number);
if( bytesWritten < 0) {
@@ -271,6 +283,7 @@ void quickRec()
} /// END quickRec()
+void QtRec::playIt()
-void playIt()
+//void playIt()
{
int bytesWritten, number;
@@ -570,13 +583,11 @@ void QtRec::init() {
sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) );
//#ifndef QT_QWS_EBX
- sampleRateComboBox->insertItem( tr( "44100"));
- sampleRateComboBox->insertItem( tr( "32000"));
-//#endif
- sampleRateComboBox->insertItem( tr( "22050"));
- //#ifndef QT_QWS_VERCEL_IDR
- sampleRateComboBox->insertItem( tr( "16000"));
- sampleRateComboBox->insertItem( tr( "11025"));
- sampleRateComboBox->insertItem( tr( "8000"));
- //#endif
+ QString s;
+ int z = 0;
+ while( deviceSampleRates[z] != -1) {
+ sampleRateComboBox->insertItem( s.setNum( deviceSampleRates[z], 10));
+ z++;
+ }
+
glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0);
@@ -610,6 +621,11 @@ void QtRec::init() {
bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" );
- bitRateComboBox->insertItem( tr( "16" ) );
- bitRateComboBox->insertItem( tr( "8" ) );
+
+ z = 0;
+ while( deviceBitRates[z] != -1) {
+ bitRateComboBox->insertItem( s.setNum( deviceBitRates[z], 10) );
+ z++;
+ }
+
bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) );
@@ -846,7 +862,12 @@ void QtRec::initConfig() {
i = cfg.readNumEntry("bitrate",16);
if(i == 16)
- bitRateComboBox->setCurrentItem( 0);
- else
bitRateComboBox->setCurrentItem( 1);
+ else if(i == 24)
+ bitRateComboBox->setCurrentItem( 2);
+ else if(i == 32)
+ bitRateComboBox->setCurrentItem( 3);
+ else
+ bitRateComboBox->setCurrentItem( 0);
+
filePara.resolution = i;
@@ -991,11 +1012,11 @@ bool QtRec::rec() { //record
stopped = false;
- pthread_t thread1;
- pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/);
+// pthread_t thread1;
+// pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/);
toBeginningButton->setEnabled( false);
toEndButton->setEnabled( false);
startTimer(1000);
-// quickRec();
+ quickRec();
}
} //end setUpFile
@@ -1054,4 +1075,20 @@ bool QtRec::setupAudio( bool b) {
filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16
+#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
@@ -1063,4 +1100,5 @@ bool QtRec::setupAudio( bool b) {
filePara.resolution = 8;
}
+#endif
stereo = filePara.channels;
@@ -1071,4 +1109,15 @@ bool QtRec::setupAudio( bool b) {
} 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;
@@ -1084,4 +1133,5 @@ bool QtRec::setupAudio( bool b) {
// qDebug("WAVE_FORMAT_DVI_ADPCM");
}
+#endif
stereo = filePara.channels;
@@ -1184,9 +1234,10 @@ bool QtRec::doPlay() {
startTimer( 1000);
- pthread_t thread2;
- pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/);
+// pthread_t thread2;
+// pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/);
toBeginningButton->setEnabled( false);
toEndButton->setEnabled( false);
+ playIt();
return true;
@@ -1198,5 +1249,7 @@ void QtRec::changebitrateCombo(int i) {
cfg.setGroup("Settings");
int bits = 0;
- if( i == 0) { bits = 16; }
+ if( i == 1) { bits = 16; }
+ else if( i == 2) { bits = 24; }
+ else if( i == 3) { bits = 32; }
else { bits=8; }
cfg.writeEntry("bitrate", bits);