Revert "directsoundsrc: Correctly calculate segsize and segtotal"

This reverts commit 6d256d9908e292f6c593bf45e69354f6b613cc8b.

It was configuring the period/buffer size in a way that often causes
drop-outs or complete underruns. Needs further investigation.
This commit is contained in:
Sebastian Dröge 2017-04-12 13:17:24 +03:00
parent 94fe5c690e
commit 244a80787d
2 changed files with 18 additions and 14 deletions

View File

@ -564,20 +564,22 @@ gst_directsound_src_prepare (GstAudioSrc * asrc, GstAudioRingBufferSpec * spec)
GST_WARNING ("buffer-time was less than latency"); GST_WARNING ("buffer-time was less than latency");
} }
spec->segsize = /* Save the times */
gst_util_uint64_scale (spec->latency_time, wfx.nAvgBytesPerSec, 1000000); dsoundsrc->buffer_time = spec->buffer_time;
if (spec->segsize < GST_AUDIO_INFO_BPF (&spec->info)) dsoundsrc->latency_time = spec->latency_time;
spec->segsize = GST_AUDIO_INFO_BPF (&spec->info);
else if (spec->segsize % GST_AUDIO_INFO_BPF (&spec->info) != 0)
spec->segsize =
((spec->segsize + GST_AUDIO_INFO_BPF (&spec->info) -
1) / GST_AUDIO_INFO_BPF (&spec->info)) *
GST_AUDIO_INFO_BPF (&spec->info);
dsoundsrc->latency_time = dsoundsrc->latency_size = (gint) wfx.nAvgBytesPerSec *
gst_util_uint64_scale (spec->segsize, 1000000, dsoundsrc->latency_time / 1000000.0;
GST_AUDIO_INFO_BPF (&spec->info) * GST_AUDIO_INFO_RATE (&spec->info));
spec->segtotal = spec->buffer_time / dsoundsrc->latency_time; spec->segsize = (guint) (((double) spec->buffer_time / 1000000.0) *
wfx.nAvgBytesPerSec);
/* just in case */
if (spec->segsize < 1)
spec->segsize = 1;
spec->segtotal = GST_AUDIO_INFO_BPF (&spec->info) * 8 *
(wfx.nAvgBytesPerSec / spec->segsize);
GST_DEBUG_OBJECT (asrc, GST_DEBUG_OBJECT (asrc,
"bytes/sec: %lu, buffer size: %d, segsize: %d, segtotal: %d", "bytes/sec: %lu, buffer size: %d, segsize: %d, segtotal: %d",
@ -816,7 +818,7 @@ gst_directsound_src_mixer_find (GstDirectSoundSrc * dsoundsrc,
if (mmres != MMSYSERR_NOERROR) if (mmres != MMSYSERR_NOERROR)
continue; continue;
mmres = mixerGetDevCaps ((UINT_PTR) dsoundsrc->mixer, mmres = mixerGetDevCaps ((UINT_PTR)dsoundsrc->mixer,
mixer_caps, sizeof (MIXERCAPS)); mixer_caps, sizeof (MIXERCAPS));
if (mmres != MMSYSERR_NOERROR) { if (mmres != MMSYSERR_NOERROR) {

View File

@ -86,8 +86,10 @@ struct _GstDirectSoundSrc
DWORD notifysize; DWORD notifysize;
guint buffer_size; guint buffer_size;
guint latency_size;
guint bytes_per_sample; guint bytes_per_sample;
guint buffer_time;
guint latency_time; guint latency_time;
HMIXER mixer; HMIXER mixer;