Skip to content

AVAudioFormat.StreamDescription returns invalid data #8892

@chamons

Description

@chamons
			var format = new AVAudioFormat (AVAudioCommonFormat.PCMFloat32, 44100.0, 2, true);

			Console.WriteLine (format.StreamDescription.Format);
			Console.WriteLine (format.StreamDescription.FormatFlags);
			Console.WriteLine (format.StreamDescription.BytesPerPacket);
			Console.WriteLine (format.StreamDescription.FramesPerPacket);
			Console.WriteLine (format.StreamDescription.BytesPerFrame);
			Console.WriteLine (format.StreamDescription.ChannelsPerFrame);
			Console.WriteLine (format.StreamDescription.BitsPerChannel);
			Console.WriteLine (format.StreamDescription.Reserved);
2020-06-18 12:02:45.633956-0500 AudioBuff[1879:21497389] 0
2020-06-18 12:02:45.634350-0500 AudioBuff[1879:21497389] 0
2020-06-18 12:02:45.634754-0500 AudioBuff[1879:21497389] 0
2020-06-18 12:02:45.634901-0500 AudioBuff[1879:21497389] 0
2020-06-18 12:02:45.635068-0500 AudioBuff[1879:21497389] 0
2020-06-18 12:02:45.635216-0500 AudioBuff[1879:21497389] 0
2020-06-18 12:02:45.635389-0500 AudioBuff[1879:21497389] 0
2020-06-18 12:02:45.635532-0500 AudioBuff[1879:21497389] 0

compare to

    AVAudioFormat * format = [[AVAudioFormat alloc] initWithCommonFormat:AVAudioPCMFormatFloat32 sampleRate:44100.0 channels:2 interleaved:YES];
    const AudioStreamBasicDescription * d = [format streamDescription];   
    NSLog (@"%d", d->mFormatID);
    NSLog (@"%d", d->mFormatFlags);
    NSLog (@"%d", d->mBytesPerPacket);
    NSLog (@"%d", d->mFramesPerPacket);
    NSLog (@"%d", d->mBytesPerFrame);
    NSLog (@"%d", d->mChannelsPerFrame);
    NSLog (@"%d", d->mBitsPerChannel);
    NSLog (@"%d", d->mReserved);
2020-06-18 11:27:52.814242-0500 AudioBuffTest[1323:21473545] 1819304813
2020-06-18 11:27:52.814513-0500 AudioBuffTest[1323:21473545] 9
2020-06-18 11:27:52.814759-0500 AudioBuffTest[1323:21473545] 8
2020-06-18 11:27:52.815011-0500 AudioBuffTest[1323:21473545] 1
2020-06-18 11:27:52.815264-0500 AudioBuffTest[1323:21473545] 8
2020-06-18 11:27:52.815464-0500 AudioBuffTest[1323:21473545] 2
2020-06-18 11:27:52.815717-0500 AudioBuffTest[1323:21473545] 32
2020-06-18 11:27:52.815952-0500 AudioBuffTest[1323:21473545] 0

The ObjC defination:

typedef struct AudioStreamBasicDescription  AudioStreamBasicDescription;
@property (nonatomic, readonly) const AudioStreamBasicDescription *streamDescription;

our binding

		[Export ("streamDescription")]
		AudioStreamBasicDescription StreamDescription { get; }

generates

	ret = global::ObjCRuntime.Messaging.AudioStreamBasicDescription_objc_msgSend (this.Handle, Selector.GetHandle ("streamDescription"));

I think this is the source of the bug.

Happens in 13.18 and master

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIf an issue is a bug or a pull request a bug fixiOSIssues affecting iOSmacOSIssues affecting macOS

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions