File: null_out.c

package info (click to toggle)
moc 1%3A2.5.0~alpha3%2Bsvn20080629-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,832 kB
  • ctags: 2,829
  • sloc: ansic: 28,929; sh: 4,988; cpp: 523; makefile: 229
file content (98 lines) | stat: -rw-r--r-- 1,841 bytes parent folder | download | duplicates (2)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
 * MOC - music on console
 * Copyright (C) 2004 Damian Pietras <daper@daper.net>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 */

/* Fake output device - only for testing. */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <unistd.h>

#include "audio.h"
#include "common.h"

static struct sound_params params = { 0, 0, 0 };

 
static int null_open (struct sound_params *sound_params)
{
	params = *sound_params;
	return 1;
}

static void null_close ()
{
	params.rate = 0;
}

static int null_play (const char *buff ATTR_UNUSED, const size_t size)
{
	usleep (size * 1000000.0 / audio_get_bps(params.fmt));
	return size;
}

static int null_read_mixer ()
{
	return 100;
}

static void null_set_mixer (int vol ATTR_UNUSED)
{
}

static int null_get_buff_fill ()
{
	return 0;
}

static int null_reset ()
{
	return 1;
}

static int null_init (struct output_driver_caps *caps)
{
	caps->formats = SFMT_S8 | SFMT_S16 | SFMT_LE;
	caps->min_channels = 1;
	caps->max_channels = 2;

	return 1;
}

static int null_get_rate ()
{
	return params.rate;
}

static void null_toggle_mixer_channel ()
{
}

static char *null_get_mixer_channel_name ()
{
	return xstrdup ("FakeMixer");
}

void null_funcs (struct hw_funcs *funcs)
{
	funcs->init = null_init;
	funcs->open = null_open;
	funcs->close = null_close;
	funcs->play = null_play;
	funcs->read_mixer = null_read_mixer;
	funcs->set_mixer = null_set_mixer;
	funcs->get_buff_fill = null_get_buff_fill;
	funcs->reset = null_reset;
	funcs->get_rate = null_get_rate;
	funcs->toggle_mixer_channel = null_toggle_mixer_channel;
	funcs->get_mixer_channel_name = null_get_mixer_channel_name;
}