New patches: [unrevert anonymous**20070921183845] < > { hunk ./README 1 -This module provides a Haskell interface to Audacious remote control -(deprecated) API rmfile ./README hunk ./Setup.lhs 1 -#!/usr/bin/env runhaskell - -> import Distribution.Simple -> main = defaultMainWithHooks defaultUserHooks rmfile ./Setup.lhs hunk ./hasc.cabal 1 -name: harc -version: 0.1 -homepage: http://gorgias.mine.nu/repos/harc -synopsis: Bindings to the Audacious remote control API -description: Bindings to the Audacious remote control API -category: Sound -license: GPL -license-file: LICENSE -author: Andrea Rossato -maintainer: andrea.rossato@unibz.it - -Executable harc { - Build-Depends: base>=2.0, unix,Cabal>=1.2 - Main-Is: harc.hs - Other-Modules: Sound.Audacious - Hs-Source-Dirs: test - Extensions: ForeignFunctionInterface - Pkgconfig-Depends: glib-2.0, audacious - GHC-options: -funbox-strict-fields -O2 -fasm -Wall -optl-Wl,-s - GHC-prof-options: -prof -auto-all -} - -Library { - Build-Depends: base>=2.0, unix,Cabal>=1.2 - Exposed-Modules: Sound.Audacious - Hs-Source-Dirs: src - Extensions: ForeignFunctionInterface - Pkgconfig-Depends: glib-2.0, audacious - GHC-options: -funbox-strict-fields -O2 -fasm -Wall -optl-Wl,-s - GHC-prof-options: -prof -auto-all -} rmfile ./hasc.cabal hunk ./src/Sound/Audacious.chs 1 -{-# OPTIONS -fglasgow-exts #-} ------------------------------------------------------------------------------ --- | --- Module : Sound.Audacious --- Copyright : (C) 2007 Andrea Rossato --- License : GPL --- --- Maintainer : andrea.rossato@unibz.it --- Stability : unstable --- Portability : unportable --- --- --- Bindings to the Audacious remote control API --- xmms_remote ------------------------------------------------------------------------------ - -module Sound.Audacious where - -import Foreign -import Foreign.C - -type Session = Int - -foreign import ccall unsafe "beepctrl.h xmms_remote_playlist" - c_xmms_remote_playlist :: CInt -> Ptr CString -> CInt -> {# type gboolean #} -> IO () - -xmms_remote_playlist :: Session -> [String] -> Bool -> IO () -xmms_remote_playlist s l b = do - la <- newArray =<< mapM newCString l - c_xmms_remote_playlist (fromIntegral s) la (fromIntegral $ length l) (fromBool b) - -foreign import ccall unsafe "beepctrl.h xmms_remote_get_version" - c_xmms_remote_get_version :: CInt -> IO CInt - -xmms_remote_get_version :: Session -> IO Int -xmms_remote_get_version s = - fromIntegral `fmap` c_xmms_remote_get_version (fromIntegral s) - -foreign import ccall unsafe "beepctrl.h xmms_remote_playlist_add" - c_xmms_remote_playlist_add :: CInt -> GList -> IO () - -xmms_remote_playlist_add :: Session -> [String] -> IO () -xmms_remote_playlist_add s fns = do - l <- mapM newCString fns >>= toGList - c_xmms_remote_playlist_add (fromIntegral s) l - -foreign import ccall unsafe "beepctrl.h xmms_remote_playlist_delete" - c_xmms_remote_playlist_delete :: CInt -> CInt -> IO () - -xmms_remote_playlist_delete :: Session -> Int -> IO () -xmms_remote_playlist_delete s pos = - c_xmms_remote_playlist_delete (fromIntegral s) (fromIntegral pos) - -foreign import ccall unsafe "beepctrl.h xmms_remote_stop" - c_xmms_remote_stop :: CInt -> IO () - -xmms_remote_stop :: Session -> IO () -xmms_remote_stop s = - c_xmms_remote_stop (fromIntegral s) - -foreign import ccall unsafe "beepctrl.h xmms_remote_play" - c_xmms_remote_play :: CInt -> IO () - -xmms_remote_play :: Session -> IO () -xmms_remote_play s = - c_xmms_remote_play (fromIntegral s) - -foreign import ccall unsafe "beepctrl.h xmms_remote_pause" - c_xmms_remote_pause :: CInt -> IO () - -xmms_remote_pause :: Session -> IO () -xmms_remote_pause s = - c_xmms_remote_pause (fromIntegral s) - -foreign import ccall unsafe "beepctrl.h xmms_remote_is_playing" - c_xmms_remote_is_playing :: CInt -> IO {# type gboolean #} - -xmms_remote_is_playing :: Session -> IO Bool -xmms_remote_is_playing s = do - b <- c_xmms_remote_is_playing (fromIntegral s) - return $ toBool b - -foreign import ccall unsafe "beepctrl.h xmms_remote_is_paused" - c_xmms_remote_is_paused :: CInt -> IO {# type gboolean #} - -xmms_remote_is_paused :: Session -> IO Bool -xmms_remote_is_paused s = do - b <- c_xmms_remote_is_paused (fromIntegral s) - return $ toBool b - -foreign import ccall unsafe "beepctrl.h xmms_remote_get_playlist_pos" - c_xmms_remote_get_playlist_pos :: CInt -> IO CInt - -xmms_remote_get_playlist_pos :: Session -> IO Int -xmms_remote_get_playlist_pos s = - fromIntegral `fmap` c_xmms_remote_get_playlist_pos (fromIntegral s) - - -foreign import ccall unsafe "beepctrl.h xmms_remote_set_playlist_pos" - c_xmms_remote_set_playlist_pos :: CInt -> CInt -> IO () - -xmms_remote_set_playlist_pos :: Session -> Int -> IO () -xmms_remote_set_playlist_pos s pos = - c_xmms_remote_set_playlist_pos (fromIntegral s) (fromIntegral pos) - -foreign import ccall unsafe "beepctrl.h xmms_remote_get_playlist_length" - c_xmms_remote_get_playlist_length :: CInt -> IO CInt - -xmms_remote_get_playlist_length :: Session -> IO Int -xmms_remote_get_playlist_length s = - fromIntegral `fmap` c_xmms_remote_get_playlist_length (fromIntegral s) - -foreign import ccall unsafe "beepctrl.h xmms_remote_playlist_clear" - c_xmms_remote_playlist_clear :: CInt -> IO () - -xmms_remote_playlist_clear :: Session -> IO () -xmms_remote_playlist_clear s = - c_xmms_remote_playlist_clear (fromIntegral s) - -foreign import ccall unsafe "beepctrl.h xmms_remote_get_output_time" - c_xmms_remote_get_output_time :: CInt -> IO CInt - -xmms_remote_get_output_time :: Session -> IO Int -xmms_remote_get_output_time s = - fromIntegral `fmap` c_xmms_remote_get_output_time (fromIntegral s) - -foreign import ccall unsafe "beepctrl.h xmms_remote_jump_to_time" - c_xmms_remote_jump_to_time :: CInt -> CInt -> IO () - -xmms_remote_jump_to_time :: Session -> Int -> IO () -xmms_remote_jump_to_time s pos = - c_xmms_remote_jump_to_time (fromIntegral s) (fromIntegral pos) - -foreign import ccall unsafe "beepctrl.h xmms_remote_get_volume" - c_xmms_remote_get_volume :: CInt -> Ptr CInt -> Ptr CInt -> IO () - -xmms_remote_get_volume :: Session -> IO (Int,Int) -xmms_remote_get_volume s = - alloca $ \vl -> - alloca $ \vr -> do - c_xmms_remote_get_volume (fromIntegral s) vl vr - l <- peek vl - r <- peek vr - return (fromIntegral l, fromIntegral r) - -foreign import ccall unsafe "beepctrl.h xmms_remote_get_main_volume" - c_xmms_remote_get_main_volume :: CInt -> IO CInt - -xmms_remote_get_main_volume :: Session -> IO Int -xmms_remote_get_main_volume s = - fromIntegral `fmap` c_xmms_remote_get_main_volume (fromIntegral s) - -foreign import ccall unsafe "beepctrl.h xmms_remote_get_balance" - c_xmms_remote_get_balance :: CInt -> IO CInt - -xmms_remote_get_balance :: Session -> IO Int -xmms_remote_get_balance s = - fromIntegral `fmap` c_xmms_remote_get_balance (fromIntegral s) - -foreign import ccall unsafe "beepctrl.h xmms_remote_set_volume" - c_xmms_remote_set_volume :: CInt -> CInt -> CInt -> IO () - -xmms_remote_set_volume :: Session -> Int -> Int -> IO () -xmms_remote_set_volume s lv rv = - c_xmms_remote_set_volume (fromIntegral s) (fromIntegral lv) (fromIntegral rv) - -foreign import ccall unsafe "beepctrl.h xmms_remote_set_main_volume" - c_xmms_remote_set_main_volume :: CInt -> CInt -> IO () - -xmms_remote_set_main_volume :: Session -> Int -> IO () -xmms_remote_set_main_volume s v = - c_xmms_remote_set_main_volume (fromIntegral s) (fromIntegral v) - -foreign import ccall unsafe "beepctrl.h xmms_remote_set_balance" - c_xmms_remote_set_balance :: CInt -> CInt -> IO () - -xmms_remote_set_balance :: Session -> Int -> IO () -xmms_remote_set_balance s b = - c_xmms_remote_set_balance (fromIntegral s) (fromIntegral b) - -foreign import ccall unsafe "beepctrl.h xmms_remote_get_skin" - c_xmms_remote_get_skin :: CInt -> IO CString - -xmms_remote_get_skin :: Session -> IO String -xmms_remote_get_skin s = do - str <- c_xmms_remote_get_skin (fromIntegral s) - peekCString str - -foreign import ccall unsafe "beepctrl.h xmms_remote_set_skin" - c_xmms_remote_set_skin :: CInt -> CString ->IO () - -xmms_remote_set_skin :: Session -> String -> IO () -xmms_remote_set_skin s sn = do - withCString sn $ c_xmms_remote_set_skin (fromIntegral s) - -foreign import ccall unsafe "beepctrl.h xmms_remote_get_playlist_file" - c_xmms_remote_get_playlist_file :: CInt -> CInt -> IO CString - -xmms_remote_get_playlist_file :: Session -> Int -> IO String -xmms_remote_get_playlist_file s pos = do - str <- c_xmms_remote_get_playlist_file (fromIntegral s) (fromIntegral pos) - peekCString str - -foreign import ccall unsafe "beepctrl.h xmms_remote_get_playlist_title" - c_xmms_remote_get_playlist_title :: CInt -> CInt -> IO CString - -xmms_remote_get_playlist_title :: Session -> Int -> IO String -xmms_remote_get_playlist_title s pos = do - str <- c_xmms_remote_get_playlist_title (fromIntegral s) (fromIntegral pos) - peekCString str - -foreign import ccall unsafe "beepctrl.h xmms_remote_get_playlist_time" - c_xmms_remote_get_playlist_time :: CInt -> CInt -> IO CInt - -xmms_remote_get_playlist_time :: Session -> Int -> IO Int -xmms_remote_get_playlist_time s pos = - fromIntegral `fmap` c_xmms_remote_get_playlist_time (fromIntegral s) (fromIntegral pos) - -foreign import ccall unsafe "beepctrl.h xmms_remote_get_info" - c_xmms_remote_get_info :: CInt -> Ptr CInt -> Ptr CInt -> Ptr CInt -> IO () - --- | (rate, frequency, number_of_channels) -xmms_remote_get_info :: Session -> IO (Int,Int,Int) -xmms_remote_get_info s = - alloca $ \rate -> - alloca $ \freq -> - alloca $ \nch -> do - c_xmms_remote_get_info (fromIntegral s) rate freq nch - r <- peek rate - f <- peek freq - n <- peek nch - return (fromIntegral r, fromIntegral f, fromIntegral n) - -foreign import ccall unsafe "beepctrl.h xmms_remote_main_win_toggle" - c_xmms_remote_main_win_toggle :: CInt -> {# type gboolean #} -> IO () - -xmms_remote_main_win_toggle :: Session -> Bool -> IO () -xmms_remote_main_win_toggle s b = do - c_xmms_remote_main_win_toggle (fromIntegral s) (fromBool b) - -foreign import ccall unsafe "beepctrl.h xmms_remote_pl_win_toggle" - c_xmms_remote_pl_win_toggle :: CInt -> {# type gboolean #} -> IO () - -xmms_remote_pl_win_toggle :: Session -> Bool -> IO () -xmms_remote_pl_win_toggle s b = do - c_xmms_remote_pl_win_toggle (fromIntegral s) (fromBool b) - -foreign import ccall unsafe "beepctrl.h xmms_remote_eq_win_toggle" - c_xmms_remote_eq_win_toggle :: CInt -> {# type gboolean #} -> IO () - -xmms_remote_eq_win_toggle :: Session -> Bool -> IO () -xmms_remote_eq_win_toggle s b = do - c_xmms_remote_eq_win_toggle (fromIntegral s) (fromBool b) - -foreign import ccall unsafe "beepctrl.h xmms_remote_is_main_win" - c_xmms_remote_is_main_win :: CInt -> IO {# type gboolean #} - -xmms_remote_is_main_win :: Session -> IO Bool -xmms_remote_is_main_win s = do - b <- c_xmms_remote_is_main_win (fromIntegral s) - return $ toBool b - -foreign import ccall unsafe "beepctrl.h xmms_remote_is_pl_win" - c_xmms_remote_is_pl_win :: CInt -> IO {# type gboolean #} - -xmms_remote_is_pl_win :: Session -> IO Bool -xmms_remote_is_pl_win s = do - b <- c_xmms_remote_is_pl_win (fromIntegral s) - return $ toBool b - -foreign import ccall unsafe "beepctrl.h xmms_remote_is_eq_win" - c_xmms_remote_is_eq_win :: CInt -> IO {# type gboolean #} - -xmms_remote_is_eq_win :: Session -> IO Bool -xmms_remote_is_eq_win s = do - b <- c_xmms_remote_is_eq_win (fromIntegral s) - return $ toBool b - -foreign import ccall unsafe "beepctrl.h xmms_remote_show_prefs_box" - c_xmms_remote_show_prefs_box :: CInt -> IO () - -xmms_remote_show_prefs_box :: Session -> IO () -xmms_remote_show_prefs_box s = - c_xmms_remote_show_prefs_box (fromIntegral s) - -foreign import ccall unsafe "beepctrl.h xmms_remote_toggle_aot" - c_xmms_remote_toggle_aot :: CInt -> {# type gboolean #} -> IO () - -xmms_remote_toggle_aot :: Session -> Bool -> IO () -xmms_remote_toggle_aot s b = do - c_xmms_remote_toggle_aot (fromIntegral s) (fromBool b) - -foreign import ccall unsafe "beepctrl.h xmms_remote_eject" - c_xmms_remote_eject :: CInt -> IO () - -xmms_remote_eject :: Session -> IO () -xmms_remote_eject s = - c_xmms_remote_eject (fromIntegral s) - -foreign import ccall unsafe "beepctrl.h xmms_remote_playlist_prev" - c_xmms_remote_playlist_prev :: CInt -> IO () - -xmms_remote_playlist_prev :: Session -> IO () -xmms_remote_playlist_prev s = - c_xmms_remote_playlist_prev (fromIntegral s) - -foreign import ccall unsafe "beepctrl.h xmms_remote_playlist_next" - c_xmms_remote_playlist_next :: CInt -> IO () - -xmms_remote_playlist_next :: Session -> IO () -xmms_remote_playlist_next s = - c_xmms_remote_playlist_next (fromIntegral s) - -foreign import ccall unsafe "beepctrl.h xmms_remote_playlist_add_url_string" - c_xmms_remote_playlist_add_url_string :: CInt -> CString ->IO () - -xmms_remote_playlist_add_url_string :: Session -> String -> IO () -xmms_remote_playlist_add_url_string s str = do - withCString str $ c_xmms_remote_playlist_add_url_string (fromIntegral s) - -foreign import ccall unsafe "beepctrl.h xmms_remote_is_running" - c_xmms_remote_is_running :: CInt -> IO {# type gboolean #} - -xmms_remote_is_running :: Session -> IO Bool -xmms_remote_is_running s = do - b <- c_xmms_remote_is_running (fromIntegral s) - return $ toBool b - -foreign import ccall unsafe "beepctrl.h xmms_remote_toggle_repeat" - c_xmms_remote_toggle_repeat :: CInt -> IO () - -xmms_remote_toggle_repeat :: Session -> IO () -xmms_remote_toggle_repeat s = - c_xmms_remote_toggle_repeat (fromIntegral s) - -foreign import ccall unsafe "beepctrl.h xmms_remote_toggle_shuffle" - c_xmms_remote_toggle_shuffle :: CInt -> IO () - -xmms_remote_toggle_shuffle :: Session -> IO () -xmms_remote_toggle_shuffle s = - c_xmms_remote_toggle_shuffle (fromIntegral s) - -foreign import ccall unsafe "beepctrl.h xmms_remote_is_repeat" - c_xmms_remote_is_repeat :: CInt -> IO {# type gboolean #} - -xmms_remote_is_repeat :: Session -> IO Bool -xmms_remote_is_repeat s = do - b <- c_xmms_remote_is_repeat (fromIntegral s) - return $ toBool b - -foreign import ccall unsafe "beepctrl.h xmms_remote_is_shuffle" - c_xmms_remote_is_shuffle :: CInt -> IO {# type gboolean #} - -xmms_remote_is_shuffle :: Session -> IO Bool -xmms_remote_is_shuffle s = do - b <- c_xmms_remote_is_shuffle (fromIntegral s) - return $ toBool b - -foreign import ccall unsafe "beepctrl.h xmms_remote_get_eq" - c_xmms_remote_get_eq :: CInt -> Ptr CFloat -> Ptr CFloat -> IO () - -xmms_remote_get_eq :: Session -> IO (Float,Float) -xmms_remote_get_eq s = - alloca $ \pream -> - alloca $ \bands -> do - c_xmms_remote_get_eq (fromIntegral s) pream bands - p <- peek pream - b <- peek bands - return (realToFrac p, realToFrac b) - -foreign import ccall unsafe "beepctrl.h xmms_remote_get_eq_preamp" - c_xmms_remote_get_eq_preamp :: CInt -> IO CFloat - -xmms_remote_get_eq_preamp :: Session -> IO Float -xmms_remote_get_eq_preamp s = - realToFrac `fmap` c_xmms_remote_get_eq_preamp (fromIntegral s) - -foreign import ccall unsafe "beepctrl.h xmms_remote_get_eq_band" - c_xmms_remote_get_eq_band :: CInt -> CInt -> IO CFloat - -xmms_remote_get_eq_band :: Session -> Int -> IO Float -xmms_remote_get_eq_band s b = - realToFrac `fmap` c_xmms_remote_get_eq_band (fromIntegral s) (fromIntegral b) - -foreign import ccall unsafe "beepctrl.h xmms_remote_set_eq" - c_xmms_remote_set_eq :: CInt -> CFloat -> Ptr CFloat -> IO () - -xmms_remote_set_eq :: Session -> Float -> [Float] -> IO () -xmms_remote_set_eq s p bs = do - lv <- newArray (map realToFrac bs) - c_xmms_remote_set_eq (fromIntegral s) (realToFrac p) lv - -foreign import ccall unsafe "beepctrl.h xmms_remote_set_eq_preamp" - c_xmms_remote_set_eq_preamp :: CInt -> CFloat -> IO () - -xmms_remote_set_eq_preamp :: Session -> Float -> IO () -xmms_remote_set_eq_preamp s b = - c_xmms_remote_set_eq_preamp (fromIntegral s) (realToFrac b) - -foreign import ccall unsafe "beepctrl.h xmms_remote_set_eq_band" - c_xmms_remote_set_eq_band :: CInt -> CInt -> CFloat -> IO () - -xmms_remote_set_eq_band :: Session -> Int -> Float -> IO () -xmms_remote_set_eq_band s b v = - c_xmms_remote_set_eq_band (fromIntegral s) (fromIntegral b) (realToFrac v) - -foreign import ccall unsafe "beepctrl.h xmms_remote_quit" - c_xmms_remote_quit :: CInt -> IO () - -xmms_remote_quit :: Session -> IO () -xmms_remote_quit s = - c_xmms_remote_quit (fromIntegral s) - --- Utilities - -#include -{# context lib="glib" prefix="g" #} -{#pointer * GList#} - -toGList :: [Ptr a] -> IO GList -toGList pl = makeList nullPtr pl - where - makeList :: GList -> [Ptr a] -> IO GList - makeList current (x:xs) = do - newHead <- {#call unsafe list_prepend#} current (castPtr x) - makeList newHead xs - makeList current [] = return current rmfile ./src/Sound/Audacious.chs rmdir ./src/Sound rmdir ./src hunk ./test/harc.hs 1 -{-# OPTIONS -fglasgow-exts #-} ------------------------------------------------------------------------------ --- | --- Module : hacr --- Copyright : (C) 2007 Andrea Rossato --- License : BSD3 --- --- Maintainer : andrea.rossato@unibz.it --- Stability : unstable --- Portability : unportable --- --- --- A simple test client for audacious ------------------------------------------------------------------------------ - -module Main where - -import Sound.Audacious -import System.Environment - -main :: IO () -main = do - args <- getArgs - case args !! 0 of - "stop" -> xmms_remote_stop 0 - "band" -> putStrLn =<< show `fmap` xmms_remote_get_eq_band 0 1 - "eq" -> putStrLn =<< show `fmap` xmms_remote_get_eq 0 - "seq" -> xmms_remote_set_eq 0 0 (take 10 $ repeat 0) - "sband" -> do xmms_remote_set_eq_band 0 0 10 - xmms_remote_set_eq_band 0 1 10 - "info" -> putStrLn =<< show `fmap` xmms_remote_get_info 0 - "get" -> putStrLn =<< xmms_remote_get_skin 0 - "set" -> xmms_remote_set_skin 0 "/usr/share/audacious/Skins/Osmosis" - "pause" -> xmms_remote_pause 0 - "play" -> xmms_remote_play 0 - "volume" -> putStrLn =<< show `fmap` xmms_remote_get_volume 0 - "pos" -> putStrLn =<< show `fmap` xmms_remote_get_playlist_pos 0 - "prev" -> xmms_remote_playlist_prev 0 - "next" -> xmms_remote_playlist_next 0 - "add" -> xmms_remote_playlist_add 0 ["/home/andrea/prove20041228.mp3"] - "file" -> putStrLn =<< xmms_remote_get_playlist_file 0 0 - "title" -> putStrLn =<< xmms_remote_get_playlist_title 0 0 - "version" -> putStrLn =<< show `fmap` xmms_remote_get_version 0 - "playlist" -> xmms_remote_playlist 0 ["/home/andrea/AndreaRobol28maggio2005.mp3"] False - "is_playing" -> do b <- xmms_remote_is_playing 0 - putStrLn $ show b - _ -> putStrLn "usage hc_xmms command" rmfile ./test/harc.hs rmdir ./test } Context: [small fixes Andrea Rossato **20070921183613] [Added Setup.lhs Andrea Rossato **20070921183153] [added cabal file, a test file and a README Andrea Rossato **20070921182818] [Bindings to a deprecated xmms_remote API Andrea Rossato **20070921154324] Patch bundle hash: eb7a2523e3fc916f12636d6b9d90b73ee9191a5f