42 using namespace Nsound;
112 std::stringstream ss;
114 ss <<
"libao Driver Info:" << endl
115 <<
" type: " << info->type << endl
116 <<
" name: " << info->name << endl
117 <<
" short_name: " << info->short_name << endl
118 <<
" comment: " << info->comment << endl
119 <<
" preferred_byte_format: ";
121 switch(info->preferred_byte_format)
124 ss <<
"Little Endian" << endl;
128 ss <<
"Big Endian" << endl;
133 if(ao_is_big_endian())
135 ss <<
"Native Big Endian" << endl;
139 ss <<
"Native Little Endian" << endl;
144 ss <<
"Unknown!" << endl;
148 ss <<
" priority: " << info->priority << endl
149 <<
" option count: " << info->option_count << endl;
151 for(
int32 i = 0; i < info->option_count; ++i)
153 ss <<
" options[" << i <<
"]: " << info->options[i] << endl;
165 M_THROW(
"Nsound::AudioBackendLibao::getInfo():"
166 <<
": Nsound was not compiled with libao support.\n");
171 return "Nsound::AudioBackendLibao::getInfo(): "
172 "Backend not initialized yet";
183 return "Nsound::AudioBackendLibao::getInfo(): "
184 "ao_driver_info() failed";
197 M_THROW(
"Nsound::AudioBackendLibao::initialize():"
198 <<
": Nsound was not compiled with libao support.\n");
227 ao_sample_format format;
229 memset(&format, 0,
sizeof(ao_sample_format));
235 #ifdef NSOUND_LITTLE_ENDIAN
236 format.byte_format = AO_FMT_LITTLE;
238 format.byte_format = AO_FMT_BIG;
273 ao_option * options = NULL;
281 for(
uint32 i = 0; i < n_options; i += 2)
283 ecode = ao_append_option(
293 <<
"Nsound::AudioBackendLibao::initialize():"
295 <<
": error appending libao '"
311 ao_free_options(options);
318 <<
"Nsound::AudioBackendLibao::initialize():"
320 <<
": ao_open_live() failed:"
327 <<
"No driver corresponds to driver_id ("
335 <<
"This driver is not a live output device"
341 <<
"A valid option key has an invalid value"
347 <<
"Cannot open the device (for example, if "
348 <<
"/dev/dsp cannot be opened for writing)"
354 <<
"Any other cause of failure"
380 M_THROW(
"Nsound::AudioBackendLibao::play():"
381 <<
": Nsound was not compiled with libao support.\n");
398 <<
"AudioBackendLibao::play():"
412 reinterpret_cast<char *>(data),
423 <<
"AudioBackendLibao::play():"
425 <<
": ao_play() failed"
438 std::stringstream ss(x);
446 M_THROW(
"Nsound::AudioBackendLibao::setOption():"
447 <<
": could not convert '"
449 <<
"' to an integer.\n");
461 std::transform(y.begin(), y.end(), y.begin(), ::tolower);
479 cout <<
"Libao: found driver '"
483 <<
"\nPLAYBACK STARTING ...";
488 cout <<
" STOPPED\n";
498 setOption(
const std::string & key,
const std::string & value)
502 M_THROW(
"Nsound::AudioBackendLibao::setOption():"
503 <<
": Nsound was not compiled with libao support.\n");
507 std::string k =
lower(key);
518 int32 id = ao_driver_id(value.c_str());
520 cerr <<
"key = 'driver', value = '"
534 M_THROW(
"Nsound::AudioBackendLibao::setOption():"
535 <<
": failed to select driver '"
555 M_THROW(
"Nsound::AudioBackendLibao::shutdown():"
556 <<
": Nsound was not compiled with libao support.\n");
AudioBackendLibao(uint32 sample_rate=44100, uint32 channels=1, uint32 bits_per_sample=16)
static int32 integer(const std::string &x, Nsound::AudioBackend::State *state)
AudioBackendType getBackendType()
static std::string lower(const std::string &x)
std::vector< std::string > options_
const char * KSDATAFORMAT_SUBTYPE_PCM
void setOption(const std::string &key, const std::string &value)
Set libao options.
void scanDevices(AudioPlayback &pb, const AudioStream &test_clip)
std::string print_info(ao_info *info)
const uint32 N_DRIVER_TYPES
void play(void *data, uint32 n_bytes)
std::string driver_types[N_DRIVER_TYPES]
std::stringstream error_buffer_
void play(const AudioStream &a)
Plays the AudioStream throuh the backend.