(Audio mixer) Add FLAC support to audio mixer

This commit is contained in:
twinaphex 2018-04-28 11:17:37 +02:00
parent faa99bd323
commit 3f7c318e3f
6 changed files with 34 additions and 2 deletions

View File

@ -1437,10 +1437,8 @@ endif
ifeq ($(HAVE_BUILTINFLAC),1)
HAVE_FLAC = 1
ifneq ($(C89_BUILD), 1)
DEFINES += -DHAVE_DR_FLAC -I$(DEPS_DIR)
CFLAGS += -DHAVE_DR_FLAC
endif
CFLAGS += -DHAVE_FLAC -I$(DEPS_DIR)/libFLAC/include
DEFINES += -DHAVE_STDINT_H -DHAVE_LROUND -DFLAC__HAS_OGG=0 \
-DFLAC_PACKAGE_VERSION="\"retroarch\""

View File

@ -86,6 +86,7 @@ enum file_path_enum
FILE_PATH_ZIP_EXTENSION,
FILE_PATH_7Z_EXTENSION,
FILE_PATH_OGG_EXTENSION,
FILE_PATH_FLAC_EXTENSION,
FILE_PATH_WAV_EXTENSION,
FILE_PATH_MOD_EXTENSION,
FILE_PATH_S3M_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_FLAC_EXTENSION:
str = ".flac";
break;
case FILE_PATH_OGG_EXTENSION:
str = ".ogg";
break;

View File

@ -102,6 +102,28 @@ static void task_audio_mixer_handle_upload_ogg(void *task_data,
free(user_data);
}
static void task_audio_mixer_handle_upload_flac(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_FLAC;
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)
{
@ -216,6 +238,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_FLAC_EXTENSION)))
{
image->type = AUDIO_MIXER_TYPE_FLAC;
nbio->type = NBIO_TYPE_FLAC;
t->callback = task_audio_mixer_handle_upload_flac;
}
else if ( strstr(fullpath, file_path_str(FILE_PATH_MOD_EXTENSION)) ||
strstr(fullpath, file_path_str(FILE_PATH_S3M_EXTENSION)) ||
strstr(fullpath, file_path_str(FILE_PATH_XM_EXTENSION)))

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_FLAC:
case NBIO_TYPE_OGG:
case NBIO_TYPE_MOD:
case NBIO_TYPE_WAV:

View File

@ -73,6 +73,7 @@ enum nbio_type
NBIO_TYPE_TGA,
NBIO_TYPE_BMP,
NBIO_TYPE_OGG,
NBIO_TYPE_FLAC,
NBIO_TYPE_MOD,
NBIO_TYPE_WAV
};