Skip to content

Commit

Permalink
Support 384kHz sample rates
Browse files Browse the repository at this point in the history
Fixes cmus#1298.
  • Loading branch information
gavtroy authored and flyingmutant committed Mar 24, 2024
1 parent 3bbb756 commit f97d936
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ip.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <unistd.h>
#endif

#define IP_ABI_VERSION 1
#define IP_ABI_VERSION 2

enum {
/* no error */
Expand Down
2 changes: 1 addition & 1 deletion op.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <fcntl.h>
#endif

#define OP_ABI_VERSION 2
#define OP_ABI_VERSION 3

enum {
/* no error */
Expand Down
3 changes: 1 addition & 2 deletions output.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ void op_load_plugins(void)
error_msg("%s: missing symbol", filename);
err = true;
}
STATIC_ASSERT(OP_ABI_VERSION == 2);
if (!plug->abi_version_ptr || (*plug->abi_version_ptr != 1 && *plug->abi_version_ptr != 2)) {
if (!plug->abi_version_ptr || *plug->abi_version_ptr != OP_ABI_VERSION) {
error_msg("%s: incompatible plugin version", filename);
err = true;
}
Expand Down
17 changes: 8 additions & 9 deletions sf.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,33 @@
/*
* 0 1 big_endian 0-1
* 1 1 is_signed 0-1
* 2 1 unused 0
* 3-5 3 bits >> 3 0-7 (* 8 = 0-56)
* 6-23 18 rate 0-262143
* 2-20 19 rate 0-524286
* 21-23 3 bits >> 3 0-7 (* 8 = 0-56)
* 24-31 8 channels 0-255
*/
typedef unsigned int sample_format_t;

#define SF_BIGENDIAN_MASK 0x00000001
#define SF_SIGNED_MASK 0x00000002
#define SF_BITS_MASK 0x00000038
#define SF_RATE_MASK 0x00ffffc0
#define SF_RATE_MASK 0x001ffffc
#define SF_BITS_MASK 0x00e00000
#define SF_CHANNELS_MASK 0xff000000

#define SF_BIGENDIAN_SHIFT 0
#define SF_SIGNED_SHIFT 1
#define SF_BITS_SHIFT 0
#define SF_RATE_SHIFT 6
#define SF_RATE_SHIFT 2
#define SF_BITS_SHIFT (21-3)
#define SF_CHANNELS_SHIFT 24

#define sf_get_bigendian(sf) (((sf) & SF_BIGENDIAN_MASK) >> SF_BIGENDIAN_SHIFT)
#define sf_get_signed(sf) (((sf) & SF_SIGNED_MASK ) >> SF_SIGNED_SHIFT)
#define sf_get_bits(sf) (((sf) & SF_BITS_MASK ) >> SF_BITS_SHIFT)
#define sf_get_rate(sf) (((sf) & SF_RATE_MASK ) >> SF_RATE_SHIFT)
#define sf_get_bits(sf) (((sf) & SF_BITS_MASK ) >> SF_BITS_SHIFT)
#define sf_get_channels(sf) (((sf) & SF_CHANNELS_MASK ) >> SF_CHANNELS_SHIFT)

#define sf_signed(val) (((val) << SF_SIGNED_SHIFT ) & SF_SIGNED_MASK)
#define sf_bits(val) (((val) << SF_BITS_SHIFT ) & SF_BITS_MASK)
#define sf_rate(val) (((val) << SF_RATE_SHIFT ) & SF_RATE_MASK)
#define sf_bits(val) (((val) << SF_BITS_SHIFT ) & SF_BITS_MASK)
#define sf_channels(val) (((val) << SF_CHANNELS_SHIFT ) & SF_CHANNELS_MASK)
#define sf_bigendian(val) (((val) << SF_BIGENDIAN_SHIFT) & SF_BIGENDIAN_MASK)
#ifdef WORDS_BIGENDIAN
Expand Down

0 comments on commit f97d936

Please sign in to comment.