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

Commit 52247733 authored by Andy Hung's avatar Andy Hung Committed by Automerger Merge Worker
Browse files

Merge "AudioFlinger: Refactor SyncEvent" am: b87f4cad am: eb60033a am:...

Merge "AudioFlinger: Refactor SyncEvent" am: b87f4cad am: eb60033a am: 8385fb5f am: 3cb4028e am: 0e089ce0

Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/2599067



Change-Id: I821eb970660a3b1627e79e5943b9fd5066066ce6
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 55afea81 0e089ce0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4003,7 +4003,7 @@ void AudioFlinger::updateSecondaryOutputsForTrack_l(
    track->setTeePatchesToUpdate(std::move(teePatches));
}

sp<AudioFlinger::SyncEvent> AudioFlinger::createSyncEvent(AudioSystem::sync_event_t type,
sp<SyncEvent> AudioFlinger::createSyncEvent(AudioSystem::sync_event_t type,
                                    audio_session_t triggerSession,
                                    audio_session_t listenerSession,
                                    sync_event_callback_t callBack,
+1 −37
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@

#include <sounddose/SoundDoseManager.h>
#include <timing/MonotonicFrameCounter.h>
#include <timing/SyncEvent.h>

#include "FastCapture.h"
#include "FastMixer.h"
@@ -383,43 +384,6 @@ public:

    static inline std::atomic<AudioFlinger *> gAudioFlinger = nullptr;

    class SyncEvent;

    typedef void (*sync_event_callback_t)(const wp<SyncEvent>& event) ;

    class SyncEvent : public RefBase {
    public:
        SyncEvent(AudioSystem::sync_event_t type,
                  audio_session_t triggerSession,
                  audio_session_t listenerSession,
                  sync_event_callback_t callBack,
                  const wp<RefBase>& cookie)
        : mType(type), mTriggerSession(triggerSession), mListenerSession(listenerSession),
          mCallback(callBack), mCookie(cookie)
        {}

        virtual ~SyncEvent() {}

        void trigger() {
            Mutex::Autolock _l(mLock);
            if (mCallback) mCallback(wp<SyncEvent>(this));
        }
        bool isCancelled() const { Mutex::Autolock _l(mLock); return (mCallback == NULL); }
        void cancel() { Mutex::Autolock _l(mLock); mCallback = NULL; }
        AudioSystem::sync_event_t type() const { return mType; }
        audio_session_t triggerSession() const { return mTriggerSession; }
        audio_session_t listenerSession() const { return mListenerSession; }
        wp<RefBase> cookie() const { return mCookie; }

    private:
          const AudioSystem::sync_event_t mType;
          const audio_session_t mTriggerSession;
          const audio_session_t mListenerSession;
          sync_event_callback_t mCallback;
          const wp<RefBase> mCookie;
          mutable Mutex mLock;
    };

    sp<SyncEvent> createSyncEvent(AudioSystem::sync_event_t type,
                                        audio_session_t triggerSession,
                                        audio_session_t listenerSession,
+58 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.
 */

#pragma once

namespace android {

class SyncEvent;

typedef void (*sync_event_callback_t)(const wp<SyncEvent>& event) ;

class SyncEvent : public RefBase {
public:
    SyncEvent(AudioSystem::sync_event_t type,
              audio_session_t triggerSession,
              audio_session_t listenerSession,
              sync_event_callback_t callBack,
              const wp<RefBase>& cookie)
    : mType(type), mTriggerSession(triggerSession), mListenerSession(listenerSession),
      mCallback(callBack), mCookie(cookie)
    {}

    virtual ~SyncEvent() {}

    void trigger() {
        Mutex::Autolock _l(mLock);
        if (mCallback) mCallback(wp<SyncEvent>(this));
    }
    bool isCancelled() const { Mutex::Autolock _l(mLock); return (mCallback == NULL); }
    void cancel() { Mutex::Autolock _l(mLock); mCallback = NULL; }
    AudioSystem::sync_event_t type() const { return mType; }
    audio_session_t triggerSession() const { return mTriggerSession; }
    audio_session_t listenerSession() const { return mListenerSession; }
    wp<RefBase> cookie() const { return mCookie; }

private:
      const AudioSystem::sync_event_t mType;
      const audio_session_t mTriggerSession;
      const audio_session_t mListenerSession;
      sync_event_callback_t mCallback;
      const wp<RefBase> mCookie;
      mutable Mutex mLock;
};

} // namespace android