protected FrameDecoder retrieveDecoder(Header header, Bitstream stream, int layer)
		throws DecoderException
	{
		FrameDecoder decoder = null;
		
		// REVIEW: allow channel output selection type
		// (LEFT, RIGHT, BOTH, DOWNMIX)
		switch (layer)
		{
		case 3:
			if (l3decoder==null)
			{
				l3decoder = new LayerIIIDecoder(stream, 
					header, filter1, filter2, 
					output, OutputChannels.BOTH_CHANNELS);
			}						
			
			decoder = l3decoder;
			break;
		case 2:
			if (l2decoder==null)
			{
				l2decoder = new LayerIIDecoder();
				l2decoder.create(stream, 
					header, filter1, filter2, 
					output, OutputChannels.BOTH_CHANNELS);				
			}
			decoder = l2decoder;
			break;
		case 1:
			if (l1decoder==null)
			{
				l1decoder = new LayerIDecoder();
				l1decoder.create(stream, 
					header, filter1, filter2, 
					output, OutputChannels.BOTH_CHANNELS);				
			}
			decoder = l1decoder;
			break;
		}
						
		if (decoder==null)
		{
			throw newDecoderException(UNSUPPORTED_LAYER, null);
		}
		
		return decoder;
	}