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

Cannot open output stream using paNonInterleaved on macOS (Blocking I/O) #753

Closed
pasin-k opened this issue Nov 17, 2022 · 2 comments
Closed
Assignees
Labels
bug Something isn't working P2 Priority: High src-coreaudio Apple Core Audio Host API src/hostapi/coreaudio
Milestone

Comments

@pasin-k
Copy link

pasin-k commented Nov 17, 2022

Describe the bug
I implemented an audio-player that is expected to support audio files in non-interleaf audio format. It works perfectly on Windows 10, but when I tested using it on Mac, it returns error -9994 (Sample format not supported).

Note that my implementation uses blocking API. If I add callback function, however, this works perfectly fine. Not sure if this is a bug or just an not implemented feature.

To Reproduce
Using code below

#include <stdio.h>
#include "portaudio.h"

#define FRAMES_PER_BUFFER   (1024)
void printErrorText(PaError err){
    printf("AUDIOIO: An error occurred while using the portaudio stream\n");
    printf("Error number: %d\n", err);
    printf("Error message: %s\n", Pa_GetErrorText(err));
}

int main(int argc, const char * argv[]) {
    char *fileName = "testAudio2.wav";
    char *fileToSave = "testAudio3Out.wav";
    PaError error;
    Pa_Initialize();
    PaStream *stream;
    /* Open PaStream with values read from the file */
    error = Pa_OpenDefaultStream(&stream
            ,0                     /* no input */
            ,2         /* stereo out */
            ,paFloat32|paNonInterleaved            /* floating point */
            ,44100
            ,FRAMES_PER_BUFFER
            ,nullptr
            ,nullptr);        /* our sndfile data struct */

    if(error != paNoError)
    {
        printErrorText(error);
        fprintf(stderr, "Problem opening Stream\n");
        return error;
    }
    return error;

    return 0;
}

Expected behavior
The code above should return 0.

Actual behavior

AUDIOIO: An error occurred while using the portaudio stream
Error number: -9994
Error message: Sample format not supported
Problem opening Stream

Adding callback function resolves problem above but I am struggling with creating callbackfunction in my actual implementation so I would prefer using blocking I/O, if possible.

Desktop (please complete the following information):

  • Mac OS
  • OS Version 12.5.1
  • PortAudio version: 19.7#3 (According to vcpkg)
  • Running on c++

Additional context

@RossBencina
Copy link
Collaborator

Unfortunately there is a known issue with non-interleaved blocking i/o on Mac: it isn't currently implemented. See:

#77

Other than callbacks, I think the only available workaround for now is to use interleaved blocking i/o.

@RossBencina RossBencina added bug Something isn't working src-coreaudio Apple Core Audio Host API src/hostapi/coreaudio P2 Priority: High labels Nov 22, 2022
@philburk philburk self-assigned this Nov 22, 2022
@RossBencina RossBencina added this to the V19.8 milestone Nov 22, 2022
@pasin-k
Copy link
Author

pasin-k commented Nov 22, 2022

I see. Thank you for the information. I guess I will limit my work to interleaved audio only for now.

@pasin-k pasin-k closed this as completed Nov 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P2 Priority: High src-coreaudio Apple Core Audio Host API src/hostapi/coreaudio
Projects
None yet
Development

No branches or pull requests

3 participants