Search in sources :

Example 1 with Line

use of javax.sound.sampled.Line in project jdk8u_jdk by JetBrains.

the class DataLine_ArrayIndexOutOfBounds method testSDL.

static void testSDL(Mixer mixer, Scenario scenario) {
    log("  Testing SDL (scenario: " + scenario + ")...");
    Line.Info linfo = new Line.Info(SourceDataLine.class);
    SourceDataLine line = null;
    try {
        line = (SourceDataLine) mixer.getLine(linfo);
        log("    got line: " + line);
        log("    open...");
        line.open();
    } catch (IllegalArgumentException ex) {
        log("    unsupported (IllegalArgumentException)");
        return;
    } catch (LineUnavailableException ex) {
        log("    unavailable: " + ex);
        return;
    }
    total++;
    log("    start...");
    line.start();
    AsyncLineStopper lineStopper = new AsyncLineStopper(line, STOPPER_DELAY);
    int offset = scenario.getBufferOffset(line);
    int len = scenario.getBufferLength(line);
    // ensure len represents integral number of frames
    len -= len % line.getFormat().getFrameSize();
    log("    write...");
    lineStopper.schedule();
    try {
        line.write(buffer, offset, len);
        log("    ERROR: didn't get ArrayIndexOutOfBoundsException");
        failed++;
    } catch (ArrayIndexOutOfBoundsException ex) {
        log("    OK: got ArrayIndexOutOfBoundsException: " + ex);
    }
    lineStopper.force();
}
Also used : TargetDataLine(javax.sound.sampled.TargetDataLine) Line(javax.sound.sampled.Line) DataLine(javax.sound.sampled.DataLine) SourceDataLine(javax.sound.sampled.SourceDataLine) LineUnavailableException(javax.sound.sampled.LineUnavailableException) SourceDataLine(javax.sound.sampled.SourceDataLine)

Example 2 with Line

use of javax.sound.sampled.Line in project jdk8u_jdk by JetBrains.

the class DataLine_ArrayIndexOutOfBounds method testTDL.

static void testTDL(Mixer mixer, Scenario scenario) {
    log("  Testing TDL (scenario: " + scenario + ")...");
    Line.Info linfo = new Line.Info(TargetDataLine.class);
    TargetDataLine line = null;
    try {
        line = (TargetDataLine) mixer.getLine(linfo);
        log("    got line: " + line);
        log("    open...");
        line.open();
    } catch (IllegalArgumentException ex) {
        log("    unsupported (IllegalArgumentException)");
        return;
    } catch (LineUnavailableException ex) {
        log("    unavailable: " + ex);
        return;
    }
    total++;
    log("    start...");
    line.start();
    AsyncLineStopper lineStopper = new AsyncLineStopper(line, STOPPER_DELAY);
    int offset = scenario.getBufferOffset(line);
    int len = scenario.getBufferLength(line);
    // ensure len represents integral number of frames
    len -= len % line.getFormat().getFrameSize();
    log("    read...");
    try {
        line.read(buffer, offset, len);
        log("    ERROR: didn't get ArrayIndexOutOfBoundsException");
        failed++;
    } catch (ArrayIndexOutOfBoundsException ex) {
        log("    OK: got ArrayIndexOutOfBoundsException: " + ex);
    }
    lineStopper.force();
}
Also used : TargetDataLine(javax.sound.sampled.TargetDataLine) Line(javax.sound.sampled.Line) DataLine(javax.sound.sampled.DataLine) SourceDataLine(javax.sound.sampled.SourceDataLine) LineUnavailableException(javax.sound.sampled.LineUnavailableException) TargetDataLine(javax.sound.sampled.TargetDataLine)

Aggregations

DataLine (javax.sound.sampled.DataLine)2 Line (javax.sound.sampled.Line)2 LineUnavailableException (javax.sound.sampled.LineUnavailableException)2 SourceDataLine (javax.sound.sampled.SourceDataLine)2 TargetDataLine (javax.sound.sampled.TargetDataLine)2