PromyLOPh / pianobar

Console-based pandora.com player
http://6xq.net/pianobar/
Other
1.74k stars 320 forks source link

Send song timeLength on event songstart! #427

Closed josefson closed 10 years ago

josefson commented 10 years ago

I have been suffering of constants freezings with the software where the song time count freezes and i only can control+c. I started thinking about it and i thought if could get the songLenghtTime with eventcmd i could predict when the next songstart event would come and if it didn't i could kill pianobar and start it again. Which is what i have been doing it, but manually. But the thing is... songstart don't send the songLength, but i though it would because pianobar displays that info. But anyhow, is that the better way for me to solve my problem? Is there another solution?

codyps commented 10 years ago

Well, it would be better for us to fix the actual cause of the freeze (though I'm not sure there is a reason not to pass the songLength to eventcmd).

To grab some info to debug the hang, I'll walk through grabbing a backtrace.

  1. To get the most info, build pianobar with make 'CFLAGS=-ggdb -O0'.
  2. run pianobar under gdb with gdb -ex run --args ./pianobar
  3. when pianobar freezes, press ctrl-c (which gets us to a gdb prompt).
  4. type info threads and press enter. This should give a list of the current threads in pianobar. Typically, there will be threads with ID 1,2,3, and 4.
  5. do thread apply 1 2 3 4 bt (where "1 2 3 4" is the list of thread IDs you saw from info threads
  6. Paste that output here.

It would also be useful to do generate-core-file and keep the core.XXXXX file it generates for debugging later (along with the pianobar executable and source code).

PromyLOPh commented 10 years ago

See https://github.com/PromyLOPh/pianobar/issues/64#issuecomment-620791 for an explanation. I should add that Pandora added an (optional) field to their response which contains the song duration since then.

josefson commented 10 years ago

I feel silly. When i tried to recompile pianobar i discovered that somehow my package manager got pianobar installed without all the dependencies. Now i got all of it, it isn't freezing as far as i tested. Sorry for the inconvenience, and for my silliness. I think you can close this. And again, thank you so much for this software. I can't stress enough how much i love it.

nikmartin commented 10 years ago

do you still need debug info? I'm also experiencing this every three songs now. It seems to be related to commercials that sneak in. I can compile with debug info if you need it

nikmartin commented 10 years ago

each time it happens, it looks like this:

(i) Receiving new playlist... Ok.
|>  "Daylight" by "Matt & Kim" on "Grand" <3 @ Vampire Weekend Radio
#   -00:02/02:51

And it's just sitting there frozen. I forgot about it today for a while, and like 20 minutes later it started playing, and a bunch of error messages had scrolled by. This has gotten progressively worse the past week

josefson commented 10 years ago

As i said, my problem was solved by installing some missing dependencies (libao and gnutls). I think it was a error by brew somehow not installing them at the time. Now i am in heaven. xD!

nikmartin commented 10 years ago

EDIT: I made a new issue #429 since this may be unrelated to this issue

josefson commented 10 years ago

I don't know if i have to open another issue, but: 1- My initial issue was freezing the application so i had to Control+C, cuz nothing would work 2- Now i am having exactly the same error of @nikmartin . Eventually, songs stops 1-2 seconds from finishing. But now, I still can use pianobar ui(n,q,s, etc). Here are some examples: 1i 1f

Also i would like to add that i do not use PulseAudio as i am inside a osx system. With that in mind, i will try to follow @jmesmon instructions and see what happens.

josefson commented 10 years ago

Ok, here it is:

(gdb) info threads
  Id   Target Id         Frame
  23   Thread 0x2c03 of process 50731 0x00007fff91a27a1a in ?? ()
  22   Thread 0x2b0b of process 50731 0x00007fff91a2c94a in ?? ()
  2    Thread 0x161f of process 50731 0x00007fff91a2c662 in ?? ()
* 1    Thread 0x1503 of process 50731 0x00007fff91a2b9aa in ?? ()
(gdb) thread apply 1 2 22 23 bt

Thread 1 (Thread 0x1503 of process 50731):
#0  0x00007fff91a2b9aa in ?? ()
#1  0x000000010000a742 in BarReadline (buf=0x7fff5fbff7a6 "", bufSize=2, mask=0x0,
    input=0x10001de8c, flags=(BAR_RL_FULLRETURN | BAR_RL_NOECHO), timeout=1)
    at src/ui_readline.c:79
#2  0x00000001000021db in BarMainHandleUserInput (app=0x1000180d8) at src/main.c:214
#3  0x0000000100001374 in BarMainLoop (app=0x1000180d8) at src/main.c:389
#4  0x00000001000010d0 in main (argc=1, argv=0x7fff5fbff960) at src/main.c:478

Thread 2 (Thread 0x161f of process 50731):
#0  0x00007fff91a2c662 in ?? ()
#1  0x00007fff901c243d in ?? ()
#2  0x0000000000000000 in ?? ()

Thread 22 (Thread 0x2b0b of process 50731):
#0  0x00007fff91a2c94a in ?? ()
#1  0x00000001000139e8 in WaitressPollLoop (fd=5, events=1, timeout=30000)
    at src/libwaitress/waitress.c:435
#2  0x0000000100010fd9 in WaitressPollRead (data=0x10001dc00, buf=0x10080b400,
    count=10239) at src/libwaitress/waitress.c:506
