Use moonlight-common-c definition for max channel count

This commit is contained in:
Cameron Gutman 2021-07-25 13:33:35 -05:00
parent d1937cb8e6
commit 4e09dccfc0
5 changed files with 14 additions and 18 deletions

View File

@ -20,6 +20,8 @@
#include "audio.h"
#include <stdio.h>
#include <string.h>
#include <opus_multistream.h>
#include <alsa/asoundlib.h>
@ -27,26 +29,23 @@
static snd_pcm_t *handle;
static OpusMSDecoder* decoder;
static short pcmBuffer[FRAME_SIZE * MAX_CHANNEL_COUNT];
static short pcmBuffer[FRAME_SIZE * AUDIO_CONFIGURATION_MAX_CHANNEL_COUNT];
static int alsa_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig, void* context, int arFlags) {
int rc;
unsigned char alsaMapping[MAX_CHANNEL_COUNT];
unsigned char alsaMapping[AUDIO_CONFIGURATION_MAX_CHANNEL_COUNT];
/* The supplied mapping array has order: FL-FR-C-LFE-RL-RR-SL-SR
* ALSA expects the order: FL-FR-RL-RR-C-LFE-SL-SR
* We need copy the mapping locally and swap the channels around.
*/
alsaMapping[0] = opusConfig->mapping[0];
alsaMapping[1] = opusConfig->mapping[1];
memcpy(alsaMapping, opusConfig->mapping, sizeof(alsaMapping));
if (opusConfig->channelCount >= 6) {
alsaMapping[2] = opusConfig->mapping[4];
alsaMapping[3] = opusConfig->mapping[5];
alsaMapping[4] = opusConfig->mapping[2];
alsaMapping[5] = opusConfig->mapping[3];
}
alsaMapping[6] = opusConfig->mapping[6];
alsaMapping[7] = opusConfig->mapping[7];
decoder = opus_multistream_decoder_create(opusConfig->sampleRate, opusConfig->channelCount, opusConfig->streams, opusConfig->coupledStreams, alsaMapping, &rc);

View File

@ -21,7 +21,6 @@
#include <Limelight.h>
#define MAX_CHANNEL_COUNT 8
#define FRAME_SIZE 240
#define FRAME_BUFFER 12

View File

@ -29,18 +29,18 @@ static OpusMSDecoder* decoder;
ILCLIENT_T* handle;
COMPONENT_T* component;
static OMX_BUFFERHEADERTYPE *buf;
static short pcmBuffer[FRAME_SIZE * MAX_CHANNEL_COUNT];
static short pcmBuffer[FRAME_SIZE * AUDIO_CONFIGURATION_MAX_CHANNEL_COUNT];
static int channelCount;
static int omx_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig, void* context, int arFlags) {
int rc, error;
OMX_ERRORTYPE err;
unsigned char omxMapping[MAX_CHANNEL_COUNT];
unsigned char omxMapping[AUDIO_CONFIGURATION_MAX_CHANNEL_COUNT];
char* componentName = "audio_render";
channelCount = opusConfig->channelCount;
/* The supplied mapping array has order: FL-FR-C-LFE-RL-RR
* OMX expects the order: FL-FR-LFE-C-RL-RR
/* The supplied mapping array has order: FL-FR-C-LFE-RL-RR-SL-SR
* OMX expects the order: FL-FR-LFE-C-RL-RR-SL-SR
* We need copy the mapping locally and swap the channels around.
*/
memcpy(omxMapping, opusConfig->mapping, sizeof(omxMapping));

View File

@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <opus_multistream.h>
#include <pulse/simple.h>
@ -28,7 +29,7 @@
static OpusMSDecoder* decoder;
static pa_simple *dev = NULL;
static short pcmBuffer[FRAME_SIZE * MAX_CHANNEL_COUNT];
static short pcmBuffer[FRAME_SIZE * AUDIO_CONFIGURATION_MAX_CHANNEL_COUNT];
static int channelCount;
bool audio_pulse_init(char* audio_device) {
@ -49,7 +50,7 @@ bool audio_pulse_init(char* audio_device) {
static int pulse_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig, void* context, int arFlags) {
int rc, error;
unsigned char alsaMapping[MAX_CHANNEL_COUNT];
unsigned char alsaMapping[AUDIO_CONFIGURATION_MAX_CHANNEL_COUNT];
channelCount = opusConfig->channelCount;
@ -57,16 +58,13 @@ static int pulse_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGU
* ALSA expects the order: FL-FR-RL-RR-C-LFE-SL-SR
* We need copy the mapping locally and swap the channels around.
*/
alsaMapping[0] = opusConfig->mapping[0];
alsaMapping[1] = opusConfig->mapping[1];
memcpy(alsaMapping, opusConfig->mapping, sizeof(alsaMapping));
if (opusConfig->channelCount >= 6) {
alsaMapping[2] = opusConfig->mapping[4];
alsaMapping[3] = opusConfig->mapping[5];
alsaMapping[4] = opusConfig->mapping[2];
alsaMapping[5] = opusConfig->mapping[3];
}
alsaMapping[6] = opusConfig->mapping[6];
alsaMapping[7] = opusConfig->mapping[7];
decoder = opus_multistream_decoder_create(opusConfig->sampleRate, opusConfig->channelCount, opusConfig->streams, opusConfig->coupledStreams, alsaMapping, &rc);

View File

@ -26,7 +26,7 @@
#include <opus_multistream.h>
static OpusMSDecoder* decoder;
static short pcmBuffer[FRAME_SIZE * MAX_CHANNEL_COUNT];
static short pcmBuffer[FRAME_SIZE * AUDIO_CONFIGURATION_MAX_CHANNEL_COUNT];
static SDL_AudioDeviceID dev;
static int channelCount;