summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opierec/device.cpp
Side-by-side diff
Diffstat (limited to 'noncore/multimedia/opierec/device.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opierec/device.cpp16
1 files changed, 10 insertions, 6 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
@@ -49,56 +49,59 @@
#endif
Device::Device( QObject * parent, bool record )
: QObject( parent)
{
// 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");
cfg.setGroup("Volume");
return cfg.readNumEntry("Mic");
}
int Device::getOutVolume( ) {
@@ -141,24 +144,25 @@ bool Device::selectMicInput() {
} else {
if( ioctl( md, SOUND_MIXER_WRITE_RECSRC, &info) == -1)
perror("ioctl(\"SOUND_MIXER_WRITE_RECSRC\")");
::close(md);
return false;
}
::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 );
if (ioctl( sd, SNDCTL_DSP_SETFMT, &form)==-1) { //set format
perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
return false;
}
devRes=form;
return true;