1 /* MMQ_AO_IMPL should be defined by the Makefile */
3 # error MMQ_AO_IMPL not defined
7 struct afmt g_next_afmt
;
8 static struct afmt current
;
9 unsigned long g_sample_size
;
11 static int matches_current(void)
13 /* no using memcmp because of potential padding */
14 return ((g_next_afmt
.rate
== current
.rate
) &&
15 (g_next_afmt
.bits
== current
.bits
) &&
16 (g_next_afmt
.channels
== current
.channels
));
19 /* this should statically define _my_open, _my_close */
26 if (matches_current())
28 if (g_next_afmt
.channels
!= 2) {
29 warn("only 2 channel output is supported for now\n");
35 rv
= _my_open(&g_next_afmt
);
37 warn("ao_open failed\n");
40 memcpy(¤t
, &g_next_afmt
, sizeof(struct afmt
));
42 current
.rate
, current
.bits
, current
.channels
);
48 void audio_close(int graceful
)
51 memset(¤t
, 0, sizeof(struct afmt
));
54 int audio_inject(void *buf
, long samples
, conv_fn conv_i
)
56 if (likely(g_state
== STATE_PLAY
))
57 return _my_inject(buf
, samples
, conv_i
);
62 long audio_copy(void *dst
, void *src
, long samples
, long offset
)
64 src
= (char *)src
+ (offset
* g_sample_size
);
65 memcpy(dst
, src
, samples
* g_sample_size
);