Useful for terminal output.
Unified · Split
| @@ -2115,7 +2115,6 @@ static char *append_track_info(char *res, struct track *track) · 2114 unmodified lines | |||
| 2115 | res = talloc_asprintf_append(res, "(%s) ", track->lang); | 2115 | res = talloc_asprintf_append(res, "(%s) ", track->lang); |
| 2116 | if (track->is_external) | 2116 | if (track->is_external) |
| 2117 | res = talloc_asprintf_append(res, "(external) "); | 2117 | res = talloc_asprintf_append(res, "(external) "); |
| 2118 | res = talloc_asprintf_append(res, "\n"); | ||
| 2119 | 2118 | ||
| 2120 | return res; | 2119 | return res; |
| 2121 | } | 2120 | } |
| @@ -2125,25 +2124,35 @@ static int property_list_tracks(void *ctx, struct m_property *prop, · 3 unmodified lines | |||
| 2125 | { | 2124 | { |
| 2126 | MPContext *mpctx = ctx; | 2125 | MPContext *mpctx = ctx; |
| 2127 | if (action == M_PROPERTY_PRINT) { | 2126 | if (action == M_PROPERTY_PRINT) { |
| 2128 | char *res = NULL; | 2127 | char *res = talloc_strdup(NULL, ""); |
| 2129 | 2128 | ||
| 2130 | for (int type = 0; type < STREAM_TYPE_COUNT; type++) { | 2129 | for (int type = 0; type < STREAM_TYPE_COUNT; type++) { |
| 2130 | bool found = false; | ||
| 2131 | |||
| 2131 | for (int n = 0; n < mpctx->num_tracks; n++) { | 2132 | for (int n = 0; n < mpctx->num_tracks; n++) { |
| 2132 | struct track *track = mpctx->tracks[n]; | 2133 | struct track *track = mpctx->tracks[n]; |
| 2133 | if (track->type == type) { | 2134 | if (track->type == type) { |
| 2134 | res = talloc_asprintf_append(res, "%s: ", track_type_name(track)); | 2135 | res = talloc_asprintf_append(res, "%s: ", track_type_name(track)); |
| 2135 | res = append_track_info(res, track); | 2136 | res = append_track_info(res, track); |
| 2137 | res = talloc_asprintf_append(res, "\n"); | ||
| 2138 | found = true; | ||
| 2136 | } | 2139 | } |
| 2137 | } | 2140 | } |
| 2138 | 2141 | ||
| 2139 | res = talloc_asprintf_append(res, "\n"); | 2142 | if (found && type < STREAM_TYPE_COUNT - 1) { |
| 2143 | res = talloc_asprintf_append(res, "\n"); | ||
| 2144 | found = false; | ||
| 2145 | } | ||
| 2140 | } | 2146 | } |
| 2141 | 2147 | ||
| 2142 | struct demuxer *demuxer = mpctx->demuxer; | 2148 | struct demuxer *demuxer = mpctx->demuxer; |
| 2143 | if (demuxer && demuxer->num_editions > 1) | 2149 | if (demuxer && demuxer->num_editions > 1) { |
| 2144 | res = talloc_asprintf_append(res, "\nEdition: %d of %d\n", | 2150 | res = talloc_asprintf_append(res, "\nEdition: %d of %d", |
| 2145 | demuxer->edition + 1, | 2151 | demuxer->edition + 1, |
| 2146 | demuxer->num_editions); | 2152 | demuxer->num_editions); |
| 2153 | } else { | ||
| 2154 | res[strlen(res) - 1] = '\0'; | ||
| 2155 | } | ||
| 2147 | 2156 | ||
| 2148 | *(char **)arg = res; | 2157 | *(char **)arg = res; |
| 2149 | return M_PROPERTY_OK; | 2158 | return M_PROPERTY_OK; |
| @@ -2169,12 +2178,14 @@ static int property_list_tracks(void *ctx, struct m_property *prop, · 19 unmodified lines | |||
| 2169 | *(struct m_option *)ka->arg = (struct m_option){.type = CONF_TYPE_STRING}; | 2178 | *(struct m_option *)ka->arg = (struct m_option){.type = CONF_TYPE_STRING}; |
| 2170 | return M_PROPERTY_OK; | 2179 | return M_PROPERTY_OK; |
| 2171 | case M_PROPERTY_PRINT: | 2180 | case M_PROPERTY_PRINT: |
| 2172 | res = talloc_asprintf(NULL, "Available %s tracks:\n", | 2181 | res = talloc_asprintf(NULL, "Available %s tracks:", |
| 2173 | type == STREAM_SUB ? "subtitle" : stream_type_name(type)); | 2182 | type == STREAM_SUB ? "subtitle" : stream_type_name(type)); |
| 2174 | 2183 | ||
| 2175 | for (int n = 0; n < mpctx->num_tracks; n++) { | 2184 | for (int n = 0; n < mpctx->num_tracks; n++) { |
| 2176 | if (mpctx->tracks[n]->type == type) | 2185 | if (mpctx->tracks[n]->type == type) { |
| 2186 | res = talloc_strdup_append(res, "\n"); | ||
| 2177 | res = append_track_info(res, mpctx->tracks[n]); | 2187 | res = append_track_info(res, mpctx->tracks[n]); |
| 2188 | } | ||
| 2178 | } | 2189 | } |
| 2179 | 2190 | ||
| 2180 | *(char **)ka->arg = res; | 2191 | *(char **)ka->arg = res; |