Audio Queues

Moderator
Posts: 3,579
Joined: 2003.06
Post: #61
I've never used .amr before but the guide says AQ should work with it.

Quote:I keep having callbackForBuffer called before the file is actually done playing.
callbackForBuffer should continue to be called until just before the file is finished playing or else it won't fill the buffers with audio. You mean it keeps being called after the file is finished?

When does it freeze the device, after it should have finished? Do you have a .amr I can play with?
Quote this message in a reply
Member
Posts: 50
Joined: 2008.06
Post: #62
AnotherJake Wrote:I've never used .amr before but the guide says AQ should work with it.


callbackForBuffer should continue to be called until just before the file is finished playing or else it won't fill the buffers with audio. You mean it keeps being called after the file is finished?

When does it freeze the device, after it should have finished? Do you have a .amr I can play with?

callbackForBuffer is getting called about a couple seconds or so before the end of the file (though you're right, it could be getting called more often) with [self readPacketsIntoBuffer:buffer] == 0 and repeat is false, so postTrackFinishedPlayingNotification gets called before the file is really done playing. It seemed to be freezing when postTrackFinishedPlayingNotification called [self close], but I commented that line out and it just freezes on the line after instead.

Yeah I have an .amr I can email you to try.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #63
I tried out the .amr examples you sent (sounds like a fun project BTW Wink ), but none of them cause any problems for me whatsoever, on either the device or the simulator. I suppose it might be possible that you're using an older version of GBMusicTrack which didn't handle track endings quite as smoothly. The last revision I posted was on 8/7/08 (at the top of this thread), which was quite a while ago now so you probably have it, but I suppose it's worth mentioning. Other than that, I can't imagine why it's working perfectly for me and not you. If you are indeed using the latest version then maybe I should send you a working project so you can verify either way.
Quote this message in a reply
Nibbie
Posts: 4
Joined: 2008.11
Post: #64
Hey folks,

Here is the fix for the _SCDynamicStoreCopyConsoleUser problem Smile Enjoy! This is a fantastic bit of code!!! Thanks! Any progress on the larger framework/class yet?

http://discussions.apple.com/thread.jspa...ID=1650506

Thanks! Smile
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #65
Hey, glad you like it jrbosser, and thanks for that link! I hope that helps out others having that strange problem as well.

Quote:Any progress on the larger framework/class yet?

Sadly, no, I haven't had any time at all to sit down and work more on my little "jukebox" class for it (which was starting to turn into a larger audio engine). I started on it a while back but it just got so nasty that I scrapped it. Hopefully once I can get some of these projects off my desk I'll take another stab at it. I'm also kind of waiting to see what happens with the next iPhone OS update, because there are some serious issues (like silent switch problems relating to Audio Queues and incompatibilities with the iPod app (or iTunes, or whatever it's called)) which I hope Apple works out before I start writing more utility functionality on top of it. I'd hate to write in all the messy, hacked-up work-arounds I've come up with, only for Apple to make them unnecessary shortly thereafter.
Quote this message in a reply
Member
Posts: 50
Joined: 2008.06
Post: #66
AnotherJake Wrote:I tried out the .amr examples you sent (sounds like a fun project BTW Wink ), but none of them cause any problems for me whatsoever, on either the device or the simulator. I suppose it might be possible that you're using an older version of GBMusicTrack which didn't handle track endings quite as smoothly. The last revision I posted was on 8/7/08 (at the top of this thread), which was quite a while ago now so you probably have it, but I suppose it's worth mentioning. Other than that, I can't imagine why it's working perfectly for me and not you. If you are indeed using the latest version then maybe I should send you a working project so you can verify either way.

I have the one with the seek bit of code in it. I was hoping to use that to make a slider bar to be able to show progress and jump around. Is that possible too?

I'd love if you could send me a project that you have that works with .amr if you don't mind.
Quote this message in a reply
Nibbie
Posts: 2
Joined: 2008.11
Post: #67
Hi,

Thanks for providing your music track code. I been trying to solve the SoundEngine memory leak issue but I was unable to get anywhere with it. So I tried out your library, and got it working, but it has the same leaks as well.

Since we are out of NDA, I am using this on the iPhone, and Instruments Leaks show that when the music is stopped and started (whether using SoundEngine or GBMusicTrack), there are a bunch of leaks due to buffers not being freed.

Anyone has any ideas about this? I tried bunch of things but it seems to be something to do with the internal AudioService code.
Quote this message in a reply
Nibbie
Posts: 2
Joined: 2008.11
Post: #68
I'm realy sorry. Its 3am here and I been fighting with the memory leaks for the audio stuff, and I didn't read the thread fully. I just read it and realized others are having the same issues. Sigh. I apologize for the posting.

Time to go to sleep. I think I'll just ignore the memory leaks Sad. Sucky thing is that I play a new track every 3-4 minutes, so those memory might add up after a few hours, hehe.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #69
bruss14 Wrote:I have the one with the seek bit of code in it. I was hoping to use that to make a slider bar to be able to show progress and jump around. Is that possible too?
I don't know, I haven't played with the seek version much since I haven't had a need for it.

Quote:I'd love if you could send me a project that you have that works with .amr if you don't mind.
Sent.

DevGu Wrote:I'm realy sorry. Its 3am here and I been fighting with the memory leaks for the audio stuff, and I didn't read the thread fully. I just read it and realized others are having the same issues. Sigh. I apologize for the posting.
Hehe, don't feel bad, this thread is getting pretty long. I seriously doubt I would have read through it all myself Wink

Yes, those leaks are pretty irritating, but usually not very large.
Quote this message in a reply
Nibbie
Posts: 1
Joined: 2008.11
Post: #70
I thought this thread would be my magic answer to the "stream an mp3" question. Not yet...here's what I did, mabe someone can tell me why it failed?

