Add value descriptions for audio mixer streams

This commit is contained in:
twinaphex 2018-05-02 20:13:13 +02:00
parent eff75a3bcd
commit 9fbfd503af
4 changed files with 69 additions and 1 deletions

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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,

View File

@ -21,6 +21,7 @@
#include <errno.h>
#include <file/nbio.h>
#include <file/file_path.h>
#include <audio/audio_mixer.h>
#include <compat/strl.h>
#include <string/stdstring.h>
@ -37,6 +38,7 @@ typedef struct nbio_buf
{
void *buf;
unsigned bufsize;
char *path;
} nbio_buf_t;
struct audio_mixer_handle
@ -56,7 +58,11 @@ static void task_audio_mixer_load_free(retro_task_t *task)
if (image)
{
if (image->buffer)
{
if (image->buffer->path)
free(image->buffer->path);
free(image->buffer);
}
}
if (!string_is_empty(nbio->path))
@ -101,9 +107,12 @@ static void task_audio_mixer_handle_upload_ogg(void *task_data,
params.buf = img->buf;
params.bufsize = img->bufsize;
params.cb = NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename(img->path)) : NULL;
audio_driver_mixer_add_stream(&params);
if (params.basename != NULL)
free(params.basename);
free(img);
free(user_data);
}
@ -123,9 +132,12 @@ static void task_audio_mixer_handle_upload_flac(void *task_data,
params.buf = img->buf;
params.bufsize = img->bufsize;
params.cb = NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename(img->path)) : NULL;
audio_driver_mixer_add_stream(&params);
if (params.basename != NULL)
free(params.basename);
free(img);
free(user_data);
}
@ -145,9 +157,12 @@ static void task_audio_mixer_handle_upload_mp3(void *task_data,
params.buf = img->buf;
params.bufsize = img->bufsize;
params.cb = NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename(img->path)) : NULL;
audio_driver_mixer_add_stream(&params);
if (params.basename != NULL)
free(params.basename);
free(img);
free(user_data);
}
@ -167,9 +182,12 @@ static void task_audio_mixer_handle_upload_mod(void *task_data,
params.buf = img->buf;
params.bufsize = img->bufsize;
params.cb = NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename(img->path)) : NULL;
audio_driver_mixer_add_stream(&params);
if (params.basename != NULL)
free(params.basename);
free(img);
free(user_data);
}
@ -189,9 +207,12 @@ static void task_audio_mixer_handle_upload_wav(void *task_data,
params.buf = img->buf;
params.bufsize = img->bufsize;
params.cb = NULL;
params.basename = !string_is_empty(img->path) ? strdup(path_basename(img->path)) : NULL;
audio_driver_mixer_add_stream(&params);
if (params.basename != NULL)
free(params.basename);
free(img);
free(user_data);
}
@ -213,6 +234,7 @@ bool task_audio_mixer_load_handler(retro_task_t *task)
{
img->buf = image->buffer->buf;
img->bufsize = image->buffer->bufsize;
img->path = strdup(nbio->path);
}
task_set_data(task, img);