Пример #1
0
void
playTune (const TuneDefinition *tune) {
  if (tune) {
    int tunePlayed = 0;

    if (prefs.alertTunes && tune->elements) {
      if (openTuneDevice()) {
        const TuneElement *element = tune->elements;

        tunePlayed = 1;
        closeTimer = 2000 / updateInterval;

        while (element->duration) {
          if (!noteMethods->play(noteDevice, element->note, element->duration)) {
            tunePlayed = 0;
            break;
          }

          element += 1;
        }

        noteMethods->flush(noteDevice);
      }
    }

    if (!tunePlayed) {
      if (prefs.alertDots && tune->tactile) {
        unsigned char dots = tune->tactile & 0XFF;
        unsigned char duration = tune->tactile >> 8;
        showDotPattern(dots, duration);
      } else if (prefs.alertMessages && tune->message) {
        message(NULL, gettext(tune->message), 0);
      }
    }
Пример #2
0
static void
handleTuneRequest_playTones (const ToneElement *tune) {
  while (tune->duration) {
    if (!openTuneDevice()) return;
    if (!noteMethods->tone(noteDevice, tune->duration, tune->frequency)) return;
    tune += 1;
  }

  flushNoteDevice();
}