comparison src/audacious/output.c @ 4186:833e5faa5847

Make sample rate conversion work with mono files. (Bugzilla #88)
author William Pitcock <nenolod@atheme.org>
date Sat, 12 Jan 2008 06:39:56 -0600
parents bf5c5dea45dc
children b3e82a1eb129 b293ce14a01a
comparison
equal deleted inserted replaced
4185:d52fe5ff19a4 4186:833e5faa5847
435 } 435 }
436 436
437 #ifdef USE_SRC 437 #ifdef USE_SRC
438 if(src_state != NULL&&length > 0) 438 if(src_state != NULL&&length > 0)
439 { 439 {
440 int lrLength = length/2; 440 int lrLength = length / nch;
441 int overLrLength = (int)floor(lrLength*(src_data.src_ratio+1)); 441 int overLrLength = (int)floor(lrLength*(src_data.src_ratio+1));
442 if(lengthOfSrcIn < lrLength) 442 if(lengthOfSrcIn < lrLength)
443 { 443 {
444 lengthOfSrcIn = lrLength; 444 lengthOfSrcIn = lrLength;
445 free(srcIn); 445 free(srcIn);
455 } 455 }
456 src_short_to_float_array((short int*)ptr, srcIn, lrLength); 456 src_short_to_float_array((short int*)ptr, srcIn, lrLength);
457 src_data.data_in = srcIn; 457 src_data.data_in = srcIn;
458 src_data.data_out = srcOut; 458 src_data.data_out = srcOut;
459 src_data.end_of_input = 0; 459 src_data.end_of_input = 0;
460 src_data.input_frames = lrLength/2; 460 src_data.input_frames = lrLength / nch;
461 src_data.output_frames = overLrLength/2; 461 src_data.output_frames = overLrLength / nch;
462 if ((srcError = src_process(src_state, &src_data)) > 0) 462 if ((srcError = src_process(src_state, &src_data)) > 0)
463 { 463 {
464 fprintf(stderr, "src_process(): %s\n", src_strerror(srcError)); 464 fprintf(stderr, "src_process(): %s\n", src_strerror(srcError));
465 } 465 }
466 else 466 else
467 { 467 {
468 src_float_to_short_array(srcOut, wOut, src_data.output_frames_gen*2); 468 src_float_to_short_array(srcOut, wOut, src_data.output_frames_gen*2);
469 ptr = wOut; 469 ptr = wOut;
470 length = src_data.output_frames_gen*4; 470 length = src_data.output_frames_gen * (nch * 2);
471 } 471 }
472 } 472 }
473 #endif 473 #endif
474 474
475 length = flow_execute(postproc_flow, time, &ptr, length, op_state.fmt, op_state.rate, op_state.nch); 475 length = flow_execute(postproc_flow, time, &ptr, length, op_state.fmt, op_state.rate, op_state.nch);