mirror of https://github.com/nealey/hdjd.git
steel support
This commit is contained in:
parent
96957e8305
commit
dcaa85e4bb
6
Makefile
6
Makefile
|
@ -6,4 +6,8 @@ hdjd: LDFLAGS += $(shell pkg-config --libs libusb-1.0)
|
|||
|
||||
aac123: CFLAGS += $(shell pkg-config --cflags alsa)
|
||||
aac123: LDLIBS += $(shell pkg-config --libs alsa)
|
||||
aac123: LDLIBS += -lfaad -lmp4ff
|
||||
aac123: LDLIBS += -lfaad -lmp4v2
|
||||
|
||||
aactest: CFLAGS += $(shell pkg-config --cflags alsa)
|
||||
aactest: LDLIBS += $(shell pkg-config --libs alsa)
|
||||
aactest: LDLIBS += -lfaad -lmp4v2
|
||||
|
|
90
aac123.c
90
aac123.c
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <alsa/asoundlib.h>
|
||||
#include <neaacdec.h>
|
||||
#include <mp4ff.h>
|
||||
#include <mp4v2/mp4v2.h>
|
||||
|
||||
/* Some things I use for debugging */
|
||||
#ifdef NODUMP
|
||||
|
@ -19,40 +19,35 @@
|
|||
#define DUMP_p(v) DUMPf("%s = %p", #v, v)
|
||||
|
||||
|
||||
uint32_t
|
||||
read_callback(void *user_data, void *buffer, uint32_t length)
|
||||
{
|
||||
return fread(buffer, 1, length, (FILE*)user_data);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
seek_callback(void *user_data, uint64_t position)
|
||||
{
|
||||
return fseek((FILE*)user_data, position, SEEK_SET);
|
||||
}
|
||||
|
||||
static int
|
||||
GetAACTrack(mp4ff_t *infile)
|
||||
GetAACTrack(MP4FileHandle *infile)
|
||||
{
|
||||
/* find AAC track */
|
||||
int i, rc;
|
||||
int numTracks = mp4ff_total_tracks(infile);
|
||||
int rc;
|
||||
MP4TrackId numTracks = MP4GetNumberOfTracks(infile, NULL, 0);
|
||||
MP4TrackId i;
|
||||
|
||||
for (i = 0; i < numTracks; i++)
|
||||
for (i = 1; i <= numTracks; i++)
|
||||
{
|
||||
unsigned char *buff = NULL;
|
||||
int buff_size = 0;
|
||||
mp4AudioSpecificConfig mp4ASC;
|
||||
uint8_t obj_type;
|
||||
const char *track_type = MP4GetTrackType(infile, i);
|
||||
|
||||
mp4ff_get_decoder_config(infile, i, &buff, &buff_size);
|
||||
if (! track_type) continue;
|
||||
|
||||
if (buff)
|
||||
{
|
||||
rc = NeAACDecAudioSpecificConfig(buff, buff_size, &mp4ASC);
|
||||
free(buff);
|
||||
if (!MP4_IS_AUDIO_TRACK_TYPE(track_type)) continue;
|
||||
|
||||
if (rc < 0)
|
||||
/* MP4GetTrackAudioType */
|
||||
obj_type = MP4GetTrackEsdsObjectTypeId(infile, i);
|
||||
if (obj_type == MP4_INVALID_AUDIO_TYPE)
|
||||
continue;
|
||||
|
||||
if (obj_type == MP4_MPEG4_AUDIO_TYPE) {
|
||||
obj_type = MP4GetTrackAudioMpeg4Type(infile, i);
|
||||
|
||||
if (MP4_IS_MPEG4_AAC_AUDIO_TYPE(obj_type))
|
||||
return i;
|
||||
} else {
|
||||
if (MP4_IS_AAC_AUDIO_TYPE(obj_type))
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
@ -62,13 +57,12 @@ GetAACTrack(mp4ff_t *infile)
|
|||
}
|
||||
|
||||
int
|
||||
play_file(snd_pcm_t *snd, FILE *f)
|
||||
play_file(snd_pcm_t *snd, char *fn)
|
||||
{
|
||||
|
||||
int track;
|
||||
|
||||
mp4ff_t *infile;
|
||||
mp4ff_callback_t mp4cb;
|
||||
MP4FileHandle infile;
|
||||
|
||||
NeAACDecHandle hDecoder;
|
||||
NeAACDecConfigurationPtr config;
|
||||
|
@ -82,11 +76,7 @@ play_file(snd_pcm_t *snd, FILE *f)
|
|||
long sampleId, numSamples;
|
||||
void *sample_buffer;
|
||||
|
||||
mp4cb.read = read_callback;
|
||||
mp4cb.seek = seek_callback;
|
||||
mp4cb.user_data = f;
|
||||
|
||||
infile = mp4ff_open_read(&mp4cb);
|
||||
infile = MP4Read(fn);
|
||||
if (! infile) {
|
||||
fprintf(stderr, "Unable to open stream\n");
|
||||
return 1;
|
||||
|
@ -100,11 +90,13 @@ play_file(snd_pcm_t *snd, FILE *f)
|
|||
hDecoder = NeAACDecOpen();
|
||||
config = NeAACDecGetCurrentConfiguration(hDecoder);
|
||||
config->outputFormat = FAAD_FMT_16BIT;
|
||||
config->downMatrix = 1;
|
||||
config->defObjectType = LC;
|
||||
NeAACDecSetConfiguration(hDecoder, config);
|
||||
|
||||
buffer = NULL;
|
||||
buffer_size = 0;
|
||||
mp4ff_get_decoder_config(infile, track, &buffer, &buffer_size);
|
||||
MP4GetTrackESConfiguration(infile, track, &buffer, &buffer_size);
|
||||
|
||||
if (NeAACDecInit2(hDecoder, buffer, buffer_size, &samplerate, &channels) < 0) {
|
||||
fprintf(stderr, "Initializing decoder\n");
|
||||
|
@ -125,9 +117,12 @@ play_file(snd_pcm_t *snd, FILE *f)
|
|||
free(buffer);
|
||||
}
|
||||
|
||||
numSamples = mp4ff_num_samples(infile, track);
|
||||
DUMP_d(MP4GetTrackMaxSampleSize(infile, track));
|
||||
|
||||
for (sampleId = 0; sampleId < numSamples; sampleId++) {
|
||||
numSamples = MP4GetTrackNumberOfSamples(infile, track);
|
||||
|
||||
DUMP_d(numSamples);
|
||||
for (sampleId = 1; sampleId <= numSamples; sampleId++) {
|
||||
int rc;
|
||||
long dur;
|
||||
unsigned int sample_count;
|
||||
|
@ -137,8 +132,7 @@ play_file(snd_pcm_t *snd, FILE *f)
|
|||
buffer = NULL;
|
||||
buffer_size = 0;
|
||||
|
||||
dur = mp4ff_get_sample_duration(infile, track, sampleId);
|
||||
rc = mp4ff_read_sample(infile, track, sampleId, &buffer, &buffer_size);
|
||||
rc = MP4ReadSample(infile, track, sampleId, &buffer, &buffer_size, NULL, NULL, NULL, NULL);
|
||||
if (rc == 0) {
|
||||
fprintf(stderr, "Read failed\n");
|
||||
return 1;
|
||||
|
@ -164,28 +158,12 @@ main(int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (argc == 1) {
|
||||
return play_file(snd, stdin);
|
||||
}
|
||||
|
||||
for (i = 1; i < argc; i += 1) {
|
||||
char *fn = argv[i];
|
||||
FILE *f = fopen(fn, "r");
|
||||
|
||||
if ((fn[0] == '-') && (fn[1] == 0)) {
|
||||
f = stdin;
|
||||
fn = "[stdin]";
|
||||
}
|
||||
|
||||
if (! f) {
|
||||
fprintf(stderr, "Opening %s: %m\n", fn);
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("%s\n", fn);
|
||||
|
||||
play_file(snd, f);
|
||||
fclose(f);
|
||||
play_file(snd, fn);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
28
hdjd.c
28
hdjd.c
|
@ -17,6 +17,10 @@
|
|||
#define DUMP_c(v) DUMPf("%s = '%c' (0x%02x)", #v, v, v)
|
||||
#define DUMP_p(v) DUMPf("%s = %p", #v, v)
|
||||
|
||||
// Steel: 0xb102, 0x83, 0x03
|
||||
// MP3e2: 0x0b105, 0x82,
|
||||
// 4set: 0xb10c, 0x84, 0x02
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
|
@ -28,28 +32,18 @@ main(int argc, char **argv)
|
|||
return 69;
|
||||
}
|
||||
|
||||
handle = libusb_open_device_with_vid_pid(NULL, 0x06f8, 0xb105); // MP3e2
|
||||
handle = libusb_open_device_with_vid_pid(NULL, 0x06f8, 0xb102);
|
||||
if (!handle) {
|
||||
printf("Couldn't find an MP3e2\n");
|
||||
printf("Couldn't find a controller\n");
|
||||
return 69;
|
||||
}
|
||||
|
||||
/* Make Deck A cue button flash. */
|
||||
{
|
||||
int transferred;
|
||||
|
||||
uint8_t cmd[] = { 0x90, 0x3e, 0x7f };
|
||||
libusb_bulk_transfer(handle, 0x03, cmd, 3, &transferred, 0);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
uint8_t data[80];
|
||||
int transferred;
|
||||
int i;
|
||||
|
||||
if ((ret = libusb_bulk_transfer(handle, 0x82,
|
||||
data, sizeof data,
|
||||
&transferred, 0))) {
|
||||
if ((ret = libusb_bulk_transfer(handle, 0x83, data, sizeof data, &transferred, 0))) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -58,13 +52,11 @@ main(int argc, char **argv)
|
|||
}
|
||||
printf("\n");
|
||||
|
||||
/* Cram it right back out */
|
||||
|
||||
if ((ret = libusb_bulk_transfer(handle, 0x03,
|
||||
data, transferred,
|
||||
&transferred, 0))) {
|
||||
// Cram it back out, to turn that light on
|
||||
if ((ret = libusb_bulk_transfer(handle, 0x04, data, transferred, &transferred, 0))) {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
|
|
Loading…
Reference in New Issue