summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-07-20 20:42:03 +0200
committerwm4 <wm4@nowhere>2014-07-20 20:42:03 +0200
commit9736f3309acf387e42aef847f594463e3351bbc2 (patch)
treeff3feecdb9dbbec909ed18c681e8a3047277a6d6 /audio
parente982b5b287d1a178bea444c6d0f81a877db2d0c9 (diff)
downloadmpv-9736f3309acf387e42aef847f594463e3351bbc2.tar.bz2
mpv-9736f3309acf387e42aef847f594463e3351bbc2.tar.xz
audio: use symbolic constants instead of magic integers
Similar to commit 26468743.
Diffstat (limited to 'audio')
-rw-r--r--audio/decode/ad_lavc.c2
-rw-r--r--audio/decode/ad_mpg123.c7
-rw-r--r--audio/decode/ad_spdif.c4
-rw-r--r--audio/decode/dec_audio.c10
-rw-r--r--audio/decode/dec_audio.h7
5 files changed, 18 insertions, 12 deletions
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c
index 404cf19560..ad00e65be6 100644
--- a/audio/decode/ad_lavc.c
+++ b/audio/decode/ad_lavc.c
@@ -398,7 +398,7 @@ static int decode_audio(struct dec_audio *da, struct mp_audio *buffer, int maxle
if (!priv->frame.samples) {
if (decode_new_packet(da) < 0)
- return -1;
+ return AD_ERR;
}
if (!mp_audio_config_equals(buffer, &priv->frame))
diff --git a/audio/decode/ad_mpg123.c b/audio/decode/ad_mpg123.c
index ec4dc04485..055285cccd 100644
--- a/audio/decode/ad_mpg123.c
+++ b/audio/decode/ad_mpg123.c
@@ -309,7 +309,7 @@ static int decode_audio(struct dec_audio *da, struct mp_audio *buffer, int maxle
if (con->need_data) {
if (feed_new_packet(da) < 0)
- return -1;
+ return AD_ERR;
}
if (!mp_audio_config_equals(&da->decoded, buffer))
@@ -338,9 +338,8 @@ static int decode_audio(struct dec_audio *da, struct mp_audio *buffer, int maxle
return 0;
mpg123_fail:
- MP_ERR(da, "mpg123 decoding error: %s\n",
- mpg123_strerror(con->handle));
- return -1;
+ MP_ERR(da, "mpg123 decoding error: %s\n", mpg123_strerror(con->handle));
+ return AD_ERR;
}
static int control(struct dec_audio *da, int cmd, void *arg)
diff --git a/audio/decode/ad_spdif.c b/audio/decode/ad_spdif.c
index c055715a32..1042fdeb48 100644
--- a/audio/decode/ad_spdif.c
+++ b/audio/decode/ad_spdif.c
@@ -200,7 +200,7 @@ static int decode_audio(struct dec_audio *da, struct mp_audio *buffer, int maxle
struct demux_packet *mpkt = demux_read_packet(da->header);
if (!mpkt)
- return -1;
+ return AD_ERR;
AVPacket pkt;
mp_set_av_packet(&pkt, mpkt, NULL);
@@ -216,7 +216,7 @@ static int decode_audio(struct dec_audio *da, struct mp_audio *buffer, int maxle
da->pts_offset += buffer->samples;
talloc_free(mpkt);
if (ret < 0)
- return -1;
+ return AD_ERR;
return 0;
}
diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c
index b8d83e899c..b8e14dfbf3 100644
--- a/audio/decode/dec_audio.c
+++ b/audio/decode/dec_audio.c
@@ -260,7 +260,7 @@ static int filter_n_bytes(struct dec_audio *da, struct mp_audio_buffer *outbuf,
// first, and don't signal a format change to the caller yet.
if (mp_audio_buffer_samples(da->decode_buffer) > 0)
break;
- error = -2;
+ error = AD_NEW_FMT;
break;
}
}
@@ -274,7 +274,7 @@ static int filter_n_bytes(struct dec_audio *da, struct mp_audio_buffer *outbuf,
bool eof = filter_data.samples == 0 && error < 0;
if (af_filter(da->afilter, &filter_data, eof ? AF_FILTER_FLAG_EOF : 0) < 0)
- return -1;
+ return AD_ERR;
mp_audio_buffer_append(outbuf, &filter_data);
if (eof && filter_data.samples > 0)
@@ -285,9 +285,9 @@ static int filter_n_bytes(struct dec_audio *da, struct mp_audio_buffer *outbuf,
// Assume the filter chain is drained from old data at this point.
// (If not, the remaining old data is discarded.)
- if (error == -2) {
+ if (error == AD_NEW_FMT) {
if (!reinit_audio_buffer(da))
- error = -1; // switch to invalid format
+ error = AD_ERR; // switch to invalid format
}
return error;
@@ -295,7 +295,7 @@ static int filter_n_bytes(struct dec_audio *da, struct mp_audio_buffer *outbuf,
/* Try to get at least minsamples decoded+filtered samples in outbuf
* (total length including possible existing data).
- * Return 0 on success, -1 on error/EOF (not distinguidaed).
+ * Return 0 on success, or negative AD_* error code.
* In the former case outbuf has at least minsamples buffered on return.
* In case of EOF/error it might or might not be. */
int audio_decode(struct dec_audio *d_audio, struct mp_audio_buffer *outbuf,
diff --git a/audio/decode/dec_audio.h b/audio/decode/dec_audio.h
index 9108f6f035..27c2040947 100644
--- a/audio/decode/dec_audio.h
+++ b/audio/decode/dec_audio.h
@@ -51,6 +51,13 @@ struct dec_audio {
void *priv;
};
+enum {
+ AD_OK = 0,
+ AD_ERR = -1,
+ AD_NEW_FMT = -2,
+ AD_ASYNC_PLAY_DONE = -3,
+};
+
struct mp_decoder_list *audio_decoder_list(void);
int audio_init_best_codec(struct dec_audio *d_audio, char *audio_decoders);
int audio_decode(struct dec_audio *d_audio, struct mp_audio_buffer *outbuf,