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

Commit b69681c8 authored by Eric Laurent's avatar Eric Laurent
Browse files

AudioSystem: added JNI for routing extensions

Bug: 14815883.

Change-Id: Ia0c0d14a8e3051a4bc0ce502b6e979135b170c97
parent 575510c4
Loading
Loading
Loading
Loading
+54 −0
Original line number Original line Diff line number Diff line
@@ -23,6 +23,11 @@
#define ENCODING_PCM_16BIT 2
#define ENCODING_PCM_16BIT 2
#define ENCODING_PCM_8BIT  3
#define ENCODING_PCM_8BIT  3
#define ENCODING_PCM_FLOAT 4
#define ENCODING_PCM_FLOAT 4
#define ENCODING_INVALID 0
#define ENCODING_DEFAULT 1

#define CHANNEL_INVALID 0
#define CHANNEL_OUT_DEFAULT 1


static inline audio_format_t audioFormatToNative(int audioFormat)
static inline audio_format_t audioFormatToNative(int audioFormat)
{
{
@@ -33,9 +38,58 @@ static inline audio_format_t audioFormatToNative(int audioFormat)
        return AUDIO_FORMAT_PCM_8_BIT;
        return AUDIO_FORMAT_PCM_8_BIT;
    case ENCODING_PCM_FLOAT:
    case ENCODING_PCM_FLOAT:
        return AUDIO_FORMAT_PCM_FLOAT;
        return AUDIO_FORMAT_PCM_FLOAT;
    case ENCODING_DEFAULT:
        return AUDIO_FORMAT_DEFAULT;
    default:
    default:
        return AUDIO_FORMAT_INVALID;
        return AUDIO_FORMAT_INVALID;
    }
    }
}
}


static inline int audioFormatFromNative(audio_format_t nativeFormat)
{
    switch (nativeFormat) {
    case AUDIO_FORMAT_PCM_16_BIT:
        return ENCODING_PCM_16BIT;
    case AUDIO_FORMAT_PCM_8_BIT:
        return ENCODING_PCM_8BIT;
    case AUDIO_FORMAT_PCM_FLOAT:
        return ENCODING_PCM_FLOAT;
    case AUDIO_FORMAT_DEFAULT:
        return ENCODING_DEFAULT;
    default:
        return ENCODING_INVALID;
    }
}

static inline audio_channel_mask_t outChannelMaskToNative(int channelMask)
{
    switch (channelMask) {
    case CHANNEL_OUT_DEFAULT:
    case CHANNEL_INVALID:
        return AUDIO_CHANNEL_NONE;
    default:
        return (audio_channel_mask_t)(channelMask>>2);
    }
}

static inline int outChannelMaskFromNative(audio_channel_mask_t nativeMask)
{
    switch (nativeMask) {
    case AUDIO_CHANNEL_NONE:
        return CHANNEL_OUT_DEFAULT;
    default:
        return (int)nativeMask<<2;
    }
}

static inline audio_channel_mask_t inChannelMaskToNative(int channelMask)
{
    return (audio_channel_mask_t)channelMask;
}

static inline int inChannelMaskFromNative(audio_channel_mask_t nativeMask)
{
    return (int)nativeMask;
}

#endif // ANDROID_MEDIA_AUDIOFORMAT_H
#endif // ANDROID_MEDIA_AUDIOFORMAT_H