win32_output: renamed win32 output plugin to winmm
Win32 has many audio APIs. New name is slightly more correct.
This commit is contained in:
		@@ -736,8 +736,8 @@ if ENABLE_SOLARIS_OUTPUT
 | 
			
		||||
OUTPUT_SRC += src/output/solaris_output_plugin.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
if ENABLE_WIN32_OUTPUT
 | 
			
		||||
OUTPUT_SRC += src/output/win32_output_plugin.c
 | 
			
		||||
if ENABLE_WINMM_OUTPUT
 | 
			
		||||
OUTPUT_SRC += src/output/winmm_output_plugin.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										14
									
								
								configure.ac
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								configure.ac
									
									
									
									
									
								
							@@ -1375,21 +1375,21 @@ esac
 | 
			
		||||
 | 
			
		||||
AM_CONDITIONAL(ENABLE_SOLARIS_OUTPUT, test x$enable_solaris_output = xyes)
 | 
			
		||||
 | 
			
		||||
dnl --------------------------------- Solaris ---------------------------------
 | 
			
		||||
dnl --------------------------------- WinMM ---------------------------------
 | 
			
		||||
 | 
			
		||||
case "$host_os" in
 | 
			
		||||
	mingw32* | windows*)
 | 
			
		||||
		AC_DEFINE(ENABLE_WIN32_OUTPUT, 1, [Define to enable WIN32 wave support])
 | 
			
		||||
		enable_win32_output=yes
 | 
			
		||||
		AC_DEFINE(ENABLE_WINMM_OUTPUT, 1, [Define to enable WinMM support])
 | 
			
		||||
		enable_winmm_output=yes
 | 
			
		||||
		MPD_LIBS="$MPD_LIBS -lwinmm"
 | 
			
		||||
		;;
 | 
			
		||||
 | 
			
		||||
	*)
 | 
			
		||||
		enable_win32_output=no
 | 
			
		||||
		enable_winmm_output=no
 | 
			
		||||
		;;
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
AM_CONDITIONAL(ENABLE_WIN32_OUTPUT, test x$enable_win32_output = xyes)
 | 
			
		||||
AM_CONDITIONAL(ENABLE_WINMM_OUTPUT, test x$enable_winmm_output = xyes)
 | 
			
		||||
 | 
			
		||||
dnl --------------------- Post Audio Output Plugins Tests ---------------------
 | 
			
		||||
if
 | 
			
		||||
@@ -1407,7 +1407,7 @@ if
 | 
			
		||||
	test x$enable_recorder_output = xno &&
 | 
			
		||||
	test x$enable_shout = xno &&
 | 
			
		||||
	test x$enable_solaris_output = xno &&
 | 
			
		||||
	test x$enable_win32_output = xno &&
 | 
			
		||||
	test x$enable_winmm_output = xno &&
 | 
			
		||||
 | 
			
		||||
		AC_MSG_ERROR([No Audio Output types configured!])
 | 
			
		||||
fi
 | 
			
		||||
@@ -1544,7 +1544,7 @@ results(mvp, [Media MVP])
 | 
			
		||||
results(shout, [SHOUTcast])
 | 
			
		||||
echo -ne '\n\t'
 | 
			
		||||
results(solaris, [Solaris])
 | 
			
		||||
results(win32_output, [WIN32 wave])
 | 
			
		||||
results(winmm_output, [WinMM])
 | 
			
		||||
 | 
			
		||||
if
 | 
			
		||||
	test x$enable_shout = xyes ||
 | 
			
		||||
 
 | 
			
		||||
@@ -24,15 +24,15 @@
 | 
			
		||||
#include <windows.h>
 | 
			
		||||
 | 
			
		||||
#undef G_LOG_DOMAIN
 | 
			
		||||
#define G_LOG_DOMAIN "win32_output"
 | 
			
		||||
#define G_LOG_DOMAIN "winmm_output"
 | 
			
		||||
 | 
			
		||||
struct win32_buffer {
 | 
			
		||||
struct winmm_buffer {
 | 
			
		||||
	struct pcm_buffer buffer;
 | 
			
		||||
 | 
			
