File npa/npa.c changed (mode: 100644) (index 89238d3..66e3070) |
... |
... |
static void stdin_tty_cfg_restore(void) |
257 |
257 |
|
|
258 |
258 |
if (!stdin_tty_cfg_modified) |
if (!stdin_tty_cfg_modified) |
259 |
259 |
return; |
return; |
260 |
|
|
|
261 |
260 |
r = tcsetattr(0, TCSANOW, &stdin_tio_save); |
r = tcsetattr(0, TCSANOW, &stdin_tio_save); |
262 |
261 |
if (r == -1) { |
if (r == -1) { |
263 |
262 |
WARNING("input:unable to restore the terminal line attributes\t"); |
WARNING("input:unable to restore the terminal line attributes\t"); |
264 |
263 |
return; |
return; |
265 |
264 |
} |
} |
266 |
|
|
|
267 |
265 |
memset(&tio_chk, 0, sizeof(tio_chk)); |
memset(&tio_chk, 0, sizeof(tio_chk)); |
268 |
266 |
r = tcgetattr(0, &tio_chk); |
r = tcgetattr(0, &tio_chk); |
269 |
267 |
if (r == -1) { |
if (r == -1) { |
270 |
268 |
WARNING("input:unable to get the current terminal line attributes for restoration checking\n"); |
WARNING("input:unable to get the current terminal line attributes for restoration checking\n"); |
271 |
269 |
return; |
return; |
272 |
270 |
} |
} |
273 |
|
|
|
274 |
271 |
r = memcmp(&tio_chk, &stdin_tio_save, sizeof(tio_chk)); |
r = memcmp(&tio_chk, &stdin_tio_save, sizeof(tio_chk)); |
275 |
272 |
if (r != 0) |
if (r != 0) |
276 |
273 |
WARNING("input:only partial restoration of the terminal line attributes\n"); |
WARNING("input:only partial restoration of the terminal line attributes\n"); |
|
... |
... |
static void *rd_thd_entry(void *arg) |
520 |
517 |
rd_loop(); |
rd_loop(); |
521 |
518 |
/* unreachable */ |
/* unreachable */ |
522 |
519 |
} |
} |
523 |
|
static void rd_thd_start(void) |
|
|
520 |
|
static void rd_thd_start(int st_index) |
524 |
521 |
{ |
{ |
525 |
522 |
int r; |
int r; |
526 |
523 |
pthread_t id; |
pthread_t id; |
527 |
524 |
pthread_attr_t attr; |
pthread_attr_t attr; |
528 |
525 |
|
|
|
526 |
|
atomic_store(&cb.st_idx, st_index); |
529 |
527 |
r = pthread_attr_init(&attr); |
r = pthread_attr_init(&attr); |
530 |
528 |
if (r != 0) |
if (r != 0) |
531 |
529 |
FATAL("read thread:unable to initialize read thread attribute\n"); |
FATAL("read thread:unable to initialize read thread attribute\n"); |
|
... |
... |
static void evt_pcm_uninstall(void) |
2230 |
2228 |
POUT("alsa:pcm events uninstalled\n"); |
POUT("alsa:pcm events uninstalled\n"); |
2231 |
2229 |
} |
} |
2232 |
2230 |
#define PRINT_INFO true |
#define PRINT_INFO true |
2233 |
|
static void play(int st_idx, double initial_vol) |
|
|
2231 |
|
static void play(int st_idx, double initial_vol, bool do_rd_thd_reset) |
2234 |
2232 |
{ |
{ |
2235 |
2233 |
enum AVSampleFormat dst_fmt; |
enum AVSampleFormat dst_fmt; |
2236 |
2234 |
int dst_rate; |
int dst_rate; |
|
... |
... |
static void play(int st_idx, double initial_vol) |
2238 |
2236 |
uint64_t dst_chans_layout; |
uint64_t dst_chans_layout; |
2239 |
2237 |
|
|
2240 |
2238 |
current_st_idx = st_idx; |
current_st_idx = st_idx; |
2241 |
|
rd_thd_reset(st_idx); |
|
|
2239 |
|
/* XXX: reset will flush all pkts dmuxed by the the rd thd until now */ |
|
2240 |
|
if (do_rd_thd_reset) |
|
2241 |
|
rd_thd_reset(st_idx); |
2242 |
2242 |
fmt_ctx_lock(); |
fmt_ctx_lock(); |
2243 |
2243 |
dec_ctx_cfg(fmt_ctx->streams[st_idx]->codecpar); |
dec_ctx_cfg(fmt_ctx->streams[st_idx]->codecpar); |
2244 |
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; |
|
... |
... |
static void cmd_mute(void) |
2396 |
2396 |
} |
} |
2397 |
2397 |
} |
} |
2398 |
2398 |
} |
} |
|
2399 |
|
#define NO_RD_THD_RESET false |
2399 |
2400 |
int main(int argc, u8 **args) |
int main(int argc, u8 **args) |
2400 |
2401 |
{ |
{ |
2401 |
2402 |
u8 *url; |
u8 *url; |
|
... |
... |
int main(int argc, u8 **args) |
2411 |
2412 |
initial_vol = 1.; |
initial_vol = 1.; |
2412 |
2413 |
opts_parse(argc, args, &url, &pcm_str, &initial_vol); |
opts_parse(argc, args, &url, &pcm_str, &initial_vol); |
2413 |
2414 |
init_once(url, pcm_str); |
init_once(url, pcm_str); |
2414 |
|
rd_thd_start(); |
|
2415 |
2415 |
best_st_idx = find_best_st(); |
best_st_idx = find_best_st(); |
2416 |
|
play(best_st_idx, initial_vol); |
|
|
2416 |
|
rd_thd_start(best_st_idx); |
|
2417 |
|
/* play with reset will flush the already dmuxed pkts */ |
|
2418 |
|
play(best_st_idx, initial_vol, NO_RD_THD_RESET); |
2417 |
2419 |
/* switch the ffmpeg log to stdout for metadata/etc dump */ |
/* switch the ffmpeg log to stdout for metadata/etc dump */ |
2418 |
2420 |
av_log_set_callback(ffmpeg_log_stdout); |
av_log_set_callback(ffmpeg_log_stdout); |
2419 |
2421 |
fmt_ctx_lock(); |
fmt_ctx_lock(); |
|
... |
... |
int main(int argc, u8 **args) |
2425 |
2427 |
loop evts_loop(); |
loop evts_loop(); |
2426 |
2428 |
/* unreachable */ |
/* unreachable */ |
2427 |
2429 |
} |
} |
|
2430 |
|
#undef NO_RD_THD_RESET |
2428 |
2431 |
/*----------------------------------------------------------------------------*/ |
/*----------------------------------------------------------------------------*/ |
2429 |
2432 |
#undef ARRAY_N |
#undef ARRAY_N |
2430 |
2433 |
#undef av_frames_alloc |
#undef av_frames_alloc |