aboutsummaryrefslogtreecommitdiff
path: root/shell/audio/portaudio/sound_output.c
blob: 0c03c938fe382e22cf1471850d4ec4629994488d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <portaudio.h>
#include <stdint.h>
#include <stdio.h>

#include "shared.h"

static PaStream *apu_stream;

uint32_t Audio_Init()
{
	Pa_Initialize();
	
	PaStreamParameters outputParameters;
	
	outputParameters.device = Pa_GetDefaultOutputDevice();
	
	if (outputParameters.device == paNoDevice) 
	{
		printf("No sound output\n");
		return 1;
	}

	outputParameters.channelCount = 2;
	outputParameters.sampleFormat = paInt16;
	outputParameters.hostApiSpecificStreamInfo = NULL;
	
	Pa_OpenStream( &apu_stream, NULL, &outputParameters, SOUND_OUTPUT_FREQUENCY, SOUND_SAMPLES_SIZE, paNoFlag, NULL, NULL);
	Pa_StartStream( apu_stream );
	
	return 0;
}

void Audio_Write(int16_t* restrict buffer, uint32_t buffer_size)
{
	Pa_WriteStream( apu_stream, buffer, buffer_size);
}

bool Audio_Underrun_Likely() {
	return false;
}

void Audio_Close()
{
	//Pa_Close();
}