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

Commit 8162c1a9 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi
Browse files

Set channel mask when opening audio sink

Update the code to use the AudioSink::open() interface that
 takes a channel mask as an additional parameter. The code
 is only stereo, and returns an error when attempting to create
 a video editor audio sink with more than two channels.

Change-Id: Ib9bba067da0b286c08656976b89fba7c8b42f99f
parent 90b61910
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -511,7 +511,7 @@ status_t VideoEditorAudioPlayer::start(bool sourceAlreadyStarted) {

    if (mAudioSink.get() != NULL) {
        status_t err = mAudioSink->open(
                mSampleRate, numChannels, AUDIO_FORMAT_PCM_16_BIT,
                mSampleRate, numChannels, CHANNEL_MASK_USE_CHANNEL_ORDER, AUDIO_FORMAT_PCM_16_BIT,
                DEFAULT_AUDIOSINK_BUFFERCOUNT,
                &VideoEditorAudioPlayer::AudioSinkCallback, this);
        if (err != OK) {
+17 −5
Original line number Diff line number Diff line
@@ -383,7 +383,8 @@ status_t VideoEditorPlayer::VeAudioOutput::getPosition(uint32_t *position) {
}

status_t VideoEditorPlayer::VeAudioOutput::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;
@@ -413,14 +414,26 @@ status_t VideoEditorPlayer::VeAudioOutput::open(

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

    if (channelMask == CHANNEL_MASK_USE_CHANNEL_ORDER) {
        switch(channelCount) {
          case 1:
            channelMask = AUDIO_CHANNEL_OUT_MONO;
            break;
          case 2:
            channelMask = AUDIO_CHANNEL_OUT_STEREO;
            break;
          default:
            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,
@@ -430,8 +443,7 @@ status_t VideoEditorPlayer::VeAudioOutput::open(
                mStreamType,
                sampleRate,
                format,
                (channelCount == 2) ?
                 AUDIO_CHANNEL_OUT_STEREO : AUDIO_CHANNEL_OUT_MONO,
                channelMask,
                frameCount);
    }

+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ class VideoEditorPlayer : public MediaPlayerInterface {
        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);