aboutsummaryrefslogtreecommitdiffstats
path: root/src/output_plugin.h
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-09-16 23:31:48 +0200
committerMax Kellermann <max@duempel.org>2011-09-19 09:41:21 +0200
commit74617389c88ccf630b8cce4b54d9e2fa5afb2259 (patch)
tree3d05faad2c2b3b2e9e885f2c391a35fe8f06553a /src/output_plugin.h
parentb4a8b8c0d4bf82fc56572c3f8e79108d22d78132 (diff)
downloadmpd-74617389c88ccf630b8cce4b54d9e2fa5afb2259.tar.gz
mpd-74617389c88ccf630b8cce4b54d9e2fa5afb2259.tar.xz
mpd-74617389c88ccf630b8cce4b54d9e2fa5afb2259.zip
output_plugin: the plugin allocates the audio_output object
Pass audio_output objects around instead of void pointers. This will give some more control to the plugin, and prepares for non-blocking audio outputs.
Diffstat (limited to '')
-rw-r--r--src/output_plugin.h135
1 files changed, 42 insertions, 93 deletions
diff --git a/src/output_plugin.h b/src/output_plugin.h
index 72b519d13..209ca6221 100644
--- a/src/output_plugin.h
+++ b/src/output_plugin.h
@@ -48,8 +48,6 @@ struct audio_output_plugin {
* Configure and initialize the device, but do not open it
* yet.
*
- * @param audio_format the configured audio format, or NULL if
- * none is configured
* @param param the configuration section, or NULL if there is
* no configuration
* @param error location to store the error occurring, or NULL
@@ -57,14 +55,13 @@ struct audio_output_plugin {
* @return NULL on error, or an opaque pointer to the plugin's
* data
*/
- void *(*init)(const struct audio_format *audio_format,
- const struct config_param *param,
- GError **error);
+ struct audio_output *(*init)(const struct config_param *param,
+ GError **error);
/**
* Free resources allocated by this device.
*/
- void (*finish)(void *data);
+ void (*finish)(struct audio_output *data);
/**
* Enable the device. This may allocate resources, preparing
@@ -76,13 +73,13 @@ struct audio_output_plugin {
* NULL to ignore errors
* @return true on success, false on error
*/
- bool (*enable)(void *data, GError **error_r);
+ bool (*enable)(struct audio_output *data, GError **error_r);
/**
* Disables the device. It is closed before this method is
* called.
*/
- void (*disable)(void *data);
+ void (*disable)(struct audio_output *data);
/**
* Really open the device.
@@ -92,13 +89,13 @@ struct audio_output_plugin {
* @param error location to store the error occurring, or NULL
* to ignore errors
*/
- bool (*open)(void *data, struct audio_format *audio_format,
+ bool (*open)(struct audio_output *data, struct audio_format *audio_format,
GError **error);
/**
* Close the device.
*/
- void (*close)(void *data);
+ void (*close)(struct audio_output *data);
/**
* Returns a positive number if the output thread shall delay
@@ -108,13 +105,13 @@ struct audio_output_plugin {
*
* @return the number of milliseconds to wait
*/
- unsigned (*delay)(void *data);
+ unsigned (*delay)(struct audio_output *data);
/**
* Display metadata for the next chunk. Optional method,
* because not all devices can display metadata.
*/
- void (*send_tag)(void *data, const struct tag *tag);
+ void (*send_tag)(struct audio_output *data, const struct tag *tag);
/**
* Play a chunk of audio data.
@@ -123,19 +120,20 @@ struct audio_output_plugin {
* to ignore errors
* @return the number of bytes played, or 0 on error
*/
- size_t (*play)(void *data, const void *chunk, size_t size,
+ size_t (*play)(struct audio_output *data,
+ const void *chunk, size_t size,
GError **error);
/**
* Wait until the device has finished playing.
*/
- void (*drain)(void *data);
+ void (*drain)(struct audio_output *data);
/**
* Try to cancel data which may still be in the device's
* buffers.
*/
- void (*cancel)(void *data);
+ void (*cancel)(struct audio_output *data);
/**
* Pause the device. If supported, it may perform a special
@@ -148,7 +146,7 @@ struct audio_output_plugin {
* @return false on error (output will be closed then), true
* for continue to pause
*/
- bool (*pause)(void *data);
+ bool (*pause)(struct audio_output *data);
/**
* The mixer plugin associated with this output plugin. This
@@ -167,95 +165,46 @@ ao_plugin_test_default_device(const struct audio_output_plugin *plugin)
: false;
}
-static inline void *
+G_GNUC_MALLOC
+struct audio_output *
ao_plugin_init(const struct audio_output_plugin *plugin,
- const struct audio_format *audio_format,
const struct config_param *param,
- GError **error)
-{
- return plugin->init(audio_format, param, error);
-}
+ GError **error);
-static inline void
-ao_plugin_finish(const struct audio_output_plugin *plugin, void *data)
-{
- plugin->finish(data);
-}
+void
+ao_plugin_finish(struct audio_output *ao);
-static inline bool
-ao_plugin_enable(const struct audio_output_plugin *plugin, void *data,
- GError **error_r)
-{
- return plugin->enable != NULL
- ? plugin->enable(data, error_r)
- : true;
-}
+bool
+ao_plugin_enable(struct audio_output *ao, GError **error_r);
-static inline void
-ao_plugin_disable(const struct audio_output_plugin *plugin, void *data)
-{
- if (plugin->disable != NULL)
- plugin->disable(data);
-}
+void
+ao_plugin_disable(struct audio_output *ao);
-static inline bool
-ao_plugin_open(const struct audio_output_plugin *plugin,
- void *data, struct audio_format *audio_format,
- GError **error)
-{
- return plugin->open(data, audio_format, error);
-}
+bool
+ao_plugin_open(struct audio_output *ao, struct audio_format *audio_format,
+ GError **error);
-static inline void
-ao_plugin_close(const struct audio_output_plugin *plugin, void *data)
-{
- plugin->close(data);
-}
+void
+ao_plugin_close(struct audio_output *ao);
-static inline unsigned
-ao_plugin_delay(const struct audio_output_plugin *plugin, void *data)
-{
- return plugin->delay != NULL
- ? plugin->delay(data)
- : 0;
-}
+G_GNUC_PURE
+unsigned
+ao_plugin_delay(struct audio_output *ao);
-static inline void
-ao_plugin_send_tag(const struct audio_output_plugin *plugin,
- void *data, const struct tag *tag)
-{
- if (plugin->send_tag != NULL)
- plugin->send_tag(data, tag);
-}
+void
+ao_plugin_send_tag(struct audio_output *ao, const struct tag *tag);
-static inline size_t
-ao_plugin_play(const struct audio_output_plugin *plugin,
- void *data, const void *chunk, size_t size,
- GError **error)
-{
- return plugin->play(data, chunk, size, error);
-}
+size_t
+ao_plugin_play(struct audio_output *ao, const void *chunk, size_t size,
+ GError **error);
-static inline void
-ao_plugin_drain(const struct audio_output_plugin *plugin, void *data)
-{
- if (plugin->drain != NULL)
- plugin->drain(data);
-}
+void
+ao_plugin_drain(struct audio_output *ao);
-static inline void
-ao_plugin_cancel(const struct audio_output_plugin *plugin, void *data)
-{
- if (plugin->cancel != NULL)
- plugin->cancel(data);
-}
+void
+ao_plugin_cancel(struct audio_output *ao);
-static inline bool
-ao_plugin_pause(const struct audio_output_plugin *plugin, void *data)
-{
- return plugin->pause != NULL
- ? plugin->pause(data)
- : false;
-}
+bool
+ao_plugin_pause(struct audio_output *ao);
#endif