101    fprintf(stderr, 
"CACodecInputStream fillNativeBuffer\n");
 
  106    UInt32 ioOutputDataPacketSize;
 
  108    AudioBufferList outOutputData;
 
  109    jobject byteBuffer = NULL;
 
  113    byteBuffer = env->GetObjectField(stream, nativeBufferFID);    
 
  114    if (byteBuffer == NULL) {
 
  120    acio->
srcBuffer = (
char *)env->GetDirectBufferAddress(byteBuffer);
 
  121    acio->
srcBufferSize = env->GetDirectBufferCapacity(byteBuffer);
 
  127    outOutputData.mNumberBuffers = 1;
 
  128    outOutputData.mBuffers[0].mNumberChannels = acio->
srcFormat.mChannelsPerFrame;
 
  129    outOutputData.mBuffers[0].mDataByteSize = acio->
srcBufferSize;
 
  130    outOutputData.mBuffers[0].mData = acio->
srcBuffer;
 
  132    res = AudioConverterFillComplexBuffer(acio->
acref,
 
  133                                    CACodecInputStream_ComplexInputDataProc,
 
  135                                    &ioOutputDataPacketSize,
 
  147    acio->
pos += ioOutputDataPacketSize;
 
  148    if (acio->
srcFormat.mBytesPerPacket != 0) {
 
  149        limit = ioOutputDataPacketSize*acio->
srcFormat.mBytesPerPacket;
 
  153        for (i=0; i<ioOutputDataPacketSize; i++) {
 
  154            limit += acio->
pktDescs[i].mDataByteSize;
 
  158    env->CallObjectMethod(byteBuffer, limitMID, (jint)limit);
 
  159    env->CallObjectMethod(byteBuffer, rewindMID);
 
  163        fprintf(stderr, 
"acio->srcFormat.mBytesPerFrame  : %i\n", acio->
srcFormat.mBytesPerFrame);
 
 
  188    jobject byteBuffer = NULL;
 
  189    jclass audioFormatClass = NULL;
 
  190    jmethodID sampleRateMID = NULL;
 
  191    jmethodID channelsMID = NULL;
 
  192    jmethodID frameSizeMID = NULL;
 
  193    jmethodID sampleSizeInBitsMID = NULL;
 
  194    jmethodID encodingMID = NULL;
 
  195    jmethodID bigEndianMID = NULL;
 
  197    jclass caEncodingClass = NULL;
 
  198    jmethodID dataFormatMID = NULL;
 
  199    jobject targetEncoding = NULL;
 
  202    if (fillNativeBufferMID == NULL || hasRemainingMID == NULL || positionMID == NULL || nativeBufferFID == NULL || rewindMID == NULL || limitMID == NULL) {
 
  203        jclass nativePeerInputStreamClass = env->FindClass(
"com/tagtraum/casampledsp/CANativePeerInputStream");
 
  204        fillNativeBufferMID = env->GetMethodID(nativePeerInputStreamClass, 
"fillNativeBuffer", 
"()V");
 
  205        nativeBufferFID = env->GetFieldID(nativePeerInputStreamClass, 
"nativeBuffer", 
"Ljava/nio/ByteBuffer;");
 
  206        jclass bufferClass = env->FindClass(
"java/nio/Buffer");
 
  207        hasRemainingMID = env->GetMethodID(bufferClass, 
"hasRemaining", 
"()Z");
 
  208        positionMID = env->GetMethodID(bufferClass, 
"position", 
"(I)Ljava/nio/Buffer;");
 
  209        rewindMID = env->GetMethodID(bufferClass, 
"rewind", 
"()Ljava/nio/Buffer;");
 
  210        limitMID = env->GetMethodID(bufferClass, 
"limit", 
"(I)Ljava/nio/Buffer;");
 
  214    byteBuffer = env->GetObjectField(stream, nativeBufferFID);    
 
  215    if (byteBuffer == NULL) {
 
  224    acio->
srcBuffer = (
char *)env->GetDirectBufferAddress(byteBuffer);
 
  225    acio->
srcBufferSize = env->GetDirectBufferCapacity(byteBuffer);
 
  233    audioFormatClass = env->FindClass(
"javax/sound/sampled/AudioFormat");
 
  234    sampleRateMID = env->GetMethodID(audioFormatClass, 
"getSampleRate", 
"()F");
 
  235    channelsMID = env->GetMethodID(audioFormatClass, 
"getChannels", 
"()I");
 
  236    frameSizeMID = env->GetMethodID(audioFormatClass, 
"getFrameSize", 
"()I");
 
  237    sampleSizeInBitsMID = env->GetMethodID(audioFormatClass, 
"getSampleSizeInBits", 
"()I");
 
  238    encodingMID = env->GetMethodID(audioFormatClass, 
"getEncoding", 
"()Ljavax/sound/sampled/AudioFormat$Encoding;");
 
  239    bigEndianMID = env->GetMethodID(audioFormatClass, 
"isBigEndian", 
"()Z");
 
  241    caEncodingClass = env->FindClass(
"com/tagtraum/casampledsp/CAAudioFormat$CAEncoding");
 
  242    dataFormatMID = env->GetMethodID(caEncodingClass, 
"getDataFormat", 
"()I");
 
  243    targetEncoding = env->CallObjectMethod(targetFormat, encodingMID);
 
  247    acio->
srcFormat.mSampleRate = (Float64)env->CallFloatMethod(targetFormat, sampleRateMID);
 
  248    acio->
srcFormat.mChannelsPerFrame = (UInt32)env->CallIntMethod(targetFormat, channelsMID);
 
  249    acio->
srcFormat.mBitsPerChannel = (UInt32)env->CallIntMethod(targetFormat, sampleSizeInBitsMID);
 
  251    acio->
srcFormat.mBytesPerFrame = (UInt32)env->CallIntMethod(targetFormat, frameSizeMID);
 
  253    acio->
srcFormat.mFormatID = (UInt32)env->CallIntMethod(targetEncoding, dataFormatMID);
 
  258    if (acio->
srcFormat.mFormatID == kAudioFormatLinearPCM) {
 
  259        acio->
srcFormat.mFormatFlags += env->CallBooleanMethod(targetFormat, bigEndianMID) == JNI_TRUE ? kAudioFormatFlagIsBigEndian : 0;
 
  260        acio->
srcFormat.mFormatFlags += kAudioFormatFlagIsPacked;
 
  263        acio->
srcFormat.mFormatFlags += kAudioFormatFlagIsSignedInteger;
 
  275    if (acio->
srcFormat.mBytesPerFrame == 0) {
 
  279    if (acio->
srcFormat.mBytesPerPacket == 0) {
 
  283    if (acio->
srcFormat.mBitsPerChannel == 0) {
 
  292        env->CallVoidMethod(sourceStream, fillNativeBufferMID);
 
  293        res = acio->
env->ExceptionCheck();
 
  344        if (acio->
acref != NULL) {
 
  345            AudioConverterDispose(acio->
acref);