Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fdded0f5 authored by Divya Narayanan Poojary's avatar Divya Narayanan Poojary
Browse files

audio: Reduce minimum offload fragment size for direct pcm

Minimum offload fragment size is huge and this results in
larger buffer being passed from AudioFlinger to HAL. As
shared block in AudioFlinger is also of the same size,
track is going into under run state multiple times at the
beginning of the playback. This is causing A/V Sync issues
during video playback.

Fix is to reduce it to 512 to be inline with other targets
Fixed alignment code as well

Change-Id: Ifc667a5f0ccf8f36c44d04c270740ed67f2a32b7
parent 2e637ce0
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
/*
 * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
 * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
 * Not a Contribution.
 *
 * Copyright (C) 2013 The Android Open Source Project
@@ -68,7 +68,7 @@
 * 24 - lcm of channels supported by DSP
 */
#define MAX_PCM_OFFLOAD_FRAGMENT_SIZE (240 * 1024)
#define MIN_PCM_OFFLOAD_FRAGMENT_SIZE (4 * 1024)
#define MIN_PCM_OFFLOAD_FRAGMENT_SIZE 512

/*
 * Offload buffer size for compress passthrough
@@ -3034,16 +3034,15 @@ uint32_t platform_get_pcm_offload_buffer_size(audio_offload_info_t* info)
                     * info->sample_rate
                     * bytes_per_sample
                     * popcount(info->channel_mask))/1000;
    // To have same PCM samples for all channels, the buffer size requires to
    // be multiple of (number of channels * bytes per sample)
    // For writes to succeed, the buffer must be written at address which is multiple of 32
    // Alignment of 96 satsfies both of the above requirements
    fragment_size = ALIGN(fragment_size, 96);
    if(fragment_size < MIN_PCM_OFFLOAD_FRAGMENT_SIZE)
        fragment_size = MIN_PCM_OFFLOAD_FRAGMENT_SIZE;
    else if(fragment_size > MAX_PCM_OFFLOAD_FRAGMENT_SIZE)
        fragment_size = MAX_PCM_OFFLOAD_FRAGMENT_SIZE;

    // To have same PCM samples for all channels, the buffer size requires to
    // be multiple of (number of channels * bytes per sample)
    // For writes to succeed, the buffer must be written at address which is multiple of 32
    fragment_size = ALIGN(fragment_size, (bytes_per_sample* popcount(info->channel_mask) * 32));
    ALOGI("PCM offload Fragment size to %d bytes", fragment_size);
    return fragment_size;
}