@@ -130,11 +130,11 @@ uint64_t AppMediaPlaybackManager::HandleMediaRequestGetAttribute(chip::Attribute
130
130
{
131
131
ChipLogProgress (Zcl, " Received AppMediaPlaybackManager::HandleMediaRequestGetAttribute:%d" , attributeId);
132
132
chip::app::ConcreteReadAttributePath aPath (mEndpointId , chip::app::Clusters::MediaPlayback::Id, attributeId);
133
- const char * resStr = mAttributeDelegate ->Read (aPath);
134
- ChipLogProgress (Zcl, " AppMediaPlaybackManager::HandleMediaRequestGetAttribute response %s" , resStr);
133
+ std::string resStr = mAttributeDelegate ->Read (aPath);
134
+ ChipLogProgress (Zcl, " AppMediaPlaybackManager::HandleMediaRequestGetAttribute response %s" , resStr. c_str () );
135
135
136
136
uint64_t ret = std::numeric_limits<uint64_t >::max ();
137
- if (resStr != nullptr && *resStr != 0 )
137
+ if (resStr. length () != 0 )
138
138
{
139
139
Json::Reader reader;
140
140
Json::Value value;
@@ -143,7 +143,7 @@ uint64_t AppMediaPlaybackManager::HandleMediaRequestGetAttribute(chip::Attribute
143
143
std::string attrId = to_string (attributeId);
144
144
ChipLogProgress (Zcl, " AppMediaPlaybackManager::HandleMediaRequestGetAttribute response parsing done. reading attr %s" ,
145
145
attrId.c_str ());
146
- if (!value[attrId].empty ())
146
+ if (!value[attrId].empty () && value[attrId]. isUInt () )
147
147
{
148
148
ret = static_cast <uint64_t >(value[attrId].asUInt ());
149
149
return ret;
@@ -177,9 +177,10 @@ CHIP_ERROR AppMediaPlaybackManager::HandleGetSampledPosition(AttributeValueEncod
177
177
ChipLogProgress (Zcl, " AppMediaPlaybackManager::HandleGetSampledPosition" );
178
178
chip::app::ConcreteReadAttributePath aPath (mEndpointId , chip::app::Clusters::MediaPlayback::Id,
179
179
chip::app::Clusters::MediaPlayback::Attributes::SampledPosition::Id);
180
- const char * resStr = mAttributeDelegate ->Read (aPath);
180
+ std::string resStr = mAttributeDelegate ->Read (aPath);
181
+ ChipLogProgress (Zcl, " AppMediaPlaybackManager::HandleGetSampledPosition response %s" , resStr.c_str ());
181
182
182
- if (resStr != nullptr && *resStr != 0 )
183
+ if (resStr. length () != 0 )
183
184
{
184
185
Json::Reader reader;
185
186
Json::Value value;
@@ -188,13 +189,14 @@ CHIP_ERROR AppMediaPlaybackManager::HandleGetSampledPosition(AttributeValueEncod
188
189
std::string attrId = to_string (chip::app::Clusters::MediaPlayback::Attributes::SampledPosition::Id);
189
190
ChipLogProgress (Zcl, " AppContentLauncherManager::HandleGetSampledPosition response parsing done. reading attr %s" ,
190
191
attrId.c_str ());
191
- if (!value[attrId].empty ())
192
+ if (!value[attrId].empty () && value[attrId]. isObject () )
192
193
{
193
194
std::string updatedAt = to_string (
194
195
static_cast <uint32_t >(chip::app::Clusters::MediaPlayback::Structs::PlaybackPosition::Fields::kUpdatedAt ));
195
196
std::string position = to_string (
196
197
static_cast <uint32_t >(chip::app::Clusters::MediaPlayback::Structs::PlaybackPosition::Fields::kPosition ));
197
- if (!value[attrId][updatedAt].empty () && !value[attrId][position].empty ())
198
+ if (!value[attrId][updatedAt].empty () && !value[attrId][position].empty () && value[attrId][updatedAt].isUInt () &&
199
+ value[attrId][position].isUInt ())
198
200
{
199
201
// valid response
200
202
response.updatedAt = value[attrId][updatedAt].asUInt ();
0 commit comments