Reputation: 11
I am working on a Java based Application that requires to record sound from Mic. Following is my code:
audioFormat = new AudioFormat(8000, 16, 1, true, false);
targetInfo = new DataLine.Info(TargetDataLine.class, audioFormat);
try {
targetDataLine = (TargetDataLine) AudioSystem.getLine(targetInfo);
targetDataLine.open(audioFormat, 320);
targetDataLine.start();
} catch (LineUnavailableException ex) {
java.util.logging.Logger.getLogger(SoundManager.class.getName()).log(Level.SEVERE, null, ex);
}
Here I am getting exception on line "targetDataLine.open(audioFormat, 320);"
javax.sound.sampled.LineUnavailableException: line with format PCM_SIGNED 8000.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian not supported.
I have changed my PC's hardware and OS to CentOS7, the same code worked perfectly on previous hardware and OS CentOS 6.7.
I have checked the formats that my current PC Supports, which are as follows:
> Supported SourceDataLines of default mixer (PCH [default]):
>
> interface SourceDataLine supporting 48 audio formats, and buffers of
> at least 32 bytes max buffer size: -1 min buffer size: 32
> Supported Audio formats:
> PCM_SIGNED unknown sample rate, 16 bit, mono, 2 bytes/frame, little-endian
> PCM_SIGNED unknown sample rate, 16 bit, mono, 2 bytes/frame, big-endian
> PCM_SIGNED unknown sample rate, 16 bit, stereo, 4 bytes/frame, little-endian
> PCM_SIGNED unknown sample rate, 16 bit, stereo, 4 bytes/frame, big-endian
> PCM_SIGNED unknown sample rate, 16 bit, 3 channels, 6 bytes/frame, little-endian
> PCM_SIGNED unknown sample rate, 16 bit, 3 channels, 6 bytes/frame, big-endian
> PCM_SIGNED unknown sample rate, 16 bit, 4 channels, 8 bytes/frame, little-endian
> PCM_SIGNED unknown sample rate, 16 bit, 4 channels, 8 bytes/frame, big-endian
> PCM_SIGNED unknown sample rate, 8 bit, mono, 1 bytes/frame,
> PCM_UNSIGNED unknown sample rate, 8 bit, mono, 1 bytes/frame,
> PCM_SIGNED unknown sample rate, 8 bit, stereo, 2 bytes/frame,
> PCM_UNSIGNED unknown sample rate, 8 bit, stereo, 2 bytes/frame,
> PCM_SIGNED unknown sample rate, 8 bit, 3 channels, 3 bytes/frame,
> PCM_UNSIGNED unknown sample rate, 8 bit, 3 channels, 3 bytes/frame,
> PCM_SIGNED unknown sample rate, 8 bit, 4 channels, 4 bytes/frame,
> PCM_UNSIGNED unknown sample rate, 8 bit, 4 channels, 4 bytes/frame,
> PCM_SIGNED unknown sample rate, 32 bit, mono, 4 bytes/frame, little-endian
> PCM_SIGNED unknown sample rate, 32 bit, mono, 4 bytes/frame, big-endian
> PCM_SIGNED unknown sample rate, 32 bit, stereo, 8 bytes/frame, little-endian
> PCM_SIGNED unknown sample rate, 32 bit, stereo, 8 bytes/frame, big-endian
> PCM_SIGNED unknown sample rate, 32 bit, 3 channels, 12 bytes/frame, little-endian
> PCM_SIGNED unknown sample rate, 32 bit, 3 channels, 12 bytes/frame, big-endian
> PCM_SIGNED unknown sample rate, 32 bit, 4 channels, 16 bytes/frame, little-endian
> PCM_SIGNED unknown sample rate, 32 bit, 4 channels, 16 bytes/frame, big-endian
> PCM_SIGNED unknown sample rate, 24 bit, mono, 4 bytes/frame, little-endian
> PCM_SIGNED unknown sample rate, 24 bit, mono, 4 bytes/frame, big-endian
> PCM_SIGNED unknown sample rate, 24 bit, stereo, 8 bytes/frame, little-endian
> PCM_SIGNED unknown sample rate, 24 bit, stereo, 8 bytes/frame, big-endian
> PCM_SIGNED unknown sample rate, 24 bit, 3 channels, 12 bytes/frame, little-endian
> PCM_SIGNED unknown sample rate, 24 bit, 3 channels, 12 bytes/frame, big-endian
> PCM_SIGNED unknown sample rate, 24 bit, 4 channels, 16 bytes/frame, little-endian
> PCM_SIGNED unknown sample rate, 24 bit, 4 channels, 16 bytes/frame, big-endian
> PCM_SIGNED unknown sample rate, 24 bit, mono, 3 bytes/frame, little-endian
> PCM_SIGNED unknown sample rate, 24 bit, mono, 3 bytes/frame, big-endian
> PCM_SIGNED unknown sample rate, 24 bit, stereo, 6 bytes/frame, little-endian
> PCM_SIGNED unknown sample rate, 24 bit, stereo, 6 bytes/frame, big-endian
> PCM_SIGNED unknown sample rate, 24 bit, 3 channels, 9 bytes/frame, little-endian
> PCM_SIGNED unknown sample rate, 24 bit, 3 channels, 9 bytes/frame, big-endian
> PCM_SIGNED unknown sample rate, 24 bit, 4 channels, 12 bytes/frame, little-endian
> PCM_SIGNED unknown sample rate, 24 bit, 4 channels, 12 bytes/frame, big-endian
> PCM_SIGNED unknown sample rate, 20 bit, mono, 3 bytes/frame, little-endian
> PCM_SIGNED unknown sample rate, 20 bit, mono, 3 bytes/frame, big-endian
> PCM_SIGNED unknown sample rate, 20 bit, stereo, 6 bytes/frame, little-endian
> PCM_SIGNED unknown sample rate, 20 bit, stereo, 6 bytes/frame, big-endian
> PCM_SIGNED unknown sample rate, 20 bit, 3 channels, 9 bytes/frame, little-endian
> PCM_SIGNED unknown sample rate, 20 bit, 3 channels, 9 bytes/frame, big-endian
> PCM_SIGNED unknown sample rate, 20 bit, 4 channels, 12 bytes/frame, little-endian
> PCM_SIGNED unknown sample rate, 20 bit, 4 channels, 12 bytes/frame, big-endian
I will be grateful if I get some sort of help in this regards.
Upvotes: 0
Views: 646