Skip to content

Commit

Permalink
base: nugu audio
Browse files Browse the repository at this point in the history
add function `nugu_audio_get_attribute`.

Signed-off-by: JeanTracker <[email protected]>
  • Loading branch information
JeanTracker authored and kimhyungrok committed Jan 9, 2024
1 parent f2c5bac commit 990cbe4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/base/nugu_audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ void nugu_audio_set_attribute_str(const NuguAudioAttribute attribute,
*/
const char *nugu_audio_get_attribute_str(const NuguAudioAttribute attribute);

/**
* @brief Get audio attribute type from string
* @param[in] str audio attribute's string
* @return audio attribute
*/
NuguAudioAttribute nugu_audio_get_attribute(const char *str);

#ifdef __cplusplus
}
#endif
Expand Down
29 changes: 29 additions & 0 deletions src/base/nugu_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,32 @@ nugu_audio_get_attribute_str(const NuguAudioAttribute attribute)

return nugu_audio_get_default_attribute_str(attribute);
}

EXPORT_API NuguAudioAttribute nugu_audio_get_attribute(const char *str)
{
if (str == NULL)
return NUGU_AUDIO_ATTRIBUTE_MUSIC;

if (!strncmp(str, NUGU_AUDIO_ATTRIBUTE_MUSIC_DEFAULT_STRING, 5))
return NUGU_AUDIO_ATTRIBUTE_MUSIC;
else if (!strncmp(str, NUGU_AUDIO_ATTRIBUTE_RINGTONE_DEFAULT_STRING, 5))
return NUGU_AUDIO_ATTRIBUTE_RINGTONE;
else if (!strncmp(str, NUGU_AUDIO_ATTRIBUTE_CALL_DEFAULT_STRING, 5))
return NUGU_AUDIO_ATTRIBUTE_CALL;
else if (!strncmp(str, NUGU_AUDIO_ATTRIBUTE_NOTIFICATION_DEFAULT_STRING,
5))
return NUGU_AUDIO_ATTRIBUTE_NOTIFICATION;
else if (!strncmp(str, NUGU_AUDIO_ATTRIBUTE_ALARM_DEFAULT_STRING, 5))
return NUGU_AUDIO_ATTRIBUTE_ALARM;
else if (!strncmp(str,
NUGU_AUDIO_ATTRIBUTE_VOICE_COMMAND_DEFAULT_STRING, 5))
return NUGU_AUDIO_ATTRIBUTE_VOICE_COMMAND;
else if (!strncmp(str, NUGU_AUDIO_ATTRIBUTE_NAVIGATION_DEFAULT_STRING,
5))
return NUGU_AUDIO_ATTRIBUTE_NAVIGATION;
else if (!strncmp(str, NUGU_AUDIO_ATTRIBUTE_SYSTEM_SOUND_DEFAULT_STRING,
5))
return NUGU_AUDIO_ATTRIBUTE_SYSTEM_SOUND;
else
return NUGU_AUDIO_ATTRIBUTE_MUSIC;
}

0 comments on commit 990cbe4

Please sign in to comment.