Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appending audio sample buffer crashes when unwrapping _converter variable #889

Closed
alexisPonce98 opened this issue Jul 18, 2021 · 4 comments
Labels

Comments

@alexisPonce98
Copy link

Describe the bug
A clear and concise description of what the bug is.
When i am appending audio sample buffers from a RPScreenRecorder, the app is crashing with HaishinKit/AudioCodec.swift:164: Fatal error: Unexpectedly found nil while unwrapping an Optional value. It seems to be when the _converter variable from the AudioCodec class. If i attach the app audio it doesnt seem to crash but there is also no audio being passed to the stream, it only happens with mic audio.
To Reproduce
Steps to reproduce the behavior:

  1. append an audio sampleBuffer to the stream
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.
Not to crash and append the audio to the stream.
Screen Shot 2021-07-18 at 3 20 01 PM

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: iPhone XR
  • OS: iOS 14.6
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

@shogo4405
Copy link
Owner

It caused to crash with an unsupported input format for CMSampleBuffer.
I see mChanneIsPerFrame: 3. It value is mChanneIsPerFrame: 2(stereo) or 1(mono) normal.

Please provide more info print(RPScreenRecorder.CMSampleBuffer).

@alexisPonce98
Copy link
Author

Thank you for your reply!, yea i thought that was weird that i am getting mChannelsIsPerFram: 3. Here is a screenshot of the sample all the info from the sample buffer that is being captured by rpScreenRecorder.
Screen Shot 2021-07-30 at 12 34 57 PM

@SergiyZhyrov
Copy link

SergiyZhyrov commented Jul 31, 2021

Hello.
There are related bug with audio, also crash. To fix just update one enum

    enum ChannelConfiguration: UInt8 {
        case definedInAOTSpecificConfig = 0
        case frontCenter = 1
        case frontLeftAndFrontRight = 2
        case frontCenterAndFrontLeftAndFrontRight = 3
        case frontCenterAndFrontLeftAndFrontRightAndBackCenter = 4
        case frontCenterAndFrontLeftAndFrontRightAndBackLeftAndBackRight = 5
        case frontCenterAndFrontLeftAndFrontRightAndBackLeftAndBackRightLFE = 6
        case frontCenterAndFrontLeftAndFrontRightAndSideLeftAndSideRightAndBackLeftAndBackRightLFE = 7
        
        case ch8 = 8
        case ch9  = 9
        case ch10 = 10
        case ch11 = 11
        case ch12 = 12
        case ch13 = 13
        case ch14 = 14
        case ch15 = 15
        case ch16 = 16
    }

and also change defaultChannels in public class AudioCodec. Converter can't convert to 16 output channels
/// 0 means according to a input source
public static let defaultChannels: UInt32 = 2

To reproduce bug, just try BlackHole with 16 channels https://github.com/ExistentialAudio/BlackHole

@shogo4405
Copy link
Owner

HaishinKit can support 1 or 2 channels input audio.
I thought iOS can't support 3 channels an AudioConverter.
I will not fix it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants