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

Commit bbb0ac8f authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I3200e32e,I9ac3db0c,I5530dfe4,I317e2cbc,I501a5956, ...

* changes:
  AudioAidlLegacyConversionTest: Added test for Aidl2Legacy2Aidl.
  AudioAidlLegacyConversionTest: Added test for Aidl2Legacy2Aidl.
  Updates to audiotrack tests
  Update AudioEffect callers to new interface
  Add tests to libaudioclient pre- and post-submit
  Remove legacy callback interfaces
  Update audiorecord tests
  Skip test if chosen effect is not available on device
  Add audio routing tests
  Add unit tests for trackPlayerBase
  Add serialization tests for libaudioclient
  Add audioeffect unit tests
  Add audiotrack unit tests
  Add audiorecord unit tests
  Enable clang format hook for media/libaudioclient/tests
parents c17d5a14 6155e65c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -11,3 +11,4 @@ clang_format = true
clang_format = --commit ${PREUPLOAD_COMMIT} --style file --extensions c,h,cc,cpp
               media/libmediatranscoding/
               services/mediatranscoding/
               media/libaudioclient/tests/
+0 −95
Original line number Diff line number Diff line
@@ -139,39 +139,6 @@ AudioRecord::AudioRecord(const AttributionSourceState &client)
{
}

AudioRecord::AudioRecord(
        audio_source_t inputSource,
        uint32_t sampleRate,
        audio_format_t format,
        audio_channel_mask_t channelMask,
        const AttributionSourceState& client,
        size_t frameCount,
        legacy_callback_t callback,
        void* user,
        uint32_t notificationFrames,
        audio_session_t sessionId,
        transfer_type transferType,
        audio_input_flags_t flags,
        const audio_attributes_t* pAttributes,
        audio_port_handle_t selectedDeviceId,
        audio_microphone_direction_t selectedMicDirection,
        float microphoneFieldDimension)
    : mActive(false),
      mStatus(NO_INIT),
      mClientAttributionSource(client),
      mSessionId(AUDIO_SESSION_ALLOCATE),
      mPreviousPriority(ANDROID_PRIORITY_NORMAL),
      mPreviousSchedulingGroup(SP_DEFAULT),
      mProxy(NULL)
{
    uid_t uid = VALUE_OR_FATAL(aidl2legacy_int32_t_uid_t(mClientAttributionSource.uid));
    pid_t pid = VALUE_OR_FATAL(aidl2legacy_int32_t_pid_t(mClientAttributionSource.pid));
    (void)set(inputSource, sampleRate, format, channelMask, frameCount, callback, user,
            notificationFrames, false /*threadCanCallJava*/, sessionId, transferType, flags,
            uid, pid, pAttributes, selectedDeviceId, selectedMicDirection,
            microphoneFieldDimension);
}

AudioRecord::AudioRecord(
        audio_source_t inputSource,
        uint32_t sampleRate,
@@ -255,37 +222,6 @@ void AudioRecord::stopAndJoinCallbacks() {
        mDeviceCallback.clear();
    }
}
namespace {
class LegacyCallbackWrapper : public AudioRecord::IAudioRecordCallback {
    const AudioRecord::legacy_callback_t mCallback;
    void* const mData;

  public:
    LegacyCallbackWrapper(AudioRecord::legacy_callback_t callback, void* user)
        : mCallback(callback), mData(user) {}

    size_t onMoreData(const AudioRecord::Buffer& buffer) override {
        AudioRecord::Buffer copy = buffer;
        mCallback(AudioRecord::EVENT_MORE_DATA, mData, &copy);
        return copy.size();
    }

    void onOverrun() override { mCallback(AudioRecord::EVENT_OVERRUN, mData, nullptr); }

    void onMarker(uint32_t markerPosition) override {
        mCallback(AudioRecord::EVENT_MARKER, mData, &markerPosition);
    }

    void onNewPos(uint32_t newPos) override {
        mCallback(AudioRecord::EVENT_NEW_POS, mData, &newPos);
    }

    void onNewIAudioRecord() override {
        mCallback(AudioRecord::EVENT_NEW_IAUDIORECORD, mData, nullptr);
    }
};
}  // namespace

