From 16a27609de509d0d37b219bf29bdd290da54ad36 Mon Sep 17 00:00:00 2001 From: PHO Date: Tue, 19 Oct 2010 22:12:22 +0900 Subject: [PATCH] esd.h (partway) --- .gitignore | 5 ++ Bindings/EsounD.hsc | 167 ++++++++++++++++++++++++++++++++++++++++++ COPYING | 29 ++++++++ GNUmakefile | 5 ++ Setup.hs | 4 + bindings-EsounD.cabal | 38 ++++++++++ cabal-package.mk | 95 ++++++++++++++++++++++++ cbits/helper_EsounD.c | 5 ++ 8 files changed, 348 insertions(+) create mode 100644 .gitignore create mode 100644 Bindings/EsounD.hsc create mode 100644 COPYING create mode 100644 GNUmakefile create mode 100644 Setup.hs create mode 100644 bindings-EsounD.cabal create mode 100644 cabal-package.mk create mode 100644 cbits/helper_EsounD.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f76a6e2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.hi +*.o + +Setup +dist diff --git a/Bindings/EsounD.hsc b/Bindings/EsounD.hsc new file mode 100644 index 0000000..dffe193 --- /dev/null +++ b/Bindings/EsounD.hsc @@ -0,0 +1,167 @@ +#include +#include + +module Bindings.EsounD where +#strict_import + +#globalarray ESD_UNIX_SOCKET_DIR , CChar +#globalarray ESD_UNIX_SOCKET_NAME, CChar + +#num ESD_BUF_SIZE +#num ESD_MAX_WRITE_SIZE +#num ESD_KEY_LEN +#num ESD_DEFAULT_PORT +#num ESD_DEFAULT_RATE +#num ESD_NAME_MAX +#num ESD_ENDIAN_KEY +#num ESD_VOLUME_BASE + +#num ESD_PROTO_CONNECT +#num ESD_PROTO_LOCK +#num ESD_PROTO_UNLOCK +#num ESD_PROTO_STREAM_PLAY +#num ESD_PROTO_STREAM_REC +#num ESD_PROTO_STREAM_MON +#num ESD_PROTO_SAMPLE_CACHE +#num ESD_PROTO_SAMPLE_FREE +#num ESD_PROTO_SAMPLE_PLAY +#num ESD_PROTO_SAMPLE_LOOP +#num ESD_PROTO_SAMPLE_STOP +#num ESD_PROTO_SAMPLE_KILL +#num ESD_PROTO_STANDBY +#num ESD_PROTO_RESUME +#num ESD_PROTO_SAMPLE_GETID +#num ESD_PROTO_STREAM_FILT +#num ESD_PROTO_SERVER_INFO +#num ESD_PROTO_ALL_INFO +#num ESD_PROTO_SUBSCRIBE +#num ESD_PROTO_UNSUBSCRIBE +#num ESD_PROTO_STREAM_PAN +#num ESD_PROTO_SAMPLE_PAN +#num ESD_PROTO_STANDBY_MODE +#num ESD_PROTO_LATENCY +#num ESD_PROTO_MAX + +#num ESD_MASK_BITS +#num ESD_BITS8 +#num ESD_BITS16 + +#num ESD_MASK_CHAN +#num ESD_MONO +#num ESD_STEREO + +#num ESD_MASK_MODE +#num ESD_STREAM +#num ESD_SAMPLE +#num ESD_ADPCM + +#num ESD_MASK_FUNC +#num ESD_PLAY +#num ESD_MONITOR +#num ESD_RECORD +#num ESD_STOP +#num ESD_LOOP + +#integral_t esd_format_t +#integral_t esd_proto_t + +#integral_t octet + +#ccall esd_open_sound, Ptr CChar -> IO CInt +#ccall esd_send_auth , CInt -> IO CInt +#ccall esd_lock , CInt -> IO CInt +#ccall esd_unlock , CInt -> IO CInt +#ccall esd_standby , CInt -> IO CInt +#ccall esd_resume , CInt -> IO CInt + +#ccall esd_play_stream , -> CInt -> Ptr CChar -> Ptr CChar -> IO CInt +#ccall esd_play_stream_fallback , -> CInt -> Ptr CChar -> Ptr CChar -> IO CInt +#ccall esd_monitor_stream , -> CInt -> Ptr CChar -> Ptr CChar -> IO CInt +#ccall esd_record_stream , -> CInt -> Ptr CChar -> Ptr CChar -> IO CInt +#ccall esd_record_stream_fallback, -> CInt -> Ptr CChar -> Ptr CChar -> IO CInt +#ccall esd_filter_stream , -> CInt -> Ptr CChar -> Ptr CChar -> IO CInt +#ccall esd_sample_cache , CInt -> -> CInt -> CInt -> Ptr CChar -> IO CInt +#ccall esd_confirm_sample_cache , CInt -> IO CInt +#ccall esd_sample_getid , CInt -> Ptr CChar -> IO CInt +#ccall esd_sample_free , CInt -> CInt -> IO CInt +#ccall esd_sample_play , CInt -> CInt -> IO CInt +#ccall esd_sample_loop , CInt -> CInt -> IO CInt +#ccall esd_sample_stop , CInt -> CInt -> IO CInt +#ccall esd_sample_kill , CInt -> CInt -> IO CInt +#ccall esd_close , CInt -> IO CInt +#ccall esd_get_latency , CInt -> IO CInt + +#starttype struct esd_server_info +# field version, CInt +# field format , +# field rate , CInt +#stoptype +#synonym_t esd_server_info_t, + +#starttype struct esd_player_info +# field next , Ptr +# field server , Ptr +# field source_id , CInt +# array_field name , CChar +# field rate , CInt +# field left_vol_scale , CInt +# field right_vol_scale, CInt +# field format , +#stoptype +#synonym_t esd_player_info_t, + +#starttype struct esd_sample_info +# field next , Ptr +# field server , Ptr +# field sample_id , CInt +# array_field name , CChar +# field rate , CInt +# field left_vol_scale , CInt +# field right_vol_scale, CInt +# field format , +# field length , CInt +#stoptype +#synonym_t esd_sample_info_t, + +#starttype struct esd_info +# field server , Ptr +# field player_list, Ptr +# field sample_list, Ptr +#stoptype +#synonym_t esd_info_t, + +#num ESM_ERROR +#num ESM_ON_STANDBY +#num ESM_ON_AUTOSTANDBY +#num ESM_RUNNING +#integral_t esd_standby_mode_t + +#callback esd_new_player_callback_t, Ptr -> IO CInt +#callback esd_old_player_callback_t, Ptr -> IO CInt +#callback esd_new_sample_callback_t, Ptr -> IO CInt +#callback esd_old_sample_callback_t, Ptr -> IO CInt + +#starttype struct esd_update_info_callbacks +# field esd_new_player_callback, Ptr +# field esd_old_player_callback, Ptr +# field esd_new_sample_callback, Ptr +# field esd_old_sample_callback, Ptr +#stoptype +#synonym_t esd_update_info_callbacks_t, + +#ccall esd_print_server_info , Ptr -> IO () +#ccall esd_print_player_info , Ptr -> IO () +#ccall esd_print_sample_info , Ptr -> IO () +#ccall esd_print_all_info , Ptr -> IO () +#ccall esd_get_server_info , CInt -> IO (Ptr ) +#ccall esd_free_server_info , Ptr -> IO () +#ccall esd_get_all_info , CInt -> IO (Ptr ) +#ccall esd_subscribe_all_info , CInt -> IO (Ptr ) +#ccall esd_update_info , CInt -> Ptr -> Ptr -> IO (Ptr ) +#ccall esd_unsubscribe_info , CInt -> IO (Ptr ) +#ccall esd_free_all_info , Ptr -> IO () +#ccall esd_set_stream_pan , CInt -> CInt -> CInt -> CInt -> IO CInt +#ccall esd_set_default_sample_pan, CInt -> CInt -> CInt -> CInt -> IO CInt +#ccall esd_get_standby_mode , CInt -> IO + +#ccall esd_send_file, CInt -> diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..5d39aa7 --- /dev/null +++ b/COPYING @@ -0,0 +1,29 @@ + + + + + bindings-EsounD + + + PHO + + + + + + + + + + + + diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 0000000..15098cd --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,5 @@ +#RUN_COMMAND = $(MAKE) -C examples run + +CONFIGURE_ARGS = -O + +include cabal-package.mk diff --git a/Setup.hs b/Setup.hs new file mode 100644 index 0000000..bd92fff --- /dev/null +++ b/Setup.hs @@ -0,0 +1,4 @@ +#!/usr/bin/env runghc + +import Distribution.Simple +main = defaultMain diff --git a/bindings-EsounD.cabal b/bindings-EsounD.cabal new file mode 100644 index 0000000..e8e2a9c --- /dev/null +++ b/bindings-EsounD.cabal @@ -0,0 +1,38 @@ +Name: bindings-EsounD +Synopsis: Low level bindings to EsounD (ESD; Enlightened Sound Daemon) +Description: + Bindings to EsounD: +Version: 0.1 +License: PublicDomain +License-File: COPYING +Author: PHO +Maintainer: PHO +Stability: experimental +Homepage: http://cielonegro.org/Bindings-EsounD.html +Category: FFI +Tested-With: GHC == 6.12.3 +Cabal-Version: >= 1.6 +Build-Type: Simple +Extra-Source-Files: + COPYING + +Source-Repository head + Type: git + Location: git://git.cielonegro.org/bindings-EsounD.git + +Library + Build-Depends: + base == 4.2.*, + bindings-DSL == 1.0.* + + Exposed-Modules: + Bindings.EsounD + + PkgConfig-Depends: + esound >= 0.2 + + C-Sources: + cbits/helper_EsounD.c + + Extensions: + ForeignFunctionInterface diff --git a/cabal-package.mk b/cabal-package.mk new file mode 100644 index 0000000..d8bbaad --- /dev/null +++ b/cabal-package.mk @@ -0,0 +1,95 @@ +# -*- makefile-gmake -*- +# +# Variables: +# +# CONFIGURE_ARGS :: arguments to be passed to ./Setup configure +# default: --disable-optimization +# +# RUN_COMMAND :: command to be run for "make run" +# + +GHC ?= ghc +FIND ?= find +RM_RF ?= rm -rf +SUDO ?= sudo +AUTOCONF ?= autoconf +HLINT ?= hlint + +CONFIGURE_ARGS ?= --disable-optimization + +SETUP_FILE := $(wildcard Setup.*hs) +CABAL_FILE := $(wildcard *.cabal) + +ifeq ($(shell ls configure.ac 2>/dev/null),configure.ac) + AUTOCONF_AC_FILE := configure.ac + AUTOCONF_FILE := configure +else + ifeq ($(shell ls configure.in 2>/dev/null),configure.in) + AUTOCONF_AC_FILE := configure.in + AUTOCONF_FILE := configure + else + AUTOCONF_AC_FILE := + AUTOCONF_FILE := + endif +endif + +BUILDINFO_IN_FILE := $(wildcard *.buildinfo.in) +BUILDINFO_FILE := $(BUILDINFO_IN_FILE:.in=) + +all: build + +build: setup-config build-hook + ./Setup build + +build-hook: + +ifeq ($(RUN_COMMAND),) +run: + @echo "cabal-package.mk: No command to run." + @echo "cabal-package.mk: If you want to run something, define RUN_COMMAND variable." +else +run: build + @echo ".:.:. Let's go .:.:." + $(RUN_COMMAND) +endif + +setup-config: dist/setup-config setup-config-hook $(BUILDINFO_FILE) + +setup-config-hook: + +dist/setup-config: $(CABAL_FILE) Setup $(AUTOCONF_FILE) + ./Setup configure $(CONFIGURE_ARGS) + +$(AUTOCONF_FILE): $(AUTOCONF_AC_FILE) + $(AUTOCONF) + +$(BUILDINFO_FILE): $(BUILDINFO_IN_FILE) configure + ./Setup configure $(CONFIGURE_ARGS) + +Setup: $(SETUP_FILE) + $(GHC) --make Setup + +clean: clean-hook + $(RM_RF) dist Setup *.o *.hi .setup-config *.buildinfo + $(FIND) . -name '*~' -exec rm -f {} \; + +clean-hook: + +doc: setup-config + ./Setup haddock + +install: build + $(SUDO) ./Setup install + +sdist: setup-config + ./Setup sdist + +test: build + ./Setup test + +lint: + $(HLINT) . --report \ + --ignore="Use string literal" \ + --ignore="Use concatMap" + +.PHONY: build build-hook setup-config setup-config-hook run clean clean-hook install doc sdist test lint diff --git a/cbits/helper_EsounD.c b/cbits/helper_EsounD.c new file mode 100644 index 0000000..11788cd --- /dev/null +++ b/cbits/helper_EsounD.c @@ -0,0 +1,5 @@ +#include +#include + +BC_GLOBALARRAY(ESD_UNIX_SOCKET_DIR , char) +BC_GLOBALARRAY(ESD_UNIX_SOCKET_NAME, char) -- 2.40.0