Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gstreamer based audioplayers plugin #277

Merged
merged 16 commits into from
Aug 25, 2022

Conversation

DoumanAsh
Copy link
Contributor

@DoumanAsh DoumanAsh commented Aug 21, 2022

This a bit update implementation that we used in our machines.
I have a bit of concern on how dispose is supposed to work, but otherwise it is complete

It unites video and audio into single option as both depend on gstreamer

CC @laynor

Copy link
Owner

@ardera ardera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just some styling changes to stay consistent with the rest of flutter-pi.

src/plugins/audioplayers/player.c Outdated Show resolved Hide resolved
src/plugins/audioplayers/player.c Outdated Show resolved Hide resolved
src/plugins/audioplayers/player.c Outdated Show resolved Hide resolved
src/plugins/audioplayers/player.c Outdated Show resolved Hide resolved
src/plugins/audioplayers/player.c Outdated Show resolved Hide resolved
src/plugins/audioplayers/plugin.c Outdated Show resolved Hide resolved
src/plugins/audioplayers/plugin.c Outdated Show resolved Hide resolved
src/plugins/audioplayers/plugin.c Outdated Show resolved Hide resolved
@ardera
Copy link
Owner

ardera commented Aug 21, 2022

Ideally the existing gstreamer player could be modified to support audio and then this plugin could just use that. But I think this is fine for now

@ardera
Copy link
Owner

ardera commented Aug 21, 2022

This is my .clang-format file btw:

# SPDX-License-Identifier: MIT
#
# For more information, see:
#
#   Documentation/process/clang-format.rst
#   https://clang.llvm.org/docs/ClangFormat.html
#   https://clang.llvm.org/docs/ClangFormatStyleOptions.html
#
---
AccessModifierOffset: -4
AlignAfterOpenBracket: BlockIndent
#AlignArrayOfStructures: Right
AlignConsecutiveAssignments: false
#AlignConsecutiveBitFields: false
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
#AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
#AllowShortLambdasOnASingleLine: None
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: false
AttributeMacros:
  - 'MAYBE_UNUSED'
  - 'ATTR_MALLOC'
  - 'NONNULL'
  - 'ATTR_PURE'
  - 'ATTR_CONST'

BinPackArguments: false
BinPackParameters: false
BraceWrapping:
  AfterClass: false
  AfterControlStatement: false
  AfterEnum: false
  AfterFunction: true
  AfterNamespace: true
  AfterObjCDeclaration: false
  AfterStruct: true
  AfterUnion: true
  AfterExternBlock: false
  BeforeCatch: false
  BeforeElse: false
  IndentBraces: false
  SplitEmptyFunction: true
  SplitEmptyRecord: true
  SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
AlwaysBreakBeforeMultilineStrings: true
ColumnLimit: 140
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 8
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
#ExperimentalAutoDetectBinPacking: true
FixNamespaceComments: false
ForEachMacros:
  - 'for_each_pointer_in_pset'
  - 'for_each_pointer_in_cpset'
  - 'for_each_connector_in_drmdev'
  - 'for_each_encoder_in_drmdev'
  - 'for_each_crtc_in_drmdev'
  - 'for_each_plane_in_drmdev'
  - 'for_each_mode_in_connector'
  - 'for_each_unreserved_plane_in_atomic_req'

IncludeBlocks: Regroup
IncludeCategories:
  # C standard library headers
  - Regex: '^<(assert|complex|ctype|errno|fenv|float|inttypes|iso646|limits|locale|math|setjmp|signal|stdalign|stdarg|stdatomic|stdbool|stddef|stdint|stdio|stdlib|stdnoreturn|string|tgmath|threads|time|uchar|wchar|wctype)\.h>$'
    Priority: 1
  - Regex: '^<(ctype|dlfcn|fcntl|glob|limits|locale|poll|pthread|regex|semaphore|unistd|sys/mman|sys/stat|sys/types)\.h>$'
    Priority: 2
  - Regex: '^<(elf|features|getopt|langinfo)\.h>$'
    Priority: 3
  - Regex: '^<(linux/[^.]*|sys/eventfd)\.h>$'
    Priority: 4
  - Regex: '^<(plugins/[^.]*|backing_store[^.]*|collection|compositor_ng|cursor|dmabuf_surface|egl_info|egl|flutter-pi|gbm_surface_backing_store|gl_renderer|gles|jsmn|keyboard|locales|modesetting|notifier_listener|pixel_format|platform_view|platformchannel|pluginregistry|surface[^.]*|texture_registry|tracer|user_input|vk_gbm_backing_store|vk_renderer)\.h>$'
    Priority: 6
  - Regex: '.*'
    Priority: 5

IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: true
IndentGotoLabels: false
IndentPPDirectives: BeforeHash
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 8
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true

PenaltyBreakAssignment: 60
PenaltyBreakBeforeFirstCallParameter: 0
PenaltyBreakComment: 10
PenaltyBreakFirstLessLess: 0
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 0
PenaltyExcessCharacter: 100
PenaltyReturnTypeOnItsOwnLine: 60

PointerAlignment: Right
ReflowComments: false
SortIncludes: CaseInsensitive
SortUsingDeclarations: false
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatementsExceptForEachMacros
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix:
  Minimum: 1
  Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp03
