aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputPlugins/oggflac_plugin.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-08-20 01:31:51 -0700
committerEric Wong <normalperson@yhbt.net>2008-08-20 01:31:51 -0700
commit1b197e65232e1a51b853db53985e8eda61f1b196 (patch)
tree2d85ff67ba79e32256a20d2d2bee7222352007fd /src/inputPlugins/oggflac_plugin.c
parent5a0216af3dc7c9dedc4dacb708191f0fd380bb73 (diff)
parent508ae1c18d3bdc99a1bb06181762e5ec859cf072 (diff)
downloadmpd-1b197e65232e1a51b853db53985e8eda61f1b196.tar.gz
mpd-1b197e65232e1a51b853db53985e8eda61f1b196.tar.xz
mpd-1b197e65232e1a51b853db53985e8eda61f1b196.zip
Merge branch 'core-rewrite' of git://git.musicpd.org/normalperson/mpd
* 'core-rewrite' of git://git.musicpd.org/normalperson/mpd: Remove ob_wait_sync and cleanup triggering in playlist fix output buffer deadlock when daemonizing log.c: thread-safety for warning log core rewrite (decode,player,outputBuffer,playlist)
Diffstat (limited to 'src/inputPlugins/oggflac_plugin.c')
-rw-r--r--src/inputPlugins/oggflac_plugin.c55
1 files changed, 27 insertions, 28 deletions
diff --git a/src/inputPlugins/oggflac_plugin.c b/src/inputPlugins/oggflac_plugin.c
index 379ff6466..6c5998afe 100644
--- a/src/inputPlugins/oggflac_plugin.c
+++ b/src/inputPlugins/oggflac_plugin.c
@@ -55,15 +55,14 @@ static OggFLAC__SeekableStreamDecoderReadStatus of_read_cb(const
while (1) {
r = readFromInputStream(data->inStream, (void *)buf, 1, *bytes);
- if (r == 0 && !inputStreamAtEOF(data->inStream) &&
- !dc.stop)
- my_usleep(10000);
+ if (r == 0 && !inputStreamAtEOF(data->inStream) && !dc_intr())
+ my_usleep(10000); /* FIXME */
else
break;
}
*bytes = r;
- if (r == 0 && !inputStreamAtEOF(data->inStream) && !dc.stop)
+ if (r == 0 && !inputStreamAtEOF(data->inStream) && !dc_intr())
return OggFLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR;
return OggFLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK;
@@ -193,16 +192,17 @@ static FLAC__StreamDecoderWriteStatus oggflacWrite(const
c_chan++) {
u16 = buf[c_chan][c_samp];
uc = (unsigned char *)&u16;
- for (i = 0; i < (dc.audioFormat.bits / 8); i++) {
+ for (i = 0; i < (dc.audio_format.bits / 8); i++) {
if (data->chunk_length >= FLAC_CHUNK_SIZE) {
- if (flacSendChunk(data) < 0) {
- return
- FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
- }
- data->chunk_length = 0;
- if (dc.seek) {
- return
- FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
+ /* FIXME: line wrapping */
+ switch (flacSendChunk(data)) {
+ case DC_ACTION_STOP:
+ return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
+ case DC_ACTION_SEEK:
+ return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
+ default:
+ /* compilers are complainers */
+ break;
}
}
data->chunk[data->chunk_length++] = *(uc++);
@@ -349,40 +349,39 @@ static int oggflac_decode(InputStream * inStream)
goto fail;
}
- dc.state = DECODE_STATE_DECODE;
-
while (1) {
OggFLAC__seekable_stream_decoder_process_single(decoder);
if (OggFLAC__seekable_stream_decoder_get_state(decoder) !=
OggFLAC__SEEKABLE_STREAM_DECODER_OK) {
break;
}
- if (dc.seek) {
- FLAC__uint64 sampleToSeek = dc.seekWhere *
- dc.audioFormat.sampleRate + 0.5;
+ if (dc_seek()) {
+ FLAC__uint64 sampleToSeek;
+ dc_action_begin();
+ assert(dc.action == DC_ACTION_SEEK);
+ sampleToSeek = dc.seek_where *
+ dc.audio_format.sampleRate + 0.5;
if (OggFLAC__seekable_stream_decoder_seek_absolute
(decoder, sampleToSeek)) {
- ob_clear();
data.time = ((float)sampleToSeek) /
- dc.audioFormat.sampleRate;
+ dc.audio_format.sampleRate;
data.position = 0;
- } else
- dc.seekError = 1;
- dc.seek = 0;
- decoder_wakeup_player();
+ data.chunk_length = 0;
+ } else {
+ dc.seek_where = DC_SEEK_ERROR;
+ }
+ dc_action_end();
}
}
- if (!dc.stop) {
+ if (!dc_intr()) {
oggflacPrintErroredState
(OggFLAC__seekable_stream_decoder_get_state(decoder));
OggFLAC__seekable_stream_decoder_finish(decoder);
}
/* send last little bit */
- if (data.chunk_length > 0 && !dc.stop) {
+ if (data.chunk_length > 0 && !dc_intr())
flacSendChunk(&data);
- ob_flush();
- }
fail:
oggflac_cleanup(&data, decoder);