Diffstat (limited to 'core/multimedia/opieplayer/audiodevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/audiodevice.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp index 59136af..11fd9e8 100644 --- a/core/multimedia/opieplayer/audiodevice.cpp +++ b/core/multimedia/opieplayer/audiodevice.cpp | |||
@@ -100,25 +100,25 @@ void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume | |||
100 | #ifdef Q_OS_WIN32 | 100 | #ifdef Q_OS_WIN32 |
101 | HWAVEOUT handle; | 101 | HWAVEOUT handle; |
102 | WAVEFORMATEX formatData; | 102 | WAVEFORMATEX formatData; |
103 | formatData.cbSize = sizeof(WAVEFORMATEX); | 103 | formatData.cbSize = sizeof(WAVEFORMATEX); |
104 | formatData.wFormatTag = WAVE_FORMAT_PCM; | 104 | formatData.wFormatTag = WAVE_FORMAT_PCM; |
105 | formatData.nAvgBytesPerSec = 4 * 44000; | 105 | formatData.nAvgBytesPerSec = 4 * 44000; |
106 | formatData.nBlockAlign = 4; | 106 | formatData.nBlockAlign = 4; |
107 | formatData.nChannels = 2; | 107 | formatData.nChannels = 2; |
108 | formatData.nSamplesPerSec = 44000; | 108 | formatData.nSamplesPerSec = 44000; |
109 | formatData.wBitsPerSample = 16; | 109 | formatData.wBitsPerSample = 16; |
110 | waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); | 110 | waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); |
111 | if ( waveOutGetVolume( handle, (LPDWORD)&volume ) ) | 111 | if ( waveOutGetVolume( handle, (LPDWORD)&volume ) ) |
112 | qDebug( "get volume of audio device failed" ); | 112 | // qDebug( "get volume of audio device failed" ); |
113 | waveOutClose( handle ); | 113 | waveOutClose( handle ); |
114 | leftVolume = volume & 0xFFFF; | 114 | leftVolume = volume & 0xFFFF; |
115 | rightVolume = volume >> 16; | 115 | rightVolume = volume >> 16; |
116 | #else | 116 | #else |
117 | int mixerHandle = open( "/dev/mixer", O_RDWR ); | 117 | int mixerHandle = open( "/dev/mixer", O_RDWR ); |
118 | if ( mixerHandle >= 0 ) { | 118 | if ( mixerHandle >= 0 ) { |
119 | if(ioctl( mixerHandle, MIXER_READ(0), &volume )==-1) | 119 | if(ioctl( mixerHandle, MIXER_READ(0), &volume )==-1) |
120 | perror("ioctl(\"MIXER_READ\")"); | 120 | perror("ioctl(\"MIXER_READ\")"); |
121 | close( mixerHandle ); | 121 | close( mixerHandle ); |
122 | } else | 122 | } else |
123 | perror("open(\"/dev/mixer\")"); | 123 | perror("open(\"/dev/mixer\")"); |
124 | leftVolume = ((volume & 0x00FF) << 16) / 101; | 124 | leftVolume = ((volume & 0x00FF) << 16) / 101; |
@@ -142,25 +142,25 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, | |||
142 | HWAVEOUT handle; | 142 | HWAVEOUT handle; |
143 | WAVEFORMATEX formatData; | 143 | WAVEFORMATEX formatData; |
144 | formatData.cbSize = sizeof(WAVEFORMATEX); | 144 | formatData.cbSize = sizeof(WAVEFORMATEX); |
145 | formatData.wFormatTag = WAVE_FORMAT_PCM; | 145 | formatData.wFormatTag = WAVE_FORMAT_PCM; |
146 | formatData.nAvgBytesPerSec = 4 * 44000; | 146 | formatData.nAvgBytesPerSec = 4 * 44000; |
147 | formatData.nBlockAlign = 4; | 147 | formatData.nBlockAlign = 4; |
148 | formatData.nChannels = 2; | 148 | formatData.nChannels = 2; |
149 | formatData.nSamplesPerSec = 44000; | 149 | formatData.nSamplesPerSec = 44000; |
150 | formatData.wBitsPerSample = 16; | 150 | formatData.wBitsPerSample = 16; |
151 | waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); | 151 | waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); |
152 | unsigned int volume = (rightVolume << 16) | leftVolume; | 152 | unsigned int volume = (rightVolume << 16) | leftVolume; |
153 | if ( waveOutSetVolume( handle, volume ) ) | 153 | if ( waveOutSetVolume( handle, volume ) ) |
154 | qDebug( "set volume of audio device failed" ); | 154 | // qDebug( "set volume of audio device failed" ); |
155 | waveOutClose( handle ); | 155 | waveOutClose( handle ); |
156 | #else | 156 | #else |
157 | // Volume can be from 0 to 100 which is 101 distinct values | 157 | // Volume can be from 0 to 100 which is 101 distinct values |
158 | unsigned int rV = (rightVolume * 101) >> 16; | 158 | unsigned int rV = (rightVolume * 101) >> 16; |
159 | 159 | ||
160 | # if 0 | 160 | # if 0 |
161 | unsigned int lV = (leftVolume * 101) >> 16; | 161 | unsigned int lV = (leftVolume * 101) >> 16; |
162 | unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF); | 162 | unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF); |
163 | int mixerHandle = 0; | 163 | int mixerHandle = 0; |
164 | if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 164 | if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
165 | if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1) | 165 | if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1) |
166 | perror("ioctl(\"MIXER_WRITE\")"); | 166 | perror("ioctl(\"MIXER_WRITE\")"); |
@@ -183,31 +183,31 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, | |||
183 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; | 183 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; |
184 | #endif | 184 | #endif |
185 | } | 185 | } |
186 | 186 | ||
187 | 187 | ||
188 | 188 | ||
189 | 189 | ||
190 | AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { | 190 | AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { |
191 | d = new AudioDevicePrivate; | 191 | d = new AudioDevicePrivate; |
192 | d->frequency = f; | 192 | d->frequency = f; |
193 | d->channels = chs; | 193 | d->channels = chs; |
194 | d->bytesPerSample = bps; | 194 | d->bytesPerSample = bps; |
195 | qDebug("%d",bps); | 195 | // qDebug("%d",bps); |
196 | int format=0; | 196 | int format=0; |
197 | if( bps == 8) format = AFMT_U8; | 197 | if( bps == 8) format = AFMT_U8; |
198 | else if( bps <= 0) format = AFMT_S16_LE; | 198 | else if( bps <= 0) format = AFMT_S16_LE; |
199 | else format = AFMT_S16_LE; | 199 | else format = AFMT_S16_LE; |
200 | 200 | ||
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 | 204 | ||
205 | int fragments = 0x10000 * 8 + sound_fragment_shift; | 205 | int fragments = 0x10000 * 8 + sound_fragment_shift; |
206 | int capabilities = 0; | 206 | int capabilities = 0; |
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 ); |