Compare commits
6 Commits
0-1-3
..
51a0138877
| Author | SHA1 | Date | |
|---|---|---|---|
| 51a0138877 | |||
| 4134cf0549 | |||
| 9a0ef7d76e | |||
| 2606634c11 | |||
| ca9e1878d8 | |||
| 15fb5a8499 |
@@ -10,6 +10,8 @@ all:
|
|||||||
|
|
||||||
install: all
|
install: all
|
||||||
mkdir -p lib/$(SUBDIR)
|
mkdir -p lib/$(SUBDIR)
|
||||||
|
@echo "copying from src/$(SUBDIR) to lib/$(SUBDIR)"
|
||||||
|
(cd src/$(SUBDIR);tar cf - . ) | (cd lib/$(SUBDIR); tar xvf - )
|
||||||
FILES=`ls build/*.so build-ffmpeg/*.so` 2>/dev/null; if [ "$$FILES" != "" ]; then cp $$FILES lib/$(SUBDIR); fi
|
FILES=`ls build/*.so build-ffmpeg/*.so` 2>/dev/null; if [ "$$FILES" != "" ]; then cp $$FILES lib/$(SUBDIR); fi
|
||||||
FILES=`ls build/*.dll build-ffmpeg/*.dll` 2>/dev/null; if [ "$$FILES" != "" ]; then cp $$FILES lib/$(SUBDIR); fi
|
FILES=`ls build/*.dll build-ffmpeg/*.dll` 2>/dev/null; if [ "$$FILES" != "" ]; then cp $$FILES lib/$(SUBDIR); fi
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ project(ao-play-async LANGUAGES C)
|
|||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||||
|
|
||||||
add_library(ao-play-async SHARED
|
add_library(ao-play-async SHARED
|
||||||
ao_playasync.c
|
ao_playasync.c
|
||||||
ao_playasync.h
|
ao_playasync.h
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "ao_playasync.h"
|
#include "ao_playasync.h"
|
||||||
|
#include "../ffi_version.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@@ -326,7 +327,7 @@ static DWORD run(LPVOID arg)
|
|||||||
|
|
||||||
int ao_async_version()
|
int ao_async_version()
|
||||||
{
|
{
|
||||||
return VERSION;
|
return ffi_version();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@@ -579,44 +580,6 @@ void ao_stop_async(void *ao_handle)
|
|||||||
fprintf(stderr, "async handle freed\n");
|
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_LITTLE 1
|
||||||
#define AO_FMT_BIG 2
|
#define AO_FMT_BIG 2
|
||||||
#define AO_FMT_NATIVE 4
|
#define AO_FMT_NATIVE 4
|
||||||
@@ -640,87 +603,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)
|
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;
|
AO_Handle *h = (AO_Handle *) ao_handle;
|
||||||
|
|
||||||
Queue_t *q = NULL;
|
Queue_t *q = NULL;
|
||||||
|
|
||||||
switch(info.type) {
|
int ao_size = 0;
|
||||||
case flac: {
|
void *ao_mem = convert_req_to_real(ao_handle, mem, buf_size, &info, &ao_size);
|
||||||
int store_size = 0;
|
|
||||||
void *store_mem = convertFlac(mem, buf_size, &info, &store_size);
|
|
||||||
|
|
||||||
int ao_size = 0;
|
q = new_elem(PLAY, music_id, at_second, music_duration, ao_size, ao_mem);
|
||||||
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);
|
free(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;
|
|
||||||
}
|
|
||||||
|
|
||||||
add(h, q);
|
add(h, q);
|
||||||
}
|
}
|
||||||
@@ -809,9 +703,6 @@ void ao_pause_async(void *ao_handle, int paused)
|
|||||||
MUTEX_UNLOCK(h->mutex);
|
MUTEX_UNLOCK(h->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int ao_real_output_bits_async(void *handle)
|
int ao_real_output_bits_async(void *handle)
|
||||||
{
|
{
|
||||||
AO_Handle *h = (AO_Handle *) handle;
|
AO_Handle *h = (AO_Handle *) handle;
|
||||||
|
|||||||
@@ -11,7 +11,9 @@
|
|||||||
#define AOPLAYASYNC_EXPORT extern
|
#define AOPLAYASYNC_EXPORT extern
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define VERSION 2
|
#define VERSION_MAJOR 1
|
||||||
|
#define VERSION_MINOR 0
|
||||||
|
#define VERSION_PATCH 0
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ao = 1,
|
ao = 1,
|
||||||
@@ -46,4 +48,5 @@ AOPLAYASYNC_EXPORT double ao_volume_async(void *ao_handle);
|
|||||||
AOPLAYASYNC_EXPORT int ao_bufsize_async(void *handle);
|
AOPLAYASYNC_EXPORT int ao_bufsize_async(void *handle);
|
||||||
AOPLAYASYNC_EXPORT int ao_real_output_bits_async(void *handle);
|
AOPLAYASYNC_EXPORT int ao_real_output_bits_async(void *handle);
|
||||||
|
|
||||||
|
|
||||||
#endif // AO_PLAYASYNC_H
|
#endif // AO_PLAYASYNC_H
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#ifndef __FFI_VERSION__
|
||||||
|
#define __FFI_VERSION__
|
||||||
|
|
||||||
|
#define VERSION_MAJOR 1
|
||||||
|
#define VERSION_MINOR 0
|
||||||
|
#define VERSION_PATCH 0
|
||||||
|
|
||||||
|
#define ffi_version() ((VERSION_MAJOR << 16) + (VERSION_MINOR << 8) + VERSION_PATCH)
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -8,6 +8,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|||||||
add_library(ffmpeg_audio SHARED
|
add_library(ffmpeg_audio SHARED
|
||||||
ffmpeg_audio.cpp
|
ffmpeg_audio.cpp
|
||||||
ffmpeg_audio.h
|
ffmpeg_audio.h
|
||||||
|
../ffi_version.h
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(demo_ffmpeg_audio
|
add_executable(demo_ffmpeg_audio
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ffmpeg_audio.h"
|
#include "ffmpeg_audio.h"
|
||||||
|
#include "../ffi_version.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@@ -1021,3 +1022,8 @@ const char *fmpg_int_version2string(int ver)
|
|||||||
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int fmpg_version()
|
||||||
|
{
|
||||||
|
return ffi_version();
|
||||||
|
}
|
||||||
|
|||||||
@@ -150,6 +150,7 @@ FFMPEG_EXTERN int64_t fmpg_sample_position(fmpg_instance *instance);
|
|||||||
/* Approximate start time of the current decoded block in seconds. */
|
/* Approximate start time of the current decoded block in seconds. */
|
||||||
FFMPEG_EXTERN double fmpg_timecode(fmpg_instance *instance);
|
FFMPEG_EXTERN double fmpg_timecode(fmpg_instance *instance);
|
||||||
|
|
||||||
|
FFMPEG_EXTERN int fmpg_version();
|
||||||
FFMPEG_EXTERN const char *fmpg_ffmpeg_version();
|
FFMPEG_EXTERN const char *fmpg_ffmpeg_version();
|
||||||
FFMPEG_EXTERN const char *fmpg_int_version2string(int ver);
|
FFMPEG_EXTERN const char *fmpg_int_version2string(int ver);
|
||||||
FFMPEG_EXTERN int fmpg_compatible_ffmpeg();
|
FFMPEG_EXTERN int fmpg_compatible_ffmpeg();
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Symlink
+1
@@ -0,0 +1 @@
|
|||||||
|
libtag.so.2
|
||||||
Symlink
+1
@@ -0,0 +1 @@
|
|||||||
|
libtag.so.2.2.1
|
||||||
Binary file not shown.
Symlink
+1
@@ -0,0 +1 @@
|
|||||||
|
libtag_c.so.2
|
||||||
Symlink
+1
@@ -0,0 +1 @@
|
|||||||
|
libtag_c.so.2.2.1
|
||||||
Binary file not shown.
Reference in New Issue
Block a user