From 5e29e7eeb0ade2b07ca0c702b823b266dfbf705a Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Fri, 14 Oct 2016 19:00:57 -0700 Subject: [PATCH] o Output a warning if the sound modules is detected. --- README.md | 13 ++++++++----- lib/gpio.cc | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a2a0b58..e66ac22 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/lib/gpio.cc b/lib/gpio.cc index 9c0c0cb..3f11542 100644 --- a/lib/gpio.cc +++ b/lib/gpio.cc @@ -214,6 +214,22 @@ private: const std::vector 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); }