shithub: libsamplerate

Download patch

ref: ca2e559c6541a0b290771163ce94e34106845512
parent: 53ec641ecba32c3574a55c9a6560eb5f79a722f0
author: Erik de Castro Lopo <erikd@mega-nerd.com>
date: Sun Mar 11 09:46:54 EDT 2012

examples/audio_out.c : Minor tweaks to Windows and OSX code.

--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,9 @@
     Fix error message for error SRC_ERR_BAD_DATA_PTR. Thanks for oneman in
     #xiph on Freenode.
 
+    * examples/audio_out.c
+    Minor tweaks to Windows and OSX code.
+
 2011-11-05  Erik de Castro Lopo  <erikd AT mega-nerd DOT com>
 
     * src/samplerate.h
--- a/examples/audio_out.c
+++ b/examples/audio_out.c
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1999-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
+** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -610,7 +610,7 @@
 	const AudioBufferList* data_in, const AudioTimeStamp* time_in,
 	AudioBufferList* data_out, const AudioTimeStamp* time_out, void* client_data)
 {	MACOSX_AUDIO_OUT	*macosx_out ;
-	int		k, size, sample_count, read_count ;
+	int		k, size, frame_count, read_count ;
 	float	*buffer ;
 
 	if ((macosx_out = (MACOSX_AUDIO_OUT*) client_data) == NULL)
@@ -624,14 +624,14 @@
 		} ;
 
 	size = data_out->mBuffers [0].mDataByteSize ;
-	sample_count = size / sizeof (float) / macosx_out->channels ;
+	frame_count = size / sizeof (float) / macosx_out->channels ;
 
 	buffer = (float*) data_out->mBuffers [0].mData ;
 
-	read_count = macosx_out->callback (macosx_out->callback_data, buffer, sample_count) ;
+	read_count = macosx_out->callback (macosx_out->callback_data, buffer, frame_count) ;
 
-	if (read_count < sample_count)
-	{	memset (&(buffer [read_count]), 0, (sample_count - read_count) * sizeof (float)) ;
+	if (read_count < frame_count)
+	{	memset (&(buffer [read_count]), 0, (frame_count - read_count) * sizeof (float)) ;
 		macosx_out->done_playing = 1 ;
 		} ;
 
@@ -811,7 +811,7 @@
 static DWORD CALLBACK
 win32_audio_out_callback (HWAVEOUT hwave, UINT msg, DWORD data, DWORD param1, DWORD param2)
 {	WIN32_AUDIO_OUT	*win32_out ;
-	int		read_count, sample_count, k ;
+	int		read_count, frame_count, k ;
 	short	*sptr ;
 
 	/*
@@ -834,8 +834,9 @@
 
 	/* Do the actual audio. */
 	sample_count = win32_out->bufferlen ;
+	frame_count = sample_count / win32_out->channels ;
 
-	read_count = win32_out->callback (win32_out->callback_data, win32_out->float_buffer, sample_count) ;
+	read_count = win32_out->callback (win32_out->callback_data, win32_out->float_buffer, frame_count) ;
 
 	sptr = (short*) win32_out->whdr [win32_out->current].lpData ;