capturing sound from wine with TargetDataLine
===

I have written a small Java application for testing purposes that captures sound from a mixer on ubuntu 12.04. 

The code works fine, I can capture sound from all applications except for anything running under Wine. Whenever I start my program after having started wine, the call to targetDataLine.read() will block forever. When wine is not running in the background it correctly outputs 0 if there is no input, or the number of bytes read if there is input, as expected. If I start my program before starting wine, the sound driver will not be available  within wine.

I have tried using both the mixers provided by alsa as well as the default device, same result. Ok, I could imagine that wine somehow locks alsa (for whatever reason), but why would a simple call to TargetDataLine.read() cause sound to fail in wine?
mixerInfo[0] is default on my system btw, and the application is of course always running outside of wine using oracle's latest jre (7).



    private void readSound() {
        byte tempBuffer[] = new byte[10000];
        int cnt=0;
        Mixer.Info[] mixerInfo =
                AudioSystem.getMixerInfo();
        System.out.println("Available mixers:");
        for (int p = 0; p < mixerInfo.length;
                p++) {
            System.out.println(mixerInfo[p].getName());
        }
        format = getAudioFormat();
        DataLine.Info dataLineInfo =
                new DataLine.Info(
                TargetDataLine.class,
                format);
             Mixer mixer = AudioSystem.getMixer(mixerInfo[0]);
             try{
             targetDataLine = (TargetDataLine) mixer.getLine(dataLineInfo);
             targetDataLine.open(format);
             }catch(Exception e){
                 e.printStackTrace();
             }
             targetDataLine.start();
             
       while(true){           
            i++;
            cnt = targetDataLine.read(tempBuffer,0,tempBuffer.length);
            System.out.println("read "+cnt+" bytes:"+tempBuffer[i]);            
            calculateLevel(tempBuffer,0,200);
            targetDataLine.flush();
            System.out.println(level);
       }

    }
