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

Commit 6ac42ebf authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "aaudio: indicate client UID and PID to audio flinger" into oc-dr1-dev

parents 4a907a17 cb4dae21
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
../../media/libaudioclient/include/media/AudioClient.h
 No newline at end of file
+8 −11
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#define ANDROID_AUDIO_MMAP_STREAM_INTERFACE_H

#include <system/audio.h>
#include <media/AudioClient.h>
#include <utils/Errors.h>
#include <utils/RefBase.h>

@@ -37,12 +38,6 @@ class MmapStreamInterface : public virtual RefBase
        DIRECTION_INPUT,       /**< open a capture mmap stream */
    } stream_direction_t;

    class Client {
     public:
        uid_t clientUid;
        pid_t clientPid;
        String16 packageName;
    };
    /**
     * Open a playback or capture stream in MMAP mode at the audio HAL.
     *
@@ -53,13 +48,14 @@ class MmapStreamInterface : public virtual RefBase
     * \param[in,out] config audio parameters (sampling rate, format ...) for the stream.
     *                       Requested parameters as input,
     *                       Actual parameters as output
     * \param[in] client a Client struct describing the first client using this stream.
     * \param[in] client a AudioClient struct describing the first client using this stream.
     * \param[in,out] deviceId audio device the stream should preferably be routed to/from
     *                       Requested as input,
     *                       Actual as output
     * \param[in] callback the MmapStreamCallback interface used by AudioFlinger to notify
     *                     condition changes affecting the stream operation
     * \param[out] interface the MmapStreamInterface interface controlling the created stream
     * \param[out] same unique handle as the one used for the first client stream started.
     * \return OK if the stream was successfully created.
     *         NO_INIT if AudioFlinger is not properly initialized
     *         BAD_VALUE if the stream cannot be opened because of invalid arguments
@@ -68,10 +64,11 @@ class MmapStreamInterface : public virtual RefBase
    static status_t openMmapStream(stream_direction_t direction,
                                           const audio_attributes_t *attr,
                                           audio_config_base_t *config,
                                           const Client& client,
                                           const AudioClient& client,
                                           audio_port_handle_t *deviceId,
                                           const sp<MmapStreamCallback>& callback,
                                           sp<MmapStreamInterface>& interface);
                                           sp<MmapStreamInterface>& interface,
                                           audio_port_handle_t *handle);

    /**
     * Retrieve information on the mmap buffer used for audio samples transfer.
@@ -105,13 +102,13 @@ class MmapStreamInterface : public virtual RefBase
     * Start a stream operating in mmap mode.
     * createMmapBuffer() must be called before calling start()
     *
     * \param[in] client a Client struct describing the client starting on this stream.
     * \param[in] client a AudioClient struct describing the client starting on this stream.
     * \param[out] handle unique handle for this instance. Used with stop().
     * \return OK in case of success.
     *         NO_INIT in case of initialization error
     *         INVALID_OPERATION if called out of sequence
     */
    virtual status_t start(const Client& client, audio_port_handle_t *handle) = 0;
    virtual status_t start(const AudioClient& client, audio_port_handle_t *handle) = 0;

    /**
     * Stop a stream operating in mmap mode.
+11 −0
Original line number Diff line number Diff line
@@ -97,6 +97,17 @@ public:
    aaudio_result_t unregisterAudioThread(aaudio_handle_t streamHandle,
                                                  pid_t clientThreadId) override;

    aaudio_result_t startClient(aaudio_handle_t streamHandle __unused,
                                      const android::AudioClient& client __unused,
                                      audio_port_handle_t *clientHandle) override {
        return AAUDIO_ERROR_UNAVAILABLE;
    }

    aaudio_result_t stopClient(aaudio_handle_t streamHandle __unused,
                               audio_port_handle_t clientHandle __unused)  override {
        return AAUDIO_ERROR_UNAVAILABLE;
    }

    void onStreamChange(aaudio_handle_t handle, int32_t opcode, int32_t value) {
        // TODO This is just a stub so we can have a client Binder to pass to the service.
        // TODO Implemented in a later CL.
+8 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#define ANDROID_AAUDIO_BINDING_AAUDIO_SERVICE_INTERFACE_H

#include <utils/StrongPointer.h>
#include <media/AudioClient.h>

#include "binding/AAudioServiceDefinitions.h"
#include "binding/AAudioStreamRequest.h"
@@ -86,6 +87,13 @@ public:

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

    virtual aaudio_result_t startClient(aaudio_handle_t streamHandle,
                                      const android::AudioClient& client,
                                      audio_port_handle_t *clientHandle) = 0;

    virtual aaudio_result_t stopClient(aaudio_handle_t streamHandle,
                                       audio_port_handle_t clientHandle) = 0;
};

} /* namespace aaudio */
+10 −0
Original line number Diff line number Diff line
@@ -52,8 +52,12 @@ status_t AAudioStreamRequest::writeToParcel(Parcel* parcel) const {
    status = parcel->writeBool(mSharingModeMatchRequired);
    if (status != NO_ERROR) goto error;

    status = parcel->writeBool(mInService);
    if (status != NO_ERROR) goto error;

    status = mConfiguration.writeToParcel(parcel);
    if (status != NO_ERROR) goto error;

    return NO_ERROR;

error:
@@ -74,8 +78,12 @@ status_t AAudioStreamRequest::readFromParcel(const Parcel* parcel) {
    status = parcel->readBool(&mSharingModeMatchRequired);
    if (status != NO_ERROR) goto error;

    status = parcel->readBool(&mInService);
    if (status != NO_ERROR) goto error;

    status = mConfiguration.readFromParcel(parcel);
    if (status != NO_ERROR) goto error;

    return NO_ERROR;

error:
@@ -91,5 +99,7 @@ void AAudioStreamRequest::dump() const {
    ALOGD("AAudioStreamRequest mUserId    = %d", mUserId);
    ALOGD("AAudioStreamRequest mProcessId = %d", mProcessId);
    ALOGD("AAudioStreamRequest mDirection = %d", mDirection);
    ALOGD("AAudioStreamRequest mSharingModeMatchRequired = %d", mSharingModeMatchRequired);
    ALOGD("AAudioStreamRequest mInService = %d", mInService);
    mConfiguration.dump();
}
Loading