summaryrefslogtreecommitdiffstats
path: root/mpvcore
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-23 21:25:05 +0100
committerwm4 <wm4@nowhere>2013-11-23 21:25:05 +0100
commite174d31fdda78374600878699ef911fd09f55a26 (patch)
tree63cd9b7023e1a198dbbea097887a16a793f2f9b5 /mpvcore
parent0f5ec05d8f4ae02262dc79a895bce3b465b376f2 (diff)
downloadmpv-e174d31fdda78374600878699ef911fd09f55a26.tar.bz2
mpv-e174d31fdda78374600878699ef911fd09f55a26.tar.xz
audio: don't write decoded audio format to sh_audio
sh_audio is supposed to contain file headers, not whatever was decoded. Fix this, and write the decoded format to separate fields in the decoder context, the dec_audio.decoded field. (Note that this field is really only needed to communicate the audio format from decoder driver to the generic code, so no other code accesses it.)
Diffstat (limited to 'mpvcore')
-rw-r--r--mpvcore/player/command.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/mpvcore/player/command.c b/mpvcore/player/command.c
index dc190adfc6..cdeb11c713 100644
--- a/mpvcore/player/command.c
+++ b/mpvcore/player/command.c
@@ -48,6 +48,7 @@
#include "video/out/vo.h"
#include "video/csputils.h"
#include "audio/mixer.h"
+#include "audio/audio_buffer.h"
#include "audio/out/ao.h"
#include "audio/filter/af.h"
#include "video/decode/dec_video.h"
@@ -868,15 +869,17 @@ static int mp_property_audio_bitrate(m_option_t *prop, int action,
static int mp_property_samplerate(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
{
- if (!mpctx->d_audio)
+ struct mp_audio fmt = {0};
+ if (mpctx->d_audio)
+ mp_audio_buffer_get_format(mpctx->d_audio->decode_buffer, &fmt);
+ if (!fmt.rate)
return M_PROPERTY_UNAVAILABLE;
switch (action) {
case M_PROPERTY_PRINT:
- *(char **)arg = talloc_asprintf(NULL, "%d kHz",
- mpctx->d_audio->header->audio->samplerate / 1000);
+ *(char **)arg = talloc_asprintf(NULL, "%d kHz", fmt.rate / 1000);
return M_PROPERTY_OK;
case M_PROPERTY_GET:
- *(int *)arg = mpctx->d_audio->header->audio->samplerate;
+ *(int *)arg = fmt.rate;
return M_PROPERTY_OK;
}
return M_PROPERTY_NOT_IMPLEMENTED;
@@ -886,14 +889,17 @@ static int mp_property_samplerate(m_option_t *prop, int action, void *arg,
static int mp_property_channels(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
{
- if (!mpctx->d_audio)
+ struct mp_audio fmt = {0};
+ if (mpctx->d_audio)
+ mp_audio_buffer_get_format(mpctx->d_audio->decode_buffer, &fmt);
+ if (!fmt.channels.num)
return M_PROPERTY_UNAVAILABLE;
switch (action) {
case M_PROPERTY_PRINT:
- *(char **) arg = mp_chmap_to_str(&mpctx->d_audio->header->audio->channels);
+ *(char **) arg = mp_chmap_to_str(&fmt.channels);
return M_PROPERTY_OK;
case M_PROPERTY_GET:
- *(int *)arg = mpctx->d_audio->header->audio->channels.num;
+ *(int *)arg = fmt.channels.num;
return M_PROPERTY_OK;
}
return M_PROPERTY_NOT_IMPLEMENTED;