status_t AudioRecord::set(
        audio_source_t inputSource,
        uint32_t sampleRate,
@@ -479,37 +415,6 @@ exit:
    return status;
}

status_t AudioRecord::set(
        audio_source_t inputSource,
        uint32_t sampleRate,
        audio_format_t format,
        audio_channel_mask_t channelMask,
        size_t frameCount,
        legacy_callback_t callback,
        void* user,
        uint32_t notificationFrames,
        bool threadCanCallJava,
        audio_session_t sessionId,
        transfer_type transferType,
        audio_input_flags_t flags,
        uid_t uid,
        pid_t pid,
        const audio_attributes_t* pAttributes,
        audio_port_handle_t selectedDeviceId,
        audio_microphone_direction_t selectedMicDirection,
        float microphoneFieldDimension,
        int32_t maxSharedAudioHistoryMs)
{
    if (callback != nullptr) {
        mLegacyCallbackWrapper = sp<LegacyCallbackWrapper>::make(callback, user);
    } else if (user) {
        LOG_ALWAYS_FATAL("Callback data provided without callback pointer!");
    }
    return set(inputSource, sampleRate, format, channelMask, frameCount, mLegacyCallbackWrapper,
        notificationFrames, threadCanCallJava, sessionId, transferType, flags, uid, pid,
        pAttributes, selectedDeviceId, selectedMicDirection, microphoneFieldDimension,
        maxSharedAudioHistoryMs);
}
// -------------------------------------------------------------------------

status_t AudioRecord::start(AudioSystem::sync_event_t event, audio_session_t triggerSession)
+0 −109
Original line number Diff line number Diff line
@@ -325,45 +325,6 @@ namespace {
        }
    };
}

AudioTrack::AudioTrack(
        audio_stream_type_t streamType,
        uint32_t sampleRate,
        audio_format_t format,
        audio_channel_mask_t channelMask,
        size_t frameCount,
        audio_output_flags_t flags,
        legacy_callback_t callback,
        void* user,
        int32_t notificationFrames,
        audio_session_t sessionId,
        transfer_type transferType,
        const audio_offload_info_t *offloadInfo,
        const AttributionSourceState& attributionSource,
        const audio_attributes_t* pAttributes,
        bool doNotReconnect,
        float maxRequiredSpeed,
        audio_port_handle_t selectedDeviceId)
    : mStatus(NO_INIT),
      mState(STATE_STOPPED),
      mPreviousPriority(ANDROID_PRIORITY_NORMAL),
      mPreviousSchedulingGroup(SP_DEFAULT),
      mPausedPosition(0),
      mAudioTrackCallback(new AudioTrackCallback())
{
    mAttributes = AUDIO_ATTRIBUTES_INITIALIZER;
    if (callback != nullptr) {
        mLegacyCallbackWrapper = sp<LegacyCallbackWrapper>::make(callback, user);
    } else if (user) {
        LOG_ALWAYS_FATAL("Callback data provided without callback pointer!");
    }
    mSetParams = std::unique_ptr<SetParams>{new SetParams{
            streamType, sampleRate, format, channelMask, frameCount, flags, mLegacyCallbackWrapper,
            notificationFrames, 0 /*sharedBuffer*/, false /*threadCanCallJava*/, sessionId,
            transferType, offloadInfo, attributionSource, pAttributes, doNotReconnect,
            maxRequiredSpeed, selectedDeviceId}};
}

AudioTrack::AudioTrack(
        audio_stream_type_t streamType,
        uint32_t sampleRate,
@@ -397,44 +358,6 @@ AudioTrack::AudioTrack(
                          doNotReconnect, maxRequiredSpeed, AUDIO_PORT_HANDLE_NONE}};
}

