Mercurial > mplayer.hg
comparison mplayer.c @ 34605:b85d4539ad07
Try to detect when an audio driver ends up hanging after
repeated seeks.
This should at least give a clear message in the case of
bug 2039.
author | reimar |
---|---|
date | Sun, 12 Feb 2012 13:35:17 +0000 |
parents | fede902a408c |
children | ed612f6f4778 |
comparison
equal
deleted
inserted
replaced
34604:1efa9c367aab | 34605:b85d4539ad07 |
---|---|
2117 int playsize; | 2117 int playsize; |
2118 int playflags = 0; | 2118 int playflags = 0; |
2119 int audio_eof = 0; | 2119 int audio_eof = 0; |
2120 int bytes_to_write; | 2120 int bytes_to_write; |
2121 int format_change = 0; | 2121 int format_change = 0; |
2122 int timeout = 0; | |
2122 sh_audio_t *const sh_audio = mpctx->sh_audio; | 2123 sh_audio_t *const sh_audio = mpctx->sh_audio; |
2123 | 2124 |
2124 current_module = "play_audio"; | 2125 current_module = "play_audio"; |
2125 | 2126 |
2126 while (1) { | 2127 while (1) { |
2130 // in get_space() | 2131 // in get_space() |
2131 ao_data.pts = ((mpctx->sh_video ? mpctx->sh_video->timer : 0) + mpctx->delay) * 90000.0; | 2132 ao_data.pts = ((mpctx->sh_video ? mpctx->sh_video->timer : 0) + mpctx->delay) * 90000.0; |
2132 bytes_to_write = mpctx->audio_out->get_space(); | 2133 bytes_to_write = mpctx->audio_out->get_space(); |
2133 if (mpctx->sh_video || bytes_to_write >= ao_data.outburst) | 2134 if (mpctx->sh_video || bytes_to_write >= ao_data.outburst) |
2134 break; | 2135 break; |
2136 if (timeout++ > 10) { | |
2137 mp_msg(MSGT_CPLAYER, MSGL_WARN, "Audio device got stuck!\n"); | |
2138 break; | |
2139 } | |
2135 | 2140 |
2136 // handle audio-only case: | 2141 // handle audio-only case: |
2137 // this is where mplayer sleeps during audio-only playback | 2142 // this is where mplayer sleeps during audio-only playback |
2138 // to avoid 100% CPU use | 2143 // to avoid 100% CPU use |
2139 sleep_time = (ao_data.outburst - bytes_to_write) * 1000 / ao_data.bps; | 2144 sleep_time = (ao_data.outburst - bytes_to_write) * 1000 / ao_data.bps; |