From 575757905dcb6df69327223ef2bb24d089627c32 Mon Sep 17 00:00:00 2001 From: waker Date: Tue, 23 Nov 2010 21:12:50 +0100 Subject: ported VTX plugin to new API; added option to use 8 or 16 bit decoder --- plugins/vtx/vtx.c | 42 ++++++++++++++++++++++++++---------------- scripts/configure_minimal.sh | 2 +- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/plugins/vtx/vtx.c b/plugins/vtx/vtx.c index 2267f706..8a718170 100644 --- a/plugins/vtx/vtx.c +++ b/plugins/vtx/vtx.c @@ -47,7 +47,7 @@ typedef struct { } vtx_info_t; static DB_fileinfo_t * -vtx_open (void) { +vtx_open (uint32_t hints) { DB_fileinfo_t *_info = malloc (sizeof (vtx_info_t)); memset (_info, 0, sizeof (vtx_info_t)); return _info; @@ -102,16 +102,21 @@ vtx_init (DB_fileinfo_t *_info, DB_playItem_t *it) { int samplerate = deadbeef->conf_get_int ("synth.samplerate", 44100); - ayemu_set_sound_format (&info->ay, samplerate, deadbeef->get_output ()->channels (), deadbeef->get_output ()->bitspersample ()); - info->left = 0; - info->rate = deadbeef->get_output ()->channels () * deadbeef->get_output ()->bitspersample () / 8; info->vtx_pos = 0; _info->plugin = &plugin; - _info->bps = deadbeef->get_output ()->bitspersample (); - _info->channels = deadbeef->get_output ()->channels (); - _info->samplerate = samplerate; + _info->fmt.bps = deadbeef->conf_get_int ("vtx.bps", 16);; + if (_info->fmt.bps != 16 && _info->fmt.bps != 8) { + _info->fmt.bps = 16; + } + _info->fmt.channels = 2; + _info->fmt.samplerate = samplerate; + _info->fmt.channelmask = _info->fmt.channels == 1 ? DDB_SPEAKER_FRONT_LEFT : (DDB_SPEAKER_FRONT_LEFT | DDB_SPEAKER_FRONT_RIGHT); _info->readpos = 0; + + ayemu_set_sound_format (&info->ay, samplerate, _info->fmt.channels, _info->fmt.bps); + + info->rate = _info->fmt.channels * _info->fmt.bps / 8; return 0; } @@ -149,7 +154,7 @@ ayemu_vtx_get_next_frame (vtx_info_t *info) } static int -vtx_read_int16 (DB_fileinfo_t *_info, char *bytes, int size) { +vtx_read (DB_fileinfo_t *_info, char *bytes, int size) { // try decode `size' bytes // return number of decoded bytes // return 0 on EOF @@ -170,7 +175,7 @@ vtx_read_int16 (DB_fileinfo_t *_info, char *bytes, int size) { } else { // number of samples it current frame - info->left = _info->samplerate / info->decoder->playerFreq; + info->left = _info->fmt.samplerate / info->decoder->playerFreq; // mul by rate to get number of bytes; info->left *= info->rate; ayemu_set_regs (&info->ay, info->regs); @@ -179,7 +184,7 @@ vtx_read_int16 (DB_fileinfo_t *_info, char *bytes, int size) { } } info->currentsample += (initsize - size) / 4; - _info->readpos = (float)info->currentsample / _info->samplerate; + _info->readpos = (float)info->currentsample / _info->fmt.samplerate; return initsize - size; } @@ -192,7 +197,7 @@ vtx_seek_sample (DB_fileinfo_t *_info, int sample) { // get frame int num_frames = info->decoder->regdata_size / AY_FRAME_SIZE; - int samples_per_frame = _info->samplerate / info->decoder->playerFreq; + int samples_per_frame = _info->fmt.samplerate / info->decoder->playerFreq; // start of frame info->vtx_pos = sample / samples_per_frame; @@ -206,11 +211,11 @@ vtx_seek_sample (DB_fileinfo_t *_info, int sample) { info->regs[n] = *p; } // set number of bytes left in frame - info->left = _info->samplerate / info->decoder->playerFreq - (sample % samples_per_frame); + info->left = _info->fmt.samplerate / info->decoder->playerFreq - (sample % samples_per_frame); // mul by rate to get number of bytes info->left *= info->rate; info->currentsample = sample; - _info->readpos = (float)info->currentsample / _info->samplerate; + _info->readpos = (float)info->currentsample / _info->fmt.samplerate; return 0; } @@ -220,7 +225,7 @@ vtx_seek (DB_fileinfo_t *_info, float time) { // seek to specified time in seconds // return 0 on success // return -1 on failure - return vtx_seek_sample (_info, time * _info->samplerate); + return vtx_seek_sample (_info, time * _info->fmt.samplerate); } static DB_playItem_t * @@ -290,6 +295,11 @@ vtx_stop (void) { // return -1 on failure return 0; } + +static const char settings_dlg[] = + "property \"Bits Per Sample (8 or 16)\" entry vtx.bps 16;\n" +; + // define plugin interface static DB_decoder_t plugin = { DB_PLUGIN_SET_API_VERSION @@ -304,11 +314,11 @@ static DB_decoder_t plugin = { .plugin.website = "http://deadbeef.sf.net", .plugin.start = vtx_start, .plugin.stop = vtx_stop, + .plugin.configdialog = settings_dlg, .open = vtx_open, .init = vtx_init, .free = vtx_free, - .read_int16 = vtx_read_int16, -// .read_float32 = vtx_read_float32, + .read = vtx_read, .seek = vtx_seek, .seek_sample = vtx_seek_sample, .insert = vtx_insert, diff --git a/scripts/configure_minimal.sh b/scripts/configure_minimal.sh index 49f289e9..6cc13a64 100755 --- a/scripts/configure_minimal.sh +++ b/scripts/configure_minimal.sh @@ -1 +1 @@ -./configure --enable-maintainer-mode --disable-nullout --disable-oss --disable-ffap --disable-vtx --disable-adplug --disable-vorbis --disable-ffmpeg --disable-flac --disable-sndfile --disable-cdda --disable-musepack --disable-wildmidi --disable-tta --disable-dca --disable-aac --disable-mms --disable-shn --disable-ao --disable-supereq --disable-artwork --disable-lfm --disable-vfs-curl --disable-hotkeys --disable-notify --disable-shellexec +./configure --enable-maintainer-mode --disable-nullout --disable-oss --disable-ffap --disable-adplug --disable-vorbis --disable-ffmpeg --disable-flac --disable-sndfile --disable-cdda --disable-musepack --disable-wildmidi --disable-tta --disable-dca --disable-aac --disable-mms --disable-shn --disable-ao --disable-supereq --disable-artwork --disable-lfm --disable-vfs-curl --disable-hotkeys --disable-notify --disable-shellexec -- cgit v1.2.3