I started a new blank window based application. I added an NSObject subclass to the project, named it GBMusicTrack, it made the .h file too of course. There was an import of AppKit.h, and the compiler wasn't finding it. I assumed that was maybe something replaced by Foundation or something in Cocoa, and removed the import. The project compiles without error until I add the call lines. The forum thread doesn't really say where to put those lines either, and I put them in the applicationDidFinishLaunching() method. It is this chunk that I get errors from:

Code:
GBMusicTrack *song = [[GBMusicTrack alloc] initWithPath:[[NSBundle mainBundle] pathForResource:@"WarChant" ofType:@"mp3"]];
    [song setRepeat:YES];
    [song play];

error: 'GBMusicTrack' undeclared(first use in this function)
error: 'song' undeclared(first use in this function)
Quote this message in a reply
Member
Posts: 50
Joined: 2008.06
Post: #71
AnotherJake Wrote:Hey, glad you like it jrbosser, and thanks for that link! I hope that helps out others having that strange problem as well.



Sadly, no, I haven't had any time at all to sit down and work more on my little "jukebox" class for it (which was starting to turn into a larger audio engine). I started on it a while back but it just got so nasty that I scrapped it. Hopefully once I can get some of these projects off my desk I'll take another stab at it. I'm also kind of waiting to see what happens with the next iPhone OS update, because there are some serious issues (like silent switch problems relating to Audio Queues and incompatibilities with the iPod app (or iTunes, or whatever it's called)) which I hope Apple works out before I start writing more utility functionality on top of it. I'd hate to write in all the messy, hacked-up work-arounds I've come up with, only for Apple to make them unnecessary shortly thereafter.

Thank you very much for this. Unfortunately, my computer still seems to be one that can't allow the sim to play compressed files... Oh well. I tried your project on the device and it worked great. The GBMusicTrack you used in that is pretty different from the one I grabbed from the thread. I grabbed the one that has seek stuff in it. I gave the one from your project a try in my project instead and it played the whole sound file(!) and then I got GDB: Interrupted... I'll look at it some and see what's happening now.

Edit: All I know so far is my notification receiver function hadn't been called yet that the track was done.
Quote this message in a reply
Member
Posts: 50
Joined: 2008.06
Post: #72
bruss14 Wrote:Thank you very much for this. Unfortunately, my computer still seems to be one that can't allow the sim to play compressed files... Oh well. I tried your project on the device and it worked great. The GBMusicTrack you used in that is pretty different from the one I grabbed from the thread. I grabbed the one that has seek stuff in it. I gave the one from your project a try in my project instead and it played the whole sound file(!) and then I got GDB: Interrupted... I'll look at it some and see what's happening now.

Edit: All I know so far is my notification receiver function hadn't been called yet that the track was done.

Okay, so far I have it narrowed to that postNotifiactName is getting called on the defaultCenter in postTrackFinishedPlayingNotification() in GBMusicTrack and then it gets the Interrupted before my listener gets that notification.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #73
limitedwave Wrote:I thought this thread would be my magic answer to the "stream an mp3" question. Not yet...here's what I did, mabe someone can tell me why it failed?

I started a new blank window based application. I added an NSObject subclass to the project, named it GBMusicTrack, it made the .h file too of course. There was an import of AppKit.h, and the compiler wasn't finding it. I assumed that was maybe something replaced by Foundation or something in Cocoa, and removed the import. The project compiles without error until I add the call lines. The forum thread doesn't really say where to put those lines either, and I put them in the applicationDidFinishLaunching() method. It is this chunk that I get errors from:

Code:
GBMusicTrack *song = [[GBMusicTrack alloc] initWithPath:[[NSBundle mainBundle] pathForResource:@"WarChant" ofType:@"mp3"]];
    [song setRepeat:YES];
    [song play];

error: 'GBMusicTrack' undeclared(first use in this function)
error: 'song' undeclared(first use in this function)

That should work just fine, and putting it in applicationDidFinishLaunching is fine too. You can put those lines anywhere.

If you're building for iPhone, you'll need to replace the appkit include with
#import <UIKit/UIKit.h> instead. In you app delegate you'll need to be sure to do #import "GBMusicTrack.h" at the top somewhere.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #74
bruss14 Wrote:Okay, so far I have it narrowed to that postNotifiactName is getting called on the defaultCenter in postTrackFinishedPlayingNotification() in GBMusicTrack and then it gets the Interrupted before my listener gets that notification.

Hmm... That's weird, for sure. You are trying to receive the notification on the main thread, correct?

[Adding] Are you sure that the receiver of the notification still exists? Was it released by a memory warning without your knowledge? You should check to be certain, otherwise it would surely crash.
Quote this message in a reply
Member
Posts: 50
Joined: 2008.06
Post: #75
AnotherJake Wrote:Hmm... That's weird, for sure. You are trying to receive the notification on the main thread, correct?

[Adding] Are you sure that the receiver of the notification still exists? Was it released by a memory warning without your knowledge? You should check to be certain, otherwise it would surely crash.

Yeah, I had that thought too.. I commented out the line where my class adds as a listener and then it doesn't crash. My app then (obviously) doesn't know the track is done playing and so the play animation continues. Then, after a small amount of time (20 seconds or so), The app closes and XCode tells me that the app closed normally.

Edit: Ug, never mind on the crashing anyway when that line is commented out. It only crashes if my class adds itself as a listener. I have a UIViewController that has an instance of my class that is the one controlling GBMusicTrack. Though now that I type all that out, I can probably just simplify and remove that class since it was there before my switch to GBMusicTrack... I'll give that a try and see what happens.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Core Audio mutlichannel audio tachyon 2 6,380 Mar 18, 2005 01:04 AM
Last Post: tachyon