Skip to content

Commit

Permalink
Merge transport thread struct with transport PCM
Browse files Browse the repository at this point in the history
  • Loading branch information
arkq committed Dec 27, 2023
1 parent 0495d17 commit 2167d1c
Show file tree
Hide file tree
Showing 21 changed files with 361 additions and 378 deletions.
6 changes: 2 additions & 4 deletions src/a2dp-aac.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ void *a2dp_aac_enc_thread(struct ba_transport_pcm *t_pcm) {
pthread_cleanup_push(PTHREAD_CLEANUP(ba_transport_pcm_thread_cleanup), t_pcm);

struct ba_transport *t = t_pcm->t;
struct ba_transport_thread *th = t_pcm->th;
struct io_poll io = { .timeout = -1 };

HANDLE_AACENCODER handle;
Expand Down Expand Up @@ -338,7 +337,7 @@ void *a2dp_aac_enc_thread(struct ba_transport_pcm *t_pcm) {
AACENC_OutArgs out_args = { 0 };

debug_transport_pcm_thread_loop(t_pcm, "START");
for (ba_transport_thread_state_set_running(th);;) {
for (ba_transport_pcm_state_set_running(t_pcm);;) {

ssize_t samples = ffb_len_in(&pcm);
switch (samples = io_poll_and_read_pcm(&io, t_pcm, pcm.tail, samples)) {
Expand Down Expand Up @@ -442,7 +441,6 @@ void *a2dp_aac_dec_thread(struct ba_transport_pcm *t_pcm) {
pthread_cleanup_push(PTHREAD_CLEANUP(ba_transport_pcm_thread_cleanup), t_pcm);

struct ba_transport *t = t_pcm->t;
struct ba_transport_thread *th = t_pcm->th;
struct io_poll io = { .timeout = -1 };

HANDLE_AACDECODER handle;
Expand Down Expand Up @@ -495,7 +493,7 @@ void *a2dp_aac_dec_thread(struct ba_transport_pcm *t_pcm) {
int markbit_quirk = -3;

debug_transport_pcm_thread_loop(t_pcm, "START");
for (ba_transport_thread_state_set_running(th);;) {
for (ba_transport_pcm_state_set_running(t_pcm);;) {

ssize_t len = ffb_blen_in(&bt);
if ((len = io_poll_and_read_bt(&io, t_pcm, bt.data, len)) <= 0) {
Expand Down
6 changes: 2 additions & 4 deletions src/a2dp-aptx-hd.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ void *a2dp_aptx_hd_enc_thread(struct ba_transport_pcm *t_pcm) {
pthread_cleanup_push(PTHREAD_CLEANUP(ba_transport_pcm_thread_cleanup), t_pcm);

struct ba_transport *t = t_pcm->t;
struct ba_transport_thread *th = t_pcm->th;
struct io_poll io = { .timeout = -1 };

HANDLE_APTX handle;
Expand Down Expand Up @@ -144,7 +143,7 @@ void *a2dp_aptx_hd_enc_thread(struct ba_transport_pcm *t_pcm) {
rtp_state_init(&rtp, samplerate, samplerate);

debug_transport_pcm_thread_loop(t_pcm, "START");
for (ba_transport_thread_state_set_running(th);;) {
for (ba_transport_pcm_state_set_running(t_pcm);;) {

ssize_t samples = ffb_len_in(&pcm);
switch (samples = io_poll_and_read_pcm(&io, t_pcm, pcm.tail, samples)) {
Expand Down Expand Up @@ -246,7 +245,6 @@ void *a2dp_aptx_hd_dec_thread(struct ba_transport_pcm *t_pcm) {
pthread_cleanup_push(PTHREAD_CLEANUP(ba_transport_pcm_thread_cleanup), t_pcm);

struct ba_transport *t = t_pcm->t;
struct ba_transport_thread *th = t_pcm->th;
struct io_poll io = { .timeout = -1 };

HANDLE_APTX handle;
Expand Down Expand Up @@ -277,7 +275,7 @@ void *a2dp_aptx_hd_dec_thread(struct ba_transport_pcm *t_pcm) {
rtp_state_init(&rtp, samplerate, samplerate);

debug_transport_pcm_thread_loop(t_pcm, "START");
for (ba_transport_thread_state_set_running(th);;) {
for (ba_transport_pcm_state_set_running(t_pcm);;) {

ssize_t len = ffb_blen_in(&bt);
if ((len = io_poll_and_read_bt(&io, t_pcm, bt.data, len)) <= 0) {
Expand Down
6 changes: 2 additions & 4 deletions src/a2dp-aptx.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ void *a2dp_aptx_enc_thread(struct ba_transport_pcm *t_pcm) {
pthread_cleanup_push(PTHREAD_CLEANUP(ba_transport_pcm_thread_cleanup), t_pcm);

struct ba_transport *t = t_pcm->t;
struct ba_transport_thread *th = t_pcm->th;
struct io_poll io = { .timeout = -1 };

HANDLE_APTX handle;
Expand All @@ -134,7 +133,7 @@ void *a2dp_aptx_enc_thread(struct ba_transport_pcm *t_pcm) {
}

debug_transport_pcm_thread_loop(t_pcm, "START");
for (ba_transport_thread_state_set_running(th);;) {
for (ba_transport_pcm_state_set_running(t_pcm);;) {

ssize_t samples = ffb_len_in(&pcm);
switch (samples = io_poll_and_read_pcm(&io, t_pcm, pcm.tail, samples)) {
Expand Down Expand Up @@ -228,7 +227,6 @@ void *a2dp_aptx_dec_thread(struct ba_transport_pcm *t_pcm) {
pthread_cleanup_push(PTHREAD_CLEANUP(ba_transport_pcm_thread_cleanup), t_pcm);

struct ba_transport *t = t_pcm->t;
struct ba_transport_thread *th = t_pcm->th;
struct io_poll io = { .timeout = -1 };

HANDLE_APTX handle;
Expand All @@ -252,7 +250,7 @@ void *a2dp_aptx_dec_thread(struct ba_transport_pcm *t_pcm) {
}

debug_transport_pcm_thread_loop(t_pcm, "START");
for (ba_transport_thread_state_set_running(th);;) {
for (ba_transport_pcm_state_set_running(t_pcm);;) {

ssize_t len = ffb_blen_in(&bt);
if ((len = io_poll_and_read_bt(&io, t_pcm, bt.data, len)) <= 0) {
Expand Down
6 changes: 2 additions & 4 deletions src/a2dp-faststream.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ void *a2dp_faststream_enc_thread(struct ba_transport_pcm *t_pcm) {
pthread_cleanup_push(PTHREAD_CLEANUP(ba_transport_pcm_thread_cleanup), t_pcm);

struct ba_transport *t = t_pcm->t;
struct ba_transport_thread *th = t_pcm->th;
struct io_poll io = { .timeout = -1 };

/* determine encoder operation mode: music or voice */
Expand Down Expand Up @@ -142,7 +141,7 @@ void *a2dp_faststream_enc_thread(struct ba_transport_pcm *t_pcm) {
}

debug_transport_pcm_thread_loop(t_pcm, "START");
for (ba_transport_thread_state_set_running(th);;) {
for (ba_transport_pcm_state_set_running(t_pcm);;) {

ssize_t samples = ffb_len_in(&pcm);
switch (samples = io_poll_and_read_pcm(&io, t_pcm, pcm.tail, samples)) {
Expand Down Expand Up @@ -238,7 +237,6 @@ void *a2dp_faststream_dec_thread(struct ba_transport_pcm *t_pcm) {
pthread_cleanup_push(PTHREAD_CLEANUP(ba_transport_pcm_thread_cleanup), t_pcm);

struct ba_transport *t = t_pcm->t;
struct ba_transport_thread *th = t_pcm->th;
struct io_poll io = { .timeout = -1 };

/* determine decoder operation mode: music or voice */
Expand Down Expand Up @@ -267,7 +265,7 @@ void *a2dp_faststream_dec_thread(struct ba_transport_pcm *t_pcm) {
}

debug_transport_pcm_thread_loop(t_pcm, "START");
for (ba_transport_thread_state_set_running(th);;) {
for (ba_transport_pcm_state_set_running(t_pcm);;) {

ssize_t len = ffb_blen_in(&bt);
if ((len = io_poll_and_read_bt(&io, t_pcm, bt.tail, len)) <= 0) {
Expand Down
6 changes: 2 additions & 4 deletions src/a2dp-lc3plus.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ void *a2dp_lc3plus_enc_thread(struct ba_transport_pcm *t_pcm) {
pthread_cleanup_push(PTHREAD_CLEANUP(ba_transport_pcm_thread_cleanup), t_pcm);

struct ba_transport *t = t_pcm->t;
struct ba_transport_thread *th = t_pcm->th;
struct io_poll io = { .timeout = -1 };

const a2dp_lc3plus_t *configuration = &t->a2dp.configuration.lc3plus;
Expand Down Expand Up @@ -255,7 +254,7 @@ void *a2dp_lc3plus_enc_thread(struct ba_transport_pcm *t_pcm) {
rtp_state_init(&rtp, samplerate, rtp_ts_clockrate);

debug_transport_pcm_thread_loop(t_pcm, "START");
for (ba_transport_thread_state_set_running(th);;) {
for (ba_transport_pcm_state_set_running(t_pcm);;) {

ssize_t samples = ffb_len_in(&pcm);
switch (samples = io_poll_and_read_pcm(&io, t_pcm, pcm.tail, samples)) {
Expand Down Expand Up @@ -405,7 +404,6 @@ void *a2dp_lc3plus_dec_thread(struct ba_transport_pcm *t_pcm) {
pthread_cleanup_push(PTHREAD_CLEANUP(ba_transport_pcm_thread_cleanup), t_pcm);

struct ba_transport *t = t_pcm->t;
struct ba_transport_thread *th = t_pcm->th;
struct io_poll io = { .timeout = -1 };

const a2dp_lc3plus_t *configuration = &t->a2dp.configuration.lc3plus;
Expand Down Expand Up @@ -466,7 +464,7 @@ void *a2dp_lc3plus_dec_thread(struct ba_transport_pcm *t_pcm) {
bool rtp_media_fragment_skip = false;

debug_transport_pcm_thread_loop(t_pcm, "START");
for (ba_transport_thread_state_set_running(th);;) {
for (ba_transport_pcm_state_set_running(t_pcm);;) {

ssize_t len = ffb_blen_in(&bt);
if ((len = io_poll_and_read_bt(&io, t_pcm, bt.data, len)) <= 0) {
Expand Down
6 changes: 2 additions & 4 deletions src/a2dp-ldac.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ void *a2dp_ldac_enc_thread(struct ba_transport_pcm *t_pcm) {
pthread_cleanup_push(PTHREAD_CLEANUP(ba_transport_pcm_thread_cleanup), t_pcm);

struct ba_transport *t = t_pcm->t;
struct ba_transport_thread *th = t_pcm->th;
struct io_poll io = { .timeout = -1 };

HANDLE_LDAC_BT handle;
Expand Down Expand Up @@ -184,7 +183,7 @@ void *a2dp_ldac_enc_thread(struct ba_transport_pcm *t_pcm) {
rtp_state_init(&rtp, samplerate, samplerate);

debug_transport_pcm_thread_loop(t_pcm, "START");
for (ba_transport_thread_state_set_running(th);;) {
for (ba_transport_pcm_state_set_running(t_pcm);;) {

ssize_t samples = ffb_len_in(&pcm);
switch (samples = io_poll_and_read_pcm(&io, t_pcm, pcm.tail, samples)) {
Expand Down Expand Up @@ -302,7 +301,6 @@ void *a2dp_ldac_dec_thread(struct ba_transport_pcm *t_pcm) {
pthread_cleanup_push(PTHREAD_CLEANUP(ba_transport_pcm_thread_cleanup), t_pcm);

struct ba_transport *t = t_pcm->t;
struct ba_transport_thread *th = t_pcm->th;
struct io_poll io = { .timeout = -1 };

HANDLE_LDAC_BT handle;
Expand Down Expand Up @@ -339,7 +337,7 @@ void *a2dp_ldac_dec_thread(struct ba_transport_pcm *t_pcm) {
rtp_state_init(&rtp, samplerate, samplerate);

debug_transport_pcm_thread_loop(t_pcm, "START");
for (ba_transport_thread_state_set_running(th);;) {
for (ba_transport_pcm_state_set_running(t_pcm);;) {

ssize_t len = ffb_blen_in(&bt);
if ((len = io_poll_and_read_bt(&io, t_pcm, bt.data, len)) <= 0) {
Expand Down
6 changes: 2 additions & 4 deletions src/a2dp-mpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ void *a2dp_mp3_enc_thread(struct ba_transport_pcm *t_pcm) {
pthread_cleanup_push(PTHREAD_CLEANUP(ba_transport_pcm_thread_cleanup), t_pcm);

struct ba_transport *t = t_pcm->t;
struct ba_transport_thread *th = t_pcm->th;
struct io_poll io = { .timeout = -1 };

lame_t handle;
Expand Down Expand Up @@ -306,7 +305,7 @@ void *a2dp_mp3_enc_thread(struct ba_transport_pcm *t_pcm) {
rtp_state_init(&rtp, samplerate, 90000);

debug_transport_pcm_thread_loop(t_pcm, "START");
for (ba_transport_thread_state_set_running(th);;) {
for (ba_transport_pcm_state_set_running(t_pcm);;) {

ssize_t samples = ffb_len_in(&pcm);
switch (samples = io_poll_and_read_pcm(&io, t_pcm, pcm.tail, samples)) {
Expand Down Expand Up @@ -415,7 +414,6 @@ void *a2dp_mpeg_dec_thread(struct ba_transport_pcm *t_pcm) {
pthread_cleanup_push(PTHREAD_CLEANUP(ba_transport_pcm_thread_cleanup), t_pcm);

struct ba_transport *t = t_pcm->t;
struct ba_transport_thread *th = t_pcm->th;
struct io_poll io = { .timeout = -1 };

#if ENABLE_MPG123
Expand Down Expand Up @@ -490,7 +488,7 @@ void *a2dp_mpeg_dec_thread(struct ba_transport_pcm *t_pcm) {
rtp_state_init(&rtp, samplerate, 90000);

debug_transport_pcm_thread_loop(t_pcm, "START");
for (ba_transport_thread_state_set_running(th);;) {
for (ba_transport_pcm_state_set_running(t_pcm);;) {

ssize_t len = ffb_blen_in(&bt);
if ((len = io_poll_and_read_bt(&io, t_pcm, bt.data, len)) <= 0) {
Expand Down
6 changes: 2 additions & 4 deletions src/a2dp-sbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ void *a2dp_sbc_enc_thread(struct ba_transport_pcm *t_pcm) {
pthread_cleanup_push(PTHREAD_CLEANUP(ba_transport_pcm_thread_cleanup), t_pcm);

struct ba_transport *t = t_pcm->t;
struct ba_transport_thread *th = t_pcm->th;
struct io_poll io = { .timeout = -1 };

sbc_t sbc;
Expand Down Expand Up @@ -223,7 +222,7 @@ void *a2dp_sbc_enc_thread(struct ba_transport_pcm *t_pcm) {
rtp_state_init(&rtp, samplerate, samplerate);

debug_transport_pcm_thread_loop(t_pcm, "START");
for (ba_transport_thread_state_set_running(th);;) {
for (ba_transport_pcm_state_set_running(t_pcm);;) {

ssize_t samples = ffb_len_in(&pcm);
switch (samples = io_poll_and_read_pcm(&io, t_pcm, pcm.tail, samples)) {
Expand Down Expand Up @@ -331,7 +330,6 @@ void *a2dp_sbc_dec_thread(struct ba_transport_pcm *t_pcm) {
pthread_cleanup_push(PTHREAD_CLEANUP(ba_transport_pcm_thread_cleanup), t_pcm);

struct ba_transport *t = t_pcm->t;
struct ba_transport_thread *th = t_pcm->th;
struct io_poll io = { .timeout = -1 };

sbc_t sbc;
Expand Down Expand Up @@ -368,7 +366,7 @@ void *a2dp_sbc_dec_thread(struct ba_transport_pcm *t_pcm) {
#endif

debug_transport_pcm_thread_loop(t_pcm, "START");
for (ba_transport_thread_state_set_running(th);;) {
for (ba_transport_pcm_state_set_running(t_pcm);;) {

ssize_t len = ffb_blen_in(&bt);
if ((len = io_poll_and_read_bt(&io, t_pcm, bt.data, len)) <= 0) {
Expand Down
Loading

0 comments on commit 2167d1c

Please sign in to comment.