summaryrefslogtreecommitdiff
authorzecke <zecke>2003-10-07 13:02:55 (UTC)
committer zecke <zecke>2003-10-07 13:02:55 (UTC)
commit75f35445e9f3ec2f730f779d67f4189296bd9c5e (patch) (side-by-side diff)
tree58d137879aefe506af087f5a75e29f60b5aaae0a
parentd72a9cfe61cbc0910373e4604220021ebbcedaeb (diff)
downloadopie-75f35445e9f3ec2f730f779d67f4189296bd9c5e.zip
opie-75f35445e9f3ec2f730f779d67f4189296bd9c5e.tar.gz
opie-75f35445e9f3ec2f730f779d67f4189296bd9c5e.tar.bz2
instead of testing for QWS_EBX we now define OPIE_NO_SOUND_PCM_READ_BITS.
If your platform does not have that ioctl define it
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opierec/device.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/noncore/multimedia/opierec/device.cpp b/noncore/multimedia/opierec/device.cpp
index f9a80c5..11071d8 100644
--- a/noncore/multimedia/opierec/device.cpp
+++ b/noncore/multimedia/opierec/device.cpp
@@ -1,53 +1,53 @@
// device.cpp
#include "device.h"
#include <qpe/config.h>
#include <qpe/qcopenvelope_qws.h>
-
+#include <qpe/custom.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#include <unistd.h>
#include<sys/wait.h>
// #include <sys/stat.h>
// #include <sys/time.h>
// #include <sys/types.h>
#include <unistd.h>
#include <errno.h>
//extern QtRec *qperec;
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
qDebug("setting up DSP for playing");
flags = O_WRONLY;
} else { //recording
qDebug("setting up DSP for recording");
flags = O_RDWR;
// flags = O_RDONLY;
selectMicInput();
}
}
bool Device::openDsp() {
if( openDevice( flags) == -1) {
perror("<<<<<<<<<<<<<<ioctl(\"Open device\")");
return false;
}
return true;
}
int Device::getOutVolume( ) {
@@ -123,104 +123,104 @@ bool Device::selectMicInput() {
if( ioctl( md, SOUND_MIXER_WRITE_RECSRC, &info) == -1)
perror("ioctl(\"SOUND_MIXER_WRITE_RECSRC\")");
::close(md);
return false;
}
::close(md);
*/
return true;
}
int Device::openDevice( int flags) {
/* pid_t pid;
int status;
int pipefd[2];
char message[20];
if (pipe(pipefd) == -1){
perror ("Error creating pipe");
exit(1);
}
switch (pid = fork()) {
case -1:
perror("The fork failed!");
break;
case 0: {
- */
+ */
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);
return -1;
}
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(ioctl(sd,SNDCTL_DSP_RESET,0)<0){
perror("ioctl RESET");
}
// sprintf(message, "%d", sd);
/* QFile f1("/pid");
f1.open(IO_WriteOnly );
f1.writeBlock(message, strlen(message));
f1.close();
*/
/* close(pipefd[0]);
write(pipefd[1], message, sizeof(message));
close(pipefd[1]);
// qDebug("%d",soundDevice->sd );
_exit(0);
}
default:
- // pid greater than zero is parent getting the child's pid
+ // pid greater than zero is parent getting the child's pid
printf("Child's pid is %d\n",pid);
QString s;
close(pipefd[1]);
read(pipefd[0], message, sizeof(message));
s = message;
close(pipefd[0]);
-
+
// while(wait(NULL)!=pid)
// ;
printf("child %ld terminated normally, return status is zero\n", (long) pid);
*/
// filePara.sd=(long) pid;
/* QFile f2("/pid");
f2.open(IO_ReadOnly);
QTextStream t(&f2);
// for(int f=0; f < t.atEnd() ;f++) {
s = t.readLine();
// }
*/
// bool ok;
// sd = s.toInt(&ok, 10);
// qDebug("<<<<<<<<<<<<<>>>>>>>>>>>>"+s);
-
+
// f2.close();
// }
::close(mixerHandle );
qDebug("open device %s", dspstr);
qDebug("success! %d",sd);
return sd;
}
bool Device::closeDevice( bool b) {
// if(b) {//close now
// if (ioctl( sd, SNDCTL_DSP_RESET, 0) == -1) {
// perror("ioctl(\"SNDCTL_DSP_RESET\")");
// }
// } else { //let play
// if (ioctl( sd, SNDCTL_DSP_SYNC, 0) == -1) {
// perror("ioctl(\"SNDCTL_DSP_SYNC\")");
// }
// }
::close( sd); //close sound device
// sdfd=0;
// sd=0;
qDebug("closed dsp");
return true;
@@ -269,67 +269,67 @@ int Device::getFormat() {
int Device::getRate() {
return devRate;
}
int Device::getChannels() {
return devCh;
}
int Device::getDeviceFormat() {
return 0;
}
int Device::getDeviceRate() {
int dRate=0;
if (ioctl( sd, SOUND_PCM_READ_RATE, &dRate) == -1) {
perror("ioctl(\"SNDCTL_PCM_READ_RATE\")");
}
return dRate;
}
int Device::getDeviceBits() {
int dBits=0;
-#ifndef QT_QWS_EBX // zaurus doesnt have this
+#if !defined(OPIE_NO_SOUND_PCM_READ_BITS) // zaurus doesnt have this
if (ioctl( sd, SOUND_PCM_READ_BITS, &dBits) == -1) {
perror("ioctl(\"SNDCTL_PCM_READ_BITS\")");
}
#endif
return dBits;
}
int Device::getDeviceChannels() {
int dCh=0;
if (ioctl( sd, SOUND_PCM_READ_CHANNELS, &dCh) == -1) {
perror("ioctl(\"SNDCTL_PCM_READ_CHANNELS\")");
}
return dCh;
}
int Device::getDeviceFragSize() {
int frag_size;
-
+
if (ioctl( sd, SNDCTL_DSP_GETBLKSIZE, &frag_size) == -1) {
qDebug("no fragsize");
} else
qDebug("driver says frag size is %d", frag_size);
return frag_size;
}
bool Device::setFragSize(int frag) {
if (ioctl(sd, SNDCTL_DSP_SETFRAGMENT, &frag)) {
perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")");
return false;
}
return true;
}
bool Device::reset() {
closeDevice(true);
openDsp();
if (ioctl( sd, SNDCTL_DSP_RESET, 0) == -1) {
perror("ioctl(\"SNDCTL_DSP_RESET\")");
return false;
}
return true;
}