public Codec waitForCodec(
    final Object nameLock,
    final long   maxTime)
  {
    boolean active;
    Codec   retval;

//    logError("wait + "+this+" "+nameLock);
    do
    {
      synchronized(nameLock)
      {
        active   = isDecoding();
        retval   = (Codec)codecTable.get(nameLock);

        if(active && (retval == null))
        {
          active = isDecoding();

          if(active)
          {
            // We wait a maximum of 5 seconds instead of forever to avoid deadlocks...
            try
            {
              nameLock.wait((maxTime <= 0L)
                ? 5000L
                : maxTime);
            }
            catch(final Throwable ignored) {}

            retval = (Codec)codecTable.get(nameLock);
          }
        }
      }
    }
    while(
      active
      && (retval == null)
      && (maxTime <= 0L)
      && (nameLock != progressiveLock));

//    logError("wait - "+this+" "+nameLock);
    return retval;
  }