Skip to content

Commit

Permalink
Added basic support to set audio output device in windows seven.
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Apr 19, 2011
1 parent f77b831 commit 537d953
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions hairtunes.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ int fmtp[32];
int sampling_rate;
int frame_size;

//Audio Device/driver variables
// Max num of chars " " - 32 character string, 1 reserved for null
char *audiodevice = "Speakers (Realtek High Definiti";
char *audiodriver = "wmm";
char *audiodeviceid = 0;

// FIFO name and file handle
char *pipename = 0;
int pipe_handle = -1;
Expand Down Expand Up @@ -740,16 +746,31 @@ void init_pipe(char* pipe) {
void* init_ao() {
ao_initialize();
int driver = ao_default_driver_id();

ao_sample_format fmt;
memset(&fmt, 0, sizeof(fmt));

ao_option aoo;
ao_option *ao_opts=0;
memset(&fmt, 0, sizeof(fmt));

fmt.bits = 16;
fmt.rate = sampling_rate;
fmt.channels = NUM_CHANNELS;
fmt.byte_format = AO_FMT_NATIVE;

ao_device *dev = ao_open_live(driver, &fmt, 0);
fmt.byte_format = AO_FMT_LITTLE;

if(audiodriver!=0){
driver = ao_driver_id(audiodriver);
}
if(audiodeviceid!=0){
aoo.key="id";
aoo.value=audiodeviceid;
aoo.next=NULL;
ao_opts=&aoo;
} else if(audiodevice!=0){
aoo.key="dev";
aoo.value=audiodevice;
aoo.next=NULL;
ao_opts=&aoo;
}
ao_device *dev = ao_open_live(driver, &fmt, ao_opts);
return dev;
}

Expand Down

0 comments on commit 537d953

Please sign in to comment.