Diffstat (limited to 'noncore/multimedia/opierec/device.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opierec/device.cpp | 59 |
1 files changed, 41 insertions, 18 deletions
diff --git a/noncore/multimedia/opierec/device.cpp b/noncore/multimedia/opierec/device.cpp index 11071d8..ce49e96 100644 --- a/noncore/multimedia/opierec/device.cpp +++ b/noncore/multimedia/opierec/device.cpp @@ -5,5 +5,5 @@ #include <qpe/config.h> #include <qpe/qcopenvelope_qws.h> -#include <qpe/custom.h> + #include <fcntl.h> @@ -27,5 +27,5 @@ Device::Device( QObject * parent, const char * dsp, const char * mixr, bool reco dspstr = (char *)dsp; mixstr = (char *)mixr; - + devForm=-1; devCh=-1; @@ -39,5 +39,7 @@ Device::Device( QObject * parent, const char * dsp, const char * mixr, bool reco flags = O_RDWR; // flags = O_RDONLY; - selectMicInput(); + +// selectMicInput(); + } } @@ -95,4 +97,5 @@ void Device::changedOutVolume(int vol) { cfg.writeEntry("VolumePercent", QString::number( vol )); QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; + qWarning("changing output vol %d", vol); } ::close(fd); @@ -109,4 +112,5 @@ void Device::changedInVolume(int vol ) { cfg.writeEntry("Mic", QString::number(vol )); QCopEnvelope( "QPE/System", "micChange(bool)" ) << false; + qWarning("changing input volume %d", vol); } ::close(fd); @@ -114,5 +118,5 @@ void Device::changedInVolume(int vol ) { bool Device::selectMicInput() { -/* + int md=0; int info=MIXER_WRITE(SOUND_MIXER_MIC); @@ -127,5 +131,5 @@ bool Device::selectMicInput() { } ::close(md); -*/ + return true; } @@ -146,16 +150,20 @@ exit(1); case 0: { */ - if (( sd = ::open( dspstr, flags)) == -1) { +qDebug("Opening %s",dspstr); + if (( sd = ::open( dspstr, flags)) == -1) { perror("open(\"/dev/dsp\")"); QString errorMsg="Could not open audio device\n /dev/dsp\n" +(QString)strerror(errno); - qDebug(errorMsg); + qDebug("XXXXXXXXXXXXXXXXXXXXXXX "+errorMsg); return -1; } +qDebug("Opening mixer"); int mixerHandle=0; - /* Set the input dsp device and its input gain the weird Zaurus way */ - if (( mixerHandle = open("/dev/mixer1",O_RDWR))<0) { - perror("open(\"/dev/mixer1\")"); + if (( mixerHandle = open("/dev/mixer",O_RDWR))<0) { + perror("open(\"/dev/mixer\")"); + QString errorMsg="Could not open audio device\n /dev/dsp\n" + +(QString)strerror(errno); + qDebug("XXXXXXXXXXXXXXXXXXXXXX "+errorMsg); } @@ -200,14 +208,14 @@ exit(1); // sd = s.toInt(&ok, 10); // qDebug("<<<<<<<<<<<<<>>>>>>>>>>>>"+s); - + // f2.close(); // } ::close(mixerHandle ); - qDebug("open device %s", dspstr); - qDebug("success! %d",sd); +// qDebug("open device %s", dspstr); +// qDebug("success! %d",sd); return sd; } -bool Device::closeDevice( bool b) { +bool Device::closeDevice( bool) { // if(b) {//close now // if (ioctl( sd, SNDCTL_DSP_RESET, 0) == -1) { @@ -223,5 +231,5 @@ bool Device::closeDevice( bool b) { // sdfd=0; // sd=0; - qDebug("closed dsp"); +// qDebug("closed dsp"); return true; } @@ -291,5 +299,5 @@ int Device::getDeviceRate() { int Device::getDeviceBits() { int dBits=0; -#if !defined(OPIE_NO_SOUND_PCM_READ_BITS) // zaurus doesnt have this +#ifndef QT_QWS_EBX // zaurus doesnt have this if (ioctl( sd, SOUND_PCM_READ_BITS, &dBits) == -1) { perror("ioctl(\"SNDCTL_PCM_READ_BITS\")"); @@ -309,9 +317,10 @@ int Device::getDeviceChannels() { int Device::getDeviceFragSize() { int frag_size; - + if (ioctl( sd, SNDCTL_DSP_GETBLKSIZE, &frag_size) == -1) { qDebug("no fragsize"); - } else + } else { qDebug("driver says frag size is %d", frag_size); + } return frag_size; } @@ -334,2 +343,16 @@ bool Device::reset() { return true; } + +int Device::devRead(int soundDescriptor, short *buf, int size) { + int number = 0; + number = ::read( soundDescriptor, (char *)buf, size); + return number; +} + +int Device::devWrite(int soundDescriptor, short * buf, int size) { + int bytesWritten = 0; + bytesWritten = ::write( soundDescriptor, buf, size); + return bytesWritten; +} + + |