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

Commit decb6295 authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

Add IAudioManager methods for tracking client recording activity

audio_unique_id_t IAudioManager::trackRecorder(IBinder token)
  - registers a client recorder withing Audio Service,
    returns a unique tracking recording ID (RIID);
    Audio Service tracks the lifetime of the recorder using
    the provided token.

oneway recorderEvent(int riid, int event)
  - updates the current state of the client;
    only "started" and "stoped" states are considered.

Bug: 123312504
Test: android.media.cts.AudioRecordingConfigurationTest
      AudioRecordTest#testAudioRecordInfoCallback
      MediaRecorderTest#testAudioRecordInfoCallback
      manual testing using Oboe and Solo test apps

Change-Id: Iddb1b91fff7127ab35ba1d33e3e6c32937ac3081
parent 8cd204d6
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@
namespace android {

// must be kept in sync with definitions in AudioPlaybackConfiguration.java

#define PLAYER_PIID_INVALID -1

typedef enum {
@@ -40,6 +39,15 @@ typedef enum {
    PLAYER_STATE_STOPPED  = 4,
} player_state_t;

// must be kept in sync with definitions in AudioManager.java
#define RECORD_RIID_INVALID -1

typedef enum {
    RECORDER_STATE_UNKNOWN  = -1,
    RECORDER_STATE_STARTED  = 0,
    RECORDER_STATE_STOPPED  = 1,
} recorder_state_t;

}; // namespace android

#endif // ANDROID_AUDIOMANAGER_H
+4 −0
Original line number Diff line number Diff line
@@ -36,6 +36,8 @@ public:
        PLAYER_ATTRIBUTES                     = IBinder::FIRST_CALL_TRANSACTION + 1,
        PLAYER_EVENT                          = IBinder::FIRST_CALL_TRANSACTION + 2,
        RELEASE_PLAYER                        = IBinder::FIRST_CALL_TRANSACTION + 3,
        TRACK_RECORDER                        = IBinder::FIRST_CALL_TRANSACTION + 4,
        RECORDER_EVENT                        = IBinder::FIRST_CALL_TRANSACTION + 5,
    };

    DECLARE_META_INTERFACE(AudioManager)
@@ -48,6 +50,8 @@ public:
                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;
    virtual audio_unique_id_t trackRecorder(const sp<IBinder>& recorder) = 0;
    /*oneway*/ virtual status_t recorderEvent(audio_unique_id_t riid, recorder_state_t event) = 0;
};

// ----------------------------------------------------------------------------
+24 −0
Original line number Diff line number Diff line
@@ -98,6 +98,30 @@ public:
        data.writeInt32((int32_t) piid);
        return remote()->transact(RELEASE_PLAYER, data, &reply, IBinder::FLAG_ONEWAY);
    }

    virtual audio_unique_id_t trackRecorder(const sp<IBinder>& recorder) {
        Parcel data, reply;
        data.writeInterfaceToken(IAudioManager::getInterfaceDescriptor());
        data.writeStrongBinder(recorder);
        // get new RIId in reply
        const status_t res = remote()->transact(TRACK_RECORDER, data, &reply, 0);
        if (res != OK || reply.readExceptionCode() != 0) {
            ALOGE("trackRecorder() failed, riid is %d", RECORD_RIID_INVALID);
            return RECORD_RIID_INVALID;
        } else {
            const audio_unique_id_t riid = (audio_unique_id_t) reply.readInt32();
            ALOGV("trackRecorder() returned riid %d", riid);
            return riid;
        }
    }

    virtual status_t recorderEvent(audio_unique_id_t riid, recorder_state_t event) {
        Parcel data, reply;
        data.writeInterfaceToken(IAudioManager::getInterfaceDescriptor());
        data.writeInt32((int32_t) riid);
        data.writeInt32((int32_t) event);
        return remote()->transact(RECORDER_EVENT, data, &reply, IBinder::FLAG_ONEWAY);
    }
};

IMPLEMENT_META_INTERFACE(AudioManager, "android.media.IAudioService");