Skip to content

Commit

Permalink
ao_pulse: fix tlength calculation
Browse files Browse the repository at this point in the history
also remove the now unused non-sensical af_fmt_seconds_to_bytes.
  • Loading branch information
tomty89 authored and sfan5 committed Sep 1, 2018
1 parent 91786fa commit 9d6b15a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 17 deletions.
11 changes: 0 additions & 11 deletions audio/format.c
Expand Up @@ -135,17 +135,6 @@ const char *af_fmt_to_str(int format)
return "??";
}

int af_fmt_seconds_to_bytes(int format, float seconds, int channels, int samplerate)
{
assert(!af_fmt_is_planar(format));
int bps = af_fmt_to_bytes(format);
int framelen = channels * bps;
int bytes = seconds * bps * samplerate;
if (bytes % framelen)
bytes += framelen - (bytes % framelen);
return bytes;
}

void af_fill_silence(void *dst, size_t bytes, int format)
{
memset(dst, af_fmt_is_unsigned(format) ? 0x80 : 0, bytes);
Expand Down
3 changes: 0 additions & 3 deletions audio/format.h
Expand Up @@ -64,9 +64,6 @@ bool af_fmt_is_pcm(int format);
int af_fmt_to_planar(int format);
int af_fmt_from_planar(int format);

// Amount of bytes that contain audio of the given duration, aligned to frames.
int af_fmt_seconds_to_bytes(int format, float seconds, int channels, int samplerate);

void af_fill_silence(void *dst, size_t bytes, int format);

void af_get_best_sample_formats(int src_format, int *out_formats);
Expand Down
6 changes: 3 additions & 3 deletions audio/out/ao_pulse.c
Expand Up @@ -454,11 +454,11 @@ static int init(struct ao *ao)
pa_stream_set_write_callback(priv->stream, stream_request_cb, ao);
pa_stream_set_latency_update_callback(priv->stream,
stream_latency_update_cb, ao);
int buf_size = af_fmt_seconds_to_bytes(ao->format, priv->cfg_buffer / 1000.0,
ao->channels.num, ao->samplerate);
uint32_t buf_size = ao->samplerate * (priv->cfg_buffer / 1000.0) *
af_fmt_to_bytes(ao->format) * ao->channels.num;
pa_buffer_attr bufattr = {
.maxlength = -1,
.tlength = buf_size > 0 ? buf_size : (uint32_t)-1,
.tlength = buf_size > 0 ? buf_size : -1,
.prebuf = -1,
.minreq = -1,
.fragsize = -1,
Expand Down

0 comments on commit 9d6b15a

Please sign in to comment.