diff --git a/ao-play-async/ao_playasync.c b/ao-play-async/ao_playasync.c index 9e1b113..f751f4a 100644 --- a/ao-play-async/ao_playasync.c +++ b/ao-play-async/ao_playasync.c @@ -579,44 +579,6 @@ void ao_stop_async(void *ao_handle) fprintf(stderr, "async handle freed\n"); } -/* -(define (abs x) (if (>= x 0) x (* x -1))) - -(define (make-sample-bytes sample bytes-per-sample endianess) - (letrec ((mk (lambda (i d) - (if (< i bytes-per-sample) - (cons (bitwise-and d 255) - (mk (+ i 1) (arithmetic-shift d -8))) - '())))) - (let ((bytes (mk 0 sample))) - (if (eq? endianess 'big-endian) - (reverse bytes) - bytes)))) - - ;(get-sample (lambda (k channel) - ; (let ((chan-buf (list-ref buffer channel))) - ; (vector-ref chan-buf k)))) - ) - ;(letrec ((i 0) - ; (fill (lambda (k channel) - ; (if (< k buf-len) - ; (if (< channel channels) - ; (let* ((sample (get-sample k channel)) - ; (bytes (make-sample-bytes sample bytes-per-sample endianess)) - ; ) - ; (for-each (lambda (byte) - ; (ptr-set! audio _byte i byte) - ; (set! i (+ i 1))) - ; bytes) - ; ;; process sample - ; (fill k (+ channel 1))) - ; (fill (+ k 1) 0)) - ; 'filled)) - ; )) - ; (fill 0 0) - -*/ - #define AO_FMT_LITTLE 1 #define AO_FMT_BIG 2 #define AO_FMT_NATIVE 4 @@ -640,87 +602,18 @@ static inline void make_sample_bytes(int32_t sample, int bytes_per_sample, int b } } -void *convertFlac(void *mem, int buf_len, BufferInfo_t *info, int *audio_size) -{ - // buf_size equals number of samples of 32bit for all channels. So buf_size for flac = 4 * buf_len * channels - - int bytes = info->sample_bits / 8; - int endianess = info->endiannes; - - int little_endian = (endianess == AO_FMT_LITTLE); - if (!little_endian && endianess == AO_FMT_NATIVE) little_endian = littleEndian(); - int big_endian = !little_endian; - - int store_size = info->channels * bytes * buf_len; - unsigned char *new_mem = (unsigned char *) malloc(store_size); - *audio_size = store_size; - int32_t **buffer = (int32_t **) mem; - int i, k, channel; - - i = 0; - for(k = 0; k < buf_len; k++) { - for(channel = 0; channel < info->channels; channel++) { - int32_t *chan = buffer[channel]; - int32_t sample = chan[k]; - unsigned char b[4]; - make_sample_bytes(sample, bytes, big_endian, b); - for(int j = 0; j < bytes; j++) { - new_mem[i++] = b[j]; - } - } - } - - return (void *) new_mem; -} - void ao_play_async(void *ao_handle, int music_id, double at_second, double music_duration, int buf_size, void *mem, BufferInfo_t info) { AO_Handle *h = (AO_Handle *) ao_handle; Queue_t *q = NULL; - switch(info.type) { - case flac: { - int store_size = 0; - void *store_mem = convertFlac(mem, buf_size, &info, &store_size); + int ao_size = 0; + void *ao_mem = convert_req_to_real(ao_handle, mem, buf_size, &info, &ao_size); - int ao_size = 0; - void *ao_mem = convert_req_to_real(ao_handle, store_mem, store_size, &info, &ao_size); + q = new_elem(PLAY, music_id, at_second, music_duration, ao_size, ao_mem); - q = new_elem(PLAY, music_id, at_second, music_duration, ao_size, ao_mem); - - free(store_mem); - free(ao_mem); - } - break; - case ao: { - int ao_size = 0; - void *ao_mem = convert_req_to_real(ao_handle, mem, buf_size, &info, &ao_size); - - q = new_elem(PLAY, music_id, at_second, music_duration, ao_size, ao_mem); - - free(ao_mem); - } - break; - case mpg123: { - static int warned = 0; - if (!warned) { - warned = 1; - fprintf(stderr, "format mpg123 not supported yet\n"); - } - return; - } - break; - case ao_ogg: { - static int warned = 0; - if (!warned) { - warned = 1; - fprintf(stderr, "format ao_ogg not supported yet\n"); - } - return; - } - break; - } + free(ao_mem); add(h, q); } diff --git a/ao-play-async/ao_playasync.h b/ao-play-async/ao_playasync.h index 08c79d5..c2aaf59 100644 --- a/ao-play-async/ao_playasync.h +++ b/ao-play-async/ao_playasync.h @@ -11,7 +11,7 @@ #define AOPLAYASYNC_EXPORT extern #endif -#define VERSION 2 +#define VERSION 3 typedef enum { ao = 1, diff --git a/lib/linux-x86_64.zip b/lib/linux-x86_64.zip index e5cfd36..4662daf 100644 Binary files a/lib/linux-x86_64.zip and b/lib/linux-x86_64.zip differ