mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 01:30:38 +00:00
opusenc: port to the new GLib thread API
This commit is contained in:
parent
79f59ea3d2
commit
2816380e7c
2 changed files with 18 additions and 18 deletions
|
@ -287,7 +287,7 @@ gst_opus_enc_finalize (GObject * object)
|
||||||
|
|
||||||
enc = GST_OPUS_ENC (object);
|
enc = GST_OPUS_ENC (object);
|
||||||
|
|
||||||
g_mutex_free (enc->property_lock);
|
g_mutex_clear (&enc->property_lock);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@ -299,7 +299,7 @@ gst_opus_enc_init (GstOpusEnc * enc)
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (enc, "init");
|
GST_DEBUG_OBJECT (enc, "init");
|
||||||
|
|
||||||
enc->property_lock = g_mutex_new ();
|
g_mutex_init (&enc->property_lock);
|
||||||
|
|
||||||
enc->n_channels = -1;
|
enc->n_channels = -1;
|
||||||
enc->sample_rate = -1;
|
enc->sample_rate = -1;
|
||||||
|
@ -608,7 +608,7 @@ gst_opus_enc_set_format (GstAudioEncoder * benc, GstAudioInfo * info)
|
||||||
|
|
||||||
enc = GST_OPUS_ENC (benc);
|
enc = GST_OPUS_ENC (benc);
|
||||||
|
|
||||||
g_mutex_lock (enc->property_lock);
|
g_mutex_lock (&enc->property_lock);
|
||||||
|
|
||||||
enc->n_channels = GST_AUDIO_INFO_CHANNELS (info);
|
enc->n_channels = GST_AUDIO_INFO_CHANNELS (info);
|
||||||
enc->sample_rate = GST_AUDIO_INFO_RATE (info);
|
enc->sample_rate = GST_AUDIO_INFO_RATE (info);
|
||||||
|
@ -622,7 +622,7 @@ gst_opus_enc_set_format (GstAudioEncoder * benc, GstAudioInfo * info)
|
||||||
enc->state = NULL;
|
enc->state = NULL;
|
||||||
}
|
}
|
||||||
if (!gst_opus_enc_setup (enc)) {
|
if (!gst_opus_enc_setup (enc)) {
|
||||||
g_mutex_unlock (enc->property_lock);
|
g_mutex_unlock (&enc->property_lock);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -631,7 +631,7 @@ gst_opus_enc_set_format (GstAudioEncoder * benc, GstAudioInfo * info)
|
||||||
/* feedback to base class */
|
/* feedback to base class */
|
||||||
gst_opus_enc_setup_base_class (enc, benc);
|
gst_opus_enc_setup_base_class (enc, benc);
|
||||||
|
|
||||||
g_mutex_unlock (enc->property_lock);
|
g_mutex_unlock (&enc->property_lock);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -793,7 +793,7 @@ gst_opus_enc_encode (GstOpusEnc * enc, GstBuffer * buf)
|
||||||
gint outsize;
|
gint outsize;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
|
|
||||||
g_mutex_lock (enc->property_lock);
|
g_mutex_lock (&enc->property_lock);
|
||||||
|
|
||||||
if (G_LIKELY (buf)) {
|
if (G_LIKELY (buf)) {
|
||||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
|
@ -859,7 +859,7 @@ done:
|
||||||
|
|
||||||
if (bdata)
|
if (bdata)
|
||||||
gst_buffer_unmap (buf, &map);
|
gst_buffer_unmap (buf, &map);
|
||||||
g_mutex_unlock (enc->property_lock);
|
g_mutex_unlock (&enc->property_lock);
|
||||||
|
|
||||||
if (mdata)
|
if (mdata)
|
||||||
g_free (mdata);
|
g_free (mdata);
|
||||||
|
@ -914,7 +914,7 @@ gst_opus_enc_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
|
|
||||||
enc = GST_OPUS_ENC (object);
|
enc = GST_OPUS_ENC (object);
|
||||||
|
|
||||||
g_mutex_lock (enc->property_lock);
|
g_mutex_lock (&enc->property_lock);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_AUDIO:
|
case PROP_AUDIO:
|
||||||
|
@ -955,7 +955,7 @@ gst_opus_enc_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_mutex_unlock (enc->property_lock);
|
g_mutex_unlock (&enc->property_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -967,12 +967,12 @@ gst_opus_enc_set_property (GObject * object, guint prop_id,
|
||||||
enc = GST_OPUS_ENC (object);
|
enc = GST_OPUS_ENC (object);
|
||||||
|
|
||||||
#define GST_OPUS_UPDATE_PROPERTY(prop,type,ctl) do { \
|
#define GST_OPUS_UPDATE_PROPERTY(prop,type,ctl) do { \
|
||||||
g_mutex_lock (enc->property_lock); \
|
g_mutex_lock (&enc->property_lock); \
|
||||||
enc->prop = g_value_get_##type (value); \
|
enc->prop = g_value_get_##type (value); \
|
||||||
if (enc->state) { \
|
if (enc->state) { \
|
||||||
opus_multistream_encoder_ctl (enc->state, OPUS_SET_##ctl (enc->prop)); \
|
opus_multistream_encoder_ctl (enc->state, OPUS_SET_##ctl (enc->prop)); \
|
||||||
} \
|
} \
|
||||||
g_mutex_unlock (enc->property_lock); \
|
g_mutex_unlock (&enc->property_lock); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
|
@ -986,18 +986,18 @@ gst_opus_enc_set_property (GObject * object, guint prop_id,
|
||||||
GST_OPUS_UPDATE_PROPERTY (bandwidth, enum, BANDWIDTH);
|
GST_OPUS_UPDATE_PROPERTY (bandwidth, enum, BANDWIDTH);
|
||||||
break;
|
break;
|
||||||
case PROP_FRAME_SIZE:
|
case PROP_FRAME_SIZE:
|
||||||
g_mutex_lock (enc->property_lock);
|
g_mutex_lock (&enc->property_lock);
|
||||||
enc->frame_size = g_value_get_enum (value);
|
enc->frame_size = g_value_get_enum (value);
|
||||||
enc->frame_samples = gst_opus_enc_get_frame_samples (enc);
|
enc->frame_samples = gst_opus_enc_get_frame_samples (enc);
|
||||||
gst_opus_enc_setup_base_class (enc, GST_AUDIO_ENCODER (enc));
|
gst_opus_enc_setup_base_class (enc, GST_AUDIO_ENCODER (enc));
|
||||||
g_mutex_unlock (enc->property_lock);
|
g_mutex_unlock (&enc->property_lock);
|
||||||
break;
|
break;
|
||||||
case PROP_CBR:
|
case PROP_CBR:
|
||||||
/* this one has an opposite meaning to the opus ctl... */
|
/* this one has an opposite meaning to the opus ctl... */
|
||||||
g_mutex_lock (enc->property_lock);
|
g_mutex_lock (&enc->property_lock);
|
||||||
enc->cbr = g_value_get_boolean (value);
|
enc->cbr = g_value_get_boolean (value);
|
||||||
opus_multistream_encoder_ctl (enc->state, OPUS_SET_VBR (!enc->cbr));
|
opus_multistream_encoder_ctl (enc->state, OPUS_SET_VBR (!enc->cbr));
|
||||||
g_mutex_unlock (enc->property_lock);
|
g_mutex_unlock (&enc->property_lock);
|
||||||
break;
|
break;
|
||||||
case PROP_CONSTRAINED_VBR:
|
case PROP_CONSTRAINED_VBR:
|
||||||
GST_OPUS_UPDATE_PROPERTY (constrained_vbr, boolean, VBR_CONSTRAINT);
|
GST_OPUS_UPDATE_PROPERTY (constrained_vbr, boolean, VBR_CONSTRAINT);
|
||||||
|
@ -1015,9 +1015,9 @@ gst_opus_enc_set_property (GObject * object, guint prop_id,
|
||||||
GST_OPUS_UPDATE_PROPERTY (packet_loss_percentage, int, PACKET_LOSS_PERC);
|
GST_OPUS_UPDATE_PROPERTY (packet_loss_percentage, int, PACKET_LOSS_PERC);
|
||||||
break;
|
break;
|
||||||
case PROP_MAX_PAYLOAD_SIZE:
|
case PROP_MAX_PAYLOAD_SIZE:
|
||||||
g_mutex_lock (enc->property_lock);
|
g_mutex_lock (&enc->property_lock);
|
||||||
enc->max_payload_size = g_value_get_uint (value);
|
enc->max_payload_size = g_value_get_uint (value);
|
||||||
g_mutex_unlock (enc->property_lock);
|
g_mutex_unlock (&enc->property_lock);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
|
|
@ -54,7 +54,7 @@ struct _GstOpusEnc {
|
||||||
OpusMSEncoder *state;
|
OpusMSEncoder *state;
|
||||||
|
|
||||||
/* Locks those properties which may be changed at play time */
|
/* Locks those properties which may be changed at play time */
|
||||||
GMutex *property_lock;
|
GMutex property_lock;
|
||||||
|
|
||||||
/* properties */
|
/* properties */
|
||||||
gboolean audio_or_voip;
|
gboolean audio_or_voip;
|
||||||
|
|
Loading…
Reference in a new issue