HAL: Align error code with HIDL wrapper
Here is how the HIDL wrapper interprets status error codes:
0 => Result::OK
-EINVAL => Result::INVALID_ARGUMENTS
-ENODATA => Result::INVALID_STATE
-ENODEV => Result::NOT_INITIALIZED
-ENOSYS => Result::NOT_SUPPORTED
otherwise => Result::INVALID_STATE
This is consistent with most of the hal.
This patch changes the few places where it was not to unify the
behaviours.
Test: vts-tradefed run vts --module VtsHalAudioV2_0Target
Test: call/play music/record/video...
Bug: 36311550
Change-Id: Id821d15ae3269cd2c9699924e2b174c7347a6d07
Signed-off-by: Kevin Rocard <krocard@google.com>
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 7d9a366..30c0637 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -2363,7 +2363,7 @@
pthread_mutex_unlock(&out->lock);
return 0;
} else
- return -EINVAL;
+ return -ENODATA;
}
static int out_add_audio_effect(const struct audio_stream *stream __unused,
@@ -2381,14 +2381,14 @@
static int out_get_next_write_timestamp(const struct audio_stream_out *stream __unused,
int64_t *timestamp __unused)
{
- return -EINVAL;
+ return -ENOSYS;
}
static int out_get_presentation_position(const struct audio_stream_out *stream,
uint64_t *frames, struct timespec *timestamp)
{
struct stream_out *out = (struct stream_out *)stream;
- int ret = -EINVAL;
+ int ret = -ENODATA;
unsigned long dsp_frames;
lock_output_stream(out);
@@ -2813,7 +2813,7 @@
static int in_set_gain(struct audio_stream_in *stream __unused, float gain __unused)
{
- return 0;
+ return -ENOSYS;
}
static void in_snd_mon_cb(void * stream, struct str_parms * parms)