AudioTrack::AudioTrack(
        audio_stream_type_t streamType,
        uint32_t sampleRate,
        audio_format_t format,
        audio_channel_mask_t channelMask,
        const sp<IMemory>& sharedBuffer,
        audio_output_flags_t flags,
        legacy_callback_t callback,
        void* user,
        int32_t notificationFrames,
        audio_session_t sessionId,
        transfer_type transferType,
        const audio_offload_info_t *offloadInfo,
        const AttributionSourceState& attributionSource,
        const audio_attributes_t* pAttributes,
        bool doNotReconnect,
        float maxRequiredSpeed)
    : mStatus(NO_INIT),
      mState(STATE_STOPPED),
      mPreviousPriority(ANDROID_PRIORITY_NORMAL),
      mPreviousSchedulingGroup(SP_DEFAULT),
      mPausedPosition(0),
      mSelectedDeviceId(AUDIO_PORT_HANDLE_NONE),
      mAudioTrackCallback(new AudioTrackCallback())
{
    mAttributes = AUDIO_ATTRIBUTES_INITIALIZER;
    if (callback) {
        mLegacyCallbackWrapper = sp<LegacyCallbackWrapper>::make(callback, user);
    } else if (user) {
        LOG_ALWAYS_FATAL("Callback data provided without callback pointer!");
    }
    mSetParams = std::unique_ptr<SetParams>{new SetParams{
            streamType, sampleRate, format, channelMask, 0 /*frameCount*/, flags,
            mLegacyCallbackWrapper, notificationFrames, sharedBuffer, false /*threadCanCallJava*/,
            sessionId, transferType, offloadInfo, attributionSource, pAttributes, doNotReconnect,
            maxRequiredSpeed, AUDIO_PORT_HANDLE_NONE}};
}

