Source file: /~heha/basteln/Haus/Telefon/Sprachausgabe.zip/AudioStatus.h

/*
  AudioStatus
  Base class for Audio* status/metadata reporting
  
  Copyright (C) 2017  Earle F. Philhower, III
*/

#pragma once

class AudioStatus
{
  public:
    AudioStatus() { ClearCBs(); };

    void ClearCBs() { mdFn=0; stFn=0; };

    typedef void (*metadataCBFn)(void *cbData, const char *type, bool isUnicode, const char *str);
    bool RegisterMetadataCB(metadataCBFn f, void *cbData) { mdFn = f; mdData = cbData; return true; }

    // Returns a unique warning/error code, varying by the object.  The string may be a PSTR, use _P functions!
    typedef void (*statusCBFn)(void *cbData, int code, const char *string);
    bool RegisterStatusCB(statusCBFn f, void *cbData) { stFn = f; stData = cbData; return true; }

    // Safely call the md function, if defined
    inline void md(const char *type, bool isUnicode, const char *string) { if (mdFn) mdFn(mdData, type, isUnicode, string); }

    // Safely call the st function, if defined
    inline void st(int code, const char *string) { if (stFn) stFn(stData, code, string); }

  private:
    metadataCBFn mdFn;
    void *mdData;
    statusCBFn stFn;
    void *stData;
};

Detected encoding: ASCII (7 bit)2