Commit 20004b7e authored by Denis Krjuchkov's avatar Denis Krjuchkov

win32_output: renamed win32 output plugin to winmm

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