diff options
-rw-r--r-- | apps/playback.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/apps/playback.c b/apps/playback.c index a99a22372e..933208c383 100644 --- a/apps/playback.c +++ b/apps/playback.c | |||
@@ -295,12 +295,25 @@ static struct mp3entry *bufgetid3(int handle_id) | |||
295 | struct mp3entry *id3; | 295 | struct mp3entry *id3; |
296 | ssize_t ret = bufgetdata(handle_id, 0, (void *)&id3); | 296 | ssize_t ret = bufgetdata(handle_id, 0, (void *)&id3); |
297 | 297 | ||
298 | if (ret < 0 || ret != sizeof(struct mp3entry)) | 298 | if (ret != sizeof(struct mp3entry)) |
299 | return NULL; | 299 | return NULL; |
300 | 300 | ||
301 | return id3; | 301 | return id3; |
302 | } | 302 | } |
303 | 303 | ||
304 | static bool bufreadid3(int handle_id, struct mp3entry *id3out) | ||
305 | { | ||
306 | struct mp3entry *id3 = bufgetid3(handle_id); | ||
307 | |||
308 | if (id3) | ||
309 | { | ||
310 | copy_mp3entry(id3out, id3); | ||
311 | return true; | ||
312 | } | ||
313 | |||
314 | return false; | ||
315 | } | ||
316 | |||
304 | static bool clear_track_info(struct track_info *track) | 317 | static bool clear_track_info(struct track_info *track) |
305 | { | 318 | { |
306 | /* bufclose returns true if the handle is not found, or if it is closed | 319 | /* bufclose returns true if the handle is not found, or if it is closed |
@@ -562,8 +575,7 @@ struct mp3entry* audio_current_track(void) | |||
562 | if (tracks[cur_idx].id3_hid >= 0) | 575 | if (tracks[cur_idx].id3_hid >= 0) |
563 | { | 576 | { |
564 | /* The current track's info has been buffered but not read yet, so get it */ | 577 | /* The current track's info has been buffered but not read yet, so get it */ |
565 | if (bufread(tracks[cur_idx].id3_hid, sizeof(struct mp3entry), write_id3) | 578 | if (bufreadid3(tracks[cur_idx].id3_hid, write_id3)) |
566 | == sizeof(struct mp3entry)) | ||
567 | return write_id3; | 579 | return write_id3; |
568 | } | 580 | } |
569 | 581 | ||
@@ -611,8 +623,7 @@ struct mp3entry* audio_next_track(void) | |||
611 | 623 | ||
612 | if (tracks[next_idx].id3_hid >= 0) | 624 | if (tracks[next_idx].id3_hid >= 0) |
613 | { | 625 | { |
614 | if (bufread(tracks[next_idx].id3_hid, sizeof(struct mp3entry), othertrack_id3) | 626 | if (bufreadid3(tracks[next_idx].id3_hid, othertrack_id3)) |
615 | == sizeof(struct mp3entry)) | ||
616 | return othertrack_id3; | 627 | return othertrack_id3; |
617 | else | 628 | else |
618 | return NULL; | 629 | return NULL; |
@@ -639,15 +650,8 @@ bool audio_peek_track(struct mp3entry* id3, int offset) | |||
639 | next_idx = (track_ridx + new_offset) & MAX_TRACK_MASK; | 650 | next_idx = (track_ridx + new_offset) & MAX_TRACK_MASK; |
640 | 651 | ||
641 | if (tracks[next_idx].id3_hid >= 0) | 652 | if (tracks[next_idx].id3_hid >= 0) |
642 | { | 653 | return bufreadid3(tracks[next_idx].id3_hid, id3); |
643 | struct mp3entry *id3src; | 654 | |
644 | if (bufgetdata(tracks[next_idx].id3_hid, 0, (void**)&id3src) | ||
645 | == sizeof(struct mp3entry)) | ||
646 | { | ||
647 | copy_mp3entry(id3, id3src); | ||
648 | return true; | ||
649 | } | ||
650 | } | ||
651 | return false; | 655 | return false; |
652 | } | 656 | } |
653 | 657 | ||
@@ -1003,7 +1007,7 @@ static void audio_update_trackinfo(void) | |||
1003 | 1007 | ||
1004 | /* Load the curent track's metadata into curtrack_id3 */ | 1008 | /* Load the curent track's metadata into curtrack_id3 */ |
1005 | if (CUR_TI->id3_hid >= 0) | 1009 | if (CUR_TI->id3_hid >= 0) |
1006 | copy_mp3entry(thistrack_id3, bufgetid3(CUR_TI->id3_hid)); | 1010 | bufreadid3(CUR_TI->id3_hid, thistrack_id3); |
1007 | 1011 | ||
1008 | /* Reset current position */ | 1012 | /* Reset current position */ |
1009 | thistrack_id3->elapsed = 0; | 1013 | thistrack_id3->elapsed = 0; |
@@ -1238,10 +1242,8 @@ static bool audio_load_track(size_t offset, bool start_play) | |||
1238 | { | 1242 | { |
1239 | /* TODO: Superfluos buffering call? */ | 1243 | /* TODO: Superfluos buffering call? */ |
1240 | buf_request_buffer_handle(tracks[track_widx].id3_hid); | 1244 | buf_request_buffer_handle(tracks[track_widx].id3_hid); |
1241 | struct mp3entry *id3 = bufgetid3(tracks[track_widx].id3_hid); | 1245 | if (bufreadid3(tracks[track_widx].id3_hid, thistrack_id3)) |
1242 | if (id3) | ||
1243 | { | 1246 | { |
1244 | copy_mp3entry(thistrack_id3, id3); | ||
1245 | thistrack_id3->offset = offset; | 1247 | thistrack_id3->offset = offset; |
1246 | logf("audio_load_track: set offset for %s to %lX\n", | 1248 | logf("audio_load_track: set offset for %s to %lX\n", |
1247 | thistrack_id3->title, | 1249 | thistrack_id3->title, |