Always include fake output but never choose it by default

This commit is contained in:
Iwan Timmer 2016-04-08 14:06:22 +02:00
parent e9811d8505
commit 870901784e
4 changed files with 52 additions and 11 deletions

View File

@ -45,9 +45,8 @@ SET(MOONLIGHT_COMMON_INCLUDE_DIR ./third_party/moonlight-common-c/src)
SET(GAMESTREAM_INCLUDE_DIR ./libgamestream)
if(CMAKE_BUILD_TYPE MATCHES Debug)
list(APPEND SRC_LIST ./src/video/fake.c)
list(APPEND MOONLIGHT_DEFINITIONS HAVE_FAKE LC_DEBUG)
list(APPEND MOONLIGHT_OPTIONS FAKE DEBUG)
list(APPEND MOONLIGHT_DEFINITIONS LC_DEBUG)
list(APPEND MOONLIGHT_OPTIONS DEBUG)
elseif(NOT AMLOGIC_FOUND AND NOT BROADCOM_FOUND AND NOT FREESCALE_FOUND AND NOT SOFTWARE_FOUND)
message(FATAL_ERROR "No video output available")
endif()
@ -76,7 +75,7 @@ endif()
include_directories("${PROJECT_BINARY_DIR}")
list(APPEND SRC_LIST ./src/audio/alsa.c)
list(APPEND SRC_LIST ./src/audio/alsa.c ./src/audio/fake.c ./src/video/fake.c)
add_subdirectory(libgamestream)

44
src/audio/fake.c Normal file
View File

@ -0,0 +1,44 @@
/*
* This file is part of Moonlight Embedded.
*
* Copyright (C) 2016 Iwan Timmer
*
* Moonlight is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Moonlight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Moonlight; if not, see <http://www.gnu.org/licenses/>.
*/
#include "../audio.h"
#include <stdio.h>
static FILE* fd;
static const char* fileName = "fake.opus";
static void alsa_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig) {
fd = fopen(fileName, "w");
}
static void alsa_renderer_cleanup() {
fclose(fd);
}
static void alsa_renderer_decode_and_play_sample(char* data, int length) {
fwrite(data, length, 1, fd);
}
AUDIO_RENDERER_CALLBACKS audio_callbacks_fake = {
.init = alsa_renderer_init,
.cleanup = alsa_renderer_cleanup,
.decodeAndPlaySample = alsa_renderer_decode_and_play_sample,
.capabilities = CAPABILITY_DIRECT_SUBMIT,
};

View File

@ -59,10 +59,9 @@ enum platform platform_check(char* name) {
if (std || strcmp(name, "sdl") == 0)
return SDL;
#endif
#ifdef HAVE_FAKE
if (std || strcmp(name, "fake") == 0)
if (strcmp(name, "fake") == 0)
return FAKE;
#endif
return 0;
}
@ -84,10 +83,8 @@ DECODER_RENDERER_CALLBACKS* platform_get_video(enum platform system) {
case AML:
return (PDECODER_RENDERER_CALLBACKS) dlsym(RTLD_DEFAULT, "decoder_callbacks_aml");
#endif
#ifdef HAVE_FAKE
case FAKE:
return &decoder_callbacks_fake;
#endif
}
return NULL;
}
@ -109,6 +106,8 @@ AUDIO_RENDERER_CALLBACKS* platform_get_audio(enum platform system) {
return &audio_callbacks_pulse;
#endif
return &audio_callbacks_alsa;
case FAKE:
return &audio_callbacks_fake;
}
return NULL;
}

View File

@ -33,9 +33,8 @@ PDECODER_RENDERER_CALLBACKS platform_get_video(enum platform system);
PAUDIO_RENDERER_CALLBACKS platform_get_audio(enum platform system);
bool platform_supports_hevc(enum platform system);
#ifdef HAVE_FAKE
extern DECODER_RENDERER_CALLBACKS decoder_callbacks_fake;
#endif
extern AUDIO_RENDERER_CALLBACKS audio_callbacks_fake;
#ifdef HAVE_SDL
extern DECODER_RENDERER_CALLBACKS decoder_callbacks_sdl;
void sdl_loop();