Mic92 / python-mpd2

Python library which provides a client interface for the Music Player Daemon.
GNU Lesser General Public License v3.0
352 stars 119 forks source link

setvol doesn't throw exception #75

Closed andreaskoelsch closed 8 years ago

andreaskoelsch commented 8 years ago

Hi, I have the following problem: Every once in a while my Raspberry Pi re-detects my USB Soundcard. After that, I can't set the volume via mpdclient.setvol(x), it just shows '0' in mpdclient.status()['volume']. However, no exception is thrown. Now, here's the funny thing. Running mpc also shows volume 0%. But running mpc volume 50 errors with problems setting volume. Now, if I try setvol(x) again with mpdclient, it also raises an exception: mpd.CommandError: [52@0] {setvol} problems setting volume

I think this exception should to be thrown, without having to use mpc before.

Mic92 commented 8 years ago

Could you run tcpdump -n -i any port 6600 -A on your PI while setting mpdclient.setvol(x) the first time (assuming that your mpd listens on port 6600).

andreaskoelsch commented 8 years ago
$ sudo tcpdump -n -i any port 6600 -A
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
15:49:40.004616 IP 127.0.0.1.33433 > 127.0.0.1.6600: Flags [P.], seq 3904968327:3904968339, ack 2981525743, win 342, options [nop,nop,TS val 93401131 ecr 93401041], length 12
E..@..@.@.;4..................x....V.4.....
..0+../.setvol "10"

15:49:40.005209 IP 127.0.0.1.6600 > 127.0.0.1.33433: Flags [P.], seq 1:4, ack 12, win 342, options [nop,nop,TS val 93401131 ecr 93401131], length 3
E..7o.@.@.................x........V.+.....
..0+..0+OK

15:49:40.005903 IP 127.0.0.1.33433 > 127.0.0.1.6600: Flags [.], ack 4, win 342, options [nop,nop,TS val 93401131 ecr 93401131], length 0
E..4..@.@.;?..................x....V.(.....
..0+..0+
andreaskoelsch commented 8 years ago

I just played around with it. It's very random. Sometimes it does error, before using mpc, sometimes it doesn't...

Mic92 commented 8 years ago

This library only implements the text protocol of MPD. I cannot fix bugs or recognize bugs inside MPD, but only reporting errors, reported by MPD itself. My guess is, that your soundsubsystem/sound card device driver is broken and returns not the correct value.

andreaskoelsch commented 8 years ago

Okay... I just realized, mpc has the exact same behaviour. It shows volume: 0%. If I want to change it to the value from before the soundcard disconnected, it does not error. I have to change it to a different value. So what I do now is: setvol(x), setvol(x+1), setvol(x). This way, the exception will be thrown, if there is a soundcard problem.