summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer
authorllornkcor <llornkcor>2002-06-17 23:09:38 (UTC)
committer llornkcor <llornkcor>2002-06-17 23:09:38 (UTC)
commit554f88d0e8839bd6112fa42139a967712552e519 (patch) (unidiff)
treed90788c9247f35ee10a1cdd8df0408b1df2a7e57 /core/multimedia/opieplayer
parent28400a31238af793fe235a0c8d13131eb823037d (diff)
downloadopie-554f88d0e8839bd6112fa42139a967712552e519.zip
opie-554f88d0e8839bd6112fa42139a967712552e519.tar.gz
opie-554f88d0e8839bd6112fa42139a967712552e519.tar.bz2
fixed volume fix
Diffstat (limited to 'core/multimedia/opieplayer') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiodevice.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp
index 4c5f12d..faadd72 100644
--- a/core/multimedia/opieplayer/audiodevice.cpp
+++ b/core/multimedia/opieplayer/audiodevice.cpp
@@ -125,99 +125,99 @@ void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume
125//#endif 125//#endif
126} 126}
127 127
128 128
129void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) { 129void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) {
130 AudioDevicePrivate::muted = muted; 130 AudioDevicePrivate::muted = muted;
131 if ( muted ) { 131 if ( muted ) {
132 AudioDevicePrivate::leftVolume = leftVolume; 132 AudioDevicePrivate::leftVolume = leftVolume;
133 AudioDevicePrivate::rightVolume = rightVolume; 133 AudioDevicePrivate::rightVolume = rightVolume;
134 leftVolume = 0; 134 leftVolume = 0;
135 rightVolume = 0; 135 rightVolume = 0;
136 } else { 136 } else {
137 leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume ); 137 leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume );
138 rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume ); 138 rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume );
139 } 139 }
140// #ifdef Q_OS_WIN32 140// #ifdef Q_OS_WIN32
141// HWAVEOUT handle; 141// HWAVEOUT handle;
142// WAVEFORMATEX formatData; 142// WAVEFORMATEX formatData;
143// formatData.cbSize = sizeof(WAVEFORMATEX); 143// formatData.cbSize = sizeof(WAVEFORMATEX);
144// formatData.wFormatTag = WAVE_FORMAT_PCM; 144// formatData.wFormatTag = WAVE_FORMAT_PCM;
145// formatData.nAvgBytesPerSec = 4 * 44000; 145// formatData.nAvgBytesPerSec = 4 * 44000;
146// formatData.nBlockAlign = 4; 146// formatData.nBlockAlign = 4;
147// formatData.nChannels = 2; 147// formatData.nChannels = 2;
148// formatData.nSamplesPerSec = 44000; 148// formatData.nSamplesPerSec = 44000;
149// formatData.wBitsPerSample = 16; 149// formatData.wBitsPerSample = 16;
150// waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); 150// waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL);
151// unsigned int volume = (rightVolume << 16) | leftVolume; 151// unsigned int volume = (rightVolume << 16) | leftVolume;
152// if ( waveOutSetVolume( handle, volume ) ) 152// if ( waveOutSetVolume( handle, volume ) )
153// // qDebug( "set volume of audio device failed" ); 153// // qDebug( "set volume of audio device failed" );
154// waveOutClose( handle ); 154// waveOutClose( handle );
155// #else 155// #else
156 // Volume can be from 0 to 100 which is 101 distinct values 156 // Volume can be from 0 to 100 which is 101 distinct values
157 unsigned int rV = (rightVolume * 101) >> 16; 157 unsigned int rV = (rightVolume * 101) >> 16;
158 158
159# if 0 159# if 0
160 unsigned int lV = (leftVolume * 101) >> 16; 160 unsigned int lV = (leftVolume * 101) >> 16;
161 unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF); 161 unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF);
162 int mixerHandle = 0; 162 int mixerHandle = 0;
163 if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 163 if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
164 if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1) 164 if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1)
165 perror("ioctl(\"MIXER_WRITE\")"); 165 perror("ioctl(\"MIXER_WRITE\")");
166 close( mixerHandle ); 166 close( mixerHandle );
167 } else 167 } else
168 perror("open(\"/dev/mixer\")"); 168 perror("open(\"/dev/mixer\")");
169 169
170# else 170# else
171 // This is the way this has to be done now I guess, doesn't allow for 171 // This is the way this has to be done now I guess, doesn't allow for
172 // independant right and left channel setting, or setting for different outputs 172 // independant right and left channel setting, or setting for different outputs
173 Config cfg("Sound"); 173 Config cfg("qpe"); // qtopia is "Sound"
174 cfg.setGroup("System"); 174 cfg.setGroup("Volume"); // qtopia is "Settings"
175 cfg.writeEntry("Volume",(int)rV); 175 cfg.writeEntry("VolumePercent",(int)rV); //qtopia is Volume
176# endif 176# endif
177 177
178//#endif 178//#endif
179// qDebug( "setting volume to: 0x%x", volume ); 179// qDebug( "setting volume to: 0x%x", volume );
180#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 180#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
181 // Send notification that the volume has changed 181 // Send notification that the volume has changed
182 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; 182 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted;
183#endif 183#endif
184} 184}
185 185
186 186
187 187
188 188
189AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { 189AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
190 qDebug("creating new audio device"); 190 qDebug("creating new audio device");
191 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; 191 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE;
192 d = new AudioDevicePrivate; 192 d = new AudioDevicePrivate;
193 d->frequency = f; 193 d->frequency = f;
194 d->channels = chs; 194 d->channels = chs;
195 d->bytesPerSample = bps; 195 d->bytesPerSample = bps;
196 qDebug("%d",bps); 196 qDebug("%d",bps);
197 int format=0; 197 int format=0;
198 if( bps == 8) format = AFMT_U8; 198 if( bps == 8) format = AFMT_U8;
199 else if( bps <= 0) format = AFMT_S16_LE; 199 else if( bps <= 0) format = AFMT_S16_LE;
200 else format = AFMT_S16_LE; 200 else format = AFMT_S16_LE;
201 qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format); 201 qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format);
202 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); 202 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) );
203 203
204 int fragments = 0x10000 * 8 + sound_fragment_shift; 204 int fragments = 0x10000 * 8 + sound_fragment_shift;
205 int capabilities = 0; 205 int capabilities = 0;
206 206
207 207
208#ifdef KEEP_DEVICE_OPEN 208#ifdef KEEP_DEVICE_OPEN
209 if ( AudioDevicePrivate::dspFd == 0 ) { 209 if ( AudioDevicePrivate::dspFd == 0 ) {
210#endif 210#endif
211 if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { 211 if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) {
212 perror("open(\"/dev/dsp\") sending to /dev/null instead"); 212 perror("open(\"/dev/dsp\") sending to /dev/null instead");
213 d->handle = ::open( "/dev/null", O_WRONLY ); 213 d->handle = ::open( "/dev/null", O_WRONLY );
214 } 214 }
215#ifdef KEEP_DEVICE_OPEN 215#ifdef KEEP_DEVICE_OPEN
216 AudioDevicePrivate::dspFd = d->handle; 216 AudioDevicePrivate::dspFd = d->handle;
217 } else { 217 } else {
218 d->handle = AudioDevicePrivate::dspFd; 218 d->handle = AudioDevicePrivate::dspFd;
219 } 219 }
220#endif 220#endif
221 221
222 if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1) 222 if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1)
223 perror("ioctl(\"SNDCTL_DSP_GETCAPS\")"); 223 perror("ioctl(\"SNDCTL_DSP_GETCAPS\")");