< prev index next >

test/javax/sound/sampled/Clip/OpenNonIntegralNumberOfSampleframes.java

Print this page




  80             }
  81         }
  82     }
  83 
  84     public static void main(final String[] args) {
  85         for (final AudioFormat af : formats) {
  86             try (Clip clip = AudioSystem.getClip()) {
  87                 final int bufferSize = af.getFrameSize() + 1;
  88                 try {
  89                     clip.open(af, new byte[100], 0, bufferSize);
  90                 } catch (final IllegalArgumentException ignored) {
  91                     // expected exception
  92                     continue;
  93                 } catch (final LineUnavailableException e) {
  94                     // should not occur, we passed incorrect bufferSize
  95                     e.printStackTrace();
  96                 }
  97                 System.err.println("af = " + af);
  98                 System.err.println("bufferSize = " + bufferSize);
  99                 throw new RuntimeException("Expected exception is not thrown");
 100             } catch (final LineUnavailableException ignored) {

 101                 // the test is not applicable
 102             }
 103         }
 104     }
 105 }


  80             }
  81         }
  82     }
  83 
  84     public static void main(final String[] args) {
  85         for (final AudioFormat af : formats) {
  86             try (Clip clip = AudioSystem.getClip()) {
  87                 final int bufferSize = af.getFrameSize() + 1;
  88                 try {
  89                     clip.open(af, new byte[100], 0, bufferSize);
  90                 } catch (final IllegalArgumentException ignored) {
  91                     // expected exception
  92                     continue;
  93                 } catch (final LineUnavailableException e) {
  94                     // should not occur, we passed incorrect bufferSize
  95                     e.printStackTrace();
  96                 }
  97                 System.err.println("af = " + af);
  98                 System.err.println("bufferSize = " + bufferSize);
  99                 throw new RuntimeException("Expected exception is not thrown");
 100             } catch (IllegalArgumentException
 101                     | LineUnavailableException ignored) {
 102                 // the test is not applicable
 103             }
 104         }
 105     }
 106 }
< prev index next >