Commit 2c44375d649910677dd9cdcf170f4dbaafa3f193

Authored by malc
1 parent d865bab5

Do not scare users with ominous error messages from AUD_open*

Apparently Windows Server 2003 sets the frequency for either mc or pi
voice to zero, which in turn triggers a call to audio_bug from this
chain:

open_voice -> AUD_open_in -> audio_bug (audio_validate_settings):

A bug was just triggered in AUD_open_in
...
Context:
audio: frequency=0 nchannels=2 fmt=S16 endianness=little

But since no attempt by the said OS is made to actually use the voice
with zero frequency this can be considered normal behavior.

Hence if zero freqency situation is encountered - close current voice,
and make noises if the guest tries to use it.

Reported by simon@...ve


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4694 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 60 additions and 31 deletions
hw/ac97.c
... ... @@ -158,6 +158,7 @@ typedef struct AC97LinkState {
158 158 SWVoiceIn *voice_pi;
159 159 SWVoiceOut *voice_po;
160 160 SWVoiceIn *voice_mc;
  161 + int invalid_freq[3];
161 162 uint8_t silence[128];
162 163 uint32_t base[2];
163 164 int bup_flag;
... ... @@ -360,39 +361,61 @@ static void open_voice (AC97LinkState *s, int index, int freq)
360 361 as.fmt = AUD_FMT_S16;
361 362 as.endianness = 0;
362 363  
363   - switch (index) {
364   - case PI_INDEX:
365   - s->voice_pi = AUD_open_in (
366   - &s->card,
367   - s->voice_pi,
368   - "ac97.pi",
369   - s,
370   - pi_callback,
371   - &as
372   - );
373   - break;
  364 + if (freq > 0) {
  365 + s->invalid_freq[index] = 0;
  366 + switch (index) {
  367 + case PI_INDEX:
  368 + s->voice_pi = AUD_open_in (
  369 + &s->card,
  370 + s->voice_pi,
  371 + "ac97.pi",
  372 + s,
  373 + pi_callback,
  374 + &as
  375 + );
  376 + break;
374 377  
375   - case PO_INDEX:
376   - s->voice_po = AUD_open_out (
377   - &s->card,
378   - s->voice_po,
379   - "ac97.po",
380   - s,
381   - po_callback,
382   - &as
383   - );
384   - break;
  378 + case PO_INDEX:
  379 + s->voice_po = AUD_open_out (
  380 + &s->card,
  381 + s->voice_po,
  382 + "ac97.po",
  383 + s,
  384 + po_callback,
  385 + &as
  386 + );
  387 + break;
385 388  
386   - case MC_INDEX:
387   - s->voice_mc = AUD_open_in (
388   - &s->card,
389   - s->voice_mc,
390   - "ac97.mc",
391   - s,
392   - mc_callback,
393   - &as
394   - );
395   - break;
  389 + case MC_INDEX:
  390 + s->voice_mc = AUD_open_in (
  391 + &s->card,
  392 + s->voice_mc,
  393 + "ac97.mc",
  394 + s,
  395 + mc_callback,
  396 + &as
  397 + );
  398 + break;
  399 + }
  400 + }
  401 + else {
  402 + s->invalid_freq[index] = freq;
  403 + switch (index) {
  404 + case PI_INDEX:
  405 + AUD_close_in (&s->card, s->voice_pi);
  406 + s->voice_pi = NULL;
  407 + break;
  408 +
  409 + case PO_INDEX:
  410 + AUD_close_out (&s->card, s->voice_po);
  411 + s->voice_po = NULL;
  412 + break;
  413 +
  414 + case MC_INDEX:
  415 + AUD_close_in (&s->card, s->voice_mc);
  416 + s->voice_mc = NULL;
  417 + break;
  418 + }
396 419 }
397 420 }
398 421  
... ... @@ -1065,6 +1088,12 @@ static void transfer_audio (AC97LinkState *s, int index, int elapsed)
1065 1088 AC97BusMasterRegs *r = &s->bm_regs[index];
1066 1089 int written = 0, stop = 0;
1067 1090  
  1091 + if (s->invalid_freq[index]) {
  1092 + AUD_log ("ac97", "attempt to use voice %d with invalid frequency %d\n",
  1093 + index, s->invalid_freq[index]);
  1094 + return;
  1095 + }
  1096 +
1068 1097 if (r->sr & SR_DCH) {
1069 1098 if (r->cr & CR_RPBM) {
1070 1099 switch (index) {
... ...