| 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 */ |
| 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; |
| 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 |
|
|
| 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, |
| 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; |
| 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 |
|
|
| 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 |
|
|
| 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 |
|
|
| 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 |
|
|
| 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 |
|
|
| 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); |