Re: Trouble with AudioDeviceGetCurrentTime....
Re: Trouble with AudioDeviceGetCurrentTime....
- Subject: Re: Trouble with AudioDeviceGetCurrentTime....
- From: Jeff Moore <email@hidden>
- Date: Mon, 29 Nov 2004 12:38:48 -0800
In the cited code, the local variable, this_time, doesn't appear to be getting initialized before it gets passed to AudioDeviceGetCurrentTime(). Consequently, it is likely to be at best a memory smasher and at worst a direct crash when the HAL tries to write to the fields of the non-existant time stamp structure.
Note that in addition to passing a pointer to a valid AudioTimeStamp structure, you also need to initialize the mFlags field of that structure to indicate how you want the current time given to you.
On Nov 28, 2004, at 5:10 PM, Rob Frohne wrote:
An addendum to my note with the errors of MallocDebug in case anyone has any ideas about that. Here it is.
[Session started at 2004-11-28 17:04:51 -0800.]
dyld: /Users/frohro/Documents/gwc-0.20-07/build/gwc multiple definitions of symbol _xdg_mime_shutdown
/sw/lib/libgnomevfs-2.0.dylib(xdgmime.o) definition of _xdg_mime_shutdown
/sw/lib/libgtk-x11-2.0.0.dylib(xdgmime.o) definition of _xdg_mime_shutdown
Thanks,
Rob
On Nov 28, 2004, at 3:50 PM, Rob Frohne wrote:
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. If I uncomment it, I get following crash log in the console.
Running…
before start_playback
After start_playback
After playback timer
after cursor timer
Start time is: -2125352296
start_sample_time is: 644517148.000000
Reading memory from the sp at: bfffe8f0
Reading memory from the sp at: bfffe8f0
Reading memory from the sp at: bfffe8f0
(gdb) continue
This time is: -2125348327
play_back_position from gettimeofday is: 698720
num_processes is: 1
Program received signal: "EXC_BAD_ACCESS".
Unable to disassemble ??.
(gdb)
I'm rather new at this. I was unable to launch MallocDebug, because it complained about some duplicate symbols in gtk or something like that.
Any ideas?
Thanks,
Rob
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", (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) / //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.
--
Rob Frohne, Ph.D., P.E.
E.F. Cross School of Engineering
Walla Walla College
http://www.wwc.edu/~frohro/ _______________________________________________
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
--
Rob Frohne, Ph.D., P.E.
E.F. Cross School of Engineering
Walla Walla College
http://www.wwc.edu/~frohro/
_______________________________________________
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
<x-tad-smaller>-- </x-tad-smaller>
<x-tad-smaller>Jeff Moore</x-tad-smaller>
<x-tad-smaller>Core Audio</x-tad-smaller>
<x-tad-smaller>Apple
</x-tad-smaller>
_______________________________________________
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