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 ********************************************************************
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
&&
37 ((a
->matrix
==NULL
&& b
->matrix
==NULL
) ||
38 !strcmp(a
->matrix
,b
->matrix
));
41 audio_device_t
*append_audio_device(audio_device_t
*devices_list
,
43 ao_option
*options
, char *filename
)
45 if (devices_list
!= NULL
) {
46 while (devices_list
->next_device
!= NULL
)
47 devices_list
= devices_list
->next_device
;
48 devices_list
= devices_list
->next_device
=
49 malloc(sizeof(audio_device_t
));
51 devices_list
= (audio_device_t
*) malloc(sizeof(audio_device_t
));
53 devices_list
->driver_id
= driver_id
;
54 devices_list
->options
= options
;
55 devices_list
->filename
= filename
;
56 devices_list
->device
= NULL
;
57 devices_list
->next_device
= NULL
;
63 int audio_devices_write(audio_device_t
*d
, void *ptr
, int nbytes
)
67 if (ao_play(d
->device
, ptr
, nbytes
) == 0)
68 return 0; /* error occurred */
75 int add_ao_option(ao_option
**op_h
, const char *optstring
)
80 key
= strdup(optstring
);
84 value
= strchr(key
, ':');
86 /* split by replacing the separator with a null */
90 result
= ao_append_option(op_h
, key
, value
);
96 void close_audio_devices (audio_device_t
*devices
)
98 audio_device_t
*current
= devices
;
100 while (current
!= NULL
) {
102 ao_close(current
->device
);
103 current
->device
= NULL
;
104 current
= current
->next_device
;
108 void free_audio_devices (audio_device_t
*devices
)
110 audio_device_t
*current
;
112 while (devices
!= NULL
) {
113 current
= devices
->next_device
;
119 void ao_onexit (void *arg
)
121 audio_device_t
*devices
= (audio_device_t
*) arg
;
123 close_audio_devices (devices
);
124 free_audio_devices (devices
);