mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:50:18 +00:00
audio: Report unknown stream positions explicitly
Instead of using 'STATUS_NO_INIT' in the case when stream position can not be reported, use a special value for Position fields. This streamlines processing of statuses on the client side, by removing the need to treat 'STATUS_NO_INIT' specially. Bug: 205884982 Test: atest VtsHalAudioCoreTargetTest Change-Id: I13c9c8d165b632900ca76de144759ef7b9200eff
This commit is contained in:
@@ -42,8 +42,9 @@ parcelable StreamDescriptor {
|
||||
const int LATENCY_UNKNOWN = -1;
|
||||
@FixedSize @VintfStability
|
||||
parcelable Position {
|
||||
long frames;
|
||||
long timeNs;
|
||||
long frames = -1;
|
||||
long timeNs = -1;
|
||||
const long UNKNOWN = -1;
|
||||
}
|
||||
@Backing(type="int") @VintfStability
|
||||
enum State {
|
||||
|
||||
@@ -116,10 +116,15 @@ parcelable StreamDescriptor {
|
||||
@VintfStability
|
||||
@FixedSize
|
||||
parcelable Position {
|
||||
/**
|
||||
* The value used when the position can not be reported by the HAL
|
||||
* module.
|
||||
*/
|
||||
const long UNKNOWN = -1;
|
||||
/** Frame count. */
|
||||
long frames;
|
||||
long frames = UNKNOWN;
|
||||
/** Timestamp in nanoseconds. */
|
||||
long timeNs;
|
||||
long timeNs = UNKNOWN;
|
||||
}
|
||||
|
||||
@VintfStability
|
||||
@@ -295,10 +300,6 @@ parcelable StreamDescriptor {
|
||||
* - STATUS_INVALID_OPERATION: the command is not applicable in the
|
||||
* current state of the stream, or to this
|
||||
* type of the stream;
|
||||
* - STATUS_NO_INIT: positions can not be reported because the mix port
|
||||
* is not connected to any producer or consumer, or
|
||||
* because the HAL module does not support positions
|
||||
* reporting for this AudioSource (on input streams).
|
||||
* - STATUS_NOT_ENOUGH_DATA: a read or write error has
|
||||
* occurred for the 'audio.fmq' queue;
|
||||
*/
|
||||
@@ -316,9 +317,11 @@ parcelable StreamDescriptor {
|
||||
*/
|
||||
int fmqByteCount;
|
||||
/**
|
||||
* It is recommended to report the current position for any command.
|
||||
* If the position can not be reported, the 'status' field must be
|
||||
* set to 'NO_INIT'.
|
||||
* It is recommended to report the current position for any command. If
|
||||
* the position can not be reported, for example because the mix port is
|
||||
* not connected to any producer or consumer, or because the HAL module
|
||||
* does not support positions reporting for this AudioSource (on input
|
||||
* streams), the 'Position::UNKNOWN' value must be used.
|
||||
*
|
||||
* For output streams: the moment when the specified stream position
|
||||
* was presented to an external observer (i.e. presentation position).
|
||||
|
||||
@@ -87,12 +87,13 @@ std::string StreamWorkerCommonLogic::init() {
|
||||
|
||||
void StreamWorkerCommonLogic::populateReply(StreamDescriptor::Reply* reply,
|
||||
bool isConnected) const {
|
||||
reply->status = STATUS_OK;
|
||||
if (isConnected) {
|
||||
reply->status = STATUS_OK;
|
||||
reply->observable.frames = mFrameCount;
|
||||
reply->observable.timeNs = ::android::elapsedRealtimeNano();
|
||||
} else {
|
||||
reply->status = STATUS_NO_INIT;
|
||||
reply->observable.frames = StreamDescriptor::Position::UNKNOWN;
|
||||
reply->observable.timeNs = StreamDescriptor::Position::UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1660,14 +1660,16 @@ class StreamLogicDefaultDriver : public StreamLogicDriver {
|
||||
}
|
||||
bool interceptRawReply(const StreamDescriptor::Reply&) override { return false; }
|
||||
bool processValidReply(const StreamDescriptor::Reply& reply) override {
|
||||
if (mPreviousFrames.has_value()) {
|
||||
if (reply.observable.frames > mPreviousFrames.value()) {
|
||||
mObservablePositionIncrease = true;
|
||||
} else if (reply.observable.frames < mPreviousFrames.value()) {
|
||||
mRetrogradeObservablePosition = true;
|
||||
if (reply.observable.frames != StreamDescriptor::Position::UNKNOWN) {
|
||||
if (mPreviousFrames.has_value()) {
|
||||
if (reply.observable.frames > mPreviousFrames.value()) {
|
||||
mObservablePositionIncrease = true;
|
||||
} else if (reply.observable.frames < mPreviousFrames.value()) {
|
||||
mRetrogradeObservablePosition = true;
|
||||
}
|
||||
}
|
||||
mPreviousFrames = reply.observable.frames;
|
||||
}
|
||||
mPreviousFrames = reply.observable.frames;
|
||||
|
||||
const auto& lastCommandState = mCommands[mNextCommand - 1];
|
||||
if (lastCommandState.second != reply.state) {
|
||||
|
||||
Reference in New Issue
Block a user