diff --git a/lib/linux-x86_64/libao-play-async.so b/lib/linux-x86_64/libao-play-async.so index f50f3ea..126ce84 100755 Binary files a/lib/linux-x86_64/libao-play-async.so and b/lib/linux-x86_64/libao-play-async.so differ diff --git a/libao/c/ao-play-async/ao_playasync.c b/libao/c/ao-play-async/ao_playasync.c index 54f2815..a3c8966 100644 --- a/libao/c/ao-play-async/ao_playasync.c +++ b/libao/c/ao-play-async/ao_playasync.c @@ -43,6 +43,7 @@ typedef struct _queue_ { void *buf; int buflen; double at_second; + double music_duration; struct _queue_ *next; struct _queue_ *prev; } Queue_t; @@ -63,6 +64,7 @@ typedef struct { pthread_t thread; #endif double at_second; + double music_duration; ao_play_func_t ao_play_f; int buf_size; } AO_Handle; @@ -106,7 +108,7 @@ static void add(AO_Handle *h, Queue_t *elem) h->buf_size += elem->buflen; } -static Queue_t *new_elem(int command, double at_second, int buf_len, void *buf) +static Queue_t *new_elem(int command, double at_second, double music_duration, int buf_len, void *buf) { Queue_t *q = (Queue_t *) malloc(sizeof(Queue_t)); void *new_buf; @@ -118,6 +120,7 @@ static Queue_t *new_elem(int command, double at_second, int buf_len, void *buf) new_buf = NULL; } q->at_second = at_second; + q->music_duration = music_duration; q->buf = new_buf; q->buflen = buf_len; q->command = command; @@ -220,7 +223,7 @@ void ao_stop_async(void *ao_handle) MUTEX_LOCK(h->mutex); clear(h); - Queue_t *q = new_elem(STOP, 0.0, 0, NULL); + Queue_t *q = new_elem(STOP, 0.0, 0.0, 0, NULL); add(h, q); MUTEX_UNLOCK(h->mutex); @@ -236,10 +239,10 @@ void ao_stop_async(void *ao_handle) free(h); } -void ao_play_async(void *ao_handle, double at_second, int buf_size, void *mem) +void ao_play_async(void *ao_handle, double at_second, double music_duration, int buf_size, void *mem) { AO_Handle *h = (AO_Handle *) ao_handle; - Queue_t *q = new_elem(PLAY, at_second, buf_size, mem); + Queue_t *q = new_elem(PLAY, at_second, music_duration, buf_size, mem); MUTEX_LOCK(h->mutex); add(h, q); MUTEX_UNLOCK(h->mutex); @@ -262,6 +265,16 @@ double ao_is_at_second_async(void *ao_handle) return s; } + +double ao_music_duration_async(void *ao_handle) +{ + AO_Handle *h = (AO_Handle *) ao_handle; + MUTEX_LOCK(h->mutex); + double duration = h->at_second; + MUTEX_UNLOCK(h->mutex); + return duration; +} + int ao_bufsize_async(void *ao_handle) { AO_Handle *h = (AO_Handle *) ao_handle; diff --git a/libao/c/ao-play-async/ao_playasync.h b/libao/c/ao-play-async/ao_playasync.h index 696bfa1..287f7d0 100644 --- a/libao/c/ao-play-async/ao_playasync.h +++ b/libao/c/ao-play-async/ao_playasync.h @@ -13,9 +13,12 @@ AOPLAYASYNC_EXPORT void *ao_create_async(void *ao_handle, void *ao_play_f); AOPLAYASYNC_EXPORT void ao_stop_async(void *handle); -AOPLAYASYNC_EXPORT void ao_play_async(void *handle, double at_second, int buf_size, void *mem); +AOPLAYASYNC_EXPORT void ao_play_async(void *handle, double at_second, double music_duration, int buf_size, void *mem); AOPLAYASYNC_EXPORT void ao_clear_async(void *handle); + AOPLAYASYNC_EXPORT double ao_is_at_second_async(void *handle); +AOPLAYASYNC_EXPORT double ao_music_duration_async(void *handle); + AOPLAYASYNC_EXPORT int ao_bufsize_async(void *handle); #endif // AO_PLAYASYNC_H diff --git a/libao/libao-async-ffi.rkt b/libao/libao-async-ffi.rkt index 3882956..a0ca304 100644 --- a/libao/libao-async-ffi.rkt +++ b/libao/libao-async-ffi.rkt @@ -32,6 +32,8 @@ ;extern double ao_is_at_second_async(void *handle); (define-libao-async ao_is_at_second_async(_fun _libao-async-handle-pointer -> _double)) + + ;extern int ao_bufsize_async(void *handle); (define-libao-async ao_bufsize_async(_fun _libao-async-handle-pointer -> _int))