void AudioTrack::onFirstRef() {
    if (mSetParams) {
        set(*mSetParams);
@@ -496,38 +419,6 @@ void AudioTrack::stopAndJoinCallbacks() {
        mDeviceCallback.clear();
    }
}

status_t AudioTrack::set(
        audio_stream_type_t streamType,
        uint32_t sampleRate,
        audio_format_t format,
        audio_channel_mask_t channelMask,
        size_t frameCount,
        audio_output_flags_t flags,
        legacy_callback_t callback,
        void * user,
        int32_t notificationFrames,
        const sp<IMemory>& sharedBuffer,
        bool threadCanCallJava,
        audio_session_t sessionId,
        transfer_type transferType,
        const audio_offload_info_t *offloadInfo,
        const AttributionSourceState& attributionSource,
        const audio_attributes_t* pAttributes,
        bool doNotReconnect,
        float maxRequiredSpeed,
        audio_port_handle_t selectedDeviceId)
{
    if (callback) {
        mLegacyCallbackWrapper = sp<LegacyCallbackWrapper>::make(callback, user);
    } else if (user) {
        LOG_ALWAYS_FATAL("Callback data provided without callback pointer!");
    }
    return set(streamType, sampleRate,format, channelMask, frameCount, flags,
               mLegacyCallbackWrapper, notificationFrames, sharedBuffer, threadCanCallJava,
               sessionId, transferType, offloadInfo, attributionSource, pAttributes,
               doNotReconnect, maxRequiredSpeed, selectedDeviceId);
}
status_t AudioTrack::set(
        audio_stream_type_t streamType,
        uint32_t sampleRate,
+20 −0
Original line number Diff line number Diff line
@@ -3,6 +3,9 @@
    {
      "name": "audio_aidl_conversion_tests"
    },
    {
      "name": "audio_aidl_status_tests"
    },
    {
      "name": "CtsNativeMediaAAudioTestCases",
      "options" : [
@@ -11,5 +14,22 @@
        }
      ]
    }
  ],
  "postsubmit": [
    {
      "name": "audieorecord_tests"
    },
    {
      "name": "audioeffect_tests"
    },
    {
      "name": "audiorouting_tests"
    },
    {
      "name": "audioclient_serialization_tests"
    },
    {
      "name": "trackplayerbase_tests"
    }
  ]
}
+0 −61
Original line number Diff line number Diff line
@@ -46,27 +46,6 @@ class AudioRecord : public AudioSystem::AudioDeviceCallback
{
public:

    /* Events used by AudioRecord callback function (legacy_callback_t).
     * Keep in sync with frameworks/base/media/java/android/media/AudioRecord.java NATIVE_EVENT_*.
     */
    enum event_type {
        EVENT_MORE_DATA = 0,        // Request to read available data from buffer.
                                    // If this event is delivered but the callback handler
                                    // does not want to read the available data, the handler must
                                    // explicitly ignore the event by setting frameCount to zero.
        EVENT_OVERRUN = 1,          // Buffer overrun occurred.
        EVENT_MARKER = 2,           // Record head is at the specified marker position
                                    // (See setMarkerPosition()).
        EVENT_NEW_POS = 3,          // Record head is at a new position
                                    // (See setPositionUpdatePeriod()).
        EVENT_NEW_IAUDIORECORD = 4, // IAudioRecord was re-created, either due to re-routing and
                                    // voluntary invalidation by mediaserver, or mediaserver crash.
    };

    /* Client should declare a Buffer and pass address to obtainBuffer()
     * and releaseBuffer().  See also legacy_callback_t for EVENT_MORE_DATA.
     */

    class Buffer
    {
      friend AudioRecord;
@@ -122,7 +101,6 @@ public:
     *          - EVENT_NEW_IAUDIORECORD: unused.
     */

    typedef void (*legacy_callback_t)(int event, void* user, void *info);

    class IAudioRecordCallback : public virtual RefBase {
        friend AudioRecord;
@@ -226,24 +204,6 @@ public:
                                    float selectedMicFieldDimension = MIC_FIELD_DIMENSION_DEFAULT);


                        AudioRecord(audio_source_t inputSource,
                                    uint32_t sampleRate,
                                    audio_format_t format,
                                    audio_channel_mask_t channelMask,
                                    const android::content::AttributionSourceState& client,
                                    size_t frameCount,
                                    legacy_callback_t callback,
                                    void* user,
                                    uint32_t notificationFrames = 0,
                                    audio_session_t sessionId = AUDIO_SESSION_ALLOCATE,
                                    transfer_type transferType = TRANSFER_DEFAULT,
                                    audio_input_flags_t flags = AUDIO_INPUT_FLAG_NONE,
                                    const audio_attributes_t* pAttributes = nullptr,
                                    audio_port_handle_t selectedDeviceId = AUDIO_PORT_HANDLE_NONE,
                                    audio_microphone_direction_t
                                        selectedMicDirection = MIC_DIRECTION_UNSPECIFIED,
                                    float selectedMicFieldDimension = MIC_FIELD_DIMENSION_DEFAULT);

    /* Terminates the AudioRecord and unregisters it from AudioFlinger.
     * Also destroys all resources associated with the AudioRecord.
     */
@@ -286,27 +246,6 @@ public:
                            float selectedMicFieldDimension = MIC_FIELD_DIMENSION_DEFAULT,
                            int32_t maxSharedAudioHistoryMs = 0);

           status_t    set(audio_source_t inputSource,
                            uint32_t sampleRate,
                            audio_format_t format,
                            audio_channel_mask_t channelMask,
                            size_t frameCount,
                            legacy_callback_t callback,
                            void* user,
                            uint32_t notificationFrames = 0,
                            bool threadCanCallJava = false,
                            audio_session_t sessionId = AUDIO_SESSION_ALLOCATE,
                            transfer_type transferType = TRANSFER_DEFAULT,
                            audio_input_flags_t flags = AUDIO_INPUT_FLAG_NONE,
                            uid_t uid = AUDIO_UID_INVALID,
                            pid_t pid = -1,
                            const audio_attributes_t* pAttributes = nullptr,
                            audio_port_handle_t selectedDeviceId = AUDIO_PORT_HANDLE_NONE,
                            audio_microphone_direction_t
                                selectedMicDirection = MIC_DIRECTION_UNSPECIFIED,
                            float selectedMicFieldDimension = MIC_FIELD_DIMENSION_DEFAULT,
                            int32_t maxSharedAudioHistoryMs = 0);

    /* Result of constructing the AudioRecord. This must be checked for successful initialization
     * before using any AudioRecord API (except for set()), because using
     * an uninitialized AudioRecord produces undefined results.
Loading