Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenAL jumps to offset on Windows when it shouldn't
    primarykey
    data
    text
    <p>I'm experiencing a problem with OpenAL on Windows.</p> <pre><code>ALuint source; ALuint buffer; alGenSources(1, &amp;source); DJAudioSource audioSource = {source, 0,0,0, 0,0,0}; alSourcef(source, AL_PITCH, 1); alSourcef(source, AL_GAIN, 1); alSourcefv(source, AL_POSITION, audioSource.pos); alSourcefv(source, AL_VELOCITY, audioSource.vel); alSourcei(source, AL_LOOPING, AL_TRUE); alGenBuffers(1, &amp;buffer); FILE *file = fopen(path, "rb"); RiffHeader rh; WaveFormatHeader wfh; DataHeader dh; fread(&amp;rh, 1, sizeof(RiffHeader), file); fread(&amp;wfh, 1, sizeof(WaveFormatHeader), file); fread(&amp;dh, 1, sizeof(DataHeader), file); unsigned char *buf = (unsigned char*)malloc(dh.SubChunkSize); fread(buf, 1, dh.SubChunkSize, file); fclose(file); alBufferData(buffer, AL_FORMAT_STEREO16, buf, dh.SubChunkSize, wfh.SampleRate); alSourcei(source, AL_BUFFER, buffer); free(but); sources.push_back(audioSource); </code></pre> <p>I don't have error checking because I know that the file I am testing it with works when I run it in Xcode on Mac OS X. And here are the structs used in my code.</p> <pre><code>// Size of 24. typedef struct WaveFormatHeader { char SubChunkID[4]; unsigned int SubChunkSize; unsigned short AudioFormat; unsigned short Channels; unsigned int SampleRate; unsigned int ByteRate; unsigned short BlockAlign; unsigned short BitsPerSample; } WaveFormatHeader; // Size of 8. typedef struct DataHeader { char SubChunkID[4]; unsigned int SubChunkSize; } DataHeader; </code></pre> <p>The problem I am experiencing is this. When I run the program on Mac OS X, it plays the audio fine, and loops fine too. When I run it on Windows, it starts roughly three quarters of the way through the file. It plays to the end, then jumps to one quarter of the way through the song (presumably because one quarter of the song has passed at that point). It then plays until about halfway through and stops. After the duration of half the song has passed, it starts again from three quarters of the way through.</p> <p>I am using this line to play the audio after it has been loaded, in my load() function.</p> <pre><code>alSourcePlay(audioManager.sources.back().source); </code></pre> <p>audioManager is a custom class object that contains a vector of sources - not an OpenAL source but a DJAudioSource struct, which contains an ALuint source in it, amongst other things.</p> <pre><code>typedef struct DJAudioSource { ALuint source; ALfloat pos[3]; ALfloat vel[3]; } DJAudioSource; </code></pre> <p>Does anyone know why this is happening and/or how to stop it? And I apologise if I've missed any crucial information out of this question.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload