Enable audio encryption unless on a slow CPU

This commit is contained in:
Cameron Gutman 2021-07-24 16:22:48 -05:00
parent b907c4b608
commit 30464979dc
3 changed files with 28 additions and 0 deletions

View File

@ -18,6 +18,7 @@
*/
#include "config.h"
#include "util.h"
#include "input/evdev.h"
#include "audio/audio.h"
@ -328,6 +329,20 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) {
config->stream.streamingRemotely = STREAM_CFG_AUTO;
config->stream.audioConfiguration = AUDIO_CONFIGURATION_STEREO;
config->stream.supportsHevc = false;
config->stream.encryptionFlags = ENCFLG_AUDIO;
#ifdef __arm__
char cpuinfo[4096] = {};
if (read_file("/proc/cpuinfo", cpuinfo, sizeof(cpuinfo)) > 0) {
// If this is a ARMv6 CPU (like the Pi 1), we'll assume it's not
// powerful enough to handle audio encryption. The Pi 1 could
// barely handle Opus decoding alone.
if (strstr(cpuinfo, "ARMv6")) {
config->stream.encryptionFlags = ENCFLG_NONE;
printf("Disabling audio encryption on low performance CPU\n");
}
}
#endif
config->debug_level = 0;
config->platform = "auto";

View File

@ -38,3 +38,15 @@ int blank_fb(char *path, bool clear) {
} else
return -1;
}
int read_file(char *path, char* output, int output_len) {
int fd = open(path, O_RDONLY);
if(fd >= 0) {
output_len = read(fd, output, output_len);
close(fd);
return output_len;
} else
return -1;
}

View File

@ -20,3 +20,4 @@
#include <stdbool.h>
int blank_fb(char *path, bool clear);
int read_file(char *path, char *output, int output_len);