Fix an issue where it would terminate if it could not allocate an excessively large buffer.
This commit is contained in:
@@ -1829,11 +1829,15 @@ static void *player_thread_func(void *arg) {
|
||||
// debug(1, "Large positive sync error: %lld. Dropping the frame.", sync_error);
|
||||
} else if ((sync_error < 0) && ((-sync_error) > filler_length)) {
|
||||
// debug(1, "Large negative sync error: %lld. Inserting silence.", sync_error);
|
||||
char *long_silence = malloc(conn->output_bytes_per_frame * (-sync_error));
|
||||
size_t silence_length = -sync_error;
|
||||
if (silence_length>(filler_length*5))
|
||||
silence_length = filler_length*5;
|
||||
|
||||
char *long_silence = malloc(conn->output_bytes_per_frame * silence_length);
|
||||
if (long_silence == NULL)
|
||||
die("Failed to allocate memory for a long_silence buffer.");
|
||||
memset(long_silence, 0, conn->output_bytes_per_frame * (-sync_error));
|
||||
config.output->play((short *)long_silence, (-sync_error));
|
||||
die("Failed to allocate memory for a long_silence buffer of %d frames.",silence_length);
|
||||
memset(long_silence, 0, conn->output_bytes_per_frame * silence_length);
|
||||
config.output->play((short *)long_silence, silence_length);
|
||||
free(long_silence);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user