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

Unverified Commit 868310c0 authored by Steve Kondik's avatar Steve Kondik Committed by Michael Bestas
Browse files

hal: Featureize FLAC offload support

 * Not all devices will have this code in the DSP, let alone the kernel.
 * Featurize it, but leave the codec bit width and sample rate controls
   in place so that 24-bit PCM offload still works.
 * Enable by default.

Change-Id: I6e156048906a2b638e9ec4a083755536a14e161f
parent a120275b
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -203,6 +203,11 @@ ifneq ($(strip $(DOLBY_DDP)),true)
        LOCAL_SRC_FILES += audio_extn/dolby.c
    endif
endif

ifneq ($(strip $(AUDIO_FEATURE_ENABLED_FLAC_OFFLOAD)),false)
    LOCAL_CFLAGS += -DFLAC_OFFLOAD_ENABLED
endif

endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_SPLIT_A2DP)),true)
+2 −0
Original line number Diff line number Diff line
@@ -606,6 +606,7 @@ int audio_extn_parse_compress_metadata(struct stream_out *out,
    char value[32];

    if (out->format == AUDIO_FORMAT_FLAC) {
#ifdef FLAC_OFFLOAD_ENABLED
        ret = str_parms_get_str(parms, AUDIO_OFFLOAD_CODEC_FLAC_MIN_BLK_SIZE, value, sizeof(value));
        if (ret >= 0) {
            out->compr_config.codec->options.flac_dec.min_blk_size = atoi(value);
@@ -631,6 +632,7 @@ int audio_extn_parse_compress_metadata(struct stream_out *out,
              out->compr_config.codec->options.flac_dec.max_blk_size,
              out->compr_config.codec->options.flac_dec.min_frame_size,
              out->compr_config.codec->options.flac_dec.max_frame_size);
#endif
    }

    else if (out->format == AUDIO_FORMAT_ALAC) {
+6 −0
Original line number Diff line number Diff line
@@ -268,7 +268,9 @@ static bool is_supported_format(audio_format_t format)
        format == AUDIO_FORMAT_AAC_HE_V2 ||
        format == AUDIO_FORMAT_PCM_16_BIT_OFFLOAD ||
        format == AUDIO_FORMAT_PCM_24_BIT_OFFLOAD ||
#ifdef FLAC_OFFLOAD_ENABLED
        format == AUDIO_FORMAT_FLAC ||
#endif
        format == AUDIO_FORMAT_ALAC ||
        format == AUDIO_FORMAT_APE ||
        format == AUDIO_FORMAT_VORBIS ||
@@ -293,9 +295,11 @@ static int get_snd_codec_id(audio_format_t format)
    case AUDIO_FORMAT_PCM_OFFLOAD:
        id = SND_AUDIOCODEC_PCM;
        break;
#ifdef FLAC_OFFLOAD_ENABLED
    case AUDIO_FORMAT_FLAC:
        id = SND_AUDIOCODEC_FLAC;
        break;
#endif
    case AUDIO_FORMAT_ALAC:
        id = SND_AUDIOCODEC_ALAC;
        break;
@@ -2764,8 +2768,10 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
        if (out->bit_width == 24)
            out->compr_config.codec->format = SNDRV_PCM_FORMAT_S24_LE;

#ifdef FLAC_OFFLOAD_ENABLED
        if (config->offload_info.format == AUDIO_FORMAT_FLAC)
            out->compr_config.codec->options.flac_dec.sample_size = PCM_OUTPUT_BIT_WIDTH;
#endif

        if (flags & AUDIO_OUTPUT_FLAG_NON_BLOCKING)
            out->non_blocking = 1;