Fix the fix_metrics() function so that we don't get a tiny buffer by default.

git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@981 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Pierre Ossman 2006-05-26 12:18:07 +00:00
parent 7d90e3a32d
commit 12dc4c21ac

View file

@ -357,7 +357,7 @@ static void reset_params(fd_info *i) {
i->sample_spec.format = PA_SAMPLE_ULAW;
i->sample_spec.channels = 1;
i->sample_spec.rate = 8000;
i->fragment_size = 1024;
i->fragment_size = 0;
i->n_fragments = 0;
}
@ -628,12 +628,22 @@ static void fix_metrics(fd_info *i) {
fs = pa_frame_size(&i->sample_spec);
i->fragment_size = (i->fragment_size/fs)*fs;
if (i->n_fragments < 2)
i->n_fragments = 12;
/* Number of fragments set? */
if (i->n_fragments < 2) {
if (i->fragment_size > 0) {
i->n_fragments = pa_bytes_per_second(&i->sample_spec) / 2 / i->fragment_size;
if (i->n_fragments < 2)
i->n_fragments = 2;
} else
i->n_fragments = 12;
}
if (i->fragment_size <= 0)
if ((i->fragment_size = pa_bytes_per_second(&i->sample_spec) / 2 / i->n_fragments) <= 0)
/* Fragment size set? */
if (i->fragment_size <= 0) {
i->fragment_size = pa_bytes_per_second(&i->sample_spec) / 2 / i->n_fragments;
if (i->fragment_size < 1024)
i->fragment_size = 1024;
}
debug(__FILE__": sample spec: %s\n", pa_sample_spec_snprint(t, sizeof(t), &i->sample_spec));
debug(__FILE__": fixated metrics to %i fragments, %li bytes each.\n", i->n_fragments, (long)i->fragment_size);