Package javax.media

Examples of javax.media.ResourceUnavailableException


      }
   
    } catch (IOException e)
    {
      logger.log(Level.WARNING, "" + e, e);
      throw new ResourceUnavailableException("" + e);
    } catch (SAXException e)
    {
      logger.log(Level.WARNING, "" + e, e);
      throw new ResourceUnavailableException("" + e);
    } catch (InterruptedException e)
    {
      logger.log(Level.WARNING, "" + e, e);
      throw new ResourceUnavailableException("" + e);
    }

    super.open();

  }
View Full Code Here


      {
        doOpen();
      } catch (UnsupportedAudioFileException e)
      {
        logger.log(Level.WARNING, "" + e, e);
        throw new ResourceUnavailableException("" + e);
      } catch (IOException e)
      {
        logger.log(Level.WARNING, "" + e, e);
        throw new ResourceUnavailableException("" + e);
      }

    }
  }
View Full Code Here

    final javax.sound.sampled.AudioFormat javaSoundAudioFormat = JavaSoundUtils.convertFormat((AudioFormat) inputFormat);
    logger.fine("javaSoundAudioFormat converted (in)=" + javaSoundAudioFormat);
   
    final byte[] header = fakeHeader(javaSoundAudioFormat);
    if (header == null)
      throw new ResourceUnavailableException("Unable to reconstruct header for format: " + inputFormat);
    if (header.length > 0)
    {
      Buffer headerBuffer = new Buffer();
      headerBuffer.setData(header);
      headerBuffer.setLength(header.length);
View Full Code Here

        if (inputFormat.getEncoding().equals(AudioFormat.ULAW))
          codec = new net.sf.fmj.media.codec.audio.ulaw.Decoder()// much more efficient than JavaSoundCodec
        else if (inputFormat.getEncoding().equals(AudioFormat.ALAW))
          codec = new net.sf.fmj.media.codec.audio.alaw.Decoder()// much more efficient than JavaSoundCodec
        else
          throw new ResourceUnavailableException("Unsupported input format encoding: " + inputFormat.getEncoding());
       
        if (codec.setInputFormat(inputFormat) == null)
          throw new ResourceUnavailableException("Codec rejected input format: " + inputFormat);
       
        final Format[] outputFormats = codec.getSupportedOutputFormats(inputFormat);
        if (outputFormats.length < 1)
          throw new ResourceUnavailableException("Unable to get an output format for input format: " + inputFormat);
        final AudioFormat codecOutputFormat = AudioFormatCompleter.complete((AudioFormat) outputFormats[0])// TODO: choose the best quality one.
        // specify any unspecified parameters:
       
        if (codec.setOutputFormat(codecOutputFormat) == null)
          throw new ResourceUnavailableException("Codec rejected output format: " + codecOutputFormat);
       
        audioFormat = JavaSoundUtils.convertFormat(codecOutputFormat);

        codec.open();

        logger.info("JavaSoundRenderer: Audio format is not linear, created conversion from " + inputFormat + " to " + codecOutputFormat);
       
      }
     
      // mgodehardt: we must use this, this will get a working mixer for windows, linux and mac
            DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat);
            sourceLine = (SourceDataLine)AudioSystem.getLine(info);
            logger.info("JavaSoundRenderer: sourceLine=" + sourceLine);
            sourceLine.open(audioFormat);
            logger.info("JavaSoundRenderer: buflen=" + sourceLine.getBufferSize());
           
            // fetch gain control
            FloatControl gainFloatControl = null;
            try
            {
                gainFloatControl = (FloatControl)sourceLine.getControl(FloatControl.Type.MASTER_GAIN);
            }
            catch (Exception e)
            {
                logger.log(Level.WARNING, "" + e, e);
            }
            logger.fine("JavaSoundRenderer: gainFloatControl=" + gainFloatControl);
           
            // fecth mute control
            BooleanControl muteBooleanControl = null;
            try
            {
                muteBooleanControl = (BooleanControl)sourceLine.getControl(BooleanControl.Type.MUTE);
            }
            catch (Exception e)
            {
                logger.log(Level.WARNING, "" + e, e);
            }
            logger.fine("JavaSoundRenderer: muteBooleanControl=" + muteBooleanControl);
           
            JavaSoundGainControl gainControl = new JavaSoundGainControl(gainFloatControl, muteBooleanControl);
            controls.addControl(gainControl);
           
            controls.addControl(new JavaSoundRendererBufferControl());
            controls.addControl(new FPC());
            controls.addControl(levelControl);
           
            ///logControls(sourceLine.getControls());
    }
    catch (LineUnavailableException e) {
      throw new ResourceUnavailableException(e.getMessage());
    }
  }
View Full Code Here

TOP

Related Classes of javax.media.ResourceUnavailableException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.