aboutsummaryrefslogtreecommitdiffstats
path: root/src/audio.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-02-27 23:13:26 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-02-27 23:13:26 +0000
commit821355361ccf360cd1867278178bc6fb32d8abab (patch)
tree609ba1ab13344fba8f9f136c3bf1780be3ef13a5 /src/audio.c
parent5622edbc98f55852bc079a50690137232fbd82a1 (diff)
downloadmpd-821355361ccf360cd1867278178bc6fb32d8abab.tar.gz
mpd-821355361ccf360cd1867278178bc6fb32d8abab.tar.xz
mpd-821355361ccf360cd1867278178bc6fb32d8abab.zip
audio cleanups
git-svn-id: https://svn.musicpd.org/mpd/trunk@109 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/audio.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/audio.c b/src/audio.c
index d1f8d863c..d8abc5648 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -131,12 +131,11 @@ int isCurrentAudioFormat(AudioFormat * audioFormat) {
int initAudio(AudioFormat * audioFormat) {
ao_sample_format format;
- if(!audio_device) {
- if(!isCurrentAudioFormat(audioFormat)) {
- finishAudio();
- return 0;
- }
+ if(audio_device && !isCurrentAudioFormat(audioFormat)) {
+ finishAudio();
+ }
+ if(!audio_device) {
format.bits = audioFormat->bits;
format.rate = audioFormat->sampleRate;
format.byte_format = AO_FMT_NATIVE;
@@ -157,24 +156,29 @@ int initAudio(AudioFormat * audioFormat) {
}
-void playAudio(char * playChunk, int size) {
+int playAudio(char * playChunk, int size) {
int send;
- if(audio_device==NULL) return 0;
+ if(audio_device==NULL) {
+ ERROR("trying to play w/ the audio device being open!\n");
+ return -1;
+ }
while(size>0) {
send = audio_write_size>size?size:audio_write_size;
- if(!ao_play(audio_device,playChunk,send)) {
+ if(ao_play(audio_device,playChunk,send)==0) {
audioError();
ERROR("closing audio device due to write error\n");
finishAudio();
- return;
+ return -1;
}
playChunk+=send;
size-=send;
}
+
+ return 0;
}
void finishAudio() {