File npa/npa.c changed (mode: 100644) (index 74af19e..89238d3) |
120 |
120 |
/*---------------------------------------------------------------------------*/ |
/*---------------------------------------------------------------------------*/ |
121 |
121 |
static u8 *current_url; |
static u8 *current_url; |
122 |
122 |
static int current_st_idx; |
static int current_st_idx; |
|
123 |
|
/* cmd_info must be fast, then a lockless copy of its data */ |
|
124 |
|
static struct { |
|
125 |
|
struct { |
|
126 |
|
int64_t duration; |
|
127 |
|
enum AVDurationEstimationMethod m; |
|
128 |
|
} fmt; |
|
129 |
|
struct { |
|
130 |
|
AVRational tb; |
|
131 |
|
int id; |
|
132 |
|
int64_t duration; |
|
133 |
|
} st; |
|
134 |
|
} cmd_info_data; |
123 |
135 |
/*---------------------------------------------------------------------------*/ |
/*---------------------------------------------------------------------------*/ |
124 |
136 |
/* linux and compatible */ |
/* linux and compatible */ |
125 |
137 |
static int ep_fd; |
static int ep_fd; |
|
... |
... |
static const AVFilter *afmt_filt; |
173 |
185 |
static AVFilterContext *abufsink_ctx; |
static AVFilterContext *abufsink_ctx; |
174 |
186 |
static const AVFilter *abufsink_filt; |
static const AVFilter *abufsink_filt; |
175 |
187 |
/*---------------------------------------------------------------------------*/ |
/*---------------------------------------------------------------------------*/ |
176 |
|
/* a formally proven concurrent accessed lockless cb */ |
|
|
188 |
|
/* a formally proven concurrently accessed lockless cb */ |
177 |
189 |
struct { |
struct { |
178 |
190 |
atomic_u8 reset; |
atomic_u8 reset; |
179 |
191 |
|
|
|
... |
... |
static void cmd_info(void) |
347 |
359 |
{ |
{ |
348 |
360 |
u8 *ts_str; |
u8 *ts_str; |
349 |
361 |
int64_t remaining; |
int64_t remaining; |
350 |
|
int64_t fmt_ctx_duration; |
|
351 |
|
enum AVDurationEstimationMethod fmt_ctx_m; |
|
352 |
362 |
u8 duration_str[sizeof("S9223372036854775807")]; |
u8 duration_str[sizeof("S9223372036854775807")]; |
353 |
|
AVStream *st; |
|
354 |
|
int st_id; |
|
355 |
|
AVRational st_tb; |
|
356 |
|
int64_t st_duration; |
|
357 |
|
|
|
358 |
|
fmt_ctx_lock(); |
|
359 |
|
fmt_ctx_duration = fmt_ctx->duration; |
|
360 |
|
fmt_ctx_m = fmt_ctx->duration_estimation_method; |
|
361 |
|
st = fmt_ctx->streams[current_st_idx]; |
|
362 |
|
st_tb = st->time_base; |
|
363 |
|
st_id = st->id; |
|
364 |
|
st_duration = st->duration; |
|
365 |
|
fmt_ctx_unlock(); |
|
366 |
363 |
|
|
367 |
364 |
RESTORE; |
RESTORE; |
368 |
365 |
GREEN;POUT("================================================================================\n");RESTORE; |
GREEN;POUT("================================================================================\n");RESTORE; |
369 |
366 |
PURPLE;POUT("%s\n", current_url);RESTORE; |
PURPLE;POUT("%s\n", current_url);RESTORE; |
370 |
|
ts_str = ts_to_str(dec_frs.most_recent_ts, st_tb, &remaining); |
|
|
367 |
|
ts_str = ts_to_str(dec_frs.most_recent_ts, cmd_info_data.st.tb, &remaining); |
371 |
368 |
RED;POUT("%s", ts_str);RESTORE; |
RED;POUT("%s", ts_str);RESTORE; |
372 |
369 |
if (remaining != 0) |
if (remaining != 0) |
373 |
370 |
POUT(" remaining %"PRId64" time base units", remaining); |
POUT(" remaining %"PRId64" time base units", remaining); |
374 |
371 |
else |
else |
375 |
372 |
POUT("\n"); |
POUT("\n"); |
376 |
|
POUT("\t%"PRId64" stream time base units (%d/%d seconds)\n", dec_frs.most_recent_ts, st_tb.num, st_tb.den); |
|
|
373 |
|
POUT("\t%"PRId64" stream time base units (%d/%d seconds)\n", dec_frs.most_recent_ts, cmd_info_data.st.tb.num, cmd_info_data.st.tb.den); |
377 |
374 |
BLUE;POUT("--------------------------------------------------------------------------------\n");RESTORE; |
BLUE;POUT("--------------------------------------------------------------------------------\n");RESTORE; |
378 |
375 |
POUT("format:"); |
POUT("format:"); |
379 |
|
if (fmt_ctx_duration == AV_NOPTS_VALUE) { |
|
|
376 |
|
if (cmd_info_data.fmt.duration == AV_NOPTS_VALUE) { |
380 |
377 |
POUT("duration is not provided\n"); |
POUT("duration is not provided\n"); |
381 |
378 |
} else { |
} else { |
382 |
|
snprintf(duration_str, sizeof(duration_str), "%"PRId64, fmt_ctx_duration); |
|
383 |
|
ts_str = ts_to_str(fmt_ctx_duration, AV_TIME_BASE_Q, |
|
|
379 |
|
snprintf(duration_str, sizeof(duration_str), "%"PRId64, cmd_info_data.fmt.duration); |
|
380 |
|
ts_str = ts_to_str(cmd_info_data.fmt.duration, AV_TIME_BASE_Q, |
384 |
381 |
&remaining); |
&remaining); |
385 |
382 |
POUT("duration=");RED;POUT("%s", ts_str);RESTORE; |
POUT("duration=");RED;POUT("%s", ts_str);RESTORE; |
386 |
383 |
if (remaining != 0) |
if (remaining != 0) |
387 |
384 |
POUT(" remaining %"PRId64" av_time_base units\n", remaining); |
POUT(" remaining %"PRId64" av_time_base units\n", remaining); |
388 |
385 |
else |
else |
389 |
386 |
POUT("\n"); |
POUT("\n"); |
390 |
|
POUT("\t%s av_time_base units (1/%d seconds)\n\testimation method is %s\n", duration_str, AV_TIME_BASE, duration_estimate_to_str(fmt_ctx_m)); |
|
|
387 |
|
POUT("\t%s av_time_base units (1/%d seconds)\n\testimation method is %s\n", duration_str, AV_TIME_BASE, duration_estimate_to_str(cmd_info_data.fmt.m)); |
391 |
388 |
} |
} |
392 |
|
POUT("stream:id=%d", st_id); |
|
393 |
|
if (st->duration == AV_NOPTS_VALUE) { |
|
|
389 |
|
POUT("stream:id=%d", cmd_info_data.st.id); |
|
390 |
|
if (cmd_info_data.st.duration == AV_NOPTS_VALUE) { |
394 |
391 |
POUT(";duration is not provided\n"); |
POUT(";duration is not provided\n"); |
395 |
392 |
} else { |
} else { |
396 |
|
snprintf(duration_str, sizeof(duration_str), "%"PRId64, st_duration); |
|
397 |
|
ts_str = ts_to_str(st->duration, st_tb, &remaining); |
|
|
393 |
|
snprintf(duration_str, sizeof(duration_str), "%"PRId64, cmd_info_data.st.duration); |
|
394 |
|
ts_str = ts_to_str(cmd_info_data.st.duration, cmd_info_data.st.tb, &remaining); |
398 |
395 |
POUT(";duration=");RED;POUT("%s\n", ts_str);RESTORE; |
POUT(";duration=");RED;POUT("%s\n", ts_str);RESTORE; |
399 |
396 |
if (remaining != 0) |
if (remaining != 0) |
400 |
397 |
POUT(" remaining %"PRId64" stream time base units\n", remaining); |
POUT(" remaining %"PRId64" stream time base units\n", remaining); |
401 |
398 |
else |
else |
402 |
399 |
POUT("\n"); |
POUT("\n"); |
403 |
|
POUT("\t%s stream time base units (%d/%d seconds)\n", duration_str, st_tb.num, st_tb.den); |
|
|
400 |
|
POUT("\t%s stream time base units (%d/%d seconds)\n", duration_str, cmd_info_data.st.tb.num, cmd_info_data.st.tb.den); |
404 |
401 |
} |
} |
405 |
402 |
BLUE;POUT("--------------------------------------------------------------------------------\n");RESTORE; |
BLUE;POUT("--------------------------------------------------------------------------------\n");RESTORE; |
406 |
403 |
POUT("circular buffer: %u/%u/%u (read/send/max)\n", atomic_load(&cb.rd), atomic_load(&cb.sd), U8_MAX); |
POUT("circular buffer: %u/%u/%u (read/send/max)\n", atomic_load(&cb.rd), atomic_load(&cb.sd), U8_MAX); |
|
... |
... |
static void play(int st_idx, double initial_vol) |
2245 |
2242 |
fmt_ctx_lock(); |
fmt_ctx_lock(); |
2246 |
2243 |
dec_ctx_cfg(fmt_ctx->streams[st_idx]->codecpar); |
dec_ctx_cfg(fmt_ctx->streams[st_idx]->codecpar); |
2247 |
2244 |
dec_frs.most_recent_ts = fmt_ctx->streams[st_idx]->start_time; |
dec_frs.most_recent_ts = fmt_ctx->streams[st_idx]->start_time; |
|
2245 |
|
cmd_info_data.fmt.duration = fmt_ctx->duration; |
|
2246 |
|
cmd_info_data.fmt.m = fmt_ctx->duration_estimation_method; |
|
2247 |
|
cmd_info_data.st.tb = fmt_ctx->streams[st_idx]->time_base; |
|
2248 |
|
cmd_info_data.st.id = fmt_ctx->streams[st_idx]->id; |
|
2249 |
|
cmd_info_data.st.duration = fmt_ctx->streams[st_idx]->duration; |
2248 |
2250 |
fmt_ctx_unlock(); |
fmt_ctx_unlock(); |
2249 |
2251 |
|
|
2250 |
2252 |
evt_pcm_uninstall(); |
evt_pcm_uninstall(); |