Skip to contentSkip to conversation

AVRCP: Metadata item #7 should return TrackDuration

PATCH In review David Stockwell 2 participants 3 messages Aug 24, 2011 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 AVRCP: Metadata item #7 should return TrackDuration

Metadata item #7 should return TrackDuration

Should be total playing time of the track (TrackDuration) in msec, not current position within track.

---
 audio/control.c |   21 ++++++++-------------
 1 files changed, 8 insertions(+), 13 deletions(-)
audio/control.c +2 -1
index be95c19..dd2930c 100644
@@ -194,7 +194,8 @@ enum media_info_id {
 	MEDIA_INFO_TRACK =		4,
 	MEDIA_INFO_N_TRACKS =		5,
 	MEDIA_INFO_GENRE =		6,
-	MEDIA_INFO_CURRENT_POSITION =	7,
+	MEDIA_INFO_PLAYING_TIME =	7,
+	MEDIA_INFO_LAST = MEDIA_INFO_PLAYING_TIME,
 };
 
 static DBusConnection *connection = NULL;
@@ -928,19 +929,13 @@ static int mp_get_media_attribute(struct media_player 

*mp,
len = strlen(valstr);
memcpy(elem->val, valstr, len);
break;
- case MEDIA_INFO_CURRENT_POSITION:
- if (mi->elapsed != 0xFFFFFFFF) {
- uint32_t elapsed;
-
- mp_get_playback_status(mp, NULL, &elapsed, NULL);
-
- snprintf(valstr, 20, "%u", elapsed);
- len = strlen(valstr);
- memcpy(elem->val, valstr, len);
- } else {
+ case MEDIA_INFO_PLAYING_TIME:
+ if (!mi->track_len)
return -ENOENT;
- }

+ snprintf(valstr, 20, "%u", mi->track_len);
+ len = strlen(valstr);
+ memcpy(elem->val, valstr, len);
break;
default:
return -EINVAL;
@@ -1126,7 +1121,7 @@ static int avrcp_handle_get_element_attributes(struct control *control,
* Return all available information, at least
* title must be returned.
*/
- for (i = 1; i <= MEDIA_INFO_CURRENT_POSITION; i++) {
+ for (i = 1; i <= MEDIA_INFO_LAST; i++) {
size = mp_get_media_attribute(control->mp, i,
&pdu->params[pos]);

Signature · 1 line
1.7.3.4
#1 lore raw

Hi David,

audio/control.c enum media_info_id { · line 199

Quoted 8 lines · David Stockwell
audio/control.c +2 -1
@@ -194,7 +194,8 @@ enum media_info_id {
 	MEDIA_INFO_TRACK =		4,
 	MEDIA_INFO_N_TRACKS =		5,
 	MEDIA_INFO_GENRE =		6,
-	MEDIA_INFO_CURRENT_POSITION =	7,
+	MEDIA_INFO_PLAYING_TIME =	7,
+	MEDIA_INFO_LAST = MEDIA_INFO_PLAYING_TIME,
 };

Actually that's not quite what I meant. The idea was this:

MEDIA_INFO_PLAYING_TIME = 7,
MEDIA_INFO_LAST,

That way you can just keep adding new entries above MEDIA_INFO_LAST and its value will always be the last "real" value + 1 (which also means that the comparison in the for-loop changes from <= to <).

Johan

#2 lore raw

Hi Johan

-----Original Message----- From: Johan Hedberg
Sent: Wednesday, August 24, 2011 3:30 AM
To: David Stockwell
Cc: [email protected]
Subject: Re: [PATCH 2/3] AVRCP: Metadata item #7 should return TrackDuration

Hi David,

audio/control.c enum media_info_id { · line 199

Quoted 8 lines · David Stockwell
audio/control.c +2 -1
@@ -194,7 +194,8 @@ enum media_info_id {
 MEDIA_INFO_TRACK = 4,
 MEDIA_INFO_N_TRACKS = 5,
 MEDIA_INFO_GENRE = 6,
- MEDIA_INFO_CURRENT_POSITION = 7,
+ MEDIA_INFO_PLAYING_TIME = 7,
+ MEDIA_INFO_LAST = MEDIA_INFO_PLAYING_TIME,
 };

Actually that's not quite what I meant. The idea was this:

MEDIA_INFO_PLAYING_TIME = 7,
MEDIA_INFO_LAST,

That way you can just keep adding new entries above MEDIA_INFO_LAST and its value will always be the last "real" value + 1 (which also means that the comparison in the for-loop changes from <= to <).

+++++ Thanks. As you can tell, C is not my most frequently used language... I'll take care of it and resubmit.

Johan