fclose(fp);
+ audio_in_unprepare(input);
audio_in_destroy(input);
}
ret = audio_in_prepare(input);
if (ret != 0) {
- printf("audio_in_prepare failed.\n");
+ printf("audio_in_prepare failed, err(0x%x)\n", ret);
audio_in_destroy(input);
return 0;
} else {
ret = audio_in_get_buffer_size(input, &size);
if (ret != AUDIO_IO_ERROR_NONE) {
- printf("audio_in_get_buffer_size failed.\n");
+ printf("audio_in_get_buffer_size failed, err(0x%x)\n", ret);
return 0;
} else {
printf("size(%d)\n", size);
ret = audio_out_prepare(output);
if (ret != 0) {
- printf("audio_out_prepare failed.\n");
+ printf("audio_out_prepare failed, err(0x%x)\n", ret);
audio_out_destroy(output);
return 0;
}
sound_stream_info_h g_stream_info_read_h = NULL;
sound_stream_info_h g_stream_info_write_h = NULL;
-static void focus_callback(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason_for_change, const char *additional_info, void *user_data)
+static void focus_callback(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state,
+ sound_stream_focus_change_reason_e reason_for_change, int sound_behavior, const char *additional_info, void *user_data)
{
- int ret = 0;
- sound_stream_focus_state_e playback_focus_state;
- sound_stream_focus_state_e recording_focus_state;
printf("*** focus_callback_read is called, stream_info(%p, read(%p)/write(%p)) ***\n", stream_info, g_stream_info_read_h, g_stream_info_write_h);
printf(" - reason_for_change(%d), additional_info(%s), user_data(%p)\n", reason_for_change, additional_info, user_data);
- ret = sound_manager_get_focus_state(stream_info, &playback_focus_state, &recording_focus_state);
- if (!ret)
- printf(" - focus_state(playback_focus:%d, recording_focus:%d)\n", playback_focus_state, recording_focus_state);
+ printf(" - focus_state is :%d \n", focus_state);
return;
}
printf("fail to sound_manager_create_stream_information(), ret(0x%x)\n", ret);
goto EXIT;
}
- ret = audio_in_set_stream_info(input, g_stream_info_read_h);
+ ret = audio_in_set_sound_stream_info(input, g_stream_info_read_h);
if (ret)
- printf("fail to audio_in_set_stream_info(), ret(0x%x)\n", ret);
+ printf("fail to audio_in_set_sound_stream_info(), ret(0x%x)\n", ret);
- ret = sound_manager_acquire_focus(g_stream_info_read_h, SOUND_STREAM_FOCUS_FOR_RECORDING, NULL);
+ ret = sound_manager_acquire_focus(g_stream_info_read_h, SOUND_STREAM_FOCUS_FOR_RECORDING, SOUND_BEHAVIOR_NONE, NULL);
if (ret) {
printf("fail to sound_manager_acquire_focus() for RECORDING, ret(0x%x)\n", ret);
goto EXIT;
printf("fail to sound_manager_create_stream_information(), ret(0x%x)\n", ret);
goto EXIT;
}
- ret = audio_out_set_stream_info(output, g_stream_info_write_h);
+ ret = audio_out_set_sound_stream_info(output, g_stream_info_write_h);
if (ret)
- printf("fail to audio_out_set_stream_info(), ret(0x%x)\n", ret);
+ printf("fail to audio_out_set_sound_stream_info(), ret(0x%x)\n", ret);
- ret = sound_manager_acquire_focus(g_stream_info_write_h, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL);
+ ret = sound_manager_acquire_focus(g_stream_info_write_h, SOUND_STREAM_FOCUS_FOR_PLAYBACK, SOUND_BEHAVIOR_NONE, NULL);
if (ret) {
printf("fail to sound_manager_acquire_focus() for PLAYBACK, ret(0x%x)\n", ret);
goto EXIT;
printf("audio_in_prepare\n");
ret = audio_in_prepare(input);
if (ret != 0) {
- printf("audio_in_prepare failed.\n");
+ printf("audio_in_prepare failed, err(0x%x)\n", ret);
audio_in_destroy(input);
goto EXIT;
} else {
ret = audio_in_get_buffer_size(input, &size);
if (ret != AUDIO_IO_ERROR_NONE) {
- printf("audio_in_get_buffer_size failed.\n");
+ printf("audio_in_get_buffer_size failed, err(0x%x)\n", ret);
goto EXIT;
} else {
printf("size(%d)\n", size);
printf("audio_out_prepare\n");
ret = audio_out_prepare(output);
if (ret != 0) {
- printf("audio_out_prepare failed.\n");
+ printf("audio_out_prepare failed, err(0x%x)\n", ret);
audio_out_destroy(output);
goto EXIT;
}
}
do {
+ int gotchar;
printf("command(q:quit) : ");
- cmd = (char)getchar();
+ gotchar = getchar();
+ if (gotchar == EOF)
+ goto EXIT;
if (cmd != '\n')
getchar();
cmd_ret = _convert_cmd_and_run(cmd, mode);
if (g_stream_info_read_h) {
ret = sound_manager_get_focus_state(g_stream_info_read_h, NULL, &recording_focus_state);
if (recording_focus_state == SOUND_STREAM_FOCUS_STATE_ACQUIRED) {
- ret = sound_manager_release_focus(g_stream_info_read_h, SOUND_STREAM_FOCUS_FOR_RECORDING, NULL);
+ ret = sound_manager_release_focus(g_stream_info_read_h, SOUND_STREAM_FOCUS_FOR_RECORDING, SOUND_BEHAVIOR_NONE, NULL);
if (ret)
printf("fail to sound_manager_release_focus() for recording, ret(0x%x)\n", ret);
}
if (g_stream_info_write_h) {
ret = sound_manager_get_focus_state(g_stream_info_write_h, &playback_focus_state, NULL);
if (playback_focus_state == SOUND_STREAM_FOCUS_STATE_ACQUIRED) {
- ret = sound_manager_release_focus(g_stream_info_write_h, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL);
+ ret = sound_manager_release_focus(g_stream_info_write_h, SOUND_STREAM_FOCUS_FOR_PLAYBACK, SOUND_BEHAVIOR_NONE, NULL);
if (ret)
printf("fail to sound_manager_release_focus() for playback, ret(0x%x)\n", ret);
}
} else if (argc == 3 && !strcmp(argv[1], "async")) {
audio_io_async_test(atoi(argv[2]));
} else if (argc == 4) {
+ int channel_idx = atoi(argv[3]);
+ if (channel_idx < 0 || channel_idx > 2) {
+ printf("Invalid channel\n");
+ return 0;
+ }
printf("run with [%s][%s][%s]\n", argv[1], argv[2], argv[3]);
- audio_io_test(atoi(argv[1]), atoi(argv[2]), atoi(argv[3]));
+ audio_io_test(atoi(argv[1]), atoi(argv[2]), channel_idx);
} else if (argc == 6) {
play_file_sample(argv[2], atoi(argv[3]), atoi(argv[4]), atoi(argv[5]));
} else {