diff --git a/audio/audio_driver.c b/audio/audio_driver.c index dfa853cfa1..9293ddcaa4 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -196,6 +196,15 @@ audio_mixer_stream_t *audio_driver_mixer_get_stream(unsigned i) return &audio_mixer_streams[i]; } +const char *audio_driver_mixer_get_stream_name(unsigned i) +{ + if (i > (AUDIO_MIXER_MAX_STREAMS-1)) + return NULL; + if (!string_is_empty(audio_mixer_streams[i].name)) + return audio_mixer_streams[i].name; + return "N/A"; +} + /** * compute_audio_buffer_statistics: * @@ -1145,6 +1154,7 @@ bool audio_driver_mixer_add_stream(audio_mixer_stream_params_t *params) audio_mixer_active = true; } + audio_mixer_streams[free_slot].name = !string_is_empty(params->basename) ? strdup(params->basename) : NULL; audio_mixer_streams[free_slot].buf = buf; audio_mixer_streams[free_slot].handle = handle; audio_mixer_streams[free_slot].voice = voice; @@ -1274,11 +1284,16 @@ void audio_driver_mixer_remove_stream(unsigned i) audio_mixer_sound_t *handle = audio_mixer_streams[i].handle; if (handle) audio_mixer_destroy(handle); + + if (!string_is_empty(audio_mixer_streams[i].name)) + free(audio_mixer_streams[i].name); + audio_mixer_streams[i].state = AUDIO_STREAM_STATE_NONE; audio_mixer_streams[i].stop_cb = NULL; audio_mixer_streams[i].volume = 0.0f; audio_mixer_streams[i].handle = NULL; audio_mixer_streams[i].voice = NULL; + audio_mixer_streams[i].name = NULL; } } diff --git a/audio/audio_driver.h b/audio/audio_driver.h index 440e563ba1..95efadd41b 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -64,6 +64,7 @@ typedef struct audio_mixer_stream enum audio_mixer_state state; float volume; void *buf; + char *name; size_t bufsize; } audio_mixer_stream_t; @@ -164,6 +165,7 @@ typedef struct audio_mixer_stream_params enum audio_mixer_type type; enum audio_mixer_state state; void *buf; + char *basename; size_t bufsize; audio_mixer_stop_cb_t cb; } audio_mixer_stream_params_t; @@ -306,6 +308,8 @@ enum resampler_quality audio_driver_get_resampler_quality(void); enum audio_mixer_state audio_driver_mixer_get_stream_state(unsigned i); +const char *audio_driver_mixer_get_stream_name(unsigned i); + bool compute_audio_buffer_statistics(audio_statistics_t *stats); extern audio_driver_t audio_rsound; diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index a015d5ec39..9e8d03bece 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -57,6 +57,26 @@ extern struct key_desc key_descriptors[RARCH_MAX_KEYS]; +static void menu_action_setting_audio_mixer_stream_name( + file_list_t* list, + unsigned *w, unsigned type, unsigned i, + const char *label, + char *s, size_t len, + const char *entry_label, + const char *path, + char *s2, size_t len2) +{ + unsigned offset = (type - MENU_SETTINGS_AUDIO_MIXER_STREAM_BEGIN); + + *w = 19; + strlcpy(s2, path, len2); + + if (offset >= AUDIO_MIXER_MAX_STREAMS) + return; + + strlcpy(s, audio_driver_mixer_get_stream_name(offset), len); +} + static void menu_action_setting_audio_mixer_stream_volume( file_list_t* list, unsigned *w, unsigned type, unsigned i, @@ -2115,7 +2135,14 @@ static int menu_cbs_init_bind_get_string_representation_compare_label( static int menu_cbs_init_bind_get_string_representation_compare_type( menu_file_list_cbs_t *cbs, unsigned type) { - if (type >= MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_VOLUME_BEGIN + if (type >= MENU_SETTINGS_AUDIO_MIXER_STREAM_BEGIN + && type <= MENU_SETTINGS_AUDIO_MIXER_STREAM_END) + { + BIND_ACTION_GET_VALUE(cbs, + menu_action_setting_audio_mixer_stream_name); + return 0; + } + else if (type >= MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_VOLUME_BEGIN && type <= MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_VOLUME_END) { BIND_ACTION_GET_VALUE(cbs, diff --git a/tasks/task_audio_mixer.c b/tasks/task_audio_mixer.c index cc9d7cbfb2..2943504e9d 100644 --- a/tasks/task_audio_mixer.c +++ b/tasks/task_audio_mixer.c @@ -21,6 +21,7 @@ #include #include +#include #include