mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-22 08:10:10 +00:00
Check Pulseaudio server availability
This commit is contained in:
@@ -17,6 +17,8 @@
|
|||||||
* along with Moonlight; if not, see <http://www.gnu.org/licenses/>.
|
* along with Moonlight; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "limelight-common/Limelight.h"
|
#include "limelight-common/Limelight.h"
|
||||||
|
|
||||||
extern const char* audio_device;
|
extern const char* audio_device;
|
||||||
@@ -27,4 +29,5 @@ extern AUDIO_RENDERER_CALLBACKS audio_callbacks_sdl;
|
|||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_PULSE
|
#ifdef HAVE_PULSE
|
||||||
extern AUDIO_RENDERER_CALLBACKS audio_callbacks_pulse;
|
extern AUDIO_RENDERER_CALLBACKS audio_callbacks_pulse;
|
||||||
|
bool audio_pulse_init();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -34,6 +34,22 @@ static pa_simple *dev = NULL;
|
|||||||
static short pcmBuffer[FRAME_SIZE * MAX_CHANNEL_COUNT];
|
static short pcmBuffer[FRAME_SIZE * MAX_CHANNEL_COUNT];
|
||||||
static int channelCount;
|
static int channelCount;
|
||||||
|
|
||||||
|
bool audio_pulse_init() {
|
||||||
|
pa_sample_spec spec = {
|
||||||
|
.format = PA_SAMPLE_S16LE,
|
||||||
|
.rate = 44000,
|
||||||
|
.channels = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
int error;
|
||||||
|
dev = pa_simple_new(NULL, "Moonlight Embedded", PA_STREAM_PLAYBACK, NULL, "Streaming", &spec, NULL, NULL, &error);
|
||||||
|
if (dev) {
|
||||||
|
pa_simple_free(dev);
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static void pulse_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig) {
|
static void pulse_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig) {
|
||||||
int rc, error;
|
int rc, error;
|
||||||
unsigned char alsaMapping[6];
|
unsigned char alsaMapping[6];
|
||||||
|
|||||||
@@ -89,7 +89,8 @@ AUDIO_RENDERER_CALLBACKS* platform_get_audio(enum platform system) {
|
|||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
#ifdef HAVE_PULSE
|
#ifdef HAVE_PULSE
|
||||||
return &audio_callbacks_pulse;
|
if (audio_pulse_init())
|
||||||
|
return &audio_callbacks_pulse;
|
||||||
#endif
|
#endif
|
||||||
return &audio_callbacks_alsa;
|
return &audio_callbacks_alsa;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user