MCPcopy Create free account
hub / github.com/HackerPoet/FractalSoundExplorer / play

Method play

WinAudio.cpp:32–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32bool WinAudio::play() {
33 MMRESULT result;
34 CHAR fault[256];
35
36 //Create a mutex
37 m_Mutex = CreateMutex(NULL, FALSE, NULL);
38 if (m_Mutex == NULL) {
39 std::cout << "Mutex failed.";
40 return false;
41 }
42
43 //Open the audio driver
44 m_IsReleasing = false;
45 result = waveOutOpen(&m_HWaveOut, WAVE_MAPPER, &m_Format, (DWORD_PTR)Callback, NULL, CALLBACK_FUNCTION);
46 if (result != MMSYSERR_NOERROR) {
47 waveInGetErrorText(result, fault, 256);
48 std::cout << fault << std::endl;
49 return false;
50 }
51
52 // Set up and prepare header for output
53 for (int i = 0; i < NUM_AUDIO_BUFFS; i++) {
54 memset(m_WaveOut[i], 0, AUDIO_BUFF_SIZE * sizeof(int16_t));
55 memset(&m_WaveOutHdr[i], 0, sizeof(WAVEHDR));
56 m_WaveOutHdr[i].lpData = (LPSTR)m_WaveOut[i];
57 m_WaveOutHdr[i].dwBufferLength = AUDIO_BUFF_SIZE * sizeof(int16_t);
58 result = waveOutPrepareHeader(m_HWaveOut, &m_WaveOutHdr[i], sizeof(WAVEHDR));
59 if (result != MMSYSERR_NOERROR) {
60 waveInGetErrorText(result, fault, 256);
61 std::cout << fault << std::endl;
62 }
63 }
64
65 SubmitBuffer();
66 SubmitBuffer();
67 return true;
68}
69
70bool WinAudio::stop() {
71 MMRESULT result;

Callers 1

mainFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected