• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Trouble with AudioDeviceGetCurrentTime....
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trouble with AudioDeviceGetCurrentTime....


  • Subject: Re: Trouble with AudioDeviceGetCurrentTime....
  • From: Brian Kelly <email@hidden>
  • Date: Mon, 29 Nov 2004 08:32:12 -0800

Hi All,

I need to get the number of bytes processed, and would like to use the AudioDeviceGetCurrentTime() function to do it. I'm having trouble with it though. If I comment out the call to AudioDeviceGetCurrentTime() below, it works.


<snip>

long audio_device_processed_bytes(void)
{
	struct timeval this;
    static long multiplier = 176;
	AudioTimeStamp* this_time;
	OSStatus err;
	UInt32 num_processes;
	UInt32		count;

	gettimeofday(&this, &tz);

	/*if (multiplier == 0)
	{
		multiplier = audio_data.sfinfo.samplerate*FRAMESIZE;
	}*/

printf("This time is: %ld\n", (long)(1000*this.tv_sec + this.tv_usec/1000.));
playback_position =
multiplier*((this.tv_sec - playback_start_time.tv_sec)*1000 + (this.tv_usec -



playback_start_time.


tv_usec) / 1000);//Have to scale it this way so the longs don't overflow.
printf("play_back_position from gettimeofday is: %ld\n",playback_position);
//usleep(1000);
count = sizeof(UInt32);
if ((err = AudioDeviceGetProperty (audio_data.device, 0, false, kAudioDevicePropertyDeviceIsRunning,


&count, &num_processes)) != noErr)
{ printf ("AudioDeviceGetProperty (AudioDeviceGetProperty) failed. The device probably isn't running.\n") ;
return -1;
}
else
{
printf("num_processes is: %ld\n",num_processes);
if((err = AudioDeviceGetCurrentTime(audio_data.device, this_time)) != noErr)
{
printf("Could not get the current time. The error number is: %ld \n",err);
//return playback_position;
}
else
{
printf("this_time - start_sample_time = %ld\n",(long) (this_time->mSampleTime - start_sample_time));
}
//playback_position = (long) (this_time->mSampleTime - start_sample_time);
}
return playback_position;
} // This is used to set the cursor. We need to make this return a number controlled by a timer.



--


Your this_time variable is a pointer to an AudioTimeStamp, but you never allocate the struct.
Does AudioDeviceGetCurrentTime allocate it for you?
Otherwise you're trampling memory, which is never good.


Cheers,
Brian
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Trouble with AudioDeviceGetCurrentTime.... (From: Rob Frohne <email@hidden>)

  • Prev by Date: Re: Can I get hook a renderproc on a filter in an AUGraph?
  • Next by Date: Re: Callbacks in an AUGraph induced state
  • Previous by thread: Re: Trouble with AudioDeviceGetCurrentTime....
  • Next by thread: Callbacks in an AUGraph induced state
  • Index(es):
    • Date
    • Thread