/[qemu]/qemu/audio/audio.c
ViewVC logotype

Diff of /qemu/audio/audio.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by bellard, Sat Nov 5 18:55:27 2005 UTC revision 1.8 by bellard, Fri Nov 11 00:04:19 2005 UTC
# Line 70  static struct { Line 70  static struct {
70          int64_t ticks;          int64_t ticks;
71      } period;      } period;
72      int plive;      int plive;
73        int log_to_monitor;
74  } conf = {  } conf = {
75      {                           /* DAC fixed settings */      {                           /* DAC fixed settings */
76          1,                      /* enabled */          1,                      /* enabled */
# Line 94  static struct { Line 95  static struct {
95      },      },
96    
97      { 0 },                      /* period */      { 0 },                      /* period */
98      0                           /* plive */      0,                          /* plive */
99        0
100  };  };
101    
102  static AudioState glob_audio_state;  static AudioState glob_audio_state;
# Line 176  void *audio_calloc (const char *funcname Line 178  void *audio_calloc (const char *funcname
178      if (audio_bug ("audio_calloc", cond)) {      if (audio_bug ("audio_calloc", cond)) {
179          AUD_log (NULL, "%s passed invalid arguments to audio_calloc\n",          AUD_log (NULL, "%s passed invalid arguments to audio_calloc\n",
180                   funcname);                   funcname);
181          AUD_log (NULL, "nmemb=%d size=%d (len=%d)\n", nmemb, size, len);          AUD_log (NULL, "nmemb=%d size=%zu (len=%zu)\n", nmemb, size, len);
182          return NULL;          return NULL;
183      }      }
184    
# Line 300  static const char *audio_get_conf_str (c Line 302  static const char *audio_get_conf_str (c
302      }      }
303  }  }
304    
305  void AUD_log (const char *cap, const char *fmt, ...)  void AUD_vlog (const char *cap, const char *fmt, va_list ap)
306  {  {
307      va_list ap;      if (conf.log_to_monitor) {
308      if (cap) {          if (cap) {
309          fprintf (stderr, "%s: ", cap);              term_printf ("%s: ", cap);
310            }
311    
312            term_vprintf (fmt, ap);
313        }
314        else {
315            if (cap) {
316                fprintf (stderr, "%s: ", cap);
317            }
318    
319            vfprintf (stderr, fmt, ap);
320      }      }
     va_start (ap, fmt);  
     vfprintf (stderr, fmt, ap);  
     va_end (ap);  
321  }  }
322    
323  void AUD_vlog (const char *cap, const char *fmt, va_list ap)  void AUD_log (const char *cap, const char *fmt, ...)
324  {  {
325      if (cap) {      va_list ap;
326          fprintf (stderr, "%s: ", cap);  
327      }      va_start (ap, fmt);
328      vfprintf (stderr, fmt, ap);      AUD_vlog (cap, fmt, ap);
329        va_end (ap);
330  }  }
331    
332  static void audio_print_options (const char *prefix,  static void audio_print_options (const char *prefix,
# Line 625  static int audio_pcm_hw_alloc_resources_ Line 635  static int audio_pcm_hw_alloc_resources_
635  {  {
636      hw->conv_buf = audio_calloc (AUDIO_FUNC, hw->samples, sizeof (st_sample_t));      hw->conv_buf = audio_calloc (AUDIO_FUNC, hw->samples, sizeof (st_sample_t));
637      if (!hw->conv_buf) {      if (!hw->conv_buf) {
638          dolog ("Could not allocate ADC conversion buffer (%d bytes)\n",          dolog ("Could not allocate ADC conversion buffer (%d samples)\n",
639                 hw->samples * sizeof (st_sample_t));                 hw->samples);
640          return -1;          return -1;
641      }      }
642      return 0;      return 0;
# Line 677  static int audio_pcm_sw_alloc_resources_ Line 687  static int audio_pcm_sw_alloc_resources_
687      int samples = ((int64_t) sw->hw->samples << 32) / sw->ratio;      int samples = ((int64_t) sw->hw->samples << 32) / sw->ratio;
688      sw->conv_buf = audio_calloc (AUDIO_FUNC, samples, sizeof (st_sample_t));      sw->conv_buf = audio_calloc (AUDIO_FUNC, samples, sizeof (st_sample_t));
689      if (!sw->conv_buf) {      if (!sw->conv_buf) {
690          dolog ("Could not allocate buffer for `%s' (%d bytes)\n",          dolog ("Could not allocate buffer for `%s' (%d samples)\n",
691                 SW_NAME (sw), samples * sizeof (st_sample_t));                 SW_NAME (sw), samples);
692          return -1;          return -1;
693      }      }
694    
# Line 805  static int audio_pcm_hw_alloc_resources_ Line 815  static int audio_pcm_hw_alloc_resources_
815  {  {
816      hw->mix_buf = audio_calloc (AUDIO_FUNC, hw->samples, sizeof (st_sample_t));      hw->mix_buf = audio_calloc (AUDIO_FUNC, hw->samples, sizeof (st_sample_t));
817      if (!hw->mix_buf) {      if (!hw->mix_buf) {
818          dolog ("Could not allocate DAC mixing buffer (%d bytes)\n",          dolog ("Could not allocate DAC mixing buffer (%d samples)\n",
819                 hw->samples * sizeof (st_sample_t));                 hw->samples);
820          return -1;          return -1;
821      }      }
822    
# Line 884  static int audio_pcm_sw_alloc_resources_ Line 894  static int audio_pcm_sw_alloc_resources_
894  {  {
895      sw->buf = audio_calloc (AUDIO_FUNC, sw->hw->samples, sizeof (st_sample_t));      sw->buf = audio_calloc (AUDIO_FUNC, sw->hw->samples, sizeof (st_sample_t));
896      if (!sw->buf) {      if (!sw->buf) {
897          dolog ("Could not allocate buffer for `%s' (%d bytes)\n",          dolog ("Could not allocate buffer for `%s' (%d samples)\n",
898                 SW_NAME (sw), sw->hw->samples * sizeof (st_sample_t));                 SW_NAME (sw), sw->hw->samples);
899          return -1;          return -1;
900      }      }
901    
# Line 1346  static struct audio_option audio_options Line 1356  static struct audio_option audio_options
1356      {"PLIVE", AUD_OPT_BOOL, &conf.plive,      {"PLIVE", AUD_OPT_BOOL, &conf.plive,
1357       "(undocumented)", NULL, 0},       "(undocumented)", NULL, 0},
1358    
1359    
1360        {"LOG_TO_MONITOR", AUD_OPT_BOOL, &conf.log_to_monitor,
1361         "print logging messages to montior instead of stderr", NULL, 0},
1362    
1363      {NULL, 0, NULL, NULL, NULL, 0}      {NULL, 0, NULL, NULL, NULL, 0}
1364  };  };
1365    
# Line 1513  static int audio_driver_init (AudioState Line 1527  static int audio_driver_init (AudioState
1527      }      }
1528  }  }
1529    
1530  static void audio_vm_stop_handler (void *opaque, int reason)  static void audio_vm_change_state_handler (void *opaque, int running)
1531  {  {
1532      AudioState *s = opaque;      AudioState *s = opaque;
1533      HWVoiceOut *hwo = NULL;      HWVoiceOut *hwo = NULL;
1534      HWVoiceIn *hwi = NULL;      HWVoiceIn *hwi = NULL;
1535      int op = reason ? VOICE_ENABLE : VOICE_DISABLE;      int op = running ? VOICE_ENABLE : VOICE_DISABLE;
   
     while ((hwo = audio_pcm_hw_find_any_out (s, hwo))) {  
         if (!hwo->pcm_ops) {  
             continue;  
         }  
1536    
1537          if (hwo->enabled != reason) {      while ((hwo = audio_pcm_hw_find_any_enabled_out (s, hwo))) {
1538              hwo->pcm_ops->ctl_out (hwo, op);          hwo->pcm_ops->ctl_out (hwo, op);
         }  
1539      }      }
1540    
1541      while ((hwi = audio_pcm_hw_find_any_in (s, hwi))) {      while ((hwi = audio_pcm_hw_find_any_enabled_in (s, hwi))) {
1542          if (!hwi->pcm_ops) {          hwi->pcm_ops->ctl_in (hwi, op);
             continue;  
         }  
   
         if (hwi->enabled != reason) {  
             hwi->pcm_ops->ctl_in (hwi, op);  
         }  
1543      }      }
1544  }  }
1545    
# Line 1690  AudioState *AUD_init (void) Line 1692  AudioState *AUD_init (void)
1692              conf.period.ticks = ticks_per_sec / conf.period.hz;              conf.period.ticks = ticks_per_sec / conf.period.hz;
1693          }          }
1694    
1695          qemu_add_vm_stop_handler (audio_vm_stop_handler, NULL);          qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s);
1696      }      }
1697      else {      else {
1698          qemu_del_timer (s->ts);          qemu_del_timer (s->ts);

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26