some small cleanups
git-svn-id: https://svn.musicpd.org/mpd/trunk@2280 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
f4d75d7596
commit
fd2ae556a2
16
src/audio.c
16
src/audio.c
@ -136,18 +136,15 @@ void finishAudioDriver() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int isCurrentAudioFormat(AudioFormat * audioFormat) {
|
int isCurrentAudioFormat(AudioFormat * audioFormat) {
|
||||||
if(!aoOutput || !audioFormat) return 0;
|
if(!audioFormat) return 0;
|
||||||
|
|
||||||
if(memcmp(audioFormat,&audio_format,sizeof(AudioFormat)) != 0) return 0;
|
if(memcmp(audioFormat,&audio_format,sizeof(AudioFormat)) != 0) return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int openAudioDevice(AudioFormat * audioFormat) {
|
int openAudioDevice(AudioFormat * audioFormat) {
|
||||||
if(aoOutput->open && !isCurrentAudioFormat(audioFormat)) {
|
if(!aoOutput->open || !isCurrentAudioFormat(audioFormat)) {
|
||||||
closeAudioOutput(aoOutput);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!aoOutput->open) {
|
|
||||||
return openAudioOutput(aoOutput, audioFormat);
|
return openAudioOutput(aoOutput, audioFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,11 +152,6 @@ int openAudioDevice(AudioFormat * audioFormat) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int playAudio(char * playChunk, int size) {
|
int playAudio(char * playChunk, int size) {
|
||||||
if(!aoOutput->open) {
|
|
||||||
ERROR("trying to play w/o the audio device being open!\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return playAudioOutput(aoOutput, playChunk, size);
|
return playAudioOutput(aoOutput, playChunk, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +160,5 @@ int isAudioDeviceOpen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void closeAudioDevice() {
|
void closeAudioDevice() {
|
||||||
if(aoOutput->open) {
|
|
||||||
closeAudioOutput(aoOutput);
|
closeAudioOutput(aoOutput);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -41,18 +41,21 @@ AudioOutput * newAudioOutput(char * name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int openAudioOutput(AudioOutput * audioOutput, AudioFormat * audioFormat) {
|
int openAudioOutput(AudioOutput * audioOutput, AudioFormat * audioFormat) {
|
||||||
|
if(audioOutput->open) closeAudioOutput(audioOutput);
|
||||||
return audioOutput->openDeviceFunc(audioOutput, audioFormat);
|
return audioOutput->openDeviceFunc(audioOutput, audioFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
int playAudioOutput(AudioOutput * audioOutput, char * playChunk, int size) {
|
int playAudioOutput(AudioOutput * audioOutput, char * playChunk, int size) {
|
||||||
|
if(!audioOutput->open) return -1;
|
||||||
return audioOutput->playFunc(audioOutput, playChunk, size);
|
return audioOutput->playFunc(audioOutput, playChunk, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void closeAudioOutput(AudioOutput * audioOutput) {
|
void closeAudioOutput(AudioOutput * audioOutput) {
|
||||||
audioOutput->closeDeviceFunc(audioOutput);
|
if(audioOutput->open) audioOutput->closeDeviceFunc(audioOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
void finishAudioOutput(AudioOutput * audioOutput) {
|
void finishAudioOutput(AudioOutput * audioOutput) {
|
||||||
|
closeAudioOutput(audioOutput);
|
||||||
audioOutput->finishDriverFunc(audioOutput);
|
audioOutput->finishDriverFunc(audioOutput);
|
||||||
free(audioOutput);
|
free(audioOutput);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user