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);
diff --git a/media/liboboe/src/binding/IOboeAudioService.h b/media/liboboe/src/binding/IOboeAudioService.h
index 4b4c99c..e2a9c15 100644
--- a/media/liboboe/src/binding/IOboeAudioService.h
+++ b/media/liboboe/src/binding/IOboeAudioService.h
@@ -29,13 +29,6 @@
#include "binding/OboeStreamRequest.h"
#include "binding/OboeStreamConfiguration.h"
-//using android::status_t;
-//using android::IInterface;
-//using android::BnInterface;
-
-using oboe::AudioEndpointParcelable;
-using oboe::OboeStreamRequest;
-using oboe::OboeStreamConfiguration;
namespace android {
@@ -45,16 +38,16 @@
DECLARE_META_INTERFACE(OboeAudioService);
- virtual oboe_handle_t openStream(OboeStreamRequest &request,
- OboeStreamConfiguration &configuration) = 0;
+ virtual oboe_handle_t openStream(oboe::OboeStreamRequest &request,
+ oboe::OboeStreamConfiguration &configuration) = 0;
- virtual oboe_result_t closeStream(int32_t streamHandle) = 0;
+ virtual oboe_result_t closeStream(oboe_handle_t streamHandle) = 0;
/* Get an immutable description of the in-memory queues
* used to communicate with the underlying HAL or Service.
*/
virtual oboe_result_t getStreamDescription(oboe_handle_t streamHandle,
- AudioEndpointParcelable &parcelable) = 0;
+ oboe::AudioEndpointParcelable &parcelable) = 0;
/**
* Start the flow of data.
@@ -79,14 +72,6 @@
virtual oboe_result_t unregisterAudioThread(oboe_handle_t streamHandle,
pid_t clientThreadId) = 0;
-
- /**
- * Poke server instead of running a background thread.
- * Cooperative multi-tasking for early development only.
- * TODO remove tickle() when service has its own thread.
- */
- virtual void tickle() { };
-
};
class BnOboeAudioService : public BnInterface<IOboeAudioService> {
diff --git a/media/liboboe/src/binding/OboeServiceDefinitions.h b/media/liboboe/src/binding/OboeServiceDefinitions.h
index ad00fe2..33a192f 100644
--- a/media/liboboe/src/binding/OboeServiceDefinitions.h
+++ b/media/liboboe/src/binding/OboeServiceDefinitions.h
@@ -37,8 +37,7 @@
PAUSE_STREAM,
FLUSH_STREAM,
REGISTER_AUDIO_THREAD,
- UNREGISTER_AUDIO_THREAD,
- TICKLE
+ UNREGISTER_AUDIO_THREAD
};
} // namespace android
@@ -53,8 +52,7 @@
PAUSE_STREAM,
FLUSH_STREAM,
REGISTER_AUDIO_THREAD,
- UNREGISTER_AUDIO_THREAD,
- TICKLE
+ UNREGISTER_AUDIO_THREAD
};
// TODO Expand this to include all the open parameters.
diff --git a/media/liboboe/src/binding/OboeStreamConfiguration.cpp b/media/liboboe/src/binding/OboeStreamConfiguration.cpp
index 4b8b5b2..124e964 100644
--- a/media/liboboe/src/binding/OboeStreamConfiguration.cpp
+++ b/media/liboboe/src/binding/OboeStreamConfiguration.cpp
@@ -65,10 +65,10 @@
}
switch (mAudioFormat) {
- case OBOE_AUDIO_FORMAT_PCM16:
+ case OBOE_AUDIO_FORMAT_PCM_I16:
case OBOE_AUDIO_FORMAT_PCM_FLOAT:
- case OBOE_AUDIO_FORMAT_PCM824:
- case OBOE_AUDIO_FORMAT_PCM32:
+ case OBOE_AUDIO_FORMAT_PCM_I8_24:
+ case OBOE_AUDIO_FORMAT_PCM_I32:
break;
default:
ALOGE("OboeStreamConfiguration.validate() invalid audioFormat = %d", mAudioFormat);