
OpenAL Stream에서 오디오 소스를 stream으로 관리하는 방법은 다음과 같습니다.
1. stream 생성: ALuint 형의 stream handle을 생성합니다. `alGenSources(1, &streamHandle);`
2. 소스 추가: stream handle에 소스를 추가합니다. `alSourcei(streamHandle, AL_BUFFER, bufferHandle);`
3. stream 종료: stream handle을 종료합니다. `alDeleteSources(1, &streamHandle);`
stream을 동시에 관리하는 방법은 다음과 같습니다.
1. stream handle 배열: 여러 stream handle을 저장하는 배열을 생성합니다. `ALuint streamHandles[10];`
2. stream handle 초기화: stream handle 배열을 초기화합니다. `alGenSources(10, streamHandles);`
3. stream handle 관리: 각 stream handle을 관리합니다. `alSourcei(streamHandles[i], AL_BUFFER, bufferHandle);`
stream 간의 오디오 소스 공유는 다음과 같이 할 수 있습니다.
1. 소스 공유: 두 stream handle 간에 소스를 공유합니다. `alSourcei(streamHandle1, AL_BUFFER, alGetSourcei(streamHandle2, AL_BUFFER));`
예제 코드는 다음과 같습니다.
#hostingforum.kr
c
#include
#include
int main() {
// OpenAL 초기화
ALCdevice* device;
ALCcontext* context;
alcOpenDevice(NULL);
alcCreateContext(device, NULL);
alcMakeContextCurrent(context);
// stream handle 생성
ALuint streamHandle;
alGenSources(1, &streamHandle);
// 소스 추가
ALuint bufferHandle;
alGenBuffers(1, &bufferHandle);
alBufferData(bufferHandle, AL_FORMAT_STEREO16, audioData, audioSize, 44100);
alSourcei(streamHandle, AL_BUFFER, bufferHandle);
// stream 종료
alDeleteSources(1, &streamHandle);
alDeleteBuffers(1, &bufferHandle);
// stream handle 배열 생성
ALuint streamHandles[10];
alGenSources(10, streamHandles);
// stream handle 초기화
for (int i = 0; i < 10; i++) {
alSourcei(streamHandles[i], AL_BUFFER, bufferHandle);
}
// stream handle 관리
for (int i = 0; i < 10; i++) {
alSourcei(streamHandles[i], AL_BUFFER, bufferHandle);
}
// 소스 공유
alSourcei(streamHandle1, AL_BUFFER, alGetSourcei(streamHandle2, AL_BUFFER));
return 0;
}
이 예제 코드는 OpenAL Stream에서 오디오 소스를 stream으로 관리하는 방법을 보여줍니다. stream handle을 생성하고 소스를 추가하는 방법, stream handle을 종료하고 소스를 제거하는 방법, stream handle 배열을 생성하고 관리하는 방법, stream 간의 오디오 소스 공유하는 방법이 모두 포함되어 있습니다.
2025-04-25 08:29