(Audio mixer) Add MP3 support as well

This commit is contained in:
twinaphex 2018-04-28 14:18:04 +02:00
parent 64f31f1ddd
commit e7272ddefa
7 changed files with 44 additions and 0 deletions

View File

@ -147,6 +147,8 @@ ifneq ($(GIT_VERSION),)
endif
# General object files
DEFINES += -DHAVE_DR_MP3
CFLAGS += -DHAVE_DR_MP3
OBJ += frontend/frontend.o \
frontend/frontend_driver.o \

View File

@ -979,6 +979,9 @@ bool audio_driver_mixer_extension_supported(const char *ext)
#endif
#ifdef HAVE_DR_FLAC
string_list_append(str_list, "flac", attr);
#endif
#ifdef HAVE_DR_MP3
string_list_append(str_list, "mp3", attr);
#endif
string_list_append(str_list, "wav", attr);
@ -1080,6 +1083,11 @@ bool audio_driver_mixer_add_stream(audio_mixer_stream_params_t *params)
case AUDIO_MIXER_TYPE_FLAC:
#ifdef HAVE_DR_FLAC
handle = audio_mixer_load_flac(buf, (int32_t)params->bufsize);
#endif
break;
case AUDIO_MIXER_TYPE_MP3:
#ifdef HAVE_DR_MP3
handle = audio_mixer_load_mp3(buf, (int32_t)params->bufsize);
#endif
break;
case AUDIO_MIXER_TYPE_NONE:

View File

@ -86,6 +86,7 @@ enum file_path_enum
FILE_PATH_ZIP_EXTENSION,
FILE_PATH_7Z_EXTENSION,
FILE_PATH_OGG_EXTENSION,
FILE_PATH_MP3_EXTENSION,
FILE_PATH_FLAC_EXTENSION,
FILE_PATH_WAV_EXTENSION,
FILE_PATH_MOD_EXTENSION,

View File

@ -101,6 +101,9 @@ const char *file_path_str(enum file_path_enum enum_idx)
case FILE_PATH_PNG_EXTENSION:
str = ".png";
break;
case FILE_PATH_MP3_EXTENSION:
str = ".mp3";
break;
case FILE_PATH_FLAC_EXTENSION:
str = ".flac";
break;

View File

@ -124,6 +124,28 @@ static void task_audio_mixer_handle_upload_flac(void *task_data,
free(user_data);
}
static void task_audio_mixer_handle_upload_mp3(void *task_data,
void *user_data, const char *err)
{
audio_mixer_stream_params_t params;
nbio_buf_t *img = (nbio_buf_t*)task_data;
if (!img)
return;
params.volume = 1.0f;
params.type = AUDIO_MIXER_TYPE_MP3;
params.state = AUDIO_STREAM_STATE_PLAYING;
params.buf = img->buf;
params.bufsize = img->bufsize;
params.cb = NULL;
audio_driver_mixer_add_stream(&params);
free(img);
free(user_data);
}
static void task_audio_mixer_handle_upload_mod(void *task_data,
void *user_data, const char *err)
{
@ -238,6 +260,12 @@ bool task_push_audio_mixer_load(const char *fullpath, retro_task_callback_t cb,
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;
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;

View File

@ -103,6 +103,7 @@ void task_file_load_handler(retro_task_t *task)
if (!task_image_load_handler(task))
task_set_finished(task, true);
break;
case NBIO_TYPE_MP3:
case NBIO_TYPE_FLAC:
case NBIO_TYPE_OGG:
case NBIO_TYPE_MOD:

View File

@ -74,6 +74,7 @@ enum nbio_type
NBIO_TYPE_BMP,
NBIO_TYPE_OGG,
NBIO_TYPE_FLAC,
NBIO_TYPE_MP3,
NBIO_TYPE_MOD,
NBIO_TYPE_WAV
};