File npa/npa.c changed (mode: 100644) (index 66e3070..15ed83a) |
83 |
83 |
#include <stdatomic.h> |
#include <stdatomic.h> |
84 |
84 |
#include <limits.h> |
#include <limits.h> |
85 |
85 |
#include <time.h> |
#include <time.h> |
|
86 |
|
#include <stdarg.h> |
86 |
87 |
/* linux and compatible */ |
/* linux and compatible */ |
87 |
88 |
#include <sys/epoll.h> |
#include <sys/epoll.h> |
88 |
89 |
#include <sys/signalfd.h> |
#include <sys/signalfd.h> |
|
96 |
97 |
#include <libavutil/opt.h> |
#include <libavutil/opt.h> |
97 |
98 |
/* alsa */ |
/* alsa */ |
98 |
99 |
#include <alsa/asoundlib.h> |
#include <alsa/asoundlib.h> |
|
100 |
|
/*----------------------------------------------------------------------------*/ |
99 |
101 |
/* fix C */ |
/* fix C */ |
100 |
102 |
#define u8 uint8_t |
#define u8 uint8_t |
101 |
103 |
#define U8_MAX 255 |
#define U8_MAX 255 |
|
108 |
110 |
#else |
#else |
109 |
111 |
#error "unable to find the right atomic for a 8 bits byte, be sure to have __STDC_WANT_IEC_60559_BFP_EXT__ defined" |
#error "unable to find the right atomic for a 8 bits byte, be sure to have __STDC_WANT_IEC_60559_BFP_EXT__ defined" |
110 |
112 |
#endif |
#endif |
|
113 |
|
/*----------------------------------------------------------------------------*/ |
111 |
114 |
|
|
112 |
115 |
#define ARRAY_N(x) (sizeof(x) / sizeof((x)[0])) |
#define ARRAY_N(x) (sizeof(x) / sizeof((x)[0])) |
113 |
116 |
|
|
114 |
117 |
#define POUT(fmt, ...) fprintf(stdout, fmt, ##__VA_ARGS__) |
#define POUT(fmt, ...) fprintf(stdout, fmt, ##__VA_ARGS__) |
115 |
118 |
#define PERR(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__) |
#define PERR(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__) |
116 |
119 |
#define WARNING(fmt, ...) fprintf(stderr, "WARNING:" fmt, ##__VA_ARGS__) |
#define WARNING(fmt, ...) fprintf(stderr, "WARNING:" fmt, ##__VA_ARGS__) |
117 |
|
#define FATAL(fmt, ...) ({PERR("FATAL:" fmt, ##__VA_ARGS__);stdin_flags_restore();stdin_tty_cfg_restore();exit(1);}) |
|
118 |
|
#define EXIT(fmt, ...) ({POUT("EXITING:" fmt, ##__VA_ARGS__);stdin_flags_restore();stdin_tty_cfg_restore();exit(0);}) |
|
|
120 |
|
#define FATAL(fmt, ...) ({perr("FATAL:" fmt, ##__VA_ARGS__);stdin_flags_restore();stdin_tty_cfg_restore();exit(1);}) |
|
121 |
|
#define EXIT(fmt, ...) ({pout("EXITING:" fmt, ##__VA_ARGS__);stdin_flags_restore();stdin_tty_cfg_restore();exit(0);}) |
119 |
122 |
#define STR_SZ 255 /* sz and idx fit in 1 byte */ |
#define STR_SZ 255 /* sz and idx fit in 1 byte */ |
120 |
123 |
/*---------------------------------------------------------------------------*/ |
/*---------------------------------------------------------------------------*/ |
121 |
124 |
static u8 *current_url; |
static u8 *current_url; |
|
... |
... |
static u8 esc_seq[STR_SZ]; |
242 |
245 |
static u8 esc_seq_next_byte; /* idx in esc_seq */ |
static u8 esc_seq_next_byte; /* idx in esc_seq */ |
243 |
246 |
#define esc_seq_sz esc_seq_next_byte /* the idx of the next byte is its sz */ |
#define esc_seq_sz esc_seq_next_byte /* the idx of the next byte is its sz */ |
244 |
247 |
/*----------------------------------------------------------------------------*/ |
/*----------------------------------------------------------------------------*/ |
|
248 |
|
static void pout(u8 *fmt, ...); |
|
249 |
|
static void perr(u8 *fmt, ...); |
|
250 |
|
static void warning(u8 *fmt, ...); |
|
251 |
|
static void fatal(u8 *fmt, ...); |
|
252 |
|
static void exit_ok(u8 *fmt, ...); |
|
253 |
|
/*----------------------------------------------------------------------------*/ |
245 |
254 |
static void stdin_flags_restore(void) |
static void stdin_flags_restore(void) |
246 |
255 |
{ |
{ |
247 |
256 |
int r; |
int r; |
248 |
257 |
|
|
249 |
258 |
r = fcntl(0, F_SETFL, stdin_flags_save); |
r = fcntl(0, F_SETFL, stdin_flags_save); |
250 |
259 |
if (r == -1) |
if (r == -1) |
251 |
|
WARNING("input:unable to restore the file flags of the standard input\n"); |
|
|
260 |
|
warning("input:unable to restore the file flags of the standard input\n"); |
252 |
261 |
} |
} |
253 |
262 |
static void stdin_tty_cfg_restore(void) |
static void stdin_tty_cfg_restore(void) |
254 |
263 |
{ |
{ |
|
... |
... |
static void stdin_tty_cfg_restore(void) |
259 |
268 |
return; |
return; |
260 |
269 |
r = tcsetattr(0, TCSANOW, &stdin_tio_save); |
r = tcsetattr(0, TCSANOW, &stdin_tio_save); |
261 |
270 |
if (r == -1) { |
if (r == -1) { |
262 |
|
WARNING("input:unable to restore the terminal line attributes\t"); |
|
|
271 |
|
warning("input:unable to restore the terminal line attributes\t"); |
263 |
272 |
return; |
return; |
264 |
273 |
} |
} |
265 |
274 |
memset(&tio_chk, 0, sizeof(tio_chk)); |
memset(&tio_chk, 0, sizeof(tio_chk)); |
266 |
275 |
r = tcgetattr(0, &tio_chk); |
r = tcgetattr(0, &tio_chk); |
267 |
276 |
if (r == -1) { |
if (r == -1) { |
268 |
|
WARNING("input:unable to get the current terminal line attributes for restoration checking\n"); |
|
|
277 |
|
warning("input:unable to get the current terminal line attributes for restoration checking\n"); |
269 |
278 |
return; |
return; |
270 |
279 |
} |
} |
271 |
280 |
r = memcmp(&tio_chk, &stdin_tio_save, sizeof(tio_chk)); |
r = memcmp(&tio_chk, &stdin_tio_save, sizeof(tio_chk)); |
272 |
281 |
if (r != 0) |
if (r != 0) |
273 |
|
WARNING("input:only partial restoration of the terminal line attributes\n"); |
|
|
282 |
|
warning("input:only partial restoration of the terminal line attributes\n"); |
|
283 |
|
} |
|
284 |
|
/*----------------------------------------------------------------------------*/ |
|
285 |
|
static void pout(u8 *fmt, ...) |
|
286 |
|
{ |
|
287 |
|
va_list ap; |
|
288 |
|
|
|
289 |
|
va_start(ap, fmt); |
|
290 |
|
vfprintf(stdout, fmt, ap); |
|
291 |
|
va_end(ap); |
|
292 |
|
} |
|
293 |
|
static void perr(u8 *fmt, ...) |
|
294 |
|
{ |
|
295 |
|
va_list ap; |
|
296 |
|
|
|
297 |
|
va_start(ap, fmt); |
|
298 |
|
vfprintf(stderr, fmt, ap); |
|
299 |
|
va_end(ap); |
274 |
300 |
} |
} |
|
301 |
|
static void warning(u8 *fmt, ...) |
|
302 |
|
{ |
|
303 |
|
va_list ap; |
|
304 |
|
|
|
305 |
|
fprintf(stderr, "warning:"); |
|
306 |
|
va_start(ap, fmt); |
|
307 |
|
vfprintf(stderr, fmt, ap); |
|
308 |
|
va_end(ap); |
|
309 |
|
} |
|
310 |
|
static void fatal(u8 *fmt, ...) |
|
311 |
|
{ |
|
312 |
|
va_list ap; |
|
313 |
|
|
|
314 |
|
fprintf(stderr, "fatal:"); |
|
315 |
|
va_start(ap, fmt); |
|
316 |
|
vfprintf(stderr, fmt, ap); |
|
317 |
|
va_end(ap); |
|
318 |
|
stdin_flags_restore(); |
|
319 |
|
stdin_tty_cfg_restore(); |
|
320 |
|
exit(EXIT_FAILURE); |
|
321 |
|
} |
|
322 |
|
static void exit_ok(u8 *fmt, ...) |
|
323 |
|
{ |
|
324 |
|
va_list ap; |
|
325 |
|
|
|
326 |
|
fprintf(stderr, "exit_ok:"); |
|
327 |
|
va_start(ap, fmt); |
|
328 |
|
vfprintf(stderr, fmt, ap); |
|
329 |
|
va_end(ap); |
|
330 |
|
stdin_flags_restore(); |
|
331 |
|
stdin_tty_cfg_restore(); |
|
332 |
|
exit(EXIT_SUCCESS); |
|
333 |
|
} |
|
334 |
|
/*----------------------------------------------------------------------------*/ |
275 |
335 |
static void fmt_ctx_lock(void) |
static void fmt_ctx_lock(void) |
276 |
336 |
{ |
{ |
277 |
337 |
int r; |
int r; |
278 |
338 |
|
|
279 |
339 |
r = pthread_mutex_lock(&fmt_ctx_mutex); |
r = pthread_mutex_lock(&fmt_ctx_mutex); |
280 |
340 |
if (r != 0) |
if (r != 0) |
281 |
|
FATAL("unable to lock the format context\n"); |
|
|
341 |
|
fatal("unable to lock the format context\n"); |
282 |
342 |
} |
} |
283 |
343 |
static void fmt_ctx_unlock(void) |
static void fmt_ctx_unlock(void) |
284 |
344 |
{ |
{ |
|
... |
... |
static void fmt_ctx_unlock(void) |
286 |
346 |
|
|
287 |
347 |
r = pthread_mutex_unlock(&fmt_ctx_mutex); |
r = pthread_mutex_unlock(&fmt_ctx_mutex); |
288 |
348 |
if (r != 0) |
if (r != 0) |
289 |
|
FATAL("unable to unlock the format context\n"); |
|
|
349 |
|
fatal("unable to unlock the format context\n"); |
290 |
350 |
} |
} |
291 |
351 |
static u8 *duration_estimate_to_str(enum AVDurationEstimationMethod m) |
static u8 *duration_estimate_to_str(enum AVDurationEstimationMethod m) |
292 |
352 |
{ |
{ |
|
... |
... |
static u8 *ts_to_str(int64_t ts, AVRational tb, int64_t *remaining) |
347 |
407 |
} |
} |
348 |
408 |
return str; |
return str; |
349 |
409 |
} |
} |
350 |
|
#define RED if (stdout_is_tty) POUT("\x1b[38;2;255;0;0m") |
|
351 |
|
#define GREEN if (stdout_is_tty) POUT("\x1b[38;2;0;255;0m") |
|
352 |
|
#define BLUE if (stdout_is_tty) POUT("\x1b[38;2;0;0;255m") |
|
353 |
|
#define PURPLE if (stdout_is_tty) POUT("\x1b[38;2;255;0;255m") |
|
354 |
|
#define RESTORE if (stdout_is_tty) POUT("\x1b[39;49m"); |
|
|
410 |
|
#define RED if (stdout_is_tty) pout("\x1b[38;2;255;0;0m") |
|
411 |
|
#define GREEN if (stdout_is_tty) pout("\x1b[38;2;0;255;0m") |
|
412 |
|
#define BLUE if (stdout_is_tty) pout("\x1b[38;2;0;0;255m") |
|
413 |
|
#define PURPLE if (stdout_is_tty) pout("\x1b[38;2;255;0;255m") |
|
414 |
|
#define RESTORE if (stdout_is_tty) pout("\x1b[39;49m") |
355 |
415 |
static void cmd_info(void) |
static void cmd_info(void) |
356 |
416 |
{ |
{ |
357 |
417 |
u8 *ts_str; |
u8 *ts_str; |
|
... |
... |
static void cmd_info(void) |
359 |
419 |
u8 duration_str[sizeof("S9223372036854775807")]; |
u8 duration_str[sizeof("S9223372036854775807")]; |
360 |
420 |
|
|
361 |
421 |
RESTORE; |
RESTORE; |
362 |
|
GREEN;POUT("================================================================================\n");RESTORE; |
|
363 |
|
PURPLE;POUT("%s\n", current_url);RESTORE; |
|
|
422 |
|
GREEN;pout("================================================================================\n");RESTORE; |
|
423 |
|
PURPLE;pout("%s\n", current_url);RESTORE; |
364 |
424 |
ts_str = ts_to_str(dec_frs.most_recent_ts, cmd_info_data.st.tb, &remaining); |
ts_str = ts_to_str(dec_frs.most_recent_ts, cmd_info_data.st.tb, &remaining); |
365 |
|
RED;POUT("%s", ts_str);RESTORE; |
|
|
425 |
|
RED;pout("%s", ts_str);RESTORE; |
366 |
426 |
if (remaining != 0) |
if (remaining != 0) |
367 |
|
POUT(" remaining %"PRId64" time base units", remaining); |
|
|
427 |
|
pout(" remaining %"PRId64" time base units", remaining); |
368 |
428 |
else |
else |
369 |
|
POUT("\n"); |
|
370 |
|
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); |
|
371 |
|
BLUE;POUT("--------------------------------------------------------------------------------\n");RESTORE; |
|
372 |
|
POUT("format:"); |
|
|
429 |
|
pout("\n"); |
|
430 |
|
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); |
|
431 |
|
BLUE;pout("--------------------------------------------------------------------------------\n");RESTORE; |
|
432 |
|
pout("format:"); |
373 |
433 |
if (cmd_info_data.fmt.duration == AV_NOPTS_VALUE) { |
if (cmd_info_data.fmt.duration == AV_NOPTS_VALUE) { |
374 |
|
POUT("duration is not provided\n"); |
|
|
434 |
|
pout("duration is not provided\n"); |
375 |
435 |
} else { |
} else { |
376 |
436 |
snprintf(duration_str, sizeof(duration_str), "%"PRId64, cmd_info_data.fmt.duration); |
snprintf(duration_str, sizeof(duration_str), "%"PRId64, cmd_info_data.fmt.duration); |
377 |
437 |
ts_str = ts_to_str(cmd_info_data.fmt.duration, AV_TIME_BASE_Q, |
ts_str = ts_to_str(cmd_info_data.fmt.duration, AV_TIME_BASE_Q, |
378 |
438 |
&remaining); |
&remaining); |
379 |
|
POUT("duration=");RED;POUT("%s", ts_str);RESTORE; |
|
|
439 |
|
pout("duration=");RED;POUT("%s", ts_str);RESTORE; |
380 |
440 |
if (remaining != 0) |
if (remaining != 0) |
381 |
|
POUT(" remaining %"PRId64" av_time_base units\n", remaining); |
|
|
441 |
|
pout(" remaining %"PRId64" av_time_base units\n", remaining); |
382 |
442 |
else |
else |
383 |
|
POUT("\n"); |
|
384 |
|
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)); |
|
|
443 |
|
pout("\n"); |
|
444 |
|
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)); |
385 |
445 |
} |
} |
386 |
|
POUT("stream:id=%d", cmd_info_data.st.id); |
|
|
446 |
|
pout("stream:id=%d", cmd_info_data.st.id); |
387 |
447 |
if (cmd_info_data.st.duration == AV_NOPTS_VALUE) { |
if (cmd_info_data.st.duration == AV_NOPTS_VALUE) { |
388 |
|
POUT(";duration is not provided\n"); |
|
|
448 |
|
pout(";duration is not provided\n"); |
389 |
449 |
} else { |
} else { |
390 |
450 |
snprintf(duration_str, sizeof(duration_str), "%"PRId64, cmd_info_data.st.duration); |
snprintf(duration_str, sizeof(duration_str), "%"PRId64, cmd_info_data.st.duration); |
391 |
451 |
ts_str = ts_to_str(cmd_info_data.st.duration, cmd_info_data.st.tb, &remaining); |
ts_str = ts_to_str(cmd_info_data.st.duration, cmd_info_data.st.tb, &remaining); |
392 |
|
POUT(";duration=");RED;POUT("%s\n", ts_str);RESTORE; |
|
|
452 |
|
pout(";duration=");RED;POUT("%s\n", ts_str);RESTORE; |
393 |
453 |
if (remaining != 0) |
if (remaining != 0) |
394 |
|
POUT(" remaining %"PRId64" stream time base units\n", remaining); |
|
|
454 |
|
pout(" remaining %"PRId64" stream time base units\n", remaining); |
395 |
455 |
else |
else |
396 |
|
POUT("\n"); |
|
397 |
|
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); |
|
|
456 |
|
pout("\n"); |
|
457 |
|
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); |
398 |
458 |
} |
} |
399 |
|
BLUE;POUT("--------------------------------------------------------------------------------\n");RESTORE; |
|
400 |
|
POUT("circular buffer: %u/%u/%u (read/send/max)\n", atomic_load(&cb.rd), atomic_load(&cb.sd), U8_MAX); |
|
|
459 |
|
BLUE;pout("--------------------------------------------------------------------------------\n");RESTORE; |
|
460 |
|
pout("circular buffer: %u/%u/%u (read/send/max)\n", atomic_load(&cb.rd), atomic_load(&cb.sd), U8_MAX); |
401 |
461 |
if (paused) { |
if (paused) { |
402 |
|
RED;POUT("paused\n");RESTORE; |
|
|
462 |
|
RED;pout("paused\n");RESTORE; |
403 |
463 |
} |
} |
404 |
464 |
if (filt_frs.muted) { |
if (filt_frs.muted) { |
405 |
|
RED;POUT("muted\n");RESTORE; |
|
|
465 |
|
RED;pout("muted\n");RESTORE; |
406 |
466 |
} |
} |
407 |
|
GREEN;POUT("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");RESTORE; |
|
|
467 |
|
GREEN;pout("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");RESTORE; |
408 |
468 |
} |
} |
409 |
469 |
#undef RED |
#undef RED |
410 |
470 |
#undef GREEN |
#undef GREEN |
|
... |
... |
static void wait(long ns) |
427 |
487 |
if (r == 0) |
if (r == 0) |
428 |
488 |
break; |
break; |
429 |
489 |
if (r != EINTR) |
if (r != EINTR) |
430 |
|
FATAL("wait timer failed:%d\n", r); |
|
|
490 |
|
fatal("wait timer failed:%d\n", r); |
431 |
491 |
/* r == EINTR */ |
/* r == EINTR */ |
432 |
492 |
memcpy(&wanted, &rem, sizeof(wanted)); |
memcpy(&wanted, &rem, sizeof(wanted)); |
433 |
493 |
memset(&rem, 0, sizeof(rem)); |
memset(&rem, 0, sizeof(rem)); |
|
... |
... |
static void rd_loop(void) { loop /* infinite loop */ |
491 |
551 |
cb.pkts[rd]->data = 0; |
cb.pkts[rd]->data = 0; |
492 |
552 |
cb.pkts[rd]->size = 0; |
cb.pkts[rd]->size = 0; |
493 |
553 |
} else if (r != 0) |
} else if (r != 0) |
494 |
|
FATAL("ffmpeg:error while demuxing coded/compressed data into packets\n"); |
|
|
554 |
|
fatal("ffmpeg:error while demuxing coded/compressed data into packets\n"); |
495 |
555 |
else { /* r == 0 */ |
else { /* r == 0 */ |
496 |
556 |
st_idx = atomic_load(&cb.st_idx); |
st_idx = atomic_load(&cb.st_idx); |
497 |
557 |
if (rd_thd_pkt->stream_index != st_idx) { /* sd_idx can be -1 */ |
if (rd_thd_pkt->stream_index != st_idx) { /* sd_idx can be -1 */ |
|
... |
... |
static void *rd_thd_entry(void *arg) |
510 |
570 |
|
|
511 |
571 |
r = sigfillset(&sset); |
r = sigfillset(&sset); |
512 |
572 |
if (r == -1) |
if (r == -1) |
513 |
|
FATAL("read thread:unable to get a full signal mask\n"); |
|
|
573 |
|
fatal("read thread:unable to get a full signal mask\n"); |
514 |
574 |
r = pthread_sigmask(SIG_SETMASK, &sset, 0); |
r = pthread_sigmask(SIG_SETMASK, &sset, 0); |
515 |
575 |
if (r != 0) |
if (r != 0) |
516 |
|
FATAL("read thread:unable to \"block\" \"all\" signals\n"); |
|
|
576 |
|
fatal("read thread:unable to \"block\" \"all\" signals\n"); |
517 |
577 |
rd_loop(); |
rd_loop(); |
518 |
578 |
/* unreachable */ |
/* unreachable */ |
519 |
579 |
} |
} |
|
... |
... |
static void rd_thd_start(int st_index) |
526 |
586 |
atomic_store(&cb.st_idx, st_index); |
atomic_store(&cb.st_idx, st_index); |
527 |
587 |
r = pthread_attr_init(&attr); |
r = pthread_attr_init(&attr); |
528 |
588 |
if (r != 0) |
if (r != 0) |
529 |
|
FATAL("read thread:unable to initialize read thread attribute\n"); |
|
|
589 |
|
fatal("read thread:unable to initialize read thread attribute\n"); |
530 |
590 |
r = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); |
r = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); |
531 |
591 |
if (r != 0) |
if (r != 0) |
532 |
|
FATAL("read thread:unable to set the read thread attribute to detach mode\n"); |
|
|
592 |
|
fatal("read thread:unable to set the read thread attribute to detach mode\n"); |
533 |
593 |
r = pthread_create(&id, &attr, &rd_thd_entry, 0); |
r = pthread_create(&id, &attr, &rd_thd_entry, 0); |
534 |
594 |
if (r != 0) |
if (r != 0) |
535 |
|
FATAL("read thread:unable to create the read thread\n"); |
|
536 |
|
POUT("read thread %lu\n", (unsigned long)id); |
|
|
595 |
|
fatal("read thread:unable to create the read thread\n"); |
|
596 |
|
pout("read thread %lu\n", (unsigned long)id); |
537 |
597 |
pthread_attr_destroy(&attr); |
pthread_attr_destroy(&attr); |
538 |
598 |
} |
} |
539 |
599 |
static void cmd_quit(void) |
static void cmd_quit(void) |
540 |
600 |
{ |
{ |
541 |
|
EXIT("quit command received\n"); |
|
|
601 |
|
exit_ok("quit command received\n"); |
542 |
602 |
} |
} |
543 |
603 |
#define RESET_DONE 0 |
#define RESET_DONE 0 |
544 |
604 |
#define DO_RESET 1 |
#define DO_RESET 1 |
|
... |
... |
static void rd_thd_reset(int st_idx) |
559 |
619 |
wait(1000000); /* 1ms */ |
wait(1000000); /* 1ms */ |
560 |
620 |
++loops_n; |
++loops_n; |
561 |
621 |
if (loops_n == 4000) /* 1ms * 4000 = 4s */ |
if (loops_n == 4000) /* 1ms * 4000 = 4s */ |
562 |
|
FATAL("read thread reset timeout\n"); |
|
|
622 |
|
fatal("read thread reset timeout\n"); |
563 |
623 |
} |
} |
564 |
624 |
/* reset = DO_RESET */ |
/* reset = DO_RESET */ |
565 |
625 |
} |
} |
|
... |
... |
static uint64_t pcm_chmaps2ff_chans_layout(snd_pcm_t *pcm, |
580 |
640 |
pcm_chmap = snd_pcm_get_chmap(pcm); |
pcm_chmap = snd_pcm_get_chmap(pcm); |
581 |
641 |
if (pcm_chmap == 0) { |
if (pcm_chmap == 0) { |
582 |
642 |
if (print_info) |
if (print_info) |
583 |
|
POUT("alsa:no pcm channel map available, wiring to default ffmpeg channel layout\n"); |
|
|
643 |
|
pout("alsa:no pcm channel map available, wiring to default ffmpeg channel layout\n"); |
584 |
644 |
} else { |
} else { |
585 |
645 |
if (print_info) |
if (print_info) |
586 |
|
POUT("alsa:your pcm device support channel maps, but fine granularity wiring strategy is not implemented\n"); |
|
|
646 |
|
pout("alsa:your pcm device support channel maps, but fine granularity wiring strategy is not implemented\n"); |
587 |
647 |
free(pcm_chmap); |
free(pcm_chmap); |
588 |
648 |
} |
} |
589 |
649 |
ff_chans_layout = av_get_default_channel_layout((int)pcm_chans_n); |
ff_chans_layout = av_get_default_channel_layout((int)pcm_chans_n); |
590 |
650 |
av_get_channel_layout_string(chans_layout_str, sizeof(chans_layout_str), |
av_get_channel_layout_string(chans_layout_str, sizeof(chans_layout_str), |
591 |
651 |
(int)pcm_chans_n, ff_chans_layout); |
(int)pcm_chans_n, ff_chans_layout); |
592 |
652 |
if (print_info) |
if (print_info) |
593 |
|
POUT("alsa channel map wired to ffmpeg channel layout:\"%s\" (%u pcm channels)\n", chans_layout_str, pcm_chans_n); |
|
|
653 |
|
pout("alsa channel map wired to ffmpeg channel layout:\"%s\" (%u pcm channels)\n", chans_layout_str, pcm_chans_n); |
594 |
654 |
return ff_chans_layout; |
return ff_chans_layout; |
595 |
655 |
} |
} |
596 |
656 |
/* fatal if the wiring cannot be done */ |
/* fatal if the wiring cannot be done */ |
|
... |
... |
static void pcm_layout2ff_fmt_strict(snd_pcm_format_t alsa_fmt, |
628 |
688 |
*ff_fmt = AV_SAMPLE_FMT_U8P; |
*ff_fmt = AV_SAMPLE_FMT_U8P; |
629 |
689 |
break; |
break; |
630 |
690 |
default: |
default: |
631 |
|
FATAL("unable to wire strictly alsa layout \"%s\"/\"%s\" to a ffmpeg format\n", snd_pcm_format_description(alsa_fmt), snd_pcm_access_name(alsa_access)); |
|
|
691 |
|
fatal("unable to wire strictly alsa layout \"%s\"/\"%s\" to a ffmpeg format\n", snd_pcm_format_description(alsa_fmt), snd_pcm_access_name(alsa_access)); |
632 |
692 |
} |
} |
633 |
693 |
if (print_info) { |
if (print_info) { |
634 |
694 |
u8 ff_fmt_str[STR_SZ]; |
u8 ff_fmt_str[STR_SZ]; |
635 |
695 |
|
|
636 |
696 |
av_get_sample_fmt_string(ff_fmt_str, sizeof(ff_fmt_str), |
av_get_sample_fmt_string(ff_fmt_str, sizeof(ff_fmt_str), |
637 |
697 |
*ff_fmt); |
*ff_fmt); |
638 |
|
POUT("alsa pcm layout \"%s\"/\"%s\" wired strictly to ffmpeg format \"%sbits\"\n", snd_pcm_format_description(alsa_fmt), snd_pcm_access_name(alsa_access), ff_fmt_str); |
|
|
698 |
|
pout("alsa pcm layout \"%s\"/\"%s\" wired strictly to ffmpeg format \"%sbits\"\n", snd_pcm_format_description(alsa_fmt), snd_pcm_access_name(alsa_access), ff_fmt_str); |
639 |
699 |
} |
} |
640 |
700 |
} |
} |
641 |
701 |
static void pcm2ff(snd_pcm_t *pcm, enum AVSampleFormat *ff_fmt, |
static void pcm2ff(snd_pcm_t *pcm, enum AVSampleFormat *ff_fmt, |
|
... |
... |
static void pcm2ff(snd_pcm_t *pcm, enum AVSampleFormat *ff_fmt, |
651 |
711 |
|
|
652 |
712 |
r = snd_pcm_hw_params_malloc(&hw_params); |
r = snd_pcm_hw_params_malloc(&hw_params); |
653 |
713 |
if (r < 0) |
if (r < 0) |
654 |
|
FATAL("alsa:unable to allocate hardware parameters context for ffmpeg filter wiring\n"); |
|
|
714 |
|
fatal("alsa:unable to allocate hardware parameters context for ffmpeg filter wiring\n"); |
655 |
715 |
r = snd_pcm_hw_params_current(pcm, hw_params); |
r = snd_pcm_hw_params_current(pcm, hw_params); |
656 |
716 |
if (r != 0) |
if (r != 0) |
657 |
|
FATAL("alsa:unable to get current hardware parameters for ffmpeg filter wiring\n"); |
|
|
717 |
|
fatal("alsa:unable to get current hardware parameters for ffmpeg filter wiring\n"); |
658 |
718 |
r = snd_pcm_hw_params_get_access(hw_params, &pcm_access); |
r = snd_pcm_hw_params_get_access(hw_params, &pcm_access); |
659 |
719 |
if (r < 0) |
if (r < 0) |
660 |
|
FATAL("alsa:unable to get the pcm access for ffmpeg filter wiring\n"); |
|
|
720 |
|
fatal("alsa:unable to get the pcm access for ffmpeg filter wiring\n"); |
661 |
721 |
r = snd_pcm_hw_params_get_format(hw_params, &pcm_fmt); |
r = snd_pcm_hw_params_get_format(hw_params, &pcm_fmt); |
662 |
722 |
if (r < 0) |
if (r < 0) |
663 |
|
FATAL("alsa:unable to get the pcm format for ffmpeg filter wiring\n"); |
|
|
723 |
|
fatal("alsa:unable to get the pcm format for ffmpeg filter wiring\n"); |
664 |
724 |
/*--------------------------------------------------------------------*/ |
/*--------------------------------------------------------------------*/ |
665 |
725 |
pcm_layout2ff_fmt_strict(pcm_fmt, pcm_access, ff_fmt, print_info); |
pcm_layout2ff_fmt_strict(pcm_fmt, pcm_access, ff_fmt, print_info); |
666 |
726 |
/*--------------------------------------------------------------------*/ |
/*--------------------------------------------------------------------*/ |
667 |
727 |
r = snd_pcm_hw_params_get_rate(hw_params, &pcm_rate, |
r = snd_pcm_hw_params_get_rate(hw_params, &pcm_rate, |
668 |
728 |
SND_PCM_STREAM_PLAYBACK); |
SND_PCM_STREAM_PLAYBACK); |
669 |
729 |
if (r < 0) |
if (r < 0) |
670 |
|
FATAL("alsa:unable to get the pcm rate for ffmpeg filter wiring\n"); |
|
|
730 |
|
fatal("alsa:unable to get the pcm rate for ffmpeg filter wiring\n"); |
671 |
731 |
*ff_rate = (int)pcm_rate; |
*ff_rate = (int)pcm_rate; |
672 |
732 |
r = snd_pcm_hw_params_get_channels(hw_params, &pcm_chans_n); |
r = snd_pcm_hw_params_get_channels(hw_params, &pcm_chans_n); |
673 |
733 |
if (r < 0) |
if (r < 0) |
674 |
|
FATAL("alsa:unable to get the pcm count of channels for ffmpeg filter wiring\n"); |
|
|
734 |
|
fatal("alsa:unable to get the pcm count of channels for ffmpeg filter wiring\n"); |
675 |
735 |
*ff_chans_n = (int)pcm_chans_n; |
*ff_chans_n = (int)pcm_chans_n; |
676 |
736 |
/*--------------------------------------------------------------------*/ |
/*--------------------------------------------------------------------*/ |
677 |
737 |
*ff_chans_layout = pcm_chmaps2ff_chans_layout(pcm, pcm_chans_n, |
*ff_chans_layout = pcm_chmaps2ff_chans_layout(pcm, pcm_chans_n, |
|
... |
... |
static void abufsrc_cfg(enum AVFrameFormat fmt, int rate, int chans_n, |
688 |
748 |
|
|
689 |
749 |
abufsrc_filt = avfilter_get_by_name("abuffer"); |
abufsrc_filt = avfilter_get_by_name("abuffer"); |
690 |
750 |
if (abufsrc_filt == 0) |
if (abufsrc_filt == 0) |
691 |
|
FATAL("audio buffer source:could not find the filter\n"); |
|
|
751 |
|
fatal("audio buffer source:could not find the filter\n"); |
692 |
752 |
abufsrc_ctx = avfilter_graph_alloc_filter(filter_graph, abufsrc_filt, |
abufsrc_ctx = avfilter_graph_alloc_filter(filter_graph, abufsrc_filt, |
693 |
753 |
"src_abuf"); |
"src_abuf"); |
694 |
754 |
if (abufsrc_ctx == 0) |
if (abufsrc_ctx == 0) |
695 |
|
FATAL("audio buffer source context:could not allocate the instance in the filter graph\n"); |
|
|
755 |
|
fatal("audio buffer source context:could not allocate the instance in the filter graph\n"); |
696 |
756 |
r = av_opt_set(abufsrc_ctx, "sample_fmt", av_get_frame_fmt_name(fmt), |
r = av_opt_set(abufsrc_ctx, "sample_fmt", av_get_frame_fmt_name(fmt), |
697 |
757 |
AV_OPT_SEARCH_CHILDREN); |
AV_OPT_SEARCH_CHILDREN); |
698 |
758 |
if (r < 0) |
if (r < 0) |
699 |
|
FATAL("audio buffer source context:unable to set the decoder frame format option\n"); |
|
|
759 |
|
fatal("audio buffer source context:unable to set the decoder frame format option\n"); |
700 |
760 |
r = av_opt_set_int(abufsrc_ctx, "sample_rate", rate, |
r = av_opt_set_int(abufsrc_ctx, "sample_rate", rate, |
701 |
761 |
AV_OPT_SEARCH_CHILDREN); |
AV_OPT_SEARCH_CHILDREN); |
702 |
762 |
if (r < 0) |
if (r < 0) |
703 |
|
FATAL("audio buffer source context:unable to set the decoder rate option\n"); |
|
|
763 |
|
fatal("audio buffer source context:unable to set the decoder rate option\n"); |
704 |
764 |
/* |
/* |
705 |
765 |
* XXX: at the time of coding, bug for 1 chans layout... or I did miss |
* XXX: at the time of coding, bug for 1 chans layout... or I did miss |
706 |
766 |
* some valuable information |
* some valuable information |
|
... |
... |
static void abufsrc_cfg(enum AVFrameFormat fmt, int rate, int chans_n, |
708 |
768 |
av_get_channel_layout_string(chans_layout_str, sizeof(chans_layout_str), |
av_get_channel_layout_string(chans_layout_str, sizeof(chans_layout_str), |
709 |
769 |
chans_n, chans_layout); |
chans_n, chans_layout); |
710 |
770 |
if (print_info) |
if (print_info) |
711 |
|
POUT("audio buffer source context:using channels layout \"%s\" (%d pcm channels)\n", chans_layout_str, chans_n); |
|
|
771 |
|
pout("audio buffer source context:using channels layout \"%s\" (%d pcm channels)\n", chans_layout_str, chans_n); |
712 |
772 |
r = av_opt_set(abufsrc_ctx, "channel_layout", chans_layout_str, |
r = av_opt_set(abufsrc_ctx, "channel_layout", chans_layout_str, |
713 |
773 |
AV_OPT_SEARCH_CHILDREN); |
AV_OPT_SEARCH_CHILDREN); |
714 |
774 |
if (r < 0) |
if (r < 0) |
715 |
|
FATAL("audio buffer source context:unable to set the decoder channel layout option\n"); |
|
|
775 |
|
fatal("audio buffer source context:unable to set the decoder channel layout option\n"); |
716 |
776 |
r = avfilter_init_str(abufsrc_ctx, 0); |
r = avfilter_init_str(abufsrc_ctx, 0); |
717 |
777 |
if (r < 0) |
if (r < 0) |
718 |
|
FATAL("audio buffer source context:unable to initialize\n"); |
|
|
778 |
|
fatal("audio buffer source context:unable to initialize\n"); |
719 |
779 |
} |
} |
720 |
780 |
static void vol_cfg(bool muted, double vol) |
static void vol_cfg(bool muted, double vol) |
721 |
781 |
{ |
{ |
|
... |
... |
static void vol_cfg(bool muted, double vol) |
725 |
785 |
|
|
726 |
786 |
vol_filt = avfilter_get_by_name("volume"); |
vol_filt = avfilter_get_by_name("volume"); |
727 |
787 |
if (vol_filt == 0) |
if (vol_filt == 0) |
728 |
|
FATAL("volume:could not find the filter\n"); |
|
|
788 |
|
fatal("volume:could not find the filter\n"); |
729 |
789 |
vol_ctx = avfilter_graph_alloc_filter(filter_graph, vol_filt, "vol"); |
vol_ctx = avfilter_graph_alloc_filter(filter_graph, vol_filt, "vol"); |
730 |
790 |
if (vol_ctx == 0) |
if (vol_ctx == 0) |
731 |
|
FATAL("volume context:could not allocate the instance in the filter graph\n"); |
|
|
791 |
|
fatal("volume context:could not allocate the instance in the filter graph\n"); |
732 |
792 |
if (muted) |
if (muted) |
733 |
793 |
vol_double = 0.0; |
vol_double = 0.0; |
734 |
794 |
else |
else |
|
... |
... |
static void vol_cfg(bool muted, double vol) |
737 |
797 |
snprintf(vol_l10n_str, sizeof(vol_l10n_str), "%f", vol_double); |
snprintf(vol_l10n_str, sizeof(vol_l10n_str), "%f", vol_double); |
738 |
798 |
r = av_opt_set(vol_ctx, "volume", vol_l10n_str, AV_OPT_SEARCH_CHILDREN); |
r = av_opt_set(vol_ctx, "volume", vol_l10n_str, AV_OPT_SEARCH_CHILDREN); |
739 |
799 |
if (r < 0) |
if (r < 0) |
740 |
|
FATAL("volume context:unable to set the volume option\n"); |
|
|
800 |
|
fatal("volume context:unable to set the volume option\n"); |
741 |
801 |
r = avfilter_init_str(vol_ctx, 0); |
r = avfilter_init_str(vol_ctx, 0); |
742 |
802 |
if (r < 0) |
if (r < 0) |
743 |
|
FATAL("volume buffer context:unable to initialize\n"); |
|
|
803 |
|
fatal("volume buffer context:unable to initialize\n"); |
744 |
804 |
} |
} |
745 |
805 |
static void afmt_cfg(enum AVFrameFormat fmt, int rate, int chans_n, |
static void afmt_cfg(enum AVFrameFormat fmt, int rate, int chans_n, |
746 |
806 |
uint64_t chans_layout, bool print_info) |
uint64_t chans_layout, bool print_info) |
|
... |
... |
static void afmt_cfg(enum AVFrameFormat fmt, int rate, int chans_n, |
751 |
811 |
|
|
752 |
812 |
afmt_filt = avfilter_get_by_name("aformat"); |
afmt_filt = avfilter_get_by_name("aformat"); |
753 |
813 |
if (afmt_filt == 0) |
if (afmt_filt == 0) |
754 |
|
FATAL("audio format:could not find the filter"); |
|
|
814 |
|
fatal("audio format:could not find the filter"); |
755 |
815 |
afmt_ctx = avfilter_graph_alloc_filter(filter_graph, afmt_filt, "afmt"); |
afmt_ctx = avfilter_graph_alloc_filter(filter_graph, afmt_filt, "afmt"); |
756 |
816 |
if (afmt_ctx == 0) |
if (afmt_ctx == 0) |
757 |
|
FATAL("audio format:could not allocate the instance in the filter graph\n"); |
|
|
817 |
|
fatal("audio format:could not allocate the instance in the filter graph\n"); |
758 |
818 |
r = av_opt_set(afmt_ctx, "sample_fmts", av_get_frame_fmt_name(fmt), |
r = av_opt_set(afmt_ctx, "sample_fmts", av_get_frame_fmt_name(fmt), |
759 |
819 |
AV_OPT_SEARCH_CHILDREN); |
AV_OPT_SEARCH_CHILDREN); |
760 |
820 |
if (r < 0) |
if (r < 0) |
761 |
|
FATAL("audio format context:could to set the pcm sample format\n"); |
|
|
821 |
|
fatal("audio format context:could to set the pcm sample format\n"); |
762 |
822 |
snprintf(rate_str, sizeof(rate_str), "%d", rate); |
snprintf(rate_str, sizeof(rate_str), "%d", rate); |
763 |
823 |
r = av_opt_set(afmt_ctx, "sample_rates", rate_str, |
r = av_opt_set(afmt_ctx, "sample_rates", rate_str, |
764 |
824 |
AV_OPT_SEARCH_CHILDREN); |
AV_OPT_SEARCH_CHILDREN); |
765 |
825 |
if (r < 0) |
if (r < 0) |
766 |
|
FATAL("audio format context:could not set the pcm rate\n"); |
|
|
826 |
|
fatal("audio format context:could not set the pcm rate\n"); |
767 |
827 |
av_get_channel_layout_string(chans_layout_str, sizeof(chans_layout_str), |
av_get_channel_layout_string(chans_layout_str, sizeof(chans_layout_str), |
768 |
828 |
chans_n, chans_layout); |
chans_n, chans_layout); |
769 |
829 |
r = av_opt_set(afmt_ctx, "channel_layouts", chans_layout_str, |
r = av_opt_set(afmt_ctx, "channel_layouts", chans_layout_str, |
770 |
830 |
AV_OPT_SEARCH_CHILDREN); |
AV_OPT_SEARCH_CHILDREN); |
771 |
831 |
if (r < 0) |
if (r < 0) |
772 |
|
FATAL("audio format context:could not set the layout of channels\n"); |
|
|
832 |
|
fatal("audio format context:could not set the layout of channels\n"); |
773 |
833 |
if (print_info) |
if (print_info) |
774 |
|
POUT("audio format context:channel layout is \"%s\"\n", chans_layout_str); |
|
|
834 |
|
pout("audio format context:channel layout is \"%s\"\n", chans_layout_str); |
775 |
835 |
r = avfilter_init_str(afmt_ctx, 0); |
r = avfilter_init_str(afmt_ctx, 0); |
776 |
836 |
if (r < 0) |
if (r < 0) |
777 |
|
FATAL("audio format context:unable to initialize\n"); |
|
|
837 |
|
fatal("audio format context:unable to initialize\n"); |
778 |
838 |
} |
} |
779 |
839 |
static void abufsink_cfg(void) |
static void abufsink_cfg(void) |
780 |
840 |
{ |
{ |
|
... |
... |
static void abufsink_cfg(void) |
782 |
842 |
|
|
783 |
843 |
abufsink_filt = avfilter_get_by_name("abuffersink"); |
abufsink_filt = avfilter_get_by_name("abuffersink"); |
784 |
844 |
if (abufsink_filt == 0) |
if (abufsink_filt == 0) |
785 |
|
FATAL("audio buffer sink:could not find the filter\n"); |
|
|
845 |
|
fatal("audio buffer sink:could not find the filter\n"); |
786 |
846 |
abufsink_ctx = avfilter_graph_alloc_filter(filter_graph, abufsink_filt, |
abufsink_ctx = avfilter_graph_alloc_filter(filter_graph, abufsink_filt, |
787 |
847 |
"sink_abuf"); |
"sink_abuf"); |
788 |
848 |
if (abufsink_ctx == 0) |
if (abufsink_ctx == 0) |
789 |
|
FATAL("audio buffer sink context:could not allocate the instance in the filter graph\n"); |
|
|
849 |
|
fatal("audio buffer sink context:could not allocate the instance in the filter graph\n"); |
790 |
850 |
r = avfilter_init_str(abufsink_ctx, 0); |
r = avfilter_init_str(abufsink_ctx, 0); |
791 |
851 |
if (r < 0) |
if (r < 0) |
792 |
|
FATAL("audio buffer sink context:unable to initialize\n"); |
|
|
852 |
|
fatal("audio buffer sink context:unable to initialize\n"); |
793 |
853 |
} |
} |
794 |
854 |
static void dec_ctx_cfg(AVCodecParameters *params) |
static void dec_ctx_cfg(AVCodecParameters *params) |
795 |
855 |
{ |
{ |
|
... |
... |
static void dec_ctx_cfg(AVCodecParameters *params) |
797 |
857 |
|
|
798 |
858 |
dec = avcodec_find_decoder(params->codec_id); |
dec = avcodec_find_decoder(params->codec_id); |
799 |
859 |
if (dec == 0) |
if (dec == 0) |
800 |
|
FATAL("ffmpeg:unable to find a proper decoder\n"); |
|
|
860 |
|
fatal("ffmpeg:unable to find a proper decoder\n"); |
801 |
861 |
avcodec_free_context(&dec_ctx); |
avcodec_free_context(&dec_ctx); |
802 |
862 |
dec_ctx = avcodec_alloc_context3(dec); |
dec_ctx = avcodec_alloc_context3(dec); |
803 |
863 |
if (dec_ctx == 0) |
if (dec_ctx == 0) |
804 |
|
FATAL("ffmpeg:unable to allocate a decoder context\n"); |
|
|
864 |
|
fatal("ffmpeg:unable to allocate a decoder context\n"); |
805 |
865 |
/* XXX: useless ? */ |
/* XXX: useless ? */ |
806 |
866 |
r = avcodec_parameters_to_context(dec_ctx, params); |
r = avcodec_parameters_to_context(dec_ctx, params); |
807 |
867 |
if (r < 0) |
if (r < 0) |
808 |
|
FATAL("ffmpeg:unable to apply codec parameters in codec context\n"); |
|
|
868 |
|
fatal("ffmpeg:unable to apply codec parameters in codec context\n"); |
809 |
869 |
/* XXX: ffmpeg thread count default is 1, set to 0 = auto */ |
/* XXX: ffmpeg thread count default is 1, set to 0 = auto */ |
810 |
870 |
dec_ctx->thread_count = 0; |
dec_ctx->thread_count = 0; |
811 |
871 |
r = avcodec_open2(dec_ctx, dec, 0); |
r = avcodec_open2(dec_ctx, dec, 0); |
812 |
872 |
if (r < 0) |
if (r < 0) |
813 |
|
FATAL("ffmpeg:unable to open the decoder context\n"); |
|
|
873 |
|
fatal("ffmpeg:unable to open the decoder context\n"); |
814 |
874 |
} |
} |
815 |
875 |
static void filter_graph_cfg( |
static void filter_graph_cfg( |
816 |
876 |
enum AVSampleFormat src_fmt, int src_rate, int src_chans_n, |
enum AVSampleFormat src_fmt, int src_rate, int src_chans_n, |
|
... |
... |
static void filter_graph_cfg( |
826 |
886 |
|
|
827 |
887 |
filter_graph = avfilter_graph_alloc(); |
filter_graph = avfilter_graph_alloc(); |
828 |
888 |
if (filter_graph == 0) |
if (filter_graph == 0) |
829 |
|
FATAL("unable to create filter graph\n"); |
|
|
889 |
|
fatal("unable to create filter graph\n"); |
830 |
890 |
abufsrc_cfg(src_fmt, src_rate, src_chans_n, src_chans_layout, |
abufsrc_cfg(src_fmt, src_rate, src_chans_n, src_chans_layout, |
831 |
891 |
print_info); |
print_info); |
832 |
892 |
vol_cfg(muted, vol); |
vol_cfg(muted, vol); |
|
... |
... |
static void filter_graph_cfg( |
834 |
894 |
abufsink_cfg(); |
abufsink_cfg(); |
835 |
895 |
r = avfilter_link(abufsrc_ctx, 0, vol_ctx, 0); |
r = avfilter_link(abufsrc_ctx, 0, vol_ctx, 0); |
836 |
896 |
if (r < 0) |
if (r < 0) |
837 |
|
FATAL("unable to connect the audio buffer source filter to the volume filter\n"); |
|
|
897 |
|
fatal("unable to connect the audio buffer source filter to the volume filter\n"); |
838 |
898 |
r = avfilter_link(vol_ctx, 0, afmt_ctx, 0); |
r = avfilter_link(vol_ctx, 0, afmt_ctx, 0); |
839 |
899 |
if (r < 0) |
if (r < 0) |
840 |
|
FATAL("unable to connect the volume filter to the audio format filter\n"); |
|
|
900 |
|
fatal("unable to connect the volume filter to the audio format filter\n"); |
841 |
901 |
r = avfilter_link(afmt_ctx, 0, abufsink_ctx, 0); |
r = avfilter_link(afmt_ctx, 0, abufsink_ctx, 0); |
842 |
902 |
if (r < 0) |
if (r < 0) |
843 |
|
FATAL("unable to connect the audio format filter to the audio buffer sink filter\n"); |
|
|
903 |
|
fatal("unable to connect the audio format filter to the audio buffer sink filter\n"); |
844 |
904 |
r = avfilter_graph_config(filter_graph, 0); |
r = avfilter_graph_config(filter_graph, 0); |
845 |
905 |
if (r < 0) |
if (r < 0) |
846 |
|
FATAL("unable to configure the filter graph\n"); |
|
|
906 |
|
fatal("unable to configure the filter graph\n"); |
847 |
907 |
/*--------------------------------------------------------------------*/ |
/*--------------------------------------------------------------------*/ |
848 |
908 |
if (!print_info) |
if (!print_info) |
849 |
909 |
return; |
return; |
850 |
910 |
dump_str = avfilter_graph_dump(filter_graph, 0); |
dump_str = avfilter_graph_dump(filter_graph, 0); |
851 |
911 |
if (dump_str == 0) { |
if (dump_str == 0) { |
852 |
|
WARNING("unable to get a filter graph description\n"); |
|
|
912 |
|
warning("unable to get a filter graph description\n"); |
853 |
913 |
return; |
return; |
854 |
914 |
} |
} |
855 |
|
POUT("GRAPH START-------------------------------------------------------\n"); |
|
856 |
|
POUT("%s", dump_str); |
|
|
915 |
|
pout("GRAPH START-------------------------------------------------------\n"); |
|
916 |
|
pout("%s", dump_str); |
857 |
917 |
av_free(dump_str); |
av_free(dump_str); |
858 |
|
POUT("GRAPH END---------------------------------------------------------\n"); |
|
|
918 |
|
pout("GRAPH END---------------------------------------------------------\n"); |
859 |
919 |
} |
} |
860 |
920 |
#define DONT_PRINT_INFO false |
#define DONT_PRINT_INFO false |
861 |
921 |
static void filt_flush(void) |
static void filt_flush(void) |
|
... |
... |
static void stdin_tty_init_once(void) |
886 |
946 |
|
|
887 |
947 |
r = isatty(0); |
r = isatty(0); |
888 |
948 |
if (r == 0) { |
if (r == 0) { |
889 |
|
POUT("input:standard input is not a terminal\n"); |
|
|
949 |
|
pout("input:standard input is not a terminal\n"); |
890 |
950 |
return; |
return; |
891 |
951 |
} |
} |
892 |
952 |
memset(&stdin_tio_save, 0, sizeof(stdin_tio_save)); |
memset(&stdin_tio_save, 0, sizeof(stdin_tio_save)); |
893 |
953 |
r = tcgetattr(0, &stdin_tio_save); |
r = tcgetattr(0, &stdin_tio_save); |
894 |
954 |
if (r == -1) |
if (r == -1) |
895 |
|
FATAL("input:unable to get the current standard input terminal line attributes\n"); |
|
|
955 |
|
fatal("input:unable to get the current standard input terminal line attributes\n"); |
896 |
956 |
tio_new = stdin_tio_save; |
tio_new = stdin_tio_save; |
897 |
957 |
tio_new.c_lflag &= ~(ICANON|ECHO); |
tio_new.c_lflag &= ~(ICANON|ECHO); |
898 |
958 |
tio_new.c_cc[VMIN] = 1; /* 1 "char", could be bytes from a utf8 code point */ |
tio_new.c_cc[VMIN] = 1; /* 1 "char", could be bytes from a utf8 code point */ |
|
... |
... |
static void stdin_tty_init_once(void) |
900 |
960 |
r = tcsetattr(0, TCSANOW, &tio_new); |
r = tcsetattr(0, TCSANOW, &tio_new); |
901 |
961 |
stdin_tty_cfg_modified = true; |
stdin_tty_cfg_modified = true; |
902 |
962 |
if (r == -1) |
if (r == -1) |
903 |
|
FATAL("input:unable to set all standard input terminal line\n"); |
|
|
963 |
|
fatal("input:unable to set all standard input terminal line\n"); |
904 |
964 |
r = tcgetattr(0, &tio_chk); |
r = tcgetattr(0, &tio_chk); |
905 |
965 |
if (r == -1) |
if (r == -1) |
906 |
|
FATAL("input:unable to get the current standard input terminal line attributes for checking\n"); |
|
|
966 |
|
fatal("input:unable to get the current standard input terminal line attributes for checking\n"); |
907 |
967 |
r = memcmp(&tio_chk, &tio_new, sizeof(tio_chk)); |
r = memcmp(&tio_chk, &tio_new, sizeof(tio_chk)); |
908 |
968 |
if (r != 0) |
if (r != 0) |
909 |
|
FATAL("input:setting the wanted terminal line attributes failed\n"); |
|
|
969 |
|
fatal("input:setting the wanted terminal line attributes failed\n"); |
910 |
970 |
} |
} |
911 |
971 |
static void stdin_flags_init_once(void) |
static void stdin_flags_init_once(void) |
912 |
972 |
{ |
{ |
|
... |
... |
static void stdin_flags_init_once(void) |
914 |
974 |
/* switch the standard input to non-blocking */ |
/* switch the standard input to non-blocking */ |
915 |
975 |
r = fcntl(0, F_GETFL); |
r = fcntl(0, F_GETFL); |
916 |
976 |
if (r == -1) |
if (r == -1) |
917 |
|
FATAL("input:unable to get the file flags of the standard input\n"); |
|
|
977 |
|
fatal("input:unable to get the file flags of the standard input\n"); |
918 |
978 |
stdin_flags_save = r; |
stdin_flags_save = r; |
919 |
979 |
r |= O_NONBLOCK; |
r |= O_NONBLOCK; |
920 |
980 |
r = fcntl(0, F_SETFL, r); |
r = fcntl(0, F_SETFL, r); |
921 |
981 |
if (r == -1) |
if (r == -1) |
922 |
|
FATAL("input:unable to set non-blocking operations on the standard input\n"); |
|
|
982 |
|
fatal("input:unable to set non-blocking operations on the standard input\n"); |
923 |
983 |
} |
} |
924 |
984 |
static void stdout_init_once(void) |
static void stdout_init_once(void) |
925 |
985 |
{ |
{ |
|
... |
... |
static void stdout_init_once(void) |
927 |
987 |
|
|
928 |
988 |
r = isatty(1); |
r = isatty(1); |
929 |
989 |
if (r == 0) { |
if (r == 0) { |
930 |
|
POUT("output:standard output not is not a terminal\n"); |
|
|
990 |
|
pout("output:standard output not is not a terminal\n"); |
931 |
991 |
stdout_is_tty = false; |
stdout_is_tty = false; |
932 |
992 |
return; |
return; |
933 |
993 |
} |
} |
|
... |
... |
static void sigs_init_once(void) |
947 |
1007 |
|
|
948 |
1008 |
r = sigfillset(&sset); |
r = sigfillset(&sset); |
949 |
1009 |
if (r == -1) |
if (r == -1) |
950 |
|
FATAL("unable to get a full signal mask\n"); |
|
|
1010 |
|
fatal("unable to get a full signal mask\n"); |
951 |
1011 |
/* the "controlling terminal" line asks for a core dump, leave it be */ |
/* the "controlling terminal" line asks for a core dump, leave it be */ |
952 |
1012 |
r = sigdelset(&sset, SIGQUIT); |
r = sigdelset(&sset, SIGQUIT); |
953 |
1013 |
if (r == -1) |
if (r == -1) |
954 |
|
FATAL("unable to remove SIGQUIT from our signal mask\n"); |
|
|
1014 |
|
fatal("unable to remove SIGQUIT from our signal mask\n"); |
955 |
1015 |
r = pthread_sigmask(SIG_SETMASK, &sset, 0); |
r = pthread_sigmask(SIG_SETMASK, &sset, 0); |
956 |
1016 |
if (r != 0) |
if (r != 0) |
957 |
|
FATAL("unable to \"block\" \"all\" signals\n"); |
|
|
1017 |
|
fatal("unable to \"block\" \"all\" signals\n"); |
958 |
1018 |
/* from here, we "steal" signals with signalfd */ |
/* from here, we "steal" signals with signalfd */ |
959 |
1019 |
r = sigemptyset(&sset); |
r = sigemptyset(&sset); |
960 |
1020 |
if (r == -1) |
if (r == -1) |
961 |
|
FATAL("unable to get an empty signal mask\n"); |
|
|
1021 |
|
fatal("unable to get an empty signal mask\n"); |
962 |
1022 |
/* we are asked nicely to terminate */ |
/* we are asked nicely to terminate */ |
963 |
1023 |
r = sigaddset(&sset, SIGTERM); |
r = sigaddset(&sset, SIGTERM); |
964 |
1024 |
if (r == -1) |
if (r == -1) |
965 |
|
FATAL("unable to add SIGTERM to our signal mask\n"); |
|
|
1025 |
|
fatal("unable to add SIGTERM to our signal mask\n"); |
966 |
1026 |
/* the "controlling terminal" line (^c) asks nicely to terminate */ |
/* the "controlling terminal" line (^c) asks nicely to terminate */ |
967 |
1027 |
r = sigaddset(&sset, SIGINT); |
r = sigaddset(&sset, SIGINT); |
968 |
1028 |
if (r == -1) |
if (r == -1) |
969 |
|
FATAL("unable to add SIGINT to our signal mask\n"); |
|
|
1029 |
|
fatal("unable to add SIGINT to our signal mask\n"); |
970 |
1030 |
r = signalfd(-1, &sset, SFD_NONBLOCK); |
r = signalfd(-1, &sset, SFD_NONBLOCK); |
971 |
1031 |
if (r == -1) |
if (r == -1) |
972 |
|
FATAL("unable to get a signalfd file descriptor\n"); |
|
|
1032 |
|
fatal("unable to get a signalfd file descriptor\n"); |
973 |
1033 |
sig_fd = r; |
sig_fd = r; |
974 |
1034 |
} |
} |
975 |
1035 |
static void evt_init_once(void) |
static void evt_init_once(void) |
|
... |
... |
static void evt_init_once(void) |
980 |
1040 |
|
|
981 |
1041 |
ep_fd = epoll_create1(0); |
ep_fd = epoll_create1(0); |
982 |
1042 |
if (ep_fd == -1) |
if (ep_fd == -1) |
983 |
|
FATAL("unable to create the epoll file descriptor\n"); |
|
|
1043 |
|
fatal("unable to create the epoll file descriptor\n"); |
984 |
1044 |
/*--------------------------------------------------------------------*/ |
/*--------------------------------------------------------------------*/ |
985 |
1045 |
/* signals */ |
/* signals */ |
986 |
1046 |
evt.events = EPOLLIN; |
evt.events = EPOLLIN; |
987 |
1047 |
evt.data.fd = sig_fd; |
evt.data.fd = sig_fd; |
988 |
1048 |
r = epoll_ctl(ep_fd, EPOLL_CTL_ADD, sig_fd, &evt); |
r = epoll_ctl(ep_fd, EPOLL_CTL_ADD, sig_fd, &evt); |
989 |
1049 |
if (r == -1) |
if (r == -1) |
990 |
|
FATAL("unable to add the signalfd file descriptior to the epoll file descriptor\n"); |
|
|
1050 |
|
fatal("unable to add the signalfd file descriptior to the epoll file descriptor\n"); |
991 |
1051 |
/*--------------------------------------------------------------------*/ |
/*--------------------------------------------------------------------*/ |
992 |
1052 |
/* standard input/terminal */ |
/* standard input/terminal */ |
993 |
1053 |
evt.events = EPOLLIN; |
evt.events = EPOLLIN; |
994 |
1054 |
evt.data.fd = 0; |
evt.data.fd = 0; |
995 |
1055 |
r = epoll_ctl(ep_fd, EPOLL_CTL_ADD, 0, &evt); |
r = epoll_ctl(ep_fd, EPOLL_CTL_ADD, 0, &evt); |
996 |
1056 |
if (r == -1) |
if (r == -1) |
997 |
|
FATAL("unable to add the standard input to the epoll file descriptor\n"); |
|
|
1057 |
|
fatal("unable to add the standard input to the epoll file descriptor\n"); |
998 |
1058 |
/*--------------------------------------------------------------------*/ |
/*--------------------------------------------------------------------*/ |
999 |
1059 |
/* the timer in charge of accounting unknown esc seq */ |
/* the timer in charge of accounting unknown esc seq */ |
1000 |
1060 |
evt.events = EPOLLIN; |
evt.events = EPOLLIN; |
1001 |
1061 |
evt.data.fd = input_timer_fd; |
evt.data.fd = input_timer_fd; |
1002 |
1062 |
r = epoll_ctl(ep_fd, EPOLL_CTL_ADD, input_timer_fd, &evt); |
r = epoll_ctl(ep_fd, EPOLL_CTL_ADD, input_timer_fd, &evt); |
1003 |
1063 |
if (r == -1) |
if (r == -1) |
1004 |
|
FATAL("unable to add the timer file descriptor accounting for unknown escape sequences to epoll file descriptor\n"); |
|
|
1064 |
|
fatal("unable to add the timer file descriptor accounting for unknown escape sequences to epoll file descriptor\n"); |
1005 |
1065 |
} |
} |
1006 |
1066 |
static void input_state_init_once(void) |
static void input_state_init_once(void) |
1007 |
1067 |
{ |
{ |
1008 |
1068 |
input_timer_fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK); |
input_timer_fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK); |
1009 |
1069 |
if (input_timer_fd == -1) |
if (input_timer_fd == -1) |
1010 |
|
FATAL("unable to get a timer file descriptor\n"); |
|
|
1070 |
|
fatal("unable to get a timer file descriptor\n"); |
1011 |
1071 |
|
|
1012 |
1072 |
input_esc_seq_mode = false; |
input_esc_seq_mode = false; |
1013 |
1073 |
|
|
|
... |
... |
static void input_byte_esc_seq(void) |
1081 |
1141 |
t.it_value.tv_sec = INPUT_ESC_SEQ_TIMEOUT_SECS_N; |
t.it_value.tv_sec = INPUT_ESC_SEQ_TIMEOUT_SECS_N; |
1082 |
1142 |
r = timerfd_settime(input_timer_fd, 0, &t, 0); |
r = timerfd_settime(input_timer_fd, 0, &t, 0); |
1083 |
1143 |
if (r == -1) |
if (r == -1) |
1084 |
|
FATAL("unable to arm the timer to account for unknown input escape sequence from the terminal\n"); |
|
|
1144 |
|
fatal("unable to arm the timer to account for unknown input escape sequence from the terminal\n"); |
1085 |
1145 |
return; |
return; |
1086 |
1146 |
} |
} |
1087 |
1147 |
esc_seq[esc_seq_next_byte] = input_b; |
esc_seq[esc_seq_next_byte] = input_b; |
|
... |
... |
static void input_byte_esc_seq(void) |
1091 |
1151 |
memset(&t, 0, sizeof(t)); |
memset(&t, 0, sizeof(t)); |
1092 |
1152 |
r = timerfd_settime(input_timer_fd, 0, &t, 0); |
r = timerfd_settime(input_timer_fd, 0, &t, 0); |
1093 |
1153 |
if (r == -1) |
if (r == -1) |
1094 |
|
FATAL("unable to disarm the timer used to account for unknown input escape sequence from the terminal\n"); |
|
|
1154 |
|
fatal("unable to disarm the timer used to account for unknown input escape sequence from the terminal\n"); |
1095 |
1155 |
esc_seq_next_byte = 0; |
esc_seq_next_byte = 0; |
1096 |
1156 |
input_esc_seq_mode = false; |
input_esc_seq_mode = false; |
1097 |
1157 |
utf8_cp_next_byte = 0; |
utf8_cp_next_byte = 0; |
|
... |
... |
static void evt_input_drain(void) { loop |
1145 |
1205 |
break; |
break; |
1146 |
1206 |
if (errno == EINTR) /* restart manually the call */ |
if (errno == EINTR) /* restart manually the call */ |
1147 |
1207 |
continue; |
continue; |
1148 |
|
FATAL("an error occured while reading the input\n"); |
|
|
1208 |
|
fatal("an error occured while reading the input\n"); |
1149 |
1209 |
} |
} |
1150 |
1210 |
if (r == 0) |
if (r == 0) |
1151 |
|
FATAL("input end of file\n"); |
|
|
1211 |
|
fatal("input end of file\n"); |
1152 |
1212 |
if (!input_esc_seq_mode) |
if (!input_esc_seq_mode) |
1153 |
1213 |
input_byte_utf8_cp(); |
input_byte_utf8_cp(); |
1154 |
1214 |
else |
else |
|
... |
... |
static void evt_sigs(void) |
1162 |
1222 |
/* no short reads */ |
/* no short reads */ |
1163 |
1223 |
r = read(sig_fd, &siginfo, sizeof(siginfo)); |
r = read(sig_fd, &siginfo, sizeof(siginfo)); |
1164 |
1224 |
if (r != sizeof(siginfo)) |
if (r != sizeof(siginfo)) |
1165 |
|
FATAL("unable to read signal information\n"); |
|
|
1225 |
|
fatal("unable to read signal information\n"); |
1166 |
1226 |
|
|
1167 |
1227 |
switch (siginfo.ssi_signo) { |
switch (siginfo.ssi_signo) { |
1168 |
1228 |
case SIGTERM: |
case SIGTERM: |
1169 |
|
EXIT("received SIGTERM\n"); |
|
|
1229 |
|
exit_ok("received SIGTERM\n"); |
1170 |
1230 |
case SIGINT: |
case SIGINT: |
1171 |
|
EXIT("received SIGINT\n"); |
|
|
1231 |
|
exit_ok("received SIGINT\n"); |
1172 |
1232 |
default: |
default: |
1173 |
|
WARNING("signal handle:unwanted signal %d received, discarding\n", siginfo.ssi_signo); |
|
|
1233 |
|
warning("signal handle:unwanted signal %d received, discarding\n", siginfo.ssi_signo); |
1174 |
1234 |
} |
} |
1175 |
1235 |
} |
} |
1176 |
1236 |
static void evt_timer(void) |
static void evt_timer(void) |
|
... |
... |
static void evt_timer(void) |
1181 |
1241 |
memset(&t, 0, sizeof(t)); |
memset(&t, 0, sizeof(t)); |
1182 |
1242 |
r = timerfd_settime(input_timer_fd, 0, &t, 0); |
r = timerfd_settime(input_timer_fd, 0, &t, 0); |
1183 |
1243 |
if (r == -1) |
if (r == -1) |
1184 |
|
FATAL("unable to disarm the timer used to account for unknown input escape sequences from the terminal\n"); |
|
|
1244 |
|
fatal("unable to disarm the timer used to account for unknown input escape sequences from the terminal\n"); |
1185 |
1245 |
|
|
1186 |
1246 |
esc_seq_next_byte = 0; |
esc_seq_next_byte = 0; |
1187 |
1247 |
input_esc_seq_mode = false; |
input_esc_seq_mode = false; |
|
... |
... |
static void evt_handle(struct epoll_event *evt, bool *pcm_evt) |
1194 |
1254 |
if ((evt->events & EPOLLIN) != 0) |
if ((evt->events & EPOLLIN) != 0) |
1195 |
1255 |
evt_input_drain(); |
evt_input_drain(); |
1196 |
1256 |
else |
else |
1197 |
|
FATAL("event loop wait:input:unexpected event\n"); |
|
|
1257 |
|
fatal("event loop wait:input:unexpected event\n"); |
1198 |
1258 |
} else if (evt->data.fd == sig_fd) { |
} else if (evt->data.fd == sig_fd) { |
1199 |
1259 |
if ((evt->events & EPOLLIN) != 0) |
if ((evt->events & EPOLLIN) != 0) |
1200 |
1260 |
evt_sigs(); |
evt_sigs(); |
1201 |
1261 |
else |
else |
1202 |
|
FATAL("event loop wait:signal:unexpected event\n"); |
|
|
1262 |
|
fatal("event loop wait:signal:unexpected event\n"); |
1203 |
1263 |
} else if (evt->data.fd == input_timer_fd) { |
} else if (evt->data.fd == input_timer_fd) { |
1204 |
1264 |
if ((evt->events & EPOLLIN) != 0) |
if ((evt->events & EPOLLIN) != 0) |
1205 |
1265 |
evt_timer(); |
evt_timer(); |
1206 |
1266 |
else |
else |
1207 |
|
FATAL("event loop wait:timer:unexpected event\n"); |
|
|
1267 |
|
fatal("event loop wait:timer:unexpected event\n"); |
1208 |
1268 |
} else { /* only update alsa fds */ |
} else { /* only update alsa fds */ |
1209 |
1269 |
u8 i; |
u8 i; |
1210 |
1270 |
|
|
|
... |
... |
static void dec_fill(void) { loop |
1239 |
1299 |
if (r == AVERROR(EAGAIN) || r == AVERROR_EOF) |
if (r == AVERROR(EAGAIN) || r == AVERROR_EOF) |
1240 |
1300 |
break; |
break; |
1241 |
1301 |
else if (r != 0) |
else if (r != 0) |
1242 |
|
FATAL("ffmpeg:error while sending the packet to the decoder\n"); |
|
|
1302 |
|
fatal("ffmpeg:error while sending the packet to the decoder\n"); |
1243 |
1303 |
/* r == 0 */ |
/* r == 0 */ |
1244 |
1304 |
av_packet_unref(cb.pkts[sd]); |
av_packet_unref(cb.pkts[sd]); |
1245 |
1305 |
next_sd = sd + 1; |
next_sd = sd + 1; |
|
... |
... |
static bool dec_frs_get(void) { loop |
1268 |
1328 |
dec_frs.most_recent_ts = dec_frs.av->pkt_dts; |
dec_frs.most_recent_ts = dec_frs.av->pkt_dts; |
1269 |
1329 |
return true; /* "return" the current dec_frs.av */ |
return true; /* "return" the current dec_frs.av */ |
1270 |
1330 |
} else if (r == AVERROR_EOF) { |
} else if (r == AVERROR_EOF) { |
1271 |
|
POUT("ffmpeg:last decoder frames reached (receiving)\n"); |
|
|
1331 |
|
pout("ffmpeg:last decoder frames reached (receiving)\n"); |
1272 |
1332 |
return false; |
return false; |
1273 |
1333 |
} |
} |
1274 |
|
FATAL("ffmpeg:error while receiving frames from the decoder\n"); |
|
|
1334 |
|
fatal("ffmpeg:error while receiving frames from the decoder\n"); |
1275 |
1335 |
}} |
}} |
1276 |
1336 |
static bool filt_frs_get(void) { loop |
static bool filt_frs_get(void) { loop |
1277 |
1337 |
{ |
{ |
|
... |
... |
static bool filt_frs_get(void) { loop |
1285 |
1345 |
0 , AV_BUFFERSRC_FLAG_PUSH |
0 , AV_BUFFERSRC_FLAG_PUSH |
1286 |
1346 |
| AV_BUFFERSRC_FLAG_KEEP_REF); |
| AV_BUFFERSRC_FLAG_KEEP_REF); |
1287 |
1347 |
if (r < 0) |
if (r < 0) |
1288 |
|
FATAL("ffmpeg:unable to notify the end of data to the filter source audio buffer context\n"); |
|
|
1348 |
|
fatal("ffmpeg:unable to notify the end of data to the filter source audio buffer context\n"); |
1289 |
1349 |
} else { |
} else { |
1290 |
1350 |
/* |
/* |
1291 |
1351 |
* the dec_frs bufs will be unref in |
* the dec_frs bufs will be unref in |
|
... |
... |
static bool filt_frs_get(void) { loop |
1295 |
1355 |
dec_frs.av, AV_BUFFERSRC_FLAG_PUSH |
dec_frs.av, AV_BUFFERSRC_FLAG_PUSH |
1296 |
1356 |
| AV_BUFFERSRC_FLAG_KEEP_REF); |
| AV_BUFFERSRC_FLAG_KEEP_REF); |
1297 |
1357 |
if (r < 0) |
if (r < 0) |
1298 |
|
FATAL("ffmpeg:unable to submit the decoder frames to the filter source audio buffer context\n"); |
|
|
1358 |
|
fatal("ffmpeg:unable to submit the decoder frames to the filter source audio buffer context\n"); |
1299 |
1359 |
} |
} |
1300 |
1360 |
} |
} |
1301 |
1361 |
/* |
/* |
|
... |
... |
static bool filt_frs_get(void) { loop |
1313 |
1373 |
filt_frs.pcm_written_ufrs_n = 0; |
filt_frs.pcm_written_ufrs_n = 0; |
1314 |
1374 |
return true; |
return true; |
1315 |
1375 |
} else if (r == AVERROR_EOF) { |
} else if (r == AVERROR_EOF) { |
1316 |
|
POUT("ffmpeg:last filter frs reached (getting)\n"); |
|
|
1376 |
|
pout("ffmpeg:last filter frs reached (getting)\n"); |
1317 |
1377 |
return false; |
return false; |
1318 |
1378 |
} |
} |
1319 |
|
FATAL("ffmpeg:error while getting frs from the filter\n"); |
|
|
1379 |
|
fatal("ffmpeg:error while getting frs from the filter\n"); |
1320 |
1380 |
}} |
}} |
1321 |
1381 |
#define NO 0 |
#define NO 0 |
1322 |
1382 |
static void chans_buf_init(u8 **chans_buf, int start_fr_idx) |
static void chans_buf_init(u8 **chans_buf, int start_fr_idx) |
|
... |
... |
static void pcm_filt_frs_write(snd_pcm_uframes_t ufrs_n) { loop |
1431 |
1491 |
|
|
1432 |
1492 |
r1 = snd_pcm_recover(pcm_g, (int)r0, 0); |
r1 = snd_pcm_recover(pcm_g, (int)r0, 0); |
1433 |
1493 |
if (r1 == 0) { |
if (r1 == 0) { |
1434 |
|
WARNING("alsa:pcm recovered going back to epoll\n"); |
|
|
1494 |
|
warning("alsa:pcm recovered going back to epoll\n"); |
1435 |
1495 |
return; /* recovered, go back to epoll */ |
return; /* recovered, go back to epoll */ |
1436 |
1496 |
} |
} |
1437 |
|
FATAL("alsa:unable to recover from suspend/underrun\n"); |
|
|
1497 |
|
fatal("alsa:unable to recover from suspend/underrun\n"); |
1438 |
1498 |
} |
} |
1439 |
|
FATAL("alsa:fatal/unhandled error while writing the frames\n"); |
|
|
1499 |
|
fatal("alsa:fatal/unhandled error while writing the frames\n"); |
1440 |
1500 |
} |
} |
1441 |
1501 |
/* r0 >= 0 */ |
/* r0 >= 0 */ |
1442 |
1502 |
written_ufrs_n = (snd_pcm_uframes_t)r0; |
written_ufrs_n = (snd_pcm_uframes_t)r0; |
|
... |
... |
static void pcm_filt_frs_write(snd_pcm_uframes_t ufrs_n) { loop |
1475 |
1535 |
break; |
break; |
1476 |
1536 |
} |
} |
1477 |
1537 |
/**********************************************/ |
/**********************************************/ |
1478 |
|
EXIT("finished playing\n"); |
|
|
1538 |
|
exit_ok("finished playing\n"); |
1479 |
1539 |
/**********************************************/ |
/**********************************************/ |
1480 |
1540 |
} |
} |
1481 |
1541 |
} |
} |
|
... |
... |
static void evt_pcm_write(void) |
1493 |
1553 |
|
|
1494 |
1554 |
r1 = snd_pcm_recover(pcm_g, (int)r0, 0); |
r1 = snd_pcm_recover(pcm_g, (int)r0, 0); |
1495 |
1555 |
if (r1 == 0) { |
if (r1 == 0) { |
1496 |
|
WARNING("alsa:pcm recovered retrying to get some available frames\n"); |
|
|
1556 |
|
warning("alsa:pcm recovered retrying to get some available frames\n"); |
1497 |
1557 |
r0 = snd_pcm_avail(pcm_g); |
r0 = snd_pcm_avail(pcm_g); |
1498 |
1558 |
if (r0 < 0) |
if (r0 < 0) |
1499 |
|
FATAL("alsa:unable to get some available frames after recovery\n"); |
|
|
1559 |
|
fatal("alsa:unable to get some available frames after recovery\n"); |
1500 |
1560 |
} else |
} else |
1501 |
|
FATAL("alsa:unable to recover from suspend/underrun\n"); |
|
|
1561 |
|
fatal("alsa:unable to recover from suspend/underrun\n"); |
1502 |
1562 |
} else |
} else |
1503 |
|
FATAL("alsa:error getting some available frames\n"); |
|
|
1563 |
|
fatal("alsa:error getting some available frames\n"); |
1504 |
1564 |
} |
} |
1505 |
1565 |
|
|
1506 |
1566 |
if (paused) |
if (paused) |
|
... |
... |
static void evts_loop(void) |
1523 |
1583 |
fds_n = epoll_wait(ep_fd, evts, EPOLL_EVTS_N, -1); |
fds_n = epoll_wait(ep_fd, evts, EPOLL_EVTS_N, -1); |
1524 |
1584 |
if (fds_n == -1) { |
if (fds_n == -1) { |
1525 |
1585 |
if (errno == EINTR) { |
if (errno == EINTR) { |
1526 |
|
WARNING("event loop wait:was interrupted by a signal\n"); |
|
|
1586 |
|
warning("event loop wait:was interrupted by a signal\n"); |
1527 |
1587 |
return; |
return; |
1528 |
1588 |
} |
} |
1529 |
|
FATAL("event loop wait:an error occured\n"); |
|
|
1589 |
|
fatal("event loop wait:an error occured\n"); |
1530 |
1590 |
} |
} |
1531 |
1591 |
pcm_evt = false; |
pcm_evt = false; |
1532 |
1592 |
fd_idx = 0; |
fd_idx = 0; |
|
... |
... |
static void evts_loop(void) |
1546 |
1606 |
r = snd_pcm_poll_descriptors_revents(pcm_g, pcm_pollfds, pcm_pollfds_n, |
r = snd_pcm_poll_descriptors_revents(pcm_g, pcm_pollfds, pcm_pollfds_n, |
1547 |
1607 |
&pcm_evts); |
&pcm_evts); |
1548 |
1608 |
if (r != 0) |
if (r != 0) |
1549 |
|
FATAL("alsa:error processing the poll file descriptors\n"); |
|
|
1609 |
|
fatal("alsa:error processing the poll file descriptors\n"); |
1550 |
1610 |
if ((pcm_evts & ~POLLOUT) != 0) |
if ((pcm_evts & ~POLLOUT) != 0) |
1551 |
|
FATAL("alsa:unexpected events\n"); |
|
|
1611 |
|
fatal("alsa:unexpected events\n"); |
1552 |
1612 |
if ((pcm_evts & POLLOUT) != 0) |
if ((pcm_evts & POLLOUT) != 0) |
1553 |
1613 |
evt_pcm_write(); |
evt_pcm_write(); |
1554 |
1614 |
} |
} |
|
... |
... |
static void silence_bufs_cfg(snd_pcm_t *pcm, bool print_info) |
1569 |
1629 |
|
|
1570 |
1630 |
r = snd_pcm_hw_params_malloc(&hw_params); |
r = snd_pcm_hw_params_malloc(&hw_params); |
1571 |
1631 |
if (r < 0) |
if (r < 0) |
1572 |
|
FATAL("silence:alsa:unable to allocate memory for a hardware parameters container\n"); |
|
|
1632 |
|
fatal("silence:alsa:unable to allocate memory for a hardware parameters container\n"); |
1573 |
1633 |
r = snd_pcm_hw_params_current(pcm, hw_params); |
r = snd_pcm_hw_params_current(pcm, hw_params); |
1574 |
1634 |
if (r != 0) |
if (r != 0) |
1575 |
|
FATAL("silence:alsa:unable to get the pcm hardware parameters\n"); |
|
|
1635 |
|
fatal("silence:alsa:unable to get the pcm hardware parameters\n"); |
1576 |
1636 |
r = snd_pcm_hw_params_get_buffer_size(hw_params, &buf_ufrs_n); |
r = snd_pcm_hw_params_get_buffer_size(hw_params, &buf_ufrs_n); |
1577 |
1637 |
if (r < 0) |
if (r < 0) |
1578 |
|
FATAL("silence:alsa:unable to get the number of frames in the pcm buffer\n"); |
|
|
1638 |
|
fatal("silence:alsa:unable to get the number of frames in the pcm buffer\n"); |
1579 |
1639 |
r = snd_pcm_hw_params_get_format(hw_params, &fmt); |
r = snd_pcm_hw_params_get_format(hw_params, &fmt); |
1580 |
1640 |
if (r < 0) |
if (r < 0) |
1581 |
|
FATAL("silence:alsa:unable to get the pcm format\n"); |
|
|
1641 |
|
fatal("silence:alsa:unable to get the pcm format\n"); |
1582 |
1642 |
r = snd_pcm_hw_params_get_access(hw_params, &access); |
r = snd_pcm_hw_params_get_access(hw_params, &access); |
1583 |
1643 |
if (r < 0) |
if (r < 0) |
1584 |
|
FATAL("silence:alsa:unable to get the pcm access mode\n"); |
|
|
1644 |
|
fatal("silence:alsa:unable to get the pcm access mode\n"); |
1585 |
1645 |
r = snd_pcm_hw_params_get_channels(hw_params, &chans_n); |
r = snd_pcm_hw_params_get_channels(hw_params, &chans_n); |
1586 |
1646 |
if (r < 0) |
if (r < 0) |
1587 |
|
FATAL("silence:alsa:unable to get the pcm number of channels\n"); |
|
|
1647 |
|
fatal("silence:alsa:unable to get the pcm number of channels\n"); |
1588 |
1648 |
/* wipe silence bufs first */ |
/* wipe silence bufs first */ |
1589 |
1649 |
c = 0; |
c = 0; |
1590 |
1650 |
loop { |
loop { |
|
... |
... |
static void silence_bufs_cfg(snd_pcm_t *pcm, bool print_info) |
1603 |
1663 |
buf_bytes_n = snd_pcm_frames_to_bytes(pcm, |
buf_bytes_n = snd_pcm_frames_to_bytes(pcm, |
1604 |
1664 |
(snd_pcm_sframes_t)buf_ufrs_n); |
(snd_pcm_sframes_t)buf_ufrs_n); |
1605 |
1665 |
if (buf_bytes_n <= 0) |
if (buf_bytes_n <= 0) |
1606 |
|
FATAL("silence:alsa:interleaved:unable to get the pcm number of bytes of all buffer frames\n"); |
|
|
1666 |
|
fatal("silence:alsa:interleaved:unable to get the pcm number of bytes of all buffer frames\n"); |
1607 |
1667 |
silence_bufs[0] = malloc((size_t)buf_bytes_n); |
silence_bufs[0] = malloc((size_t)buf_bytes_n); |
1608 |
1668 |
if (silence_bufs[0] == 0) |
if (silence_bufs[0] == 0) |
1609 |
|
FATAL("silence:interleaved:unable to allocate the silence buffer of %d bytes\n", (int)buf_bytes_n); |
|
|
1669 |
|
fatal("silence:interleaved:unable to allocate the silence buffer of %d bytes\n", (int)buf_bytes_n); |
1610 |
1670 |
if (print_info) |
if (print_info) |
1611 |
|
POUT("silence:interleaved:buffer of %d bytes is allocated\n", (int)buf_bytes_n); |
|
|
1671 |
|
pout("silence:interleaved:buffer of %d bytes is allocated\n", (int)buf_bytes_n); |
1612 |
1672 |
r = snd_pcm_format_set_silence(fmt, silence_bufs[0], |
r = snd_pcm_format_set_silence(fmt, silence_bufs[0], |
1613 |
1673 |
(unsigned int)buf_ufrs_n); |
(unsigned int)buf_ufrs_n); |
1614 |
1674 |
if (r < 0) |
if (r < 0) |
1615 |
|
FATAL("silence:interleaved:unable to fill with silence the buffer\n"); |
|
1616 |
|
POUT("silence:interleaved:silence buffer filled with %u silence frames\n", buf_ufrs_n); |
|
|
1675 |
|
fatal("silence:interleaved:unable to fill with silence the buffer\n"); |
|
1676 |
|
pout("silence:interleaved:silence buffer filled with %u silence frames\n", buf_ufrs_n); |
1617 |
1677 |
} else if (access == SND_PCM_ACCESS_RW_NONINTERLEAVED |
} else if (access == SND_PCM_ACCESS_RW_NONINTERLEAVED |
1618 |
1678 |
|| access == SND_PCM_ACCESS_MMAP_NONINTERLEAVED) { |
|| access == SND_PCM_ACCESS_MMAP_NONINTERLEAVED) { |
1619 |
1679 |
ssize_t buf_bytes_n; |
ssize_t buf_bytes_n; |
|
... |
... |
static void silence_bufs_cfg(snd_pcm_t *pcm, bool print_info) |
1622 |
1682 |
buf_samples_n = (long)buf_ufrs_n; |
buf_samples_n = (long)buf_ufrs_n; |
1623 |
1683 |
buf_bytes_n = snd_pcm_samples_to_bytes(pcm, buf_samples_n); |
buf_bytes_n = snd_pcm_samples_to_bytes(pcm, buf_samples_n); |
1624 |
1684 |
if (buf_bytes_n <= 0) |
if (buf_bytes_n <= 0) |
1625 |
|
FATAL("silence:alsa:non interleaved:unable to get the pcm number of total bytes of all buffer samples\n"); |
|
|
1685 |
|
fatal("silence:alsa:non interleaved:unable to get the pcm number of total bytes of all buffer samples\n"); |
1626 |
1686 |
c = 0; |
c = 0; |
1627 |
1687 |
loop { |
loop { |
1628 |
1688 |
if (c == chans_n) |
if (c == chans_n) |
1629 |
1689 |
break; |
break; |
1630 |
1690 |
silence_bufs[c] = malloc((size_t)buf_bytes_n); |
silence_bufs[c] = malloc((size_t)buf_bytes_n); |
1631 |
1691 |
if (silence_bufs[c] == 0) |
if (silence_bufs[c] == 0) |
1632 |
|
FATAL("silence:non interleaved:unable to allocate silence buffer %u of %d bytes\n", c, (int)buf_bytes_n); |
|
|
1692 |
|
fatal("silence:non interleaved:unable to allocate silence buffer %u of %d bytes\n", c, (int)buf_bytes_n); |
1633 |
1693 |
r = snd_pcm_format_set_silence(fmt, silence_bufs[c], |
r = snd_pcm_format_set_silence(fmt, silence_bufs[c], |
1634 |
1694 |
(unsigned int)buf_samples_n); |
(unsigned int)buf_samples_n); |
1635 |
1695 |
if (r < 0) |
if (r < 0) |
1636 |
|
FATAL("silence:non interleaved:unable to fill with silence the buffer\n"); |
|
|
1696 |
|
fatal("silence:non interleaved:unable to fill with silence the buffer\n"); |
1637 |
1697 |
if (print_info) |
if (print_info) |
1638 |
|
POUT("silence:non interleaved:buffer[%u] of %d bytes is allocated\n", c, (int)buf_bytes_n); |
|
|
1698 |
|
pout("silence:non interleaved:buffer[%u] of %d bytes is allocated\n", c, (int)buf_bytes_n); |
1639 |
1699 |
++c; |
++c; |
1640 |
1700 |
} |
} |
1641 |
1701 |
if (print_info) |
if (print_info) |
1642 |
|
POUT("silence:non interleaved:allocated %u silence buffers for %u frames\n", chans_n, (unsigned int)buf_ufrs_n); |
|
|
1702 |
|
pout("silence:non interleaved:allocated %u silence buffers for %u frames\n", chans_n, (unsigned int)buf_ufrs_n); |
1643 |
1703 |
} else |
} else |
1644 |
|
FATAL("silence:the pcm access type is not supported\n"); |
|
|
1704 |
|
fatal("silence:the pcm access type is not supported\n"); |
1645 |
1705 |
snd_pcm_hw_params_free(hw_params); |
snd_pcm_hw_params_free(hw_params); |
1646 |
1706 |
} |
} |
1647 |
1707 |
static void ffmpeg_log_stdout(void *a, int b, const char *fmt, va_list ap) |
static void ffmpeg_log_stdout(void *a, int b, const char *fmt, va_list ap) |
|
... |
... |
static void ffmpeg_log_stdout(void *a, int b, const char *fmt, va_list ap) |
1650 |
1710 |
} |
} |
1651 |
1711 |
static void usage(void) |
static void usage(void) |
1652 |
1712 |
{ |
{ |
1653 |
|
POUT("\ |
|
|
1713 |
|
pout("\ |
1654 |
1714 |
npa [-p alsa pcm] [-v volume(0..100)] [-h] url\n"); |
npa [-p alsa pcm] [-v volume(0..100)] [-h] url\n"); |
1655 |
1715 |
} |
} |
1656 |
1716 |
static void opts_parse(int argc, u8 **args, u8 **url, u8 **pcm_str, |
static void opts_parse(int argc, u8 **args, u8 **url, u8 **pcm_str, |
|
... |
... |
static void opts_parse(int argc, u8 **args, u8 **url, u8 **pcm_str, |
1666 |
1726 |
break; |
break; |
1667 |
1727 |
if (strcmp("-p", args[i]) == 0) { |
if (strcmp("-p", args[i]) == 0) { |
1668 |
1728 |
if ((i + 1) == argc) |
if ((i + 1) == argc) |
1669 |
|
FATAL("-p:alsa pcm is missing\n"); |
|
|
1729 |
|
fatal("-p:alsa pcm is missing\n"); |
1670 |
1730 |
*pcm_str = args[i + 1]; |
*pcm_str = args[i + 1]; |
1671 |
|
POUT("-p:alsa pcm \"%s\"\n", *pcm_str); |
|
|
1731 |
|
pout("-p:alsa pcm \"%s\"\n", *pcm_str); |
1672 |
1732 |
i += 2; |
i += 2; |
1673 |
1733 |
} else if (strcmp("-v", args[i]) == 0) { |
} else if (strcmp("-v", args[i]) == 0) { |
1674 |
1734 |
unsigned long vol_ul; |
unsigned long vol_ul; |
1675 |
1735 |
|
|
1676 |
1736 |
if ((i + 1) == argc) |
if ((i + 1) == argc) |
1677 |
|
FATAL("-v:initial volume option is missing\n"); |
|
|
1737 |
|
fatal("-v:initial volume option is missing\n"); |
1678 |
1738 |
vol_ul = strtoul(args[i + 1], 0, 10); |
vol_ul = strtoul(args[i + 1], 0, 10); |
1679 |
1739 |
if (vol_ul < 0 || 100 < vol_ul) |
if (vol_ul < 0 || 100 < vol_ul) |
1680 |
|
FATAL("-v:invalid volume value %lu (0..100)\n", vol_ul); |
|
|
1740 |
|
fatal("-v:invalid volume value %lu (0..100)\n", vol_ul); |
1681 |
1741 |
*initial_vol = (double)vol_ul / 100.0; |
*initial_vol = (double)vol_ul / 100.0; |
1682 |
|
POUT("-v:using initial volume %f\n", *initial_vol); |
|
|
1742 |
|
pout("-v:using initial volume %f\n", *initial_vol); |
1683 |
1743 |
i += 2; |
i += 2; |
1684 |
1744 |
} else if (strcmp("-h", args[i]) == 0) { |
} else if (strcmp("-h", args[i]) == 0) { |
1685 |
1745 |
usage(); |
usage(); |
|
... |
... |
static void opts_parse(int argc, u8 **args, u8 **url, u8 **pcm_str, |
1690 |
1750 |
} |
} |
1691 |
1751 |
} |
} |
1692 |
1752 |
if (url_idx == -1) |
if (url_idx == -1) |
1693 |
|
FATAL("missing url\n"); |
|
|
1753 |
|
fatal("missing url\n"); |
1694 |
1754 |
*url = args[url_idx]; |
*url = args[url_idx]; |
1695 |
|
POUT("playing ####%s####\n", *url); |
|
|
1755 |
|
pout("playing ####%s####\n", *url); |
1696 |
1756 |
} |
} |
1697 |
1757 |
#define RESET_DONE 0 |
#define RESET_DONE 0 |
1698 |
1758 |
static void cb_init_once(void) |
static void cb_init_once(void) |
|
... |
... |
static void cb_init_once(void) |
1703 |
1763 |
loop { |
loop { |
1704 |
1764 |
cb.pkts[i] = av_packet_alloc(); |
cb.pkts[i] = av_packet_alloc(); |
1705 |
1765 |
if (cb.pkts[i] == 0) |
if (cb.pkts[i] == 0) |
1706 |
|
FATAL("unable to allocate a packet reference for the circular buffer\n"); |
|
|
1766 |
|
fatal("unable to allocate a packet reference for the circular buffer\n"); |
1707 |
1767 |
if (i == U8_MAX) |
if (i == U8_MAX) |
1708 |
1768 |
break; |
break; |
1709 |
1769 |
++i; |
++i; |
|
... |
... |
static void filter_graph_init_once(void) |
1730 |
1790 |
memset(&filt_frs, 0, sizeof(filt_frs)); |
memset(&filt_frs, 0, sizeof(filt_frs)); |
1731 |
1791 |
filt_frs.av = av_frames_alloc(); |
filt_frs.av = av_frames_alloc(); |
1732 |
1792 |
if (filt_frs.av == 0) |
if (filt_frs.av == 0) |
1733 |
|
FATAL("ffmpeg:unable to allocate a filtered frames structure\n"); |
|
|
1793 |
|
fatal("ffmpeg:unable to allocate a filtered frames structure\n"); |
1734 |
1794 |
} |
} |
1735 |
1795 |
static void dec_init_once(void) |
static void dec_init_once(void) |
1736 |
1796 |
{ |
{ |
|
... |
... |
static void dec_init_once(void) |
1738 |
1798 |
dec_ctx = 0; |
dec_ctx = 0; |
1739 |
1799 |
dec_frs.av = av_frames_alloc(); |
dec_frs.av = av_frames_alloc(); |
1740 |
1800 |
if (dec_frs.av == 0) |
if (dec_frs.av == 0) |
1741 |
|
FATAL("ffmpeg:unable to allocate a decoded frames structure\n"); |
|
|
1801 |
|
fatal("ffmpeg:unable to allocate a decoded frames structure\n"); |
1742 |
1802 |
dec_frs.most_recent_ts = AV_NOPTS_VALUE; |
dec_frs.most_recent_ts = AV_NOPTS_VALUE; |
1743 |
1803 |
} |
} |
1744 |
1804 |
static void rd_thd_init_once(void) |
static void rd_thd_init_once(void) |
1745 |
1805 |
{ |
{ |
1746 |
1806 |
rd_thd_pkt = av_packet_alloc(); |
rd_thd_pkt = av_packet_alloc(); |
1747 |
1807 |
if (rd_thd_pkt == 0) |
if (rd_thd_pkt == 0) |
1748 |
|
FATAL("ffmpeg:unable to allocate a packet for the read thread\n"); |
|
|
1808 |
|
fatal("ffmpeg:unable to allocate a packet for the read thread\n"); |
1749 |
1809 |
} |
} |
1750 |
1810 |
static void fmt_init_once(u8 *url) |
static void fmt_init_once(u8 *url) |
1751 |
1811 |
{ |
{ |
|
... |
... |
static void fmt_init_once(u8 *url) |
1754 |
1814 |
fmt_ctx = 0; |
fmt_ctx = 0; |
1755 |
1815 |
r = avformat_open_input(&fmt_ctx, url, NULL, NULL); |
r = avformat_open_input(&fmt_ctx, url, NULL, NULL); |
1756 |
1816 |
if (r < 0) |
if (r < 0) |
1757 |
|
FATAL("ffmpeg:unable to open \"%s\"\n", url); |
|
|
1817 |
|
fatal("ffmpeg:unable to open \"%s\"\n", url); |
1758 |
1818 |
/* probe beyond the header, if any */ |
/* probe beyond the header, if any */ |
1759 |
1819 |
r = avformat_find_stream_info(fmt_ctx, 0); |
r = avformat_find_stream_info(fmt_ctx, 0); |
1760 |
1820 |
if (r < 0) |
if (r < 0) |
1761 |
|
FATAL("ffmpeg:unable to probe \"%s\"\n", url); |
|
|
1821 |
|
fatal("ffmpeg:unable to probe \"%s\"\n", url); |
1762 |
1822 |
r = pthread_mutex_init(&fmt_ctx_mutex, 0); |
r = pthread_mutex_init(&fmt_ctx_mutex, 0); |
1763 |
1823 |
if (r != 0) |
if (r != 0) |
1764 |
|
FATAL("unable to init the format context mutex\n"); |
|
|
1824 |
|
fatal("unable to init the format context mutex\n"); |
1765 |
1825 |
} |
} |
1766 |
1826 |
static void pcm_init_once(u8 *pcm_str) |
static void pcm_init_once(u8 *pcm_str) |
1767 |
1827 |
{ |
{ |
|
... |
... |
static void pcm_init_once(u8 *pcm_str) |
1769 |
1829 |
|
|
1770 |
1830 |
r = snd_output_stdio_attach(&pcm_pout, stdout, 0); |
r = snd_output_stdio_attach(&pcm_pout, stdout, 0); |
1771 |
1831 |
if (r < 0) |
if (r < 0) |
1772 |
|
FATAL("alsa:unable to attach stdout\n"); |
|
|
1832 |
|
fatal("alsa:unable to attach stdout\n"); |
1773 |
1833 |
r = snd_output_stdio_attach(&pcm_perr, stderr, 0); |
r = snd_output_stdio_attach(&pcm_perr, stderr, 0); |
1774 |
1834 |
if (r < 0) |
if (r < 0) |
1775 |
|
FATAL("alsa:unable to attach stderr\n"); |
|
|
1835 |
|
fatal("alsa:unable to attach stderr\n"); |
1776 |
1836 |
r = snd_pcm_open(&pcm_g, pcm_str, SND_PCM_STREAM_PLAYBACK, |
r = snd_pcm_open(&pcm_g, pcm_str, SND_PCM_STREAM_PLAYBACK, |
1777 |
1837 |
SND_PCM_NONBLOCK); |
SND_PCM_NONBLOCK); |
1778 |
1838 |
if (r < 0) { |
if (r < 0) { |
1779 |
1839 |
if (r == -EAGAIN) |
if (r == -EAGAIN) |
1780 |
|
FATAL("alsa:\"%s\" pcm is already in use\n", pcm_str); |
|
|
1840 |
|
fatal("alsa:\"%s\" pcm is already in use\n", pcm_str); |
1781 |
1841 |
else |
else |
1782 |
|
FATAL("alsa:unable to open \"%s\" pcm for playback\n", pcm_str); |
|
|
1842 |
|
fatal("alsa:unable to open \"%s\" pcm for playback\n", pcm_str); |
1783 |
1843 |
} |
} |
1784 |
1844 |
r = snd_pcm_poll_descriptors_count(pcm_g); |
r = snd_pcm_poll_descriptors_count(pcm_g); |
1785 |
|
POUT("alsa:have %d poll file descriptors\n", r); |
|
|
1845 |
|
pout("alsa:have %d poll file descriptors\n", r); |
1786 |
1846 |
if ((r <= 0) || (r > PCM_POLLFDS_N_MAX)) |
if ((r <= 0) || (r > PCM_POLLFDS_N_MAX)) |
1787 |
|
FATAL("alsa:invalid count of alsa poll file descriptors\n"); |
|
|
1847 |
|
fatal("alsa:invalid count of alsa poll file descriptors\n"); |
1788 |
1848 |
pcm_pollfds_n =(u8)r; |
pcm_pollfds_n =(u8)r; |
1789 |
1849 |
memset(pcm_pollfds, 0, sizeof(pcm_pollfds)); |
memset(pcm_pollfds, 0, sizeof(pcm_pollfds)); |
1790 |
1850 |
snd_pcm_poll_descriptors(pcm_g, pcm_pollfds, PCM_POLLFDS_N_MAX); |
snd_pcm_poll_descriptors(pcm_g, pcm_pollfds, PCM_POLLFDS_N_MAX); |
|
... |
... |
static int find_best_st(void) |
1815 |
1875 |
|
|
1816 |
1876 |
r = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, 0, 0); |
r = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, 0, 0); |
1817 |
1877 |
if (r < 0) |
if (r < 0) |
1818 |
|
FATAL("ffmpeg:no audio stream found\n"); |
|
|
1878 |
|
fatal("ffmpeg:no audio stream found\n"); |
1819 |
1879 |
return r; |
return r; |
1820 |
1880 |
} |
} |
1821 |
1881 |
static void pcm_hw_chans_n_decide(snd_pcm_t *pcm, |
static void pcm_hw_chans_n_decide(snd_pcm_t *pcm, |
|
... |
... |
static void pcm_hw_chans_n_decide(snd_pcm_t *pcm, |
1829 |
1889 |
if (r == 0) { |
if (r == 0) { |
1830 |
1890 |
r = snd_pcm_hw_params_set_channels(pcm, pcm_hw_params, chans_n); |
r = snd_pcm_hw_params_set_channels(pcm, pcm_hw_params, chans_n); |
1831 |
1891 |
if (r != 0) |
if (r != 0) |
1832 |
|
FATAL("alsa:unable to restrict pcm device to %u channels, count which was successfully tested\n", chans_n); |
|
1833 |
|
POUT("alsa:using %u channels\n", chans_n); |
|
|
1892 |
|
fatal("alsa:unable to restrict pcm device to %u channels, count which was successfully tested\n", chans_n); |
|
1893 |
|
pout("alsa:using %u channels\n", chans_n); |
1834 |
1894 |
return; |
return; |
1835 |
1895 |
} |
} |
1836 |
|
POUT("alsa:unable to use %u channels\n", chans_n); |
|
|
1896 |
|
pout("alsa:unable to use %u channels\n", chans_n); |
1837 |
1897 |
/* try to use the max chans n the pcm can */ |
/* try to use the max chans n the pcm can */ |
1838 |
1898 |
r = snd_pcm_hw_params_get_channels_max(pcm_hw_params, &chans_n_max); |
r = snd_pcm_hw_params_get_channels_max(pcm_hw_params, &chans_n_max); |
1839 |
1899 |
if (r != 0) |
if (r != 0) |
1840 |
|
FATAL("alsa:unable to get the maximum count of pcm device channels\n"); |
|
|
1900 |
|
fatal("alsa:unable to get the maximum count of pcm device channels\n"); |
1841 |
1901 |
r = snd_pcm_hw_params_test_channels(pcm, pcm_hw_params, chans_n_max); |
r = snd_pcm_hw_params_test_channels(pcm, pcm_hw_params, chans_n_max); |
1842 |
1902 |
if (r == 0) { |
if (r == 0) { |
1843 |
1903 |
r = snd_pcm_hw_params_set_channels(pcm, pcm_hw_params, |
r = snd_pcm_hw_params_set_channels(pcm, pcm_hw_params, |
1844 |
1904 |
chans_n_max); |
chans_n_max); |
1845 |
1905 |
if (r != 0) |
if (r != 0) |
1846 |
|
FATAL("alsa:unable to restrict pcm device to %u channels, count which was successfully tested\n", chans_n_max); |
|
1847 |
|
POUT("alsa:using pcm maximum %u channels\n", chans_n_max); |
|
|
1906 |
|
fatal("alsa:unable to restrict pcm device to %u channels, count which was successfully tested\n", chans_n_max); |
|
1907 |
|
pout("alsa:using pcm maximum %u channels\n", chans_n_max); |
1848 |
1908 |
return; |
return; |
1849 |
1909 |
} |
} |
1850 |
1910 |
/* ok... last try, the pcm dev min chans n */ |
/* ok... last try, the pcm dev min chans n */ |
1851 |
1911 |
r = snd_pcm_hw_params_get_channels_min(pcm_hw_params, &chans_n_min); |
r = snd_pcm_hw_params_get_channels_min(pcm_hw_params, &chans_n_min); |
1852 |
1912 |
if (r != 0) |
if (r != 0) |
1853 |
|
FATAL("alsa:unable to get the minimum count of pcm device channels\n"); |
|
|
1913 |
|
fatal("alsa:unable to get the minimum count of pcm device channels\n"); |
1854 |
1914 |
r = snd_pcm_hw_params_test_channels(pcm, pcm_hw_params, chans_n_min); |
r = snd_pcm_hw_params_test_channels(pcm, pcm_hw_params, chans_n_min); |
1855 |
1915 |
if (r == 0) { |
if (r == 0) { |
1856 |
1916 |
r = snd_pcm_hw_params_set_channels(pcm, pcm_hw_params, |
r = snd_pcm_hw_params_set_channels(pcm, pcm_hw_params, |
1857 |
1917 |
chans_n_min); |
chans_n_min); |
1858 |
1918 |
if (r != 0) |
if (r != 0) |
1859 |
|
FATAL("alsa:unable to restrict pcm device to %u channels, count which was successfully tested\n", chans_n_min); |
|
1860 |
|
POUT("alsa:using pcm device minimum %u channels\n", chans_n_min); |
|
|
1919 |
|
fatal("alsa:unable to restrict pcm device to %u channels, count which was successfully tested\n", chans_n_min); |
|
1920 |
|
pout("alsa:using pcm device minimum %u channels\n", chans_n_min); |
1861 |
1921 |
return; |
return; |
1862 |
1922 |
} |
} |
1863 |
|
FATAL("alsa:unable to find a suitable count of channels\n"); |
|
|
1923 |
|
fatal("alsa:unable to find a suitable count of channels\n"); |
1864 |
1924 |
} |
} |
1865 |
1925 |
static void pcm_hw_rate_decide(snd_pcm_t *pcm, |
static void pcm_hw_rate_decide(snd_pcm_t *pcm, |
1866 |
1926 |
snd_pcm_hw_params_t *pcm_hw_params, unsigned int rate) |
snd_pcm_hw_params_t *pcm_hw_params, unsigned int rate) |
|
... |
... |
static void pcm_hw_rate_decide(snd_pcm_t *pcm, |
1876 |
1936 |
r = snd_pcm_hw_params_set_rate(pcm, pcm_hw_params, rate, |
r = snd_pcm_hw_params_set_rate(pcm, pcm_hw_params, rate, |
1877 |
1937 |
SND_PCM_STREAM_PLAYBACK); |
SND_PCM_STREAM_PLAYBACK); |
1878 |
1938 |
if (r != 0) |
if (r != 0) |
1879 |
|
FATAL("alsa:unable to restrict pcm device to %uHz, which was successfully tested\n", rate); |
|
1880 |
|
POUT("alsa:using %uHz\n", rate); |
|
|
1939 |
|
fatal("alsa:unable to restrict pcm device to %uHz, which was successfully tested\n", rate); |
|
1940 |
|
pout("alsa:using %uHz\n", rate); |
1881 |
1941 |
return; |
return; |
1882 |
1942 |
} |
} |
1883 |
|
POUT("alsa:unable to use %uHz\n", rate); |
|
|
1943 |
|
pout("alsa:unable to use %uHz\n", rate); |
1884 |
1944 |
/* try to use the max rate the pcm can */ |
/* try to use the max rate the pcm can */ |
1885 |
1945 |
r = snd_pcm_hw_params_get_rate_max(pcm_hw_params, &rate_max, |
r = snd_pcm_hw_params_get_rate_max(pcm_hw_params, &rate_max, |
1886 |
1946 |
SND_PCM_STREAM_PLAYBACK); |
SND_PCM_STREAM_PLAYBACK); |
1887 |
1947 |
if (r != 0) |
if (r != 0) |
1888 |
|
FATAL("alsa:unable to get the maximum rate of pcm device\n"); |
|
|
1948 |
|
fatal("alsa:unable to get the maximum rate of pcm device\n"); |
1889 |
1949 |
r = snd_pcm_hw_params_test_rate(pcm, pcm_hw_params, rate_max, |
r = snd_pcm_hw_params_test_rate(pcm, pcm_hw_params, rate_max, |
1890 |
1950 |
SND_PCM_STREAM_PLAYBACK); |
SND_PCM_STREAM_PLAYBACK); |
1891 |
1951 |
if (r == 0) { |
if (r == 0) { |
1892 |
1952 |
r = snd_pcm_hw_params_set_rate(pcm, pcm_hw_params, rate_max, |
r = snd_pcm_hw_params_set_rate(pcm, pcm_hw_params, rate_max, |
1893 |
1953 |
SND_PCM_STREAM_PLAYBACK); |
SND_PCM_STREAM_PLAYBACK); |
1894 |
1954 |
if (r != 0) |
if (r != 0) |
1895 |
|
FATAL("alsa:unable to restrict pcm device to %uHz, which was successfully tested\n", rate_max); |
|
1896 |
|
POUT("alsa:using pcm device %uHz\n", rate_max); |
|
|
1955 |
|
fatal("alsa:unable to restrict pcm device to %uHz, which was successfully tested\n", rate_max); |
|
1956 |
|
pout("alsa:using pcm device %uHz\n", rate_max); |
1897 |
1957 |
return; |
return; |
1898 |
1958 |
} |
} |
1899 |
1959 |
/* try to use a rate "near" of what the pcm dev can */ |
/* try to use a rate "near" of what the pcm dev can */ |
|
... |
... |
static void pcm_hw_rate_decide(snd_pcm_t *pcm, |
1901 |
1961 |
r = snd_pcm_hw_params_set_rate_near(pcm, pcm_hw_params, &rate_near, |
r = snd_pcm_hw_params_set_rate_near(pcm, pcm_hw_params, &rate_near, |
1902 |
1962 |
SND_PCM_STREAM_PLAYBACK); |
SND_PCM_STREAM_PLAYBACK); |
1903 |
1963 |
if (r == 0) { |
if (r == 0) { |
1904 |
|
POUT("alsa:using pcm device %uHz\n", rate_near); |
|
|
1964 |
|
pout("alsa:using pcm device %uHz\n", rate_near); |
1905 |
1965 |
return; |
return; |
1906 |
1966 |
} |
} |
1907 |
1967 |
/* even a "near" rate did failed... try the min */ |
/* even a "near" rate did failed... try the min */ |
1908 |
1968 |
r = snd_pcm_hw_params_get_rate_min(pcm_hw_params, &rate_min, |
r = snd_pcm_hw_params_get_rate_min(pcm_hw_params, &rate_min, |
1909 |
1969 |
SND_PCM_STREAM_PLAYBACK); |
SND_PCM_STREAM_PLAYBACK); |
1910 |
1970 |
if (r != 0) |
if (r != 0) |
1911 |
|
FATAL("alsa:unable to get the minimum rate of pcm device\n"); |
|
|
1971 |
|
fatal("alsa:unable to get the minimum rate of pcm device\n"); |
1912 |
1972 |
r = snd_pcm_hw_params_test_rate(pcm, pcm_hw_params, rate_min, |
r = snd_pcm_hw_params_test_rate(pcm, pcm_hw_params, rate_min, |
1913 |
1973 |
SND_PCM_STREAM_PLAYBACK); |
SND_PCM_STREAM_PLAYBACK); |
1914 |
1974 |
if (r == 0) { |
if (r == 0) { |
1915 |
1975 |
r = snd_pcm_hw_params_set_rate(pcm, pcm_hw_params, rate_min, |
r = snd_pcm_hw_params_set_rate(pcm, pcm_hw_params, rate_min, |
1916 |
1976 |
SND_PCM_STREAM_PLAYBACK); |
SND_PCM_STREAM_PLAYBACK); |
1917 |
1977 |
if (r != 0) |
if (r != 0) |
1918 |
|
FATAL("alsa:unable to restrict pcm device to %uHz, which was successfully tested\n", rate_min); |
|
1919 |
|
POUT("alsa:using pcm device %uHz\n", rate_min); |
|
|
1978 |
|
fatal("alsa:unable to restrict pcm device to %uHz, which was successfully tested\n", rate_min); |
|
1979 |
|
pout("alsa:using pcm device %uHz\n", rate_min); |
1920 |
1980 |
return; |
return; |
1921 |
1981 |
} |
} |
1922 |
|
FATAL("alsa:unable to find a suitable rate\n"); |
|
|
1982 |
|
fatal("alsa:unable to find a suitable rate\n"); |
1923 |
1983 |
} |
} |
1924 |
1984 |
static bool ff_fmt2pcm_layout_best_effort(enum AVSampleFormat ff_fmt, |
static bool ff_fmt2pcm_layout_best_effort(enum AVSampleFormat ff_fmt, |
1925 |
1985 |
snd_pcm_format_t *alsa_fmt, snd_pcm_access_t *alsa_access) |
snd_pcm_format_t *alsa_fmt, snd_pcm_access_t *alsa_access) |
|
... |
... |
static bool ff_fmt2pcm_layout_best_effort(enum AVSampleFormat ff_fmt, |
1963 |
2023 |
*alsa_access = SND_PCM_ACCESS_RW_NONINTERLEAVED; |
*alsa_access = SND_PCM_ACCESS_RW_NONINTERLEAVED; |
1964 |
2024 |
break; |
break; |
1965 |
2025 |
default: |
default: |
1966 |
|
POUT("best effort:unable to wire ffmpeg sample format \"%sbits\" to alsa sample format, \n,", ff_fmt_str); |
|
|
2026 |
|
pout("best effort:unable to wire ffmpeg sample format \"%sbits\" to alsa sample format, \n,", ff_fmt_str); |
1967 |
2027 |
return false; |
return false; |
1968 |
2028 |
} |
} |
1969 |
|
POUT("best effort:ffmpeg format \"%sbits\" (%u bytes) to alsa layout \"%s\" and access \"%s\"\n", ff_fmt_str, av_get_bytes_per_sample(ff_fmt), snd_pcm_format_description(*alsa_fmt), snd_pcm_access_name(*alsa_access)); |
|
|
2029 |
|
pout("best effort:ffmpeg format \"%sbits\" (%u bytes) to alsa layout \"%s\" and access \"%s\"\n", ff_fmt_str, av_get_bytes_per_sample(ff_fmt), snd_pcm_format_description(*alsa_fmt), snd_pcm_access_name(*alsa_access)); |
1970 |
2030 |
return true; |
return true; |
1971 |
2031 |
} |
} |
1972 |
2032 |
static bool pcm_hw_fmt_decide_x(snd_pcm_t *pcm, |
static bool pcm_hw_fmt_decide_x(snd_pcm_t *pcm, |
|
... |
... |
static bool pcm_hw_fmt_decide_x(snd_pcm_t *pcm, |
1979 |
2039 |
return false; |
return false; |
1980 |
2040 |
r = snd_pcm_hw_params_set_format(pcm, pcm_hw_params, fmt); |
r = snd_pcm_hw_params_set_format(pcm, pcm_hw_params, fmt); |
1981 |
2041 |
if (r != 0) |
if (r != 0) |
1982 |
|
FATAL("alsa:unable to restrict pcm device to \"%s\", which was successfully tested\n", snd_pcm_format_description(fmt)); |
|
1983 |
|
POUT("alsa:using \"%s\" format\n", snd_pcm_format_description(fmt)); |
|
|
2042 |
|
fatal("alsa:unable to restrict pcm device to \"%s\", which was successfully tested\n", snd_pcm_format_description(fmt)); |
|
2043 |
|
pout("alsa:using \"%s\" format\n", snd_pcm_format_description(fmt)); |
1984 |
2044 |
return true; |
return true; |
1985 |
2045 |
} |
} |
1986 |
2046 |
#define PCM_HW_FMT_DECIDE_X(fmt) pcm_hw_fmt_decide_x(pcm, pcm_hw_params, fmt) |
#define PCM_HW_FMT_DECIDE_X(fmt) pcm_hw_fmt_decide_x(pcm, pcm_hw_params, fmt) |
|
... |
... |
static void pcm_hw_fmt_decide(snd_pcm_t *pcm, |
1998 |
2058 |
r = snd_pcm_hw_params_set_format(pcm, pcm_hw_params, |
r = snd_pcm_hw_params_set_format(pcm, pcm_hw_params, |
1999 |
2059 |
forced_fmt); |
forced_fmt); |
2000 |
2060 |
if (r != 0) |
if (r != 0) |
2001 |
|
FATAL("alsa:unable to restrict pcm device to \"%s\", which was successfully tested\n", snd_pcm_format_description(forced_fmt)); |
|
2002 |
|
POUT("alsa:using forced \"%s\" format\n", snd_pcm_format_description(forced_fmt)); |
|
|
2061 |
|
fatal("alsa:unable to restrict pcm device to \"%s\", which was successfully tested\n", snd_pcm_format_description(forced_fmt)); |
|
2062 |
|
pout("alsa:using forced \"%s\" format\n", snd_pcm_format_description(forced_fmt)); |
2003 |
2063 |
return; |
return; |
2004 |
2064 |
} |
} |
2005 |
2065 |
} |
} |
|
... |
... |
static void pcm_hw_fmt_decide(snd_pcm_t *pcm, |
2027 |
2087 |
return; |
return; |
2028 |
2088 |
if (PCM_HW_FMT_DECIDE_X(SND_PCM_FORMAT_S8)) |
if (PCM_HW_FMT_DECIDE_X(SND_PCM_FORMAT_S8)) |
2029 |
2089 |
return; |
return; |
2030 |
|
FATAL("alsa:unable to find a suitable format\n"); |
|
|
2090 |
|
fatal("alsa:unable to find a suitable format\n"); |
2031 |
2091 |
} |
} |
2032 |
2092 |
#undef PCM_HW_FMT_DECIDE_X |
#undef PCM_HW_FMT_DECIDE_X |
2033 |
2093 |
static bool pcm_hw_access_decide_x(snd_pcm_t *pcm, |
static bool pcm_hw_access_decide_x(snd_pcm_t *pcm, |
|
... |
... |
static bool pcm_hw_access_decide_x(snd_pcm_t *pcm, |
2040 |
2100 |
return false; |
return false; |
2041 |
2101 |
r = snd_pcm_hw_params_set_access(pcm, pcm_hw_params, access); |
r = snd_pcm_hw_params_set_access(pcm, pcm_hw_params, access); |
2042 |
2102 |
if (r != 0) |
if (r != 0) |
2043 |
|
FATAL("alsa:unable to restrict pcm device to \"%s\", which was successfully tested\n", snd_pcm_access_name(access)); |
|
2044 |
|
POUT("alsa:using \"%s\" access\n", snd_pcm_access_name(access)); |
|
|
2103 |
|
fatal("alsa:unable to restrict pcm device to \"%s\", which was successfully tested\n", snd_pcm_access_name(access)); |
|
2104 |
|
pout("alsa:using \"%s\" access\n", snd_pcm_access_name(access)); |
2045 |
2105 |
return true; |
return true; |
2046 |
2106 |
} |
} |
2047 |
2107 |
#define PCM_HW_ACCESS_DECIDE_X(access) \ |
#define PCM_HW_ACCESS_DECIDE_X(access) \ |
|
... |
... |
static void pcm_hw_access_decide(snd_pcm_t *pcm, |
2061 |
2121 |
r = snd_pcm_hw_params_set_access(pcm, pcm_hw_params, |
r = snd_pcm_hw_params_set_access(pcm, pcm_hw_params, |
2062 |
2122 |
forced_access); |
forced_access); |
2063 |
2123 |
if (r != 0) |
if (r != 0) |
2064 |
|
FATAL("alsa:unable to restrict pcm device to \"%s\", which was successfully tested\n", snd_pcm_access_name(forced_access)); |
|
2065 |
|
POUT("alsa:using forced \"%s\" access\n", snd_pcm_access_name(forced_access)); |
|
|
2124 |
|
fatal("alsa:unable to restrict pcm device to \"%s\", which was successfully tested\n", snd_pcm_access_name(forced_access)); |
|
2125 |
|
pout("alsa:using forced \"%s\" access\n", snd_pcm_access_name(forced_access)); |
2066 |
2126 |
return; |
return; |
2067 |
2127 |
} |
} |
2068 |
2128 |
} |
} |
|
... |
... |
static void pcm_hw_access_decide(snd_pcm_t *pcm, |
2071 |
2131 |
return; |
return; |
2072 |
2132 |
if (PCM_HW_ACCESS_DECIDE_X(SND_PCM_ACCESS_RW_NONINTERLEAVED)) |
if (PCM_HW_ACCESS_DECIDE_X(SND_PCM_ACCESS_RW_NONINTERLEAVED)) |
2073 |
2133 |
return; |
return; |
2074 |
|
FATAL("alsa:unable to find a suitable access\n"); |
|
|
2134 |
|
fatal("alsa:unable to find a suitable access\n"); |
2075 |
2135 |
} |
} |
2076 |
2136 |
#undef PCM_HW_ACCESS_DECIDE_X |
#undef PCM_HW_ACCESS_DECIDE_X |
2077 |
2137 |
/* |
/* |
|
... |
... |
static void pcm_hw_buf_sz_cfg(snd_pcm_t *pcm, |
2094 |
2154 |
|
|
2095 |
2155 |
r = snd_pcm_hw_params_get_rate(pcm_hw_params, &rate, 0); |
r = snd_pcm_hw_params_get_rate(pcm_hw_params, &rate, 0); |
2096 |
2156 |
if (r < 0) { |
if (r < 0) { |
2097 |
|
WARNING("alsa:latency control:DISABLING LATENCY CONTROL:unable to get the decided rate from the current device parameters\n"); |
|
|
2157 |
|
warning("alsa:latency control:DISABLING LATENCY CONTROL:unable to get the decided rate from the current device parameters\n"); |
2098 |
2158 |
return; |
return; |
2099 |
2159 |
} |
} |
2100 |
2160 |
latency_control_target_buf_ufrs_n = (snd_pcm_uframes_t)rate; |
latency_control_target_buf_ufrs_n = (snd_pcm_uframes_t)rate; |
|
... |
... |
static void pcm_hw_buf_sz_cfg(snd_pcm_t *pcm, |
2103 |
2163 |
r = snd_pcm_hw_params_set_buffer_size_near(pcm, pcm_hw_params, |
r = snd_pcm_hw_params_set_buffer_size_near(pcm, pcm_hw_params, |
2104 |
2164 |
&latency_control_buf_ufrs_n); |
&latency_control_buf_ufrs_n); |
2105 |
2165 |
if (r < 0) { |
if (r < 0) { |
2106 |
|
WARNING("alsa:latency control:DISABLING_LATENCY_CONTROL:unable to set the audio buffer size (count of frames) to %u periods for the current device parameters\n", latency_control_buf_ufrs_n); |
|
|
2166 |
|
warning("alsa:latency control:DISABLING_LATENCY_CONTROL:unable to set the audio buffer size (count of frames) to %u periods for the current device parameters\n", latency_control_buf_ufrs_n); |
2107 |
2167 |
return; |
return; |
2108 |
2168 |
} |
} |
2109 |
|
POUT("alsa:latency control:target buffer frame count is %u (~0.25 sec), got an audio buffer size set to %u frames\n", latency_control_target_buf_ufrs_n, latency_control_buf_ufrs_n); |
|
|
2169 |
|
pout("alsa:latency control:target buffer frame count is %u (~0.25 sec), got an audio buffer size set to %u frames\n", latency_control_target_buf_ufrs_n, latency_control_buf_ufrs_n); |
2110 |
2170 |
} |
} |
2111 |
2171 |
static void pcm_cfg_sw(snd_pcm_t *pcm) |
static void pcm_cfg_sw(snd_pcm_t *pcm) |
2112 |
2172 |
{ |
{ |
2113 |
2173 |
int r; |
int r; |
2114 |
2174 |
snd_pcm_sw_params_t *sw_params; |
snd_pcm_sw_params_t *sw_params; |
2115 |
2175 |
|
|
2116 |
|
POUT("ALSA:SW_PARAMS START------------------------------------------------------------\n"); |
|
|
2176 |
|
pout("ALSA:SW_PARAMS START------------------------------------------------------------\n"); |
2117 |
2177 |
r = snd_pcm_sw_params_malloc(&sw_params); |
r = snd_pcm_sw_params_malloc(&sw_params); |
2118 |
2178 |
if (r != 0) |
if (r != 0) |
2119 |
|
FATAL("alsa:unable to allocate software parameters structure\n"); |
|
|
2179 |
|
fatal("alsa:unable to allocate software parameters structure\n"); |
2120 |
2180 |
r = snd_pcm_sw_params_current(pcm, sw_params); |
r = snd_pcm_sw_params_current(pcm, sw_params); |
2121 |
2181 |
if (r != 0) |
if (r != 0) |
2122 |
|
FATAL("alsa:unable to get current software parameters\n"); |
|
|
2182 |
|
fatal("alsa:unable to get current software parameters\n"); |
2123 |
2183 |
r = snd_pcm_sw_params_set_period_event(pcm, sw_params, 1); |
r = snd_pcm_sw_params_set_period_event(pcm, sw_params, 1); |
2124 |
2184 |
if (r != 0) |
if (r != 0) |
2125 |
|
FATAL("alsa:unable to enable period event\n"); |
|
|
2185 |
|
fatal("alsa:unable to enable period event\n"); |
2126 |
2186 |
r = snd_pcm_sw_params(pcm, sw_params); |
r = snd_pcm_sw_params(pcm, sw_params); |
2127 |
2187 |
if (r != 0) |
if (r != 0) |
2128 |
|
FATAL("alsa:unable to install sotfware parameters\n"); |
|
|
2188 |
|
fatal("alsa:unable to install sotfware parameters\n"); |
2129 |
2189 |
snd_pcm_sw_params_dump(sw_params, pcm_pout); |
snd_pcm_sw_params_dump(sw_params, pcm_pout); |
2130 |
2190 |
snd_pcm_sw_params_free(sw_params); |
snd_pcm_sw_params_free(sw_params); |
2131 |
|
POUT("ALSA:SW_PARAMS END--------------------------------------------------------------\n"); |
|
|
2191 |
|
pout("ALSA:SW_PARAMS END--------------------------------------------------------------\n"); |
2132 |
2192 |
} |
} |
2133 |
2193 |
/* |
/* |
2134 |
2194 |
* this function will "decide" the pcm dev cfg: |
* this function will "decide" the pcm dev cfg: |
|
... |
... |
static void pcm_cfg_hw_core(snd_pcm_t *pcm, snd_pcm_hw_params_t *pcm_hw_params, |
2151 |
2211 |
/* the return value is from a first refine of the raw hw params */ |
/* the return value is from a first refine of the raw hw params */ |
2152 |
2212 |
r = snd_pcm_hw_params_any(pcm, pcm_hw_params); |
r = snd_pcm_hw_params_any(pcm, pcm_hw_params); |
2153 |
2213 |
if (r < 0) |
if (r < 0) |
2154 |
|
FATAL("alsa:unable to populate the hardware parameters context\n"); |
|
|
2214 |
|
fatal("alsa:unable to populate the hardware parameters context\n"); |
2155 |
2215 |
pcm_hw_chans_n_decide(pcm, pcm_hw_params, (unsigned int)chans_n); |
pcm_hw_chans_n_decide(pcm, pcm_hw_params, (unsigned int)chans_n); |
2156 |
2216 |
pcm_hw_rate_decide(pcm, pcm_hw_params, (unsigned int)rate); |
pcm_hw_rate_decide(pcm, pcm_hw_params, (unsigned int)rate); |
2157 |
2217 |
/* try our best */ |
/* try our best */ |
|
... |
... |
static void pcm_cfg_hw(snd_pcm_t *pcm, unsigned int chans_n, unsigned int rate, |
2170 |
2230 |
snd_pcm_access_t access; |
snd_pcm_access_t access; |
2171 |
2231 |
snd_pcm_hw_params_t *hw_params; |
snd_pcm_hw_params_t *hw_params; |
2172 |
2232 |
|
|
2173 |
|
POUT("ALSA:HW_PARAMS START------------------------------------------------------------\n"); |
|
|
2233 |
|
pout("ALSA:HW_PARAMS START------------------------------------------------------------\n"); |
2174 |
2234 |
r = snd_pcm_hw_params_malloc(&hw_params); |
r = snd_pcm_hw_params_malloc(&hw_params); |
2175 |
2235 |
if (r < 0) |
if (r < 0) |
2176 |
|
FATAL("alsa:unable to allocate hardware parameters context\n"); |
|
|
2236 |
|
fatal("alsa:unable to allocate hardware parameters context\n"); |
2177 |
2237 |
pcm_cfg_hw_core(pcm, hw_params, chans_n, rate, ff_fmt); |
pcm_cfg_hw_core(pcm, hw_params, chans_n, rate, ff_fmt); |
2178 |
2238 |
r = snd_pcm_hw_params(pcm, hw_params); |
r = snd_pcm_hw_params(pcm, hw_params); |
2179 |
2239 |
if (r != 0) |
if (r != 0) |
2180 |
|
FATAL("alsa:unable to install the hardware parameters\n"); |
|
|
2240 |
|
fatal("alsa:unable to install the hardware parameters\n"); |
2181 |
2241 |
r = snd_pcm_hw_params_current(pcm, hw_params); |
r = snd_pcm_hw_params_current(pcm, hw_params); |
2182 |
2242 |
if (r != 0) |
if (r != 0) |
2183 |
|
FATAL("alsa:unable to get current hardware parameters\n"); |
|
|
2243 |
|
fatal("alsa:unable to get current hardware parameters\n"); |
2184 |
2244 |
snd_pcm_hw_params_dump(hw_params, pcm_pout); |
snd_pcm_hw_params_dump(hw_params, pcm_pout); |
2185 |
2245 |
snd_pcm_hw_params_free(hw_params); |
snd_pcm_hw_params_free(hw_params); |
2186 |
|
POUT("ALSA:HW_PARAMS END--------------------------------------------------------------\n"); |
|
|
2246 |
|
pout("ALSA:HW_PARAMS END--------------------------------------------------------------\n"); |
2187 |
2247 |
} |
} |
2188 |
2248 |
static void pcm_cfg(snd_pcm_t *pcm, unsigned int chans_n, unsigned int rate, |
static void pcm_cfg(snd_pcm_t *pcm, unsigned int chans_n, unsigned int rate, |
2189 |
2249 |
enum AVSampleFormat ff_fmt) |
enum AVSampleFormat ff_fmt) |
2190 |
2250 |
{ |
{ |
2191 |
2251 |
pcm_cfg_hw(pcm, chans_n, rate, ff_fmt); |
pcm_cfg_hw(pcm, chans_n, rate, ff_fmt); |
2192 |
2252 |
pcm_cfg_sw(pcm); |
pcm_cfg_sw(pcm); |
2193 |
|
POUT("ALSA PCM DUMP START-------------------------------------------------------------\n"); |
|
|
2253 |
|
pout("ALSA PCM DUMP START-------------------------------------------------------------\n"); |
2194 |
2254 |
snd_pcm_dump(pcm, pcm_pout); |
snd_pcm_dump(pcm, pcm_pout); |
2195 |
|
POUT("ALSA PCM DUMP END---------------------------------------------------------------\n"); |
|
|
2255 |
|
pout("ALSA PCM DUMP END---------------------------------------------------------------\n"); |
2196 |
2256 |
} |
} |
2197 |
2257 |
static void evt_pcm_install(void) |
static void evt_pcm_install(void) |
2198 |
2258 |
{ |
{ |
|
... |
... |
static void evt_pcm_install(void) |
2209 |
2269 |
evt.data.fd = pcm_pollfds[i].fd; |
evt.data.fd = pcm_pollfds[i].fd; |
2210 |
2270 |
r = epoll_ctl(ep_fd, EPOLL_CTL_ADD, pcm_pollfds[i].fd, &evt); |
r = epoll_ctl(ep_fd, EPOLL_CTL_ADD, pcm_pollfds[i].fd, &evt); |
2211 |
2271 |
if (r == -1) |
if (r == -1) |
2212 |
|
FATAL("unable to add alsa poll file descriptor[%d]=%d to epoll file descriptor\n", i, pcm_pollfds[i].fd); |
|
|
2272 |
|
fatal("unable to add alsa poll file descriptor[%d]=%d to epoll file descriptor\n", i, pcm_pollfds[i].fd); |
2213 |
2273 |
++i; |
++i; |
2214 |
2274 |
} |
} |
2215 |
|
POUT("alsa:pcm events installed\n"); |
|
|
2275 |
|
pout("alsa:pcm events installed\n"); |
2216 |
2276 |
} |
} |
2217 |
2277 |
static void evt_pcm_uninstall(void) |
static void evt_pcm_uninstall(void) |
2218 |
2278 |
{ |
{ |
|
... |
... |
static void evt_pcm_uninstall(void) |
2225 |
2285 |
(void)epoll_ctl(ep_fd, EPOLL_CTL_DEL, pcm_pollfds[i].fd, 0); |
(void)epoll_ctl(ep_fd, EPOLL_CTL_DEL, pcm_pollfds[i].fd, 0); |
2226 |
2286 |
++i; |
++i; |
2227 |
2287 |
} |
} |
2228 |
|
POUT("alsa:pcm events uninstalled\n"); |
|
|
2288 |
|
pout("alsa:pcm events uninstalled\n"); |
2229 |
2289 |
} |
} |
2230 |
2290 |
#define PRINT_INFO true |
#define PRINT_INFO true |
2231 |
2291 |
static void play(int st_idx, double initial_vol, bool do_rd_thd_reset) |
static void play(int st_idx, double initial_vol, bool do_rd_thd_reset) |
|
... |
... |
static void seek_x(int64_t delta) |
2278 |
2338 |
AVRational st_tb; |
AVRational st_tb; |
2279 |
2339 |
|
|
2280 |
2340 |
if (dec_frs.most_recent_ts == AV_NOPTS_VALUE) |
if (dec_frs.most_recent_ts == AV_NOPTS_VALUE) |
2281 |
|
WARNING("unable to seek because no time stamp are currently available\n"); |
|
|
2341 |
|
warning("unable to seek because no time stamp are currently available\n"); |
2282 |
2342 |
fmt_ctx_lock(); |
fmt_ctx_lock(); |
2283 |
2343 |
st = fmt_ctx->streams[current_st_idx]; |
st = fmt_ctx->streams[current_st_idx]; |
2284 |
2344 |
st_tb = st->time_base; |
st_tb = st->time_base; |
|
... |
... |
static void seek_x(int64_t delta) |
2286 |
2346 |
|
|
2287 |
2347 |
new_ts = dec_frs.most_recent_ts + delta * st_tb.den / st_tb.num; |
new_ts = dec_frs.most_recent_ts + delta * st_tb.den / st_tb.num; |
2288 |
2348 |
/* rewind capping */ |
/* rewind capping */ |
2289 |
|
POUT("trying to seek to %"PRId64" stream time base units\n", new_ts); |
|
|
2349 |
|
pout("trying to seek to %"PRId64" stream time base units\n", new_ts); |
2290 |
2350 |
fmt_ctx_lock(); |
fmt_ctx_lock(); |
2291 |
2351 |
r = av_seek_pkt(fmt_ctx, st->id, new_ts, 0); |
r = av_seek_pkt(fmt_ctx, st->id, new_ts, 0); |
2292 |
2352 |
fmt_ctx_unlock(); |
fmt_ctx_unlock(); |
2293 |
2353 |
if (r < 0) |
if (r < 0) |
2294 |
|
WARNING("unable to seek to %"PRId64" stream time base units\n", new_ts); |
|
|
2354 |
|
warning("unable to seek to %"PRId64" stream time base units\n", new_ts); |
2295 |
2355 |
dec_frs.most_recent_ts = AV_NOPTS_VALUE; |
dec_frs.most_recent_ts = AV_NOPTS_VALUE; |
2296 |
2356 |
rd_thd_reset(current_st_idx); |
rd_thd_reset(current_st_idx); |
2297 |
2357 |
avcodec_flush_buffers(dec_ctx); |
avcodec_flush_buffers(dec_ctx); |
2298 |
2358 |
filt_frs.no_more_dec_frs = false; /* reset by the previous line */ |
filt_frs.no_more_dec_frs = false; /* reset by the previous line */ |
2299 |
2359 |
filt_flush(); |
filt_flush(); |
2300 |
2360 |
if (!filt_frs_get()) |
if (!filt_frs_get()) |
2301 |
|
EXIT("no more audio frames to play\n"); |
|
|
2361 |
|
exit_ok("no more audio frames to play\n"); |
2302 |
2362 |
} |
} |
2303 |
2363 |
static void cmd_rewind(void) |
static void cmd_rewind(void) |
2304 |
2364 |
{ |
{ |
2305 |
|
POUT("COMMAND:rewind\n"); |
|
|
2365 |
|
pout("COMMAND:rewind\n"); |
2306 |
2366 |
seek_x(-SEEK_DELTA); |
seek_x(-SEEK_DELTA); |
2307 |
2367 |
} |
} |
2308 |
2368 |
static void cmd_rewind_big(void) |
static void cmd_rewind_big(void) |
2309 |
2369 |
{ |
{ |
2310 |
|
POUT("COMMAND:rewind big\n"); |
|
|
2370 |
|
pout("COMMAND:rewind big\n"); |
2311 |
2371 |
seek_x(-SEEK_DELTA_BIG); |
seek_x(-SEEK_DELTA_BIG); |
2312 |
2372 |
} |
} |
2313 |
2373 |
static void cmd_fastforward(void) |
static void cmd_fastforward(void) |
2314 |
2374 |
{ |
{ |
2315 |
|
POUT("COMMAND:fastforward\n"); |
|
|
2375 |
|
pout("COMMAND:fastforward\n"); |
2316 |
2376 |
seek_x(SEEK_DELTA); |
seek_x(SEEK_DELTA); |
2317 |
2377 |
} |
} |
2318 |
2378 |
static void cmd_fastforward_big(void) |
static void cmd_fastforward_big(void) |
2319 |
2379 |
{ |
{ |
2320 |
|
POUT("COMMAND:fastforward big\n"); |
|
|
2380 |
|
pout("COMMAND:fastforward big\n"); |
2321 |
2381 |
seek_x(SEEK_DELTA_BIG); |
seek_x(SEEK_DELTA_BIG); |
2322 |
2382 |
} |
} |
2323 |
2383 |
static void cmd_pause(void) |
static void cmd_pause(void) |
2324 |
2384 |
{ |
{ |
2325 |
2385 |
if (paused) { |
if (paused) { |
2326 |
|
POUT("COMMAND:unpause\n"); |
|
|
2386 |
|
pout("COMMAND:unpause\n"); |
2327 |
2387 |
paused = false; |
paused = false; |
2328 |
2388 |
} else { |
} else { |
2329 |
|
POUT("COMMAND:pause\n"); |
|
|
2389 |
|
pout("COMMAND:pause\n"); |
2330 |
2390 |
paused = true; |
paused = true; |
2331 |
2391 |
} |
} |
2332 |
2392 |
} |
} |
|
... |
... |
static void cmd_vol_up(void) |
2340 |
2400 |
if (filt_frs.vol > 1.0) |
if (filt_frs.vol > 1.0) |
2341 |
2401 |
filt_frs.vol = 1.0; |
filt_frs.vol = 1.0; |
2342 |
2402 |
snprintf(vol_l10n_str, sizeof(vol_l10n_str), "%f", filt_frs.vol); |
snprintf(vol_l10n_str, sizeof(vol_l10n_str), "%f", filt_frs.vol); |
2343 |
|
POUT("COMMAND:volume up to value %s(%s)\n", vol_l10n_str, filt_frs.muted ? "muted" : "unmuted"); |
|
|
2403 |
|
pout("COMMAND:volume up to value %s(%s)\n", vol_l10n_str, filt_frs.muted ? "muted" : "unmuted"); |
2344 |
2404 |
if (filt_frs.muted) |
if (filt_frs.muted) |
2345 |
2405 |
return; |
return; |
2346 |
2406 |
r = avfilter_graph_send_command(filter_graph, "vol", "volume", |
r = avfilter_graph_send_command(filter_graph, "vol", "volume", |
2347 |
2407 |
vol_l10n_str, response, sizeof(response), 0); |
vol_l10n_str, response, sizeof(response), 0); |
2348 |
2408 |
if (r < 0) |
if (r < 0) |
2349 |
|
WARNING("ffmpeg:volume context:unable to set the volume up to \"%s\":response from volume filter:\"%s\"\n", response); |
|
|
2409 |
|
warning("ffmpeg:volume context:unable to set the volume up to \"%s\":response from volume filter:\"%s\"\n", response); |
2350 |
2410 |
} |
} |
2351 |
2411 |
static void cmd_vol_down(void) |
static void cmd_vol_down(void) |
2352 |
2412 |
{ |
{ |
|
... |
... |
static void cmd_vol_down(void) |
2358 |
2418 |
if (filt_frs.vol < 0.0) |
if (filt_frs.vol < 0.0) |
2359 |
2419 |
filt_frs.vol = 0.0; |
filt_frs.vol = 0.0; |
2360 |
2420 |
snprintf(vol_l10n_str, sizeof(vol_l10n_str), "%f", filt_frs.vol); |
snprintf(vol_l10n_str, sizeof(vol_l10n_str), "%f", filt_frs.vol); |
2361 |
|
POUT("COMMAND:volume down to value %s(%s)\n", vol_l10n_str, filt_frs.muted ? "muted" : "unmuted"); |
|
|
2421 |
|
pout("COMMAND:volume down to value %s(%s)\n", vol_l10n_str, filt_frs.muted ? "muted" : "unmuted"); |
2362 |
2422 |
if (filt_frs.muted) |
if (filt_frs.muted) |
2363 |
2423 |
return; |
return; |
2364 |
2424 |
r = avfilter_graph_send_command(filter_graph, "vol", "volume", |
r = avfilter_graph_send_command(filter_graph, "vol", "volume", |
2365 |
2425 |
vol_l10n_str, response, sizeof(response), 0); |
vol_l10n_str, response, sizeof(response), 0); |
2366 |
2426 |
if (r < 0) |
if (r < 0) |
2367 |
|
WARNING("ffmpeg:volume context:unable to set the volume down to \"%s\":response from volume filter:\"%s\"\n", response); |
|
|
2427 |
|
warning("ffmpeg:volume context:unable to set the volume down to \"%s\":response from volume filter:\"%s\"\n", response); |
2368 |
2428 |
} |
} |
2369 |
2429 |
static void cmd_mute(void) |
static void cmd_mute(void) |
2370 |
2430 |
{ |
{ |
|
... |
... |
static void cmd_mute(void) |
2373 |
2433 |
u8 response[STR_SZ]; |
u8 response[STR_SZ]; |
2374 |
2434 |
|
|
2375 |
2435 |
if (filt_frs.muted) { |
if (filt_frs.muted) { |
2376 |
|
POUT("COMMAND:unmuting\n"); |
|
|
2436 |
|
pout("COMMAND:unmuting\n"); |
2377 |
2437 |
|
|
2378 |
2438 |
snprintf(vol_l10n_str, sizeof(vol_l10n_str), "%f", |
snprintf(vol_l10n_str, sizeof(vol_l10n_str), "%f", |
2379 |
2439 |
filt_frs.vol); |
filt_frs.vol); |
2380 |
2440 |
r = avfilter_graph_send_command(filter_graph, "vol", "volume", |
r = avfilter_graph_send_command(filter_graph, "vol", "volume", |
2381 |
2441 |
vol_l10n_str, response, sizeof(response), 0); |
vol_l10n_str, response, sizeof(response), 0); |
2382 |
2442 |
if (r < 0) { |
if (r < 0) { |
2383 |
|
WARNING("ffmpeg:volume context:unable to mute the volume to 0:response from volume filter:%s\n", response); |
|
|
2443 |
|
warning("ffmpeg:volume context:unable to mute the volume to 0:response from volume filter:%s\n", response); |
2384 |
2444 |
} else { |
} else { |
2385 |
2445 |
filt_frs.muted = false; |
filt_frs.muted = false; |
2386 |
2446 |
} |
} |
2387 |
2447 |
} else { |
} else { |
2388 |
|
POUT("COMMAND:muting\n"); |
|
|
2448 |
|
pout("COMMAND:muting\n"); |
2389 |
2449 |
|
|
2390 |
2450 |
r = avfilter_graph_send_command(filter_graph, "vol", "volume", |
r = avfilter_graph_send_command(filter_graph, "vol", "volume", |
2391 |
2451 |
double_zero_l10n_str, response, sizeof(response), 0); |
double_zero_l10n_str, response, sizeof(response), 0); |
2392 |
2452 |
if (r < 0) { |
if (r < 0) { |
2393 |
|
WARNING("ffmpeg:volume context:unable to mute the volume to 0:response from volume filter:%s\n", response); |
|
|
2453 |
|
warning("ffmpeg:volume context:unable to mute the volume to 0:response from volume filter:%s\n", response); |
2394 |
2454 |
} else { |
} else { |
2395 |
2455 |
filt_frs.muted = true; |
filt_frs.muted = true; |
2396 |
2456 |
} |
} |
|
... |
... |
int main(int argc, u8 **args) |
2423 |
2483 |
fmt_ctx_unlock(); |
fmt_ctx_unlock(); |
2424 |
2484 |
av_log_set_callback(av_log_default_callback); |
av_log_set_callback(av_log_default_callback); |
2425 |
2485 |
if (!filt_frs_get()) /* must have some frames to play */ |
if (!filt_frs_get()) /* must have some frames to play */ |
2426 |
|
EXIT("no initial audio frames to play\n"); |
|
|
2486 |
|
exit_ok("no initial audio frames to play\n"); |
2427 |
2487 |
loop evts_loop(); |
loop evts_loop(); |
2428 |
2488 |
/* unreachable */ |
/* unreachable */ |
2429 |
2489 |
} |
} |
|
... |
... |
int main(int argc, u8 **args) |
2442 |
2502 |
#undef AVFrameFormat |
#undef AVFrameFormat |
2443 |
2503 |
#undef AVFrames |
#undef AVFrames |
2444 |
2504 |
#undef esc_seq_sz |
#undef esc_seq_sz |
2445 |
|
#undef EXIT |
|
2446 |
2505 |
#undef f32 |
#undef f32 |
2447 |
|
#undef FATAL |
|
2448 |
2506 |
#undef frame_fmt |
#undef frame_fmt |
2449 |
2507 |
#undef frame_rate |
#undef frame_rate |
2450 |
2508 |
#undef frames_n |
#undef frames_n |
2451 |
2509 |
#undef INPUT_ESC_SEQ_TIMEOUT_SECS_N |
#undef INPUT_ESC_SEQ_TIMEOUT_SECS_N |
2452 |
2510 |
#undef loop |
#undef loop |
2453 |
2511 |
#undef PCM_POLLFDS_N_MAX |
#undef PCM_POLLFDS_N_MAX |
2454 |
|
#undef PERR |
|
2455 |
2512 |
#undef PKTS_N_MAX |
#undef PKTS_N_MAX |
2456 |
|
#undef POUT |
|
2457 |
2513 |
#undef SEEK_DELTA |
#undef SEEK_DELTA |
2458 |
2514 |
#undef SEEK_DELTA_BIG |
#undef SEEK_DELTA_BIG |
2459 |
2515 |
#undef STR_SZ |
#undef STR_SZ |
|
... |
... |
int main(int argc, u8 **args) |
2462 |
2518 |
#undef u8 |
#undef u8 |
2463 |
2519 |
#undef U8_MAX |
#undef U8_MAX |
2464 |
2520 |
#undef VOL_DELTA |
#undef VOL_DELTA |
2465 |
|
#undef WARNING |
|
2466 |
2521 |
#endif |
#endif |