#3  0x0000000100010e44 in WaitressOrdinaryRead (data=0x10001dc00, buf=0x10080b400 "q",
    size=10239, retSize=0x1006b0de0) at src/libwaitress/waitress.c:526
#4  0x00000001000120d3 in WaitressReceiveResponse (waith=0x10001dc00)
    at src/libwaitress/waitress.c:1093
#5  0x0000000100010c24 in WaitressFetchCall (waith=0x10001dc00)
    at src/libwaitress/waitress.c:1141
#6  0x0000000100002599 in BarPlayerThread (data=0x100018240) at src/player.c:504
#7  0x00007fff8a162899 in ?? ()
#8  0x0000000000000383 in ?? ()
#9  0x00000001006b1000 in ?? ()
#10 0x00000001006b0f50 in ?? ()
#11 0x00007fff8a16272a in ?? ()
#12 0x0000000000000000 in ?? ()

Thread 23 (Thread 0x2c03 of process 50731):
#0  0x00007fff91a27a1a in ?? ()
#1  0x00007fff91a26d18 in ?? ()
#2  0x0000000100000000 in ?? ()
#3  0x0000000300000000 in ?? ()
#4  0x0000000100000018 in ?? ()
#5  0x000000010039acd8 in ?? ()
#6  0x0000000100528910 in ?? ()
#7  0x00000001005286c0 in ?? ()
#8  0x0000000000000000 in ?? ()
PromyLOPh commented 10 years ago

Can you compile with debug symbols (-g in CFLAGS, unless you already did that) and run “bt full” instead of “bt”? Please remove sensitive data (username, password, authentication token, …) from the output before posting it here or send me a PM/email.

tcaddy commented 10 years ago

@PromyLOPh Per your request in #429, I was able to build Pianobar (at the 2013.09.15 tag) with the CFLAGS, but I don't have gdb installed in OSX and there is not gdb package available from Homebrew.

Is there a way to debug this in OSX or will that only work on Linux platforms?


EDIT: I figured out how to install gdb: brew install https://raw.github.com/Homebrew/homebrew-dupes/master/gdb.rb

Source: http://stackoverflow.com/questions/19554439/gdb-missing-in-os-x-mavericks

It is configuring now, I will try to debug again soon.

tcaddy commented 10 years ago

It took a while, but I it finally stopped playing. Here is the output of the gdb command:

(gdb) thread apply 1 2 bt full

Thread 1 (Thread 0x1803 of process 48066):
#0  0x00007fff94da49aa in ?? ()
No symbol table info available.
#1  0x000000010000aa0a in BarReadline (buf=0x7fff5fbff996 "", bufSize=2, 
    mask=0x0, input=0x10001de8c, flags=(BAR_RL_FULLRETURN | BAR_RL_NOECHO), 
    timeout=1) at src/ui_readline.c:80
        curFd = -1
        chr = 0 '\000'
        timeoutstruct = {tv_sec = 1, tv_usec = 0}
        bufPos = 0
        bufLen = 0
        escapeState = 0 '\000'
        set = {fds_bits = {1, 0 <repeats 31 times>}}
        echo = false
#2  0x000000010000253b in BarMainHandleUserInput (app=0x1000180d8)
    at src/main.c:214
        buf = "\000"
#3  0x00000001000016e4 in BarMainLoop (app=0x1000180d8) at src/main.c:388
        playerThread = 0x1003a3000