StatementMacros:
  - 'DECLARE_REF_OPS'
  - 'DEFINE_REF_OPS'
  - 'DEFINE_STATIC_REF_OPS'
  - 'DECLARE_LOCK_OPS'
  - 'DEFINE_LOCK_OPS'
  - 'DEFINE_STATIC_LOCK_OPS'
  - 'DEFINE_INLINE_LOCK_OPS'
  - 'UUID'
  - 'CONST_UUID'
TabWidth: 4
TypenameMacros:
  - 'BMAP_ELEMENT_TYPE'
  - 'MAX_ALIGNMENT'
UseTab: Never

@DoumanAsh
Copy link
Contributor Author

@ardera I applied comments and clang format using your config

@DoumanAsh DoumanAsh force-pushed the plugin_audioplayers branch from f65fc14 to c733a49 Compare August 22, 2022 12:48
.github/workflows/cmake.yml Outdated Show resolved Hide resolved
include/plugins/audioplayers.h Outdated Show resolved Hide resolved
include/plugins/audioplayers.h Outdated Show resolved Hide resolved
.github/workflows/cmake.yml Outdated Show resolved Hide resolved
src/plugins/audioplayers/player.c Outdated Show resolved Hide resolved
src/plugins/audioplayers/player.c Outdated Show resolved Hide resolved
src/plugins/audioplayers/player.c Show resolved Hide resolved
src/plugins/audioplayers/plugin.c Outdated Show resolved Hide resolved
src/plugins/audioplayers/plugin.c Outdated Show resolved Hide resolved
src/plugins/audioplayers/plugin.c Outdated Show resolved Hide resolved
@DoumanAsh
Copy link
Contributor Author

I applied second round of comments.
Thanks for review

@ardera
Copy link
Owner

ardera commented Aug 22, 2022

@DoumanAsh btw, are you applying the suggestions directly? Because I'm writing them that way so you can just click "commit suggestion"

@DoumanAsh
Copy link
Contributor Author

@DoumanAsh btw, are you applying the suggestions directly? Because I'm writing them that way so you can just click "commit suggestion"

Yeah, I didn't notice at first but even still github UI is not really convenient to do it as some changes require consideration (lik e renaming of function etc).
But in most cases I just copy your suggestion as it is, except few places that doesn't work and need fixes

Copy link
Owner

@ardera ardera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, I think after these comments it should be fine

src/plugins/audioplayers/player.c Outdated Show resolved Hide resolved
src/plugins/audioplayers/player.c Outdated Show resolved Hide resolved
src/plugins/audioplayers/player.c Show resolved Hide resolved
src/plugins/audioplayers/plugin.c Outdated Show resolved Hide resolved
src/plugins/audioplayers/plugin.c Outdated Show resolved Hide resolved
src/plugins/audioplayers/plugin.c Outdated Show resolved Hide resolved
src/plugins/audioplayers/plugin.c Outdated Show resolved Hide resolved
src/plugins/audioplayers/plugin.c Outdated Show resolved Hide resolved
src/plugins/audioplayers/plugin.c Outdated Show resolved Hide resolved
@ardera
Copy link
Owner

ardera commented Aug 24, 2022

Yeah, I didn't notice at first but even still github UI is not really convenient to do it as some changes require consideration (lik e renaming of function etc).

Ah okay, yeah then it's probably better to only use suggestions when you can apply them directly

@DoumanAsh
Copy link
Contributor Author

@ardera
I applied all comments, and added some extra error checks when we cannot allocate player and local_url memory

Copy link
Owner

@ardera ardera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ardera
Copy link
Owner

ardera commented Aug 25, 2022

Ah wait, forgot one thing. meta-flutter depends on the name of the build arg being BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN. So we should probably make the audio player plugin a separate build option.

@DoumanAsh
Copy link
Contributor Author

Oh I see... it is a bit of pain, should we make them completely independent features then?

CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Show resolved Hide resolved
@ardera
Copy link
Owner

ardera commented Aug 25, 2022

@DoumanAsh Last comments, I swear :p
It should not be too complicated to make them independent IMO. If you don't feel too comfortable in Cmake I can also make the changes myself and we merge it into develop for now or something

@DoumanAsh
Copy link
Contributor Author

DoumanAsh commented Aug 25, 2022

@ardera I reworked to make them independent.
And actually compiler is perfectly fine feeding multiple repetitions of libs/includes so I didn't add branch when both video and audio enabled together.
I tested build with video disabled and audio enabled, vice verse and when both are enabled

But please take a look yourself and test it too maybe to be sure

Copy link
Owner

@ardera ardera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ardera ardera merged commit fb8e61b into ardera:master Aug 25, 2022
@DoumanAsh DoumanAsh deleted the plugin_audioplayers branch August 25, 2022 23:50
@Taha-Firoz
Copy link

Could we also have a simpler/light weight plugin based on miniaudio since it's a header only library and can cross compile very well. I've already written a very small poc plugin for flutter-elinux

@ardera
Copy link
Owner

ardera commented Sep 2, 2022

@Taha-Firoz A 3.68MB header-only library :)
I think miniaudio is a good choice as well, but I'd still prefer gstreamer

@DoumanAsh
Copy link
Contributor Author

Choice of gstreamer is really mostly because existing audioplayers plugin use it, not to mention flutter-pi also rely on it for video.

@Taha-Firoz
Copy link

😅 I think it'll get pretty small after compilation, it contains a lot of code to make it cross compile to almost every platform(ios, windows, android etc.), but I'm not sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants