Cleanup Pulseaudio code to allow server select using audio argument

This commit is contained in:
Iwan Timmer
2017-05-10 15:58:32 +02:00
parent 45f9b0554e
commit 4bf3137bfc

View File

@@ -35,19 +35,19 @@ static short pcmBuffer[FRAME_SIZE * MAX_CHANNEL_COUNT];
static int channelCount; static int channelCount;
bool audio_pulse_init() { bool audio_pulse_init() {
pa_sample_spec spec = { pa_sample_spec spec = {
.format = PA_SAMPLE_S16LE, .format = PA_SAMPLE_S16LE,
.rate = 44000, .rate = 44000,
.channels = 2 .channels = 2
}; };
int error; int error;
dev = pa_simple_new(NULL, "Moonlight Embedded", PA_STREAM_PLAYBACK, NULL, "Streaming", &spec, NULL, NULL, &error); dev = pa_simple_new(audio_device, "Moonlight Embedded", PA_STREAM_PLAYBACK, NULL, "Streaming", &spec, NULL, NULL, &error);
if (dev) {
pa_simple_free(dev); if (dev)
return true; pa_simple_free(dev);
} else
return false; return (bool) dev;
} }
static void pulse_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig) { static void pulse_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig) {
@@ -69,12 +69,7 @@ static void pulse_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIG
alsaMapping[5] = opusConfig->mapping[3]; alsaMapping[5] = opusConfig->mapping[3];
} }
decoder = opus_multistream_decoder_create(opusConfig->sampleRate, decoder = opus_multistream_decoder_create(opusConfig->sampleRate, opusConfig->channelCount, opusConfig->streams, opusConfig->coupledStreams, alsaMapping, &rc);
opusConfig->channelCount,
opusConfig->streams,
opusConfig->coupledStreams,
alsaMapping,
&rc);
pa_sample_spec spec = { pa_sample_spec spec = {
.format = PA_SAMPLE_S16LE, .format = PA_SAMPLE_S16LE,
@@ -82,7 +77,7 @@ static void pulse_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIG
.channels = opusConfig->channelCount .channels = opusConfig->channelCount
}; };
dev = pa_simple_new(NULL, "Moonlight Embedded", PA_STREAM_PLAYBACK, NULL, "Streaming", &spec, NULL, NULL, &error); dev = pa_simple_new(audio_device, "Moonlight Embedded", PA_STREAM_PLAYBACK, NULL, "Streaming", &spec, NULL, NULL, &error);
if (!dev) { if (!dev) {
printf("Pulseaudio error: %s\n", pa_strerror(error)); printf("Pulseaudio error: %s\n", pa_strerror(error));