/*
 * Copyright 1988, 1989, 1990, 1991 Massachusetts Institute of Technology
 */
#include"xpointer.h"
#include<stdio.h>
#include"../../Glib/Glib.h"

error_handler(serv, error_code)
     Server *serv;
     int error_code;
{
  extern short DEBUG;
  extern Display *dpy;
  extern int max_volumes, cur_volume, l_cur_volume, 
  v_cur_volume, r_cur_volume;
  extern Window *volume_windows;

  int i;

  if (DEBUG) printf("Error code = %d\n",error_code);

  if (error_code == VOLUME_LIST_OLD) {
    for (i = 0; i < GNumberVolumes(serv); i++)
      XUnmapWindow(dpy, volume_windows[i]);
    
    GReopenServer(serv);
    
    for (i = 0; i < GNumberVolumes(serv); i++) {
      if (i >=  max_volumes) {
	max_volumes *= 2;
	volume_windows = (Window *)realloc(volume_windows, 
					   max_volumes * sizeof(Window));
	create_volume_window(i);
      }
      XMapWindow(dpy, volume_windows[i]);
    }
    cur_volume = l_cur_volume = v_cur_volume = r_cur_volume = 0;
    GSwitch(serv, GVolumeIndex(serv, 0), ALL_CHAN);
    GRelease(serv);
    draw_active();
    set_cur_vol();
  }
}