		||||
	WAVEHDR hdr;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct win32_output {
 | 
			
		||||
struct winmm_output {
 | 
			
		||||
	HWAVEOUT handle;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
@@ -41,7 +41,7 @@ struct win32_output {
 | 
			
		||||
	 */
 | 
			
		||||
	HANDLE event;
 | 
			
		||||
 | 
			
		||||
	struct win32_buffer buffers[8];
 | 
			
		||||
	struct winmm_buffer buffers[8];
 | 
			
		||||
	unsigned next_buffer;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@@ -49,45 +49,45 @@ struct win32_output {
 | 
			
		||||
 * The quark used for GError.domain.
 | 
			
		||||
 */
 | 
			
		||||
static inline GQuark
 | 
			
		||||
win32_output_quark(void)
 | 
			
		||||
winmm_output_quark(void)
 | 
			
		||||
{
 | 
			
		||||
	return g_quark_from_static_string("win32_output");
 | 
			
		||||
	return g_quark_from_static_string("winmm_output");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static bool
 | 
			
		||||
win32_output_test_default_device(void)
 | 
			
		||||
winmm_output_test_default_device(void)
 | 
			
		||||
{
 | 
			
		||||
	/* we assume that Wave is always available */
 | 
			
		||||
	return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void *
 | 
			
		||||
win32_output_init(G_GNUC_UNUSED const struct audio_format *audio_format,
 | 
			
		||||
winmm_output_init(G_GNUC_UNUSED const struct audio_format *audio_format,
 | 
			
		||||
		  G_GNUC_UNUSED const struct config_param *param,
 | 
			
		||||
		  G_GNUC_UNUSED GError **error)
 | 
			
		||||
{
 | 
			
		||||
	struct win32_output *wo = g_new(struct win32_output, 1);
 | 
			
		||||
	struct winmm_output *wo = g_new(struct winmm_output, 1);
 | 
			
		||||
 | 
			
		||||
	return wo;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
win32_output_finish(void *data)
 | 
			
		||||
winmm_output_finish(void *data)
 | 
			
		||||
{
 | 
			
		||||
	struct win32_output *wo = data;
 | 
			
		||||
	struct winmm_output *wo = data;
 | 
			
		||||
 | 
			
		||||
	g_free(wo);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static bool
 | 
			
		||||
win32_output_open(void *data, struct audio_format *audio_format,
 | 
			
		||||
winmm_output_open(void *data, struct audio_format *audio_format,
 | 
			
		||||
		  GError **error_r)
 | 
			
		||||
{
 | 
			
		||||
	struct win32_output *wo = data;
 | 
			
		||||
	struct winmm_output *wo = data;
 | 
			
		||||
 | 
			
		||||
	wo->event = CreateEvent(NULL, false, false, NULL);
 | 
			
		||||
	if (wo->event == NULL) {
 | 
			
		||||
		g_set_error(error_r, win32_output_quark(), 0,
 | 
			
		||||
		g_set_error(error_r, winmm_output_quark(), 0,
 | 
			
		||||
			    "CreateEvent() failed");
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
@@ -123,7 +123,7 @@ win32_output_open(void *data, struct audio_format *audio_format,
 | 
			
		||||
				      (DWORD_PTR)wo->event, 0, CALLBACK_EVENT);
 | 
			
		||||
	if (result != MMSYSERR_NOERROR) {
 | 
			
		||||
		CloseHandle(wo->event);
 | 
			
		||||
		g_set_error(error_r, win32_output_quark(), result,
 | 
			
		||||
		g_set_error(error_r, winmm_output_quark(), result,
 | 
			
		||||
			    "waveOutOpen() failed");
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
@@ -139,9 +139,9 @@ win32_output_open(void *data, struct audio_format *audio_format,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
win32_output_close(void *data)
 | 
			
		||||
winmm_output_close(void *data)
 | 
			
		||||
{
 | 
			
		||||
	struct win32_output *wo = data;
 | 
			
		||||
	struct winmm_output *wo = data;
 | 
			
		||||
 | 
			
		||||
	for (unsigned i = 0; i < G_N_ELEMENTS(wo->buffers); ++i)
 | 
			
		||||
		pcm_buffer_deinit(&wo->buffers[i].buffer);
 | 
			
		||||
@@ -155,13 +155,13 @@ win32_output_close(void *data)
 | 
			
		||||
 * Copy data into a buffer, and prepare the wave header.
 | 
			
		||||
 */
 | 
			
		||||
static bool
 | 
			
		||||
win32_set_buffer(struct win32_output *wo, struct win32_buffer *buffer,
 | 
			
		||||
winmm_set_buffer(struct winmm_output *wo, struct winmm_buffer *buffer,
 | 
			
		||||
		 const void *data, size_t size,
 | 
			
		||||
		 GError **error_r)
 | 
			
		||||
{
 | 
			
		||||
	void *dest = pcm_buffer_get(&buffer->buffer, size);
 | 
			
		||||
	if (dest == NULL) {
 | 
			
		||||
		g_set_error(error_r, win32_output_quark(), 0,
 | 
			
		||||
		g_set_error(error_r, winmm_output_quark(), 0,
 | 
			
		||||
			    "Out of memory");
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
@@ -175,7 +175,7 @@ win32_set_buffer(struct win32_output *wo, struct win32_buffer *buffer,
 | 
			
		||||
	MMRESULT result = waveOutPrepareHeader(wo->handle, &buffer->hdr,
 | 
			
		||||
					       sizeof(buffer->hdr));
 | 
			
		||||
	if (result != MMSYSERR_NOERROR) {
 | 
			
		||||
		g_set_error(error_r, win32_output_quark(), result,
 | 
			
		||||
		g_set_error(error_r, winmm_output_quark(), result,
 | 
			
		||||
			    "waveOutPrepareHeader() failed");
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
@@ -187,7 +187,7 @@ win32_set_buffer(struct win32_output *wo, struct win32_buffer *buffer,
 | 
			
		||||
 * Wait until the buffer is finished.
 | 
			
		||||
 */
 | 
			
		||||
static bool
 | 
			
		||||
win32_drain_buffer(struct win32_output *wo, struct win32_buffer *buffer,
 | 
			
		||||
winmm_drain_buffer(struct winmm_output *wo, struct winmm_buffer *buffer,
 | 
			
		||||
		   GError **error_r)
 | 
			
		||||
{
 | 
			
		||||
	if ((buffer->hdr.dwFlags & WHDR_DONE) == WHDR_DONE)
 | 
			
		||||
@@ -201,7 +201,7 @@ win32_drain_buffer(struct win32_output *wo, struct win32_buffer *buffer,
 | 
			
		||||
		if (result == MMSYSERR_NOERROR)
 | 
			
		||||
			return true;
 | 
			
		||||
		else if (result != WAVERR_STILLPLAYING) {
 | 
			
		||||
			g_set_error(error_r, win32_output_quark(), result,
 | 
			
		||||
			g_set_error(error_r, winmm_output_quark(), result,
 | 
			
		||||
				    "waveOutUnprepareHeader() failed");
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
@@ -212,14 +212,14 @@ win32_drain_buffer(struct win32_output *wo, struct win32_buffer *buffer,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static size_t
 | 
			
		||||
win32_output_play(void *data, const void *chunk, size_t size, GError **error_r)
 | 
			
		||||
winmm_output_play(void *data, const void *chunk, size_t size, GError **error_r)
 | 
			
		||||
{
 | 
			
		||||
	struct win32_output *wo = data;
 | 
			
		||||
	struct winmm_output *wo = data;
 | 
			
		||||
 | 
			
		||||
	/* get the next buffer from the ring and prepare it */
 | 
			
		||||
	struct win32_buffer *buffer = &wo->buffers[wo->next_buffer];
 | 
			
		||||
	if (!win32_drain_buffer(wo, buffer, error_r) ||
 | 
			
		||||
	    !win32_set_buffer(wo, buffer, chunk, size, error_r))
 | 
			
		||||
	struct winmm_buffer *buffer = &wo->buffers[wo->next_buffer];
 | 
			
		||||
	if (!winmm_drain_buffer(wo, buffer, error_r) ||
 | 
			
		||||
	    !winmm_set_buffer(wo, buffer, chunk, size, error_r))
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	/* enqueue the buffer */
 | 
			
		||||
@@ -228,7 +228,7 @@ win32_output_play(void *data, const void *chunk, size_t size, GError **error_r)
 | 
			
		||||
	if (result != MMSYSERR_NOERROR) {
 | 
			
		||||
		waveOutUnprepareHeader(wo->handle, &buffer->hdr,
 | 
			
		||||
				       sizeof(buffer->hdr));
 | 
			
		||||
		g_set_error(error_r, win32_output_quark(), result,
 | 
			
		||||
		g_set_error(error_r, winmm_output_quark(), result,
 | 
			
		||||
			    "waveOutWrite() failed");
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
@@ -241,56 +241,56 @@ win32_output_play(void *data, const void *chunk, size_t size, GError **error_r)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static bool
 | 
			
		||||
win32_drain_all_buffers(struct win32_output *wo, GError **error_r)
 | 
			
		||||
winmm_drain_all_buffers(struct winmm_output *wo, GError **error_r)
 | 
			
		||||
{
 | 
			
		||||
	for (unsigned i = wo->next_buffer; i < G_N_ELEMENTS(wo->buffers); ++i)
 | 
			
		||||
		if (!win32_drain_buffer(wo, &wo->buffers[i], error_r))
 | 
			
		||||
		if (!winmm_drain_buffer(wo, &wo->buffers[i], error_r))
 | 
			
		||||
			return false;
 | 
			
		||||
 | 
			
		||||
	for (unsigned i = 0; i < wo->next_buffer; ++i)
 | 
			
		||||
		if (!win32_drain_buffer(wo, &wo->buffers[i], error_r))
 | 
			
		||||
		if (!winmm_drain_buffer(wo, &wo->buffers[i], error_r))
 | 
			
		||||
			return false;
 | 
			
		||||
 | 
			
		||||
	return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
win32_stop(struct win32_output *wo)
 | 
			
		||||
winmm_stop(struct winmm_output *wo)
 | 
			
		||||
{
 | 
			
		||||
	waveOutReset(wo->handle);
 | 
			
		||||
 | 
			
		||||
	for (unsigned i = 0; i < G_N_ELEMENTS(wo->buffers); ++i) {
 | 
			
		||||
		struct win32_buffer *buffer = &wo->buffers[i];
 | 
			
		||||
		struct winmm_buffer *buffer = &wo->buffers[i];
 | 
			
		||||
		waveOutUnprepareHeader(wo->handle, &buffer->hdr,
 | 
			
		||||
				       sizeof(buffer->hdr));
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
win32_output_drain(void *data)
 | 
			
		||||
winmm_output_drain(void *data)
 | 
			
		||||
{
 | 
			
		||||
	struct win32_output *wo = data;
 | 
			
		||||
	struct winmm_output *wo = data;
 | 
			
		||||
 | 
			
		||||
	if (!win32_drain_all_buffers(wo, NULL))
 | 
			
		||||
		win32_stop(wo);
 | 
			
		||||
	if (!winmm_drain_all_buffers(wo, NULL))
 | 
			
		||||
		winmm_stop(wo);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
win32_output_cancel(void *data)
 | 
			
		||||
winmm_output_cancel(void *data)
 | 
			
		||||
{
 | 
			
		||||
	struct win32_output *wo = data;
 | 
			
		||||
	struct winmm_output *wo = data;
 | 
			
		||||
 | 
			
		||||
	win32_stop(wo);
 | 
			
		||||
	winmm_stop(wo);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const struct audio_output_plugin win32_output_plugin = {
 | 
			
		||||
	.name = "win32",
 | 
			
		||||
	.test_default_device = win32_output_test_default_device,
 | 
			
		||||
	.init = win32_output_init,
 | 
			
		||||
	.finish = win32_output_finish,
 | 
			
		||||
	.open = win32_output_open,
 | 
			
		||||
	.close = win32_output_close,
 | 
			
		||||
	.play = win32_output_play,
 | 
			
		||||
	.drain = win32_output_drain,
 | 
			
		||||
	.cancel = win32_output_cancel,
 | 
			
		||||
const struct audio_output_plugin winmm_output_plugin = {
 | 
			
		||||
	.name = "winmm",
 | 
			
		||||
	.test_default_device = winmm_output_test_default_device,
 | 
			
		||||
	.init = winmm_output_init,
 | 
			
		||||
	.finish = winmm_output_finish,
 | 
			
		||||
	.open = winmm_output_open,
 | 
			
		||||
	.close = winmm_output_close,
 | 
			
		||||
	.play = winmm_output_play,
 | 
			
		||||
	.drain = winmm_output_drain,
 | 
			
		||||
	.cancel = winmm_output_cancel,
 | 
			
		||||
};
 | 
			
		||||
@@ -36,7 +36,7 @@ extern const struct audio_output_plugin mvp_output_plugin;
 | 
			
		||||
extern const struct audio_output_plugin jack_output_plugin;
 | 
			
		||||
extern const struct audio_output_plugin httpd_output_plugin;
 | 
			
		||||
extern const struct audio_output_plugin recorder_output_plugin;
 | 
			
		||||
extern const struct audio_output_plugin win32_output_plugin;
 | 
			
		||||
extern const struct audio_output_plugin winmm_output_plugin;
 | 
			
		||||
 | 
			
		||||
const struct audio_output_plugin *audio_output_plugins[] = {
 | 
			
		||||
#ifdef HAVE_SHOUT
 | 
			
		||||
@@ -82,8 +82,8 @@ const struct audio_output_plugin *audio_output_plugins[] = {
 | 
			
		||||
#ifdef ENABLE_RECORDER_OUTPUT
 | 
			
		||||
	&recorder_output_plugin,
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef ENABLE_WIN32_OUTPUT
 | 
			
		||||
	&win32_output_plugin,
 | 
			
		||||
#ifdef ENABLE_WINMM_OUTPUT
 | 
			
		||||
	&winmm_output_plugin,
 | 
			
		||||
#endif
 | 
			
		||||
	NULL
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user