{
HRESULT hr;
- hr = glue (IFACE, _Unlock) (buf, p1, blen1, p2, blen2);
- if (FAILED (hr)) {
- dsound_logerr (hr, "Could not unlock " NAME "\n");
+ hr = glue(IFACE, _Unlock)(buf, p1, blen1, p2, blen2);
+ if (FAILED(hr)) {
+ dsound_logerr(hr, "Could not unlock " NAME);
return -1;
}
#endif
hr = glue(IFACE, _Lock)(buf, pos, len, p1p, blen1p, p2p, blen2p, flag);
- if (FAILED (hr)) {
+ if (FAILED(hr)) {
#ifndef DSBTYPE_IN
if (hr == DSERR_BUFFERLOST) {
- if (glue (dsound_restore_, TYPE) (buf, s)) {
- dsound_logerr (hr, "Could not lock " NAME "\n");
+ if (glue(dsound_restore_, TYPE)(buf, s)) {
+ dsound_logerr(hr, "Could not lock " NAME);
}
goto fail;
}
#endif
- dsound_logerr (hr, "Could not lock " NAME "\n");
+ dsound_logerr(hr, "Could not lock " NAME);
goto fail;
}
if ((p1p && *p1p && (*blen1p % info->bytes_per_frame)) ||
(p2p && *p2p && (*blen2p % info->bytes_per_frame))) {
- dolog("DirectSound returned misaligned buffer %ld %ld\n",
- *blen1p, *blen2p);
+ error_report("dsound: returned misaligned buffer %ld %ld",
+ *blen1p, *blen2p);
glue(dsound_unlock_, TYPE)(buf, *p1p, p2p ? *p2p : NULL, *blen1p,
blen2p ? *blen2p : 0);
goto fail;
}
if (p1p && !*p1p && *blen1p) {
- dolog("warning: !p1 && blen1=%ld\n", *blen1p);
+ warn_report("dsound: !p1 && blen1=%ld", *blen1p);
*blen1p = 0;
}
if (p2p && !*p2p && *blen2p) {
- dolog("warning: !p2 && blen2=%ld\n", *blen2p);
+ warn_report("dsound: !p2 && blen2=%ld", *blen2p);
*blen2p = 0;
}
#endif
if (ds->FIELD) {
- hr = glue (IFACE, _Stop) (ds->FIELD);
- if (FAILED (hr)) {
- dsound_logerr (hr, "Could not stop " NAME "\n");
+ hr = glue(IFACE, _Stop)(ds->FIELD);
+ if (FAILED(hr)) {
+ dsound_logerr(hr, "Could not stop " NAME);
}
- hr = glue (IFACE, _Release) (ds->FIELD);
- if (FAILED (hr)) {
- dsound_logerr (hr, "Could not release " NAME "\n");
+ hr = glue(IFACE, _Release)(ds->FIELD);
+ if (FAILED(hr)) {
+ dsound_logerr(hr, "Could not release " NAME);
}
ds->FIELD = NULL;
}
#endif
if (!s->FIELD2) {
- dolog ("Attempt to initialize voice without " NAME2 " object\n");
+ error_report("dsound: Attempt to initialize voice without "
+ NAME2 " object");
return -1;
}
);
#endif
- if (FAILED (hr)) {
- dsound_logerr2 (hr, typ, "Could not create " NAME "\n");
+ if (FAILED(hr)) {
+ dsound_logerr2(hr, typ, "Could not create " NAME);
return -1;
}
- hr = glue (IFACE, _GetFormat) (ds->FIELD, &wfx, sizeof (wfx), NULL);
- if (FAILED (hr)) {
- dsound_logerr2 (hr, typ, "Could not get " NAME " format\n");
+ hr = glue(IFACE, _GetFormat)(ds->FIELD, &wfx, sizeof(wfx), NULL);
+ if (FAILED(hr)) {
+ dsound_logerr2(hr, typ, "Could not get " NAME " format");
goto fail0;
}
-#ifdef DEBUG_DSOUND
- dolog (NAME "\n");
- print_wave_format (&wfx);
-#endif
+ trace_dsound_wave_format(
+ wfx.wFormatTag, wfx.nChannels,
+ wfx.nSamplesPerSec, wfx.nAvgBytesPerSec,
+ wfx.nBlockAlign, wfx.wBitsPerSample, wfx.cbSize);
memset (&bc, 0, sizeof (bc));
bc.dwSize = sizeof (bc);
- hr = glue (IFACE, _GetCaps) (ds->FIELD, &bc);
- if (FAILED (hr)) {
- dsound_logerr2 (hr, typ, "Could not get " NAME " format\n");
+ hr = glue(IFACE, _GetCaps)(ds->FIELD, &bc);
+ if (FAILED(hr)) {
+ dsound_logerr2(hr, typ, "Could not get " NAME " caps");
goto fail0;
}
audio_pcm_init_info (&hw->info, &obt_as);
if (bc.dwBufferBytes % hw->info.bytes_per_frame) {
- dolog (
- "GetCaps returned misaligned buffer size %ld, alignment %d\n",
- bc.dwBufferBytes, hw->info.bytes_per_frame
- );
+ warn_report("dsound: GetCaps returned misaligned buffer size %ld, "
+ "alignment %d", bc.dwBufferBytes, hw->info.bytes_per_frame);
}
hw->size_emul = bc.dwBufferBytes;
hw->samples = bc.dwBufferBytes / hw->info.bytes_per_frame;
-#ifdef DEBUG_DSOUND
- dolog ("caps %ld, desc %ld\n",
- bc.dwBufferBytes, bd.dwBufferBytes);
-#endif
+ trace_dsound_buffer_bytes(bc.dwBufferBytes, bd.dwBufferBytes);
return 0;
fail0:
#include "qemu/osdep.h"
#include "qemu/audio.h"
-
-#define AUDIO_CAP "dsound"
+#include "qemu/error-report.h"
#include "audio_int.h"
#include "qemu/module.h"
#include "qapi/error.h"
#include <objbase.h>
#include <dsound.h>
+#include "trace.h"
#include "audio_win_int.h"
#define TYPE_AUDIO_DSOUND "audio-dsound"
struct audsettings settings;
};
-
-/* #define DEBUG_DSOUND */
-
typedef struct {
HWVoiceOut hw;
LPDIRECTSOUNDBUFFER dsound_buffer;
const char *str = dserror(hr);
if (str) {
- AUD_log (AUDIO_CAP, "Reason: %s\n", str);
+ error_printf(" Reason: %s", str);
} else {
- AUD_log (AUDIO_CAP, "Reason: Unknown (HRESULT: 0x%lx)\n", hr);
+ error_printf(" Reason: Unknown (HRESULT: 0x%lx)", hr);
}
}
-static void G_GNUC_PRINTF (2, 3) dsound_logerr (
- HRESULT hr,
- const char *fmt,
- ...
- )
+static void G_GNUC_PRINTF(2, 3) dsound_logerr(HRESULT hr, const char *fmt, ...)
{
va_list ap;
- va_start (ap, fmt);
- AUD_vlog (AUDIO_CAP, fmt, ap);
- va_end (ap);
-
- dsound_log_hresult (hr);
+ error_printf("dsound: ");
+ va_start(ap, fmt);
+ error_vprintf(fmt, ap);
+ va_end(ap);
+ dsound_log_hresult(hr);
+ error_printf("\n");
}
-static void G_GNUC_PRINTF (3, 4) dsound_logerr2 (
- HRESULT hr,
- const char *typ,
- const char *fmt,
- ...
- )
+static void G_GNUC_PRINTF(3, 4) dsound_logerr2(HRESULT hr, const char *typ,
+ const char *fmt, ...)
{
va_list ap;
- AUD_log (AUDIO_CAP, "Could not initialize %s\n", typ);
- va_start (ap, fmt);
- AUD_vlog (AUDIO_CAP, fmt, ap);
- va_end (ap);
-
- dsound_log_hresult (hr);
+ error_printf("dsound: Could not initialize %s: ", typ);
+ va_start(ap, fmt);
+ error_vprintf(fmt, ap);
+ va_end(ap);
+ dsound_log_hresult(hr);
+ error_printf("\n");
}
-#ifdef DEBUG_DSOUND
-static void print_wave_format (WAVEFORMATEX *wfx)
-{
- dolog ("tag = %d\n", wfx->wFormatTag);
- dolog ("nChannels = %d\n", wfx->nChannels);
- dolog ("nSamplesPerSec = %ld\n", wfx->nSamplesPerSec);
- dolog ("nAvgBytesPerSec = %ld\n", wfx->nAvgBytesPerSec);
- dolog ("nBlockAlign = %d\n", wfx->nBlockAlign);
- dolog ("wBitsPerSample = %d\n", wfx->wBitsPerSample);
- dolog ("cbSize = %d\n", wfx->cbSize);
-}
-#endif
static int dsound_restore_out (LPDIRECTSOUNDBUFFER dsb, AudioDsound *s)
{
hr = IDirectSoundBuffer_Restore (dsb);
if (hr != DS_OK) {
- dsound_logerr (hr, "Could not restore playback buffer\n");
+ dsound_logerr(hr, "Could not restore playback buffer");
return -1;
}
return 0;
hr = IDirectSoundBuffer_GetStatus (dsb, statusp);
if (FAILED (hr)) {
- dsound_logerr (hr, "Could not get playback buffer status\n");
+ dsound_logerr(hr, "Could not get playback buffer status");
return -1;
}
hr = IDirectSoundCaptureBuffer_GetStatus (dscb, statusp);
if (FAILED (hr)) {
- dsound_logerr (hr, "Could not get capture buffer status\n");
+ dsound_logerr(hr, "Could not get capture buffer status");
return -1;
}
len1 = blen1 / hw->info.bytes_per_frame;
len2 = blen2 / hw->info.bytes_per_frame;
-#ifdef DEBUG_DSOUND
- dolog ("clear %p,%ld,%ld %p,%ld,%ld\n",
- p1, blen1, len1,
- p2, blen2, len2);
-#endif
+ trace_dsound_clear_sample(p1, blen1, len1, p2, blen2, len2);
if (p1 && len1) {
audio_pcm_info_clear_buf (&hw->info, p1, len1);
LPDIRECTSOUNDBUFFER dsb = ds->dsound_buffer;
if (!dsb) {
- dolog ("Attempt to control voice without a buffer\n");
+ error_report("dsound: Attempt to control voice without a buffer");
return;
}
if (enable) {
- if (dsound_get_status_out (dsb, &status, s)) {
+ if (dsound_get_status_out(dsb, &status, s)) {
return;
}
if (status & DSBSTATUS_PLAYING) {
- dolog ("warning: Voice is already playing\n");
+ warn_report("dsound: Voice is already playing");
return;
}
- dsound_clear_sample (hw, dsb, s);
+ dsound_clear_sample(hw, dsb, s);
- hr = IDirectSoundBuffer_Play (dsb, 0, 0, DSBPLAY_LOOPING);
- if (FAILED (hr)) {
- dsound_logerr (hr, "Could not start playing buffer\n");
+ hr = IDirectSoundBuffer_Play(dsb, 0, 0, DSBPLAY_LOOPING);
+ if (FAILED(hr)) {
+ dsound_logerr(hr, "Could not start playing buffer");
return;
}
} else {
- if (dsound_get_status_out (dsb, &status, s)) {
+ if (dsound_get_status_out(dsb, &status, s)) {
return;
}
if (status & DSBSTATUS_PLAYING) {
- hr = IDirectSoundBuffer_Stop (dsb);
- if (FAILED (hr)) {
- dsound_logerr (hr, "Could not stop playing buffer\n");
+ hr = IDirectSoundBuffer_Stop(dsb);
+ if (FAILED(hr)) {
+ dsound_logerr(hr, "Could not stop playing buffer");
return;
}
} else {
- dolog ("warning: Voice is not playing\n");
+ warn_report("dsound: Voice is not playing");
}
}
}
hr = IDirectSoundBuffer_GetCurrentPosition(
dsb, &ppos, ds->first_time ? &wpos : NULL);
if (FAILED(hr)) {
- dsound_logerr(hr, "Could not get playback buffer position\n");
+ dsound_logerr(hr, "Could not get playback buffer position");
return 0;
}
err = dsound_lock_out(dsb, &hw->info, hw->pos_emul, req_size, &ret, NULL,
&act_size, NULL, false, AUDIO_DSOUND(hw->s));
if (err) {
- dolog("Failed to lock buffer\n");
+ error_report("dsound: Failed to lock buffer");
*size = 0;
return NULL;
}
int err = dsound_unlock_out(dsb, buf, NULL, len, 0);
if (err) {
- dolog("Failed to unlock buffer!!\n");
+ error_report("dsound: Failed to unlock buffer");
return 0;
}
hw->pos_emul = (hw->pos_emul + len) % hw->size_emul;
LPDIRECTSOUNDCAPTUREBUFFER dscb = ds->dsound_capture_buffer;
if (!dscb) {
- dolog ("Attempt to control capture voice without a buffer\n");
+ error_report("dsound: Attempt to control capture voice without a buffer");
return;
}
if (enable) {
- if (dsound_get_status_in (dscb, &status)) {
+ if (dsound_get_status_in(dscb, &status)) {
return;
}
if (status & DSCBSTATUS_CAPTURING) {
- dolog ("warning: Voice is already capturing\n");
+ warn_report("dsound: Voice is already capturing");
return;
}
/* clear ?? */
- hr = IDirectSoundCaptureBuffer_Start (dscb, DSCBSTART_LOOPING);
- if (FAILED (hr)) {
- dsound_logerr (hr, "Could not start capturing\n");
+ hr = IDirectSoundCaptureBuffer_Start(dscb, DSCBSTART_LOOPING);
+ if (FAILED(hr)) {
+ dsound_logerr(hr, "Could not start capturing");
return;
}
} else {
- if (dsound_get_status_in (dscb, &status)) {
+ if (dsound_get_status_in(dscb, &status)) {
return;
}
if (status & DSCBSTATUS_CAPTURING) {
- hr = IDirectSoundCaptureBuffer_Stop (dscb);
- if (FAILED (hr)) {
- dsound_logerr (hr, "Could not stop capturing\n");
+ hr = IDirectSoundCaptureBuffer_Stop(dscb);
+ if (FAILED(hr)) {
+ dsound_logerr(hr, "Could not stop capturing");
return;
}
} else {
- dolog ("warning: Voice is not capturing\n");
+ warn_report("dsound: Voice is not capturing");
}
}
}
hr = IDirectSoundCaptureBuffer_GetCurrentPosition(dscb, NULL, &rpos);
if (FAILED(hr)) {
- dsound_logerr(hr, "Could not get capture buffer position\n");
+ dsound_logerr(hr, "Could not get capture buffer position");
*size = 0;
return NULL;
}
err = dsound_lock_in(dscb, &hw->info, hw->pos_emul, req_size, &ret, NULL,
&act_size, NULL, false, AUDIO_DSOUND(hw->s));
if (err) {
- dolog("Failed to lock buffer\n");
+ error_report("dsound: Failed to lock buffer");
*size = 0;
return NULL;
}
int err = dsound_unlock_in(dscb, buf, NULL, len, 0);
if (err) {
- dolog("Failed to unlock buffer!!\n");
+ error_report("dsound: Failed to unlock buffer");
return;
}
hw->pos_emul = (hw->pos_emul + len) % hw->size_emul;
hr = IDirectSound_Release (s->dsound);
if (FAILED (hr)) {
- dsound_logerr (hr, "Could not release DirectSound\n");
+ dsound_logerr(hr, "Could not release DirectSound");
}
s->dsound = NULL;
hr = IDirectSoundCapture_Release (s->dsound_capture);
if (FAILED (hr)) {
- dsound_logerr (hr, "Could not release DirectSoundCapture\n");
+ dsound_logerr(hr, "Could not release DirectSoundCapture");
}
s->dsound_capture = NULL;
}