/*
 * hifi.c:
 *
 * Copyright (c) 2000 James McKenzie <james@fishsoup.dhs.org>,
 * All rights reserved.
 *
 */

static char rcsid[] = "$Id: hifi.c,v 1.2 2000/10/06 19:52:46 root Exp $";

/*
 * $Log: hifi.c,v $
 * Revision 1.2  2000/10/06 19:52:46  root
 * #
 *
 * Revision 1.1  2000/10/06 06:21:36  root
 * #
 *
 */

#include "project.h"

void
hifi_valid_cmd (Byte sclass, Byte sunit, Byte dclass, Byte dunit, Word cmd,
                Byte * data, Word len)
{

  if ((dclass != HIFI_CLASS_DISPLAY) && (dclass != HIFI_CLASS_ALL))
    return;
  if ((dunit != clientunit) && (dunit != HIFI_UNIT_ALL))
    return;

  switch (sclass)
    {
    case HIFI_CLASS_TUNER:
      tuner_cmdst (sclass, sunit, cmd, data, len);
      system_cmdst (sclass, sunit, cmd, data, len);
      break;
    case HIFI_CLASS_CD:
      cd_cmdst (sclass, sunit, cmd, data, len);
      system_cmdst (sclass, sunit, cmd, data, len);
      break;
    case HIFI_CLASS_MPEG:
      mpeg_cmdst (sclass, sunit, cmd, data, len);
      system_cmdst (sclass, sunit, cmd, data, len);
      break;
    case HIFI_CLASS_WAVE:
      wave_cmdst (sclass, sunit, cmd, data, len);
      system_cmdst (sclass, sunit, cmd, data, len);
      break;
    case HIFI_CLASS_OGG:
      ogg_cmdst (sclass, sunit, cmd, data, len);
      system_cmdst (sclass, sunit, cmd, data, len);
      break;
    case HIFI_CLASS_SYSTEM:
      system_cmdst (sclass, sunit, cmd, data, len);
      break;
    case HIFI_CLASS_CLOCK:
      clock_cmdst (sclass, sunit, cmd, data, len);
      break;
    }

}

void
hifi_dispatch ()
{
  extern void *msglib;

  Byte buf[1024];
  int len;
  int i;

  Word w, l;
  Byte class, unit, d;


  len = hifimsg_recv (msglib, buf, sizeof (buf));
  if (len <= 0)
    return;


  hifi_new_packet (msglib, buf, len, hifi_valid_cmd);

}
