[outputs] Reorganise new generic output interface

This commit is contained in:
ejurgensen 2016-01-24 22:19:15 +01:00
parent 233fa24ffd
commit cd841ad7b5
2 changed files with 42 additions and 26 deletions

View File

@ -31,31 +31,37 @@
#include "logger.h"
#include "outputs.h"
/*#ifdef ALSA
extern audio_output output_alsa;
#endif
#ifdef OSS4
extern audio_output output_oss4;
#endif
extern struct output_definition output_dummy;*/
extern struct output_definition output_raop;
#ifdef CHROMECAST
extern struct output_definition output_cast;
#endif
/* TODO
extern struct output_definition output_streaming;
#ifdef ALSA
extern struct output_definition output_alsa;
#endif
#ifdef OSS4
extern struct output_definition output_oss4;
#endif
extern struct output_definition output_dummy;
*/
// Must be in sync with enum output_types
static struct output_definition *outputs[] = {
/*#ifdef ALSA
&output_raop,
#ifdef CHROMECAST
&output_cast,
#endif
/* TODO
&output_streaming,
#ifdef ALSA
&output_alsa,
#endif
#ifdef OSS4
&output_oss4,
#endif
&output_dummy,*/
&output_raop,
#ifdef CHROMECAST
&output_cast,
#endif
&output_dummy,
*/
NULL
};
@ -327,6 +333,12 @@ outputs_init(void)
no_output = 1;
for (i = 0; outputs[i]; i++)
{
if (outputs[i]->type != i)
{
DPRINTF(E_FATAL, L_PLAYER, "BUG! Output definitions are misaligned with output enum\n");
return -1;
}
ret = outputs[i]->init();
if (ret < 0)
outputs[i]->disabled = 1;

View File

@ -16,46 +16,50 @@
*
*/
// Must be in sync with outputs[] in outputs.c
enum output_types
{
/* OUTPUT_TYPE_ALSA,
OUTPUT_TYPE_OSS,
OUTPUT_TYPE_DUMMY,*/
OUTPUT_TYPE_RAOP,
#ifdef CHROMECAST
OUTPUT_TYPE_CAST,
#endif
/* TODO
OUTPUT_TYPE_STREAMING,
OUTPUT_TYPE_ALSA,
OUTPUT_TYPE_OSS,
OUTPUT_TYPE_DUMMY,
*/
};
/* Output session state */
/* Session is starting up */
// Session is starting up
#define OUTPUT_STATE_F_STARTUP (1 << 15)
/* Streaming is up (connection established) */
// Streaming is up (connection established)
#define OUTPUT_STATE_F_CONNECTED (1 << 16)
enum output_device_state
{
OUTPUT_STATE_STOPPED = 0,
/* Session startup */
// Session startup
// TODO Make this less RAOP-specific
OUTPUT_STATE_OPTIONS = OUTPUT_STATE_F_STARTUP | 0x01,
OUTPUT_STATE_ANNOUNCE = OUTPUT_STATE_F_STARTUP | 0x02,
OUTPUT_STATE_SETUP = OUTPUT_STATE_F_STARTUP | 0x03,
OUTPUT_STATE_RECORD = OUTPUT_STATE_F_STARTUP | 0x04,
/* Session established
* - streaming ready (RECORD sent and acked, connection established)
* - commands (SET_PARAMETER) are possible
*/
// Session established
// - streaming ready (RECORD sent and acked, connection established)
// - commands (SET_PARAMETER) are possible
OUTPUT_STATE_CONNECTED = OUTPUT_STATE_F_CONNECTED,
/* Audio data is being sent */
// Audio data is being sent
OUTPUT_STATE_STREAMING = OUTPUT_STATE_F_CONNECTED | 0x01,
/* Session is failed, couldn't startup or error occurred */
// Session is failed, couldn't startup or error occurred
OUTPUT_STATE_FAILED = -1,
/* Password issue: unknown password or bad password */
// Password issue: unknown password or bad password
OUTPUT_STATE_PASSWORD = -2,
};