使用 MPMoviePlayerViewController iOS 4.2 时,AudioToolbox 导致 iPhone 内存泄漏

发布于 2024-10-18 12:19:44 字数 798 浏览 4 评论 0原文

我使用以下代码(在选项卡栏应用程序的视图控制器内)在用户选择表行后播放从主包加载的视频。

- (void)loadMoviePlayer:(NSString*)moviePath
{
    NSURL* fileURL    =   [[NSURL alloc] initFileURLWithPath:moviePath];

    MPMoviePlayerViewController* player = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];
    [fileURL release];

    [self presentMoviePlayerViewControllerAnimated:player];
    [player release];
}

该应用程序在模拟器中构建和运行时没有任何明显问题(我尚未在设备上进行测试),但当我通过 Instruments 运行它时,视频播放期间会发生内存泄漏。 Instruments 将 AudioToolbox 突出显示为“负责任的库”,并且 SimAggregateDevice::SimAggregateDevice(_CFString const*, _CFString const*, long&)

APComponent::CreateDispatchTable(AudioComponentPluginInterface*, unsigned long)

作为“责任框架”。

如果您能对此有所了解,我们将不胜感激! 谢谢。

I'm using the following code (inside a view controller in a tab bar application) to play video loaded from the main bundle after a user selects a table row.

- (void)loadMoviePlayer:(NSString*)moviePath
{
    NSURL* fileURL    =   [[NSURL alloc] initFileURLWithPath:moviePath];

    MPMoviePlayerViewController* player = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];
    [fileURL release];

    [self presentMoviePlayerViewControllerAnimated:player];
    [player release];
}

The app builds and runs without any obvious problems in the simulator (I haven't tested on a device yet) but when I run it through Instruments a memory leak occurs during video playback.
Instruments highlights the AudioToolbox as the 'Responsible Library' and SimAggregateDevice::SimAggregateDevice(_CFString const*, _CFString const*, long&)
and

APComponent::CreateDispatchTable(AudioComponentPluginInterface*, unsigned long)

as the 'Responsible Frame(s)'.

Any light you can shed on this would be much appreciated!
Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

残龙傲雪 2024-10-25 12:19:44

您还可以为 iPhone 和 iPad 的电影播放器​​创建自己的自定义控件,您可以在其中创建自定义音量管理,并且可以管理很多事情。

以下方法启动电影播放器​​。用于管理 mov

-(void)initAndPlayMovie:(NSURL *)movieURL andViewController:(UIViewController*)vCtr
{
    self.mPlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
    // we have movie from file - Alizee :)
    [self.mPlayer.moviePlayer setMovieSourceType:MPMovieSourceTypeFile];

    // we don't need standard controlls as we have built our own
    [self.mPlayer.moviePlayer setControlStyle:MPMovieControlStyleNone];

    // aspect fit to screen  mode
    [self.mPlayer.moviePlayer setScalingMode:MPMovieScalingModeAspectFit];

    // full screen mode
    [self.mPlayer.moviePlayer setFullscreen:YES animated:YES];

    // to start movie player
    [vCtr presentMoviePlayerViewControllerAnimated:self.mPlayer];

    // now we will add our own view over video player
    self.vCtr.view.frame=CGRectMake(0, 20, self.window.frame.size.width, self.window.frame.size.height-20);

    [self.mPlayer.view addSubview:self.vCtr.view];
}

- (void)stopTapped:(id)sender{
    [self.mPlayer.moviePlayer stop];
}

-(void)moviePlayBackDidFinish:(NSNotification*)notification
{
    [self.mPlayer dismissMoviePlayerViewControllerAnimated];
    [self.vCtr.view removeFromSuperview];
}

You can create you own custom control for the movie player for iPhone and iPad also, where you can create custom volume management and so many things can manage.

Following method to start moview player. for manage the mov

-(void)initAndPlayMovie:(NSURL *)movieURL andViewController:(UIViewController*)vCtr
{
    self.mPlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
    // we have movie from file - Alizee :)
    [self.mPlayer.moviePlayer setMovieSourceType:MPMovieSourceTypeFile];

    // we don't need standard controlls as we have built our own
    [self.mPlayer.moviePlayer setControlStyle:MPMovieControlStyleNone];

    // aspect fit to screen  mode
    [self.mPlayer.moviePlayer setScalingMode:MPMovieScalingModeAspectFit];

    // full screen mode
    [self.mPlayer.moviePlayer setFullscreen:YES animated:YES];

    // to start movie player
    [vCtr presentMoviePlayerViewControllerAnimated:self.mPlayer];

    // now we will add our own view over video player
    self.vCtr.view.frame=CGRectMake(0, 20, self.window.frame.size.width, self.window.frame.size.height-20);

    [self.mPlayer.view addSubview:self.vCtr.view];
}

- (void)stopTapped:(id)sender{
    [self.mPlayer.moviePlayer stop];
}

-(void)moviePlayBackDidFinish:(NSNotification*)notification
{
    [self.mPlayer dismissMoviePlayerViewControllerAnimated];
    [self.vCtr.view removeFromSuperview];
}
伪心 2024-10-25 12:19:44

问题不在于“模拟器”本身,而在于 AVFoundation
为 Mac OS X 编译的框架。 – Alex Nichol,2011 年 8 月 17 日 23:53

我将 Alex 的评论设置为可接受的答案。 K

The problem isn't the "simulator" itself, but rather the AVFoundation
framework compiled for Mac OS X. – Alex Nichol Aug 17 '11 at 23:53

I'm setting this comment by Alex as the accepted answer. K

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文