mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2025-07-03 00:06:06 +00:00
Move audio code to seperate directory
This commit is contained in:
parent
f167c6febb
commit
2ba4840569
@ -40,6 +40,8 @@ if (AVCODEC_FOUND AND AVUTIL_FOUND AND SWSCALE_FOUND AND SDL_FOUND)
|
||||
list(APPEND MOONLIGHT_DEFINITIONS HAVE_SDL)
|
||||
endif()
|
||||
|
||||
list(APPEND SRC_LIST ./src/audio/alsa.c)
|
||||
|
||||
add_subdirectory(libgamestream)
|
||||
|
||||
add_executable(moonlight ${SRC_LIST})
|
||||
|
@ -21,4 +21,4 @@
|
||||
|
||||
extern const char* audio_device;
|
||||
|
||||
extern AUDIO_RENDERER_CALLBACKS audio_callbacks;
|
||||
extern AUDIO_RENDERER_CALLBACKS audio_callbacks_alsa;
|
||||
|
@ -17,7 +17,7 @@
|
||||
* along with Moonlight; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "audio.h"
|
||||
#include "../audio.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <opus.h>
|
||||
@ -35,7 +35,7 @@ static snd_pcm_t *handle;
|
||||
static OpusDecoder* decoder;
|
||||
static short pcmBuffer[FRAME_SIZE * CHANNEL_COUNT];
|
||||
|
||||
static void audio_renderer_init() {
|
||||
static void alsa_renderer_init() {
|
||||
int rc;
|
||||
decoder = opus_decoder_create(SAMPLE_RATE, CHANNEL_COUNT, &rc);
|
||||
|
||||
@ -71,7 +71,7 @@ static void audio_renderer_init() {
|
||||
CHECK_RETURN(snd_pcm_prepare(handle));
|
||||
}
|
||||
|
||||
static void audio_renderer_cleanup() {
|
||||
static void alsa_renderer_cleanup() {
|
||||
if (decoder != NULL)
|
||||
opus_decoder_destroy(decoder);
|
||||
|
||||
@ -81,7 +81,7 @@ static void audio_renderer_cleanup() {
|
||||
}
|
||||
}
|
||||
|
||||
static void audio_renderer_decode_and_play_sample(char* data, int length) {
|
||||
static void alsa_renderer_decode_and_play_sample(char* data, int length) {
|
||||
int decodeLen = opus_decode(decoder, data, length, pcmBuffer, FRAME_SIZE, 0);
|
||||
if (decodeLen > 0) {
|
||||
int rc = snd_pcm_writei(handle, pcmBuffer, decodeLen);
|
||||
@ -97,8 +97,8 @@ static void audio_renderer_decode_and_play_sample(char* data, int length) {
|
||||
}
|
||||
}
|
||||
|
||||
AUDIO_RENDERER_CALLBACKS audio_callbacks = {
|
||||
.init = audio_renderer_init,
|
||||
.cleanup = audio_renderer_cleanup,
|
||||
.decodeAndPlaySample = audio_renderer_decode_and_play_sample,
|
||||
AUDIO_RENDERER_CALLBACKS audio_callbacks_alsa = {
|
||||
.init = alsa_renderer_init,
|
||||
.cleanup = alsa_renderer_cleanup,
|
||||
.decodeAndPlaySample = alsa_renderer_decode_and_play_sample,
|
||||
};
|
@ -72,7 +72,7 @@ static void stream(STREAM_CONFIGURATION* config, const char* address, const char
|
||||
|
||||
client_start_app(config, address, appId, sops, localaudio);
|
||||
|
||||
LiStartConnection(address, config, &connection_callbacks, platform_get_video(system), &audio_callbacks, NULL, NULL, 0, client_get_server_version());
|
||||
LiStartConnection(address, config, &connection_callbacks, platform_get_video(system), platform_get_audio(system), NULL, NULL, 0, client_get_server_version());
|
||||
|
||||
if (IS_EMBEDDED(system))
|
||||
loop_main();
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "platform.h"
|
||||
#include "video.h"
|
||||
#include "audio.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
@ -68,3 +69,10 @@ DECODER_RENDERER_CALLBACKS* platform_get_video(enum platform system) {
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
AUDIO_RENDERER_CALLBACKS* platform_get_audio(enum platform system) {
|
||||
switch (system) {
|
||||
default:
|
||||
return &audio_callbacks_alsa;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user