1
0
Fork 0
forked from len0rd/rockbox

Code-police raid - cosmetic changes only.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15862 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dave Chapman 2007-12-01 02:46:31 +00:00
parent aaacb7010f
commit 05b158f81e

View file

@ -309,8 +309,8 @@ static int asf_read_packet(uint8_t** audiobuf, int* audiobufsize, int* packetlen
} }
static int get_timestamp(int *duration){ static int get_timestamp(int *duration)
{
uint8_t tmp8, packet_flags, packet_property; uint8_t tmp8, packet_flags, packet_property;
//int stream_id; //int stream_id;
int ec_length, opaque_data, ec_length_type; int ec_length, opaque_data, ec_length_type;
@ -333,8 +333,8 @@ static int asf_read_packet(uint8_t** audiobuf, int* audiobufsize, int* packetlen
/* TODO: We need a better way to detect endofstream */ /* TODO: We need a better way to detect endofstream */
if (tmp8 != 0x82) { if (tmp8 != 0x82) {
DEBUGF("Get timestamp: Detected end of stream\n"); DEBUGF("Get timestamp: Detected end of stream\n");
return ASF_ERROR_EOF;
return ASF_ERROR_EOF; } }
if (tmp8 & 0x80) { if (tmp8 & 0x80) {
@ -354,8 +354,15 @@ static int asf_read_packet(uint8_t** audiobuf, int* audiobufsize, int* packetlen
ec_length = 0; ec_length = 0;
} }
if (ci->read_filebuf(&packet_flags, 1) == 0) { DEBUGF("Detected end of stream 2\n"); return ASF_ERROR_EOF; } if (ci->read_filebuf(&packet_flags, 1) == 0) {
if (ci->read_filebuf(&packet_property, 1) == 0) {DEBUGF("Detected end of stream3\n"); return ASF_ERROR_EOF; } DEBUGF("Detected end of stream 2\n");
return ASF_ERROR_EOF;
}
if (ci->read_filebuf(&packet_property, 1) == 0) {
DEBUGF("Detected end of stream3\n");
return ASF_ERROR_EOF;
}
bytesread += 2; bytesread += 2;
datalen = GETLEN2b((packet_flags >> 1) & 0x03) + datalen = GETLEN2b((packet_flags >> 1) & 0x03) +
@ -372,6 +379,7 @@ static int asf_read_packet(uint8_t** audiobuf, int* audiobufsize, int* packetlen
datap = data; datap = data;
length = GETVALUE2b((packet_flags >> 5) & 0x03, datap); length = GETVALUE2b((packet_flags >> 5) & 0x03, datap);
datap += GETLEN2b((packet_flags >> 5) & 0x03); datap += GETLEN2b((packet_flags >> 5) & 0x03);
/* sequence value is not used */ /* sequence value is not used */
GETVALUE2b((packet_flags >> 1) & 0x03, datap); GETVALUE2b((packet_flags >> 1) & 0x03, datap);
datap += GETLEN2b((packet_flags >> 1) & 0x03); datap += GETLEN2b((packet_flags >> 1) & 0x03);
@ -382,10 +390,11 @@ static int asf_read_packet(uint8_t** audiobuf, int* audiobufsize, int* packetlen
*duration = get_short_le(datap); *duration = get_short_le(datap);
return send_time; return send_time;
} }
/*entry point for seeks*/ /*entry point for seeks*/
static int seek(int ms, asf_waveformatex_t* wfx){ static int seek(int ms, asf_waveformatex_t* wfx)
{
int time, duration, delta, temp, count=0; int time, duration, delta, temp, count=0;
/*estimate packet number from bitrate*/ /*estimate packet number from bitrate*/
@ -393,16 +402,18 @@ static int asf_read_packet(uint8_t** audiobuf, int* audiobufsize, int* packetlen
int packet_num = (ms*(wfx->bitrate>>3))/wfx->packet_size/1000; int packet_num = (ms*(wfx->bitrate>>3))/wfx->packet_size/1000;
int last_packet = ci->id3->filesize / wfx->packet_size; int last_packet = ci->id3->filesize / wfx->packet_size;
if(packet_num > last_packet){ if (packet_num > last_packet) {
packet_num = last_packet; packet_num = last_packet;
} }
/*calculate byte address of the start of that packet*/ /*calculate byte address of the start of that packet*/
int packet_offset = packet_num*wfx->packet_size; int packet_offset = packet_num*wfx->packet_size;
/*seek to estimated packet*/ /*seek to estimated packet*/
ci->seek_buffer(ci->id3->first_frame_offset+packet_offset); ci->seek_buffer(ci->id3->first_frame_offset+packet_offset);
temp = ms; temp = ms;
while(1){ while (1)
{
/*for very large files it can be difficult and unimportant to find the exact packet*/ /*for very large files it can be difficult and unimportant to find the exact packet*/
count++; count++;
@ -410,19 +421,19 @@ static int asf_read_packet(uint8_t** audiobuf, int* audiobufsize, int* packetlen
time = get_timestamp(&duration); time = get_timestamp(&duration);
DEBUGF("seeked to %d ms with duration %d\n", time, duration); DEBUGF("seeked to %d ms with duration %d\n", time, duration);
if(time < 0){ if (time < 0) {
/*unknown error, try to recover*/ /*unknown error, try to recover*/
DEBUGF("UKNOWN SEEK ERROR\n"); DEBUGF("UKNOWN SEEK ERROR\n");
ci->seek_buffer(ci->id3->first_frame_offset+initial_packet*wfx->packet_size); ci->seek_buffer(ci->id3->first_frame_offset+initial_packet*wfx->packet_size);
return ms; return ms;
} }
if((time+duration>=ms && time<=ms) || count > 10){ if ((time+duration>=ms && time<=ms) || count > 10) {
/*the get_timestamp function advances us 12 bytes past the packet start*/ /*the get_timestamp function advances us 12 bytes past the packet start*/
ci->seek_buffer(ci->curpos-12); ci->seek_buffer(ci->curpos-12);
DEBUGF("Found our packet! Now at %d packet\n", packet_num); DEBUGF("Found our packet! Now at %d packet\n", packet_num);
return time; return time;
}else { } else {
/*seek again*/ /*seek again*/
delta = ms-time; delta = ms-time;
/*estimate new packet number from bitrate and our current position*/ /*estimate new packet number from bitrate and our current position*/
@ -432,7 +443,7 @@ static int asf_read_packet(uint8_t** audiobuf, int* audiobufsize, int* packetlen
ci->seek_buffer(ci->id3->first_frame_offset+packet_offset); ci->seek_buffer(ci->id3->first_frame_offset+packet_offset);
} }
} }
} }
@ -517,7 +528,7 @@ next_track:
} }
elapsedtime = seek(ci->seek_time, &wfx); elapsedtime = seek(ci->seek_time, &wfx);
if(elapsedtime < 1){ if (elapsedtime < 1){
ci->seek_complete(); ci->seek_complete();
goto next_track; goto next_track;
} }
@ -532,8 +543,8 @@ next_track:
errcount = 0; errcount = 0;
new_packet: new_packet:
res = asf_read_packet(&audiobuf, &audiobufsize, &packetlength, &wfx); res = asf_read_packet(&audiobuf, &audiobufsize, &packetlength, &wfx);
if(res < 0){
if (res < 0) {
/* We'll try to recover from a parse error a certain number of /* We'll try to recover from a parse error a certain number of
* times. If we succeed, the error counter will be reset. * times. If we succeed, the error counter will be reset.
*/ */
@ -546,10 +557,8 @@ new_packet:
ci->advance_buffer(packetlength); ci->advance_buffer(packetlength);
goto new_packet; goto new_packet;
} }
} else if (res > 0) {
}else if (res > 0) { wma_decode_superframe_init(&wmadec, audiobuf, audiobufsize);
wma_decode_superframe_init(&wmadec,
audiobuf, audiobufsize);
for (i=0; i < wmadec.nb_frames; i++) for (i=0; i < wmadec.nb_frames; i++)
{ {
@ -559,9 +568,8 @@ new_packet:
ci->yield (); ci->yield ();
if (wmares < 0){ if (wmares < 0) {
/* Do the above, but for errors in decode. /* Do the above, but for errors in decode. */
*/
errcount++; errcount++;
DEBUGF("WMA decode error %d, errcount %d\n",wmares, errcount); DEBUGF("WMA decode error %d, errcount %d\n",wmares, errcount);
if (errcount > 5) { if (errcount > 5) {