mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 00:20:01 +00:00
Add 4 additional mixer slots for system sound effects and music
for menu
This commit is contained in:
parent
30e48b46b3
commit
65d5de6674
@ -137,7 +137,7 @@ static const audio_driver_t *audio_drivers[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static struct audio_mixer_stream audio_mixer_streams[AUDIO_MIXER_MAX_STREAMS] = {{0}};
|
||||
static struct audio_mixer_stream audio_mixer_streams[AUDIO_MIXER_MAX_SYSTEM_STREAMS] = {{0}};
|
||||
|
||||
static size_t audio_driver_chunk_size = 0;
|
||||
static size_t audio_driver_chunk_nonblock_size = 0;
|
||||
@ -203,14 +203,14 @@ enum resampler_quality audio_driver_get_resampler_quality(void)
|
||||
|
||||
audio_mixer_stream_t *audio_driver_mixer_get_stream(unsigned i)
|
||||
{
|
||||
if (i > (AUDIO_MIXER_MAX_STREAMS-1))
|
||||
if (i > (AUDIO_MIXER_MAX_SYSTEM_STREAMS-1))
|
||||
return NULL;
|
||||
return &audio_mixer_streams[i];
|
||||
}
|
||||
|
||||
const char *audio_driver_mixer_get_stream_name(unsigned i)
|
||||
{
|
||||
if (i > (AUDIO_MIXER_MAX_STREAMS-1))
|
||||
if (i > (AUDIO_MIXER_MAX_SYSTEM_STREAMS-1))
|
||||
return "N/A";
|
||||
if (!string_is_empty(audio_mixer_streams[i].name))
|
||||
return audio_mixer_streams[i].name;
|
||||
@ -1053,7 +1053,7 @@ static int audio_mixer_find_index(audio_mixer_sound_t *sound)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < AUDIO_MIXER_MAX_STREAMS; i++)
|
||||
for (i = 0; i < AUDIO_MIXER_MAX_SYSTEM_STREAMS; i++)
|
||||
{
|
||||
audio_mixer_sound_t *handle = audio_mixer_streams[i].handle;
|
||||
if (handle == sound)
|
||||
@ -1112,6 +1112,11 @@ static void audio_mixer_play_stop_sequential_cb(
|
||||
if (!string_is_empty(audio_mixer_streams[i].name))
|
||||
free(audio_mixer_streams[i].name);
|
||||
|
||||
if (i < AUDIO_MIXER_MAX_STREAMS)
|
||||
audio_mixer_streams[i].type = AUDIO_STREAM_TYPE_USER;
|
||||
else
|
||||
audio_mixer_streams[i].type = AUDIO_STREAM_TYPE_SYSTEM;
|
||||
|
||||
audio_mixer_streams[i].name = NULL;
|
||||
audio_mixer_streams[i].state = AUDIO_STREAM_STATE_NONE;
|
||||
audio_mixer_streams[i].volume = 0.0f;
|
||||
@ -1122,7 +1127,7 @@ static void audio_mixer_play_stop_sequential_cb(
|
||||
|
||||
i++;
|
||||
|
||||
for (; i < AUDIO_MIXER_MAX_STREAMS; i++)
|
||||
for (; i < AUDIO_MIXER_MAX_SYSTEM_STREAMS; i++)
|
||||
{
|
||||
if (audio_mixer_streams[i].state == AUDIO_STREAM_STATE_STOPPED)
|
||||
{
|
||||
@ -1139,10 +1144,11 @@ static void audio_mixer_play_stop_sequential_cb(
|
||||
}
|
||||
}
|
||||
|
||||
bool audio_driver_mixer_get_free_stream_slot(unsigned *id)
|
||||
static bool audio_driver_mixer_get_free_stream_slot(unsigned *id, enum audio_mixer_stream_type type)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < AUDIO_MIXER_MAX_STREAMS; i++)
|
||||
unsigned i = (type == AUDIO_STREAM_TYPE_USER) ? 0 : AUDIO_MIXER_MAX_STREAMS;
|
||||
unsigned count = (type == AUDIO_STREAM_TYPE_USER) ? AUDIO_MIXER_MAX_STREAMS : AUDIO_MIXER_MAX_SYSTEM_STREAMS;
|
||||
for (; i < count; i++)
|
||||
{
|
||||
if (audio_mixer_streams[i].state == AUDIO_STREAM_STATE_NONE)
|
||||
{
|
||||
@ -1163,7 +1169,10 @@ bool audio_driver_mixer_add_stream(audio_mixer_stream_params_t *params)
|
||||
bool looped = false;
|
||||
void *buf = NULL;
|
||||
|
||||
if (!audio_driver_mixer_get_free_stream_slot(&free_slot))
|
||||
if (params->stream_type == AUDIO_STREAM_TYPE_NONE)
|
||||
return false;
|
||||
|
||||
if (!audio_driver_mixer_get_free_stream_slot(&free_slot, params->stream_type))
|
||||
return false;
|
||||
|
||||
if (params->state == AUDIO_STREAM_STATE_NONE)
|
||||
@ -1230,6 +1239,7 @@ bool audio_driver_mixer_add_stream(audio_mixer_stream_params_t *params)
|
||||
audio_mixer_streams[free_slot].buf = buf;
|
||||
audio_mixer_streams[free_slot].handle = handle;
|
||||
audio_mixer_streams[free_slot].voice = voice;
|
||||
audio_mixer_streams[free_slot].type = params->stream_type;
|
||||
audio_mixer_streams[free_slot].state = params->state;
|
||||
audio_mixer_streams[free_slot].volume = params->volume;
|
||||
audio_mixer_streams[free_slot].stop_cb = stop_cb;
|
||||
@ -1239,7 +1249,7 @@ bool audio_driver_mixer_add_stream(audio_mixer_stream_params_t *params)
|
||||
|
||||
enum audio_mixer_state audio_driver_mixer_get_stream_state(unsigned i)
|
||||
{
|
||||
if (i >= AUDIO_MIXER_MAX_STREAMS)
|
||||
if (i >= AUDIO_MIXER_MAX_SYSTEM_STREAMS)
|
||||
return AUDIO_STREAM_STATE_NONE;
|
||||
|
||||
return audio_mixer_streams[i].state;
|
||||
@ -1249,7 +1259,7 @@ static void audio_driver_mixer_play_stream_internal(unsigned i, unsigned type)
|
||||
{
|
||||
bool set_state = false;
|
||||
|
||||
if (i >= AUDIO_MIXER_MAX_STREAMS)
|
||||
if (i >= AUDIO_MIXER_MAX_SYSTEM_STREAMS)
|
||||
return;
|
||||
|
||||
switch (audio_mixer_streams[i].state)
|
||||
@ -1291,7 +1301,7 @@ void audio_driver_mixer_play_stream_sequential(unsigned i)
|
||||
|
||||
float audio_driver_mixer_get_stream_volume(unsigned i)
|
||||
{
|
||||
if (i >= AUDIO_MIXER_MAX_STREAMS)
|
||||
if (i >= AUDIO_MIXER_MAX_SYSTEM_STREAMS)
|
||||
return 0.0f;
|
||||
|
||||
return audio_mixer_streams[i].volume;
|
||||
@ -1301,7 +1311,7 @@ void audio_driver_mixer_set_stream_volume(unsigned i, float vol)
|
||||
{
|
||||
audio_mixer_voice_t *voice = NULL;
|
||||
|
||||
if (i >= AUDIO_MIXER_MAX_STREAMS)
|
||||
if (i >= AUDIO_MIXER_MAX_SYSTEM_STREAMS)
|
||||
return;
|
||||
|
||||
audio_mixer_streams[i].volume = vol;
|
||||
@ -1316,7 +1326,7 @@ void audio_driver_mixer_stop_stream(unsigned i)
|
||||
{
|
||||
bool set_state = false;
|
||||
|
||||
if (i >= AUDIO_MIXER_MAX_STREAMS)
|
||||
if (i >= AUDIO_MIXER_MAX_SYSTEM_STREAMS)
|
||||
return;
|
||||
|
||||
switch (audio_mixer_streams[i].state)
|
||||
@ -1346,7 +1356,7 @@ void audio_driver_mixer_remove_stream(unsigned i)
|
||||
{
|
||||
bool destroy = false;
|
||||
|
||||
if (i >= AUDIO_MIXER_MAX_STREAMS)
|
||||
if (i >= AUDIO_MIXER_MAX_SYSTEM_STREAMS)
|
||||
return;
|
||||
|
||||
switch (audio_mixer_streams[i].state)
|
||||
@ -1388,7 +1398,7 @@ static void audio_driver_mixer_deinit(void)
|
||||
|
||||
audio_mixer_active = false;
|
||||
|
||||
for (i = 0; i < AUDIO_MIXER_MAX_STREAMS; i++)
|
||||
for (i = 0; i < AUDIO_MIXER_MAX_SYSTEM_STREAMS; i++)
|
||||
{
|
||||
audio_driver_mixer_stop_stream(i);
|
||||
audio_driver_mixer_remove_stream(i);
|
||||
|
@ -37,6 +37,8 @@ RETRO_BEGIN_DECLS
|
||||
|
||||
#define AUDIO_MIXER_MAX_STREAMS 16
|
||||
|
||||
#define AUDIO_MIXER_MAX_SYSTEM_STREAMS (AUDIO_MIXER_MAX_STREAMS+4)
|
||||
|
||||
enum audio_action
|
||||
{
|
||||
AUDIO_ACTION_NONE = 0,
|
||||
@ -48,6 +50,13 @@ enum audio_action
|
||||
AUDIO_ACTION_MIXER
|
||||
};
|
||||
|
||||
enum audio_mixer_stream_type
|
||||
{
|
||||
AUDIO_STREAM_TYPE_NONE = 0,
|
||||
AUDIO_STREAM_TYPE_USER,
|
||||
AUDIO_STREAM_TYPE_SYSTEM
|
||||
};
|
||||
|
||||
enum audio_mixer_state
|
||||
{
|
||||
AUDIO_STREAM_STATE_NONE = 0,
|
||||
@ -62,6 +71,8 @@ typedef struct audio_mixer_stream
|
||||
audio_mixer_sound_t *handle;
|
||||
audio_mixer_voice_t *voice;
|
||||
audio_mixer_stop_cb_t stop_cb;
|
||||
enum audio_mixer_stream_type stream_type;
|
||||
enum audio_mixer_type type;
|
||||
enum audio_mixer_state state;
|
||||
float volume;
|
||||
void *buf;
|
||||
@ -163,6 +174,7 @@ typedef struct audio_driver
|
||||
typedef struct audio_mixer_stream_params
|
||||
{
|
||||
float volume;
|
||||
enum audio_mixer_stream_type stream_type;
|
||||
enum audio_mixer_type type;
|
||||
enum audio_mixer_state state;
|
||||
void *buf;
|
||||
|
@ -70,7 +70,7 @@ static void menu_action_setting_audio_mixer_stream_name(
|
||||
*w = 19;
|
||||
strlcpy(s2, path, len2);
|
||||
|
||||
if (offset >= AUDIO_MIXER_MAX_STREAMS)
|
||||
if (offset >= AUDIO_MIXER_MAX_SYSTEM_STREAMS)
|
||||
return;
|
||||
|
||||
strlcpy(s, audio_driver_mixer_get_stream_name(offset), len);
|
||||
@ -90,7 +90,7 @@ static void menu_action_setting_audio_mixer_stream_volume(
|
||||
*w = 19;
|
||||
strlcpy(s2, path, len2);
|
||||
|
||||
if (offset >= AUDIO_MIXER_MAX_STREAMS)
|
||||
if (offset >= AUDIO_MIXER_MAX_SYSTEM_STREAMS)
|
||||
return;
|
||||
|
||||
snprintf(s, len, "%.2f dB", audio_driver_mixer_get_stream_volume(offset));
|
||||
|
@ -2029,7 +2029,7 @@ static int action_ok_audio_add_to_mixer(const char *path,
|
||||
|
||||
if (filestream_exists(entry_path))
|
||||
task_push_audio_mixer_load(entry_path,
|
||||
NULL, NULL);
|
||||
NULL, NULL, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -2048,7 +2048,7 @@ static int action_ok_audio_add_to_mixer_and_play(const char *path,
|
||||
|
||||
if (filestream_exists(entry_path))
|
||||
task_push_audio_mixer_load_and_play(entry_path,
|
||||
NULL, NULL);
|
||||
NULL, NULL, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -2076,7 +2076,7 @@ static int action_ok_audio_add_to_mixer_and_collection(const char *path,
|
||||
|
||||
if (filestream_exists(combined_path))
|
||||
task_push_audio_mixer_load(combined_path,
|
||||
NULL, NULL);
|
||||
NULL, NULL, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -2104,7 +2104,7 @@ static int action_ok_audio_add_to_mixer_and_collection_and_play(const char *path
|
||||
|
||||
if (filestream_exists(combined_path))
|
||||
task_push_audio_mixer_load_and_play(combined_path,
|
||||
NULL, NULL);
|
||||
NULL, NULL, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -6803,7 +6803,14 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist
|
||||
unsigned i;
|
||||
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
|
||||
|
||||
#if 1
|
||||
/* TODO - for developers -
|
||||
* turn this into #if 0 if you want to be able to see
|
||||
* the system streams as well. */
|
||||
for (i = 0; i < AUDIO_MIXER_MAX_STREAMS; i++)
|
||||
#else
|
||||
for (i = 0; i < AUDIO_MIXER_MAX_SYSTEM_STREAMS; i++)
|
||||
#endif
|
||||
{
|
||||
char msg[128];
|
||||
char msg_lbl[128];
|
||||
|
@ -127,7 +127,7 @@ enum rarch_menu_ctl_state
|
||||
MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL
|
||||
};
|
||||
|
||||
#define MENU_SETTINGS_AUDIO_MIXER_MAX_STREAMS (AUDIO_MIXER_MAX_STREAMS-1)
|
||||
#define MENU_SETTINGS_AUDIO_MIXER_MAX_STREAMS (AUDIO_MIXER_MAX_SYSTEM_STREAMS-1)
|
||||
|
||||
enum menu_settings_type
|
||||
{
|
||||
|
@ -41,6 +41,11 @@ typedef struct nbio_buf
|
||||
char *path;
|
||||
} nbio_buf_t;
|
||||
|
||||
struct audio_mixer_userdata
|
||||
{
|
||||
enum audio_mixer_stream_type stream_type;
|
||||
};
|
||||
|
||||
struct audio_mixer_handle
|
||||
{
|
||||
nbio_buf_t *buffer;
|
||||
@ -53,15 +58,15 @@ struct audio_mixer_handle
|
||||
static void task_audio_mixer_load_free(retro_task_t *task)
|
||||
{
|
||||
nbio_handle_t *nbio = (nbio_handle_t*)task->state;
|
||||
struct audio_mixer_handle *image = (struct audio_mixer_handle*)nbio->data;
|
||||
struct audio_mixer_handle *mixer = (struct audio_mixer_handle*)nbio->data;
|
||||
|
||||
if (image)
|
||||
if (mixer)
|
||||
{
|
||||
if (image->buffer)
|
||||
if (mixer->buffer)
|
||||
{
|
||||
if (image->buffer->path)
|
||||
free(image->buffer->path);
|
||||
free(image->buffer);
|
||||
if (mixer->buffer->path)
|
||||
free(mixer->buffer->path);
|
||||
free(mixer->buffer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,17 +81,17 @@ static void task_audio_mixer_load_free(retro_task_t *task)
|
||||
static int cb_nbio_audio_mixer_load(void *data, size_t len)
|
||||
{
|
||||
nbio_handle_t *nbio = (nbio_handle_t*)data;
|
||||
struct audio_mixer_handle *image= (struct audio_mixer_handle*)nbio->data;
|
||||
struct audio_mixer_handle *mixer= (struct audio_mixer_handle*)nbio->data;
|
||||
void *ptr = nbio_get_ptr(nbio->handle, &len);
|
||||
nbio_buf_t *buffer = (nbio_buf_t*)calloc(1, sizeof(*image->buffer));
|
||||
nbio_buf_t *buffer = (nbio_buf_t*)calloc(1, sizeof(*mixer->buffer));
|
||||
|
||||
if (!buffer)
|
||||
return -1;
|
||||
|
||||
image->buffer = buffer;
|
||||
image->buffer->buf = ptr;
|
||||
image->buffer->bufsize = (unsigned)len;
|
||||
image->copy_data_over = true;
|
||||
mixer->buffer = buffer;
|
||||
mixer->buffer->buf = ptr;
|
||||
mixer->buffer->bufsize = (unsigned)len;
|
||||
mixer->copy_data_over = true;
|
||||
nbio->is_finished = true;
|
||||
|
||||
return 0;
|
||||
@ -97,11 +102,12 @@ static void task_audio_mixer_handle_upload_ogg(void *task_data,
|
||||
{
|
||||
audio_mixer_stream_params_t params;
|
||||
nbio_buf_t *img = (nbio_buf_t*)task_data;
|
||||
|
||||
if (!img)
|
||||
struct audio_mixer_userdata *user = (struct audio_mixer_userdata*)user_data;
|
||||
if (!img || !user)
|
||||
return;
|
||||
|
||||
params.volume = 1.0f;
|
||||
params.stream_type = user->stream_type;
|
||||
params.type = AUDIO_MIXER_TYPE_OGG;
|
||||
params.state = AUDIO_STREAM_STATE_STOPPED;
|
||||
params.buf = img->buf;
|
||||
@ -122,11 +128,13 @@ static void task_audio_mixer_handle_upload_ogg_and_play(void *task_data,
|
||||
{
|
||||
audio_mixer_stream_params_t params;
|
||||
nbio_buf_t *img = (nbio_buf_t*)task_data;
|
||||
struct audio_mixer_userdata *user = (struct audio_mixer_userdata*)user_data;
|
||||
|
||||
if (!img)
|
||||
if (!img || !user)
|
||||
return;
|
||||
|
||||
params.volume = 1.0f;
|
||||
params.stream_type = user->stream_type;
|
||||
params.type = AUDIO_MIXER_TYPE_OGG;
|
||||
params.state = AUDIO_STREAM_STATE_PLAYING;
|
||||
params.buf = img->buf;
|
||||
@ -147,11 +155,13 @@ static void task_audio_mixer_handle_upload_flac(void *task_data,
|
||||
{
|
||||
audio_mixer_stream_params_t params;
|
||||
nbio_buf_t *img = (nbio_buf_t*)task_data;
|
||||
struct audio_mixer_userdata *user = (struct audio_mixer_userdata*)user_data;
|
||||
|
||||
if (!img)
|
||||
if (!img || !user)
|
||||
return;
|
||||
|
||||
params.volume = 1.0f;
|
||||
params.stream_type = user->stream_type;
|
||||
params.type = AUDIO_MIXER_TYPE_FLAC;
|
||||
params.state = AUDIO_STREAM_STATE_STOPPED;
|
||||
params.buf = img->buf;
|
||||
@ -172,11 +182,13 @@ static void task_audio_mixer_handle_upload_flac_and_play(void *task_data,
|
||||
{
|
||||
audio_mixer_stream_params_t params;
|
||||
nbio_buf_t *img = (nbio_buf_t*)task_data;
|
||||
struct audio_mixer_userdata *user = (struct audio_mixer_userdata*)user_data;
|
||||
|
||||
if (!img)
|
||||
if (!img || !user)
|
||||
return;
|
||||
|
||||
params.volume = 1.0f;
|
||||
params.stream_type = user->stream_type;
|
||||
params.type = AUDIO_MIXER_TYPE_FLAC;
|
||||
params.state = AUDIO_STREAM_STATE_PLAYING;
|
||||
params.buf = img->buf;
|
||||
@ -197,11 +209,13 @@ static void task_audio_mixer_handle_upload_mp3(void *task_data,
|
||||
{
|
||||
audio_mixer_stream_params_t params;
|
||||
nbio_buf_t *img = (nbio_buf_t*)task_data;
|
||||
struct audio_mixer_userdata *user = (struct audio_mixer_userdata*)user_data;
|
||||
|
||||
if (!img)
|
||||
if (!img || !user)
|
||||
return;
|
||||
|
||||
params.volume = 1.0f;
|
||||
params.stream_type = user->stream_type;
|
||||
params.type = AUDIO_MIXER_TYPE_MP3;
|
||||
params.state = AUDIO_STREAM_STATE_STOPPED;
|
||||
params.buf = img->buf;
|
||||
@ -222,11 +236,13 @@ static void task_audio_mixer_handle_upload_mp3_and_play(void *task_data,
|
||||
{
|
||||
audio_mixer_stream_params_t params;
|
||||
nbio_buf_t *img = (nbio_buf_t*)task_data;
|
||||
struct audio_mixer_userdata *user = (struct audio_mixer_userdata*)user_data;
|
||||
|
||||
if (!img)
|
||||
if (!img || !user)
|
||||
return;
|
||||
|
||||
params.volume = 1.0f;
|
||||
params.stream_type = user->stream_type;
|
||||
params.type = AUDIO_MIXER_TYPE_MP3;
|
||||
params.state = AUDIO_STREAM_STATE_PLAYING;
|
||||
params.buf = img->buf;
|
||||
@ -247,11 +263,13 @@ static void task_audio_mixer_handle_upload_mod(void *task_data,
|
||||
{
|
||||
audio_mixer_stream_params_t params;
|
||||
nbio_buf_t *img = (nbio_buf_t*)task_data;
|
||||
struct audio_mixer_userdata *user = (struct audio_mixer_userdata*)user_data;
|
||||
|
||||
if (!img)
|
||||
if (!img || !user)
|
||||
return;
|
||||
|
||||
params.volume = 1.0f;
|
||||
params.stream_type = user->stream_type;
|
||||
params.type = AUDIO_MIXER_TYPE_MOD;
|
||||
params.state = AUDIO_STREAM_STATE_STOPPED;
|
||||
params.buf = img->buf;
|
||||
@ -272,11 +290,13 @@ static void task_audio_mixer_handle_upload_mod_and_play(void *task_data,
|
||||
{
|
||||
audio_mixer_stream_params_t params;
|
||||
nbio_buf_t *img = (nbio_buf_t*)task_data;
|
||||
struct audio_mixer_userdata *user = (struct audio_mixer_userdata*)user_data;
|
||||
|
||||
if (!img)
|
||||
if (!img || !user)
|
||||
return;
|
||||
|
||||
params.volume = 1.0f;
|
||||
params.stream_type = user->stream_type;
|
||||
params.type = AUDIO_MIXER_TYPE_MOD;
|
||||
params.state = AUDIO_STREAM_STATE_PLAYING;
|
||||
params.buf = img->buf;
|
||||
@ -297,11 +317,13 @@ static void task_audio_mixer_handle_upload_wav(void *task_data,
|
||||
{
|
||||
audio_mixer_stream_params_t params;
|
||||
nbio_buf_t *img = (nbio_buf_t*)task_data;
|
||||
struct audio_mixer_userdata *user = (struct audio_mixer_userdata*)user_data;
|
||||
|
||||
if (!img)
|
||||
if (!img || !user)
|
||||
return;
|
||||
|
||||
params.volume = 1.0f;
|
||||
params.stream_type = user->stream_type;
|
||||
params.type = AUDIO_MIXER_TYPE_WAV;
|
||||
params.state = AUDIO_STREAM_STATE_STOPPED;
|
||||
params.buf = img->buf;
|
||||
@ -322,11 +344,13 @@ static void task_audio_mixer_handle_upload_wav_and_play(void *task_data,
|
||||
{
|
||||
audio_mixer_stream_params_t params;
|
||||
nbio_buf_t *img = (nbio_buf_t*)task_data;
|
||||
struct audio_mixer_userdata *user = (struct audio_mixer_userdata*)user_data;
|
||||
|
||||
if (!img)
|
||||
if (!img || !user)
|
||||
return;
|
||||
|
||||
params.volume = 1.0f;
|
||||
params.stream_type = user->stream_type;
|
||||
params.type = AUDIO_MIXER_TYPE_WAV;
|
||||
params.state = AUDIO_STREAM_STATE_PLAYING;
|
||||
params.buf = img->buf;
|
||||
@ -345,27 +369,27 @@ static void task_audio_mixer_handle_upload_wav_and_play(void *task_data,
|
||||
bool task_audio_mixer_load_handler(retro_task_t *task)
|
||||
{
|
||||
nbio_handle_t *nbio = (nbio_handle_t*)task->state;
|
||||
struct audio_mixer_handle *image = (struct audio_mixer_handle*)nbio->data;
|
||||
struct audio_mixer_handle *mixer = (struct audio_mixer_handle*)nbio->data;
|
||||
|
||||
if (
|
||||
nbio->is_finished
|
||||
&& (image && !image->is_finished)
|
||||
&& (image->copy_data_over)
|
||||
&& (mixer && !mixer->is_finished)
|
||||
&& (mixer->copy_data_over)
|
||||
&& (!task_get_cancelled(task)))
|
||||
{
|
||||
nbio_buf_t *img = (nbio_buf_t*)calloc(1, sizeof(*img));
|
||||
|
||||
if (img)
|
||||
{
|
||||
img->buf = image->buffer->buf;
|
||||
img->bufsize = image->buffer->bufsize;
|
||||
img->buf = mixer->buffer->buf;
|
||||
img->bufsize = mixer->buffer->bufsize;
|
||||
img->path = strdup(nbio->path);
|
||||
}
|
||||
|
||||
task_set_data(task, img);
|
||||
|
||||
image->copy_data_over = false;
|
||||
image->is_finished = true;
|
||||
mixer->copy_data_over = false;
|
||||
mixer->is_finished = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -373,13 +397,15 @@ bool task_audio_mixer_load_handler(retro_task_t *task)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool task_push_audio_mixer_load_and_play(const char *fullpath, retro_task_callback_t cb, void *user_data)
|
||||
bool task_push_audio_mixer_load_and_play(const char *fullpath, retro_task_callback_t cb, void *user_data,
|
||||
bool system)
|
||||
{
|
||||
nbio_handle_t *nbio = NULL;
|
||||
struct audio_mixer_handle *image = NULL;
|
||||
struct audio_mixer_handle *mixer = NULL;
|
||||
retro_task_t *t = (retro_task_t*)calloc(1, sizeof(*t));
|
||||
struct audio_mixer_userdata *user = (struct audio_mixer_userdata*)calloc(1, sizeof(*user));
|
||||
|
||||
if (!t)
|
||||
if (!t || !user)
|
||||
goto error;
|
||||
|
||||
nbio = (nbio_handle_t*)calloc(1, sizeof(*nbio));
|
||||
@ -389,38 +415,38 @@ bool task_push_audio_mixer_load_and_play(const char *fullpath, retro_task_callba
|
||||
|
||||
nbio->path = strdup(fullpath);
|
||||
|
||||
image = (struct audio_mixer_handle*)calloc(1, sizeof(*image));
|
||||
if (!image)
|
||||
mixer = (struct audio_mixer_handle*)calloc(1, sizeof(*mixer));
|
||||
if (!mixer)
|
||||
goto error;
|
||||
|
||||
image->is_finished = false;
|
||||
mixer->is_finished = false;
|
||||
|
||||
strlcpy(image->path, fullpath, sizeof(image->path));
|
||||
strlcpy(mixer->path, fullpath, sizeof(mixer->path));
|
||||
|
||||
nbio->type = NBIO_TYPE_NONE;
|
||||
image->type = AUDIO_MIXER_TYPE_NONE;
|
||||
mixer->type = AUDIO_MIXER_TYPE_NONE;
|
||||
|
||||
if (strstr(fullpath, file_path_str(FILE_PATH_WAV_EXTENSION)))
|
||||
{
|
||||
image->type = AUDIO_MIXER_TYPE_WAV;
|
||||
mixer->type = AUDIO_MIXER_TYPE_WAV;
|
||||
nbio->type = NBIO_TYPE_WAV;
|
||||
t->callback = task_audio_mixer_handle_upload_wav_and_play;
|
||||
}
|
||||
else if (strstr(fullpath, file_path_str(FILE_PATH_OGG_EXTENSION)))
|
||||
{
|
||||
image->type = AUDIO_MIXER_TYPE_OGG;
|
||||
mixer->type = AUDIO_MIXER_TYPE_OGG;
|
||||
nbio->type = NBIO_TYPE_OGG;
|
||||
t->callback = task_audio_mixer_handle_upload_ogg_and_play;
|
||||
}
|
||||
else if (strstr(fullpath, file_path_str(FILE_PATH_MP3_EXTENSION)))
|
||||
{
|
||||
image->type = AUDIO_MIXER_TYPE_MP3;
|
||||
mixer->type = AUDIO_MIXER_TYPE_MP3;
|
||||
nbio->type = NBIO_TYPE_MP3;
|
||||
t->callback = task_audio_mixer_handle_upload_mp3_and_play;
|
||||
}
|
||||
else if (strstr(fullpath, file_path_str(FILE_PATH_FLAC_EXTENSION)))
|
||||
{
|
||||
image->type = AUDIO_MIXER_TYPE_FLAC;
|
||||
mixer->type = AUDIO_MIXER_TYPE_FLAC;
|
||||
nbio->type = NBIO_TYPE_FLAC;
|
||||
t->callback = task_audio_mixer_handle_upload_flac_and_play;
|
||||
}
|
||||
@ -428,12 +454,17 @@ bool task_push_audio_mixer_load_and_play(const char *fullpath, retro_task_callba
|
||||
strstr(fullpath, file_path_str(FILE_PATH_S3M_EXTENSION)) ||
|
||||
strstr(fullpath, file_path_str(FILE_PATH_XM_EXTENSION)))
|
||||
{
|
||||
image->type = AUDIO_MIXER_TYPE_MOD;
|
||||
mixer->type = AUDIO_MIXER_TYPE_MOD;
|
||||
nbio->type = NBIO_TYPE_MOD;
|
||||
t->callback = task_audio_mixer_handle_upload_mod_and_play;
|
||||
}
|
||||
|
||||
nbio->data = (struct audio_mixer_handle*)image;
|
||||
if (system)
|
||||
user->stream_type = AUDIO_STREAM_TYPE_SYSTEM;
|
||||
else
|
||||
user->stream_type = AUDIO_STREAM_TYPE_USER;
|
||||
|
||||
nbio->data = (struct audio_mixer_handle*)mixer;
|
||||
nbio->is_finished = false;
|
||||
nbio->cb = &cb_nbio_audio_mixer_load;
|
||||
nbio->status = NBIO_STATUS_INIT;
|
||||
@ -441,7 +472,7 @@ bool task_push_audio_mixer_load_and_play(const char *fullpath, retro_task_callba
|
||||
t->state = nbio;
|
||||
t->handler = task_file_load_handler;
|
||||
t->cleanup = task_audio_mixer_load_free;
|
||||
t->user_data = user_data;
|
||||
t->user_data = user;
|
||||
|
||||
task_queue_push(t);
|
||||
|
||||
@ -457,6 +488,8 @@ error:
|
||||
nbio_free(nbio->handle);
|
||||
free(nbio);
|
||||
}
|
||||
if (user)
|
||||
free(user);
|
||||
if (t)
|
||||
free(t);
|
||||
|
||||
@ -466,13 +499,15 @@ error:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool task_push_audio_mixer_load(const char *fullpath, retro_task_callback_t cb, void *user_data)
|
||||
bool task_push_audio_mixer_load(const char *fullpath, retro_task_callback_t cb, void *user_data,
|
||||
bool system)
|
||||
{
|
||||
nbio_handle_t *nbio = NULL;
|
||||
struct audio_mixer_handle *image = NULL;
|
||||
struct audio_mixer_handle *mixer = NULL;
|
||||
retro_task_t *t = (retro_task_t*)calloc(1, sizeof(*t));
|
||||
struct audio_mixer_userdata *user = (struct audio_mixer_userdata*)calloc(1, sizeof(*user));
|
||||
|
||||
if (!t)
|
||||
if (!t || !user)
|
||||
goto error;
|
||||
|
||||
nbio = (nbio_handle_t*)calloc(1, sizeof(*nbio));
|
||||
@ -482,38 +517,38 @@ bool task_push_audio_mixer_load(const char *fullpath, retro_task_callback_t cb,
|
||||
|
||||
nbio->path = strdup(fullpath);
|
||||
|
||||
image = (struct audio_mixer_handle*)calloc(1, sizeof(*image));
|
||||
if (!image)
|
||||
mixer = (struct audio_mixer_handle*)calloc(1, sizeof(*mixer));
|
||||
if (!mixer)
|
||||
goto error;
|
||||
|
||||
image->is_finished = false;
|
||||
mixer->is_finished = false;
|
||||
|
||||
strlcpy(image->path, fullpath, sizeof(image->path));
|
||||
strlcpy(mixer->path, fullpath, sizeof(mixer->path));
|
||||
|
||||
nbio->type = NBIO_TYPE_NONE;
|
||||
image->type = AUDIO_MIXER_TYPE_NONE;
|
||||
mixer->type = AUDIO_MIXER_TYPE_NONE;
|
||||
|
||||
if (strstr(fullpath, file_path_str(FILE_PATH_WAV_EXTENSION)))
|
||||
{
|
||||
image->type = AUDIO_MIXER_TYPE_WAV;
|
||||
mixer->type = AUDIO_MIXER_TYPE_WAV;
|
||||
nbio->type = NBIO_TYPE_WAV;
|
||||
t->callback = task_audio_mixer_handle_upload_wav;
|
||||
}
|
||||
else if (strstr(fullpath, file_path_str(FILE_PATH_OGG_EXTENSION)))
|
||||
{
|
||||
image->type = AUDIO_MIXER_TYPE_OGG;
|
||||
mixer->type = AUDIO_MIXER_TYPE_OGG;
|
||||
nbio->type = NBIO_TYPE_OGG;
|
||||
t->callback = task_audio_mixer_handle_upload_ogg;
|
||||
}
|
||||
else if (strstr(fullpath, file_path_str(FILE_PATH_MP3_EXTENSION)))
|
||||
{
|
||||
image->type = AUDIO_MIXER_TYPE_MP3;
|
||||
mixer->type = AUDIO_MIXER_TYPE_MP3;
|
||||
nbio->type = NBIO_TYPE_MP3;
|
||||
t->callback = task_audio_mixer_handle_upload_mp3;
|
||||
}
|
||||
else if (strstr(fullpath, file_path_str(FILE_PATH_FLAC_EXTENSION)))
|
||||
{
|
||||
image->type = AUDIO_MIXER_TYPE_FLAC;
|
||||
mixer->type = AUDIO_MIXER_TYPE_FLAC;
|
||||
nbio->type = NBIO_TYPE_FLAC;
|
||||
t->callback = task_audio_mixer_handle_upload_flac;
|
||||
}
|
||||
@ -521,20 +556,25 @@ bool task_push_audio_mixer_load(const char *fullpath, retro_task_callback_t cb,
|
||||
strstr(fullpath, file_path_str(FILE_PATH_S3M_EXTENSION)) ||
|
||||
strstr(fullpath, file_path_str(FILE_PATH_XM_EXTENSION)))
|
||||
{
|
||||
image->type = AUDIO_MIXER_TYPE_MOD;
|
||||
mixer->type = AUDIO_MIXER_TYPE_MOD;
|
||||
nbio->type = NBIO_TYPE_MOD;
|
||||
t->callback = task_audio_mixer_handle_upload_mod;
|
||||
}
|
||||
|
||||
nbio->data = (struct audio_mixer_handle*)image;
|
||||
nbio->data = (struct audio_mixer_handle*)mixer;
|
||||
nbio->is_finished = false;
|
||||
nbio->cb = &cb_nbio_audio_mixer_load;
|
||||
nbio->status = NBIO_STATUS_INIT;
|
||||
|
||||
if (system)
|
||||
user->stream_type = AUDIO_STREAM_TYPE_SYSTEM;
|
||||
else
|
||||
user->stream_type = AUDIO_STREAM_TYPE_USER;
|
||||
|
||||
t->state = nbio;
|
||||
t->handler = task_file_load_handler;
|
||||
t->cleanup = task_audio_mixer_load_free;
|
||||
t->user_data = user_data;
|
||||
t->user_data = user;
|
||||
|
||||
task_queue_push(t);
|
||||
|
||||
@ -550,6 +590,8 @@ error:
|
||||
nbio_free(nbio->handle);
|
||||
free(nbio);
|
||||
}
|
||||
if (user)
|
||||
free(user);
|
||||
if (t)
|
||||
free(t);
|
||||
|
||||
|
@ -261,10 +261,12 @@ void task_push_get_powerstate(void);
|
||||
enum frontend_powerstate get_last_powerstate(int *percent);
|
||||
|
||||
bool task_push_audio_mixer_load_and_play(
|
||||
const char *fullpath, retro_task_callback_t cb, void *user_data);
|
||||
const char *fullpath, retro_task_callback_t cb, void *user_data,
|
||||
bool system);
|
||||
|
||||
bool task_push_audio_mixer_load(
|
||||
const char *fullpath, retro_task_callback_t cb, void *user_data);
|
||||
const char *fullpath, retro_task_callback_t cb, void *user_data,
|
||||
bool system);
|
||||
|
||||
void set_save_state_in_background(bool state);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user