#4  0x0000000100001440 in main (argc=1, argv=0x7fff5fbffb50) at src/main.c:478
        app = {ph = {user = {listenerId = 0x1004095c0 "137005537", 
              authToken = 0x100427ce0 "xxxxx=="}, stations = 0x100601100, genreStations = 0x0, partner = {
              in = 0x100808800, out = 0x10080aa00, 
              authToken = 0x1006002d0 "xxx", 
              device = 0x10040fae0 "android-generic", 
              user = 0x100411070 "android", 
              password = 0x100427cb0 "AC7IBG09A3DTSYM4R41UJWL07VLN8JI7", 
              id = 42}, timeOffset = 1}, waith = {timeout = 30000, 
            method = WAITRESS_METHOD_POST, 
            extraHeaders = 0x100015c54 "Content-Type: text/plain\r\n", 
            postData = 0x100704ae0 "", data = 0x7fff5fbff460, 
            callback = 0x100010950 <WaitressFetchBufCb>, 
            tlsFingerprint = 0x10001ddc8 "-\n\375\257\241oK\\\nC\363\313\035GR\371SU\a\300?+-acdeghijnpqrstux$b()= vPS^", url = {url = 0x0, tls = true, 
              user = 0x0, password = 0x0, 
              host = 0x100412020 "tuner.pandora.com", port = 0x0, 
              tlsPort = 0x0, path = 0x7fff5fbff508 "\020,c"}, proxy = {
              url = 0x0, tls = false, user = 0x0, password = 0x0, host = 0x0, 
              port = 0x0, tlsPort = 0x0, path = 0x0}, tlsCred = 0x100700440, 
            request = {sockfd = 6, readWriteRet = WAITRESS_RET_OK, 
              contentLength = 0, contentReceived = 0, chunkSize = 0, 
              contentLengthKnown = false, chunkedState = CHUNKSIZE, 
              buf = 0x10200c000 "HTTP/1.1 502 Bad Gateway", 
              dataHandler = 0x100010d10 <WaitressHandleIdentity>, 
              read = 0x100013c00 <WaitressGnutlsRead>, 
              write = 0x100013c80 <WaitressGnutlsWrite>, 
              tlsSession = 0x102004c00}}, player = {doQuit = false, 
            doPause = false, channels = 0 '\000', aoError = 0 '\000', 
            mode = PLAYER_FREED, audioFormat = PIANO_AF_UNKNOWN, scale = 0, 
            gain = 0, songDuration = 0, songPlayed = 0, samplerate = 0, 
            bufferFilled = 0, bufferRead = 0, bytesReceived = 0, 
            sampleSizeN = 0, sampleSizeCurr = 0, sampleSize = 0x0, 
            aacHandle = 0x0, mp3Stream = {buffer = 0x0, bufend = 0x0, 
              skiplen = 0, sync = 0, freerate = 0, this_frame = 0x0, 
              next_frame = 0x0, ptr = {byte = 0x0, cache = 0, left = 0}, 
              anc_ptr = {byte = 0x0, cache = 0, left = 0}, anc_bitlen = 0, 
              main_data = 0x0, md_len = 0, options = 0, 
              error = MAD_ERROR_NONE}, mp3Frame = {header = {layer = 0, 
                mode = MAD_MODE_SINGLE_CHANNEL, mode_extension = 0, 
                emphasis = MAD_EMPHASIS_NONE, bitrate = 0, samplerate = 0, 
                crc_check = 0, crc_target = 0, flags = 0, private_bits = 0, 
                duration = {seconds = 0, fraction = 0}}, options = 0, 
              sbsample = {{{0 <repeats 32 times>} <repeats 36 times>}, {{
                    0 <repeats 32 times>} <repeats 36 times>}}, 
              overlap = 0x0}, mp3Synth = {filter = {{{{{0, 0, 0, 0, 0, 0, 0, 
                        0} <repeats 16 times>}, {{0, 0, 0, 0, 0, 0, 0, 
                        0} <repeats 16 times>}}, {{{0, 0, 0, 0, 0, 0, 0, 
                        0} <repeats 16 times>}, {{0, 0, 0, 0, 0, 0, 0, 
                        0} <repeats 16 times>}}}, {{{{0, 0, 0, 0, 0, 0, 0, 
                        0} <repeats 16 times>}, {{0, 0, 0, 0, 0, 0, 0, 
                        0} <repeats 16 times>}}, {{{0, 0, 0, 0, 0, 0, 0, 
                        0} <repeats 16 times>}, {{0, 0, 0, 0, 0, 0, 0, 
                        0} <repeats 16 times>}}}}, phase = 0, pcm = {
                samplerate = 0, channels = 0, length = 0, samples = {{
                    0 <repeats 1152 times>}, {0 <repeats 1152 times>}}}}, 
            audioOutDevice = 0x0, settings = 0x0, buffer = 0x0, pauseMutex = {
              __sig = 0, __opaque = '\000' <repeats 55 times>}, pauseCond = {
              __sig = 0, __opaque = '\000' <repeats 39 times>}, waith = {
              timeout = 0, method = WAITRESS_METHOD_GET, extraHeaders = 0x0, 
              postData = 0x0, data = 0x0, callback = 0x0, 
              tlsFingerprint = 0x0, url = {url = 0x0, tls = false, user = 0x0, 
                password = 0x0, host = 0x0, port = 0x0, tlsPort = 0x0, 
                path = 0x0}, proxy = {url = 0x0, tls = false, user = 0x0, 
                password = 0x0, host = 0x0, port = 0x0, tlsPort = 0x0, 
                path = 0x0}, tlsCred = 0x0, request = {sockfd = 0, 
                readWriteRet = WAITRESS_RET_ERR, contentLength = 0, 
                contentReceived = 0, chunkSize = 0, 
                contentLengthKnown = false, chunkedState = CHUNKSIZE, 
                buf = 0x0, dataHandler = 0x0, read = 0x0, write = 0x0, 
                tlsSession = 0x0}}}, settings = {autoselect = true, 
            history = 5, maxPlayerErrors = 5, volume = -14, 
            sortOrder = BAR_SORT_NAME_AZ, audioQuality = PIANO_AQ_HIGH, 
            username = 0x1004111f0 "xxxx@xxxxxxxxxx.com", 
            password = 0x10040e8e0 "xxxxxxxx", passwordCmd = 0x0, 
            controlProxy = 0x0, proxy = 0x0, 
            autostartStation = 0x100412040 "1814131805862398433", 
            eventCmd = 0x10040f5e0 "/Users/administrator/.config/pianobar/pianobar-lastfm.rb", loveIcon = 0x100412170 " <3", banIcon = 0x100411d80 " </3", 
            atIcon = 0x100411bd0 " @ ", 
            npSongFormat = 0x100411e70 "\"%t\" by \"%a\" on \"%l\"%r%@%s", 
            npStationFormat = 0x100411e90 "Station \"%n\" (%i)", 
            listSongFormat = 0x100410dd0 "%i) %a - %t%r", 
            fifo = 0x100805200 "/Users/administrator/.config/pianobar/ctl", 
            rpcHost = 0x100412020 "tuner.pandora.com", rpcTlsPort = 0x0, 
            partnerUser = 0x100411aa0 "android", 
            partnerPassword = 0x100410fa0 "AC7IBG09A3DTSYM4R41UJWL07VLN8JI7", 
            device = 0x100410fd0 "android-generic", 
            inkey = 0x100411840 "R=U!LH$O2B#", 
            outkey = 0x100410d60 "6#26FRL$ZWD", 
            tlsFingerprint = "-\n\375\257\241oK\\\nC\363\313\035GR\371SU\a\300", keys = "?+-acdeghijnpqrstux$b()= vPS^", msgFormat = {{prefix = 0x0, 
                postfix = 0x0}, {prefix = 0x1004100c0 "(i) ", postfix = 0x0}, {
                prefix = 0x10040e9a0 "|>  ", postfix = 0x0}, {
                prefix = 0x10040fd30 "#   ", postfix = 0x0}, {
                prefix = 0x1004096d0 "/!\\ ", postfix = 0x0}, {
                prefix = 0x1004115e0 "[?] ", postfix = 0x0}, {
                prefix = 0x10040dce0 "\t", postfix = 0x0}}}, playlist = 0x0, 
          songHistory = 0x100613d60, curStation = 0x0, doQuit = 0 '\000', 
          input = {set = {fds_bits = {1, 0 <repeats 31 times>}}, maxfd = 1, 
            fds = {0, -1}}, playerErrors = 0}
        termOrig = {c_iflag = 27394, c_oflag = 3, c_cflag = 19200, 
          c_lflag = 1483, 
          c_cc = "\004\377\377\177\027\025\022\377\003\034\032\031\021\023\026\017\001\000\024\377", c_ispeed = 9600, c_ospeed = 9600}
        pret = PIANO_RET_OK

Thread 2 (Thread 0x1a1b of process 48066):
#0  0x00007fff94da5662 in ?? ()
No symbol table info available.
#1  0x00007fff89e9243d in ?? ()
No symbol table info available.
#2  0x0000000000000000 in ?? ()
No symbol table info available.
PromyLOPh commented 10 years ago

And there’s no error message like “network error: foobar”?

Here’s what the backtrace tells me so far: There is no station selected (curStation = NULL) and no playlist exists (playlist = NULL). The player exited and was cleaned up, so I believe pianobar should have requested a new playlist at that point, but somehow the station was set to NULL.

The HTTP stuff looks strange: app.waith.url.path contains a garbage value, the receive buffer reads “HTTP/1.1 502 Bad Gateway” and postData is an empty string (which should not happen).

Can you start pianobar with gdb, set a breakpoint on BarUiPianoCall and dump the program’s state at that point:

set pagination off
break BarUiPianoCall
command
bt full
c
end

I’m only interested in the last one, right before the audio stops.

Also note this backtrace is different from the one @josefson posted.