From 849922592a1ae3c3088f362f48a45a8da3f03cbb Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Sat, 14 Jun 2008 20:33:44 +0000 Subject: Added pjmedia_tonegen_rewind() git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2022 74dad513-b988-da41-8d7b-12977e46ad98 --- pjmedia/include/pjmedia/tonegen.h | 11 +++++++++++ pjmedia/src/pjmedia/tonegen.c | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) (limited to 'pjmedia') diff --git a/pjmedia/include/pjmedia/tonegen.h b/pjmedia/include/pjmedia/tonegen.h index dadc036d..ab591732 100644 --- a/pjmedia/include/pjmedia/tonegen.h +++ b/pjmedia/include/pjmedia/tonegen.h @@ -194,6 +194,17 @@ PJ_DECL(pj_bool_t) pjmedia_tonegen_is_busy(pjmedia_port *tonegen); PJ_DECL(pj_status_t) pjmedia_tonegen_stop(pjmedia_port *tonegen); +/** + * Rewind the playback. This will start the playback to the first + * tone in the playback list. + * + * @param tonegen The tone generator instance. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_tonegen_rewind(pjmedia_port *tonegen); + + /** * Instruct the tone generator to play single or dual frequency tones * with the specified duration. The new tones will be appended to currently diff --git a/pjmedia/src/pjmedia/tonegen.c b/pjmedia/src/pjmedia/tonegen.c index 68d6634b..9333ab23 100644 --- a/pjmedia/src/pjmedia/tonegen.c +++ b/pjmedia/src/pjmedia/tonegen.c @@ -400,6 +400,26 @@ PJ_DEF(pj_status_t) pjmedia_tonegen_stop(pjmedia_port *port) } +/* + * Instruct the tone generator to stop current processing. + */ +PJ_DEF(pj_status_t) pjmedia_tonegen_rewind(pjmedia_port *port) +{ + struct tonegen *tonegen = (struct tonegen*) port; + PJ_ASSERT_RETURN(port->info.signature == SIGNATURE, PJ_EINVAL); + + TRACE_((THIS_FILE, "tonegen_rewind()")); + + /* Reset back to the first tone */ + pj_lock_acquire(tonegen->lock); + tonegen->cur_digit = 0; + tonegen->dig_samples = 0; + pj_lock_release(tonegen->lock); + + return PJ_SUCCESS; +} + + /* * Callback to destroy tonegen */ -- cgit v1.2.3