OboeAudioService: add thread to service for passing timestamps
Cleanup several TODOs.
Test: test_aaudio in CTS
Change-Id: I7fc956b6a21cbb592f98e1e5a8f43ebd6926d796
Signed-off-by: Phil Burk <philburk@google.com>
diff --git a/media/liboboe/src/binding/IOboeAudioService.cpp b/media/liboboe/src/binding/IOboeAudioService.cpp
index a3437b2..2584bc9 100644
--- a/media/liboboe/src/binding/IOboeAudioService.cpp
+++ b/media/liboboe/src/binding/IOboeAudioService.cpp
@@ -20,6 +20,7 @@
#include "binding/OboeStreamRequest.h"
#include "binding/OboeStreamConfiguration.h"
#include "binding/IOboeAudioService.h"
+#include "utility/OboeUtilities.h"
namespace android {
@@ -44,7 +45,7 @@
request.writeToParcel(&data);
status_t err = remote()->transact(OPEN_STREAM, data, &reply);
if (err != NO_ERROR) {
- return OBOE_ERROR_INTERNAL; // TODO consider another error
+ return OboeConvert_androidToOboeResult(err);
}
// parse reply
oboe_handle_t stream;
@@ -53,14 +54,14 @@
return stream;
}
- virtual oboe_result_t closeStream(int32_t streamHandle) override {
+ virtual oboe_result_t closeStream(oboe_handle_t streamHandle) override {
Parcel data, reply;
// send command
data.writeInterfaceToken(IOboeAudioService::getInterfaceDescriptor());
data.writeInt32(streamHandle);
status_t err = remote()->transact(CLOSE_STREAM, data, &reply);
if (err != NO_ERROR) {
- return OBOE_ERROR_INTERNAL; // TODO consider another error
+ return OboeConvert_androidToOboeResult(err);
}
// parse reply
oboe_result_t res;
@@ -69,14 +70,14 @@
}
virtual oboe_result_t getStreamDescription(oboe_handle_t streamHandle,
- AudioEndpointParcelable &parcelable) {
+ oboe::AudioEndpointParcelable &parcelable) {
Parcel data, reply;
// send command
data.writeInterfaceToken(IOboeAudioService::getInterfaceDescriptor());
data.writeInt32(streamHandle);
status_t err = remote()->transact(GET_STREAM_DESCRIPTION, data, &reply);
if (err != NO_ERROR) {
- return OBOE_ERROR_INTERNAL; // TODO consider another error
+ return OboeConvert_androidToOboeResult(err);
}
// parse reply
parcelable.readFromParcel(&reply);
@@ -97,7 +98,7 @@
data.writeInt32(streamHandle);
status_t err = remote()->transact(START_STREAM, data, &reply);
if (err != NO_ERROR) {
- return OBOE_ERROR_INTERNAL; // TODO consider another error
+ return OboeConvert_androidToOboeResult(err);
}
// parse reply
oboe_result_t res;
@@ -112,7 +113,7 @@
data.writeInt32(streamHandle);
status_t err = remote()->transact(PAUSE_STREAM, data, &reply);
if (err != NO_ERROR) {
- return OBOE_ERROR_INTERNAL; // TODO consider another error
+ return OboeConvert_androidToOboeResult(err);
}
// parse reply
oboe_result_t res;
@@ -127,7 +128,7 @@
data.writeInt32(streamHandle);
status_t err = remote()->transact(FLUSH_STREAM, data, &reply);
if (err != NO_ERROR) {
- return OBOE_ERROR_INTERNAL; // TODO consider another error
+ return OboeConvert_androidToOboeResult(err);
}
// parse reply
oboe_result_t res;
@@ -135,13 +136,6 @@
return res;
}
- virtual void tickle() override { // TODO remove after service thread implemented
- Parcel data;
- // send command
- data.writeInterfaceToken(IOboeAudioService::getInterfaceDescriptor());
- remote()->transact(TICKLE, data, nullptr);
- }
-
virtual oboe_result_t registerAudioThread(oboe_handle_t streamHandle, pid_t clientThreadId,
oboe_nanoseconds_t periodNanoseconds)
override {
@@ -153,7 +147,7 @@
data.writeInt64(periodNanoseconds);
status_t err = remote()->transact(REGISTER_AUDIO_THREAD, data, &reply);
if (err != NO_ERROR) {
- return OBOE_ERROR_INTERNAL; // TODO consider another error
+ return OboeConvert_androidToOboeResult(err);
}
// parse reply
oboe_result_t res;
@@ -170,7 +164,7 @@
data.writeInt32((int32_t) clientThreadId);
status_t err = remote()->transact(UNREGISTER_AUDIO_THREAD, data, &reply);
if (err != NO_ERROR) {
- return OBOE_ERROR_INTERNAL; // TODO consider another error
+ return OboeConvert_androidToOboeResult(err);
}
// parse reply
oboe_result_t res;
@@ -189,8 +183,8 @@
status_t BnOboeAudioService::onTransact(uint32_t code, const Parcel& data,
Parcel* reply, uint32_t flags) {
OboeStream stream;
- OboeStreamRequest request;
- OboeStreamConfiguration configuration;
+ oboe::OboeStreamRequest request;
+ oboe::OboeStreamConfiguration configuration;
pid_t pid;
oboe_nanoseconds_t nanoseconds;
oboe_result_t result;
@@ -201,7 +195,7 @@
case OPEN_STREAM: {
request.readFromParcel(&data);
stream = openStream(request, configuration);
- ALOGD("BnOboeAudioService::onTransact OPEN_STREAM 0x%08X", stream);
+ ALOGD("BnOboeAudioService::onTransact OPEN_STREAM server handle = 0x%08X", stream);
reply->writeInt32(stream);
configuration.writeToParcel(reply);
return NO_ERROR;
@@ -221,12 +215,12 @@
oboe::AudioEndpointParcelable parcelable;
result = getStreamDescription(stream, parcelable);
if (result != OBOE_OK) {
- return -1; // FIXME
+ return OboeConvert_oboeToAndroidStatus(result);
}
parcelable.dump();
result = parcelable.validate();
if (result != OBOE_OK) {
- return -1; // FIXME
+ return OboeConvert_oboeToAndroidStatus(result);
}
parcelable.writeToParcel(reply);
reply->writeInt32(result);
@@ -281,12 +275,6 @@
return NO_ERROR;
} break;
- case TICKLE: {
- ALOGV("BnOboeAudioService::onTransact TICKLE");
- tickle();
- return NO_ERROR;
- } break;
-
default:
// ALOGW("BnOboeAudioService::onTransact not handled %u", code);
return BBinder::onTransact(code, data, reply, flags);