summaryrefslogtreecommitdiff
path: root/noncore
Side-by-side diff
Diffstat (limited to 'noncore') (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opierec/device.cpp16
-rw-r--r--noncore/multimedia/opierec/opierec.pro1
-rw-r--r--noncore/multimedia/opierec/qtrec.cpp21
-rw-r--r--noncore/multimedia/opierec/wavFile.cpp40
4 files changed, 43 insertions, 35 deletions
diff --git a/noncore/multimedia/opierec/device.cpp b/noncore/multimedia/opierec/device.cpp
index e7e0f4b..a76665e 100644
--- a/noncore/multimedia/opierec/device.cpp
+++ b/noncore/multimedia/opierec/device.cpp
@@ -55,44 +55,47 @@ Device::Device( QObject * parent, bool record )
// dspstr = dsp;
devForm = -1;
devCh = -1;
devRate = -1;
if( !record){ //playing
- owarn << "setting up DSP for playing" << oendl;
- flags = O_WRONLY;
+ owarn << "New Sound device DSP for playing" << oendl;
+ flags = O_RDWR;
+// flags = O_WRONLY;
} else { //recording
- owarn << "setting up DSP for recording" << oendl;
+ owarn << "New Sound device DSP for recording" << oendl;
flags = O_RDWR;
// flags = O_RDONLY;
selectMicInput();
}
}
bool Device::openDsp() {
+ qWarning("Device::openDsp()");
if( openDevice( flags) == -1) {
perror("<<<<<<<<<<<<<<ioctl(\"Open device\")");
return false;
}
return true;
}
int Device::openDevice( int flags) {
- owarn << "Opening"<< dspstr;
+ owarn << "Opening sound device:"<< DSPSTROUT << oendl;
- if (( sd = ::open( DSPSTROUT, flags)) == -1) {
- perror("open(\"/dev/dsp\")");
+ if (( sd = ::open( DSPSTROUT, O_RDWR)) == -1) {
+ perror("open(\"/dev/dsp\")\n");
QString errorMsg="Could not open audio device\n /dev/dsp\n"
+(QString)strerror(errno);
qDebug( "XXXXXXXXXXXXXXXXXXXXXXX "+errorMsg );
return -1;
}
if(ioctl(sd,SNDCTL_DSP_RESET,0)<0){
perror("ioctl RESET");
}
+ qWarning("opened!");
return sd;
}
int Device::getInVolume() {
unsigned int volume = 0;
Config cfg("qpe");
@@ -147,12 +150,13 @@ bool Device::selectMicInput() {
::close(md);
return true;
}
bool Device::closeDevice( bool) {
+ if(sd)
::close( sd); //close sound device
return true;
}
bool Device::setDeviceFormat( int form) {
qDebug( "set device res %d: %d ",form, sd );
diff --git a/noncore/multimedia/opierec/opierec.pro b/noncore/multimedia/opierec/opierec.pro
index 6a5838a..6008bf7 100644
--- a/noncore/multimedia/opierec/opierec.pro
+++ b/noncore/multimedia/opierec/opierec.pro
@@ -28,11 +28,12 @@ contains(CONFIG, pdaudio) {
}
!contains(CONFIG, pdaudio) {
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lopiecore2 -lpthread
+ DEFINES += THREADED
TARGET = opierec
include( $(OPIEDIR)/include.pro )
}
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp
index e827083..9b761aa 100644
--- a/noncore/multimedia/opierec/qtrec.cpp
+++ b/noncore/multimedia/opierec/qtrec.cpp
@@ -153,24 +153,24 @@ void quickRec()
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);
+ bytesWritten = ::write( filePara.fd , abuf, number/4);
waveform->newSamples( sbuf, number );
total += bytesWritten;
filePara.numberSamples = total;
timeSlider->setValue( total);
printf("%d, bytes %d,total %d\r", number, bytesWritten, total);
fflush(stdout);
- filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2 / filePara.channels;
+ filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2;// / filePara.channels;
qApp->processEvents();
if( total >= filePara.samplesToRecord) {
stopped = true;
break;
}
@@ -298,14 +298,16 @@ void playIt()
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 *4);
+ bytesWritten = write ( soundDevice->sd , sbuf, number * 4);
+
+ waveform->newSamples( 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;
@@ -339,13 +341,13 @@ void playIt()
// 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
// outbuffer[i+1]= outbuffer[i]=inbuffer[i];
// }
- bytesWritten = ::write( filePara.sd, inbuffer, number);
+ bytesWritten = ::write( soundDevice->sd, inbuffer, number);
waveform->newSamples( inbuffer, number);
//-------------->>>> out to device
// total+=bytesWritten;
// if(filePara.channels==1)
// total += bytesWritten/2; //mono
// else
@@ -785,14 +787,14 @@ void QtRec::initConfig() {
} else {
filePara.channels = 1;
}
compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1));
if( compressionCheckBox->isChecked()) {
+ bitRateComboBox->setCurrentItem(1);
bitRateComboBox->setEnabled(false);
- bitRateComboBox->setCurrentItem(0);
filePara.resolution=16;
}
autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0));
if( autoMuteCheckBox->isChecked())
slotAutoMute(true);
@@ -1045,13 +1047,13 @@ bool QtRec::setupAudio( bool b) {
flags= O_RDWR;
// flags= O_RDONLY;
recording = true;
}
// if(soundDevice) delete soundDevice;
- odebug << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl;
+ owarn << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl;
// owarn << "change waveform settings" << oendl;
waveform->changeSettings( filePara.sampleRate, filePara.channels );
soundDevice = new Device( this, b); //open rec
// soundDevice->openDsp();
soundDevice->reset();
@@ -1480,13 +1482,13 @@ void QtRec::endPlaying() {
// if(soundDevice) delete soundDevice;
}
bool QtRec::openPlayFile() {
-
+ qWarning("opening file");
qApp->processEvents();
if( currentFile.isEmpty()) {
QMessageBox::message(tr("Opierec"),tr("Please select file to play"));
endPlaying();
return false;
}
@@ -1723,14 +1725,15 @@ void QtRec::compressionSelected(bool b) {
cfg.writeEntry("wavCompression", b);
cfg.writeEntry("bitrate", 16);
filePara.resolution = 16;
cfg.write();
if(b) {
- bitRateComboBox->setEnabled( false);
+ qWarning("set adpcm");
bitRateComboBox->setCurrentItem( 1);
+ bitRateComboBox->setEnabled( false);
filePara.resolution = 16;
} else{
bitRateComboBox->setEnabled( true);
}
}
diff --git a/noncore/multimedia/opierec/wavFile.cpp b/noncore/multimedia/opierec/wavFile.cpp
index 80453e1..b53c416 100644
--- a/noncore/multimedia/opierec/wavFile.cpp
+++ b/noncore/multimedia/opierec/wavFile.cpp
@@ -24,13 +24,13 @@ using namespace Opie::Core;
#include <unistd.h>
WavFile::WavFile( QObject * parent,const QString &fileName, bool makeNwFile, int sampleRate,
int channels, int resolution, int format )
: QObject( parent)
{
-//odebug << "new wave file" << oendl;
+ owarn << "new wave file: " << fileName << oendl;
bool b = makeNwFile;
wavSampleRate=sampleRate;
wavFormat=format;
wavChannels=channels;
wavResolution=resolution;
useTmpFile=false;
@@ -106,13 +106,13 @@ WavFile::~WavFile() {
void WavFile::closeFile() {
if(track.isOpen())
track.close();
}
int WavFile::openFile(const QString &currentFileName) {
-// odebug << "open play file "+currentFileName << oendl;
+ qWarning("open play file "+currentFileName);;
closeFile();
track.setName(currentFileName);
if(!track.open(IO_ReadOnly)) {
QString errorMsg=(QString)strerror(errno);
@@ -149,100 +149,100 @@ bool WavFile::setWavHeader(int fd, wavhdr *hdr) {
(*hdr).nBlockAlign = wavChannels*( wavResolution/8); //block align
(*hdr).bitsPerSample = wavResolution; //bits per sample 8, or 16
strncpy((*hdr).dataID, "data", 4);
write( fd,hdr, sizeof(*hdr));
- odebug << "writing header: bitrate " << wavResolution << ", samplerate " << wavSampleRate << ", channels " << wavChannels << oendl;
+ owarn << "writing header: bitrate " << wavResolution << ", samplerate " << wavSampleRate << ", channels " << wavChannels << oendl;
return true;
}
bool WavFile::adjustHeaders(int fd, int total) {
lseek(fd, 4, SEEK_SET);
int i = total + 36;
write( fd, &i, sizeof(i));
lseek( fd, 40, SEEK_SET);
write( fd, &total, sizeof(total));
- odebug << "adjusting header " << total << "" << oendl;
+ owarn << "adjusting header " << total << "" << oendl;
return true;
}
int WavFile::parseWavHeader(int fd) {
- odebug << "Parsing wav header" << oendl;
+ owarn << "Parsing wav header" << oendl;
char string[4];
int found;
short fmt;
unsigned short ch, bitrate;
unsigned long samplerrate, longdata;
if (read(fd, string, 4) < 4) {
- odebug << " Could not read from sound file." << oendl;
+ owarn << " Could not read from sound file." << oendl;
return -1;
}
if (strncmp(string, "RIFF", 4)) {
- odebug << " not a valid WAV file." << oendl;
+ owarn << " not a valid WAV file." << oendl;
return -1;
}
lseek(fd, 4, SEEK_CUR);
if (read(fd, string, 4) < 4) {
- odebug << "Could not read from sound file." << oendl;
+ owarn << "Could not read from sound file." << oendl;
return -1;
}
if (strncmp(string, "WAVE", 4)) {
- odebug << "not a valid WAV file." << oendl;
+ owarn << "not a valid WAV file." << oendl;
return -1;
}
found = 0;
while (!found) {
if (read(fd, string, 4) < 4) {
- odebug << "Could not read from sound file." << oendl;
+ owarn << "Could not read from sound file." << oendl;
return -1;
}
if (strncmp(string, "fmt ", 4)) {
if (read(fd, &longdata, 4) < 4) {
- odebug << "Could not read from sound file." << oendl;
+ owarn << "Could not read from sound file." << oendl;
return -1;
}
lseek(fd, longdata, SEEK_CUR);
} else {
lseek(fd, 4, SEEK_CUR);
if (read(fd, &fmt, 2) < 2) {
- odebug << "Could not read format chunk." << oendl;
+ owarn << "Could not read format chunk." << oendl;
return -1;
}
if (fmt != WAVE_FORMAT_PCM && fmt != WAVE_FORMAT_DVI_ADPCM) {
- odebug << "Wave file contains unknown format. Unable to continue." << oendl;
+ owarn << "Wave file contains unknown format. Unable to continue." << oendl;
return -1;
}
wavFormat = fmt;
// compressionFormat=fmt;
- odebug << "compressionFormat is " << fmt << "" << oendl;
+ owarn << "compressionFormat is " << fmt << "" << oendl;
if (read(fd, &ch, 2) < 2) {
- odebug << "Could not read format chunk." << oendl;
+ owarn << "Could not read format chunk." << oendl;
return -1;
} else {
wavChannels = ch;
- odebug << "File has " << ch << " channels" << oendl;
+ owarn << "File has " << ch << " channels" << oendl;
}
if (read(fd, &samplerrate, 4) < 4) {
- odebug << "Could not read from format chunk." << oendl;
+ owarn << "Could not read from format chunk." << oendl;
return -1;
} else {
wavSampleRate = samplerrate;
// sampleRate = samplerrate;
- odebug << "File has samplerate of " << (int) samplerrate << "" << oendl;
+ owarn << "File has samplerate of " << (int) samplerrate << "" << oendl;
}
lseek(fd, 6, SEEK_CUR);
if (read(fd, &bitrate, 2) < 2) {
- odebug << "Could not read format chunk." << oendl;
+ owarn << "Could not read format chunk." << oendl;
return -1;
} else {
wavResolution=bitrate;
// resolution = bitrate;
- odebug << "File has bitrate of " << bitrate << "" << oendl;
+ owarn << "File has bitrate of " << bitrate << "" << oendl;
}
found++;
}
}
found = 0;
while (!found) {