output: replace audio_output.*Func with audio_output.plugin
Instead of copying all that stuff from the audio output plugin to the audio output structure, store a pointer to the plugin.
This commit is contained in:
parent
3b09c54b67
commit
a0103dd05c
@ -72,11 +72,12 @@ int initAudioOutput(struct audio_output *ao, ConfigParam * param)
|
|||||||
void *data = NULL;
|
void *data = NULL;
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
char *format = NULL;
|
char *format = NULL;
|
||||||
const char *type = NULL;
|
|
||||||
BlockParam *bp = NULL;
|
BlockParam *bp = NULL;
|
||||||
struct audio_output_plugin *plugin = NULL;
|
struct audio_output_plugin *plugin = NULL;
|
||||||
|
|
||||||
if (param) {
|
if (param) {
|
||||||
|
const char *type = NULL;
|
||||||
|
|
||||||
getBlockParam(AUDIO_OUTPUT_NAME, name, 1);
|
getBlockParam(AUDIO_OUTPUT_NAME, name, 1);
|
||||||
getBlockParam(AUDIO_OUTPUT_TYPE, type, 1);
|
getBlockParam(AUDIO_OUTPUT_TYPE, type, 1);
|
||||||
getBlockParam(AUDIO_OUTPUT_FORMAT, format, 0);
|
getBlockParam(AUDIO_OUTPUT_FORMAT, format, 0);
|
||||||
@ -114,17 +115,10 @@ int initAudioOutput(struct audio_output *ao, ConfigParam * param)
|
|||||||
}
|
}
|
||||||
|
|
||||||
name = "default detected output";
|
name = "default detected output";
|
||||||
type = plugin->name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ao->name = name;
|
ao->name = name;
|
||||||
ao->type = type;
|
ao->plugin = plugin;
|
||||||
ao->finishDriverFunc = plugin->finishDriverFunc;
|
|
||||||
ao->openDeviceFunc = plugin->openDeviceFunc;
|
|
||||||
ao->playFunc = plugin->playFunc;
|
|
||||||
ao->dropBufferedAudioFunc = plugin->dropBufferedAudioFunc;
|
|
||||||
ao->closeDeviceFunc = plugin->closeDeviceFunc;
|
|
||||||
ao->sendMetdataFunc = plugin->sendMetdataFunc;
|
|
||||||
ao->open = 0;
|
ao->open = 0;
|
||||||
|
|
||||||
ao->convertAudioFormat = 0;
|
ao->convertAudioFormat = 0;
|
||||||
@ -176,7 +170,7 @@ int openAudioOutput(struct audio_output *audioOutput,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!audioOutput->open)
|
if (!audioOutput->open)
|
||||||
ret = audioOutput->openDeviceFunc(audioOutput);
|
ret = audioOutput->plugin->openDeviceFunc(audioOutput);
|
||||||
|
|
||||||
audioOutput->sameInAndOutFormats =
|
audioOutput->sameInAndOutFormats =
|
||||||
!cmpAudioFormat(&audioOutput->inAudioFormat,
|
!cmpAudioFormat(&audioOutput->inAudioFormat,
|
||||||
@ -220,7 +214,7 @@ int playAudioOutput(struct audio_output *audioOutput,
|
|||||||
convertAudioFormat(audioOutput, &playChunk, &size);
|
convertAudioFormat(audioOutput, &playChunk, &size);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = audioOutput->playFunc(audioOutput, playChunk, size);
|
ret = audioOutput->plugin->playFunc(audioOutput, playChunk, size);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -228,20 +222,20 @@ int playAudioOutput(struct audio_output *audioOutput,
|
|||||||
void dropBufferedAudioOutput(struct audio_output *audioOutput)
|
void dropBufferedAudioOutput(struct audio_output *audioOutput)
|
||||||
{
|
{
|
||||||
if (audioOutput->open)
|
if (audioOutput->open)
|
||||||
audioOutput->dropBufferedAudioFunc(audioOutput);
|
audioOutput->plugin->dropBufferedAudioFunc(audioOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
void closeAudioOutput(struct audio_output *audioOutput)
|
void closeAudioOutput(struct audio_output *audioOutput)
|
||||||
{
|
{
|
||||||
if (audioOutput->open)
|
if (audioOutput->open)
|
||||||
audioOutput->closeDeviceFunc(audioOutput);
|
audioOutput->plugin->closeDeviceFunc(audioOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
void finishAudioOutput(struct audio_output *audioOutput)
|
void finishAudioOutput(struct audio_output *audioOutput)
|
||||||
{
|
{
|
||||||
closeAudioOutput(audioOutput);
|
closeAudioOutput(audioOutput);
|
||||||
if (audioOutput->finishDriverFunc)
|
if (audioOutput->plugin->finishDriverFunc)
|
||||||
audioOutput->finishDriverFunc(audioOutput);
|
audioOutput->plugin->finishDriverFunc(audioOutput);
|
||||||
if (audioOutput->convBuffer)
|
if (audioOutput->convBuffer)
|
||||||
free(audioOutput->convBuffer);
|
free(audioOutput->convBuffer);
|
||||||
}
|
}
|
||||||
@ -249,9 +243,9 @@ void finishAudioOutput(struct audio_output *audioOutput)
|
|||||||
void sendMetadataToAudioOutput(struct audio_output *audioOutput,
|
void sendMetadataToAudioOutput(struct audio_output *audioOutput,
|
||||||
const struct tag *tag)
|
const struct tag *tag)
|
||||||
{
|
{
|
||||||
if (!audioOutput->sendMetdataFunc)
|
if (!audioOutput->plugin->sendMetdataFunc)
|
||||||
return;
|
return;
|
||||||
audioOutput->sendMetdataFunc(audioOutput, tag);
|
audioOutput->plugin->sendMetdataFunc(audioOutput, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
void printAllOutputPluginTypes(FILE * fp)
|
void printAllOutputPluginTypes(FILE * fp)
|
||||||
|
@ -67,14 +67,8 @@ struct audio_output_plugin {
|
|||||||
struct audio_output {
|
struct audio_output {
|
||||||
int open;
|
int open;
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *type;
|
|
||||||
|
|
||||||
AudioOutputFinishDriverFunc finishDriverFunc;
|
const struct audio_output_plugin *plugin;
|
||||||
AudioOutputOpenDeviceFunc openDeviceFunc;
|
|
||||||
AudioOutputPlayFunc playFunc;
|
|
||||||
AudioOutputDropBufferedAudioFunc dropBufferedAudioFunc;
|
|
||||||
AudioOutputCloseDeviceFunc closeDeviceFunc;
|
|
||||||
AudioOutputSendMetadataFunc sendMetdataFunc;
|
|
||||||
|
|
||||||
int convertAudioFormat;
|
int convertAudioFormat;
|
||||||
struct audio_format inAudioFormat;
|
struct audio_format inAudioFormat;
|
||||||
|
Loading…
Reference in New Issue
Block a user