From 68e18a20671da36fc3370ad087557f6f51b67604 Mon Sep 17 00:00:00 2001 From: Iwan Timmer Date: Fri, 25 Mar 2016 11:12:20 +0100 Subject: [PATCH] Default to corect audio device on Raspberry Pi --- docs/README.pod | 2 +- src/audio/alsa.c | 5 ++++- src/audio/omx.c | 5 ++++- src/config.c | 4 ++-- src/main.c | 4 ++-- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/docs/README.pod b/docs/README.pod index 4f94385..16e0a5a 100644 --- a/docs/README.pod +++ b/docs/README.pod @@ -137,7 +137,7 @@ To use a different gamepad mapping then the default the B<-mapping> should be sp =item B<-audio> [I] Use as audio output device. -The default value is 'sysdefault' +The default value is 'sysdefault' for ALSA and 'hdmi' for OMX on the Raspberry Pi. =back diff --git a/src/audio/alsa.c b/src/audio/alsa.c index 2815375..273ce82 100644 --- a/src/audio/alsa.c +++ b/src/audio/alsa.c @@ -1,7 +1,7 @@ /* * This file is part of Moonlight Embedded. * - * Copyright (C) 2015 Iwan Timmer + * Copyright (C) 2015, 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 @@ -62,6 +62,9 @@ static void alsa_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGU snd_pcm_uframes_t buffer_size = 12 * period_size; unsigned int sampleRate = opusConfig->sampleRate; + if (audio_device == NULL) + audio_device = "sysdefault"; + /* Open PCM device for playback. */ CHECK_RETURN(snd_pcm_open(&handle, audio_device, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)) diff --git a/src/audio/omx.c b/src/audio/omx.c index b5ae4bd..bf8f7d3 100644 --- a/src/audio/omx.c +++ b/src/audio/omx.c @@ -1,7 +1,7 @@ /* * This file is part of Moonlight Embedded. * - * Copyright (C) 2015 Iwan Timmer + * Copyright (C) 2015, 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 @@ -131,6 +131,9 @@ static void omx_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGUR } OMX_CONFIG_BRCMAUDIODESTINATIONTYPE arDest; + if (audio_device == NULL) + audio_device = "hdmi"; + if (audio_device && strlen(audio_device) < sizeof(arDest.sName)) { memset(&arDest, 0, sizeof(OMX_CONFIG_BRCMAUDIODESTINATIONTYPE)); arDest.nSize = sizeof(OMX_CONFIG_BRCMAUDIODESTINATIONTYPE); diff --git a/src/config.c b/src/config.c index fa65fd8..2f660cb 100644 --- a/src/config.c +++ b/src/config.c @@ -1,7 +1,7 @@ /* * This file is part of Moonlight Embedded. * - * Copyright (C) 2015 Iwan Timmer + * Copyright (C) 2015, 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 @@ -38,7 +38,7 @@ bool inputAdded = false; static bool mapped = true; -const char* audio_device = "sysdefault"; +const char* audio_device = NULL; static struct option long_options[] = { {"720", no_argument, NULL, 'a'}, diff --git a/src/main.c b/src/main.c index 0314496..e1a5213 100644 --- a/src/main.c +++ b/src/main.c @@ -1,7 +1,7 @@ /* * This file is part of Moonlight Embedded. * - * Copyright (C) 2015 Iwan Timmer + * Copyright (C) 2015, 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 @@ -152,7 +152,7 @@ static void help() { printf("\n I/O options\n\n"); printf("\t-mapping \t\tUse as gamepad mapping configuration file (use before -input)\n"); printf("\t-input \t\tUse as input. Can be used multiple times\n"); - printf("\t-audio \t\tUse as audio output device (default sysdefault)\n"); + printf("\t-audio \t\tUse as audio output device\n"); printf("\t-forcehw \t\tTry to use video hardware acceleration\n"); #endif printf("\nUse Ctrl+Alt+Shift+Q to exit streaming session\n\n");