comparison libao2/ao_oss.c @ 3319:66134af21278

fixed to check that SNDCTL_DSP_CHANNELS actually grants the requested number of channels
author steve
date Tue, 04 Dec 2001 17:54:08 +0000
parents c8edb0691f09
children 921a78c7b4aa
comparison
equal deleted inserted replaced
3318:a3739b590cf2 3319:66134af21278
127 127
128 if(format != AFMT_AC3) { 128 if(format != AFMT_AC3) {
129 // We only use SNDCTL_DSP_CHANNELS for >2 channels, in case some drivers don't have it 129 // We only use SNDCTL_DSP_CHANNELS for >2 channels, in case some drivers don't have it
130 ao_data.channels = channels; 130 ao_data.channels = channels;
131 if (ao_data.channels > 2) { 131 if (ao_data.channels > 2) {
132 if (ioctl (audio_fd, SNDCTL_DSP_CHANNELS, &ao_data.channels) == -1) { 132 if ( ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &ao_data.channels) == -1 ||
133 printf("audio_setup: Failed to set audio device to %d channels\n", ao_data.channels); 133 ao_data.channels != channels ) {
134 printf("audio_setup: Failed to set audio device to %d channels\n", channels);
134 return 0; 135 return 0;
135 } 136 }
136 } 137 }
137 else { 138 else {
138 int c = ao_data.channels-1; 139 int c = ao_data.channels-1;
139 if (ioctl (audio_fd, SNDCTL_DSP_STEREO, &c) == -1) { 140 if (ioctl (audio_fd, SNDCTL_DSP_STEREO, &c) == -1) {
140 printf("audio_setup: Failed to set audio device to %d channels\n", ao_data.channels); 141 printf("audio_setup: Failed to set audio device to %d channels\n", ao_data.channels);
141 return 0; 142 return 0;
142 } 143 }
143 } 144 }
144 printf("audio_setup: using %d channels (requested: %d)\n", ao_data.channels, ao_data.channels); 145 printf("audio_setup: using %d channels (requested: %d)\n", ao_data.channels, channels);
145 // set rate 146 // set rate
146 ao_data.samplerate=rate; 147 ao_data.samplerate=rate;
147 ioctl (audio_fd, SNDCTL_DSP_SPEED, &ao_data.samplerate); 148 ioctl (audio_fd, SNDCTL_DSP_SPEED, &ao_data.samplerate);
148 printf("audio_setup: using %d Hz samplerate (requested: %d)\n",ao_data.samplerate,rate); 149 printf("audio_setup: using %d Hz samplerate (requested: %d)\n",ao_data.samplerate,rate);
149 } 150 }