Search code examples
androidandroid-sourceandroid-hardwareandroid-romandroid-mediacodec

Android custom ROM: force software decoders


I'm building a ROM from AOSP, running on Nexus 5X (bullhead). I wish to completely disable hardware audio/video decoders and make the platform route everything through software - to work exactly the same as on emulator.

I've tried editing audio_policy_configuration.xml and media_codecs.xml to remove decoders, however I'm getting error messages in logcat and no audio is being played - I've no idea if this is even the right direction.


Solution

  • I achieved what I wanted by editing the following in hardware/qcom/audio/hal/audio_hw.c:

    static uint32_t out_get_sample_rate(const struct audio_stream *stream)
    {
     /*   struct stream_out *out = (struct stream_out *)stream;
    
        return out->sample_rate;*/
    
        return 44100;
    }
    
    static uint32_t out_get_channels(const struct audio_stream *stream)
    {
        /*struct stream_out *out = (struct stream_out *)stream;
    
        return out->channel_mask;*/
    
        return AUDIO_CHANNEL_OUT_STEREO;
    }
    
    static audio_format_t out_get_format(const struct audio_stream *stream)
    {
       /* struct stream_out *out = (struct stream_out *)stream;
    
        return out->format;*/
    
        return AUDIO_FORMAT_PCM_16_BIT;
    }