@@ -39,7 +39,7 @@ import Data.Tuple (swap)
3939import Control.Monad.State.Strict
4040import System.Directory (doesFileExist , findExecutable , createDirectoryIfMissing ,
4141 getXdgDirectory , XdgDirectory (.. ))
42- import System.IO (hPutStrLn , hGetLine , stderr )
42+ import System.IO (hPutStrLn , stderr )
4343import System.Process (runInteractiveProcess , waitForProcess )
4444import System.Clock (TimeSpec (.. ), diffTimeSpec )
4545import System.Random (randomR , newStdGen )
@@ -85,7 +85,6 @@ start opts (Playlist folders music) = do
8585 , mpgInput
8686 , refreshLoop
8787 , uptimeLoop
88- , errorLoop
8988 ]
9089
9190 putMVar hState HState
@@ -158,12 +157,12 @@ mpgLoop = runForever do
158157 case mmpg of
159158 Nothing -> shutdown $ Just $ " Cannot find " ++ mp3Tool ++ " in path"
160159 Just mppath -> do
161- mv <- try $ runInteractiveProcess mppath [" -R" , " -" ] Nothing Nothing
160+ mv <- try $ runInteractiveProcess mppath [" -R" , " --remote-err " ] Nothing Nothing
162161 case mv of
163162 Left (ex :: SomeException ) ->
164163 warnA $ mppath ++ " failed to start; retrying: " ++ show ex
165164
166- Right (writeh, readh , errh, pid) -> do
165+ Right (writeh, _ , errh, pid) -> do
167166 ct <- modifyHS $ \ st -> let sp = spawns st + 1 in (st
168167 { mpgPid = Just pid
169168 , status = Stopped
@@ -172,7 +171,7 @@ mpgLoop = runForever do
172171 , spawns = sp
173172 }, sp)
174173
175- putMVar mpg Mpg { readh, errh, writeh }
174+ putMVar mpg Mpg { errh, writeh }
176175
177176 when (ct > 1 ) $ warnA $ mp3Tool ++ " #" ++ show ct ++ " : Ready"
178177 catch @ SomeException (void $ waitForProcess pid) (const $ pure () )
@@ -229,20 +228,13 @@ showTimeDiff = showTimeDiff_ False
229228
230229------------------------------------------------------------------------
231230
232- -- | Handle, and display errors produced by mpg123
233- errorLoop :: IO ()
234- errorLoop = runForever $
235- readMVar mpg <&> errh >>= hGetLine >>= (warnA . (" mpg123 err: " ++ ))
236-
237- ------------------------------------------------------------------------
238-
239231-- | Handle messages arriving over a pipe from the decoder process. When
240232-- shutdown kills the other end of the pipe, hGetLine will fail, so we
241233-- take that chance to exit.
242234--
243235mpgInput :: IO ()
244236mpgInput = runForever $ do
245- line <- P. hGetLine =<< readh <$> readMVar mpg
237+ line <- P. hGetLine =<< errh <$> readMVar mpg
246238 case mpgParser line of
247239 Right m -> handleMsg m
248240 Left (Just e) -> warnA (" mpg123: " ++ e)
0 commit comments