rendered paste bodystatic voidclear_AudioStreamBasicDescription (AudioStreamBasicDescription *desc){ desc->mSampleRate = 0; desc->mFormatID = 0; desc->mFormatFlags = 0; desc->mBytesPerPacket = 0; desc->mFramesPerPacket = 0; desc->mBytesPerFrame = 0; desc->mChannelsPerFrame = 0; desc->mBitsPerChannel = 0;}static voidfill_indesc_mp3 (MacOSXAudioDecoder * macosx, guint32 fourcc, gint rate, gint channels){ GST_LOG ("..."); clear_AudioStreamBasicDescription (&macosx->indesc); /* only the samplerate is needed apparently */ macosx->indesc.mSampleRate = rate; macosx->indesc.mFormatID = kAudioFormatMPEGLayer3; macosx->indesc.mChannelsPerFrame = channels;}[.....]static gbooleanopen_decoder (MacOSXAudioDecoder * macosx, GstCaps * caps, GstCaps **othercaps){ .... fill_indesc_mp3 (macosx, oclass->componentSubType, rate, channels); /* Setup the output format description */ macosx->outdesc.mSampleRate = rate; macosx->outdesc.mFormatID = kAudioFormatLinearPCM; macosx->outdesc.mFormatFlags = kAudioFormatFlagIsFloat; macosx->outdesc.mBytesPerPacket = channels * 4; /* ?? */ macosx->outdesc.mFramesPerPacket = 1; macosx->outdesc.mBytesPerFrame = channels * 4;/* channels * bytes-per-samples*/ macosx->outdesc.mChannelsPerFrame = channels; macosx->outdesc.mBitsPerChannel = 32; /* Create an AudioConverter */ status = AudioConverterNew (&macosx->indesc, &macosx->outdesc, &macosx->aconv); if (status != noErr) { GST_WARNING_OBJECT (macosx, "Error when calling AudioConverterNew() : %ld", status); goto beach; }}static OSStatusprocess_buffer_cb (AudioConverterRef inAudioConverter, UInt32* ioDataSize, void** outData, MacOSXAudioDecoder *macosx){ gint len; GST_LOG_OBJECT (macosx, "ioDataSize:%d", *ioDataSize); len = MIN (gst_adapter_available (macosx->adapter), *ioDataSize); if (len) { *outData = gst_adapter_take (macosx->adapter, len); } *ioDataSize = len; GST_LOG_OBJECT (macosx, "returning %d bytes at %p", len, *outData); return noErr;}chain(){ /* 4. Create buffer and copy data in it */ ret = gst_pad_alloc_buffer (macosx->srcpad, macosx->cur_offset, outbytes, GST_PAD_CAPS (macosx->srcpad), &outbuf); if (ret != GST_FLOW_OK) goto beach; GST_LOG_OBJECT (macosx, "Calling FillBuffer(outbytes:%d , outdata:%p)", outbytes, GST_BUFFER_DATA (outbuf)); /* Ask AudioConverter to give us data ! */ oserr = AudioConverterFillBuffer (macosx->aconv, (AudioConverterInputDataProc) process_buffer_cb, macosx, &outbytes, &GST_BUFFER_DATA (outbuf)); if (oserr != noErr) { GST_WARNING_OBJECT (macosx, "Error in AudioConverterFillBuffer() : %d", oserr); ret = GST_FLOW_ERROR; gst_buffer_unref (outbuf); goto beach; } GST_LOG_OBJECT (macosx, "We now have %d bytes", outbytes);}