summaryrefslogtreecommitdiff
path: root/plugins/vtx
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2010-11-23 21:12:50 +0100
committerGravatar waker <wakeroid@gmail.com>2010-11-23 21:12:50 +0100
commit575757905dcb6df69327223ef2bb24d089627c32 (patch)
tree2ccc72887b889e84daca7e71e7f24b0c737311d4 /plugins/vtx
parent5898772de0ba58b4e1e28c0d86d7f3f780e12f29 (diff)
ported VTX plugin to new API;
added option to use 8 or 16 bit decoder
Diffstat (limited to 'plugins/vtx')
-rw-r--r--plugins/vtx/vtx.c42
1 files changed, 26 insertions, 16 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,