espie caaef9a183 Erm... forgot the actual patch... why does cvs tell me about missing files
after the commit ? so that I can either get careless, or waste
time/bandwidth by running each commit twice...

Anyways, files/audio_openbsd.c is a `caching' audio system.
It's much smarter than the old one: uses get encoding to map the reasonable
encodings, does not even cross-check alaw/ulaw when 8 bit/16 bit work okay.

It does keep audio opened all the way instead of closing/reopening all the
time.

and it avoids gratuitous assumptions about PC broken hardware, such as not
having support for 8 bits signed and other brain-damage.

Missing part: it won't convert endianess on the fly when the only `right'
modes have the wrong endianess... this might occur with e.g., a sb16 on
an alpha.
1999-03-23 21:38:26 +00:00

126 lines
3.1 KiB
Plaintext

--- audio.c.orig Mon Nov 23 17:16:24 1998
+++ audio.c Tue Mar 23 22:25:08 1999
@@ -68,42 +68,43 @@
{
int fmts;
int i,j,k,k1=NUM_RATES-1;
- struct audio_info_struct ai1 = *ai;
if (param.outmode != DECODE_AUDIO) {
memset(capabilities,1,sizeof(capabilities));
return;
}
- memset(capabilities,0,sizeof(capabilities));
+ memset(capabilities,-1,sizeof(capabilities));
if(param.force_rate) {
rates[NUM_RATES-1] = param.force_rate;
k1 = NUM_RATES;
}
- if(audio_open(&ai1) < 0) {
- perror("audio");
- exit(1);
- }
+ if(param.verbose > 1) {
+ struct audio_info_struct ai1 = *ai;
+ if(audio_open(&ai1) < 0) {
+ perror("audio");
+ exit(1);
+ }
- for(i=0;i<NUM_CHANNELS;i++) {
- for(j=0;j<NUM_RATES;j++) {
- ai1.channels = channels[i];
- ai1.rate = rates[j];
- fmts = audio_get_formats(&ai1);
- if(fmts < 0)
- continue;
- for(k=0;k<NUM_ENCODINGS;k++) {
- if((fmts & encodings[k]) == encodings[k])
- capabilities[i][k][j] = 1;
+ for(i=0;i<NUM_CHANNELS;i++) {
+ for(j=0;j<NUM_RATES;j++) {
+ ai1.channels = channels[i];
+ ai1.rate = rates[j];
+ fmts = audio_get_formats(&ai1);
+ if(fmts < 0)
+ continue;
+ for(k=0;k<NUM_ENCODINGS;k++) {
+ if((fmts & encodings[k]) == encodings[k])
+ capabilities[i][k][j] = 1;
+ else
+ capabilities[i][k][j] = 0;
+ }
}
}
- }
-
- audio_close(&ai1);
- if(param.verbose > 1) {
- fprintf(stderr,"\nAudio capabilties:\n |");
+ audio_close(&ai1);
+ fprintf(stderr,"\nAudio capabilities:\n |");
for(j=0;j<NUM_ENCODINGS;j++) {
fprintf(stderr," %5s |",audio_val2name[j].sname);
}
@@ -144,7 +145,19 @@
if(rn >= 0) {
for(i=f0;i<f2;i++) {
- if(capabilities[c][i][rn]) {
+ if(capabilities[c][i][rn] == (char)-1) {
+ int fmts, k;
+ ai->channels = channels[c];
+ ai->rate = rates[rn];
+ fmts = audio_get_formats(ai);
+ for(k=0;k<NUM_ENCODINGS;k++) {
+ if ((fmts & encodings[k]) == encodings[k])
+ capabilities[c][k][rn] = 1;
+ else
+ capabilities[c][k][rn] = 0;
+ }
+ }
+ if(capabilities[c][i][rn] == 1) {
ai->rate = rates[rn];
ai->format = encodings[i];
ai->channels = channels[c];
@@ -160,7 +173,11 @@
* c=num of channels of stream
* r=rate of stream
*/
-void audio_fit_capabilities(struct audio_info_struct *ai,int c,int r)
+#ifdef OPENBSD
+void audio_fit_capabilities(struct audio_info_struct *ai, int c, int r)
+#else
+static void do_audio_fit_capabilities(struct audio_info_struct *ai,int c,int r)
+#endif
{
int rn;
int f0=0;
@@ -247,6 +264,23 @@
exit(1);
}
+#ifndef OPENBSD
+void audio_fit_capabilities(struct audio_info_struct *ai,int c,int r)
+{
+ struct audio_info_struct ai1 = *ai;
+
+ if (param.verbose <= 1 && audio_open(&ai1) >= 0) {
+ do_audio_fit_capabilities(&ai1, c, r);
+ ai->rate = ai1.rate;
+ ai->channels = ai1.channels;
+ ai->format = ai1.format;
+ audio_close(&ai1);
+ } else {
+ do_audio_fit_capabilities(ai, c, r);
+ }
+}
+#endif
+
char *audio_encoding_name(int format)
{
int i;