mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-17 17:22:21 +00:00
FS-6622: [mod_shout] set buffer size for streams based on the number of channels to avoid buffer starvation
This commit is contained in:
parent
424df19083
commit
8eaaa083ad
@ -123,6 +123,7 @@ struct shout_context {
|
|||||||
int lame_ready;
|
int lame_ready;
|
||||||
int eof;
|
int eof;
|
||||||
int channels;
|
int channels;
|
||||||
|
int stream_channels;
|
||||||
int16_t *l;
|
int16_t *l;
|
||||||
switch_size_t llen;
|
switch_size_t llen;
|
||||||
int16_t *r;
|
int16_t *r;
|
||||||
@ -371,14 +372,25 @@ static size_t stream_callback(void *ptr, size_t size, size_t nmemb, void *data)
|
|||||||
shout_context_t *context = data;
|
shout_context_t *context = data;
|
||||||
int decode_status = 0;
|
int decode_status = 0;
|
||||||
size_t usedlen;
|
size_t usedlen;
|
||||||
uint32_t buf_size = 1024 * 128; /* do not make this 64 or less, stutter will ensue after
|
uint32_t buf_size = 1024 * 128; /* do not make this 64 or less, stutter will ensue after first 64k buffer is dry */
|
||||||
first 64k buffer is dry */
|
|
||||||
switch_size_t used;
|
switch_size_t used;
|
||||||
|
|
||||||
|
if (!context->stream_channels) {
|
||||||
|
long rate = 0;
|
||||||
|
int channels = 0;
|
||||||
|
int encoding = 0;
|
||||||
|
mpg123_getformat(context->mh, &rate, &channels, &encoding);
|
||||||
|
context->stream_channels = channels;
|
||||||
|
}
|
||||||
|
|
||||||
if (context->prebuf) {
|
if (context->prebuf) {
|
||||||
buf_size = context->prebuf;
|
buf_size = context->prebuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (context->stream_channels) {
|
||||||
|
buf_size = buf_size * context->stream_channels;
|
||||||
|
}
|
||||||
|
|
||||||
/* make sure we aren't over zealous by slowing down the stream when the buffer is too full */
|
/* make sure we aren't over zealous by slowing down the stream when the buffer is too full */
|
||||||
while (!context->err) {
|
while (!context->err) {
|
||||||
switch_mutex_lock(context->audio_mutex);
|
switch_mutex_lock(context->audio_mutex);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user