summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opierec/device.cpp
Unidiff
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 @@
49 49
50#endif 50#endif
51 51
52Device::Device( QObject * parent, bool record ) 52Device::Device( QObject * parent, bool record )
53 : QObject( parent) 53 : QObject( parent)
54{ 54{
55// dspstr = dsp; 55// dspstr = dsp;
56 devForm = -1; 56 devForm = -1;
57 devCh = -1; 57 devCh = -1;
58 devRate = -1; 58 devRate = -1;
59 59
60 if( !record){ //playing 60 if( !record){ //playing
61 owarn << "setting up DSP for playing" << oendl; 61 owarn << "New Sound device DSP for playing" << oendl;
62 flags = O_WRONLY; 62 flags = O_RDWR;
63// flags = O_WRONLY;
63 } else { //recording 64 } else { //recording
64 owarn << "setting up DSP for recording" << oendl; 65 owarn << "New Sound device DSP for recording" << oendl;
65 flags = O_RDWR; 66 flags = O_RDWR;
66// flags = O_RDONLY; 67// flags = O_RDONLY;
67 selectMicInput(); 68 selectMicInput();
68 } 69 }
69} 70}
70 71
71bool Device::openDsp() { 72bool Device::openDsp() {
73 qWarning("Device::openDsp()");
72 if( openDevice( flags) == -1) { 74 if( openDevice( flags) == -1) {
73 perror("<<<<<<<<<<<<<<ioctl(\"Open device\")"); 75 perror("<<<<<<<<<<<<<<ioctl(\"Open device\")");
74 return false; 76 return false;
75 } 77 }
76 return true; 78 return true;
77} 79}
78 80
79int Device::openDevice( int flags) { 81int Device::openDevice( int flags) {
80 owarn << "Opening"<< dspstr; 82 owarn << "Opening sound device:"<< DSPSTROUT << oendl;
81 83
82 if (( sd = ::open( DSPSTROUT, flags)) == -1) { 84 if (( sd = ::open( DSPSTROUT, O_RDWR)) == -1) {
83 perror("open(\"/dev/dsp\")"); 85 perror("open(\"/dev/dsp\")\n");
84 QString errorMsg="Could not open audio device\n /dev/dsp\n" 86 QString errorMsg="Could not open audio device\n /dev/dsp\n"
85 +(QString)strerror(errno); 87 +(QString)strerror(errno);
86 qDebug( "XXXXXXXXXXXXXXXXXXXXXXX "+errorMsg ); 88 qDebug( "XXXXXXXXXXXXXXXXXXXXXXX "+errorMsg );
87 return -1; 89 return -1;
88 } 90 }
89 91
90 if(ioctl(sd,SNDCTL_DSP_RESET,0)<0){ 92 if(ioctl(sd,SNDCTL_DSP_RESET,0)<0){
91 perror("ioctl RESET"); 93 perror("ioctl RESET");
92 } 94 }
95 qWarning("opened!");
93 return sd; 96 return sd;
94} 97}
95 98
96int Device::getInVolume() { 99int Device::getInVolume() {
97 unsigned int volume = 0; 100 unsigned int volume = 0;
98 Config cfg("qpe"); 101 Config cfg("qpe");
99 cfg.setGroup("Volume"); 102 cfg.setGroup("Volume");
100 103
101 return cfg.readNumEntry("Mic"); 104 return cfg.readNumEntry("Mic");
102} 105}
103 106
104int Device::getOutVolume( ) { 107int Device::getOutVolume( ) {
@@ -141,24 +144,25 @@ bool Device::selectMicInput() {
141 } else { 144 } else {
142 if( ioctl( md, SOUND_MIXER_WRITE_RECSRC, &info) == -1) 145 if( ioctl( md, SOUND_MIXER_WRITE_RECSRC, &info) == -1)
143 perror("ioctl(\"SOUND_MIXER_WRITE_RECSRC\")"); 146 perror("ioctl(\"SOUND_MIXER_WRITE_RECSRC\")");
144 ::close(md); 147 ::close(md);
145 return false; 148 return false;
146 } 149 }
147 ::close(md); 150 ::close(md);
148 151
149 return true; 152 return true;
150} 153}
151 154
152bool Device::closeDevice( bool) { 155bool Device::closeDevice( bool) {
156 if(sd)
153 ::close( sd); //close sound device 157 ::close( sd); //close sound device
154 return true; 158 return true;
155} 159}
156 160
157bool Device::setDeviceFormat( int form) { 161bool Device::setDeviceFormat( int form) {
158 qDebug( "set device res %d: %d ",form, sd ); 162 qDebug( "set device res %d: %d ",form, sd );
159 if (ioctl( sd, SNDCTL_DSP_SETFMT, &form)==-1) { //set format 163 if (ioctl( sd, SNDCTL_DSP_SETFMT, &form)==-1) { //set format
160 perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); 164 perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
161 return false; 165 return false;
162 } 166 }
163 devRes=form; 167 devRes=form;
164 return true; 168 return true;