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

Commit 1c473f30 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi Committed by Android (Google) Code Review
Browse files

Merge "Native IPlayer interface"

parents 27d40795 63189325
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -23,19 +23,19 @@ namespace android {

#define PLAYER_PIID_INVALID -1

enum {
typedef enum {
    PLAYER_TYPE_SLES_AUDIOPLAYER_BUFFERQUEUE = 11,
    PLAYER_TYPE_SLES_AUDIOPLAYER_URI_FD = 12,
};
} player_type_t;

enum {
typedef enum {
    PLAYER_STATE_UNKNOWN  = -1,
    PLAYER_STATE_RELEASED = 0,
    PLAYER_STATE_IDLE     = 1,
    PLAYER_STATE_STARTED  = 2,
    PLAYER_STATE_PAUSED   = 3,
    PLAYER_STATE_STOPPED  = 4,
};
} player_state_t;

}; // namespace android

+6 −4
Original line number Diff line number Diff line
@@ -114,10 +114,12 @@ public:

    // The parcels created by these methods must be kept in sync with the
    // corresponding methods from IAudioService.aidl and objects it imports.
    virtual audio_unique_id_t trackPlayer(int playerType, int usage, int content) = 0;
    /*oneway*/ virtual status_t playerAttributes(audio_unique_id_t piid, int usage, int content)= 0;
    /*oneway*/ virtual status_t playerEvent(int piid, int event) = 0;
    /*oneway*/ virtual status_t releasePlayer(int piid) = 0;
    virtual audio_unique_id_t trackPlayer(player_type_t playerType, audio_usage_t usage,
                audio_content_type_t content, const sp<IBinder>& player) = 0;
    /*oneway*/ virtual status_t playerAttributes(audio_unique_id_t piid, audio_usage_t usage,
                audio_content_type_t content)= 0;
    /*oneway*/ virtual status_t playerEvent(audio_unique_id_t piid, player_state_t event) = 0;
    /*oneway*/ virtual status_t releasePlayer(audio_unique_id_t piid) = 0;
};

// ----------------------------------------------------------------------------
+61 −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_IPLAYER_H
#define ANDROID_IPLAYER_H

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

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

namespace android {

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

class IPlayer : public IInterface
{
public:
    DECLARE_META_INTERFACE(Player);

    virtual void start() = 0;

    virtual void pause() = 0;

    virtual void stop() = 0;

    virtual void setVolume(float vol) = 0;

};

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

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

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

}; // namespace android

#endif // ANDROID_IPLAYER_H
+4 −1
Original line number Diff line number Diff line
cc_library_shared {
    name: "libaudiomanager",

    srcs: ["IAudioManager.cpp"],
    srcs: [
        "IAudioManager.cpp",
        "IPlayer.cpp",
    ],

    shared_libs: [
        "libutils",
+16 −12
Original line number Diff line number Diff line
@@ -35,15 +35,16 @@ public:
    {
    }

    virtual audio_unique_id_t trackPlayer(int playerType, int usage, int content) {
    virtual audio_unique_id_t trackPlayer(player_type_t playerType, audio_usage_t usage,
            audio_content_type_t content, const sp<IBinder>& player) {
        Parcel data, reply;
        data.writeInterfaceToken(IAudioManager::getInterfaceDescriptor());
        data.writeInt32(1); // non-null PlayerIdCard parcelable
        // marshall PlayerIdCard data
        data.writeInt32((int32_t) playerType);
        //   write attributes of PlayerIdCard
        data.writeInt32(usage);
        data.writeInt32(content);
        data.writeInt32((int32_t) usage);
        data.writeInt32((int32_t) content);
        data.writeInt32(0 /*source: none here, this is a player*/);
        data.writeInt32(0 /*flags*/);
        //   write attributes' tags
@@ -51,6 +52,8 @@ public:
        data.writeString16(String16("")); // no tags
        //   write attributes' bundle
        data.writeInt32(-1977 /*ATTR_PARCEL_IS_NULL_BUNDLE*/); // no bundle
        //   write IPlayer
        data.writeStrongBinder(player);
        // get new PIId in reply
        const status_t res = remote()->transact(TRACK_PLAYER, data, &reply, 0);
        if (res != OK || reply.readExceptionCode() != 0) {
@@ -63,13 +66,14 @@ public:
        }
    }

    virtual status_t playerAttributes(audio_unique_id_t piid, int usage, int content) {
    virtual status_t playerAttributes(audio_unique_id_t piid, audio_usage_t usage,
            audio_content_type_t content) {
        Parcel data, reply;
        data.writeInterfaceToken(IAudioManager::getInterfaceDescriptor());
        data.writeInt32(piid);
        data.writeInt32((int32_t) piid);
        data.writeInt32(1); // non-null AudioAttributes parcelable
        data.writeInt32(usage);
        data.writeInt32(content);
        data.writeInt32((int32_t) usage);
        data.writeInt32((int32_t) content);
        data.writeInt32(0 /*source: none here, this is a player*/);
        data.writeInt32(0 /*flags*/);
        //   write attributes' tags
@@ -80,18 +84,18 @@ public:
        return remote()->transact(PLAYER_ATTRIBUTES, data, &reply, IBinder::FLAG_ONEWAY);
    }

    virtual status_t playerEvent(int piid, int event) {
    virtual status_t playerEvent(audio_unique_id_t piid, player_state_t event) {
        Parcel data, reply;
        data.writeInterfaceToken(IAudioManager::getInterfaceDescriptor());
        data.writeInt32(piid);
        data.writeInt32(event);
        data.writeInt32((int32_t) piid);
        data.writeInt32((int32_t) event);
        return remote()->transact(PLAYER_EVENT, data, &reply, IBinder::FLAG_ONEWAY);
    }

    virtual status_t releasePlayer(int piid) {
    virtual status_t releasePlayer(audio_unique_id_t piid) {
        Parcel data, reply;
        data.writeInterfaceToken(IAudioManager::getInterfaceDescriptor());
        data.writeInt32(piid);
        data.writeInt32((int32_t) piid);
        return remote()->transact(RELEASE_PLAYER, data, &reply, IBinder::FLAG_ONEWAY);
    }
};
Loading