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

Commit 8c6297e4 authored by Pavan Chikkala's avatar Pavan Chikkala Committed by Ethan Chen
Browse files

audio: Initial changes for LPA/Tunnel

Initial changes to enable Tunnel/LPA feature

Change-Id: Id3df3b9ad1a11a045be7280a080a0ac166fcdfc6
parent d0ea1164
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
 * Not a Contribution.
 * Copyright (C) 2008 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
@@ -163,6 +165,7 @@ public:
        INPUT_CLOSED,
        INPUT_CONFIG_CHANGED,
        STREAM_CONFIG_CHANGED,
        EFFECT_CONFIG_CHANGED,
        NUM_CONFIG_EVENTS
    };

+16 −5
Original line number Diff line number Diff line
/*
 * Copyright (c) 2013, The Linux Foundation. All rights reserved.
 * Not a Contribution.
 * Copyright (C) 2007 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,7 +24,8 @@
#include <media/AudioTimestamp.h>
#include <media/IAudioTrack.h>
#include <utils/threads.h>

#include <media/IDirectTrack.h>
#include <media/IDirectTrackClient.h>
namespace android {

// ----------------------------------------------------------------------------
@@ -33,7 +36,8 @@ class StaticAudioTrackClientProxy;

// ----------------------------------------------------------------------------

class AudioTrack : public RefBase
class AudioTrack : public BnDirectTrackClient,
                   virtual public RefBase
{
public:

@@ -61,6 +65,7 @@ public:
        EVENT_NEW_TIMESTAMP = 8,    // Delivered periodically and when there's a significant change
                                    // in the mapping from frame position to presentation time.
                                    // See AudioTimestamp for the information included with event.
        EVENT_HW_FAIL = 9,          // ADSP failure.
    };

    /* Client should declare Buffer on the stack and pass address to obtainBuffer()
@@ -221,9 +226,8 @@ public:
    /* Terminates the AudioTrack and unregisters it from AudioFlinger.
     * Also destroys all resources associated with the AudioTrack.
     */
protected:

                        virtual ~AudioTrack();
public:

    /* Initialize an AudioTrack that was created using the AudioTrack() constructor.
     * Don't call set() more than once, or after the AudioTrack() constructors that take parameters.
@@ -590,7 +594,9 @@ public:
     *
     * The timestamp parameter is undefined on return, if status is not NO_ERROR.
     */
            status_t    getTimestamp(AudioTimestamp& timestamp);
      virtual status_t    getTimestamp(AudioTimestamp& timestamp);
      virtual void notify(int msg);
      virtual status_t    getTimeStamp(uint64_t *tstamp);

protected:
    /* copying audio tracks is not allowed */
@@ -671,12 +677,14 @@ protected:
            uint32_t updateAndGetPosition_l();

    // Next 4 fields may be changed if IAudioTrack is re-created, but always != 0
    sp<IDirectTrack>        mDirectTrack;
    sp<IAudioTrack>         mAudioTrack;
    sp<IMemory>             mCblkMemory;
    audio_track_cblk_t*     mCblk;                  // re-load after mLock.unlock()
    audio_io_handle_t       mOutput;                // returned by AudioSystem::getOutput()

    sp<AudioTrackThread>    mAudioTrackThread;
    sp<IAudioFlinger>       mAudioFlinger;

    float                   mVolume[2];
    float                   mSendLevel;
@@ -758,6 +766,9 @@ protected:
                                                    // only used for offloaded and direct tracks.

    audio_output_flags_t    mFlags;
    audio_io_handle_t       mAudioDirectOutput;
    void*                   mObserver;

        // const after set(), except for bits AUDIO_OUTPUT_FLAG_FAST and AUDIO_OUTPUT_FLAG_OFFLOAD.
        // mLock must be held to read or write those bits reliably.

