Revert "Adding getModelState API to sound trigger"

This reverts commit 19a2dc31ab.

Reason for revert: fix build breakage

Change-Id: I9f58d4c7cfbd871259b4d3186b81de2af6c5021f
gugelfrei
Michael Dooley 6 years ago
parent 19a2dc31ab
commit 6dd21efefe

@ -40,8 +40,6 @@ public:
virtual status_t startRecognition(sound_model_handle_t handle,
const sp<IMemory>& dataMemory) = 0;
virtual status_t stopRecognition(sound_model_handle_t handle) = 0;
virtual status_t getModelState(sound_model_handle_t handle,
sp<IMemory>& eventMemory) = 0;
};

@ -52,7 +52,6 @@ public:
status_t startRecognition(sound_model_handle_t handle, const sp<IMemory>& dataMemory);
status_t stopRecognition(sound_model_handle_t handle);
status_t getModelState(sound_model_handle_t handle, sp<IMemory>& eventMemory);
// BpSoundTriggerClient
virtual void onRecognitionEvent(const sp<IMemory>& eventMemory);

@ -55,7 +55,6 @@ LOCAL_SHARED_LIBRARIES += \
libaudiohal_deathhandler \
android.hardware.soundtrigger@2.0 \
android.hardware.soundtrigger@2.1 \
android.hardware.soundtrigger@2.2 \
android.hardware.audio.common@2.0 \
android.hidl.allocator@1.0 \
android.hidl.memory@1.0

