1 /********************************************************************
3 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
5 * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
6 * PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * THE Ogg123 SOURCE CODE IS (C) COPYRIGHT 2000-2001 *
9 * by Stan Seibert <volsung@xiph.org> AND OTHER CONTRIBUTORS *
10 * http://www.xiph.org/ *
12 ********************************************************************
14 last mod: $Id: audio.c,v 1.2 2001/12/19 02:52:53 volsung Exp $
16 ********************************************************************/
29 int audio_format_equal (audio_format_t
*a
, audio_format_t
*b
)
32 a
->big_endian
== b
->big_endian
&&
33 a
->word_size
== b
->word_size
&&
34 a
->signed_sample
== b
->signed_sample
&&
36 a
->channels
== b
->channels
;
40 audio_device_t
*append_audio_device(audio_device_t
*devices_list
,
42 ao_option
*options
, char *filename
)
44 audio_device_t
*head
= devices_list
;
46 if (devices_list
!= NULL
) {
47 while (devices_list
->next_device
!= NULL
)
48 devices_list
= devices_list
->next_device
;
49 devices_list
= devices_list
->next_device
=
50 malloc(sizeof(audio_device_t
));
52 head
= devices_list
= (audio_device_t
*) malloc(sizeof(audio_device_t
));
54 devices_list
->driver_id
= driver_id
;
55 devices_list
->options
= options
;
56 devices_list
->filename
= filename
;
57 devices_list
->device
= NULL
;
58 devices_list
->next_device
= NULL
;
64 int audio_devices_write(audio_device_t
*d
, void *ptr
, int nbytes
)
68 if (ao_play(d
->device
, ptr
, nbytes
) == 0)
69 return 0; /* error occurred */
76 int add_ao_option(ao_option
**op_h
, const char *optstring
)
81 key
= strdup(optstring
);
85 value
= strchr(key
, ':');
91 /* split by replacing the separator with a null */
94 result
= ao_append_option(op_h
, key
, value
);
100 void close_audio_devices (audio_device_t
*devices
)
102 audio_device_t
*current
= devices
;
104 while (current
!= NULL
) {
106 ao_close(current
->device
);
107 current
->device
= NULL
;
108 current
= current
->next_device
;
112 void free_audio_devices (audio_device_t
*devices
)
114 audio_device_t
*current
;
116 while (devices
!= NULL
) {
117 current
= devices
->next_device
;
123 void ao_onexit (void *arg
)
125 audio_device_t
*devices
= (audio_device_t
*) arg
;
127 close_audio_devices (devices
);
128 free_audio_devices (devices
);