# HG changeset patch # User Eris Caffee # Date 1427318710 18000 # Node ID cf38ffea8defb1b3cb9d791abe467ed71b33f7e4 # Parent 65c716ba7cda357ef3a1c2742a9bd1fef20d09a8 Added AODevice and AODriver. Renamed AOOptions.cpp file. diff -r 65c716ba7cda -r cf38ffea8def src/AODevice.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/AODevice.cpp Wed Mar 25 16:25:10 2015 -0500 @@ -0,0 +1,13 @@ +#include "aopp.hpp" + +AOPP::AODevice::AODevice( ao_device * dev ) : + device (dev) { + } + +int AOPP::AODevice::play( char *output_samples, uint32_t num_bytes ) { + return ao_play( device, output_samples, num_bytes ); + } + +int AOPP::AODevice::close( void ) { + return ao_close( device ); + } diff -r 65c716ba7cda -r cf38ffea8def src/AODriver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/AODriver.cpp Wed Mar 25 16:25:10 2015 -0500 @@ -0,0 +1,52 @@ +#include "aopp.hpp" + +using namespace AOPP; + +AODriver::AODriver( int id ) : + driver_id (id) { + } + +AOInfo * AODriver::driver_info( void ) { + return ao_driver_info( driver_id ); + } + +#if 0 +// ao_file_extension not in my libao ? +const char * AODriver::file_extension( void ) { + return ao_file_extension( driver_id ); + } +#endif + +AODevice * AODriver::open_file( const char *filename, int overwrite, AOSampleFormat *format, AOOptions *options ) { + ao_device * dev = ao_open_file( + driver_id, + filename, + overwrite, + static_cast (format), + options->options + ); + if ( dev ) { + AODevice *d; + *d = AODevice( dev ); + return d; + } + return NULL; + } + +AODevice * AODriver::open_live( AOSampleFormat *format, AOOptions *options ) { + ao_device * dev = ao_open_live( + driver_id, + static_cast (format), + options->options + ); + if ( dev ) { + AODevice *d; + *d = AODevice( dev ); + return d; + } + return NULL; + } + +int AODriver::get_driver_id( const char *short_name ) { + return ao_driver_id( short_name ); + } diff -r 65c716ba7cda -r cf38ffea8def src/AOOption.cpp --- a/src/AOOption.cpp Wed Mar 25 12:21:35 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -#include "aopp.hpp" -#include - -AOPP::AOOptions::AOOptions() : - options (NULL) - { - } - -AOPP::AOOptions::~AOOptions() { - if ( options ) { - ao_free_options( options ); - } - } - - -int AOPP::AOOptions::append( const char *key, const char *value ) { - if ( key && value ) { - return ao_append_option( &options, key, value ); - } - return 0; - } - - -void AOPP::AOOptions::print_options(void) { - ao_option * opt = options; - while ( opt ) { - printf("%s\t\t%s\n", opt->key, opt->value); - opt = opt->next; - } - } diff -r 65c716ba7cda -r cf38ffea8def src/AOOptions.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/AOOptions.cpp Wed Mar 25 16:25:10 2015 -0500 @@ -0,0 +1,30 @@ +#include "aopp.hpp" +#include + +AOPP::AOOptions::AOOptions() : + options (NULL) + { + } + +AOPP::AOOptions::~AOOptions() { + if ( options ) { + ao_free_options( options ); + } + } + + +int AOPP::AOOptions::append( const char *key, const char *value ) { + if ( key && value ) { + return ao_append_option( &options, key, value ); + } + return 0; + } + + +void AOPP::AOOptions::print_options(void) { + ao_option * opt = options; + while ( opt ) { + printf("%s\t\t%s\n", opt->key, opt->value); + opt = opt->next; + } + } diff -r 65c716ba7cda -r cf38ffea8def src/aopp.hpp --- a/src/aopp.hpp Wed Mar 25 12:21:35 2015 -0500 +++ b/src/aopp.hpp Wed Mar 25 16:25:10 2015 -0500 @@ -2,6 +2,7 @@ #define __AOPP_H__ #include "ao/ao.h" +#include namespace AOPP { @@ -10,6 +11,8 @@ //////////////////////////////////////////////////////////////////////////// class AOOptions { + friend class AODriver; + public: AOOptions(); ~AOOptions(); @@ -22,6 +25,37 @@ }; + //////////////////////////////////////////////////////////////////////////// + class AODevice { + public: + AODevice( ao_device * dev ); + int play( char *output_samples, uint32_t num_bytes ); + int close( void ); + + private: + AODevice(); + ao_device *device; + }; + + //////////////////////////////////////////////////////////////////////////// + class AODriver { + public: + AODriver( int id ); + AODevice * open_live( AOSampleFormat *format, AOOptions *options ); + AODevice * open_file( const char *filename, int overwrite, AOSampleFormat *format, AOOptions *options ); + AOInfo * driver_info( void ); +#if 0 +// ao_file_extension not in my libao ? + const char * file_extension( void ); +#endif + + static int get_driver_id( const char *short_name ); + + private: + AODriver(); + int driver_id; + }; + } #endif