Fix up audio formats as well

This commit is contained in:
Wim Taymans 2016-08-26 19:22:50 +02:00
parent b67c216a04
commit a973007a49
12 changed files with 82 additions and 58 deletions

View file

@ -83,8 +83,8 @@ struct _SpaALSASink {
void *user_data;
bool have_format;
SpaAudioRawFormat query_format;
SpaAudioRawFormat current_format;
SpaFormatAudio query_format;
SpaFormatAudio current_format;
SpaALSAState state;
@ -351,10 +351,14 @@ spa_alsa_sink_node_port_enum_formats (SpaNode *node,
switch (index) {
case 0:
spa_audio_raw_format_init (&this->query_format);
spa_format_audio_init (SPA_MEDIA_TYPE_AUDIO,
SPA_MEDIA_SUBTYPE_RAW,
&this->query_format);
break;
case 1:
spa_audio_raw_format_init (&this->query_format);
spa_format_audio_init (SPA_MEDIA_TYPE_AUDIO,
SPA_MEDIA_SUBTYPE_AAC,
&this->query_format);
break;
default:
return SPA_RESULT_ENUM_END;
@ -387,7 +391,7 @@ spa_alsa_sink_node_port_set_format (SpaNode *node,
return SPA_RESULT_OK;
}
if ((res = spa_audio_raw_format_parse (format, &this->current_format)) < 0)
if ((res = spa_format_audio_parse (format, &this->current_format)) < 0)
return res;
if (alsa_set_format (this, &this->current_format, false) < 0)

View file

@ -105,7 +105,7 @@ spa_alsa_format_to_alsa (SpaAudioFormat format)
}
static int
alsa_set_format (SpaALSASink *this, SpaAudioRawFormat *fmt, bool try_only)
alsa_set_format (SpaALSASink *this, SpaFormatAudio *fmt, bool try_only)
{
unsigned int rrate;
snd_pcm_uframes_t size;
@ -113,7 +113,7 @@ alsa_set_format (SpaALSASink *this, SpaAudioRawFormat *fmt, bool try_only)
snd_pcm_hw_params_t *params;
snd_pcm_format_t format;
SpaALSAState *state = &this->state;
SpaAudioRawInfo *info = &fmt->info;
SpaAudioInfoRaw *info = &fmt->info.raw;
snd_pcm_t *handle;
unsigned int buffer_time;
unsigned int period_time;

View file

@ -49,7 +49,7 @@ struct _MixerBuffer {
typedef struct {
bool valid;
bool have_format;
SpaAudioRawFormat format[2];
SpaFormatAudio format[2];
SpaAudioMixerPortProps props[2];
SpaPortInfo info;
SpaPortStatus status;
@ -338,7 +338,9 @@ spa_audiomixer_node_port_enum_formats (SpaNode *node,
switch (index) {
case 0:
spa_audio_raw_format_init (&port->format[0]);
spa_format_audio_init (SPA_MEDIA_TYPE_AUDIO,
SPA_MEDIA_SUBTYPE_RAW,
&port->format[0]);
break;
default:
return SPA_RESULT_ENUM_END;
@ -374,7 +376,7 @@ spa_audiomixer_node_port_set_format (SpaNode *node,
return SPA_RESULT_OK;
}
if ((res = spa_audio_raw_format_parse (format, &port->format[1])) < 0)
if ((res = spa_format_audio_parse (format, &port->format[1])) < 0)
return res;
port->have_format = true;

View file

@ -45,8 +45,8 @@ struct _SpaAudioTestSrc {
SpaPortStatus status;
bool have_format;
SpaAudioRawFormat query_format;
SpaAudioRawFormat current_format;
SpaFormatAudio query_format;
SpaFormatAudio current_format;
};
static const uint32_t default_wave = 1.0;
@ -298,7 +298,9 @@ spa_audiotestsrc_node_port_enum_formats (SpaNode *node,
switch (index) {
case 0:
spa_audio_raw_format_init (&this->query_format);
spa_format_audio_init (SPA_MEDIA_TYPE_AUDIO,
SPA_MEDIA_SUBTYPE_RAW,
&this->query_format);
break;
default:
return SPA_RESULT_ENUM_END;
@ -331,7 +333,7 @@ spa_audiotestsrc_node_port_set_format (SpaNode *node,
return SPA_RESULT_OK;
}
if ((res = spa_audio_raw_format_parse (format, &this->current_format)) < 0)
if ((res = spa_format_audio_parse (format, &this->current_format)) < 0)
return res;
this->have_format = true;

View file

@ -477,8 +477,11 @@ spa_v4l2_set_format (SpaV4l2Source *this, V4l2Format *f, bool try_only)
f->fmt.media_subtype,
f->format,
0);
if (info == NULL)
if (info == NULL) {
fprintf (stderr, "unknown media type %d %d %d\n", f->fmt.media_type,
f->fmt.media_subtype, f->format);
return -1;
}
fmt.fmt.pix.pixelformat = info->fourcc;
fmt.fmt.pix.field = V4L2_FIELD_ANY;

View file

@ -51,8 +51,8 @@ struct _SpaVolume {
void *user_data;
bool have_format;
SpaAudioRawFormat query_format;
SpaAudioRawFormat current_format;
SpaFormatAudio query_format;
SpaFormatAudio current_format;
SpaVolumePort ports[2];
};
@ -285,7 +285,9 @@ spa_volume_node_port_enum_formats (SpaNode *node,
switch (index) {
case 0:
spa_audio_raw_format_init (&this->query_format);
spa_format_audio_init (SPA_MEDIA_TYPE_AUDIO,
SPA_MEDIA_SUBTYPE_RAW,
&this->query_format);
break;
default:
return SPA_RESULT_ENUM_END;
@ -321,7 +323,7 @@ spa_volume_node_port_set_format (SpaNode *node,
return SPA_RESULT_OK;
}
if ((res = spa_audio_raw_format_parse (format, &this->current_format)) < 0)
if ((res = spa_format_audio_parse (format, &this->current_format)) < 0)
return res;
port->have_format = true;