protected byte [ ] getClipData ( SoundKey key ) throws IOException , UnsupportedAudioFileException { byte [ ] [ ] data ; synchronized ( _clipCache ) { // if we're testing, clear all non-locked sounds every time if ( isTesting ( ) ) { _clipCache . clear ( ) ; } data = _clipCache . get ( key ) ; // see if it's in the locked cache (we first look in the regular // clip cache so that locked clips that are still cached continue // to be moved to the head of the LRU queue) if ( data == null ) { data = _lockedClips . get ( key ) ; } if ( data == null ) { // if there is a test sound, JUST use the test sound. InputStream stream = getTestClip ( key ) ; if ( stream != null ) { data = new byte [ 1 ] [ ] ; data [ 0 ] = StreamUtil . toByteArray ( stream ) ; } else { data = _loader . load ( key . pkgPath , key . key ) ; } _clipCache . put ( key , data ) ; } } return ( data . length > 0 ) ? data [ RandomUtil . getInt ( data . length ) ] : null ; }
Called by spooling threads loads clip data from the resource manager or the cache .