Skip to content

Commit

Permalink
Merge remote-tracking branch 'vicamo/for-libhybris-maintainers/fix-te…
Browse files Browse the repository at this point in the history
…st_audio-for-android-5.x' into staging
  • Loading branch information
morphis committed Jan 13, 2016
2 parents 69bfefe + c09bf65 commit 06ecf1d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
5 changes: 0 additions & 5 deletions hybris/tests/Makefile.am
Expand Up @@ -28,11 +28,6 @@ if HAS_LIBNFC_NXP_HEADERS
bin_PROGRAMS += test_nfc
endif

# Please re-enable your test programs according to android
# if HAS_ANDROID_X_Y_Z
# bin_PROGRAMS += test_audio
# endif

test_audio_SOURCES = test_audio.c
test_audio_CFLAGS = \
-I$(top_srcdir)/include \
Expand Down
37 changes: 34 additions & 3 deletions hybris/tests/test_audio.c
Expand Up @@ -48,6 +48,25 @@ int main(int argc, char **argv)
assert(hwmod != NULL);

assert(audio_hw_device_open(hwmod, &audiohw) == 0);
do {
#if defined(AUDIO_DEVICE_API_VERSION_MIN)
if (audiohw->common.version < AUDIO_DEVICE_API_VERSION_MIN) {
fprintf(stderr, "Audio device API version %04x failed to meet minimum requirement %0x4.",
audiohw->common.version, AUDIO_DEVICE_API_VERSION_MIN);
} else
#endif
if (audiohw->common.version != AUDIO_DEVICE_API_VERSION_CURRENT) {
fprintf(stderr, "Audio device API version %04x doesn't match platform current %0x4.",
audiohw->common.version, AUDIO_DEVICE_API_VERSION_CURRENT);
} else
break;

#if defined(AUDIO_DEVICE_API_VERSION_MIN)
assert(audiohw->common.version >= AUDIO_DEVICE_API_VERSION_MIN);
#endif
assert(audiohw->common.version == AUDIO_DEVICE_API_VERSION_CURRENT);
} while(0);

assert(audiohw->init_check(audiohw) == 0);
fprintf(stdout, "Audio Hardware Interface initialized.\n");

Expand All @@ -73,12 +92,20 @@ int main(int argc, char **argv)
struct audio_stream_out *stream_out = NULL;

audiohw->open_output_stream(audiohw, 0, AUDIO_DEVICE_OUT_DEFAULT,
AUDIO_OUTPUT_FLAG_PRIMARY, &config_out, &stream_out);
AUDIO_OUTPUT_FLAG_PRIMARY, &config_out, &stream_out
#if ANDROID_VERSION_MAJOR >= 5
, NULL
#endif
);

/* Try it again */
if (!stream_out)
audiohw->open_output_stream(audiohw, 0, AUDIO_DEVICE_OUT_DEFAULT,
AUDIO_OUTPUT_FLAG_PRIMARY, &config_out, &stream_out);
AUDIO_OUTPUT_FLAG_PRIMARY, &config_out, &stream_out
#if ANDROID_VERSION_MAJOR >= 5
, NULL
#endif
);

assert(stream_out != NULL);

Expand All @@ -93,7 +120,11 @@ int main(int argc, char **argv)
struct audio_stream_in *stream_in = NULL;

audiohw->open_input_stream(audiohw, 0, AUDIO_DEVICE_IN_DEFAULT,
&config_in, &stream_in);
&config_in, &stream_in
#if ANDROID_VERSION_MAJOR >= 5
, AUDIO_INPUT_FLAG_NONE, NULL, AUDIO_SOURCE_DEFAULT
#endif
);
assert(stream_in != NULL);

fprintf(stdout, "Successfully created audio input stream: sample rate: %u, channel_mask: %u, format: %u\n",
Expand Down

0 comments on commit 06ecf1d

Please sign in to comment.