Skip to content

Commit

Permalink
[更新音频输出设备信息显示功能]: 在MainWindow构造函数中添加了对`Ffmpeg::printAudioOuputDevic…
Browse files Browse the repository at this point in the history
…e`的调用,以便在程序启动时打印音频输出设备信息。

- 在`mainwindow.cpp`文件中,增加了对`Ffmpeg::printAudioOuputDevice`函数的调用,以在程序启动时打印音频输出设备信息。
- 添加了注释说明`QPlatformMediaDevices`的创建和释放需要在主线程中进行,以避免程序退出时崩溃。
- 在`audiooutput.hpp`文件中,增加了`printAudioOuputDevice`函数的声明。
- 为`audiooutput.hpp`文件添加了`ffmpeg/ffmepg_global.h`头文件的包含,以支持全局定义。
  • Loading branch information
RealChuan committed Oct 9, 2024
1 parent 3579b85 commit 2b9d6e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions examples/ffmpegplayer/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <examples/common/playlistview.hpp>
#include <examples/common/qmediaplaylist.h>
#include <examples/common/titlewidget.hpp>
#include <ffmpeg/audiorender/audiooutput.hpp>
#include <ffmpeg/averror.h>
#include <ffmpeg/event/errorevent.hpp>
#include <ffmpeg/event/seekevent.hpp>
Expand Down Expand Up @@ -287,6 +288,11 @@ MainWindow::MainWindow(QWidget *parent)
{
Ffmpeg::printFfmpegInfo();

// QPlatformMediaDevices中有一个static std::unique_ptr<QPlatformMediaDevices> create();
// 这个QPlatformMediaDevices最终会在主线程释放,需要在主线程创建
// 如果在主线程创建,会导致退出程序崩溃,ASSERT: "m_threadId == GetCurrentThreadId()"
Ffmpeg::printAudioOuputDevice();

setupUI();
buildConnect();
initMenu();
Expand Down
4 changes: 4 additions & 0 deletions src/ffmpeg/audiorender/audiooutput.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef AUDIOOUTPUT_HPP
#define AUDIOOUTPUT_HPP

#include <ffmpeg/ffmepg_global.h>

#include <QAudio>
#include <QObject>

Expand All @@ -9,6 +11,8 @@ namespace Ffmpeg {
class AVContextInfo;
class Frame;

void FFMPEG_EXPORT printAudioOuputDevice();

class AudioOutput : public QObject
{
Q_OBJECT
Expand Down

0 comments on commit 2b9d6e6

Please sign in to comment.