summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Keevil <rkeevil+rockbox@gmail.com>2007-08-23 18:53:17 +0000
committerRobert Keevil <rkeevil+rockbox@gmail.com>2007-08-23 18:53:17 +0000
commitb8bb521fc7df2a068cd3861f255e54ff13a9e716 (patch)
treeb852280160a0cd0fa5ce419bd0f8d40e00c03e79
parent0d2ce98a3fce6b54450ce7c547a8dd9a30a964d1 (diff)
downloadrockbox-b8bb521fc7df2a068cd3861f255e54ff13a9e716.tar.gz
rockbox-b8bb521fc7df2a068cd3861f255e54ff13a9e716.zip
FS #6639 - Fixes for Last.fm logging on HWCODEC targets by Boris Gjenero
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14443 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--docs/CREDITS1
-rw-r--r--firmware/mpeg.c75
2 files changed, 41 insertions, 35 deletions
diff --git a/docs/CREDITS b/docs/CREDITS
index 32e18edd22..97d4debdce 100644
--- a/docs/CREDITS
+++ b/docs/CREDITS
@@ -318,6 +318,7 @@ Harry Tu
318Pawel Wysocki 318Pawel Wysocki
319Xinlu Huang 319Xinlu Huang
320Daniel Dalton 320Daniel Dalton
321Boris Gjenero
321The libmad team 322The libmad team
322The wavpack team 323The wavpack team
323The ffmpeg team 324The ffmpeg team
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 278eea4758..e412c36fe2 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -117,7 +117,7 @@ static int track_write_idx = 0;
117#endif /* !SIMULATOR */ 117#endif /* !SIMULATOR */
118 118
119/* Callback function to call when current track has really changed. */ 119/* Callback function to call when current track has really changed. */
120void (*track_changed_callback)(struct mp3entry *id3); 120void (*track_changed_callback)(struct mp3entry *id3) = NULL;
121void (*track_buffer_callback)(struct mp3entry *id3, bool last_track); 121void (*track_buffer_callback)(struct mp3entry *id3, bool last_track);
122void (*track_unbuffer_callback)(struct mp3entry *id3, bool last_track); 122void (*track_unbuffer_callback)(struct mp3entry *id3, bool last_track);
123 123
@@ -149,6 +149,7 @@ static int audiobuf_read;
149static int mpeg_file; 149static int mpeg_file;
150 150
151static bool play_pending; /* We are about to start playing */ 151static bool play_pending; /* We are about to start playing */
152static bool play_pending_track_change; /* When starting play we're starting a new file */
152static bool filling; /* We are filling the buffer with data from disk */ 153static bool filling; /* We are filling the buffer with data from disk */
153static bool dma_underrun; /* True when the DMA has stopped because of 154static bool dma_underrun; /* True when the DMA has stopped because of
154 slow disk reading (read error, shaking) */ 155 slow disk reading (read error, shaking) */
@@ -1027,10 +1028,17 @@ static int new_file(int steps)
1027 1028
1028static void stop_playing(void) 1029static void stop_playing(void)
1029{ 1030{
1031 struct trackdata *track;
1032
1030 /* Stop the current stream */ 1033 /* Stop the current stream */
1031 mp3_play_stop(); 1034 mp3_play_stop();
1032 playing = false; 1035 playing = false;
1033 filling = false; 1036 filling = false;
1037
1038 track = get_trackdata(0);
1039 if (track != NULL)
1040 prev_track_elapsed = track->id3.elapsed;
1041
1034 if(mpeg_file >= 0) 1042 if(mpeg_file >= 0)
1035 close(mpeg_file); 1043 close(mpeg_file);
1036 mpeg_file = -1; 1044 mpeg_file = -1;
@@ -1039,6 +1047,25 @@ static void stop_playing(void)
1039 reset_mp3_buffer(); 1047 reset_mp3_buffer();
1040} 1048}
1041 1049
1050static void end_current_track(void) {
1051 struct trackdata *track;
1052
1053 play_pending = false;
1054 playing = false;
1055 mp3_play_pause(false);
1056
1057 track = get_trackdata(0);
1058 if (track != NULL)
1059 prev_track_elapsed = track->id3.elapsed;
1060
1061 reset_mp3_buffer();
1062 remove_all_tags();
1063 generate_unbuffer_events();
1064
1065 if(mpeg_file >= 0)
1066 close(mpeg_file);
1067}
1068
1042/* Is this a really the end of playback or is a new playlist starting */ 1069/* Is this a really the end of playback or is a new playlist starting */
1043static void check_playlist_end(int direction) 1070static void check_playlist_end(int direction)
1044{ 1071{
@@ -1134,8 +1161,12 @@ static void start_playback_if_ready(void)
1134 if (play_pending) /* don't do this when recovering from DMA underrun */ 1161 if (play_pending) /* don't do this when recovering from DMA underrun */
1135 { 1162 {
1136 generate_postbuffer_events(); /* signal first track as buffered */ 1163 generate_postbuffer_events(); /* signal first track as buffered */
1137 if (track_changed_callback) 1164 if (play_pending_track_change)
1138 track_changed_callback(audio_current_track()); 1165 {
1166 play_pending_track_change = false;
1167 if(track_changed_callback)
1168 track_changed_callback(audio_current_track());
1169 }
1139 play_pending = false; 1170 play_pending = false;
1140 } 1171 }
1141 playing = true; 1172 playing = true;
@@ -1260,17 +1291,8 @@ static void mpeg_thread(void)
1260#endif /* CONFIG_TUNER */ 1291#endif /* CONFIG_TUNER */
1261 1292
1262 /* Stop the current stream */ 1293 /* Stop the current stream */
1263 play_pending = false;
1264 playing = false;
1265 paused = false; 1294 paused = false;
1266 mp3_play_pause(false); 1295 end_current_track();
1267
1268 reset_mp3_buffer();
1269 remove_all_tags();
1270 generate_unbuffer_events();
1271
1272 if(mpeg_file >= 0)
1273 close(mpeg_file);
1274 1296
1275 if ( new_file(0) == -1 ) 1297 if ( new_file(0) == -1 )
1276 { 1298 {
@@ -1303,6 +1325,7 @@ static void mpeg_thread(void)
1303 /* Tell the file loading code that we want to start playing 1325 /* Tell the file loading code that we want to start playing
1304 as soon as we have some data */ 1326 as soon as we have some data */
1305 play_pending = true; 1327 play_pending = true;
1328 play_pending_track_change = true;
1306 1329
1307 update_playlist(); 1330 update_playlist();
1308 current_track_counter++; 1331 current_track_counter++;
@@ -1390,18 +1413,8 @@ static void mpeg_thread(void)
1390 break; 1413 break;
1391 1414
1392 /* stop the current stream */ 1415 /* stop the current stream */
1393 play_pending = false; 1416 end_current_track();
1394 playing = false;
1395 mp3_play_pause(false);
1396
1397 reset_mp3_buffer();
1398 remove_all_tags();
1399 generate_unbuffer_events();
1400 1417
1401 /* Open the next file */
1402 if (mpeg_file >= 0)
1403 close(mpeg_file);
1404
1405 if (new_file(1) < 0) { 1418 if (new_file(1) < 0) {
1406 DEBUGF("No more files to play\n"); 1419 DEBUGF("No more files to play\n");
1407 filling = false; 1420 filling = false;
@@ -1416,6 +1429,7 @@ static void mpeg_thread(void)
1416 /* Tell the file loading code that we want 1429 /* Tell the file loading code that we want
1417 to start playing as soon as we have some data */ 1430 to start playing as soon as we have some data */
1418 play_pending = true; 1431 play_pending = true;
1432 play_pending_track_change = true;
1419 1433
1420 update_playlist(); 1434 update_playlist();
1421 current_track_counter++; 1435 current_track_counter++;
@@ -1430,18 +1444,9 @@ static void mpeg_thread(void)
1430 break; 1444 break;
1431 1445
1432 /* stop the current stream */ 1446 /* stop the current stream */
1433 play_pending = false; 1447 end_current_track();
1434 playing = false;
1435 mp3_play_pause(false);
1436
1437 reset_mp3_buffer();
1438 remove_all_tags();
1439 generate_unbuffer_events();
1440 1448
1441 /* Open the next file */ 1449 /* Open the next file */
1442 if (mpeg_file >= 0)
1443 close(mpeg_file);
1444
1445 if (new_file(-1) < 0) { 1450 if (new_file(-1) < 0) {
1446 DEBUGF("No more files to play\n"); 1451 DEBUGF("No more files to play\n");
1447 filling = false; 1452 filling = false;
@@ -1456,6 +1461,7 @@ static void mpeg_thread(void)
1456 /* Tell the file loading code that we want to 1461 /* Tell the file loading code that we want to
1457 start playing as soon as we have some data */ 1462 start playing as soon as we have some data */
1458 play_pending = true; 1463 play_pending = true;
1464 play_pending_track_change = true;
1459 1465
1460 update_playlist(); 1466 update_playlist();
1461 current_track_counter++; 1467 current_track_counter++;
@@ -2905,7 +2911,6 @@ void audio_init(void)
2905 mpeg_errno = 0; 2911 mpeg_errno = 0;
2906 track_buffer_callback = NULL; 2912 track_buffer_callback = NULL;
2907 track_unbuffer_callback = NULL; 2913 track_unbuffer_callback = NULL;
2908 track_changed_callback = NULL;
2909 2914
2910#ifndef SIMULATOR 2915#ifndef SIMULATOR
2911 audiobuflen = audiobufend - audiobuf; 2916 audiobuflen = audiobufend - audiobuf;