summaryrefslogtreecommitdiff
path: root/drivers/ao/audio_driver_ao.cpp
diff options
context:
space:
mode:
authorAnton Yabchinskiy <arn@bestmx.ru>2014-11-22 02:58:32 +0300
committerAnton Yabchinskiy <arn@bestmx.ru>2014-11-22 13:38:11 +0300
commit2f92e2a67ad3fcd98ccff4482fdb75cd6eb33be3 (patch)
tree66fc12b9370cfa4d35650993d0a54248b70eb3f7 /drivers/ao/audio_driver_ao.cpp
parent9fb49e56a4bead2651abb8a86652715902aa493f (diff)
Open/close libao audio device
Diffstat (limited to 'drivers/ao/audio_driver_ao.cpp')
-rw-r--r--drivers/ao/audio_driver_ao.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/ao/audio_driver_ao.cpp b/drivers/ao/audio_driver_ao.cpp
index 29c90b5bdf..d143b4aa6e 100644
--- a/drivers/ao/audio_driver_ao.cpp
+++ b/drivers/ao/audio_driver_ao.cpp
@@ -43,6 +43,17 @@ Error AudioDriverAO::init() {
output_format = OUTPUT_STEREO;
channels = 2;
+ ao_sample_format format;
+
+ format.bits = 16;
+ format.rate = mix_rate;
+ format.channels = channels;
+ format.byte_format = AO_FMT_LITTLE;
+ format.matrix = "L,R";
+
+ device = ao_open_live(ao_default_driver_id(), &format, 0);
+ ERR_FAIL_COND_V(device == 0, ERR_CANT_OPEN);
+
int latency = GLOBAL_DEF("audio/output_latency",25);
buffer_size = nearest_power_of_2( latency * mix_rate / 1000 );
@@ -114,6 +125,10 @@ void AudioDriverAO::finish() {
memdelete(thread);
if (mutex)
memdelete(mutex);
+
+ if (device)
+ ao_close(device);
+
thread = NULL;
};