comparison libao2/ao_macosx.c @ 25290:2502d1944968

Remove useless variable aoIsCreated since we took good care of init failure.
author ulion
date Sat, 08 Dec 2007 02:57:50 +0000
parents 7055944e3ce9
children 57dc7e8e7e82
comparison
equal deleted inserted replaced
25289:4bbc9ad3124c 25290:2502d1944968
294 Component comp; 294 Component comp;
295 AURenderCallbackStruct renderCallback; 295 AURenderCallbackStruct renderCallback;
296 OSStatus err; 296 OSStatus err;
297 UInt32 size, maxFrames, i_param_size; 297 UInt32 size, maxFrames, i_param_size;
298 char *psz_name; 298 char *psz_name;
299 int aoIsCreated = ao != NULL;
300 AudioDeviceID devid_def = 0; 299 AudioDeviceID devid_def = 0;
301 int b_alive; 300 int b_alive;
302 301
303 ao_msg(MSGT_AO,MSGL_V, "init([%dHz][%dch][%s][%d])\n", rate, channels, af_fmt2str_short(format), flags); 302 ao_msg(MSGT_AO,MSGL_V, "init([%dHz][%dch][%s][%d])\n", rate, channels, af_fmt2str_short(format), flags);
304 303
305 if (!aoIsCreated) { ao = malloc(sizeof(ao_macosx_t)); ao->buffer = NULL;} 304 ao = calloc(1, sizeof(ao_macosx_t));
306 305
307 ao->i_selected_dev = 0; 306 ao->i_selected_dev = 0;
308 ao->b_supports_digital = 0; 307 ao->b_supports_digital = 0;
309 ao->b_digital = 0; 308 ao->b_digital = 0;
310 ao->b_muted = 0; 309 ao->b_muted = 0;
495 ao_data.outburst = ao->chunk_size; 494 ao_data.outburst = ao->chunk_size;
496 ao_data.buffersize = ao_data.bps; 495 ao_data.buffersize = ao_data.bps;
497 496
498 ao->num_chunks = (ao_data.bps+ao->chunk_size-1)/ao->chunk_size; 497 ao->num_chunks = (ao_data.bps+ao->chunk_size-1)/ao->chunk_size;
499 ao->buffer_len = (ao->num_chunks + 1) * ao->chunk_size; 498 ao->buffer_len = (ao->num_chunks + 1) * ao->chunk_size;
500 ao->buffer = aoIsCreated ? realloc(ao->buffer,(ao->num_chunks + 1)*ao->chunk_size) 499 ao->buffer = calloc(ao->num_chunks + 1, ao->chunk_size);
501 : calloc(ao->num_chunks + 1, ao->chunk_size);
502 500
503 ao_msg(MSGT_AO,MSGL_V, "using %5d chunks of %d bytes (buffer len %d bytes)\n", (int)ao->num_chunks, (int)ao->chunk_size, (int)ao->buffer_len); 501 ao_msg(MSGT_AO,MSGL_V, "using %5d chunks of %d bytes (buffer len %d bytes)\n", (int)ao->num_chunks, (int)ao->chunk_size, (int)ao->buffer_len);
504 502
505 renderCallback.inputProc = theRenderProc; 503 renderCallback.inputProc = theRenderProc;
506 renderCallback.inputProcRefCon = 0; 504 renderCallback.inputProcRefCon = 0;
740 ao_data.outburst = ao->chunk_size; 738 ao_data.outburst = ao->chunk_size;
741 ao_data.buffersize = ao_data.bps; 739 ao_data.buffersize = ao_data.bps;
742 740
743 ao->num_chunks = (ao_data.bps+ao->chunk_size-1)/ao->chunk_size; 741 ao->num_chunks = (ao_data.bps+ao->chunk_size-1)/ao->chunk_size;
744 ao->buffer_len = (ao->num_chunks + 1) * ao->chunk_size; 742 ao->buffer_len = (ao->num_chunks + 1) * ao->chunk_size;
745 ao->buffer = NULL!=ao->buffer ? realloc(ao->buffer,(ao->num_chunks + 1)*ao->chunk_size) 743 ao->buffer = calloc(ao->num_chunks + 1, ao->chunk_size);
746 : calloc(ao->num_chunks + 1, ao->chunk_size);
747 744
748 ao_msg(MSGT_AO,MSGL_V, "using %5d chunks of %d bytes (buffer len %d bytes)\n", (int)ao->num_chunks, (int)ao->chunk_size, (int)ao->buffer_len); 745 ao_msg(MSGT_AO,MSGL_V, "using %5d chunks of %d bytes (buffer len %d bytes)\n", (int)ao->num_chunks, (int)ao->chunk_size, (int)ao->buffer_len);
749 746
750 747
751 /* Add IOProc callback. */ 748 /* Add IOProc callback. */