mirror of
https://github.com/libretro/RetroArch
synced 2025-03-01 07:13:35 +00:00
Attempt to copy over audio mixer data
This commit is contained in:
parent
ba5f7ff5e4
commit
c898ef1d6d
@ -45,37 +45,6 @@
|
||||
#define AUDIO_MIXER_MAX_VOICES 8
|
||||
#define AUDIO_MIXER_TEMP_OGG_BUFFER 8192
|
||||
|
||||
enum audio_mixer_type
|
||||
{
|
||||
AUDIO_MIXER_TYPE_NONE = 0,
|
||||
AUDIO_MIXER_TYPE_WAV,
|
||||
AUDIO_MIXER_TYPE_OGG
|
||||
};
|
||||
|
||||
struct audio_mixer_sound
|
||||
{
|
||||
enum audio_mixer_type type;
|
||||
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
/* wav */
|
||||
unsigned frames;
|
||||
const float* pcm;
|
||||
} wav;
|
||||
|
||||
#ifdef HAVE_STB_VORBIS
|
||||
struct
|
||||
{
|
||||
/* ogg */
|
||||
unsigned size;
|
||||
const void* data;
|
||||
} ogg;
|
||||
#endif
|
||||
} types;
|
||||
};
|
||||
|
||||
struct audio_mixer_voice
|
||||
{
|
||||
bool repeat;
|
||||
|
@ -27,11 +27,46 @@
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <boolean.h>
|
||||
#include <retro_common_api.h>
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
enum audio_mixer_type
|
||||
{
|
||||
AUDIO_MIXER_TYPE_NONE = 0,
|
||||
AUDIO_MIXER_TYPE_WAV,
|
||||
AUDIO_MIXER_TYPE_OGG
|
||||
};
|
||||
|
||||
struct audio_mixer_sound
|
||||
{
|
||||
enum audio_mixer_type type;
|
||||
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
/* wav */
|
||||
unsigned frames;
|
||||
const float* pcm;
|
||||
} wav;
|
||||
|
||||
#ifdef HAVE_STB_VORBIS
|
||||
struct
|
||||
{
|
||||
/* ogg */
|
||||
unsigned size;
|
||||
const void* data;
|
||||
} ogg;
|
||||
#endif
|
||||
} types;
|
||||
};
|
||||
|
||||
typedef struct audio_mixer_sound audio_mixer_sound_t;
|
||||
typedef struct audio_mixer_voice audio_mixer_voice_t;
|
||||
|
||||
|
@ -39,6 +39,7 @@
|
||||
|
||||
#include <compat/strl.h>
|
||||
#include <compat/getopt.h>
|
||||
#include <audio/audio_mixer.h>
|
||||
#include <compat/posix_string.h>
|
||||
#include <file/file_path.h>
|
||||
#include <retro_stat.h>
|
||||
@ -2261,7 +2262,11 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
|
||||
static void runloop_upload_audio(void *task_data,
|
||||
void *user_data, const char *err)
|
||||
{
|
||||
RARCH_LOG("GETS HERE.\n");
|
||||
audio_mixer_sound_t *handle = (audio_mixer_sound_t*)task_data;
|
||||
|
||||
if (handle)
|
||||
audio_mixer_play(handle, true, 1.0f, NULL);
|
||||
|
||||
free(user_data);
|
||||
}
|
||||
#endif
|
||||
|
@ -32,8 +32,8 @@
|
||||
|
||||
struct nbio_audio_mixer_handle
|
||||
{
|
||||
audio_mixer_sound_t *handle;
|
||||
bool is_finished;
|
||||
void *handle;
|
||||
};
|
||||
|
||||
static void task_audio_mixer_cleanup(nbio_handle_t *nbio)
|
||||
@ -64,20 +64,16 @@ static int cb_nbio_audio_wav_loaded(void *data, size_t len)
|
||||
struct nbio_audio_mixer_handle *image = nbio ?
|
||||
(struct nbio_audio_mixer_handle*)nbio->data : NULL;
|
||||
void *ptr = nbio_get_ptr(nbio->handle, &len);
|
||||
audio_mixer_sound_t *audmix = audio_mixer_load_wav(ptr, len);
|
||||
|
||||
if (!audmix ||
|
||||
!audio_mixer_play(audmix, true, 0.0f, NULL)
|
||||
)
|
||||
image->handle = audio_mixer_load_wav(ptr, len);
|
||||
|
||||
if (!image->handle)
|
||||
{
|
||||
task_audio_mixer_cleanup(nbio);
|
||||
return -1;
|
||||
}
|
||||
|
||||
free(ptr);
|
||||
|
||||
image->is_finished = true;
|
||||
nbio->is_finished = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -90,18 +86,16 @@ static int cb_nbio_audio_ogg_loaded(void *data, size_t len)
|
||||
(struct nbio_audio_mixer_handle*)nbio->data : NULL;
|
||||
|
||||
void *ptr = nbio_get_ptr(nbio->handle, &len);
|
||||
audio_mixer_sound_t *audmix = audio_mixer_load_ogg(ptr, len);
|
||||
|
||||
if (!audmix ||
|
||||
!audio_mixer_play(audmix, true, 0.0f, NULL)
|
||||
)
|
||||
image->handle = audio_mixer_load_ogg(ptr, len);
|
||||
|
||||
if (!image->handle)
|
||||
{
|
||||
task_audio_mixer_cleanup(nbio);
|
||||
return -1;
|
||||
}
|
||||
|
||||
image->is_finished = true;
|
||||
nbio->is_finished = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -112,10 +106,22 @@ bool task_audio_mixer_load_handler(retro_task_t *task)
|
||||
nbio_handle_t *nbio = (nbio_handle_t*)task->state;
|
||||
struct nbio_audio_mixer_handle *image = (struct nbio_audio_mixer_handle*)nbio->data;
|
||||
|
||||
if ( nbio->is_finished
|
||||
&& (image && image->is_finished )
|
||||
if (
|
||||
(image && image->is_finished )
|
||||
&& (!task_get_cancelled(task)))
|
||||
{
|
||||
audio_mixer_sound_t *data = (audio_mixer_sound_t*)calloc(1, sizeof(*data));
|
||||
|
||||
if (data)
|
||||
{
|
||||
memcpy((void*)data, &image->handle, sizeof(audio_mixer_sound_t));
|
||||
}
|
||||
|
||||
task_set_data(task, data);
|
||||
|
||||
nbio->is_finished = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user