#!/usr/bin/env python
#==============================================================================
#
#  $Id: esdinfo,v 1.1.1.1 1999/07/23 16:07:44 mike Exp $
#
"""
   Program to print all of the server information.
"""
#
#  Copyright (C) 1999 Michael A. Muller
#
#  Permission is granted to use, modify and redistribute this code,
#  providing that the following conditions are met:
#
#  1) This copyright/licensing notice must remain intact.
#  2) If the code is modified and redistributed, the modifications must 
#  include documentation indicating that the code has been modified.
#  3) The author(s) of this code must be indemnified and held harmless
#  against any damage resulting from the use of this code.
#
#  This code comes with ABSOLUTELY NO WARRANTEE, not even the implied 
#  warrantee of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
#
#  $Log: esdinfo,v $
#  Revision 1.1.1.1  1999/07/23 16:07:44  mike
#  Python EsounD wrapper
#
#
#==============================================================================

import string
import esd

def formatAsString(fmt):
   items = []
   
   if fmt & esd.ESD_PLAY:
      items.append('playable')
   
   if fmt & esd.ESD_STEREO:
      items.append('stereo')
   elif fmt & esd.ESD_MONO:
      items.append('mono')
   
   if fmt & esd.ESD_BITS16:
      items.append('16 bit')
   else:
      items.append('8 bit')
   
   return string.join(items)

s = esd.ServerSession('localhost')
info = s.getAllInfo()

print 'server:'
srvr = info.getServer()
print '  rate:', srvr.rate
print '  format:', srvr.format
print '  version:', srvr.version

print '\nplayers:'
for x in info.getPlayers():
   print
   print '  id:', x.source_id
   print '  name:', x.getName()
   print '  left_vol_scale:', x.left_vol_scale
   print '  right_vol_scale:', x.right_vol_scale
   print '  format:', x.format

print '\nsamples:'
for x in info.getSamples():
   print
   print '  id:', x.sample_id
   print '  name:', x.getName()
   print '  left_vol_scale:', x.left_vol_scale
   print '  right_vol_scale:', x.right_vol_scale
   print '  format:', x.format
   print '  length:', x.length

