summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2004-04-25 20:37:28 (UTC)
committer llornkcor <llornkcor>2004-04-25 20:37:28 (UTC)
commitae76c412a340a0808ed6ece5e4a8fbc04baa4ff3 (patch) (side-by-side diff)
treea086457c05142e1ac2749844ffcb458d96550c6f
parent22d51bcaa58b90a3ffd4d429c43e6c24e1694ab3 (diff)
downloadopie-ae76c412a340a0808ed6ece5e4a8fbc04baa4ff3.zip
opie-ae76c412a340a0808ed6ece5e4a8fbc04baa4ff3.tar.gz
opie-ae76c412a340a0808ed6ece5e4a8fbc04baa4ff3.tar.bz2
soundcard descriptor mucking about
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opierec/device.cpp46
1 files changed, 23 insertions, 23 deletions
diff --git a/noncore/multimedia/opierec/device.cpp b/noncore/multimedia/opierec/device.cpp
index 5319d97..db2d63f 100644
--- a/noncore/multimedia/opierec/device.cpp
+++ b/noncore/multimedia/opierec/device.cpp
@@ -23,22 +23,22 @@ using namespace Opie::Core;
Device::Device( QObject * parent, const char * dsp, const char * mixr, bool record )
: QObject( parent)
{
dspstr = (char *)dsp;
mixstr = (char *)mixr;
-
+
devForm=-1;
devCh=-1;
devRate=-1;
if( !record){ //playing
- odebug << "setting up DSP for playing" << oendl;
+ odebug << "setting up DSP for playing" << oendl;
flags = O_WRONLY;
} else { //recording
- odebug << "setting up DSP for recording" << oendl;
+ odebug << "setting up DSP for recording" << oendl;
flags = O_RDWR;
// flags = O_RDONLY;
// selectMicInput();
}
@@ -93,13 +93,13 @@ void Device::changedOutVolume(int vol) {
perror("ioctl(\"MIXER_IN_WRITE\")");
Config cfg("qpe");
cfg.setGroup("Volume");
cfg.writeEntry("VolumePercent", QString::number( vol ));
QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false;
- owarn << "changing output vol " << vol << "" << oendl;
+ owarn << "changing output vol " << vol << "" << oendl;
}
::close(fd);
}
void Device::changedInVolume(int vol ) {
int level = (vol << 8) + vol;
@@ -108,13 +108,13 @@ void Device::changedInVolume(int vol ) {
if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &level) == -1)
perror("ioctl(\"MIXER_IN_WRITE\")");
Config cfg("qpe");
cfg.setGroup("Volume");
cfg.writeEntry("Mic", QString::number(vol ));
QCopEnvelope( "QPE/System", "micChange(bool)" ) << false;
- owarn << "changing input volume " << vol << "" << oendl;
+ owarn << "changing input volume " << vol << "" << oendl;
}
::close(fd);
}
bool Device::selectMicInput() {
@@ -146,28 +146,28 @@ exit(1);
switch (pid = fork()) {
case -1:
perror("The fork failed!");
break;
case 0: {
*/
-odebug << "Opening " << dspstr << "" << oendl;
+odebug << "Opening " << dspstr << "" << oendl;
if (( sd = ::open( dspstr, flags)) == -1) {
perror("open(\"/dev/dsp\")");
QString errorMsg="Could not open audio device\n /dev/dsp\n"
+(QString)strerror(errno);
- odebug << "XXXXXXXXXXXXXXXXXXXXXXX "+errorMsg << oendl;
+ odebug << "XXXXXXXXXXXXXXXXXXXXXXX "+errorMsg << oendl;
return -1;
}
-odebug << "Opening mixer" << oendl;
+odebug << "Opening mixer" << oendl;
int mixerHandle=0;
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);
- odebug << "XXXXXXXXXXXXXXXXXXXXXX "+errorMsg << oendl;
+ odebug << "XXXXXXXXXXXXXXXXXXXXXX "+errorMsg << oendl;
}
if(ioctl(sd,SNDCTL_DSP_RESET,0)<0){
perror("ioctl RESET");
}
// sprintf(message, "%d", sd);
@@ -177,13 +177,13 @@ odebug << "Opening mixer" << oendl;
f1.writeBlock(message, strlen(message));
f1.close();
*/
/* close(pipefd[0]);
write(pipefd[1], message, sizeof(message));
close(pipefd[1]);
- // odebug << "" << soundDevice->sd << "" << oendl;
+ // odebug << "" << soundDevice->sd << "" << oendl;
_exit(0);
}
default:
// pid greater than zero is parent getting the child's pid
printf("Child's pid is %d\n",pid);
QString s;
@@ -203,19 +203,19 @@ odebug << "Opening mixer" << oendl;
// for(int f=0; f < t.atEnd() ;f++) {
s = t.readLine();
// }
*/
// bool ok;
// sd = s.toInt(&ok, 10);
-// odebug << "<<<<<<<<<<<<<>>>>>>>>>>>>"+s << oendl;
-
+// odebug << "<<<<<<<<<<<<<>>>>>>>>>>>>"+s << oendl;
+
// f2.close();
// }
::close(mixerHandle );
-// odebug << "open device " << dspstr << "" << oendl;
-// odebug << "success! " << sd << "" << oendl;
+// odebug << "open device " << dspstr << "" << oendl;
+// odebug << "success! " << sd << "" << oendl;
return sd;
}
bool Device::closeDevice( bool) {
// if(b) {//close now
// if (ioctl( sd, SNDCTL_DSP_RESET, 0) == -1) {
@@ -227,38 +227,38 @@ bool Device::closeDevice( bool) {
// }
// }
::close( sd); //close sound device
// sdfd=0;
// sd=0;
-// odebug << "closed dsp" << oendl;
+// odebug << "closed dsp" << oendl;
return true;
}
bool Device::setDeviceFormat( int form) {
- odebug << "set device res " << form << " " << sd << "" << oendl;
+ odebug << "set device res " << form << " " << sd << "" << oendl;
if (ioctl( sd, SNDCTL_DSP_SETFMT, &form)==-1) { //set format
perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
return false;
}
devRes=form;
return true;
}
bool Device::setDeviceChannels( int ch) {
- odebug << "set channels " << ch << " " << sd << "" << oendl;
+ odebug << "set channels " << ch << " " << sd << "" << oendl;
if (ioctl( sd, SNDCTL_DSP_CHANNELS, &ch)==-1) {
perror("ioctl(\"SNDCTL_DSP_CHANNELS\")");
return false;
}
devCh=ch;
return true;
}
bool Device::setDeviceRate( int rate) {
- odebug << "set rate " << rate << " " << sd << "" << oendl;
+ odebug << "set rate " << rate << " " << sd << "" << oendl;
if (ioctl( sd, SNDCTL_DSP_SPEED, &rate) == -1) {
perror("ioctl(\"SNDCTL_DSP_SPEED\")");
return false;
}
devRate=rate;
@@ -313,17 +313,17 @@ int Device::getDeviceChannels() {
}
return dCh;
}
int Device::getDeviceFragSize() {
int frag_size;
-
+
if (ioctl( sd, SNDCTL_DSP_GETBLKSIZE, &frag_size) == -1) {
- odebug << "no fragsize" << oendl;
+ odebug << "no fragsize" << oendl;
} else {
- odebug << "driver says frag size is " << frag_size << "" << oendl;
+ odebug << "driver says frag size is " << frag_size << "" << oendl;
}
return frag_size;
}
bool Device::setFragSize(int frag) {
if (ioctl(sd, SNDCTL_DSP_SETFRAGMENT, &frag)) {
@@ -342,17 +342,17 @@ bool Device::reset() {
}
return true;
}
int Device::devRead(int soundDescriptor, short *buf, int size) {
int number = 0;
- number = ::read( soundDescriptor, (char *)buf, size);
+ number = ::read( sd /*soundDescriptor*/, (char *)buf, size);
return number;
}
int Device::devWrite(int soundDescriptor, short * buf, int size) {
int bytesWritten = 0;
- bytesWritten = ::write( soundDescriptor, buf, size);
+ bytesWritten = ::write( sd /*soundDescriptor*/, buf, size);
return bytesWritten;
}