int main(int argc, char *argv[]) { CoInitializeEx(nullptr, COINIT_MULTITHREADED); char *buffer = new char[BUFFER_SIZE]; if (buffer == nullptr) return -11; try { audio.open(XAUDIO2_DEBUG_ENGINE); DMSG("open"); Wav wav("D:\\openAL\\11k16bitpcm.wav"); uint32_t readSize = wav.read(buffer, BUFFER_SIZE); DVAR(readSize); wav.close(); DMSG("play"); audio.play(wav.getFormat(), buffer, wav.getSize()); while (audio.isPlaying()) Thread::sleep(10); } catch (...) { std::cout << "error" << std::endl; } DMSG("close"); audio.close(); CoUninitialize(); return 0; }
int main(int argc, char *argv[]) { CoInitializeEx(nullptr, COINIT_MULTITHREADED); try { audio.open(XAUDIO2_DEBUG_ENGINE); DMSG("open"); Wav wav("D:\\openAL\\11k16bitpcm.wav"); audio.stream(wav.getFormat()); for (int i = 0; i < 2; ++i) { DMSG("submit buffer " << i); uint32_t size = wav.getSize(); audio.appendBuffer(size); wav.read(audio.getBuffer(i), size); audio.submitBuffer(i, size); } wav.close(); DMSG("sleep"); Thread::sleep(10000); DMSG("stop"); audio.stop(); } catch (...) { std::cout << "error" << std::endl; } DMSG("close"); audio.close(); CoUninitialize(); return 0; }
static void audioclose(Chan *c) { Audiochan *ac; Audio *adev; ac = c->aux; adev = ac->adev; if((c->qid.path == Qaudio) && (c->flag & COPEN)){ if(adev->close){ if(!waserror()){ adev->close(adev); poperror(); } } decref(&adev->audioopen); } if(ac->owner == c){ ac->owner = nil; c->aux = nil; free(ac); } }