+17 −1
Original line number Diff line number Diff line
/*
 * Copyright (C) 2007 The Android Open Source Project
 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
 * Not a contribution.
 * Copyright (C) 2007 The Android Open Source Project.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -24,6 +26,8 @@
#include <utils/RefBase.h>
#include <utils/Errors.h>
#include <binder/IInterface.h>
#include <media/IDirectTrack.h>
#include <media/IDirectTrackClient.h>
#include <media/IAudioTrack.h>
#include <media/IAudioRecord.h>
#include <media/IAudioFlingerClient.h>
@@ -76,6 +80,18 @@ public:
                                int *sessionId,
                                int clientUid,
                                status_t *status) = 0;
    /* create a direct audio track and registers it with AudioFlinger.
     * return null if the track cannot be created.
     */
    virtual sp<IDirectTrack> createDirectTrack(
                                pid_t pid,
                                uint32_t sampleRate,
                                audio_channel_mask_t channelMask,
                                audio_io_handle_t output,
                                int *sessionId,
                                IDirectTrackClient* client,
                                audio_stream_type_t streamType,
                                status_t *status) = 0;

    virtual sp<IAudioRecord> openRecord(
                                // On successful return, AudioFlinger takes over the handle
+92 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
 * Not a Contribution.
 *
 * Copyright (C) 2007 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef ANDROID_IDIRECTTRACK_H
#define ANDROID_IDIRECTTRACK_H

#include <stdint.h>
#include <sys/types.h>

#include <utils/RefBase.h>
#include <utils/Errors.h>
#include <binder/IInterface.h>
#include <binder/IMemory.h>


namespace android {

// ----------------------------------------------------------------------------

class IDirectTrack : public IInterface
{
public:
    DECLARE_META_INTERFACE(DirectTrack);

    /* After it's created the track is not active. Call start() to
     * make it active. If set, the callback will start being called.
     */
    virtual status_t    start() = 0;

    /* Stop a track. If set, the callback will cease being called and
     * obtainBuffer will return an error. Buffers that are already released
     * will be processed, unless flush() is called.
     */
    virtual void        stop() = 0;

    /* flush a stopped track. All pending buffers are discarded.
     * This function has no effect if the track is not stoped.
     */
    virtual void        flush() = 0;

    /* mute or unmutes this track.
     * While mutted, the callback, if set, is still called.
     */
    virtual void        mute(bool) = 0;

    /* Pause a track. If set, the callback will cease being called and
     * obtainBuffer will return an error. Buffers that are already released
     * will be processed, unless flush() is called.
     */
    virtual void        pause() = 0;

    /* set volume for both left and right channels.
     */
    virtual void        setVolume(float l, float r) = 0;

    virtual ssize_t     write(const void*, size_t) =  0;

    virtual int64_t     getTimeStamp() =  0;
};

// ----------------------------------------------------------------------------

class BnDirectTrack : public BnInterface<IDirectTrack>
{
public:
    virtual status_t    onTransact( uint32_t code,
                                    const Parcel& data,
                                    Parcel* reply,
                                    uint32_t flags = 0);
};

// ----------------------------------------------------------------------------

}; // namespace android

#endif // ANDROID_IAUDIOTRACK_H
+50 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
 * Not a Contribution.
 *
 * Copyright (C) 2007 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef ANDROID_IDIRECTTRACKCLIENT_H
#define ANDROID_IDIRECTTRACKCLIENT_H

#include <utils/RefBase.h>
#include <binder/IInterface.h>
#include <binder/Parcel.h>

namespace android {

class IDirectTrackClient: public IInterface
{
public:
    DECLARE_META_INTERFACE(DirectTrackClient);

    virtual void notify(int msg) = 0;
};

// ----------------------------------------------------------------------------

class BnDirectTrackClient: public BnInterface<IDirectTrackClient>
{
public:
    virtual status_t    onTransact( uint32_t code,
                                    const Parcel& data,
                                    Parcel* reply,
                                    uint32_t flags = 0);
};

}; // namespace android

#endif // ANDROID_IDIRECTTRACKCLIENT_H
Loading