o Output a warning if the sound modules is detected.

This commit is contained in:
Henner Zeller 2016-10-14 19:00:57 -07:00
parent 19b3bfb219
commit 5e29e7eeb0
2 changed files with 30 additions and 5 deletions

View file

@ -297,11 +297,14 @@ Troubleshooting
Here are some tips in case things don't work as expected.
### Use minimal Raspbian distribution
In general, run a minimal configuration on your Pi. There were some
unconfirmed reports of problems with Pis running GUI systems. Even though the
Raspberry Pi foundation makes you believe that you can do that: don't. Using it
with a GUI is a frustratingly slow use of an otherwise perfectly good
embedded device.
In general, run a minimal configuration on your Pi.
* Do not use a graphical user interface (Even though the
Raspberry Pi foundation makes you believe that you can do that: don't.
Using a Pi with a GUI is a frustratingly slow use of an otherwise
perfectly good embedded device.)
* Switch off on-board sound (external USB sound adapters work).
Everything seems to work well with a **[Raspbian Lite][raspbian-lite]**
distribution.

View file

@ -214,6 +214,22 @@ private:
const std::vector<int> nano_specs_;
};
static bool LinuxHasModuleLoaded(const char *name) {
FILE *f = fopen("/proc/modules", "r");
if (f == NULL) return false; // don't care.
char buf[256];
const size_t namelen = strlen(name);
bool found = false;
while (fgets(buf, sizeof(buf), f) != NULL) {
if (strncmp(buf, name, namelen) == 0) {
found = true;
break;
}
}
fclose(f);
return found;
}
static volatile uint32_t *timer1Mhz = NULL;
static void sleep_nanos_rpi_1(long nanos);
@ -293,6 +309,12 @@ public:
: triggered_(false) {
assert(CanHandle(pins));
if (LinuxHasModuleLoaded("snd_bcm2835")) {
fprintf(stderr, "\nsnd_bcm2835: found the sound module to be loaded.\n"
"This is known to cause trouble.\n"
"See Troubleshooting section in README how to disable.\n\n");
}
for (size_t i = 0; i < specs.size(); ++i) {
sleep_hints_.push_back(specs[i] / 1000);
}