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

Commit eb7de450 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi Committed by Android (Google) Code Review
Browse files

Merge "Add channel mask in AudioSink"

parents cdfc4fcd 786618ff
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -60,6 +60,8 @@ enum player_type {
#define DEFAULT_AUDIOSINK_BUFFERSIZE 1200
#define DEFAULT_AUDIOSINK_SAMPLERATE 44100

// when the channel mask isn't known, use the channel count to derive a mask in AudioSink::open()
#define CHANNEL_MASK_USE_CHANNEL_ORDER 0

// callback mechanism for passing messages to MediaPlayer object
typedef void (*notify_callback_f)(void* cookie,
@@ -91,7 +93,7 @@ public:
        // If no callback is specified, use the "write" API below to submit
        // audio data.
        virtual status_t    open(
                uint32_t sampleRate, int channelCount,
                uint32_t sampleRate, int channelCount, audio_channel_mask_t channelMask,
                audio_format_t format=AUDIO_FORMAT_PCM_16_BIT,
                int bufferCount=DEFAULT_AUDIOSINK_BUFFERCOUNT,
                AudioCallback cb = NULL,
+1 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ enum {
    kKeyStride            = 'strd',  // int32_t
    kKeySliceHeight       = 'slht',  // int32_t
    kKeyChannelCount      = '#chn',  // int32_t
    kKeyChannelMask       = 'chnm',  // int32_t
    kKeySampleRate        = 'srte',  // int32_t (audio sampling rate Hz)
    kKeyFrameRate         = 'frmR',  // int32_t (video frame rate fps)
    kKeyBitRate           = 'brte',  // int32_t (bps)
+17 −6
Original line number Diff line number Diff line
@@ -1458,7 +1458,8 @@ status_t MediaPlayerService::AudioOutput::getPosition(uint32_t *position)
}

status_t MediaPlayerService::AudioOutput::open(
        uint32_t sampleRate, int channelCount, audio_format_t format, int bufferCount,
        uint32_t sampleRate, int channelCount, audio_channel_mask_t channelMask,
        audio_format_t format, int bufferCount,
        AudioCallback cb, void *cookie)
{
    mCallback = cb;
@@ -1470,7 +1471,8 @@ status_t MediaPlayerService::AudioOutput::open(
        bufferCount = mMinBufferCount;

    }
    ALOGV("open(%u, %d, %d, %d, %d)", sampleRate, channelCount, format, bufferCount,mSessionId);
    ALOGV("open(%u, %d, 0x%x, %d, %d, %d)", sampleRate, channelCount, channelMask,
            format, bufferCount, mSessionId);
    if (mTrack) close();
    int afSampleRate;
    int afFrameCount;
@@ -1485,13 +1487,21 @@ status_t MediaPlayerService::AudioOutput::open(

    frameCount = (sampleRate*afFrameCount*bufferCount)/afSampleRate;

    if (channelMask == CHANNEL_MASK_USE_CHANNEL_ORDER) {
        channelMask = audio_channel_mask_from_count(channelCount);
        if (0 == channelMask) {
            ALOGE("open() error, can\'t derive mask for %d audio channels", channelCount);
            return NO_INIT;
        }
    }

    AudioTrack *t;
    if (mCallback != NULL) {
        t = new AudioTrack(
                mStreamType,
                sampleRate,
                format,
                (channelCount == 2) ? AUDIO_CHANNEL_OUT_STEREO : AUDIO_CHANNEL_OUT_MONO,
                channelMask,
                frameCount,
                0 /* flags */,
                CallbackWrapper,
@@ -1503,7 +1513,7 @@ status_t MediaPlayerService::AudioOutput::open(
                mStreamType,
                sampleRate,
                format,
                (channelCount == 2) ? AUDIO_CHANNEL_OUT_STEREO : AUDIO_CHANNEL_OUT_MONO,
                channelMask,
                frameCount,
                0,
                NULL,
@@ -1751,10 +1761,11 @@ bool CallbackThread::threadLoop() {
////////////////////////////////////////////////////////////////////////////////

status_t MediaPlayerService::AudioCache::open(
        uint32_t sampleRate, int channelCount, audio_format_t format, int bufferCount,
        uint32_t sampleRate, int channelCount, audio_channel_mask_t channelMask,
        audio_format_t format, int bufferCount,
        AudioCallback cb, void *cookie)
{
    ALOGV("open(%u, %d, %d, %d)", sampleRate, channelCount, format, bufferCount);
    ALOGV("open(%u, %d, 0x%x, %d, %d)", sampleRate, channelCount, channelMask, format, bufferCount);
    if (mHeap->getHeapID() < 0) {
        return NO_INIT;
    }
+3 −3
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ class MediaPlayerService : public BnMediaPlayerService
        virtual int             getSessionId();

        virtual status_t        open(
                uint32_t sampleRate, int channelCount,
                uint32_t sampleRate, int channelCount, audio_channel_mask_t channelMask,
                audio_format_t format, int bufferCount,
                AudioCallback cb, void *cookie);

@@ -145,8 +145,8 @@ class MediaPlayerService : public BnMediaPlayerService
        virtual int             getSessionId();

        virtual status_t        open(
                uint32_t sampleRate, int channelCount, audio_format_t format,
                int bufferCount = 1,
                uint32_t sampleRate, int channelCount, audio_channel_mask_t channelMask,
                audio_format_t format, int bufferCount = 1,
                AudioCallback cb = NULL, void *cookie = NULL);

        virtual void            start();
+2 −1
Original line number Diff line number Diff line
@@ -421,7 +421,8 @@ status_t MidiFile::setLooping(int loop)
}

status_t MidiFile::createOutputTrack() {
    if (mAudioSink->open(pLibConfig->sampleRate, pLibConfig->numChannels, AUDIO_FORMAT_PCM_16_BIT, 2) != NO_ERROR) {
    if (mAudioSink->open(pLibConfig->sampleRate, pLibConfig->numChannels,
            CHANNEL_MASK_USE_CHANNEL_ORDER, AUDIO_FORMAT_PCM_16_BIT, 2) != NO_ERROR) {
        ALOGE("mAudioSink open failed");
        return ERROR_OPEN_FAILED;
    }
Loading