我的简单音频流应用程序在 1.6 中完美运行,而 2.1 在 2.2 中无法运行。我不知道为什么。它在模拟器上运行良好,在实际的 2.2 设备上,音频在大约 10 分钟左右后意外停止。当我在手机(HTC EVO)上查看 logcat 时,我看到:
I/HTTPStream( 65): 1358 Bytes read, progress 34346/65536
I/HTTPStream( 65): 1358 Bytes read, progress 35704/65536
I/HTTPStream( 65): 1359 Bytes read, progress 37063/65536
I/HTTPStream( 65): 1358 Bytes read, progress 38421/65536
I/HTTPStream( 65): 1358 Bytes read, progress 39779/65536
I/HTTPStream( 65): 1359 Bytes read, progress 41138/65536
I/HTTPStream( 65): 2716 Bytes read, progress 43854/65536
I/HTTPStream( 65): 1359 Bytes read, progress 45213/65536
I/HTTPStream( 65): 1358 Bytes read, progress 46571/65536
然后突然:
E/HTTPStream( 65): recv failed, errno = 11 (Try again)
I/HTTPDataSource( 65): Retry ... 0 times left
W/HTTPStream( 65): Calling connect()...
I/AudioHardwareQSD( 65): AudioHardware pcm playback is going to standby.
D/StreamProcess( 65): OutputStreamProcess::ResetAOLC()
W/HTTPStream( 65): Returned from connect()...
E/HTTPDataSource( 65): retrying connection failed
V/MediaPlayerService( 65): [2] notify (0x355d0, 4, 0, 0)
I/MediaPlayer( 1719): MediaPlayer handleMessage what=4
I/Prefetcher( 65): [0x3db60] cache below low water mark, filling cache.
W/HTTPStream( 65): Calling connect()...
W/HTTPStream( 65): Returned from connect()...
V/MediaPlayerService( 65): [2] notify (0x355d0, 4, 0, 0)
I/MediaPlayer( 1719): MediaPlayer handleMessage what=4
I/Prefetcher( 65): [0x3db60] cache below low water mark, filling cache.
E/HTTPStream( 65): recv failed, errno = 9 (Bad file number)
V/MediaPlayerService( 65): [2] notify (0x355d0, 4, 0, 0)
I/MediaPlayer( 1719): MediaPlayer handleMessage what=4
I/Prefetcher( 65): [0x3db60] cache below low water mark, filling cache.
E/HTTPStream( 65): recv failed, errno = 9 (Bad file number)
V/MediaPlayerService( 65): [2] notify (0x355d0, 4, 0, 0)
I/MediaPlayer( 1719): MediaPlayer handleMessage what=4
I/Prefetcher( 65): [0x3db60] cache below low water mark, filling cache.
该代码基本上直接来自谷歌自己的文档“从文件或流播放”:http: //developer.android.com/guide/topics/media/index.html。
它再次在 1.6 和 2.1 以及 2.2模拟器上完美运行,但在 2.2设备上像上面一样失败。
这让我发疯,有什么想法吗?谢谢。
编辑:这是我手机上的 logcat 运行时的另一个示例,突然接收失败,服务器“消失”:
I/HTTPStream( 65): 29329 Bytes read, progress 29329/65536
I/HTTPStream( 65): 1448 Bytes read, progress 30777/65536
I/HTTPStream( 65): 1448 Bytes read, progress 32225/65536
I/HTTPStream( 65): 2896 Bytes read, progress 35121/65536
I/HTTPStream( 65): 1448 Bytes read, progress 36569/65536
I/HTTPStream( 65): 2896 Bytes read, progress 39465/65536
I/HTTPStream( 65): 5792 Bytes read, progress 45257/65536
I/HTTPStream( 65): 1448 Bytes read, progress 46705/65536
I/HTTPStream( 65): 4344 Bytes read, progress 51049/65536
I/HTTPStream( 65): 7240 Bytes read, progress 58289/65536
I/HTTPStream( 65): 5792 Bytes read, progress 64081/65536
I/HTTPStream( 65): 1448 Bytes read, progress 65529/65536
I/HTTPStream( 65): 7 Bytes read, progress 65536/65536
I/HTTPStream( 65): 21713 Bytes read, progress 21713/65536
I/HTTPStream( 65): 1448 Bytes read, progress 23161/65536
I/HTTPStream( 65): 5792 Bytes read, progress 28953/65536
I/HTTPStream( 65): 4344 Bytes read, progress 33297/65536
I/HTTPStream( 65): 1448 Bytes read, progress 34745/65536
I/HTTPStream( 65): 5792 Bytes read, progress 40537/65536
I/HTTPStream( 65): 1448 Bytes read, progress 41985/65536
I/HTTPStream( 65): 5792 Bytes read, progress 47777/65536
I/HTTPStream( 65): 5792 Bytes read, progress 53569/65536
I/HTTPStream( 65): 1448 Bytes read, progress 55017/65536
I/HTTPStream( 65): 2896 Bytes read, progress 57913/65536
I/HTTPStream( 65): 4344 Bytes read, progress 62257/65536
I/HTTPStream( 65): 1448 Bytes read, progress 63705/65536
I/HTTPStream( 65): 1831 Bytes read, progress 65536/65536
I/HTTPStream( 65): 31473 Bytes read, progress 31473/65536
I/HTTPStream( 65): 1448 Bytes read, progress 32921/65536
I/HTTPStream( 65): 23168 Bytes read, progress 56089/65536
I/HTTPStream( 65): 1448 Bytes read, progress 57537/65536
I/HTTPStream( 65): 4344 Bytes read, progress 61881/65536
I/HTTPStream( 65): 2896 Bytes read, progress 64777/65536
I/HTTPStream( 65): 759 Bytes read, progress 65536/65536
I/HTTPStream( 65): 36889 Bytes read, progress 36889/65536
I/HTTPStream( 65): 1448 Bytes read, progress 38337/65536
I/HTTPStream( 65): 4344 Bytes read, progress 42681/65536
I/HTTPStream( 65): 10136 Bytes read, progress 52817/65536
I/HTTPStream( 65): 12719 Bytes read, progress 65536/65536
I/HTTPStream( 65): 3209 Bytes read, progress 3209/65536
E/HTTPStream( 65): recv failed, server is gone, total received: 3209 bytes
同样,在 1.6 和 2.1 以及 2.2模拟器中工作正常,只是在 2.2设备上失败,特别是在我的 HTC EVO 4G 上。请注意,这是使用信号良好的 Wi-Fi。