summaryrefslogtreecommitdiffstats
path: root/bin/snd-pcm-open.c
blob: abda2864c1847da446553183453726e58e1aec72 (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
#include <alsa/asoundlib.h>
#include <stdio.h>
#include <stdlib.h>

int
main(int argc __attribute__((__unused__)),
		char *argv[] __attribute__((__unused__)))
{
	int        e;
	snd_pcm_t *pcm;

	e = snd_pcm_open(&pcm, "default", SND_PCM_STREAM_PLAYBACK, 0);
	if (e < 0) {
		fprintf(stderr, "Failed to open PCM: %s\n", snd_strerror(e));
		return EXIT_FAILURE;
	}

	pause();

	e = snd_pcm_close(pcm);
	if (e < 0) {
		fprintf(stderr, "Failed to close PCM: %s\n", snd_strerror(e));
		return EXIT_FAILURE;
	}

	return EXIT_SUCCESS;
}