question

zipswich avatar image
0 Votes"
zipswich asked RobCaplan edited

GeneralParamError from OutputAudioQueue.EnqueueBuffer()

I have extracted relevant code from an app as follows:

 OutputAudioQueue _audioQueue = new OutputAudioQueue(new AudioStreamBasicDescription()
                                 {
                                     Format = AudioFormatType.MPEG4AAC_HE,
                                     BytesPerFrame = 0, //Set this field to 0 for compressed formats. 
                                     SampleRate = 16000,
                                     ChannelsPerFrame = 1,
                                     FramesPerPacket = 1024 //for AAC. According to Appple's document
                                 });
    
 for (int i = 0; i < 10; i++)
 {
     IntPtr ipBuffer;
     _audioQueue.AllocateBuffer(BufferSize, out ipBuffer);
     _qFreeAudioOutputBuffers.Enqueue(ipBuffer);
 }
 ...
 if (_qFreeAudioOutputBuffers.TryDequeue(out ipBuffer))
 {
     Marshal.Copy(abData, 0, ipBuffer, abData.Length);
     AudioStreamPacketDescription aspDescription = new AudioStreamPacketDescription()
     {
         DataByteSize = abData.Length,
         StartOffset = 0,
         VariableFramesInPacket = 0    //The codec should be able to know the number of frames based on supplied AudioStreamBasicDescription
     };
    
     AudioQueueStatus aqStatus = _audioQueue.EnqueueBuffer(ipBuffer, new AudioStreamPacketDescription[] { aspDescription });
     Console.WriteLine("Queued audio sample with status: " + aqStatus);
 }

audioQueue.EnqueueBuffer() keeps generating aqStatus: GeneralParamError.

Could anyone shed some light on this? What are the possible causes?

dotnet-xamarin
· 8
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The problem seems to relate with the parameter you pass into EnqueueBuffer method , could you clarify what you're trying to implement ? Would you mind sharing the complete code to us for reproducing the issue ?

0 Votes 0 ·

Let me try on a physical device first, then get back here.

0 Votes 0 ·

0 Answers