Commit dfc2fbd3 authored by Simon Morlat's avatar Simon Morlat
Browse files

change ms_new calls to ms_new0, as a good practice to avoid facing unitialized...

change ms_new calls to ms_new0, as a good practice to avoid facing unitialized values in the future.
parent 26ff7a20
......@@ -27,7 +27,7 @@ typedef struct _AlawEncData{
} AlawEncData;
static AlawEncData * alaw_enc_data_new(){
AlawEncData *obj=(AlawEncData *)ms_new(AlawEncData,1);
AlawEncData *obj=(AlawEncData *)ms_new0(AlawEncData,1);
obj->bz=ms_bufferizer_new();
obj->ptime=0;
obj->ts=0;
......
......@@ -766,7 +766,7 @@ struct _AlsaReadData{
typedef struct _AlsaReadData AlsaReadData;
void alsa_read_init(MSFilter *obj){
AlsaReadData *ad=ms_new(AlsaReadData,1);
AlsaReadData *ad=ms_new0(AlsaReadData,1);
ad->pcmdev=NULL;
ad->handle=NULL;
ad->rate=forced_rate!=-1 ? forced_rate : 8000;
......@@ -1025,7 +1025,7 @@ static MSFilter * ms_alsa_read_new(const char *dev){
typedef struct _AlsaReadData AlsaWriteData;
void alsa_write_init(MSFilter *obj){
AlsaWriteData *ad=ms_new(AlsaWriteData,1);
AlsaWriteData *ad=ms_new0(AlsaWriteData,1);
ad->pcmdev=NULL;
ad->handle=NULL;
ad->rate=forced_rate!=-1 ? forced_rate : 8000;
......
......@@ -30,7 +30,7 @@ typedef struct AdapterState{
}AdapterState;
static void adapter_init(MSFilter *f){
AdapterState *s=ms_new(AdapterState,1);
AdapterState *s=ms_new0(AdapterState,1);
s->inputchans=1;
s->outputchans=1;
f->data=s;
......
......@@ -182,7 +182,7 @@ static SoundDeviceDescription *lookup_by_platform(const char *platform) {
}
void ms_sound_device_description_add(const char *manufacturer, const char *model, const char *platform, unsigned int flags, int delay, int recommended_rate) {
SoundDeviceDescription *new_sound_device_description = ms_new(SoundDeviceDescription, 1);
SoundDeviceDescription *new_sound_device_description = ms_new0(SoundDeviceDescription, 1);
new_sound_device_description->manufacturer = ms_strdup(manufacturer);
new_sound_device_description->model = ms_strdup(model);
new_sound_device_description->platform = ms_strdup(platform);
......
......@@ -72,7 +72,7 @@ static void equalizer_rate_update( EqualizerState* s, int rate ){
equalizer_state_flatten(s);
s->fir_len=s->nfft;
if (s->fir != NULL) ms_free(s->fir);
s->fir=(ms_word16_t*)ms_new(ms_word16_t,s->fir_len);
s->fir=(ms_word16_t*)ms_new0(ms_word16_t,s->fir_len);
if (s->mem != NULL) ms_free(s->mem);
s->mem=(ms_mem_t*)ms_new0(ms_mem_t,s->fir_len);
s->needs_update=TRUE;
......
......@@ -31,7 +31,7 @@ struct EncState {
static void enc_init(MSFilter *f)
{
struct EncState *s=(struct EncState*)ms_new(struct EncState,1);
struct EncState *s=ms_new0(struct EncState,1);
s->ts=0;
s->bufferizer=ms_bufferizer_new();
s->ptime = 10;
......
......@@ -36,7 +36,7 @@ typedef struct RecState{
} RecState;
static void rec_init(MSFilter *f){
RecState *s=ms_new(RecState,1);
RecState *s=ms_new0(RecState,1);
s->fd=-1;
s->rate=8000;
s->nchannels = 1;
......
......@@ -41,7 +41,7 @@ struct EncState {
static void enc_init(MSFilter *f)
{
struct EncState *s=(struct EncState*)ms_new(struct EncState,1);
struct EncState *s=ms_new0(struct EncState,1);
s->state = g722_encode_init(NULL, 64000, 0);
s->ts=0;
s->bufferizer=ms_bufferizer_new();
......@@ -184,7 +184,7 @@ struct DecState {
};
static void dec_init(MSFilter *f){
struct DecState *s=(struct DecState*)ms_new(struct DecState,1);
struct DecState *s=ms_new0(struct DecState,1);
f->data=s;
s->state = g722_decode_init(NULL, 64000, 0);
......
......@@ -42,7 +42,7 @@ typedef struct _ResampleData{
} ResampleData;
static ResampleData * resample_data_new(){
ResampleData *obj=(ResampleData *)ms_new(ResampleData,1);
ResampleData *obj=ms_new0(ResampleData,1);
obj->bz=ms_bufferizer_new();
obj->ts=0;
obj->input_rate=8000;
......
......@@ -46,9 +46,9 @@ typedef struct SpeexEncState{
} SpeexEncState;
static void enc_init(MSFilter *f){
SpeexEncState *s=(SpeexEncState *)ms_new(SpeexEncState,1);
SpeexEncState *s=ms_new0(SpeexEncState,1);
#ifdef SPEEX_LIB_SET_CPU_FEATURES
int cpuFeatures = 0;
int cpuFeatures = 0;
#endif
s->rate=8000;
s->bitrate=-1;
......@@ -66,19 +66,19 @@ static void enc_init(MSFilter *f){
#ifdef SPEEX_LIB_SET_CPU_FEATURES
#ifdef __ARM_NEON__
#ifdef ANDROID
if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM
&& (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0) {
cpuFeatures = SPEEX_LIB_CPU_FEATURE_NEON;
}
#else
cpuFeatures = SPEEX_LIB_CPU_FEATURE_NEON;
#endif
#ifdef ANDROID
if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM
&& (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0) {
cpuFeatures = SPEEX_LIB_CPU_FEATURE_NEON;
}
#else
cpuFeatures = SPEEX_LIB_CPU_FEATURE_NEON;
#endif
#endif
ms_message("speex_lib_ctl init with neon ? %d", (cpuFeatures == SPEEX_LIB_CPU_FEATURE_NEON));
speex_lib_ctl(SPEEX_LIB_SET_CPU_FEATURES, &cpuFeatures);
ms_message("speex_lib_ctl init with neon ? %d", (cpuFeatures == SPEEX_LIB_CPU_FEATURE_NEON));
speex_lib_ctl(SPEEX_LIB_SET_CPU_FEATURES, &cpuFeatures);
#else
ms_message("speex_lib_ctl does not support SPEEX_LIB_CPU_FEATURE_NEON");
ms_message("speex_lib_ctl does not support SPEEX_LIB_CPU_FEATURE_NEON");
#endif
}
......@@ -481,7 +481,7 @@ typedef struct DecState{
} DecState;
static void dec_init(MSFilter *f){
DecState *s=(DecState *)ms_new(DecState,1);
DecState *s=ms_new0(DecState,1);
s->rate=8000;
s->frsz=0;
s->state=NULL;
......@@ -494,9 +494,7 @@ static void dec_init(MSFilter *f){
static void dec_uninit(MSFilter *f){
DecState *s=(DecState*)f->data;
if (s==NULL)
return;
if (s->state!=NULL)
if (s->state!=NULL)
speex_decoder_destroy(s->state);
ms_free(s);
}
......
......@@ -253,7 +253,7 @@ static void oss_set_source(MSSndCard *card, MSSndCardCapture source)
}
static void oss_init(MSSndCard *card){
OssData *d=ms_new(OssData,1);
OssData *d=ms_new0(OssData,1);
d->pcmdev=NULL;
d->mixdev=NULL;
d->pcmfd_read=-1;
......
......@@ -78,7 +78,7 @@ typedef struct SpeexECState{
}SpeexECState;
static void speex_ec_init(MSFilter *f){
SpeexECState *s=(SpeexECState *)ms_new(SpeexECState,1);
SpeexECState *s=ms_new0(SpeexECState,1);
s->samplerate=8000;
ms_bufferizer_init(&s->delayed_ref);
......
......@@ -28,7 +28,7 @@ typedef struct _UlawEncData{
} UlawEncData;
static UlawEncData * ulaw_enc_data_new(){
UlawEncData *obj=(UlawEncData *)ms_new(UlawEncData,1);
UlawEncData *obj=(UlawEncData *)ms_new0(UlawEncData,1);
obj->bz=ms_bufferizer_new();
obj->ptime=0;
obj->ts=0;
......
......@@ -62,8 +62,7 @@ void ms_set_cpu_count(unsigned int c) {
}
MSList *ms_list_new(void *data){
MSList *new_elem=(MSList *)ms_new(MSList,1);
new_elem->prev=new_elem->next=NULL;
MSList *new_elem=(MSList *)ms_new0(MSList,1);
new_elem->data=data;
return new_elem;
}
......@@ -402,7 +401,7 @@ unsigned long ms_concealer_context_get_total_number_of_plc(MSConcealerContext* o
}
MSConcealerContext* ms_concealer_context_new(unsigned int max_plc_time){
MSConcealerContext *obj=(MSConcealerContext *) ms_new(MSConcealerContext,1);
MSConcealerContext *obj=(MSConcealerContext *) ms_new0(MSConcealerContext,1);
obj->sample_time=-1;
obj->plc_start_time=-1;
obj->total_number_for_plc=0;
......@@ -463,7 +462,7 @@ unsigned long ms_concealer_ts_context_get_total_number_of_plc(MSConcealerTsConte
}
MSConcealerTsContext* ms_concealer_ts_context_new(unsigned int max_plc_ts){
MSConcealerTsContext *obj=(MSConcealerTsContext *) ms_new(MSConcealerTsContext,1);
MSConcealerTsContext *obj=(MSConcealerTsContext *) ms_new0(MSConcealerTsContext,1);
obj->sample_ts=-1;
obj->plc_start_ts=-1;
obj->total_number_for_plc=0;
......
......@@ -248,7 +248,7 @@ void ms_filter_postpone_task(MSFilter *f, MSFilterFunc taskfunc){
ms_error("ms_filter_postpone_task(): this method cannot be called outside of filter's process method.");
return;
}
task=ms_new(MSFilterTask,1);
task=ms_new0(MSFilterTask,1);
task->f=f;
task->taskfunc=taskfunc;
ticker->task_list=ms_list_prepend(ticker->task_list,task);
......
......@@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#endif
MSQueue * ms_queue_new(struct _MSFilter *f1, int pin1, struct _MSFilter *f2, int pin2 ){
MSQueue *q=(MSQueue*)ms_new(MSQueue,1);
MSQueue *q=(MSQueue*)ms_new0(MSQueue,1);
qinit(&q->q);
q->prev.filter=f1;
q->prev.pin=pin1;
......@@ -63,7 +63,7 @@ void ms_bufferizer_init(MSBufferizer *obj){
}
MSBufferizer * ms_bufferizer_new(){
MSBufferizer *obj=(MSBufferizer *)ms_new(MSBufferizer,1);
MSBufferizer *obj=(MSBufferizer *)ms_new0(MSBufferizer,1);
ms_bufferizer_init(obj);
return obj;
}
......
......@@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static MSSndCardManager *scm=NULL;
static MSSndCardManager * create_manager(){
MSSndCardManager *obj=(MSSndCardManager *)ms_new(MSSndCardManager,1);
MSSndCardManager *obj=(MSSndCardManager *)ms_new0(MSSndCardManager,1);
obj->cards=NULL;
obj->descs=NULL;
return obj;
......
......@@ -574,7 +574,7 @@ static uint64_t get_wallclock_ms(void){
static const double clock_coef = .01;
MSTickerSynchronizer* ms_ticker_synchronizer_new(void) {
MSTickerSynchronizer *obj=(MSTickerSynchronizer *)ms_new(MSTickerSynchronizer,1);
MSTickerSynchronizer *obj=(MSTickerSynchronizer *)ms_new0(MSTickerSynchronizer,1);
obj->av_skew = 0;
obj->offset = 0;
return obj;
......
......@@ -27,9 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static MSWebCamManager *scm=NULL;
static MSWebCamManager * create_manager(){
MSWebCamManager *obj=(MSWebCamManager *)ms_new(MSWebCamManager,1);
obj->cams=NULL;
obj->descs=NULL;
MSWebCamManager *obj=(MSWebCamManager *)ms_new0(MSWebCamManager,1);
return obj;
}
......@@ -99,11 +97,8 @@ void ms_web_cam_manager_reload(MSWebCamManager *m){
}
MSWebCam * ms_web_cam_new(MSWebCamDesc *desc){
MSWebCam *obj=(MSWebCam *)ms_new(MSWebCam,1);
MSWebCam *obj=(MSWebCam *)ms_new0(MSWebCam,1);
obj->desc=desc;
obj->name=NULL;
obj->data=NULL;
obj->id=NULL;
if (desc->init!=NULL)
desc->init(obj);
return obj;
......
......@@ -30,7 +30,7 @@ typedef struct VoidSourceState VoidSourceState;
static void void_source_init(MSFilter *f) {
VoidSourceState *s = (VoidSourceState *)ms_new(VoidSourceState, 1);
VoidSourceState *s = ms_new0(VoidSourceState, 1);
s->rate = 8000;
s->nchannels = 1;
f->data = s;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment