1
0
mirror of https://github.com/DigitalDevices/octonet.git synced 2023-10-10 13:36:52 +02:00

issue 45 and 46

This commit is contained in:
Ralph Metzler 2016-04-21 23:30:13 +02:00
parent f6c13c7a6b
commit 9251fed043

View File

@ -59,9 +59,14 @@ static void update_switch_vec(struct ossess *sess)
{ {
struct osmcc *mcc; struct osmcc *mcc;
uint32_t vec = 0; uint32_t vec = 0;
struct ossess *ownsess = sess->stream->session;
if (!sess->os->has_switch)
return;
for (mcc = sess->mccs.lh_first; mcc; mcc = mcc->mcc.le_next) for (mcc = sess->mccs.lh_first; mcc; mcc = mcc->mcc.le_next)
vec |= mcc->port_vec; vec |= mcc->port_vec;
if (conform && ownsess->trans.mcast && (ownsess->playing & 2))
vec |= 0x1f;
if (vec != sess->mcc_port_vec_set || sess->port_vec != sess->port_vec_set) { if (vec != sess->mcc_port_vec_set || sess->port_vec != sess->port_vec_set) {
sess->mcc_port_vec_set = vec; sess->mcc_port_vec_set = vec;
sess->port_vec_set = sess->port_vec; sess->port_vec_set = sess->port_vec;
@ -469,6 +474,7 @@ static uint32_t session_is_playing(struct ossess *sess)
pthread_mutex_lock(&os->lock); pthread_mutex_lock(&os->lock);
for (i = 0; i < MAX_SESSION; i++) for (i = 0; i < MAX_SESSION; i++)
if (os->session[i].state && if (os->session[i].state &&
os->session[i].trans.mcast &&
(os->session[i].stream == str)) { (os->session[i].stream == str)) {
playing |= os->session[i].playing; playing |= os->session[i].playing;
dbgprintf(DEBUG_DEBUG, "playing[%u] = %u\n", dbgprintf(DEBUG_DEBUG, "playing[%u] = %u\n",
@ -1591,8 +1597,7 @@ static int setup_session(struct oscon *con, int newtrans)
set_pmt(str->ca, p->pmt); set_pmt(str->ca, p->pmt);
} }
if (con->session->trans.mcast) { if (con->session->trans.mcast) {
if (con->os->has_switch) update_switch_vec(sess);
update_switch_vec(sess);
} }
return 0; return 0;
} }
@ -1602,29 +1607,29 @@ static int stop_session(struct ossess *sess)
if (!session_is_playing(sess)) if (!session_is_playing(sess))
return 0; return 0;
sess->playing &= ~1; sess->playing &= ~1;
if (session_is_playing(sess)) if (!session_is_playing(sess)) {
return 0; printf("stopping session %d\n", sess->nr);
printf("stopping session %d\n", sess->nr); if (sess->nsfd >= 0)
if (sess->nsfd >= 0) ioctl(sess->nsfd, NS_STOP);
ioctl(sess->nsfd, NS_STOP); }
update_switch_vec(sess);
return 0; return 0;
} }
static int start_session(struct ossess *sess) static int start_session(struct ossess *sess)
{ {
if (session_is_playing(sess)) { if (!session_is_playing(sess)) {
sess->playing |= 1; dbgprintf(DEBUG_SYS, "start session %d\n", sess->nr);
return 0; if (sess->stream->ca) {
} uint8_t canum = sess->stream->ca->nr - 1;
dbgprintf(DEBUG_SYS, "start session %d\n", sess->nr); if (sess->nsfd >= 0)
if (sess->stream->ca) { ioctl(sess->nsfd, NS_SET_CI, &canum);
uint8_t canum = sess->stream->ca->nr - 1; }
if (sess->nsfd >= 0) if (sess->nsfd >= 0)
ioctl(sess->nsfd, NS_SET_CI, &canum); ioctl(sess->nsfd, NS_START);
} }
if (sess->nsfd >= 0)
ioctl(sess->nsfd, NS_START);
sess->playing |= 1; sess->playing |= 1;
update_switch_vec(sess);
return 0; return 0;
} }
@ -1653,13 +1658,15 @@ static int play_session(struct oscon *con)
start_session(str->session); start_session(str->session);
} else { } else {
#ifndef IGNORE_NS #ifndef IGNORE_NS
if (sess->nsfd < 0) if (sess->nsfd < 0)
return -455; return -455;
#endif #endif
start_session(sess); start_session(sess);
} }
dbgprintf(DEBUG_SYS, "%s set playing =2\n", __FUNCTION__);
sess->playing |= 2; sess->playing |= 2;
pthread_mutex_unlock(&os->lock); pthread_mutex_unlock(&os->lock);
update_switch_vec(sess);
return 0; return 0;
} }
@ -1672,6 +1679,8 @@ static struct ossess *match_session(struct octoserve *os, uint8_t *group)
sess = &os->session[i]; sess = &os->session[i];
if (!sess->state || !sess->trans.mcast) if (!sess->state || !sess->trans.mcast)
continue; continue;
if (conform && sess->stream->session != sess)
continue;
if (!memcmp(sess->trans.mcip, group, 4)) if (!memcmp(sess->trans.mcip, group, 4))
return sess; return sess;
} }
@ -1699,10 +1708,9 @@ void mc_check(struct ossess *sess, int update)
} }
} }
if (update) { if (update) {
if (os->has_switch) update_switch_vec(sess);
update_switch_vec(sess);
if (!sess->mccs.lh_first) if (!sess->mccs.lh_first)
//if (mtime() > sess->mc_timeout) //if (mtime() > sess->mc_timeout)
stop_session(sess); stop_session(sess);
} }
pthread_mutex_unlock(&os->lock); pthread_mutex_unlock(&os->lock);
@ -1719,8 +1727,7 @@ void mc_del(struct ossess *sess)
LIST_REMOVE(mcc, mcc); LIST_REMOVE(mcc, mcc);
free(mcc); free(mcc);
} }
if (os->has_switch) update_switch_vec(sess);
update_switch_vec(sess);
pthread_mutex_unlock(&os->lock); pthread_mutex_unlock(&os->lock);
} }
@ -1779,8 +1786,7 @@ void mc_join(struct octoserve *os, uint8_t *ip, uint8_t *mac, uint8_t *group)
newmcc->port_vec = port; newmcc->port_vec = port;
sess->mcc_port_vec |= port; sess->mcc_port_vec |= port;
} }
if (os->has_switch) update_switch_vec(sess);
update_switch_vec(sess);
} }
if (!session_is_playing(sess)) if (!session_is_playing(sess))
start_session(sess); start_session(sess);
@ -1823,8 +1829,7 @@ void mc_leave(struct octoserve *os, uint8_t *ip, uint8_t *group)
break; break;
} }
} }
if (os->has_switch) update_switch_vec(sess);
update_switch_vec(sess);
out: out:
pthread_mutex_unlock(&os->lock); pthread_mutex_unlock(&os->lock);
} }