home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pyth_os2.zip / python-1.0.2 / Demo / sgi / dal / dalxdr.py < prev   
Text File  |  1993-03-01  |  2KB  |  76 lines

  1. # Packer and Unpacker extensions for Distributed Audio Library (DAL)
  2.  
  3. import rpc
  4.  
  5. class DALPacker(rpc.Packer):
  6.     def pack_openport(self, arg):
  7.         name, mode, config = arg
  8.         self.pack_string(name)
  9.         self.pack_string(mode)
  10.         self.pack_config(config)
  11.     def pack_setconfig(self, arg):
  12.         i, config = arg
  13.         self.pack_int(i)
  14.         self.pack_config(config)
  15.     def pack_config(self, arg):
  16.         queuesize, width, channels, sampfmt, floatmax = arg
  17.         self.pack_int(queuesize)
  18.         self.pack_int(width)
  19.         self.pack_int(channels)
  20.         self.pack_int(sampfmt)
  21.         self.pack_float(floatmax)
  22.     def pack_readsamps(self, arg):
  23.         i, n = arg
  24.         self.pack_int(i)
  25.         self.pack_int(n)
  26.     def pack_writesamps(self, arg):
  27.         i, buffer = arg
  28.         self.pack_int(i)
  29.         self.pack_string(buffer)
  30.     def pack_int_int(self, arg):
  31.         i1, i2 = arg
  32.         self.pack_int(i1)
  33.         self.pack_int(i2)
  34.     def pack_int_params(self, arg):
  35.         i, params = arg
  36.         self.pack_int(i)
  37.         self.pack_params(params)
  38.     def pack_params(self, params):
  39.         self.pack_list(params, self.pack_int)
  40.  
  41. class DALUnpacker(rpc.Unpacker):
  42.     def unpack_openport(self):
  43.         name = self.unpack_string()
  44.         mode = self.unpack_string()
  45.         config = self.unpack_config()
  46.         return name, mode, config
  47.     def unpack_setconfig(self):
  48.         i = self.unpack_int()
  49.         config = self.unpack_config()
  50.         return i, config
  51.     def unpack_config(self):
  52.         queuesize = self.unpack_int()
  53.         width = self.unpack_int()
  54.         channels = self.unpack_int()
  55.         sampfmt = self.unpack_int()
  56.         floatmax = self.unpack_float()
  57.         return queuesize, width, channels, sampfmt, floatmax
  58.     def unpack_readsamps(self):
  59.         i = self.unpack_int()
  60.         n = self.unpack_int()
  61.         return i, n
  62.     def unpack_writesamps(self):
  63.         i = self.unpack_int()
  64.         buffer = self.unpack_string()
  65.         return i, buffer
  66.     def unpack_int_int(self):
  67.         i1 = self.unpack_int()
  68.         i2 = self.unpack_int()
  69.         return i1, i2
  70.     def unpack_int_params(self):
  71.         i = self.unpack_int()
  72.         params = self.unpack_params()
  73.         return i, params
  74.     def unpack_params(self):
  75.         return self.unpack_list(self.unpack_int)
  76.