@ -356,50 +356,6 @@ int SoundTriggerHalHidl::stopAllRecognitions()
return hidlReturn;
}
int SoundTriggerHalHidl::getModelState(sound_model_handle_t handle,
struct sound_trigger_recognition_event** event)
{
sp<ISoundTriggerHw> soundtrigger = getService();
if (soundtrigger == 0) {
return -ENODEV;
}
sp<V2_2_ISoundTriggerHw> soundtrigger_2_2 = toService2_2(soundtrigger);
if (soundtrigger_2_2 == 0) {
ALOGE("getModelState not supported");
return -ENODEV;
}
sp<SoundModel> model = getModel(handle);
if (model == 0) {
ALOGE("getModelState model not found for handle %u", handle);
return -EINVAL;
}
int ret = NO_ERROR;
Return<void> hidlReturn;
{
AutoMutex lock(mHalLock);
hidlReturn = soundtrigger_2_2->getModelState(
model->mHalHandle,
[&](int r, const V2_0_ISoundTriggerHwCallback::RecognitionEvent& halEvent) {
ret = r;
if (ret != 0) {
ALOGE("getModelState returned error code %d", ret);
} else {
*event = convertRecognitionEventFromHal(&halEvent);
}
});
}
if (!hidlReturn.isOk()) {
ALOGE("getModelState error %s", hidlReturn.description().c_str());
free(*event);
*event = nullptr;
ret = FAILED_TRANSACTION;
}
return ret;
}
SoundTriggerHalHidl::SoundTriggerHalHidl(const char *moduleName)
: mModuleName(moduleName), mNextUniqueId(1)
{
@ -432,12 +388,6 @@ sp<V2_1_ISoundTriggerHw> SoundTriggerHalHidl::toService2_1(const sp<ISoundTrigge
return castResult_2_1.isOk() ? static_cast<sp<V2_1_ISoundTriggerHw>>(castResult_2_1) : nullptr;
}
sp<V2_2_ISoundTriggerHw> SoundTriggerHalHidl::toService2_2(const sp<ISoundTriggerHw>& s)
{
auto castResult_2_2 = V2_2_ISoundTriggerHw::castFrom(s);
return castResult_2_2.isOk() ? static_cast<sp<V2_2_ISoundTriggerHw>>(castResult_2_2) : nullptr;
}
sp<SoundTriggerHalHidl::SoundModel> SoundTriggerHalHidl::getModel(sound_model_handle_t handle)
{
AutoMutex lock(mLock);

@ -27,7 +27,6 @@
#include "SoundTriggerHalInterface.h"
#include <android/hardware/soundtrigger/2.0/types.h>
#include <android/hardware/soundtrigger/2.1/ISoundTriggerHw.h>
#include <android/hardware/soundtrigger/2.2/ISoundTriggerHw.h>
#include <android/hardware/soundtrigger/2.0/ISoundTriggerHwCallback.h>
#include <android/hardware/soundtrigger/2.1/ISoundTriggerHwCallback.h>
@ -47,8 +46,6 @@ using V2_1_ISoundTriggerHw =
using V2_1_ISoundTriggerHwCallback =
::android::hardware::soundtrigger::V2_1::ISoundTriggerHwCallback;
using ::android::hidl::memory::V1_0::IMemory;
using V2_2_ISoundTriggerHw =
::android::hardware::soundtrigger::V2_2::ISoundTriggerHw;
class SoundTriggerHalHidl : public SoundTriggerHalInterface,
public virtual V2_1_ISoundTriggerHwCallback
@ -95,14 +92,6 @@ public:
*/
virtual int stopAllRecognitions();
/* Get the current state of a given model.
* Returns 0 or an error code. If successful it also sets indicated the event pointer
* and expectes that the caller will free the memory.
* Only supported for device api versions SOUND_TRIGGER_DEVICE_API_VERSION_1_2 or above.
*/
virtual int getModelState(sound_model_handle_t handle,
struct sound_trigger_recognition_event** event);
// ISoundTriggerHwCallback
virtual ::android::hardware::Return<void> recognitionCallback(
const V2_0_ISoundTriggerHwCallback::RecognitionEvent& event, CallbackCookie cookie);
@ -193,7 +182,6 @@ private:
uint32_t nextUniqueId();
sp<ISoundTriggerHw> getService();
sp<V2_1_ISoundTriggerHw> toService2_1(const sp<ISoundTriggerHw>& s);
sp<V2_2_ISoundTriggerHw> toService2_2(const sp<ISoundTriggerHw>& s);
sp<SoundModel> getModel(sound_model_handle_t handle);
sp<SoundModel> removeModel(sound_model_handle_t handle);

@ -71,14 +71,6 @@ public:
*/
virtual int stopAllRecognitions() = 0;
/* Get the current state of a given model.
* Returns 0 or an error code. If successful it also sets indicated the event pointer
* and expectes that the caller will free the memory.
* Only supported for device api versions SOUND_TRIGGER_DEVICE_API_VERSION_1_2 or above.
*/
virtual int getModelState(sound_model_handle_t handle,
struct sound_trigger_recognition_event** event) = 0;
protected:
SoundTriggerHalInterface() {}
};

@ -717,40 +717,6 @@ status_t SoundTriggerHwService::Module::stopRecognition(sound_model_handle_t han
return NO_ERROR;
}
status_t SoundTriggerHwService::Module::getModelState(sound_model_handle_t handle,
sp<IMemory>& eventMemory)
{
ALOGV("getModelState() model handle %d", handle);
if (mHalInterface == 0) {
return NO_INIT;
}
AutoMutex lock(mLock);
sp<Model> model = getModel(handle);
if (model == 0) {
return BAD_VALUE;
}
if (model->mState != Model::STATE_ACTIVE) {
return INVALID_OPERATION;
}
if (model->mType != SOUND_MODEL_TYPE_GENERIC) {
return BAD_VALUE;
}
struct sound_trigger_recognition_event* event = nullptr;
status_t status = mHalInterface->getModelState(handle, &event);
if (status == NO_ERROR) {
sp<SoundTriggerHwService> service;
service = mService.promote();
if (service != 0) {
eventMemory = service->prepareRecognitionEvent(event);
}
free(event);
}
return status;
}
void SoundTriggerHwService::Module::onCallbackEvent(const sp<CallbackEvent>& event)
{
ALOGV("onCallbackEvent type %d", event->mType);
@ -1052,22 +1018,6 @@ status_t SoundTriggerHwService::ModuleClient::stopRecognition(sound_model_handle
return module->stopRecognition(handle);
}
status_t SoundTriggerHwService::ModuleClient::getModelState(sound_model_handle_t handle,
sp<IMemory>& eventMemory)
{
ALOGV("getModelState() model handle %d", handle);
if (!captureHotwordAllowed(IPCThreadState::self()->getCallingPid(),
IPCThreadState::self()->getCallingUid())) {
return PERMISSION_DENIED;
}
sp<Module> module = mModule.promote();
if (module == 0) {
return NO_INIT;
}
return module->getModelState(handle, eventMemory);
}
void SoundTriggerHwService::ModuleClient::setCaptureState_l(bool active)
{
ALOGV("ModuleClient::setCaptureState_l %d", active);

@ -122,8 +122,6 @@ public:
virtual status_t startRecognition(sound_model_handle_t handle,
const sp<IMemory>& dataMemory);
virtual status_t stopRecognition(sound_model_handle_t handle);
virtual status_t getModelState(sound_model_handle_t handle,
sp<IMemory>& eventMemory);
sp<SoundTriggerHalInterface> halInterface() const { return mHalInterface; }
struct sound_trigger_module_descriptor descriptor() { return mDescriptor; }
@ -171,8 +169,6 @@ public:
virtual status_t startRecognition(sound_model_handle_t handle,
const sp<IMemory>& dataMemory);
virtual status_t stopRecognition(sound_model_handle_t handle);
virtual status_t getModelState(sound_model_handle_t handle,
sp<IMemory>& eventMemory);
virtual status_t dump(int fd, const Vector<String16>& args);

@ -32,7 +32,6 @@ enum {
UNLOAD_SOUND_MODEL,
START_RECOGNITION,
STOP_RECOGNITION,
GET_MODEL_STATE,
};
class BpSoundTrigger: public BpInterface<ISoundTrigger>
@ -114,22 +113,6 @@ public:
return status;
}
virtual status_t getModelState(sound_model_handle_t handle,
sp<IMemory>& eventMemory)
{
Parcel data, reply;
data.writeInterfaceToken(ISoundTrigger::getInterfaceDescriptor());
data.write(&handle, sizeof(sound_model_handle_t));
status_t status = remote()->transact(GET_MODEL_STATE, data, &reply);
if (status == NO_ERROR) {
status = (status_t)reply.readInt32();
if (status == NO_ERROR) {
eventMemory = interface_cast<IMemory>(reply.readStrongBinder());
}
}
return status;
}
};
IMPLEMENT_META_INTERFACE(SoundTrigger, "android.hardware.ISoundTrigger");
@ -186,24 +169,6 @@ status_t BnSoundTrigger::onTransact(
reply->writeInt32(status);
return NO_ERROR;
}
case GET_MODEL_STATE: {
CHECK_INTERFACE(ISoundTrigger, data, reply);
sound_model_handle_t handle;
status_t status = UNKNOWN_ERROR;
status_t ret = data.read(&handle, sizeof(sound_model_handle_t));
if (ret == NO_ERROR) {
sp<IMemory> eventMemory;
status = getModelState(handle, eventMemory);
if (eventMemory != NULL) {
ret = reply->writeStrongBinder(
IInterface::asBinder(eventMemory));
} else {
ret = NO_MEMORY;
}
}
reply->writeInt32(status);
return ret;
}
default:
return BBinder::onTransact(code, data, reply, flags);
}

@ -188,16 +188,6 @@ status_t SoundTrigger::stopRecognition(sound_model_handle_t handle)
return mISoundTrigger->stopRecognition(handle);
}
status_t SoundTrigger::getModelState(sound_model_handle_t handle,
sp<IMemory>& eventMemory)
{
Mutex::Autolock _l(mLock);
if (mISoundTrigger == 0) {
return NO_INIT;
}
return mISoundTrigger->getModelState(handle, eventMemory);
}
// BpSoundTriggerClient
void SoundTrigger::onRecognitionEvent(const sp<IMemory>& eventMemory)
{

Loading…
Cancel
Save