Commit b95426f5 authored by Warren Dukes's avatar Warren Dukes

some minor changes, still doesn't quite work

git-svn-id: https://svn.musicpd.org/mpd/trunk@2922 09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent 4422fae2
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "../pcm_utils.h" #include "../pcm_utils.h"
#include "../inputStream.h" #include "../inputStream.h"
#include "../outputBuffer.h" #include "../outputBuffer.h"
#include "../replayGain.h"
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
...@@ -44,7 +45,7 @@ mpc_int32_t mpc_read_cb(void * vdata, void * ptr, mpc_int32_t size) { ...@@ -44,7 +45,7 @@ mpc_int32_t mpc_read_cb(void * vdata, void * ptr, mpc_int32_t size) {
MpcCallbackData * data = (MpcCallbackData *)vdata; MpcCallbackData * data = (MpcCallbackData *)vdata;
while(1) { while(1) {
ret = readFromInputStream(data->inStream, ptr, size, 1); ret = readFromInputStream(data->inStream, ptr, 1, size);
if(ret == 0 && !inputStreamAtEOF(data->inStream) && if(ret == 0 && !inputStreamAtEOF(data->inStream) &&
!data->dc->stop) !data->dc->stop)
{ {
...@@ -131,6 +132,7 @@ int mpc_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream) ...@@ -131,6 +132,7 @@ int mpc_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
mpc_uint32_t vbrUpdateBits; mpc_uint32_t vbrUpdateBits;
float time; float time;
int i; int i;
ReplayGainInfo * replayGainInfo;
data.inStream = inStream; data.inStream = inStream;
data.dc = dc; data.dc = dc;
...@@ -142,12 +144,17 @@ int mpc_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream) ...@@ -142,12 +144,17 @@ int mpc_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
reader.canseek = mpc_canseek_cb; reader.canseek = mpc_canseek_cb;
reader.data = &data; reader.data = &data;
DEBUG("HERE 1\n");
mpc_streaminfo_init(&info); mpc_streaminfo_init(&info);
if(mpc_streaminfo_read(&info, &reader) != ERROR_CODE_OK) { DEBUG("HERE 2\n");
if((ret = mpc_streaminfo_read(&info, &reader)) != ERROR_CODE_OK) {
closeInputStream(inStream); closeInputStream(inStream);
if(!dc->stop) { if(!dc->stop) {
ERROR("Not a valid musepack stream"); ERROR("Not a valid musepack stream");
DEBUG("ret: %i\n", ret);
return -1;
} }
else { else {
dc->state = DECODE_STATE_STOP; dc->state = DECODE_STATE_STOP;
...@@ -156,7 +163,9 @@ int mpc_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream) ...@@ -156,7 +163,9 @@ int mpc_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
return 0; return 0;
} }
DEBUG("HERE 3\n");
mpc_decoder_setup(&decoder, &reader); mpc_decoder_setup(&decoder, &reader);
DEBUG("HERE 4\n");
if(!mpc_decoder_initialize(&decoder, &info)) { if(!mpc_decoder_initialize(&decoder, &info)) {
closeInputStream(inStream); closeInputStream(inStream);
if(!dc->stop) { if(!dc->stop) {
...@@ -168,11 +177,16 @@ int mpc_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream) ...@@ -168,11 +177,16 @@ int mpc_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
} }
} }
DEBUG("HERE 5\n");
dc->totalTime = mpc_streaminfo_get_length(&info); dc->totalTime = mpc_streaminfo_get_length(&info);
dc->audioFormat.bits = 16; dc->audioFormat.bits = 16;
dc->audioFormat.channels = 16;
dc->audioFormat.sampleRate = info.sample_freq; dc->audioFormat.sampleRate = info.sample_freq;
replayGainInfo = newReplayGainInfo();
DEBUG("HERE 6\n");
while(!eof) { while(!eof) {
if(dc->seek) { if(dc->seek) {
samplePos = dc->seekWhere * dc->audioFormat.sampleRate; samplePos = dc->seekWhere * dc->audioFormat.sampleRate;
...@@ -215,7 +229,7 @@ int mpc_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream) ...@@ -215,7 +229,7 @@ int mpc_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
chunk, chunkpos, chunk, chunkpos,
time, time,
bitRate, bitRate,
NULL); replayGainInfo);
chunkpos = 0; chunkpos = 0;
s16 = (mpd_sint16 *)chunk; s16 = (mpd_sint16 *)chunk;
if(dc->stop) break; if(dc->stop) break;
...@@ -223,6 +237,7 @@ int mpc_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream) ...@@ -223,6 +237,7 @@ int mpc_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
} }
} }
DEBUG("HERE 7\n");
if(!dc->stop && chunkpos > 0) { if(!dc->stop && chunkpos > 0) {
time = ((float)samplePos) / dc->audioFormat.sampleRate; time = ((float)samplePos) / dc->audioFormat.sampleRate;
...@@ -230,13 +245,18 @@ int mpc_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream) ...@@ -230,13 +245,18 @@ int mpc_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
chunkpos; chunkpos;
sendDataToOutputBuffer(cb, NULL, dc, inStream->seekable, sendDataToOutputBuffer(cb, NULL, dc, inStream->seekable,
chunk, chunkpos, time, bitRate, NULL); chunk, chunkpos, time, bitRate,
replayGainInfo);
} }
DEBUG("HERE 8\n");
closeInputStream(inStream); closeInputStream(inStream);
DEBUG("HERE 9\n");
flushOutputBuffer(cb); flushOutputBuffer(cb);
freeReplayGainInfo(replayGainInfo);
if(dc->stop) { if(dc->stop) {
dc->state = DECODE_STATE_STOP; dc->state = DECODE_STATE_STOP;
dc->stop = 0; dc->stop = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment