diff options
author | Benny Prijono <bennylp@teluu.com> | 2008-03-04 15:31:13 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2008-03-04 15:31:13 +0000 |
commit | 93f91b36381a56608b372cc5bc99b17fe8d6174d (patch) | |
tree | d2285860da37886f3606b07ede41bbad932760bd | |
parent | f20e3435d9ce6fbbc7ca3194eda369e77531819c (diff) |
Ticket #501: Set master port worker thread priority to highest by default
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1843 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r-- | pjmedia/include/pjmedia/clock.h | 14 | ||||
-rw-r--r-- | pjmedia/include/pjmedia/master_port.h | 3 | ||||
-rw-r--r-- | pjmedia/src/pjmedia/clock_thread.c | 7 | ||||
-rw-r--r-- | pjmedia/src/pjmedia/master_port.c | 4 |
4 files changed, 18 insertions, 10 deletions
diff --git a/pjmedia/include/pjmedia/clock.h b/pjmedia/include/pjmedia/clock.h index 06fe4cd6..12daa837 100644 --- a/pjmedia/include/pjmedia/clock.h +++ b/pjmedia/include/pjmedia/clock.h @@ -62,7 +62,12 @@ enum pjmedia_clock_options * application must poll the clock continuously by calling * #pjmedia_clock_wait() in order to synchronize timing. */ - PJMEDIA_CLOCK_NO_ASYNC = 1 + PJMEDIA_CLOCK_NO_ASYNC = 1, + + /** + * Prevent the clock from setting it's thread to highest priority. + */ + PJMEDIA_CLOCK_NO_HIGHEST_PRIO = 2 }; @@ -86,12 +91,7 @@ typedef void pjmedia_clock_callback(const pj_timestamp *ts, * @param samples_per_frame Number of samples per frame. This argument * along with clock_rate, specifies the interval * of each clock run (or clock ticks). - * @param options By default, the callback will be called - * asynchronously (depending on the clock - * implementation backend, a thread may be - * created). If PJMEDIA_CLOCK_NO_ASYNC is set, - * application must poll the clock with - * #pjmedia_clock_wait() to let the clock runs. + * @param options Bitmask of pjmedia_clock_options. * @param cb Callback to be called for each clock tick. * @param user_data User data, which will be passed to the callback. * @param p_clock Pointer to receive the clock instance. diff --git a/pjmedia/include/pjmedia/master_port.h b/pjmedia/include/pjmedia/master_port.h index 33216b86..242949d9 100644 --- a/pjmedia/include/pjmedia/master_port.h +++ b/pjmedia/include/pjmedia/master_port.h @@ -70,7 +70,8 @@ typedef struct pjmedia_master_port pjmedia_master_port; * @param pool Pool to allocate master port from. * @param u_port Upstream port. * @param d_port Downstream port. - * @param options Options flags, must be zero for now. + * @param options Options flags, from bitmask combinations from + * pjmedia_clock_options. * @param p_m Pointer to receive the master port instance. * * @return PJ_SUCCESS on success. diff --git a/pjmedia/src/pjmedia/clock_thread.c b/pjmedia/src/pjmedia/clock_thread.c index ad0e4e88..02ff66cf 100644 --- a/pjmedia/src/pjmedia/clock_thread.c +++ b/pjmedia/src/pjmedia/clock_thread.c @@ -215,6 +215,13 @@ static int clock_thread(void *arg) pj_timestamp now; pjmedia_clock *clock = (pjmedia_clock*) arg; + /* Set thread priority to maximum unless not wanted. */ + if ((clock->options & PJMEDIA_CLOCK_NO_HIGHEST_PRIO) == 0) { + int max = pj_thread_get_prio_max(pj_thread_this()); + if (max > 0) + pj_thread_set_prio(pj_thread_this(), max); + } + /* Get the first tick */ pj_get_timestamp(&clock->next_tick); clock->next_tick.u64 += clock->interval.u64; diff --git a/pjmedia/src/pjmedia/master_port.c b/pjmedia/src/pjmedia/master_port.c index 85099a48..34d0661e 100644 --- a/pjmedia/src/pjmedia/master_port.c +++ b/pjmedia/src/pjmedia/master_port.c @@ -102,8 +102,8 @@ PJ_DEF(pj_status_t) pjmedia_master_port_create( pj_pool_t *pool, return status; /* Create media clock */ - status = pjmedia_clock_create(pool, clock_rate, samples_per_frame, 0, - &clock_callback, m, &m->clock); + status = pjmedia_clock_create(pool, clock_rate, samples_per_frame, + options, &clock_callback, m, &m->clock); if (status != PJ_SUCCESS) { pj_lock_destroy(m->lock); return status; |