3

I am trying to check if mplayer is playing an mp3 file. I currently use this line from python

strace -p " + str(mplayer.pid) + " 2>&1 | head -n 200 | grep 'read(3'

That is because I know that mplayer makes system calls when reading file from descriptor number 3. However, no matter how many lines I analyze, there is not a single reading operation.

Sam
  • 7,252
  • 16
  • 46
  • 65
Vintage
  • 238
  • 1
  • 2
  • 13
  • you're only looking at the first 200 lines of output. that's not nearly enough to account for all the syscalls done during an app's startup (of which there are many many many). – Marc B Oct 08 '12 at 16:27
  • 1
    It works fine for me. What `strace -p $pid -e read` shows? Consider a different approach. There is no guarantee the input will end up as fd #3 or that MPlayer will use `read` to read it. – Piotr Praszmo Oct 08 '12 at 16:37
  • Yes, that works. Indeed, this time it reads from #4. – Vintage Oct 08 '12 at 17:17
  • @Banthar You can rephrase it as an answer since your solution works – Eduard Florinescu Oct 08 '12 at 20:41

1 Answers1

0

I only know of one reliable way to determining whether MPlayer is playing something, and that is by running it as slave and reading its ASCII pipe continuously.

Watching text occurrences in that pipe of media data not found, Failed to open or STARTING PLAYBACK and whether the process has quit (it is done playing).

Barry Staes
  • 3,890
  • 4
  • 24
  • 30