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

Commit 523b3047 authored by Phil Burk's avatar Phil Burk
Browse files

aaudio: keep track of streams using strong pointers

Maintain strong pointer to service stream during service calls.
Use simple AAudioStreamTracker instead of complex HandleTracker.

Bug: 65280854
Test: affects all MMAP streams, run all CTS tests, etcetera
Change-Id: I3d2ed8b588ea39c216dacd4dea503b11c33f36f3
parent 1e0c671e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -744,12 +744,12 @@ WARN_LOGFILE =
# Note: If this tag is empty the current directory is searched.

INPUT                  = include/aaudio/AAudio.h \
                         src/binding/AAudioCommon.h \
                         src/legacy/AudioStreamTrack.h \
                         src/legacy/AudioStreamRecord.h \
                         src/legacy/AAudioLegacy.h \
                         src/core/AudioStreamBuilder.h \
                         src/core/AudioStream.h \
                         src/utility/HandleTracker.h \
                         src/utility/MonotonicCounter.h \
                         src/utility/AudioClock.h \
                         src/utility/AAudioUtilities.h
+0 −2
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ LOCAL_SRC_FILES = \
    legacy/AudioStreamLegacy.cpp \
    legacy/AudioStreamRecord.cpp \
    legacy/AudioStreamTrack.cpp \
    utility/HandleTracker.cpp \
    utility/AAudioUtilities.cpp \
    utility/FixedBlockAdapter.cpp \
    utility/FixedBlockReader.cpp \
@@ -95,7 +94,6 @@ LOCAL_SRC_FILES = core/AudioStream.cpp \
    legacy/AudioStreamLegacy.cpp \
    legacy/AudioStreamRecord.cpp \
    legacy/AudioStreamTrack.cpp \
    utility/HandleTracker.cpp \
    utility/AAudioUtilities.cpp \
    utility/FixedBlockAdapter.cpp \
    utility/FixedBlockReader.cpp \
+32 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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_AAUDIO_COMMON_H
#define ANDROID_AAUDIO_COMMON_H

#include <stdint.h>

/*
 * Internal header that is common to both client and server.
 *
 */
namespace aaudio {

typedef int32_t aaudio_handle_t;

} /* namespace aaudio */

#endif // ANDROID_AAUDIO_COMMON_H
+2 −2
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@

#include <aaudio/AAudio.h>

#include "utility/HandleTracker.h"
#include "binding/AAudioCommon.h"

namespace android {

@@ -33,7 +33,7 @@ public:

    DECLARE_META_INTERFACE(AAudioClient);

    virtual void onStreamChange(aaudio_handle_t handle, int32_t opcode, int32_t value) = 0;
    virtual void onStreamChange(aaudio::aaudio_handle_t handle, int32_t opcode, int32_t value) = 0;

};

+6 −6
Original line number Diff line number Diff line
@@ -24,12 +24,12 @@

#include <aaudio/AAudio.h>

#include "binding/AAudioCommon.h"
#include "binding/AAudioServiceDefinitions.h"
#include "binding/AudioEndpointParcelable.h"
#include "binding/AAudioStreamRequest.h"
#include "binding/AAudioStreamConfiguration.h"
#include "binding/AAudioStreamRequest.h"
#include "binding/AudioEndpointParcelable.h"
#include "binding/IAAudioClient.h"
#include "utility/HandleTracker.h"

namespace android {

@@ -51,7 +51,7 @@ public:
     * @param configuration contains information about the created stream
     * @return handle to the stream or a negative error
     */
    virtual aaudio_handle_t openStream(const aaudio::AAudioStreamRequest &request,
    virtual aaudio::aaudio_handle_t openStream(const aaudio::AAudioStreamRequest &request,
                                     aaudio::AAudioStreamConfiguration &configurationOutput) = 0;

    virtual aaudio_result_t closeStream(aaudio::aaudio_handle_t streamHandle) = 0;
@@ -89,11 +89,11 @@ public:
    /**
     * Manage the specified thread as a low latency audio thread.
     */
    virtual aaudio_result_t registerAudioThread(aaudio_handle_t streamHandle,
    virtual aaudio_result_t registerAudioThread(aaudio::aaudio_handle_t streamHandle,
                                              pid_t clientThreadId,
                                              int64_t periodNanoseconds) = 0;

    virtual aaudio_result_t unregisterAudioThread(aaudio_handle_t streamHandle,
    virtual aaudio_result_t unregisterAudioThread(aaudio::aaudio_handle_t streamHandle,
                                                pid_t clientThreadId) = 0;
};

Loading