summaryrefslogtreecommitdiff
authorschurig <schurig>2004-09-10 12:34:40 (UTC)
committer schurig <schurig>2004-09-10 12:34:40 (UTC)
commit85928a3781d9a91b58ea414c0d7982459cc21920 (patch) (unidiff)
tree10aeedf3a79fe2372c55bda730b6913b5562231b
parent9d0ccc1c5ca687bc017b2b515a9d3a47e98ce521 (diff)
downloadopie-85928a3781d9a91b58ea414c0d7982459cc21920.zip
opie-85928a3781d9a91b58ea414c0d7982459cc21920.tar.gz
opie-85928a3781d9a91b58ea414c0d7982459cc21920.tar.bz2
support for DEVFS
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp4
-rw-r--r--noncore/multimedia/opierec/device.cpp16
-rw-r--r--noncore/multimedia/opierec/qtrec.cpp7
3 files changed, 27 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 7b4bfd9..e6afbd8 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -260,49 +260,53 @@ void MediaPlayer::timerEvent( QTimerEvent * ) {
260 drawnOnScreenDisplay = TRUE; 260 drawnOnScreenDisplay = TRUE;
261 onScreenDisplayVolume = v; 261 onScreenDisplayVolume = v;
262 QPainter p( videoUI() ); 262 QPainter p( videoUI() );
263 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 263 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
264 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 264 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
265 265
266 QFont f; 266 QFont f;
267 f.setPixelSize( 20 ); 267 f.setPixelSize( 20 );
268 f.setBold( TRUE ); 268 f.setBold( TRUE );
269 p.setFont( f ); 269 p.setFont( f );
270 p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); 270 p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) );
271 271
272 for ( unsigned int i = 0; i < 10; i++ ) { 272 for ( unsigned int i = 0; i < 10; i++ ) {
273 if ( v > i ) { 273 if ( v > i ) {
274 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 274 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
275 } else { 275 } else {
276 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 276 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
277 } 277 }
278 } 278 }
279 } 279 }
280} 280}
281 281
282 282
283void MediaPlayer::blank( bool b ) { 283void MediaPlayer::blank( bool b ) {
284#ifdef QT_QWS_DEVFS
285 fd=open("/dev/fb/0",O_RDWR);
286#else
284 fd=open("/dev/fb0",O_RDWR); 287 fd=open("/dev/fb0",O_RDWR);
288#endif
285#ifdef QT_QWS_SL5XXX 289#ifdef QT_QWS_SL5XXX
286 fl= open( "/dev/fl", O_RDWR ); 290 fl= open( "/dev/fl", O_RDWR );
287#endif 291#endif
288 if (fd != -1) { 292 if (fd != -1) {
289 if ( b ) { 293 if ( b ) {
290 odebug << "do blanking" << oendl; 294 odebug << "do blanking" << oendl;
291#ifdef QT_QWS_SL5XXX 295#ifdef QT_QWS_SL5XXX
292 ioctl( fd, FBIOBLANK, 1 ); 296 ioctl( fd, FBIOBLANK, 1 );
293 if(fl !=-1) { 297 if(fl !=-1) {
294 ioctl( fl, 2 ); 298 ioctl( fl, 2 );
295 ::close(fl); 299 ::close(fl);
296 } 300 }
297#else 301#else
298 ioctl( fd, FBIOBLANK, 3 ); 302 ioctl( fd, FBIOBLANK, 3 );
299#endif 303#endif
300 isBlanked = TRUE; 304 isBlanked = TRUE;
301 } else { 305 } else {
302 odebug << "do unblanking" << oendl; 306 odebug << "do unblanking" << oendl;
303 ioctl( fd, FBIOBLANK, 0); 307 ioctl( fd, FBIOBLANK, 0);
304#ifdef QT_QWS_SL5XXX 308#ifdef QT_QWS_SL5XXX
305 if(fl != -1) { 309 if(fl != -1) {
306 ioctl( fl, 1); 310 ioctl( fl, 1);
307 ::close(fl); 311 ::close(fl);
308 } 312 }
diff --git a/noncore/multimedia/opierec/device.cpp b/noncore/multimedia/opierec/device.cpp
index 683f0a5..cb47b77 100644
--- a/noncore/multimedia/opierec/device.cpp
+++ b/noncore/multimedia/opierec/device.cpp
@@ -54,49 +54,53 @@ int Device::openDevice( int flags) {
54 int status; 54 int status;
55 int pipefd[2]; 55 int pipefd[2];
56 char message[20]; 56 char message[20];
57 if (pipe(pipefd) == -1){ 57 if (pipe(pipefd) == -1){
58 perror ("Error creating pipe"); 58 perror ("Error creating pipe");
59exit(1); 59exit(1);
60 } 60 }
61 switch (pid = fork()) { 61 switch (pid = fork()) {
62 case -1: 62 case -1:
63 perror("The fork failed!"); 63 perror("The fork failed!");
64 break; 64 break;
65 case 0: { 65 case 0: {
66 */ 66 */
67qDebug( "Opening %s",dspstr); 67qDebug( "Opening %s",dspstr);
68 if (( sd = ::open( dspstr, flags)) == -1) { 68 if (( sd = ::open( dspstr, flags)) == -1) {
69 perror("open(\"/dev/dsp\")"); 69 perror("open(\"/dev/dsp\")");
70 QString errorMsg="Could not open audio device\n /dev/dsp\n" 70 QString errorMsg="Could not open audio device\n /dev/dsp\n"
71 +(QString)strerror(errno); 71 +(QString)strerror(errno);
72 qDebug( "XXXXXXXXXXXXXXXXXXXXXXX "+errorMsg ); 72 qDebug( "XXXXXXXXXXXXXXXXXXXXXXX "+errorMsg );
73 return -1; 73 return -1;
74 } 74 }
75 75
76qDebug( "Opening mixer" ); 76qDebug( "Opening mixer" );
77 int mixerHandle=0; 77 int mixerHandle=0;
78#ifdef QT_QWS_DEVFS
79 if (( mixerHandle = open("/dev/sound/mixer",O_RDWR))<0) {
80#else
78 if (( mixerHandle = open("/dev/mixer",O_RDWR))<0) { 81 if (( mixerHandle = open("/dev/mixer",O_RDWR))<0) {
82#endif
79 perror("open(\"/dev/mixer\")"); 83 perror("open(\"/dev/mixer\")");
80 QString errorMsg="Could not open audio device\n /dev/dsp\n" 84 QString errorMsg="Could not open audio device\n /dev/dsp\n"
81 +(QString)strerror(errno); 85 +(QString)strerror(errno);
82 qDebug( "XXXXXXXXXXXXXXXXXXXXXX "+errorMsg ); 86 qDebug( "XXXXXXXXXXXXXXXXXXXXXX "+errorMsg );
83 } 87 }
84 88
85 if(ioctl(sd,SNDCTL_DSP_RESET,0)<0){ 89 if(ioctl(sd,SNDCTL_DSP_RESET,0)<0){
86 perror("ioctl RESET"); 90 perror("ioctl RESET");
87 } 91 }
88// sprintf(message, "%d", sd); 92// sprintf(message, "%d", sd);
89 93
90/* QFile f1("/pid"); 94/* QFile f1("/pid");
91 f1.open(IO_WriteOnly ); 95 f1.open(IO_WriteOnly );
92 f1.writeBlock(message, strlen(message)); 96 f1.writeBlock(message, strlen(message));
93 f1.close(); 97 f1.close();
94 */ 98 */
95 /* close(pipefd[0]); 99 /* close(pipefd[0]);
96 write(pipefd[1], message, sizeof(message)); 100 write(pipefd[1], message, sizeof(message));
97 close(pipefd[1]); 101 close(pipefd[1]);
98 // qDebug( "" + soundDevice->sd ); 102 // qDebug( "" + soundDevice->sd );
99 _exit(0); 103 _exit(0);
100 } 104 }
101 default: 105 default:
102 // pid greater than zero is parent getting the child's pid 106 // pid greater than zero is parent getting the child's pid
@@ -147,81 +151,93 @@ int Device::getOutVolume( ) {
147 cfg.setGroup("Volume"); 151 cfg.setGroup("Volume");
148 152
149 return cfg.readNumEntry("VolumePercent"); 153 return cfg.readNumEntry("VolumePercent");
150} 154}
151 155
152int Device::getInVolume() { 156int Device::getInVolume() {
153 unsigned int volume=0; 157 unsigned int volume=0;
154 int mixerHandle = ::open( mixstr, O_RDWR ); 158 int mixerHandle = ::open( mixstr, O_RDWR );
155 if ( mixerHandle >= 0 ) { 159 if ( mixerHandle >= 0 ) {
156 if(ioctl( mixerHandle, MIXER_READ(SOUND_MIXER_MIC), &volume )==-1) 160 if(ioctl( mixerHandle, MIXER_READ(SOUND_MIXER_MIC), &volume )==-1)
157 perror("<<<<<<<<<<<<<<<ioctl(\"MIXER_READ\")"); 161 perror("<<<<<<<<<<<<<<<ioctl(\"MIXER_READ\")");
158 ::close( mixerHandle ); 162 ::close( mixerHandle );
159 } else 163 } else
160 perror("open(\"/dev/mixer\")"); 164 perror("open(\"/dev/mixer\")");
161 printf("<<<<<<<<<<<<<<input volume %d\n", volume ); 165 printf("<<<<<<<<<<<<<<input volume %d\n", volume );
162 Config cfg("qpe"); 166 Config cfg("qpe");
163 cfg.setGroup("Volume"); 167 cfg.setGroup("Volume");
164 168
165 return cfg.readNumEntry("Mic"); 169 return cfg.readNumEntry("Mic");
166} 170}
167 171
168void Device::changedOutVolume(int vol) { 172void Device::changedOutVolume(int vol) {
169 int level = (vol << 8) + vol; 173 int level = (vol << 8) + vol;
170 int fd = 0; 174 int fd = 0;
175#ifdef QT_QWS_DEVFS
176 if ((fd = open("/dev/sound/mixer", O_RDWR))>=0) {
177#else
171 if ((fd = open("/dev/mixer", O_RDWR))>=0) { 178 if ((fd = open("/dev/mixer", O_RDWR))>=0) {
179#endif
172 if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_VOLUME), &level) == -1) 180 if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_VOLUME), &level) == -1)
173 perror("ioctl(\"MIXER_IN_WRITE\")"); 181 perror("ioctl(\"MIXER_IN_WRITE\")");
174 182
175 Config cfg("qpe"); 183 Config cfg("qpe");
176 cfg.setGroup("Volume"); 184 cfg.setGroup("Volume");
177 cfg.writeEntry("VolumePercent", QString::number( vol )); 185 cfg.writeEntry("VolumePercent", QString::number( vol ));
178 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; 186 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false;
179 qDebug("changing output vol %d" ,vol ); 187 qDebug("changing output vol %d" ,vol );
180 } 188 }
181 ::close(fd); 189 ::close(fd);
182} 190}
183 191
184void Device::changedInVolume(int vol ) { 192void Device::changedInVolume(int vol ) {
185 int level = (vol << 8) + vol; 193 int level = (vol << 8) + vol;
186 int fd = 0; 194 int fd = 0;
195#ifdef QT_QWS_DEVFS
196 if ((fd = open("/dev/sound/mixer", O_RDWR))>=0) {
197#else
187 if ((fd = open("/dev/mixer", O_RDWR))>=0) { 198 if ((fd = open("/dev/mixer", O_RDWR))>=0) {
199#endif
188 if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &level) == -1) 200 if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &level) == -1)
189 perror("ioctl(\"MIXER_IN_WRITE\")"); 201 perror("ioctl(\"MIXER_IN_WRITE\")");
190 Config cfg("qpe"); 202 Config cfg("qpe");
191 cfg.setGroup("Volume"); 203 cfg.setGroup("Volume");
192 cfg.writeEntry("Mic", QString::number(vol )); 204 cfg.writeEntry("Mic", QString::number(vol ));
193 QCopEnvelope( "QPE/System", "micChange(bool)" ) << false; 205 QCopEnvelope( "QPE/System", "micChange(bool)" ) << false;
194 qDebug("changing input volume %d",vol); 206 qDebug("changing input volume %d",vol);
195 } 207 }
196 ::close(fd); 208 ::close(fd);
197} 209}
198 210
199bool Device::selectMicInput() { 211bool Device::selectMicInput() {
200 212
201 int md=0; 213 int md=0;
202 int info=MIXER_WRITE(SOUND_MIXER_MIC); 214 int info=MIXER_WRITE(SOUND_MIXER_MIC);
215#ifdef QT_QWS_DEVFS
216 md = ::open( "/dev/sound/mixer", O_RDWR );
217#else
203 md = ::open( "/dev/mixer", O_RDWR ); 218 md = ::open( "/dev/mixer", O_RDWR );
219#endif
204 if ( md == -1) 220 if ( md == -1)
205 perror("open(\"/dev/mixer\")"); 221 perror("open(\"/dev/mixer\")");
206 else { 222 else {
207 if( ioctl( md, SOUND_MIXER_WRITE_RECSRC, &info) == -1) 223 if( ioctl( md, SOUND_MIXER_WRITE_RECSRC, &info) == -1)
208 perror("ioctl(\"SOUND_MIXER_WRITE_RECSRC\")"); 224 perror("ioctl(\"SOUND_MIXER_WRITE_RECSRC\")");
209 ::close(md); 225 ::close(md);
210 return false; 226 return false;
211 } 227 }
212 ::close(md); 228 ::close(md);
213 229
214 return true; 230 return true;
215} 231}
216 232
217bool Device::closeDevice( bool) { 233bool Device::closeDevice( bool) {
218// if(b) {//close now 234// if(b) {//close now
219// if (ioctl( sd, SNDCTL_DSP_RESET, 0) == -1) { 235// if (ioctl( sd, SNDCTL_DSP_RESET, 0) == -1) {
220// perror("ioctl(\"SNDCTL_DSP_RESET\")"); 236// perror("ioctl(\"SNDCTL_DSP_RESET\")");
221// } 237// }
222// } else { //let play 238// } else { //let play
223// if (ioctl( sd, SNDCTL_DSP_SYNC, 0) == -1) { 239// if (ioctl( sd, SNDCTL_DSP_SYNC, 0) == -1) {
224// perror("ioctl(\"SNDCTL_DSP_SYNC\")"); 240// perror("ioctl(\"SNDCTL_DSP_SYNC\")");
225// } 241// }
226// } 242// }
227 243
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp
index 1141faa..c237726 100644
--- a/noncore/multimedia/opierec/qtrec.cpp
+++ b/noncore/multimedia/opierec/qtrec.cpp
@@ -58,52 +58,59 @@ using namespace Opie::Core;
58#include <alsa/asoundlib.h> 58#include <alsa/asoundlib.h>
59static int deviceSampleRates[8] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, -1 }; 59static int deviceSampleRates[8] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, -1 };
60static int deviceBitRates[] = { 8, 16, 24, 32, -1 }; 60static int deviceBitRates[] = { 8, 16, 24, 32, -1 };
61#else //OSS 61#else //OSS
62static int deviceSampleRates[6] = { 11025, 16000, 22050, 32000, 44100, -1 }; 62static int deviceSampleRates[6] = { 11025, 16000, 22050, 32000, 44100, -1 };
63static int deviceBitRates[] = { 8, 16, -1 }; 63static int deviceBitRates[] = { 8, 16, -1 };
64#endif 64#endif
65 65
66#if defined(QT_QWS_SL5XXX) 66#if defined(QT_QWS_SL5XXX)
67///#if defined(QT_QWS_EBX) 67///#if defined(QT_QWS_EBX)
68 68
69#define DSPSTROUT "/dev/dsp" 69#define DSPSTROUT "/dev/dsp"
70#define DSPSTRMIXEROUT "/dev/mixer" 70#define DSPSTRMIXEROUT "/dev/mixer"
71 71
72#ifdef SHARP 72#ifdef SHARP
73#define DSPSTRIN "/dev/dsp1" 73#define DSPSTRIN "/dev/dsp1"
74#define DSPSTRMIXERIN "/dev/mixer1" 74#define DSPSTRMIXERIN "/dev/mixer1"
75#else 75#else
76#define DSPSTRIN "/dev/dsp" 76#define DSPSTRIN "/dev/dsp"
77#define DSPSTRMIXERIN "/dev/mixer" 77#define DSPSTRMIXERIN "/dev/mixer"
78#endif 78#endif
79 79
80#else 80#else
81 81
82#ifdef QT_QWS_DEVFS
83#define DSPSTROUT "/dev/sound/dsp"
84#define DSPSTRIN "/dev/sound/dsp"
85#define DSPSTRMIXERIN "/dev/sound/mixer"
86#define DSPSTRMIXEROUT "/dev/sound/mixer"
87#else
82#define DSPSTROUT "/dev/dsp" 88#define DSPSTROUT "/dev/dsp"
83#define DSPSTRIN "/dev/dsp" 89#define DSPSTRIN "/dev/dsp"
84#define DSPSTRMIXERIN "/dev/mixer" 90#define DSPSTRMIXERIN "/dev/mixer"
85#define DSPSTRMIXEROUT "/dev/mixer" 91#define DSPSTRMIXEROUT "/dev/mixer"
92#endif
86 93
87#endif 94#endif
88 95
89//#define ZAURUS 0 96//#define ZAURUS 0
90struct adpcm_state encoder_state; 97struct adpcm_state encoder_state;
91struct adpcm_state decoder_state; 98struct adpcm_state decoder_state;
92 99
93typedef struct { 100typedef struct {
94 int sampleRate; 101 int sampleRate;
95 /* int fragSize; */ 102 /* int fragSize; */
96 /* int blockSize; */ 103 /* int blockSize; */
97 int resolution; //bitrate 104 int resolution; //bitrate
98 int channels; //number of channels 105 int channels; //number of channels
99 int fd; //file descriptor 106 int fd; //file descriptor
100 int sd; //sound device descriptor 107 int sd; //sound device descriptor
101 int numberSamples; //total number of samples 108 int numberSamples; //total number of samples
102 int SecondsToRecord; // number of seconds that should be recorded 109 int SecondsToRecord; // number of seconds that should be recorded
103 float numberOfRecordedSeconds; //total number of samples recorded 110 float numberOfRecordedSeconds; //total number of samples recorded
104 int samplesToRecord; //number of samples to be recorded 111 int samplesToRecord; //number of samples to be recorded
105 int inVol; //input volume 112 int inVol; //input volume
106 int outVol; //output volume 113 int outVol; //output volume
107 int format; //wavfile format PCM.. ADPCM 114 int format; //wavfile format PCM.. ADPCM
108 const char *fileName; //name of fiel to be played/recorded 115 const char *fileName; //name of fiel to be played/recorded
109} fileParameters; 116} fileParameters;